@cordy/electro 1.1.2 → 1.1.3
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.mts +340 -338
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,122 +1,6 @@
|
|
|
1
1
|
import { BaseWindow, BaseWindowConstructorOptions, WebContentsView, WebPreferences } from "electron";
|
|
2
2
|
import { UserConfig } from "vite";
|
|
3
3
|
|
|
4
|
-
//#region src/config/types.d.ts
|
|
5
|
-
declare const RUNTIME_BRAND: unique symbol;
|
|
6
|
-
declare const VIEW_BRAND: unique symbol;
|
|
7
|
-
declare const CONFIG_BRAND: unique symbol;
|
|
8
|
-
interface RuntimeDefinition {
|
|
9
|
-
readonly [RUNTIME_BRAND]: true;
|
|
10
|
-
readonly entry: string;
|
|
11
|
-
readonly vite?: UserConfig;
|
|
12
|
-
/** @internal Caller path captured by defineRuntime(). */
|
|
13
|
-
readonly __source: string;
|
|
14
|
-
}
|
|
15
|
-
interface ViewDefinition {
|
|
16
|
-
readonly [VIEW_BRAND]: true;
|
|
17
|
-
readonly name: string;
|
|
18
|
-
readonly entry: string;
|
|
19
|
-
readonly features?: readonly string[];
|
|
20
|
-
readonly vite?: UserConfig;
|
|
21
|
-
readonly preload?: string;
|
|
22
|
-
readonly webPreferences?: Record<string, unknown>;
|
|
23
|
-
/** @internal Caller path captured by defineView(). */
|
|
24
|
-
readonly __source: string;
|
|
25
|
-
}
|
|
26
|
-
interface ElectroConfig {
|
|
27
|
-
readonly [CONFIG_BRAND]: true;
|
|
28
|
-
readonly runtime: RuntimeDefinition;
|
|
29
|
-
readonly views?: readonly ViewDefinition[];
|
|
30
|
-
}
|
|
31
|
-
interface DefineRuntimeInput {
|
|
32
|
-
entry: string;
|
|
33
|
-
vite?: UserConfig;
|
|
34
|
-
}
|
|
35
|
-
interface DefineViewInput {
|
|
36
|
-
name: string;
|
|
37
|
-
entry: string;
|
|
38
|
-
features?: readonly string[];
|
|
39
|
-
vite?: UserConfig;
|
|
40
|
-
preload?: string;
|
|
41
|
-
webPreferences?: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
interface DefineConfigInput {
|
|
44
|
-
runtime: RuntimeDefinition;
|
|
45
|
-
views?: readonly ViewDefinition[];
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/config/define-config.d.ts
|
|
49
|
-
declare function defineConfig(input: DefineConfigInput): ElectroConfig;
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/config/define-runtime.d.ts
|
|
52
|
-
declare function defineRuntime(input: DefineRuntimeInput): RuntimeDefinition;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/config/define-view.d.ts
|
|
55
|
-
declare function defineView(input: DefineViewInput): ViewDefinition;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/core/event-bus/types.d.ts
|
|
58
|
-
type EventHandler = (payload: unknown) => void;
|
|
59
|
-
type EventSubscription = {
|
|
60
|
-
channel: string;
|
|
61
|
-
handler: EventHandler;
|
|
62
|
-
ownerId: string;
|
|
63
|
-
};
|
|
64
|
-
type EventId = string;
|
|
65
|
-
/**
|
|
66
|
-
* Type-erased event interface for heterogeneous collections.
|
|
67
|
-
*/
|
|
68
|
-
interface EventInstance {
|
|
69
|
-
readonly id: EventId;
|
|
70
|
-
readonly defaults: unknown;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Public interface returned by {@link createEvent}.
|
|
74
|
-
*
|
|
75
|
-
* Generic parameter preserves payload type for codegen inference
|
|
76
|
-
* (`_EventPayload<T>` infers `T` from `payload()` phantom method).
|
|
77
|
-
*/
|
|
78
|
-
interface CreatedEvent<T = void> extends EventInstance {
|
|
79
|
-
readonly id: EventId;
|
|
80
|
-
readonly defaults: T | undefined;
|
|
81
|
-
/** @internal Phantom method for codegen type extraction. Never called. */
|
|
82
|
-
payload(): T;
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/core/event-bus/event-bus.d.ts
|
|
86
|
-
declare class EventBus {
|
|
87
|
-
private readonly subscriptions;
|
|
88
|
-
publish(channel: string, payload?: unknown): void;
|
|
89
|
-
subscribe(channel: string, handler: EventHandler, ownerId: string): () => void;
|
|
90
|
-
removeByOwner(ownerId: string): void;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/core/event-bus/accessor.d.ts
|
|
94
|
-
/**
|
|
95
|
-
* Scoped event access per feature.
|
|
96
|
-
*
|
|
97
|
-
* - `publish("name", payload)` -> publishes as `"ownerId:name"`
|
|
98
|
-
* - `on("dep:name", handler)` -> validates `dep` is a declared dependency
|
|
99
|
-
* - `on("name", handler)` -> subscribes to own `"ownerId:name"`
|
|
100
|
-
*/
|
|
101
|
-
declare class EventAccessor {
|
|
102
|
-
private readonly bus;
|
|
103
|
-
private readonly ownerId;
|
|
104
|
-
private readonly declaredDeps;
|
|
105
|
-
constructor(bus: EventBus, ownerId: string, declaredDeps: Set<string>);
|
|
106
|
-
publish(event: string, payload?: unknown): void;
|
|
107
|
-
on(event: string, handler: EventHandler): () => void;
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/core/event-bus/helpers.d.ts
|
|
111
|
-
/**
|
|
112
|
-
* Creates a typed event definition.
|
|
113
|
-
*
|
|
114
|
-
* @overload Explicit generic — `createEvent<{ version: string }>("ready")`
|
|
115
|
-
* @overload Infer from defaults — `createEvent("ready", { version: "unknown" })`
|
|
116
|
-
*/
|
|
117
|
-
declare function createEvent<T = void>(id: EventId): CreatedEvent<T>;
|
|
118
|
-
declare function createEvent<T>(id: EventId, defaults: T): CreatedEvent<T>;
|
|
119
|
-
//#endregion
|
|
120
4
|
//#region src/core/feature/enums.d.ts
|
|
121
5
|
declare enum FeatureStatus {
|
|
122
6
|
NONE = "none",
|
|
@@ -224,225 +108,40 @@ declare class WindowManager {
|
|
|
224
108
|
destroyAll(): void;
|
|
225
109
|
}
|
|
226
110
|
//#endregion
|
|
227
|
-
//#region src/core/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
declare enum TaskStatus {
|
|
234
|
-
Registered = "registered",
|
|
235
|
-
Scheduled = "scheduled",
|
|
236
|
-
Running = "running",
|
|
237
|
-
Stopped = "stopped",
|
|
238
|
-
Failed = "failed"
|
|
239
|
-
}
|
|
240
|
-
declare enum TaskRetryStrategy {
|
|
241
|
-
Fixed = "fixed",
|
|
242
|
-
Exponential = "exponential"
|
|
243
|
-
}
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/core/task/types.d.ts
|
|
246
|
-
type TaskId = string;
|
|
247
|
-
type StopMode = "graceful" | "force";
|
|
248
|
-
type TaskRetryConfig = {
|
|
249
|
-
attempts: number;
|
|
250
|
-
strategy: TaskRetryStrategy;
|
|
251
|
-
delayMs: number;
|
|
252
|
-
};
|
|
253
|
-
type TaskExecutionContext = {
|
|
254
|
-
signal: AbortSignal;
|
|
255
|
-
attempt: number;
|
|
256
|
-
};
|
|
257
|
-
type TaskConfig<TId extends TaskId, TPayload = void> = {
|
|
258
|
-
id: TId;
|
|
259
|
-
cron?: string;
|
|
260
|
-
autoStart?: boolean;
|
|
261
|
-
overlap?: TaskOverlapStrategy;
|
|
262
|
-
dedupeKey?: (payload: TPayload) => string;
|
|
263
|
-
timeoutMs?: number;
|
|
264
|
-
retry?: TaskRetryConfig;
|
|
265
|
-
execute: (ctx: FeatureContext<_TaskOwner<TId>, never, TId>, payload: TPayload, execCtx: TaskExecutionContext) => void | Promise<void>;
|
|
111
|
+
//#region src/core/event-bus/types.d.ts
|
|
112
|
+
type EventHandler = (payload: unknown) => void;
|
|
113
|
+
type EventSubscription = {
|
|
114
|
+
channel: string;
|
|
115
|
+
handler: EventHandler;
|
|
116
|
+
ownerId: string;
|
|
266
117
|
};
|
|
118
|
+
type EventId = string;
|
|
267
119
|
/**
|
|
268
|
-
* Type-erased
|
|
269
|
-
*
|
|
270
|
-
* Using a non-generic interface (instead of `Task<TaskId, unknown>`)
|
|
271
|
-
* avoids TypeScript variance issues: `TaskConfig.execute` has `payload: TPayload`
|
|
272
|
-
* in a contravariant position, making `Task` invariant in `TPayload`.
|
|
273
|
-
* Interface methods are bivariant, so any `Task<TId, TPayload>` is
|
|
274
|
-
* structurally assignable to `TaskInstance`.
|
|
275
|
-
*/
|
|
276
|
-
interface TaskInstance {
|
|
277
|
-
readonly id: TaskId;
|
|
278
|
-
enable(ctx: FeatureContext<any>): void;
|
|
279
|
-
disable(mode?: StopMode): void;
|
|
280
|
-
start(payload?: unknown): Promise<void>;
|
|
281
|
-
queue(payload: unknown): void;
|
|
282
|
-
stop(): void;
|
|
283
|
-
clear(): void;
|
|
284
|
-
status(): TaskStatusInfo;
|
|
285
|
-
}
|
|
286
|
-
interface TaskStatusInfo {
|
|
287
|
-
taskId: string;
|
|
288
|
-
state: TaskStatus;
|
|
289
|
-
running: boolean;
|
|
290
|
-
queueSize: number;
|
|
291
|
-
lastRunAt: number | null;
|
|
292
|
-
lastSuccessAt: number | null;
|
|
293
|
-
lastErrorAt: number | null;
|
|
294
|
-
lastError: Error | null;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Public interface returned by {@link createTask}.
|
|
298
|
-
*
|
|
299
|
-
* Hides class internals (private fields) so consumers can safely
|
|
300
|
-
* `export const myTask = createTask({...})` without TypeScript
|
|
301
|
-
* "cannot be named" errors in declaration emit.
|
|
302
|
-
*
|
|
303
|
-
* Generic parameters preserve payload type for codegen inference
|
|
304
|
-
* (`_TaskPayload<T>` infers `TPayload` from `start(payload?)`).
|
|
120
|
+
* Type-erased event interface for heterogeneous collections.
|
|
305
121
|
*/
|
|
306
|
-
interface
|
|
307
|
-
readonly id:
|
|
308
|
-
|
|
309
|
-
disable(mode?: StopMode): void;
|
|
310
|
-
start(payload?: TPayload): Promise<void>;
|
|
311
|
-
queue(payload: TPayload): void;
|
|
312
|
-
stop(): void;
|
|
313
|
-
clear(): void;
|
|
314
|
-
status(): TaskStatusInfo;
|
|
122
|
+
interface EventInstance {
|
|
123
|
+
readonly id: EventId;
|
|
124
|
+
readonly defaults: unknown;
|
|
315
125
|
}
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/core/task/handle.d.ts
|
|
318
126
|
/**
|
|
319
|
-
*
|
|
127
|
+
* Public interface returned by {@link createEvent}.
|
|
320
128
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
129
|
+
* Generic parameter preserves payload type for codegen inference
|
|
130
|
+
* (`_EventPayload<T>` infers `T` from `payload()` phantom method).
|
|
323
131
|
*/
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
start(payload?: TPayload): Promise<void>;
|
|
330
|
-
/** Push payload to FIFO queue, processes sequentially. */
|
|
331
|
-
queue(payload: TPayload): void;
|
|
332
|
-
/** Abort current execution. Queue continues processing. */
|
|
333
|
-
stop(): void;
|
|
334
|
-
/** Re-enable the task (cron, ready for start/queue). */
|
|
335
|
-
enable(): void;
|
|
336
|
-
/** Abort current + clear queue + stop cron. */
|
|
337
|
-
disable(mode?: StopMode): void;
|
|
338
|
-
/** Clear the FIFO queue without stopping current execution. */
|
|
339
|
-
clear(): void;
|
|
340
|
-
/** Snapshot of the task's current state. */
|
|
341
|
-
status(): TaskStatusInfo;
|
|
132
|
+
interface CreatedEvent<T = void> extends EventInstance {
|
|
133
|
+
readonly id: EventId;
|
|
134
|
+
readonly defaults: T | undefined;
|
|
135
|
+
/** @internal Phantom method for codegen type extraction. Never called. */
|
|
136
|
+
payload(): T;
|
|
342
137
|
}
|
|
343
138
|
//#endregion
|
|
344
|
-
//#region src/core/
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
*/
|
|
351
|
-
interface FeatureMap {}
|
|
352
|
-
/** Maps service ID → owning feature ID. Populated by codegen. */
|
|
353
|
-
interface ServiceOwnerMap {}
|
|
354
|
-
/** Maps task ID → owning feature ID. Populated by codegen. */
|
|
355
|
-
interface TaskOwnerMap {}
|
|
356
|
-
/** Declaration-merging registry for view types. Codegen populates this. */
|
|
357
|
-
interface ViewMap {}
|
|
358
|
-
/** Declaration-merging registry for window API types. Codegen populates this. */
|
|
359
|
-
interface WindowApiMap {}
|
|
360
|
-
/** Resolve the owning feature ID for a service. Falls back to `string` (→ BaseContext). */
|
|
361
|
-
type _ServiceOwner<TId extends string> = TId extends keyof ServiceOwnerMap ? ServiceOwnerMap[TId] : string;
|
|
362
|
-
/** Resolve the owning feature ID for a task. Falls back to `string` (→ BaseContext). */
|
|
363
|
-
type _TaskOwner<TId extends string> = TId extends keyof TaskOwnerMap ? TaskOwnerMap[TId] : string;
|
|
364
|
-
type _SuggestViewKeys = (keyof ViewMap & string) | (string & {});
|
|
365
|
-
type _SuggestWindowKeys = (keyof WindowApiMap & string) | (string & {});
|
|
366
|
-
type _ResolveWindowApi<K extends string> = K extends keyof WindowApiMap ? WindowApiMap[K] : unknown;
|
|
367
|
-
/** Extract the dependency IDs union for a feature. */
|
|
368
|
-
type _DepIds<FId> = FId extends keyof FeatureMap ? FeatureMap[FId]["dependencies"] : never;
|
|
369
|
-
/** Own service keys for a feature. */
|
|
370
|
-
type _OwnSvcKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["services"] & string : never;
|
|
371
|
-
/** Distributive helper — maps a single dep ID to its qualified service keys. */
|
|
372
|
-
type _DepSvcOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["services"] & string}` : never;
|
|
373
|
-
/** Qualified dependency service keys ("dep:svc"), distributes over the deps union. */
|
|
374
|
-
type _DepSvcKeys<FId> = _DepSvcOf<_DepIds<FId>>;
|
|
375
|
-
/** Resolve a service type from own or dependency services. */
|
|
376
|
-
type _ResolveSvc<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["services"] ? FeatureMap[FId]["services"][K] : K extends `${infer D}:${infer S}` ? D extends _DepIds<FId> & keyof FeatureMap ? S extends keyof FeatureMap[D]["services"] ? FeatureMap[D]["services"][S] : unknown : unknown : unknown : unknown;
|
|
377
|
-
/** Resolve a task type from own tasks. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
378
|
-
type _ResolveTask<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["tasks"] ? TaskHandle<FeatureMap[FId]["tasks"][K]> : unknown : unknown;
|
|
379
|
-
/** Resolve a feature handle from dependency features. */
|
|
380
|
-
type _ResolveFeature<FId, K extends string> = FId extends keyof FeatureMap ? K extends _DepIds<FId> & string ? FeatureHandle : unknown : unknown;
|
|
381
|
-
type _SuggestSvcKeys<FId> = _OwnSvcKeys<FId> | _DepSvcKeys<FId>;
|
|
382
|
-
type _SuggestTaskKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["tasks"] & string : never;
|
|
383
|
-
type _SuggestDepKeys<FId> = _DepIds<FId> & string;
|
|
384
|
-
/** Own event keys for a feature. */
|
|
385
|
-
type _OwnEventKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["events"] & string : never;
|
|
386
|
-
/** Distributive helper — maps a single dep ID to its qualified event keys. */
|
|
387
|
-
type _DepEventOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["events"] & string}` : never;
|
|
388
|
-
/** Qualified dependency event keys ("dep:event"), distributes over the deps union. */
|
|
389
|
-
type _DepEventKeys<FId> = _DepEventOf<_DepIds<FId>>;
|
|
390
|
-
/** Resolve own event payload. */
|
|
391
|
-
type _ResolveOwnEvent<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["events"] ? FeatureMap[FId]["events"][K] : unknown : unknown;
|
|
392
|
-
/** Resolve any event payload (own or dep). */
|
|
393
|
-
type _ResolveEvent<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["events"] ? FeatureMap[FId]["events"][K] : K extends `${infer D}:${infer E}` ? D extends _DepIds<FId> & keyof FeatureMap ? E extends keyof FeatureMap[D]["events"] ? FeatureMap[D]["events"][E] : unknown : unknown : unknown : unknown;
|
|
394
|
-
/** All service keys across all features (mapped type distributes over each feature). */
|
|
395
|
-
type _AllSvcKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["services"] & string }[keyof FeatureMap];
|
|
396
|
-
/** All task keys across all features (mapped type distributes over each feature). */
|
|
397
|
-
type _AllTaskKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["tasks"] & string }[keyof FeatureMap];
|
|
398
|
-
/** All feature IDs. */
|
|
399
|
-
type _AllFeatureIds = keyof FeatureMap & string;
|
|
400
|
-
/** All event keys across all features. */
|
|
401
|
-
type _AllEventKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["events"] & string }[keyof FeatureMap];
|
|
402
|
-
type _SuggestAllSvc = _AllSvcKeys | (string & {});
|
|
403
|
-
type _SuggestAllTask = _AllTaskKeys | (string & {});
|
|
404
|
-
type _SuggestAllFeature = _AllFeatureIds | (string & {});
|
|
405
|
-
type _SuggestAllEvent = _AllEventKeys | (string & {});
|
|
406
|
-
/** Flat resolve for unscoped service lookup. */
|
|
407
|
-
type _FlatResolveSvc<K extends string> = { [F in keyof FeatureMap]: K extends keyof FeatureMap[F]["services"] ? FeatureMap[F]["services"][K] : never }[keyof FeatureMap] extends infer U ? [U] extends [never] ? unknown : U : unknown;
|
|
408
|
-
/** Flat resolve for unscoped task lookup. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
409
|
-
type _FlatResolveTask<K extends string> = { [F in keyof FeatureMap]: K extends keyof FeatureMap[F]["tasks"] ? TaskHandle<FeatureMap[F]["tasks"][K]> : never }[keyof FeatureMap] extends infer U ? [U] extends [never] ? unknown : U : unknown;
|
|
410
|
-
/** Flat resolve for unscoped feature lookup. */
|
|
411
|
-
type _FlatResolveFeature<K extends string> = K extends keyof FeatureMap ? FeatureHandle : unknown;
|
|
412
|
-
/** Scoped context — used when `FId` is a concrete feature key. */
|
|
413
|
-
type TypedContext<FId extends keyof FeatureMap, ExcludeSvc extends string = never, ExcludeTask extends string = never> = {
|
|
414
|
-
signal: AbortSignal;
|
|
415
|
-
logger: LoggerContext;
|
|
416
|
-
getService: <K extends Exclude<_SuggestSvcKeys<FId>, ExcludeSvc>>(name: K) => _ResolveSvc<FId, K & string>;
|
|
417
|
-
getTask: <K extends Exclude<_SuggestTaskKeys<FId>, ExcludeTask>>(name: K) => _ResolveTask<FId, K & string>;
|
|
418
|
-
getFeature: <K extends _SuggestDepKeys<FId>>(name: K) => _ResolveFeature<FId, K & string>;
|
|
419
|
-
events: {
|
|
420
|
-
publish<K extends _OwnEventKeys<FId>>(event: K, ...args: undefined extends _ResolveOwnEvent<FId, K> ? [payload?: _ResolveOwnEvent<FId, K>] : [payload: _ResolveOwnEvent<FId, K>]): void;
|
|
421
|
-
on<K extends _OwnEventKeys<FId> | _DepEventKeys<FId>>(event: K, handler: (payload: _ResolveEvent<FId, K>) => void): () => void;
|
|
422
|
-
};
|
|
423
|
-
getWindow: <K extends _SuggestWindowKeys>(id: K) => CreatedWindow<_ResolveWindowApi<K & string>> | null;
|
|
424
|
-
createView: <K extends _SuggestViewKeys>(id: K) => ElectroView;
|
|
425
|
-
getView: <K extends _SuggestViewKeys>(id: K) => ElectroView | null;
|
|
426
|
-
};
|
|
427
|
-
/** Unscoped context — flat suggestions from all features. */
|
|
428
|
-
type BaseContext = {
|
|
429
|
-
signal: AbortSignal;
|
|
430
|
-
logger: LoggerContext;
|
|
431
|
-
getService: <K extends _SuggestAllSvc>(name: K) => _FlatResolveSvc<K & string>;
|
|
432
|
-
getTask: <K extends _SuggestAllTask>(name: K) => _FlatResolveTask<K & string>;
|
|
433
|
-
getFeature: <K extends _SuggestAllFeature>(name: K) => _FlatResolveFeature<K & string>;
|
|
434
|
-
events: {
|
|
435
|
-
publish(event: _SuggestAllEvent, payload?: unknown): void;
|
|
436
|
-
on(event: string, handler: (payload: unknown) => void): () => void;
|
|
437
|
-
};
|
|
438
|
-
getWindow: <K extends _SuggestWindowKeys>(id: K) => CreatedWindow<_ResolveWindowApi<K & string>> | null;
|
|
439
|
-
createView: <K extends _SuggestViewKeys>(id: K) => ElectroView;
|
|
440
|
-
getView: <K extends _SuggestViewKeys>(id: K) => ElectroView | null;
|
|
441
|
-
};
|
|
442
|
-
interface LoggerContext {
|
|
443
|
-
debug(code: string, message: string, details?: Record<string, unknown>): void;
|
|
444
|
-
warn(code: string, message: string, details?: Record<string, unknown>): void;
|
|
445
|
-
error(code: string, message: string, details?: Record<string, unknown>): void;
|
|
139
|
+
//#region src/core/event-bus/event-bus.d.ts
|
|
140
|
+
declare class EventBus {
|
|
141
|
+
private readonly subscriptions;
|
|
142
|
+
publish(channel: string, payload?: unknown): void;
|
|
143
|
+
subscribe(channel: string, handler: EventHandler, ownerId: string): () => void;
|
|
144
|
+
removeByOwner(ownerId: string): void;
|
|
446
145
|
}
|
|
447
146
|
//#endregion
|
|
448
147
|
//#region src/core/service/enums.d.ts
|
|
@@ -484,22 +183,112 @@ interface ServiceInstance {
|
|
|
484
183
|
status(): ServiceInfo;
|
|
485
184
|
}
|
|
486
185
|
/**
|
|
487
|
-
* Public interface returned by {@link createService}.
|
|
186
|
+
* Public interface returned by {@link createService}.
|
|
187
|
+
*
|
|
188
|
+
* Hides class internals so consumers can safely
|
|
189
|
+
* `export const myService = createService({...})` without TypeScript
|
|
190
|
+
* "cannot be named" errors in declaration emit.
|
|
191
|
+
*
|
|
192
|
+
* Generic parameters preserve scope + API types for codegen inference
|
|
193
|
+
* (`_SvcApi<T>` infers from `api()`).
|
|
194
|
+
*/
|
|
195
|
+
interface CreatedService<Scope extends ServiceScope = ServiceScope, TApi = unknown> {
|
|
196
|
+
readonly id: ServiceId;
|
|
197
|
+
readonly scope: Scope;
|
|
198
|
+
build(ctx: FeatureContext<any>): void;
|
|
199
|
+
destroy(): void;
|
|
200
|
+
api(): TApi | null;
|
|
201
|
+
status(): ServiceInfo;
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/core/task/enums.d.ts
|
|
205
|
+
declare enum TaskOverlapStrategy {
|
|
206
|
+
Skip = "skip",
|
|
207
|
+
Queue = "queue",
|
|
208
|
+
Parallel = "parallel"
|
|
209
|
+
}
|
|
210
|
+
declare enum TaskStatus {
|
|
211
|
+
Registered = "registered",
|
|
212
|
+
Scheduled = "scheduled",
|
|
213
|
+
Running = "running",
|
|
214
|
+
Stopped = "stopped",
|
|
215
|
+
Failed = "failed"
|
|
216
|
+
}
|
|
217
|
+
declare enum TaskRetryStrategy {
|
|
218
|
+
Fixed = "fixed",
|
|
219
|
+
Exponential = "exponential"
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/core/task/types.d.ts
|
|
223
|
+
type TaskId = string;
|
|
224
|
+
type StopMode = "graceful" | "force";
|
|
225
|
+
type TaskRetryConfig = {
|
|
226
|
+
attempts: number;
|
|
227
|
+
strategy: TaskRetryStrategy;
|
|
228
|
+
delayMs: number;
|
|
229
|
+
};
|
|
230
|
+
type TaskExecutionContext = {
|
|
231
|
+
signal: AbortSignal;
|
|
232
|
+
attempt: number;
|
|
233
|
+
};
|
|
234
|
+
type TaskConfig<TId extends TaskId, TPayload = void> = {
|
|
235
|
+
id: TId;
|
|
236
|
+
cron?: string;
|
|
237
|
+
autoStart?: boolean;
|
|
238
|
+
overlap?: TaskOverlapStrategy;
|
|
239
|
+
dedupeKey?: (payload: TPayload) => string;
|
|
240
|
+
timeoutMs?: number;
|
|
241
|
+
retry?: TaskRetryConfig;
|
|
242
|
+
execute: (ctx: FeatureContext<_TaskOwner<TId>, never, TId>, payload: TPayload, execCtx: TaskExecutionContext) => void | Promise<void>;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Type-erased task interface for heterogeneous collections.
|
|
246
|
+
*
|
|
247
|
+
* Using a non-generic interface (instead of `Task<TaskId, unknown>`)
|
|
248
|
+
* avoids TypeScript variance issues: `TaskConfig.execute` has `payload: TPayload`
|
|
249
|
+
* in a contravariant position, making `Task` invariant in `TPayload`.
|
|
250
|
+
* Interface methods are bivariant, so any `Task<TId, TPayload>` is
|
|
251
|
+
* structurally assignable to `TaskInstance`.
|
|
252
|
+
*/
|
|
253
|
+
interface TaskInstance {
|
|
254
|
+
readonly id: TaskId;
|
|
255
|
+
enable(ctx: FeatureContext<any>): void;
|
|
256
|
+
disable(mode?: StopMode): void;
|
|
257
|
+
start(payload?: unknown): Promise<void>;
|
|
258
|
+
queue(payload: unknown): void;
|
|
259
|
+
stop(): void;
|
|
260
|
+
clear(): void;
|
|
261
|
+
status(): TaskStatusInfo;
|
|
262
|
+
}
|
|
263
|
+
interface TaskStatusInfo {
|
|
264
|
+
taskId: string;
|
|
265
|
+
state: TaskStatus;
|
|
266
|
+
running: boolean;
|
|
267
|
+
queueSize: number;
|
|
268
|
+
lastRunAt: number | null;
|
|
269
|
+
lastSuccessAt: number | null;
|
|
270
|
+
lastErrorAt: number | null;
|
|
271
|
+
lastError: Error | null;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Public interface returned by {@link createTask}.
|
|
488
275
|
*
|
|
489
|
-
* Hides class internals so consumers can safely
|
|
490
|
-
* `export const
|
|
276
|
+
* Hides class internals (private fields) so consumers can safely
|
|
277
|
+
* `export const myTask = createTask({...})` without TypeScript
|
|
491
278
|
* "cannot be named" errors in declaration emit.
|
|
492
279
|
*
|
|
493
|
-
* Generic parameters preserve
|
|
494
|
-
* (`
|
|
280
|
+
* Generic parameters preserve payload type for codegen inference
|
|
281
|
+
* (`_TaskPayload<T>` infers `TPayload` from `start(payload?)`).
|
|
495
282
|
*/
|
|
496
|
-
interface
|
|
497
|
-
readonly id:
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
283
|
+
interface CreatedTask<TId extends TaskId = TaskId, TPayload = void> {
|
|
284
|
+
readonly id: TId;
|
|
285
|
+
enable(ctx: FeatureContext<any>): void;
|
|
286
|
+
disable(mode?: StopMode): void;
|
|
287
|
+
start(payload?: TPayload): Promise<void>;
|
|
288
|
+
queue(payload: TPayload): void;
|
|
289
|
+
stop(): void;
|
|
290
|
+
clear(): void;
|
|
291
|
+
status(): TaskStatusInfo;
|
|
503
292
|
}
|
|
504
293
|
//#endregion
|
|
505
294
|
//#region src/core/feature/types.d.ts
|
|
@@ -697,6 +486,219 @@ declare class FeatureHandle {
|
|
|
697
486
|
disable(): Promise<void>;
|
|
698
487
|
}
|
|
699
488
|
//#endregion
|
|
489
|
+
//#region src/core/task/handle.d.ts
|
|
490
|
+
/**
|
|
491
|
+
* Ergonomic handle for a single {@link Task}.
|
|
492
|
+
*
|
|
493
|
+
* Provides per-task control: start, queue, stop, enable, disable, clear, status.
|
|
494
|
+
* Created by Feature and bound to `ctx.getTask(name)`.
|
|
495
|
+
*/
|
|
496
|
+
declare class TaskHandle<TPayload = unknown> {
|
|
497
|
+
private readonly task;
|
|
498
|
+
private readonly ctx;
|
|
499
|
+
constructor(task: TaskInstance, ctx?: FeatureContext<any> | undefined);
|
|
500
|
+
/** Execute immediately (respects overlap policy). */
|
|
501
|
+
start(payload?: TPayload): Promise<void>;
|
|
502
|
+
/** Push payload to FIFO queue, processes sequentially. */
|
|
503
|
+
queue(payload: TPayload): void;
|
|
504
|
+
/** Abort current execution. Queue continues processing. */
|
|
505
|
+
stop(): void;
|
|
506
|
+
/** Re-enable the task (cron, ready for start/queue). */
|
|
507
|
+
enable(): void;
|
|
508
|
+
/** Abort current + clear queue + stop cron. */
|
|
509
|
+
disable(mode?: StopMode): void;
|
|
510
|
+
/** Clear the FIFO queue without stopping current execution. */
|
|
511
|
+
clear(): void;
|
|
512
|
+
/** Snapshot of the task's current state. */
|
|
513
|
+
status(): TaskStatusInfo;
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/core/types.d.ts
|
|
517
|
+
/**
|
|
518
|
+
* Declaration-merging registry.
|
|
519
|
+
* Codegen populates this via `declare module "@cordy/electro"`.
|
|
520
|
+
*
|
|
521
|
+
* Each key is a feature ID mapping to its services, tasks, and dependencies.
|
|
522
|
+
*/
|
|
523
|
+
interface FeatureMap {}
|
|
524
|
+
/** Maps service ID → owning feature ID. Populated by codegen. */
|
|
525
|
+
interface ServiceOwnerMap {}
|
|
526
|
+
/** Maps task ID → owning feature ID. Populated by codegen. */
|
|
527
|
+
interface TaskOwnerMap {}
|
|
528
|
+
/** Declaration-merging registry for view types. Codegen populates this. */
|
|
529
|
+
interface ViewMap {}
|
|
530
|
+
/** Declaration-merging registry for window API types. Codegen populates this. */
|
|
531
|
+
interface WindowApiMap {}
|
|
532
|
+
/** Resolve the owning feature ID for a service. Falls back to `string` (→ BaseContext). */
|
|
533
|
+
type _ServiceOwner<TId extends string> = TId extends keyof ServiceOwnerMap ? ServiceOwnerMap[TId] : string;
|
|
534
|
+
/** Resolve the owning feature ID for a task. Falls back to `string` (→ BaseContext). */
|
|
535
|
+
type _TaskOwner<TId extends string> = TId extends keyof TaskOwnerMap ? TaskOwnerMap[TId] : string;
|
|
536
|
+
type _SuggestViewKeys = (keyof ViewMap & string) | (string & {});
|
|
537
|
+
type _SuggestWindowKeys = (keyof WindowApiMap & string) | (string & {});
|
|
538
|
+
type _ResolveWindowApi<K extends string> = K extends keyof WindowApiMap ? WindowApiMap[K] : unknown;
|
|
539
|
+
/** Extract the dependency IDs union for a feature. */
|
|
540
|
+
type _DepIds<FId> = FId extends keyof FeatureMap ? FeatureMap[FId]["dependencies"] : never;
|
|
541
|
+
/** Own service keys for a feature. */
|
|
542
|
+
type _OwnSvcKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["services"] & string : never;
|
|
543
|
+
/** Distributive helper — maps a single dep ID to its qualified service keys. */
|
|
544
|
+
type _DepSvcOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["services"] & string}` : never;
|
|
545
|
+
/** Qualified dependency service keys ("dep:svc"), distributes over the deps union. */
|
|
546
|
+
type _DepSvcKeys<FId> = _DepSvcOf<_DepIds<FId>>;
|
|
547
|
+
/** Resolve a service type from own or dependency services. */
|
|
548
|
+
type _ResolveSvc<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["services"] ? FeatureMap[FId]["services"][K] : K extends `${infer D}:${infer S}` ? D extends _DepIds<FId> & keyof FeatureMap ? S extends keyof FeatureMap[D]["services"] ? FeatureMap[D]["services"][S] : unknown : unknown : unknown : unknown;
|
|
549
|
+
/** Resolve a task type from own tasks. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
550
|
+
type _ResolveTask<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["tasks"] ? TaskHandle<FeatureMap[FId]["tasks"][K]> : unknown : unknown;
|
|
551
|
+
/** Resolve a feature handle from dependency features. */
|
|
552
|
+
type _ResolveFeature<FId, K extends string> = FId extends keyof FeatureMap ? K extends _DepIds<FId> & string ? FeatureHandle : unknown : unknown;
|
|
553
|
+
type _SuggestSvcKeys<FId> = _OwnSvcKeys<FId> | _DepSvcKeys<FId>;
|
|
554
|
+
type _SuggestTaskKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["tasks"] & string : never;
|
|
555
|
+
type _SuggestDepKeys<FId> = _DepIds<FId> & string;
|
|
556
|
+
/** Own event keys for a feature. */
|
|
557
|
+
type _OwnEventKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["events"] & string : never;
|
|
558
|
+
/** Distributive helper — maps a single dep ID to its qualified event keys. */
|
|
559
|
+
type _DepEventOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["events"] & string}` : never;
|
|
560
|
+
/** Qualified dependency event keys ("dep:event"), distributes over the deps union. */
|
|
561
|
+
type _DepEventKeys<FId> = _DepEventOf<_DepIds<FId>>;
|
|
562
|
+
/** Resolve own event payload. */
|
|
563
|
+
type _ResolveOwnEvent<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["events"] ? FeatureMap[FId]["events"][K] : unknown : unknown;
|
|
564
|
+
/** Resolve any event payload (own or dep). */
|
|
565
|
+
type _ResolveEvent<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["events"] ? FeatureMap[FId]["events"][K] : K extends `${infer D}:${infer E}` ? D extends _DepIds<FId> & keyof FeatureMap ? E extends keyof FeatureMap[D]["events"] ? FeatureMap[D]["events"][E] : unknown : unknown : unknown : unknown;
|
|
566
|
+
/** All service keys across all features (mapped type distributes over each feature). */
|
|
567
|
+
type _AllSvcKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["services"] & string }[keyof FeatureMap];
|
|
568
|
+
/** All task keys across all features (mapped type distributes over each feature). */
|
|
569
|
+
type _AllTaskKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["tasks"] & string }[keyof FeatureMap];
|
|
570
|
+
/** All feature IDs. */
|
|
571
|
+
type _AllFeatureIds = keyof FeatureMap & string;
|
|
572
|
+
/** All event keys across all features. */
|
|
573
|
+
type _AllEventKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["events"] & string }[keyof FeatureMap];
|
|
574
|
+
type _SuggestAllSvc = _AllSvcKeys | (string & {});
|
|
575
|
+
type _SuggestAllTask = _AllTaskKeys | (string & {});
|
|
576
|
+
type _SuggestAllFeature = _AllFeatureIds | (string & {});
|
|
577
|
+
type _SuggestAllEvent = _AllEventKeys | (string & {});
|
|
578
|
+
/** Flat resolve for unscoped service lookup. */
|
|
579
|
+
type _FlatResolveSvc<K extends string> = { [F in keyof FeatureMap]: K extends keyof FeatureMap[F]["services"] ? FeatureMap[F]["services"][K] : never }[keyof FeatureMap] extends infer U ? [U] extends [never] ? unknown : U : unknown;
|
|
580
|
+
/** Flat resolve for unscoped task lookup. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
581
|
+
type _FlatResolveTask<K extends string> = { [F in keyof FeatureMap]: K extends keyof FeatureMap[F]["tasks"] ? TaskHandle<FeatureMap[F]["tasks"][K]> : never }[keyof FeatureMap] extends infer U ? [U] extends [never] ? unknown : U : unknown;
|
|
582
|
+
/** Flat resolve for unscoped feature lookup. */
|
|
583
|
+
type _FlatResolveFeature<K extends string> = K extends keyof FeatureMap ? FeatureHandle : unknown;
|
|
584
|
+
/** Scoped context — used when `FId` is a concrete feature key. */
|
|
585
|
+
type TypedContext<FId extends keyof FeatureMap, ExcludeSvc extends string = never, ExcludeTask extends string = never> = {
|
|
586
|
+
signal: AbortSignal;
|
|
587
|
+
logger: LoggerContext;
|
|
588
|
+
getService: <K extends Exclude<_SuggestSvcKeys<FId>, ExcludeSvc>>(name: K) => _ResolveSvc<FId, K & string>;
|
|
589
|
+
getTask: <K extends Exclude<_SuggestTaskKeys<FId>, ExcludeTask>>(name: K) => _ResolveTask<FId, K & string>;
|
|
590
|
+
getFeature: <K extends _SuggestDepKeys<FId>>(name: K) => _ResolveFeature<FId, K & string>;
|
|
591
|
+
events: {
|
|
592
|
+
publish<K extends _OwnEventKeys<FId>>(event: K, ...args: undefined extends _ResolveOwnEvent<FId, K> ? [payload?: _ResolveOwnEvent<FId, K>] : [payload: _ResolveOwnEvent<FId, K>]): void;
|
|
593
|
+
on<K extends _OwnEventKeys<FId> | _DepEventKeys<FId>>(event: K, handler: (payload: _ResolveEvent<FId, K>) => void): () => void;
|
|
594
|
+
};
|
|
595
|
+
getWindow: <K extends _SuggestWindowKeys>(id: K) => CreatedWindow<_ResolveWindowApi<K & string>> | null;
|
|
596
|
+
createView: <K extends _SuggestViewKeys>(id: K) => ElectroView;
|
|
597
|
+
getView: <K extends _SuggestViewKeys>(id: K) => ElectroView | null;
|
|
598
|
+
};
|
|
599
|
+
/** Unscoped context — flat suggestions from all features. */
|
|
600
|
+
type BaseContext = {
|
|
601
|
+
signal: AbortSignal;
|
|
602
|
+
logger: LoggerContext;
|
|
603
|
+
getService: <K extends _SuggestAllSvc>(name: K) => _FlatResolveSvc<K & string>;
|
|
604
|
+
getTask: <K extends _SuggestAllTask>(name: K) => _FlatResolveTask<K & string>;
|
|
605
|
+
getFeature: <K extends _SuggestAllFeature>(name: K) => _FlatResolveFeature<K & string>;
|
|
606
|
+
events: {
|
|
607
|
+
publish(event: _SuggestAllEvent, payload?: unknown): void;
|
|
608
|
+
on(event: string, handler: (payload: unknown) => void): () => void;
|
|
609
|
+
};
|
|
610
|
+
getWindow: <K extends _SuggestWindowKeys>(id: K) => CreatedWindow<_ResolveWindowApi<K & string>> | null;
|
|
611
|
+
createView: <K extends _SuggestViewKeys>(id: K) => ElectroView;
|
|
612
|
+
getView: <K extends _SuggestViewKeys>(id: K) => ElectroView | null;
|
|
613
|
+
};
|
|
614
|
+
interface LoggerContext {
|
|
615
|
+
debug(code: string, message: string, details?: Record<string, unknown>): void;
|
|
616
|
+
warn(code: string, message: string, details?: Record<string, unknown>): void;
|
|
617
|
+
error(code: string, message: string, details?: Record<string, unknown>): void;
|
|
618
|
+
}
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/config/types.d.ts
|
|
621
|
+
declare const RUNTIME_BRAND: unique symbol;
|
|
622
|
+
declare const VIEW_BRAND: unique symbol;
|
|
623
|
+
declare const CONFIG_BRAND: unique symbol;
|
|
624
|
+
interface RuntimeDefinition {
|
|
625
|
+
readonly [RUNTIME_BRAND]: true;
|
|
626
|
+
readonly entry: string;
|
|
627
|
+
readonly vite?: UserConfig;
|
|
628
|
+
/** @internal Caller path captured by defineRuntime(). */
|
|
629
|
+
readonly __source: string;
|
|
630
|
+
}
|
|
631
|
+
interface ViewDefinition {
|
|
632
|
+
readonly [VIEW_BRAND]: true;
|
|
633
|
+
readonly name: string;
|
|
634
|
+
readonly entry: string;
|
|
635
|
+
readonly features?: readonly string[];
|
|
636
|
+
readonly vite?: UserConfig;
|
|
637
|
+
readonly preload?: string;
|
|
638
|
+
readonly webPreferences?: Record<string, unknown>;
|
|
639
|
+
/** @internal Caller path captured by defineView(). */
|
|
640
|
+
readonly __source: string;
|
|
641
|
+
}
|
|
642
|
+
interface ElectroConfig {
|
|
643
|
+
readonly [CONFIG_BRAND]: true;
|
|
644
|
+
readonly runtime: RuntimeDefinition;
|
|
645
|
+
readonly views?: readonly ViewDefinition[];
|
|
646
|
+
}
|
|
647
|
+
interface DefineRuntimeInput {
|
|
648
|
+
entry: string;
|
|
649
|
+
vite?: UserConfig;
|
|
650
|
+
}
|
|
651
|
+
/** Suggests known feature IDs from FeatureMap while still allowing arbitrary strings. */
|
|
652
|
+
type SuggestFeatureId = (keyof FeatureMap & string) | (string & {});
|
|
653
|
+
interface DefineViewInput {
|
|
654
|
+
name: string;
|
|
655
|
+
entry: string;
|
|
656
|
+
features?: readonly SuggestFeatureId[];
|
|
657
|
+
vite?: UserConfig;
|
|
658
|
+
preload?: string;
|
|
659
|
+
webPreferences?: Record<string, unknown>;
|
|
660
|
+
}
|
|
661
|
+
interface DefineConfigInput {
|
|
662
|
+
runtime: RuntimeDefinition;
|
|
663
|
+
views?: readonly ViewDefinition[];
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/config/define-config.d.ts
|
|
667
|
+
declare function defineConfig(input: DefineConfigInput): ElectroConfig;
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/config/define-runtime.d.ts
|
|
670
|
+
declare function defineRuntime(input: DefineRuntimeInput): RuntimeDefinition;
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/config/define-view.d.ts
|
|
673
|
+
declare function defineView(input: DefineViewInput): ViewDefinition;
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/core/event-bus/accessor.d.ts
|
|
676
|
+
/**
|
|
677
|
+
* Scoped event access per feature.
|
|
678
|
+
*
|
|
679
|
+
* - `publish("name", payload)` -> publishes as `"ownerId:name"`
|
|
680
|
+
* - `on("dep:name", handler)` -> validates `dep` is a declared dependency
|
|
681
|
+
* - `on("name", handler)` -> subscribes to own `"ownerId:name"`
|
|
682
|
+
*/
|
|
683
|
+
declare class EventAccessor {
|
|
684
|
+
private readonly bus;
|
|
685
|
+
private readonly ownerId;
|
|
686
|
+
private readonly declaredDeps;
|
|
687
|
+
constructor(bus: EventBus, ownerId: string, declaredDeps: Set<string>);
|
|
688
|
+
publish(event: string, payload?: unknown): void;
|
|
689
|
+
on(event: string, handler: EventHandler): () => void;
|
|
690
|
+
}
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/core/event-bus/helpers.d.ts
|
|
693
|
+
/**
|
|
694
|
+
* Creates a typed event definition.
|
|
695
|
+
*
|
|
696
|
+
* @overload Explicit generic — `createEvent<{ version: string }>("ready")`
|
|
697
|
+
* @overload Infer from defaults — `createEvent("ready", { version: "unknown" })`
|
|
698
|
+
*/
|
|
699
|
+
declare function createEvent<T = void>(id: EventId): CreatedEvent<T>;
|
|
700
|
+
declare function createEvent<T>(id: EventId, defaults: T): CreatedEvent<T>;
|
|
701
|
+
//#endregion
|
|
700
702
|
//#region src/core/feature/helpers.d.ts
|
|
701
703
|
/**
|
|
702
704
|
* Method for creating a feature
|