change firefish-js to esm

This commit is contained in:
Lhcfl 2024-04-26 10:22:51 +08:00
parent fec1a800b6
commit 99f30ba01a
13 changed files with 35 additions and 33 deletions

View File

@ -1,5 +1,4 @@
import LangMap from "firefish-js/built/misc/langmap.js";
export const langmap = LangMap.langmap;
import { langmap as _langmap } from "firefish-js";
export const langmap = _langmap;
export type PostLanguage = keyof typeof langmap;

View File

@ -1,4 +1,7 @@
// TODO: use firefish-js
import { Schema as _Schema } from "firefish-js";
export * from "firefish-js/built/misc/schema.js";
// export Schema from "firefish-js";
export const refs = _Schema.refs;
export type Packed<T extends keyof typeof refs> = _Schema.Packed<T>;
export type Schema = _Schema.Schema;
export type SchemaType<P extends _Schema.Schema> = _Schema.SchemaType<P>;

View File

@ -89,7 +89,7 @@ export default defineConfig(({ command, mode }) => {
sourcemap: process.env.NODE_ENV === "development",
reportCompressedSize: false,
commonjsOptions: {
include: [/firefish-js/, /node_modules/],
include: [/node_modules/],
},
},
optimizeDeps: {

View File

@ -17,7 +17,7 @@
},
"minify": false,
"module": {
"type": "commonjs",
"type": "es6",
"strict": true,
"resolveFully": true
}

View File

@ -4,12 +4,12 @@
"description": "Firefish SDK for JavaScript",
"homepage": "https://firefish.dev/firefish/firefish/-/tree/develop/packages/firefish-js",
"main": "./built/index.js",
"type": "module",
"types": "./src/index.ts",
"license": "MIT",
"scripts": {
"build": "pnpm swc src --out-dir built --source-maps false --copy-files --strip-leading-paths && pnpm run build:types",
"build:debug": "pnpm swc src --out-dir built --source-maps true --copy-files --strip-leading-paths && pnpm run build:types",
"build:types": "pnpm tsc --emitDeclarationOnly",
"build": "pnpm swc src --out-dir built --source-maps false --copy-files --strip-leading-paths",
"build:debug": "pnpm swc src --out-dir built --source-maps true --copy-files --strip-leading-paths",
"watch": "pnpm swc src --out-dir built --source-maps true --copy-files --strip-leading-paths --watch",
"lint": "pnpm biome check --apply src",
"format": "pnpm biome format --write src",
@ -36,7 +36,7 @@
"typescript": "5.4.5"
},
"files": [
"built"
"built", "src"
],
"dependencies": {
"eventemitter3": "^5.0.1",

View File

@ -1,4 +1,4 @@
import type { Endpoints } from "./api.types";
import type { Endpoints } from "./api.types.js";
const MK_API_ERROR = Symbol();

View File

@ -38,7 +38,7 @@ import type {
UserList,
UserLite,
UserSorting,
} from "./entities";
} from "./entities.js";
import type * as consts from "./consts";

View File

@ -1,5 +1,5 @@
import type * as consts from "./consts";
import type { Packed } from "./misc/schema";
import type * as consts from "./consts.js";
import type { Packed } from "./misc/schema.js";
export type ID = string;
export type DateString = string;

View File

@ -1,17 +1,17 @@
import * as acct from "./acct";
import type { Acct } from "./acct";
import { Endpoints } from "./api.types";
import type * as ApiTypes from "./api.types";
import * as consts from "./consts";
import Stream, { Connection } from "./streaming";
import * as StreamTypes from "./streaming.types";
import type * as TypeUtils from "./type-utils";
import * as acct from "./acct.js";
import type { Acct } from "./acct.js";
import type { Endpoints } from "./api.types.js";
import type * as ApiTypes from "./api.types.js";
import * as consts from "./consts.js";
import Stream, { Connection } from "./streaming.js";
import * as StreamTypes from "./streaming.types.js";
import type * as TypeUtils from "./type-utils.js";
import type * as SchemaTypes from "./misc/schema";
import * as Schema from "./misc/schema";
import type * as SchemaTypes from "./misc/schema.js";
import * as Schema from "./misc/schema.js";
export {
Endpoints,
type Endpoints,
type ApiTypes,
Stream,
Connection as ChannelConnection,
@ -31,11 +31,11 @@ export const languages = consts.languages;
export const ffVisibility = consts.ffVisibility;
export const instanceSortParam = consts.instanceSortParam;
import { langmap } from "./misc/langmap";
import { langmap } from "./misc/langmap.js";
// api extractor not supported yet
//export * as api from './api';
//export * as entities from './entities';
import * as api from "./api";
import * as entities from "./entities";
import * as api from "./api.js";
import * as entities from "./entities.js";
export { api, entities, langmap };

View File

@ -1,4 +1,4 @@
import { notificationTypes } from "../consts";
import { notificationTypes } from "../consts.js";
export const packedNotificationSchema = {
type: "object",

View File

@ -1,6 +1,6 @@
import { EventEmitter } from "eventemitter3";
import ReconnectingWebsocket from "reconnecting";
import type { BroadcastEvents, Channels } from "./streaming.types";
import type { BroadcastEvents, Channels } from "./streaming.types.js";
function autobind(instance: any): void {
const prototype = Object.getPrototypeOf(instance);

View File

@ -12,7 +12,7 @@ import type {
UserGroup,
UserLite,
} from "./entities";
import type { Connection } from "./streaming";
import type { Connection } from "./streaming.js";
type FIXME = any;

View File

@ -1,4 +1,4 @@
import type { Endpoints } from "./api.types";
import type { Endpoints } from "./api.types.js";
export type PropertyOfType<Type, U> = {
[K in keyof Type]: Type[K] extends U ? K : never;