mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-05 08:53:08 +02:00
refactor: migrate to ESM
This commit is contained in:
parent
b9a81edae5
commit
1de29e5566
7 changed files with 45 additions and 24 deletions
|
@ -101,11 +101,6 @@ export function getConfig(): UserConfig {
|
|||
__VUE_PROD_DEVTOOLS__: false,
|
||||
},
|
||||
|
||||
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
|
||||
optimizeDeps: {
|
||||
include: ['misskey-js', 'misskey-reversi', 'misskey-bubble-game'],
|
||||
},
|
||||
|
||||
build: {
|
||||
target: [
|
||||
'chrome116',
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "misskey-bubble-game",
|
||||
"version": "0.0.1",
|
||||
"main": "./built/index.js",
|
||||
"types": "./built/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./built/esm/index.js",
|
||||
"types": "./built/dts/index.d.ts"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./built/esm/*",
|
||||
"types": "./built/dts/*"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "npm run ts",
|
||||
"ts": "npm run ts-esm && npm run ts-dts",
|
||||
"ts-esm": "tsc --outDir built/esm",
|
||||
"ts-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
|
||||
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"",
|
||||
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
||||
"typecheck": "tsc --noEmit",
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "misskey-js",
|
||||
"version": "0.0.16",
|
||||
"description": "Misskey SDK for JavaScript",
|
||||
"main": "./built/index.js",
|
||||
"types": "./built/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./built/esm/index.js",
|
||||
"types": "./built/dts/index.d.ts"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./built/esm/*",
|
||||
"types": "./built/dts/*"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "npm run ts",
|
||||
"ts": "npm run ts-esm && npm run ts-dts",
|
||||
"ts-esm": "tsc --outDir built/esm",
|
||||
"ts-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
|
||||
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"",
|
||||
"tsd": "tsd",
|
||||
"api": "pnpm api-extractor run --local --verbose",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import './autogen/apiClientJSDoc';
|
||||
import './autogen/apiClientJSDoc.js';
|
||||
|
||||
import { SwitchCaseResponseType } from './api.types';
|
||||
import type { Endpoints } from './api.types';
|
||||
import { SwitchCaseResponseType } from './api.types.js';
|
||||
import type { Endpoints } from './api.types.js';
|
||||
|
||||
export {
|
||||
SwitchCaseResponseType,
|
||||
} from './api.types';
|
||||
} from './api.types.js';
|
||||
|
||||
const MK_API_ERROR = Symbol();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Endpoints as Gen } from './autogen/endpoint';
|
||||
import { UserDetailed } from './autogen/models';
|
||||
import { UsersShowRequest } from './autogen/entities';
|
||||
import { Endpoints as Gen } from './autogen/endpoint.js';
|
||||
import { UserDetailed } from './autogen/models.js';
|
||||
import { UsersShowRequest } from './autogen/entities.js';
|
||||
import {
|
||||
SigninRequest,
|
||||
SigninResponse,
|
||||
|
@ -8,7 +8,7 @@ import {
|
|||
SignupPendingResponse,
|
||||
SignupRequest,
|
||||
SignupResponse,
|
||||
} from './entities';
|
||||
} from './entities.js';
|
||||
|
||||
type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit<
|
||||
T,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { ModerationLogPayloads } from './consts.js';
|
||||
import { Announcement, EmojiDetailed, MeDetailed, MeDetailedOnly, Page, User, UserDetailed } from './autogen/models';
|
||||
import { Announcement, EmojiDetailed, MeDetailed, MeDetailedOnly, Page, User, UserDetailed } from './autogen/models.js';
|
||||
|
||||
export * from './autogen/entities';
|
||||
export * from './autogen/models';
|
||||
export * from './autogen/entities.js';
|
||||
export * from './autogen/models.js';
|
||||
|
||||
export type ID = string;
|
||||
export type DateString = string;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { EventEmitter } from 'eventemitter3';
|
||||
import ReconnectingWebsocket from 'reconnecting-websocket';
|
||||
import _ReconnectingWebsocket from 'reconnecting-websocket';
|
||||
import type { BroadcastEvents, Channels } from './streaming.types.js';
|
||||
|
||||
const ReconnectingWebsocket = _ReconnectingWebsocket as unknown as typeof _ReconnectingWebsocket['default'];
|
||||
|
||||
export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string {
|
||||
const params = Object.entries(obj)
|
||||
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
||||
|
@ -24,7 +26,7 @@ type StreamEvents = {
|
|||
* Misskey stream connection
|
||||
*/
|
||||
export default class Stream extends EventEmitter<StreamEvents> {
|
||||
private stream: ReconnectingWebsocket;
|
||||
private stream: _ReconnectingWebsocket.default;
|
||||
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
|
||||
private sharedConnectionPools: Pool[] = [];
|
||||
private sharedConnections: SharedConnection[] = [];
|
||||
|
|
Loading…
Reference in a new issue