@nextclaw/shared 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,11 @@ declare const eventKeys: {
|
|
|
153
153
|
sessionKey: string;
|
|
154
154
|
status: "running" | "idle";
|
|
155
155
|
}>;
|
|
156
|
+
readonly sessionMetadataChanged: AppEventKey<{
|
|
157
|
+
metadata: Record<string, unknown>;
|
|
158
|
+
mode: "set" | "update";
|
|
159
|
+
sessionKey: string;
|
|
160
|
+
}>;
|
|
156
161
|
readonly ncpEvent: AppEventKey<NcpEndpointEvent>;
|
|
157
162
|
readonly sessionSummaryUpsert: AppEventKey<{
|
|
158
163
|
summary: NcpSessionSummary;
|
|
@@ -246,4 +251,5 @@ declare const ingressKeys: {
|
|
|
246
251
|
};
|
|
247
252
|
};
|
|
248
253
|
//#endregion
|
|
249
|
-
export { type AgentRunSendIngressPayload, type AgentRunSessionMessageRequestPayload, type AppEvent, type AppEventEmitOptions, type AppEventEnvelope, type AppEventHandler, type AppEventKey, type AppEventSource, type Cleanup, type Disposable, DisposableOwner, DisposableStore, EventBus, type EventBusOptions, type EventEmitOptions, type EventEnvelope, type EventHandler, type EventKey, type EventSource, type ExtensionChannelConfigGetIngressPayload, type ExtensionChannelFileContent, type ExtensionChannelImageContent, type ExtensionChannelMessageContent, type ExtensionChannelMessageSubmitIngressPayload, type ExtensionChannelSubmittedAttachment, type ExtensionChannelTextContent, type ExtensionResponseIngressPayload, Ingress, type IngressContext, type IngressEnvelope, type IngressHandler, type InstallationKind, type Key, type TypedKey, type Unsubscribe, type UpdateBlockReason, type UpdatePreferences, type UpdateProgress, type UpdateSnapshot, type UpdateStatus, createAppEventKey, createEventKey, createTypedKey, eventKeys, getKeyId, ingressKeys, toDisposable };
|
|
254
|
+
export { type AgentRunSendIngressPayload, type AgentRunSessionMessageRequestPayload, type AppEvent, type AppEventEmitOptions, type AppEventEnvelope, type AppEventHandler, type AppEventKey, type AppEventSource, type Cleanup, type Disposable, DisposableOwner, DisposableStore, EventBus, type EventBusOptions, type EventEmitOptions, type EventEnvelope, type EventHandler, type EventKey, type EventSource, type ExtensionChannelConfigGetIngressPayload, type ExtensionChannelFileContent, type ExtensionChannelImageContent, type ExtensionChannelMessageContent, type ExtensionChannelMessageSubmitIngressPayload, type ExtensionChannelSubmittedAttachment, type ExtensionChannelTextContent, type ExtensionResponseIngressPayload, Ingress, type IngressContext, type IngressEnvelope, type IngressHandler, type InstallationKind, type Key, type TypedKey, type Unsubscribe, type UpdateBlockReason, type UpdatePreferences, type UpdateProgress, type UpdateSnapshot, type UpdateStatus, createAppEventKey, createEventKey, createTypedKey, eventKeys, getKeyId, ingressKeys, toDisposable };
|
|
255
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types/typed-key.types.ts","../src/types/event-bus.types.ts","../src/services/event-bus.service.ts","../src/services/ingress.service.ts","../src/services/disposable.service.ts","../src/types/update.types.ts","../src/configs/event-keys.config.ts","../src/configs/ingress-keys.config.ts"],"mappings":";;;KAAY,QAAA;EAAA,SACD,EAAA;EAAA,SACA,KAAA,GAAQ,CAAA;AAAA;AAAA,KAGP,GAAA,gBAAmB,QAAA,CAAS,CAAA;AAAA,iBAExB,cAAA,GAAA,CAAkB,EAAA,WAAa,QAAA,CAAS,CAAA;AAAA,iBAQxC,QAAA,CAAS,GAAA,EAAK,GAAA;;;KCblB,QAAA,MAAc,QAAA,CAAS,CAAA;AAAA,KAEvB,WAAA;AAAA,KAEA,aAAA;EACV,IAAA;EACA,OAAA,EAAS,CAAA;EACT,SAAA;EACA,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,gBAAA;EACV,SAAA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oBAAA;EACJ,OAAA,EAAS,cAAA;EACT,OAAA;AAAA;AAAA,cAGO,WAAA;EAAA"}
|
package/dist/index.js
CHANGED
|
@@ -205,6 +205,7 @@ const eventKeys = {
|
|
|
205
205
|
channelConfigApplyStatus: createAppEventKey("channel.config.apply-status"),
|
|
206
206
|
sessionUpdated: createAppEventKey("session.updated"),
|
|
207
207
|
sessionRunStatus: createAppEventKey("session.run-status"),
|
|
208
|
+
sessionMetadataChanged: createAppEventKey("session.metadata.changed"),
|
|
208
209
|
ncpEvent: createAppEventKey("ncp.event"),
|
|
209
210
|
sessionSummaryUpsert: createAppEventKey("session.summary.upsert"),
|
|
210
211
|
sessionSummaryDelete: createAppEventKey("session.summary.delete"),
|
|
@@ -232,3 +233,5 @@ const ingressKeys = {
|
|
|
232
233
|
};
|
|
233
234
|
//#endregion
|
|
234
235
|
export { DisposableOwner, DisposableStore, EventBus, Ingress, createAppEventKey, createEventKey, createTypedKey, eventKeys, getKeyId, ingressKeys, toDisposable };
|
|
236
|
+
|
|
237
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/types/typed-key.types.ts","../src/services/event-bus.service.ts","../src/services/ingress.service.ts","../src/services/disposable.service.ts","../src/configs/event-keys.config.ts","../src/configs/ingress-keys.config.ts"],"sourcesContent":["export type TypedKey<T = unknown> = {\n readonly id: string;\n readonly _type?: T;\n};\n\nexport type Key<T = unknown> = TypedKey<T> | string;\n\nexport function createTypedKey<T>(id: string): TypedKey<T> {\n const normalizedId = id.trim();\n if (!normalizedId) {\n throw new Error(\"typed key id is required\");\n }\n return { id: normalizedId };\n}\n\nexport function getKeyId(key: Key<unknown>): string {\n return typeof key === \"string\" ? key.trim() : key.id;\n}\n","import type {\n AppEventEmitOptions,\n AppEventEnvelope,\n AppEventHandler,\n AppEventKey,\n EventBusOptions,\n Unsubscribe,\n} from \"../types/event-bus.types.js\";\nimport { getKeyId, type Key } from \"../types/typed-key.types.js\";\n\nexport class EventBus {\n private readonly listeners = new Map<string, Set<AppEventHandler<unknown>>>();\n private readonly globalListeners = new Set<(event: AppEventEnvelope) => void>();\n private listenerCount = 0;\n private readonly onFirstSubscriber?: EventBusOptions[\"onFirstSubscriber\"];\n private readonly onListenerError?: EventBusOptions[\"onListenerError\"];\n private readonly onNoSubscribers?: EventBusOptions[\"onNoSubscribers\"];\n\n constructor(options: EventBusOptions = {}) {\n this.onFirstSubscriber = options.onFirstSubscriber;\n this.onListenerError = options.onListenerError;\n this.onNoSubscribers = options.onNoSubscribers;\n }\n\n emit = <T>(\n key: Key<T>,\n payload: T,\n options: AppEventEmitOptions = {},\n ): void => {\n const envelope: AppEventEnvelope<T> = {\n type: getKeyId(key),\n payload,\n ...(options.emittedAt ? { emittedAt: options.emittedAt } : {}),\n ...(options.source ? { source: options.source } : {}),\n };\n this.emitEnvelope(envelope);\n };\n\n emitEnvelope = <T>(event: AppEventEnvelope<T>): void => {\n const listeners = this.listeners.get(event.type);\n if (listeners) {\n for (const listener of listeners) {\n this.safeInvokeListener(event, listener as AppEventHandler<T>);\n }\n }\n if (this.globalListeners.size === 0) {\n return;\n }\n for (const listener of this.globalListeners) {\n this.safeInvokeGlobalListener(event, listener);\n }\n };\n\n on = <T>(key: AppEventKey<T>, handler: AppEventHandler<T>): Unsubscribe => {\n const keyId = getKeyId(key);\n const listeners = this.listeners.get(keyId) ?? new Set<AppEventHandler<unknown>>();\n const typedHandler = handler as AppEventHandler<unknown>;\n const added = !listeners.has(typedHandler);\n listeners.add(typedHandler);\n this.listeners.set(keyId, listeners);\n if (added) {\n this.registerSubscriber();\n }\n return () => {\n this.off(key, handler);\n };\n };\n\n off = <T>(key: AppEventKey<T>, handler: AppEventHandler<T>): void => {\n const keyId = getKeyId(key);\n const listeners = this.listeners.get(keyId);\n if (!listeners) {\n return;\n }\n const deleted = listeners.delete(handler as AppEventHandler<unknown>);\n if (listeners.size === 0) {\n this.listeners.delete(keyId);\n }\n if (deleted) {\n this.unregisterSubscriber();\n }\n };\n\n once = <T>(key: AppEventKey<T>, handler: AppEventHandler<T>): Unsubscribe => {\n const wrappedHandler: AppEventHandler<T> = (payload, envelope) => {\n unsubscribe();\n handler(payload, envelope);\n };\n const unsubscribe = this.on(key, wrappedHandler);\n return unsubscribe;\n };\n\n subscribeAll = (handler: (event: AppEventEnvelope) => void): Unsubscribe => {\n const added = !this.globalListeners.has(handler);\n this.globalListeners.add(handler);\n if (added) {\n this.registerSubscriber();\n }\n return () => {\n if (this.globalListeners.delete(handler)) {\n this.unregisterSubscriber();\n }\n };\n };\n\n private registerSubscriber = (): void => {\n this.listenerCount += 1;\n if (this.listenerCount === 1) {\n this.onFirstSubscriber?.();\n }\n };\n\n private unregisterSubscriber = (): void => {\n this.listenerCount = Math.max(0, this.listenerCount - 1);\n if (this.listenerCount === 0) {\n this.onNoSubscribers?.();\n }\n };\n\n private safeInvokeListener = <T>(\n event: AppEventEnvelope<T>,\n listener: AppEventHandler<T>,\n ): void => {\n try {\n listener(event.payload, event);\n } catch (error) {\n this.onListenerError?.({\n type: event.type,\n payload: event.payload,\n error,\n });\n }\n };\n\n private safeInvokeGlobalListener = (\n event: AppEventEnvelope,\n listener: (event: AppEventEnvelope) => void,\n ): void => {\n try {\n listener(event);\n } catch (error) {\n this.onListenerError?.({\n type: event.type,\n payload: event.payload,\n error,\n });\n }\n };\n}\n","import { getKeyId, type Key } from \"../types/typed-key.types.js\";\n\nexport type IngressEnvelope<TPayload = unknown> = {\n type: Key<TPayload>;\n payload?: TPayload;\n source?: string;\n};\n\nexport type IngressContext = {\n source: string;\n token?: string | null;\n};\n\nexport type IngressHandler<TPayload = unknown, TResult = unknown> = (\n envelope: IngressEnvelope<TPayload>,\n context: IngressContext,\n) => Promise<TResult> | TResult;\n\nexport class Ingress {\n private readonly handlers = new Map<string, IngressHandler<unknown, unknown>>();\n\n readonly addHandler = <TPayload = unknown, TResult = unknown>(\n type: Key<TPayload>,\n handler: IngressHandler<TPayload, TResult>,\n ): (() => void) => {\n const normalizedType = getKeyId(type);\n if (!normalizedType) {\n throw new Error(\"ingress type is required\");\n }\n this.handlers.set(normalizedType, handler as IngressHandler<unknown, unknown>);\n return () => {\n if (this.handlers.get(normalizedType) === handler) {\n this.handlers.delete(normalizedType);\n }\n };\n };\n\n readonly handle = async <TPayload = unknown, TResult = unknown>(\n envelope: IngressEnvelope<TPayload>,\n context: IngressContext,\n ): Promise<TResult> => {\n const normalizedType = getKeyId(envelope.type);\n const handler = this.handlers.get(normalizedType);\n if (!handler) {\n throw new Error(`Unsupported ingress type: ${normalizedType}`);\n }\n return await (handler as IngressHandler<TPayload, TResult>)(envelope, context);\n };\n}\n","export type Cleanup = () => void;\n\nexport type Disposable = {\n dispose: () => void;\n};\n\nconst once = (cleanup: Cleanup): Cleanup => {\n let disposed = false;\n return () => {\n if (disposed) {\n return;\n }\n disposed = true;\n cleanup();\n };\n};\n\nconst runCleanups = (cleanups: Cleanup[]): void => {\n const errors: unknown[] = [];\n for (const cleanup of cleanups) {\n try {\n cleanup();\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length === 1) {\n throw errors[0];\n }\n if (errors.length > 1) {\n throw new AggregateError(errors, \"Failed to run cleanups.\");\n }\n};\n\nexport const toDisposable = (dispose: Cleanup): Disposable => ({\n dispose: once(dispose),\n});\n\nexport abstract class DisposableOwner implements Disposable {\n protected readonly cleanups: Cleanup[] = [];\n private disposed = false;\n\n protected get isDisposed(): boolean {\n return this.disposed;\n }\n\n protected addCleanup = (cleanup: Cleanup): Cleanup => {\n const disposableCleanup = once(cleanup);\n if (this.disposed) {\n disposableCleanup();\n return disposableCleanup;\n }\n this.cleanups.push(disposableCleanup);\n return disposableCleanup;\n };\n\n protected addDisposable = <T extends Disposable>(disposable: T): T => {\n this.addCleanup(() => {\n disposable.dispose();\n });\n return disposable;\n };\n\n dispose = (): void => {\n if (this.disposed) {\n return;\n }\n this.disposed = true;\n const current = this.cleanups.splice(0);\n runCleanups(current.reverse());\n };\n}\n\nexport class DisposableStore implements Disposable {\n private readonly disposables = new Set<Disposable>();\n\n private isDisposed = false;\n\n add = <T extends Disposable>(disposable: T): T => {\n if (this.isDisposed) {\n disposable.dispose();\n return disposable;\n }\n this.disposables.add(disposable);\n return disposable;\n };\n\n clear = (): void => {\n const current = [...this.disposables];\n this.disposables.clear();\n for (const disposable of current.reverse()) {\n disposable.dispose();\n }\n };\n\n dispose = (): void => {\n if (this.isDisposed) {\n return;\n }\n this.isDisposed = true;\n this.clear();\n };\n}\n","import type { NcpEndpointEvent, NcpSessionSummary } from \"@nextclaw/ncp\";\nimport type { AppEventKey, EventKey } from \"../types/event-bus.types.js\";\nimport { createTypedKey } from \"../types/typed-key.types.js\";\nimport type { UpdateSnapshot } from \"../types/update.types.js\";\n\nexport function createEventKey<T>(id: string): EventKey<T> {\n return createTypedKey<T>(id);\n}\n\nexport function createAppEventKey<T>(id: string): AppEventKey<T> {\n return createTypedKey<T>(id);\n}\n\nexport const eventKeys = {\n configUpdated: createAppEventKey<{ path: string }>(\"config.updated\"),\n channelConfigApplyStatus: createAppEventKey<{\n channel: string;\n status: \"started\" | \"succeeded\" | \"failed\";\n message?: string;\n }>(\"channel.config.apply-status\"),\n sessionUpdated: createAppEventKey<{ sessionKey: string }>(\"session.updated\"),\n sessionRunStatus: createAppEventKey<{\n sessionKey: string;\n status: \"running\" | \"idle\";\n }>(\"session.run-status\"),\n sessionMetadataChanged: createAppEventKey<{\n metadata: Record<string, unknown>;\n mode: \"set\" | \"update\";\n sessionKey: string;\n }>(\"session.metadata.changed\"),\n ncpEvent: createAppEventKey<NcpEndpointEvent>(\"ncp.event\"),\n sessionSummaryUpsert: createAppEventKey<{ summary: NcpSessionSummary }>(\n \"session.summary.upsert\",\n ),\n sessionSummaryDelete: createAppEventKey<{ sessionKey: string }>(\n \"session.summary.delete\",\n ),\n configReloadStarted: createAppEventKey<Record<string, unknown> | undefined>(\n \"config.reload.started\",\n ),\n configReloadFinished: createAppEventKey<Record<string, unknown> | undefined>(\n \"config.reload.finished\",\n ),\n error: createAppEventKey<{ message: string; code?: string }>(\"error\"),\n connectionOpen: createAppEventKey<Record<string, never> | undefined>(\n \"connection.open\",\n ),\n connectionClose: createAppEventKey<Record<string, never> | undefined>(\n \"connection.close\",\n ),\n connectionError: createAppEventKey<{ message?: string } | undefined>(\n \"connection.error\",\n ),\n runtimeUpdateSnapshot: createAppEventKey<UpdateSnapshot>(\n \"runtime.update.snapshot\",\n ),\n} as const;\n","import type {\n NcpAgentSendEnvelope,\n NcpMessage,\n NcpMessageAbortPayload,\n NcpMessagePart,\n} from \"@nextclaw/ncp\";\nimport { createTypedKey } from \"../types/typed-key.types.js\";\n\nexport type ExtensionChannelTextContent = {\n type: \"text\";\n text: string;\n};\n\ntype ExtensionChannelResourceRef = {\n url?: string;\n assetUri?: string;\n mimeType?: string;\n name?: string;\n};\n\nexport type ExtensionChannelImageContent = ExtensionChannelResourceRef & { type: \"image\" };\n\nexport type ExtensionChannelFileContent = ExtensionChannelResourceRef & { type: \"file\" };\n\nexport type ExtensionChannelMessageContent =\n | ExtensionChannelTextContent\n | ExtensionChannelImageContent\n | ExtensionChannelFileContent;\n\nexport type ExtensionChannelSubmittedAttachment = ExtensionChannelResourceRef & {\n id?: string;\n path?: string;\n size?: number;\n source?: string;\n status?: \"ready\" | \"remote-only\";\n errorCode?: \"too_large\" | \"download_failed\" | \"http_error\" | \"invalid_payload\";\n};\n\nexport type ExtensionChannelConfigGetIngressPayload = {\n channelId: string;\n};\n\nexport type ExtensionChannelMessageSubmitIngressPayload = {\n channelId: string;\n conversationId: string;\n senderId: string;\n content: ExtensionChannelMessageContent;\n attachments?: ExtensionChannelSubmittedAttachment[];\n metadata?: Record<string, unknown>;\n};\n\nexport type ExtensionResponseIngressPayload =\n | {\n requestId: string;\n ok: true;\n data?: unknown;\n }\n | {\n requestId: string;\n ok: false;\n error: {\n message: string;\n };\n };\n\nexport type AgentRunSessionMessageRequestPayload = {\n message: NcpMessage;\n requestId: string;\n sessionId: string;\n};\n\nexport type AgentRunSendIngressPayload =\n | (NcpAgentSendEnvelope & { content?: never })\n | (Omit<NcpAgentSendEnvelope, \"message\"> & {\n content: NcpMessagePart[];\n message?: never;\n });\n\nexport const ingressKeys = {\n extension: {\n channelConfigGet: createTypedKey<ExtensionChannelConfigGetIngressPayload>(\n \"extension.channel.config.get\",\n ),\n channelMessageSubmit:\n createTypedKey<ExtensionChannelMessageSubmitIngressPayload>(\n \"extension.channel.message.submit\",\n ),\n response: createTypedKey<ExtensionResponseIngressPayload>(\"extension.response\"),\n },\n agentRun: {\n send: createTypedKey<AgentRunSendIngressPayload>(\"agent-run.send\"),\n abort: createTypedKey<NcpMessageAbortPayload>(\"agent-run.abort\"),\n sessionMessageRequest:\n createTypedKey<AgentRunSessionMessageRequestPayload>(\n \"agent-run.session-message.request\",\n ),\n },\n} as const;\n"],"mappings":";AAOA,SAAgB,eAAkB,IAAyB;CACzD,MAAM,eAAe,GAAG,MAAM;AAC9B,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,2BAA2B;AAE7C,QAAO,EAAE,IAAI,cAAc;;AAG7B,SAAgB,SAAS,KAA2B;AAClD,QAAO,OAAO,QAAQ,WAAW,IAAI,MAAM,GAAG,IAAI;;;;ACNpD,IAAa,WAAb,MAAsB;CACpB,4BAA6B,IAAI,KAA4C;CAC7E,kCAAmC,IAAI,KAAwC;CAC/E,gBAAwB;CACxB;CACA;CACA;CAEA,YAAY,UAA2B,EAAE,EAAE;AACzC,OAAK,oBAAoB,QAAQ;AACjC,OAAK,kBAAkB,QAAQ;AAC/B,OAAK,kBAAkB,QAAQ;;CAGjC,QACE,KACA,SACA,UAA+B,EAAE,KACxB;EACT,MAAM,WAAgC;GACpC,MAAM,SAAS,IAAI;GACnB;GACA,GAAI,QAAQ,YAAY,EAAE,WAAW,QAAQ,WAAW,GAAG,EAAE;GAC7D,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,QAAQ,GAAG,EAAE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E,kBAAkB,kBAGf,qBAAqB;CACxB,wBAAwB,kBAIrB,2BAA2B;CAC9B,UAAU,kBAAoC,YAAY;CAC1D,sBAAsB,kBACpB,yBACD;CACD,sBAAsB,kBACpB,yBACD;CACD,qBAAqB,kBACnB,wBACD;CACD,sBAAsB,kBACpB,yBACD;CACD,OAAO,kBAAsD,QAAQ;CACrE,gBAAgB,kBACd,kBACD;CACD,iBAAiB,kBACf,mBACD;CACD,iBAAiB,kBACf,mBACD;CACD,uBAAuB,kBACrB,0BACD;CACF;;;ACsBD,MAAa,cAAc;CACzB,WAAW;EACT,kBAAkB,eAChB,+BACD;EACD,sBACE,eACE,mCACD;EACH,UAAU,eAAgD,qBAAqB;EAChF;CACD,UAAU;EACR,MAAM,eAA2C,iBAAiB;EAClE,OAAO,eAAuC,kBAAkB;EAChE,uBACE,eACE,oCACD;EACJ;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared lightweight primitives and contracts for NextClaw packages.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@nextclaw/ncp": "0.5.
|
|
18
|
+
"@nextclaw/ncp": "0.5.16"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.17.6",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"vitest": "^4.1.2"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsdown src/index.ts --dts --clean --target es2022 --no-fixedExtension",
|
|
27
|
+
"build": "tsdown src/index.ts --dts.sourcemap --clean --target es2022 --no-fixedExtension",
|
|
28
28
|
"lint": "eslint src --max-warnings=0",
|
|
29
29
|
"test": "vitest run",
|
|
30
30
|
"tsc": "tsc -p tsconfig.json"
|