@nextclaw/shared 0.1.1
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/LICENSE +21 -0
- package/dist/index.d.ts +177 -0
- package/dist/index.js +220 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NextClaw contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { NcpEndpointEvent, NcpSessionSummary } from "@nextclaw/ncp";
|
|
2
|
+
|
|
3
|
+
//#region src/types/typed-key.types.d.ts
|
|
4
|
+
type TypedKey<T = unknown> = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly _type?: T;
|
|
7
|
+
};
|
|
8
|
+
type Key<T = unknown> = TypedKey<T> | string;
|
|
9
|
+
declare function createTypedKey<T>(id: string): TypedKey<T>;
|
|
10
|
+
declare function getKeyId(key: Key<unknown>): string;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/types/event-bus.types.d.ts
|
|
13
|
+
type EventKey<T> = TypedKey<T>;
|
|
14
|
+
type EventSource = string;
|
|
15
|
+
type EventEnvelope<T = unknown> = {
|
|
16
|
+
type: string;
|
|
17
|
+
payload: T;
|
|
18
|
+
emittedAt?: string;
|
|
19
|
+
source?: EventSource;
|
|
20
|
+
};
|
|
21
|
+
type EventEmitOptions = {
|
|
22
|
+
emittedAt?: string;
|
|
23
|
+
source?: EventSource;
|
|
24
|
+
};
|
|
25
|
+
type EventHandler<T> = (payload: T, envelope: EventEnvelope<T>) => void;
|
|
26
|
+
type Unsubscribe = () => void;
|
|
27
|
+
type EventBusOptions = {
|
|
28
|
+
onFirstSubscriber?: () => void;
|
|
29
|
+
onListenerError?: (params: {
|
|
30
|
+
type: string;
|
|
31
|
+
payload: unknown;
|
|
32
|
+
error: unknown;
|
|
33
|
+
}) => void;
|
|
34
|
+
onNoSubscribers?: () => void;
|
|
35
|
+
};
|
|
36
|
+
type AppEventKey<T> = Key<T>;
|
|
37
|
+
type AppEventSource = EventSource;
|
|
38
|
+
type AppEventEnvelope<T = unknown> = EventEnvelope<T>;
|
|
39
|
+
type AppEventEmitOptions = EventEmitOptions;
|
|
40
|
+
type AppEventHandler<T> = EventHandler<T>;
|
|
41
|
+
type AppEvent = AppEventEnvelope;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/services/event-bus.service.d.ts
|
|
44
|
+
declare class EventBus {
|
|
45
|
+
private readonly listeners;
|
|
46
|
+
private readonly globalListeners;
|
|
47
|
+
private listenerCount;
|
|
48
|
+
private readonly onFirstSubscriber?;
|
|
49
|
+
private readonly onListenerError?;
|
|
50
|
+
private readonly onNoSubscribers?;
|
|
51
|
+
constructor(options?: EventBusOptions);
|
|
52
|
+
emit: <T>(key: Key<T>, payload: T, options?: AppEventEmitOptions) => void;
|
|
53
|
+
emitEnvelope: <T>(event: AppEventEnvelope<T>) => void;
|
|
54
|
+
on: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => Unsubscribe;
|
|
55
|
+
off: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => void;
|
|
56
|
+
once: <T>(key: AppEventKey<T>, handler: AppEventHandler<T>) => Unsubscribe;
|
|
57
|
+
subscribeAll: (handler: (event: AppEventEnvelope) => void) => Unsubscribe;
|
|
58
|
+
private registerSubscriber;
|
|
59
|
+
private unregisterSubscriber;
|
|
60
|
+
private safeInvokeListener;
|
|
61
|
+
private safeInvokeGlobalListener;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/services/ingress.service.d.ts
|
|
65
|
+
type IngressEnvelope<TPayload = unknown> = {
|
|
66
|
+
type: Key<TPayload>;
|
|
67
|
+
payload?: TPayload;
|
|
68
|
+
source?: string;
|
|
69
|
+
};
|
|
70
|
+
type IngressContext = {
|
|
71
|
+
source: string;
|
|
72
|
+
token?: string | null;
|
|
73
|
+
};
|
|
74
|
+
type IngressHandler<TPayload = unknown, TResult = unknown> = (envelope: IngressEnvelope<TPayload>, context: IngressContext) => Promise<TResult> | TResult;
|
|
75
|
+
declare class Ingress {
|
|
76
|
+
private readonly handlers;
|
|
77
|
+
readonly addHandler: <TPayload = unknown, TResult = unknown>(type: Key<TPayload>, handler: IngressHandler<TPayload, TResult>) => (() => void);
|
|
78
|
+
readonly handle: <TPayload = unknown, TResult = unknown>(envelope: IngressEnvelope<TPayload>, context: IngressContext) => Promise<TResult>;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/services/disposable.service.d.ts
|
|
82
|
+
type Cleanup = () => void;
|
|
83
|
+
type Disposable = {
|
|
84
|
+
dispose: () => void;
|
|
85
|
+
};
|
|
86
|
+
declare const toDisposable: (dispose: Cleanup) => Disposable;
|
|
87
|
+
declare abstract class DisposableOwner implements Disposable {
|
|
88
|
+
protected readonly cleanups: Cleanup[];
|
|
89
|
+
private disposed;
|
|
90
|
+
protected get isDisposed(): boolean;
|
|
91
|
+
protected addCleanup: (cleanup: Cleanup) => Cleanup;
|
|
92
|
+
protected addDisposable: <T extends Disposable>(disposable: T) => T;
|
|
93
|
+
dispose: () => void;
|
|
94
|
+
}
|
|
95
|
+
declare class DisposableStore implements Disposable {
|
|
96
|
+
private readonly disposables;
|
|
97
|
+
private isDisposed;
|
|
98
|
+
add: <T extends Disposable>(disposable: T) => T;
|
|
99
|
+
clear: () => void;
|
|
100
|
+
dispose: () => void;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/types/update.types.d.ts
|
|
104
|
+
type UpdateStatus = "idle" | "checking" | "update-available" | "downloading" | "downloaded" | "applying" | "restart-required" | "up-to-date" | "blocked" | "failed";
|
|
105
|
+
type InstallationKind = "desktop-bundle" | "npm-runtime-bundle" | "npm-global" | "unknown";
|
|
106
|
+
type UpdateBlockReason = "host-too-old" | "unsupported-installation" | "signature-verification-unavailable";
|
|
107
|
+
type UpdateProgress = {
|
|
108
|
+
downloadedBytes: number;
|
|
109
|
+
totalBytes: number | null;
|
|
110
|
+
percent: number | null;
|
|
111
|
+
};
|
|
112
|
+
type UpdatePreferences = {
|
|
113
|
+
automaticChecks: boolean;
|
|
114
|
+
autoDownload: boolean;
|
|
115
|
+
};
|
|
116
|
+
type UpdateSnapshot = {
|
|
117
|
+
status: UpdateStatus;
|
|
118
|
+
installationKind: InstallationKind;
|
|
119
|
+
channel: "stable" | "beta";
|
|
120
|
+
hostVersion: string | null;
|
|
121
|
+
currentVersion: string | null;
|
|
122
|
+
availableVersion: string | null;
|
|
123
|
+
downloadedVersion: string | null;
|
|
124
|
+
minimumHostVersion: string | null;
|
|
125
|
+
releaseNotesUrl: string | null;
|
|
126
|
+
lastCheckedAt: string | null;
|
|
127
|
+
progress: UpdateProgress | null;
|
|
128
|
+
canAutoDownload: boolean;
|
|
129
|
+
canApplyInApp: boolean;
|
|
130
|
+
requiresRestart: boolean;
|
|
131
|
+
blockReason: UpdateBlockReason | null;
|
|
132
|
+
recoveryCommand: string | null;
|
|
133
|
+
errorMessage: string | null;
|
|
134
|
+
preferences: UpdatePreferences;
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/configs/event-keys.config.d.ts
|
|
138
|
+
declare function createEventKey<T>(id: string): EventKey<T>;
|
|
139
|
+
declare function createAppEventKey<T>(id: string): AppEventKey<T>;
|
|
140
|
+
declare const eventKeys: {
|
|
141
|
+
readonly configUpdated: AppEventKey<{
|
|
142
|
+
path: string;
|
|
143
|
+
}>;
|
|
144
|
+
readonly channelConfigApplyStatus: AppEventKey<{
|
|
145
|
+
channel: string;
|
|
146
|
+
status: "started" | "succeeded" | "failed";
|
|
147
|
+
message?: string;
|
|
148
|
+
}>;
|
|
149
|
+
readonly sessionUpdated: AppEventKey<{
|
|
150
|
+
sessionKey: string;
|
|
151
|
+
}>;
|
|
152
|
+
readonly sessionRunStatus: AppEventKey<{
|
|
153
|
+
sessionKey: string;
|
|
154
|
+
status: "running" | "idle";
|
|
155
|
+
}>;
|
|
156
|
+
readonly ncpEvent: AppEventKey<NcpEndpointEvent>;
|
|
157
|
+
readonly sessionSummaryUpsert: AppEventKey<{
|
|
158
|
+
summary: NcpSessionSummary;
|
|
159
|
+
}>;
|
|
160
|
+
readonly sessionSummaryDelete: AppEventKey<{
|
|
161
|
+
sessionKey: string;
|
|
162
|
+
}>;
|
|
163
|
+
readonly configReloadStarted: AppEventKey<Record<string, unknown> | undefined>;
|
|
164
|
+
readonly configReloadFinished: AppEventKey<Record<string, unknown> | undefined>;
|
|
165
|
+
readonly error: AppEventKey<{
|
|
166
|
+
message: string;
|
|
167
|
+
code?: string;
|
|
168
|
+
}>;
|
|
169
|
+
readonly connectionOpen: AppEventKey<Record<string, never> | undefined>;
|
|
170
|
+
readonly connectionClose: AppEventKey<Record<string, never> | undefined>;
|
|
171
|
+
readonly connectionError: AppEventKey<{
|
|
172
|
+
message?: string;
|
|
173
|
+
} | undefined>;
|
|
174
|
+
readonly runtimeUpdateSnapshot: AppEventKey<UpdateSnapshot>;
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
177
|
+
export { 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, 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, toDisposable };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
//#region src/types/typed-key.types.ts
|
|
2
|
+
function createTypedKey(id) {
|
|
3
|
+
const normalizedId = id.trim();
|
|
4
|
+
if (!normalizedId) throw new Error("typed key id is required");
|
|
5
|
+
return { id: normalizedId };
|
|
6
|
+
}
|
|
7
|
+
function getKeyId(key) {
|
|
8
|
+
return typeof key === "string" ? key.trim() : key.id;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/services/event-bus.service.ts
|
|
12
|
+
var EventBus = class {
|
|
13
|
+
listeners = /* @__PURE__ */ new Map();
|
|
14
|
+
globalListeners = /* @__PURE__ */ new Set();
|
|
15
|
+
listenerCount = 0;
|
|
16
|
+
onFirstSubscriber;
|
|
17
|
+
onListenerError;
|
|
18
|
+
onNoSubscribers;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.onFirstSubscriber = options.onFirstSubscriber;
|
|
21
|
+
this.onListenerError = options.onListenerError;
|
|
22
|
+
this.onNoSubscribers = options.onNoSubscribers;
|
|
23
|
+
}
|
|
24
|
+
emit = (key, payload, options = {}) => {
|
|
25
|
+
const envelope = {
|
|
26
|
+
type: getKeyId(key),
|
|
27
|
+
payload,
|
|
28
|
+
...options.emittedAt ? { emittedAt: options.emittedAt } : {},
|
|
29
|
+
...options.source ? { source: options.source } : {}
|
|
30
|
+
};
|
|
31
|
+
this.emitEnvelope(envelope);
|
|
32
|
+
};
|
|
33
|
+
emitEnvelope = (event) => {
|
|
34
|
+
const listeners = this.listeners.get(event.type);
|
|
35
|
+
if (listeners) for (const listener of listeners) this.safeInvokeListener(event, listener);
|
|
36
|
+
if (this.globalListeners.size === 0) return;
|
|
37
|
+
for (const listener of this.globalListeners) this.safeInvokeGlobalListener(event, listener);
|
|
38
|
+
};
|
|
39
|
+
on = (key, handler) => {
|
|
40
|
+
const keyId = getKeyId(key);
|
|
41
|
+
const listeners = this.listeners.get(keyId) ?? /* @__PURE__ */ new Set();
|
|
42
|
+
const typedHandler = handler;
|
|
43
|
+
const added = !listeners.has(typedHandler);
|
|
44
|
+
listeners.add(typedHandler);
|
|
45
|
+
this.listeners.set(keyId, listeners);
|
|
46
|
+
if (added) this.registerSubscriber();
|
|
47
|
+
return () => {
|
|
48
|
+
this.off(key, handler);
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
off = (key, handler) => {
|
|
52
|
+
const keyId = getKeyId(key);
|
|
53
|
+
const listeners = this.listeners.get(keyId);
|
|
54
|
+
if (!listeners) return;
|
|
55
|
+
const deleted = listeners.delete(handler);
|
|
56
|
+
if (listeners.size === 0) this.listeners.delete(keyId);
|
|
57
|
+
if (deleted) this.unregisterSubscriber();
|
|
58
|
+
};
|
|
59
|
+
once = (key, handler) => {
|
|
60
|
+
const wrappedHandler = (payload, envelope) => {
|
|
61
|
+
unsubscribe();
|
|
62
|
+
handler(payload, envelope);
|
|
63
|
+
};
|
|
64
|
+
const unsubscribe = this.on(key, wrappedHandler);
|
|
65
|
+
return unsubscribe;
|
|
66
|
+
};
|
|
67
|
+
subscribeAll = (handler) => {
|
|
68
|
+
const added = !this.globalListeners.has(handler);
|
|
69
|
+
this.globalListeners.add(handler);
|
|
70
|
+
if (added) this.registerSubscriber();
|
|
71
|
+
return () => {
|
|
72
|
+
if (this.globalListeners.delete(handler)) this.unregisterSubscriber();
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
registerSubscriber = () => {
|
|
76
|
+
this.listenerCount += 1;
|
|
77
|
+
if (this.listenerCount === 1) this.onFirstSubscriber?.();
|
|
78
|
+
};
|
|
79
|
+
unregisterSubscriber = () => {
|
|
80
|
+
this.listenerCount = Math.max(0, this.listenerCount - 1);
|
|
81
|
+
if (this.listenerCount === 0) this.onNoSubscribers?.();
|
|
82
|
+
};
|
|
83
|
+
safeInvokeListener = (event, listener) => {
|
|
84
|
+
try {
|
|
85
|
+
listener(event.payload, event);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
this.onListenerError?.({
|
|
88
|
+
type: event.type,
|
|
89
|
+
payload: event.payload,
|
|
90
|
+
error
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
safeInvokeGlobalListener = (event, listener) => {
|
|
95
|
+
try {
|
|
96
|
+
listener(event);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
this.onListenerError?.({
|
|
99
|
+
type: event.type,
|
|
100
|
+
payload: event.payload,
|
|
101
|
+
error
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/services/ingress.service.ts
|
|
108
|
+
var Ingress = class {
|
|
109
|
+
handlers = /* @__PURE__ */ new Map();
|
|
110
|
+
addHandler = (type, handler) => {
|
|
111
|
+
const normalizedType = getKeyId(type);
|
|
112
|
+
if (!normalizedType) throw new Error("ingress type is required");
|
|
113
|
+
this.handlers.set(normalizedType, handler);
|
|
114
|
+
return () => {
|
|
115
|
+
if (this.handlers.get(normalizedType) === handler) this.handlers.delete(normalizedType);
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
handle = async (envelope, context) => {
|
|
119
|
+
const normalizedType = getKeyId(envelope.type);
|
|
120
|
+
const handler = this.handlers.get(normalizedType);
|
|
121
|
+
if (!handler) throw new Error(`Unsupported ingress type: ${normalizedType}`);
|
|
122
|
+
return await handler(envelope, context);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/services/disposable.service.ts
|
|
127
|
+
const once = (cleanup) => {
|
|
128
|
+
let disposed = false;
|
|
129
|
+
return () => {
|
|
130
|
+
if (disposed) return;
|
|
131
|
+
disposed = true;
|
|
132
|
+
cleanup();
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
const runCleanups = (cleanups) => {
|
|
136
|
+
const errors = [];
|
|
137
|
+
for (const cleanup of cleanups) try {
|
|
138
|
+
cleanup();
|
|
139
|
+
} catch (error) {
|
|
140
|
+
errors.push(error);
|
|
141
|
+
}
|
|
142
|
+
if (errors.length === 1) throw errors[0];
|
|
143
|
+
if (errors.length > 1) throw new AggregateError(errors, "Failed to run cleanups.");
|
|
144
|
+
};
|
|
145
|
+
const toDisposable = (dispose) => ({ dispose: once(dispose) });
|
|
146
|
+
var DisposableOwner = class {
|
|
147
|
+
cleanups = [];
|
|
148
|
+
disposed = false;
|
|
149
|
+
get isDisposed() {
|
|
150
|
+
return this.disposed;
|
|
151
|
+
}
|
|
152
|
+
addCleanup = (cleanup) => {
|
|
153
|
+
const disposableCleanup = once(cleanup);
|
|
154
|
+
if (this.disposed) {
|
|
155
|
+
disposableCleanup();
|
|
156
|
+
return disposableCleanup;
|
|
157
|
+
}
|
|
158
|
+
this.cleanups.push(disposableCleanup);
|
|
159
|
+
return disposableCleanup;
|
|
160
|
+
};
|
|
161
|
+
addDisposable = (disposable) => {
|
|
162
|
+
this.addCleanup(() => {
|
|
163
|
+
disposable.dispose();
|
|
164
|
+
});
|
|
165
|
+
return disposable;
|
|
166
|
+
};
|
|
167
|
+
dispose = () => {
|
|
168
|
+
if (this.disposed) return;
|
|
169
|
+
this.disposed = true;
|
|
170
|
+
runCleanups(this.cleanups.splice(0).reverse());
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
var DisposableStore = class {
|
|
174
|
+
disposables = /* @__PURE__ */ new Set();
|
|
175
|
+
isDisposed = false;
|
|
176
|
+
add = (disposable) => {
|
|
177
|
+
if (this.isDisposed) {
|
|
178
|
+
disposable.dispose();
|
|
179
|
+
return disposable;
|
|
180
|
+
}
|
|
181
|
+
this.disposables.add(disposable);
|
|
182
|
+
return disposable;
|
|
183
|
+
};
|
|
184
|
+
clear = () => {
|
|
185
|
+
const current = [...this.disposables];
|
|
186
|
+
this.disposables.clear();
|
|
187
|
+
for (const disposable of current.reverse()) disposable.dispose();
|
|
188
|
+
};
|
|
189
|
+
dispose = () => {
|
|
190
|
+
if (this.isDisposed) return;
|
|
191
|
+
this.isDisposed = true;
|
|
192
|
+
this.clear();
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/configs/event-keys.config.ts
|
|
197
|
+
function createEventKey(id) {
|
|
198
|
+
return createTypedKey(id);
|
|
199
|
+
}
|
|
200
|
+
function createAppEventKey(id) {
|
|
201
|
+
return createTypedKey(id);
|
|
202
|
+
}
|
|
203
|
+
const eventKeys = {
|
|
204
|
+
configUpdated: createAppEventKey("config.updated"),
|
|
205
|
+
channelConfigApplyStatus: createAppEventKey("channel.config.apply-status"),
|
|
206
|
+
sessionUpdated: createAppEventKey("session.updated"),
|
|
207
|
+
sessionRunStatus: createAppEventKey("session.run-status"),
|
|
208
|
+
ncpEvent: createAppEventKey("ncp.event"),
|
|
209
|
+
sessionSummaryUpsert: createAppEventKey("session.summary.upsert"),
|
|
210
|
+
sessionSummaryDelete: createAppEventKey("session.summary.delete"),
|
|
211
|
+
configReloadStarted: createAppEventKey("config.reload.started"),
|
|
212
|
+
configReloadFinished: createAppEventKey("config.reload.finished"),
|
|
213
|
+
error: createAppEventKey("error"),
|
|
214
|
+
connectionOpen: createAppEventKey("connection.open"),
|
|
215
|
+
connectionClose: createAppEventKey("connection.close"),
|
|
216
|
+
connectionError: createAppEventKey("connection.error"),
|
|
217
|
+
runtimeUpdateSnapshot: createAppEventKey("runtime.update.snapshot")
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
export { DisposableOwner, DisposableStore, EventBus, Ingress, createAppEventKey, createEventKey, createTypedKey, eventKeys, getKeyId, toDisposable };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nextclaw/shared",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Shared lightweight primitives and contracts for NextClaw packages.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@nextclaw/ncp": "0.5.7"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.17.6",
|
|
22
|
+
"prettier": "^3.3.3",
|
|
23
|
+
"typescript": "^5.6.3",
|
|
24
|
+
"vitest": "^4.1.2"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsdown src/index.ts --dts --clean --target es2022 --no-fixedExtension",
|
|
28
|
+
"lint": "eslint src --max-warnings=0",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"tsc": "tsc -p tsconfig.json"
|
|
31
|
+
}
|
|
32
|
+
}
|