mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-15 05:05:42 +01: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,
|
__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: {
|
build: {
|
||||||
target: [
|
target: [
|
||||||
'chrome116',
|
'chrome116',
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
{
|
{
|
||||||
|
"type": "module",
|
||||||
"name": "misskey-bubble-game",
|
"name": "misskey-bubble-game",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "./built/index.js",
|
"exports": {
|
||||||
"types": "./built/index.d.ts",
|
".": {
|
||||||
|
"import": "./built/esm/index.js",
|
||||||
|
"types": "./built/dts/index.d.ts"
|
||||||
|
},
|
||||||
|
"./*": {
|
||||||
|
"import": "./built/esm/*",
|
||||||
|
"types": "./built/dts/*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"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\"",
|
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"",
|
||||||
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
{
|
{
|
||||||
|
"type": "module",
|
||||||
"name": "misskey-js",
|
"name": "misskey-js",
|
||||||
"version": "0.0.16",
|
"version": "0.0.16",
|
||||||
"description": "Misskey SDK for JavaScript",
|
"description": "Misskey SDK for JavaScript",
|
||||||
"main": "./built/index.js",
|
"exports": {
|
||||||
"types": "./built/index.d.ts",
|
".": {
|
||||||
|
"import": "./built/esm/index.js",
|
||||||
|
"types": "./built/dts/index.d.ts"
|
||||||
|
},
|
||||||
|
"./*": {
|
||||||
|
"import": "./built/esm/*",
|
||||||
|
"types": "./built/dts/*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"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\"",
|
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"",
|
||||||
"tsd": "tsd",
|
"tsd": "tsd",
|
||||||
"api": "pnpm api-extractor run --local --verbose",
|
"api": "pnpm api-extractor run --local --verbose",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import './autogen/apiClientJSDoc';
|
import './autogen/apiClientJSDoc.js';
|
||||||
|
|
||||||
import { SwitchCaseResponseType } from './api.types';
|
import { SwitchCaseResponseType } from './api.types.js';
|
||||||
import type { Endpoints } from './api.types';
|
import type { Endpoints } from './api.types.js';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SwitchCaseResponseType,
|
SwitchCaseResponseType,
|
||||||
} from './api.types';
|
} from './api.types.js';
|
||||||
|
|
||||||
const MK_API_ERROR = Symbol();
|
const MK_API_ERROR = Symbol();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Endpoints as Gen } from './autogen/endpoint';
|
import { Endpoints as Gen } from './autogen/endpoint.js';
|
||||||
import { UserDetailed } from './autogen/models';
|
import { UserDetailed } from './autogen/models.js';
|
||||||
import { UsersShowRequest } from './autogen/entities';
|
import { UsersShowRequest } from './autogen/entities.js';
|
||||||
import {
|
import {
|
||||||
SigninRequest,
|
SigninRequest,
|
||||||
SigninResponse,
|
SigninResponse,
|
||||||
|
@ -8,7 +8,7 @@ import {
|
||||||
SignupPendingResponse,
|
SignupPendingResponse,
|
||||||
SignupRequest,
|
SignupRequest,
|
||||||
SignupResponse,
|
SignupResponse,
|
||||||
} from './entities';
|
} from './entities.js';
|
||||||
|
|
||||||
type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit<
|
type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit<
|
||||||
T,
|
T,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { ModerationLogPayloads } from './consts.js';
|
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/entities.js';
|
||||||
export * from './autogen/models';
|
export * from './autogen/models.js';
|
||||||
|
|
||||||
export type ID = string;
|
export type ID = string;
|
||||||
export type DateString = string;
|
export type DateString = string;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
import ReconnectingWebsocket from 'reconnecting-websocket';
|
import _ReconnectingWebsocket from 'reconnecting-websocket';
|
||||||
import type { BroadcastEvents, Channels } from './streaming.types.js';
|
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 {
|
export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string {
|
||||||
const params = Object.entries(obj)
|
const params = Object.entries(obj)
|
||||||
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
||||||
|
@ -24,7 +26,7 @@ type StreamEvents = {
|
||||||
* Misskey stream connection
|
* Misskey stream connection
|
||||||
*/
|
*/
|
||||||
export default class Stream extends EventEmitter<StreamEvents> {
|
export default class Stream extends EventEmitter<StreamEvents> {
|
||||||
private stream: ReconnectingWebsocket;
|
private stream: _ReconnectingWebsocket.default;
|
||||||
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
|
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
|
||||||
private sharedConnectionPools: Pool[] = [];
|
private sharedConnectionPools: Pool[] = [];
|
||||||
private sharedConnections: SharedConnection[] = [];
|
private sharedConnections: SharedConnection[] = [];
|
||||||
|
|
Loading…
Reference in a new issue