@cordy/electro 1.0.0
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 +791 -0
- package/dist/index.mjs +1592 -0
- package/package.json +67 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
import { BaseWindow } from "electron";
|
|
2
|
+
import { UserConfig } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/config/types.d.ts
|
|
5
|
+
declare const RUNTIME_BRAND: unique symbol;
|
|
6
|
+
declare const WINDOW_BRAND: unique symbol;
|
|
7
|
+
declare const CONFIG_BRAND: unique symbol;
|
|
8
|
+
type WindowLifecycle = "singleton" | "multi";
|
|
9
|
+
type WindowCloseBehavior = "hide" | "destroy";
|
|
10
|
+
type WindowType = "base-window" | "browser-window";
|
|
11
|
+
interface WindowBehavior {
|
|
12
|
+
close: WindowCloseBehavior;
|
|
13
|
+
}
|
|
14
|
+
interface RuntimeDefinition {
|
|
15
|
+
readonly [RUNTIME_BRAND]: true;
|
|
16
|
+
readonly entry: string;
|
|
17
|
+
readonly vite?: UserConfig;
|
|
18
|
+
/** @internal Caller path captured by defineRuntime(). */
|
|
19
|
+
readonly __source: string;
|
|
20
|
+
}
|
|
21
|
+
interface WindowDefinition {
|
|
22
|
+
readonly [WINDOW_BRAND]: true;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly entry: string;
|
|
25
|
+
readonly type?: WindowType;
|
|
26
|
+
readonly features?: readonly string[];
|
|
27
|
+
readonly vite?: UserConfig;
|
|
28
|
+
readonly preload?: string;
|
|
29
|
+
readonly lifecycle?: WindowLifecycle;
|
|
30
|
+
readonly autoShow?: boolean;
|
|
31
|
+
readonly behavior?: WindowBehavior;
|
|
32
|
+
readonly window?: Record<string, unknown>;
|
|
33
|
+
/** @internal Caller path captured by defineWindow(). */
|
|
34
|
+
readonly __source: string;
|
|
35
|
+
}
|
|
36
|
+
interface ElectroConfig {
|
|
37
|
+
readonly [CONFIG_BRAND]: true;
|
|
38
|
+
readonly runtime: RuntimeDefinition;
|
|
39
|
+
readonly windows?: readonly WindowDefinition[];
|
|
40
|
+
}
|
|
41
|
+
interface DefineRuntimeInput {
|
|
42
|
+
entry: string;
|
|
43
|
+
vite?: UserConfig;
|
|
44
|
+
}
|
|
45
|
+
interface DefineWindowInput {
|
|
46
|
+
name: string;
|
|
47
|
+
entry: string;
|
|
48
|
+
type?: WindowType;
|
|
49
|
+
features?: readonly string[];
|
|
50
|
+
vite?: UserConfig;
|
|
51
|
+
preload?: string;
|
|
52
|
+
lifecycle?: WindowLifecycle;
|
|
53
|
+
autoShow?: boolean;
|
|
54
|
+
behavior?: WindowBehavior;
|
|
55
|
+
window?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
interface DefineConfigInput {
|
|
58
|
+
runtime: RuntimeDefinition;
|
|
59
|
+
windows?: readonly WindowDefinition[];
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/config/define-config.d.ts
|
|
63
|
+
declare function defineConfig(input: DefineConfigInput): ElectroConfig;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/config/define-runtime.d.ts
|
|
66
|
+
declare function defineRuntime(input: DefineRuntimeInput): RuntimeDefinition;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/config/define-window.d.ts
|
|
69
|
+
declare function defineWindow(input: DefineWindowInput): WindowDefinition;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/core/event-bus/types.d.ts
|
|
72
|
+
type EventHandler = (payload: unknown) => void;
|
|
73
|
+
type EventSubscription = {
|
|
74
|
+
channel: string;
|
|
75
|
+
handler: EventHandler;
|
|
76
|
+
ownerId: string;
|
|
77
|
+
};
|
|
78
|
+
type EventId = string;
|
|
79
|
+
/**
|
|
80
|
+
* Type-erased event interface for heterogeneous collections.
|
|
81
|
+
*/
|
|
82
|
+
interface EventInstance {
|
|
83
|
+
readonly id: EventId;
|
|
84
|
+
readonly defaults: unknown;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Public interface returned by {@link createEvent}.
|
|
88
|
+
*
|
|
89
|
+
* Generic parameter preserves payload type for codegen inference
|
|
90
|
+
* (`_EventPayload<T>` infers `T` from `payload()` phantom method).
|
|
91
|
+
*/
|
|
92
|
+
interface CreatedEvent<T = void> extends EventInstance {
|
|
93
|
+
readonly id: EventId;
|
|
94
|
+
readonly defaults: T | undefined;
|
|
95
|
+
/** @internal Phantom method for codegen type extraction. Never called. */
|
|
96
|
+
payload(): T;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/core/event-bus/event-bus.d.ts
|
|
100
|
+
declare class EventBus {
|
|
101
|
+
private readonly subscriptions;
|
|
102
|
+
publish(channel: string, payload?: unknown): void;
|
|
103
|
+
subscribe(channel: string, handler: EventHandler, ownerId: string): () => void;
|
|
104
|
+
removeByOwner(ownerId: string): void;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/core/event-bus/accessor.d.ts
|
|
108
|
+
/**
|
|
109
|
+
* Scoped event access per feature.
|
|
110
|
+
*
|
|
111
|
+
* - `publish("name", payload)` -> publishes as `"ownerId:name"`
|
|
112
|
+
* - `on("dep:name", handler)` -> validates `dep` is a declared dependency
|
|
113
|
+
* - `on("name", handler)` -> subscribes to own `"ownerId:name"`
|
|
114
|
+
*/
|
|
115
|
+
declare class EventAccessor {
|
|
116
|
+
private readonly bus;
|
|
117
|
+
private readonly ownerId;
|
|
118
|
+
private readonly declaredDeps;
|
|
119
|
+
constructor(bus: EventBus, ownerId: string, declaredDeps: Set<string>);
|
|
120
|
+
publish(event: string, payload?: unknown): void;
|
|
121
|
+
on(event: string, handler: EventHandler): () => void;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/core/event-bus/helpers.d.ts
|
|
125
|
+
/**
|
|
126
|
+
* Creates a typed event definition.
|
|
127
|
+
*
|
|
128
|
+
* @overload Explicit generic — `createEvent<{ version: string }>("ready")`
|
|
129
|
+
* @overload Infer from defaults — `createEvent("ready", { version: "unknown" })`
|
|
130
|
+
*/
|
|
131
|
+
declare function createEvent<T = void>(id: EventId): CreatedEvent<T>;
|
|
132
|
+
declare function createEvent<T>(id: EventId, defaults: T): CreatedEvent<T>;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/core/feature/enums.d.ts
|
|
135
|
+
declare enum FeatureStatus {
|
|
136
|
+
NONE = "none",
|
|
137
|
+
REGISTERED = "registered",
|
|
138
|
+
INITIALIZING = "initializing",
|
|
139
|
+
READY = "ready",
|
|
140
|
+
ACTIVATING = "activating",
|
|
141
|
+
ACTIVATED = "activated",
|
|
142
|
+
DEACTIVATING = "deactivating",
|
|
143
|
+
DEACTIVATED = "deactivated",
|
|
144
|
+
DESTROYING = "destroying",
|
|
145
|
+
DESTROYED = "destroyed",
|
|
146
|
+
ERROR = "error"
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/window/types.d.ts
|
|
150
|
+
/** A window with an auto-loading `load()` method that resolves dev/prod URLs. */
|
|
151
|
+
type ElectroWindow<T extends BaseWindow = BaseWindow> = T & {
|
|
152
|
+
load(): Promise<void>;
|
|
153
|
+
};
|
|
154
|
+
/** Factory interface for creating platform windows from definitions. */
|
|
155
|
+
interface WindowFactory {
|
|
156
|
+
create(definition: WindowDefinition): BaseWindow;
|
|
157
|
+
}
|
|
158
|
+
/** Snapshot of a tracked window. */
|
|
159
|
+
interface WindowInfo {
|
|
160
|
+
name: string;
|
|
161
|
+
windowId: number;
|
|
162
|
+
destroyed: boolean;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/window/manager.d.ts
|
|
166
|
+
/**
|
|
167
|
+
* WindowManager — registry, creation, and lifecycle coordinator for windows.
|
|
168
|
+
*
|
|
169
|
+
* Manages window definitions and their instances through a WindowFactory
|
|
170
|
+
* abstraction. Enforces singleton/multi lifecycle semantics and provides
|
|
171
|
+
* querying and bulk destruction capabilities.
|
|
172
|
+
*/
|
|
173
|
+
declare class WindowManager {
|
|
174
|
+
private readonly factory;
|
|
175
|
+
private readonly definitions;
|
|
176
|
+
private readonly instances;
|
|
177
|
+
constructor(factory: WindowFactory);
|
|
178
|
+
/** Register a window definition. Throws on duplicate name. */
|
|
179
|
+
registerDefinition(definition: WindowDefinition): void;
|
|
180
|
+
/** Check whether a definition is registered for the given name. */
|
|
181
|
+
hasDefinition(name: string): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Create a window from a registered definition.
|
|
184
|
+
*
|
|
185
|
+
* - Throws if no definition exists for `name`.
|
|
186
|
+
* - For singleton lifecycle (the default), throws if a live instance already exists.
|
|
187
|
+
* - For multi lifecycle, always creates a new instance.
|
|
188
|
+
*/
|
|
189
|
+
createWindow(name: string): ElectroWindow;
|
|
190
|
+
/**
|
|
191
|
+
* Get the first alive window for the given name, or null.
|
|
192
|
+
* Cleans up destroyed instances as a side effect.
|
|
193
|
+
*/
|
|
194
|
+
getWindow(name: string): ElectroWindow | null;
|
|
195
|
+
/** Destroy all instances for the given name. No-op if name is unknown. */
|
|
196
|
+
destroyWindow(name: string): void;
|
|
197
|
+
/** Destroy all tracked windows across all names. */
|
|
198
|
+
destroyAll(): void;
|
|
199
|
+
/** Returns a snapshot of all tracked windows (including destroyed ones). */
|
|
200
|
+
list(): WindowInfo[];
|
|
201
|
+
/** Return alive (non-destroyed) instances for a given name. */
|
|
202
|
+
private getAliveInstances;
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/core/task/enums.d.ts
|
|
206
|
+
declare enum TaskOverlapStrategy {
|
|
207
|
+
Skip = "skip",
|
|
208
|
+
Queue = "queue",
|
|
209
|
+
Parallel = "parallel"
|
|
210
|
+
}
|
|
211
|
+
declare enum TaskStatus {
|
|
212
|
+
Registered = "registered",
|
|
213
|
+
Scheduled = "scheduled",
|
|
214
|
+
Running = "running",
|
|
215
|
+
Stopped = "stopped",
|
|
216
|
+
Failed = "failed"
|
|
217
|
+
}
|
|
218
|
+
declare enum TaskRetryStrategy {
|
|
219
|
+
Fixed = "fixed",
|
|
220
|
+
Exponential = "exponential"
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/core/task/types.d.ts
|
|
224
|
+
type TaskId = string;
|
|
225
|
+
type StopMode = "graceful" | "force";
|
|
226
|
+
type TaskRetryConfig = {
|
|
227
|
+
attempts: number;
|
|
228
|
+
strategy: TaskRetryStrategy;
|
|
229
|
+
delayMs: number;
|
|
230
|
+
};
|
|
231
|
+
type TaskExecutionContext = {
|
|
232
|
+
signal: AbortSignal;
|
|
233
|
+
attempt: number;
|
|
234
|
+
};
|
|
235
|
+
type TaskConfig<TId extends TaskId, TPayload = void> = {
|
|
236
|
+
id: TId;
|
|
237
|
+
cron?: string;
|
|
238
|
+
autoStart?: boolean;
|
|
239
|
+
overlap?: TaskOverlapStrategy;
|
|
240
|
+
dedupeKey?: (payload: TPayload) => string;
|
|
241
|
+
timeoutMs?: number;
|
|
242
|
+
retry?: TaskRetryConfig;
|
|
243
|
+
execute: (ctx: FeatureContext<_TaskOwner<TId>, never, TId>, payload: TPayload, execCtx: TaskExecutionContext) => void | Promise<void>;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Type-erased task interface for heterogeneous collections.
|
|
247
|
+
*
|
|
248
|
+
* Using a non-generic interface (instead of `Task<TaskId, unknown>`)
|
|
249
|
+
* avoids TypeScript variance issues: `TaskConfig.execute` has `payload: TPayload`
|
|
250
|
+
* in a contravariant position, making `Task` invariant in `TPayload`.
|
|
251
|
+
* Interface methods are bivariant, so any `Task<TId, TPayload>` is
|
|
252
|
+
* structurally assignable to `TaskInstance`.
|
|
253
|
+
*/
|
|
254
|
+
interface TaskInstance {
|
|
255
|
+
readonly id: TaskId;
|
|
256
|
+
enable(ctx: FeatureContext<any>): void;
|
|
257
|
+
disable(mode?: StopMode): void;
|
|
258
|
+
start(payload?: unknown): Promise<void>;
|
|
259
|
+
queue(payload: unknown): void;
|
|
260
|
+
stop(): void;
|
|
261
|
+
clear(): void;
|
|
262
|
+
status(): TaskStatusInfo;
|
|
263
|
+
}
|
|
264
|
+
interface TaskStatusInfo {
|
|
265
|
+
taskId: string;
|
|
266
|
+
state: TaskStatus;
|
|
267
|
+
running: boolean;
|
|
268
|
+
queueSize: number;
|
|
269
|
+
lastRunAt: number | null;
|
|
270
|
+
lastSuccessAt: number | null;
|
|
271
|
+
lastErrorAt: number | null;
|
|
272
|
+
lastError: Error | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Public interface returned by {@link createTask}.
|
|
276
|
+
*
|
|
277
|
+
* Hides class internals (private fields) so consumers can safely
|
|
278
|
+
* `export const myTask = createTask({...})` without TypeScript
|
|
279
|
+
* "cannot be named" errors in declaration emit.
|
|
280
|
+
*
|
|
281
|
+
* Generic parameters preserve payload type for codegen inference
|
|
282
|
+
* (`_TaskPayload<T>` infers `TPayload` from `start(payload?)`).
|
|
283
|
+
*/
|
|
284
|
+
interface CreatedTask<TId extends TaskId = TaskId, TPayload = void> {
|
|
285
|
+
readonly id: TId;
|
|
286
|
+
enable(ctx: FeatureContext<any>): void;
|
|
287
|
+
disable(mode?: StopMode): void;
|
|
288
|
+
start(payload?: TPayload): Promise<void>;
|
|
289
|
+
queue(payload: TPayload): void;
|
|
290
|
+
stop(): void;
|
|
291
|
+
clear(): void;
|
|
292
|
+
status(): TaskStatusInfo;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/core/task/handle.d.ts
|
|
296
|
+
/**
|
|
297
|
+
* Ergonomic handle for a single {@link Task}.
|
|
298
|
+
*
|
|
299
|
+
* Provides per-task control: start, queue, stop, enable, disable, clear, status.
|
|
300
|
+
* Created by Feature and bound to `ctx.getTask(name)`.
|
|
301
|
+
*/
|
|
302
|
+
declare class TaskHandle<TPayload = unknown> {
|
|
303
|
+
private readonly task;
|
|
304
|
+
private readonly ctx;
|
|
305
|
+
constructor(task: TaskInstance, ctx?: FeatureContext<any> | undefined);
|
|
306
|
+
/** Execute immediately (respects overlap policy). */
|
|
307
|
+
start(payload?: TPayload): Promise<void>;
|
|
308
|
+
/** Push payload to FIFO queue, processes sequentially. */
|
|
309
|
+
queue(payload: TPayload): void;
|
|
310
|
+
/** Abort current execution. Queue continues processing. */
|
|
311
|
+
stop(): void;
|
|
312
|
+
/** Re-enable the task (cron, ready for start/queue). */
|
|
313
|
+
enable(): void;
|
|
314
|
+
/** Abort current + clear queue + stop cron. */
|
|
315
|
+
disable(mode?: StopMode): void;
|
|
316
|
+
/** Clear the FIFO queue without stopping current execution. */
|
|
317
|
+
clear(): void;
|
|
318
|
+
/** Snapshot of the task's current state. */
|
|
319
|
+
status(): TaskStatusInfo;
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/core/types.d.ts
|
|
323
|
+
/**
|
|
324
|
+
* Declaration-merging registry.
|
|
325
|
+
* Codegen populates this via `declare module "@cordy/electro"`.
|
|
326
|
+
*
|
|
327
|
+
* Each key is a feature ID mapping to its services, tasks, and dependencies.
|
|
328
|
+
*/
|
|
329
|
+
interface FeatureMap {}
|
|
330
|
+
/** Maps service ID → owning feature ID. Populated by codegen. */
|
|
331
|
+
interface ServiceOwnerMap {}
|
|
332
|
+
/** Maps task ID → owning feature ID. Populated by codegen. */
|
|
333
|
+
interface TaskOwnerMap {}
|
|
334
|
+
/** Declaration-merging registry for window types. Codegen populates this. */
|
|
335
|
+
interface WindowMap {}
|
|
336
|
+
/** Resolve the owning feature ID for a service. Falls back to `string` (→ BaseContext). */
|
|
337
|
+
type _ServiceOwner<TId extends string> = TId extends keyof ServiceOwnerMap ? ServiceOwnerMap[TId] : string;
|
|
338
|
+
/** Resolve the owning feature ID for a task. Falls back to `string` (→ BaseContext). */
|
|
339
|
+
type _TaskOwner<TId extends string> = TId extends keyof TaskOwnerMap ? TaskOwnerMap[TId] : string;
|
|
340
|
+
type _SuggestWindowKeys = (keyof WindowMap & string) | (string & {});
|
|
341
|
+
type _ResolveWindow<K extends string> = K extends keyof WindowMap ? ElectroWindow<WindowMap[K]> : ElectroWindow;
|
|
342
|
+
/** Extract the dependency IDs union for a feature. */
|
|
343
|
+
type _DepIds<FId> = FId extends keyof FeatureMap ? FeatureMap[FId]["dependencies"] : never;
|
|
344
|
+
/** Own service keys for a feature. */
|
|
345
|
+
type _OwnSvcKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["services"] & string : never;
|
|
346
|
+
/** Distributive helper — maps a single dep ID to its qualified service keys. */
|
|
347
|
+
type _DepSvcOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["services"] & string}` : never;
|
|
348
|
+
/** Qualified dependency service keys ("dep:svc"), distributes over the deps union. */
|
|
349
|
+
type _DepSvcKeys<FId> = _DepSvcOf<_DepIds<FId>>;
|
|
350
|
+
/** Resolve a service type from own or dependency services. */
|
|
351
|
+
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;
|
|
352
|
+
/** Resolve a task type from own tasks. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
353
|
+
type _ResolveTask<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["tasks"] ? TaskHandle<FeatureMap[FId]["tasks"][K]> : unknown : unknown;
|
|
354
|
+
/** Resolve a feature handle from dependency features. */
|
|
355
|
+
type _ResolveFeature<FId, K extends string> = FId extends keyof FeatureMap ? K extends _DepIds<FId> & string ? FeatureHandle : unknown : unknown;
|
|
356
|
+
type _SuggestSvcKeys<FId> = _OwnSvcKeys<FId> | _DepSvcKeys<FId>;
|
|
357
|
+
type _SuggestTaskKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["tasks"] & string : never;
|
|
358
|
+
type _SuggestDepKeys<FId> = _DepIds<FId> & string;
|
|
359
|
+
/** Own event keys for a feature. */
|
|
360
|
+
type _OwnEventKeys<FId> = FId extends keyof FeatureMap ? keyof FeatureMap[FId]["events"] & string : never;
|
|
361
|
+
/** Distributive helper — maps a single dep ID to its qualified event keys. */
|
|
362
|
+
type _DepEventOf<D> = D extends keyof FeatureMap & string ? `${D}:${keyof FeatureMap[D]["events"] & string}` : never;
|
|
363
|
+
/** Qualified dependency event keys ("dep:event"), distributes over the deps union. */
|
|
364
|
+
type _DepEventKeys<FId> = _DepEventOf<_DepIds<FId>>;
|
|
365
|
+
/** Resolve own event payload. */
|
|
366
|
+
type _ResolveOwnEvent<FId, K extends string> = FId extends keyof FeatureMap ? K extends keyof FeatureMap[FId]["events"] ? FeatureMap[FId]["events"][K] : unknown : unknown;
|
|
367
|
+
/** Resolve any event payload (own or dep). */
|
|
368
|
+
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;
|
|
369
|
+
/** All service keys across all features (mapped type distributes over each feature). */
|
|
370
|
+
type _AllSvcKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["services"] & string }[keyof FeatureMap];
|
|
371
|
+
/** All task keys across all features (mapped type distributes over each feature). */
|
|
372
|
+
type _AllTaskKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["tasks"] & string }[keyof FeatureMap];
|
|
373
|
+
/** All feature IDs. */
|
|
374
|
+
type _AllFeatureIds = keyof FeatureMap & string;
|
|
375
|
+
/** All event keys across all features. */
|
|
376
|
+
type _AllEventKeys = { [F in keyof FeatureMap]: keyof FeatureMap[F]["events"] & string }[keyof FeatureMap];
|
|
377
|
+
type _SuggestAllSvc = _AllSvcKeys | (string & {});
|
|
378
|
+
type _SuggestAllTask = _AllTaskKeys | (string & {});
|
|
379
|
+
type _SuggestAllFeature = _AllFeatureIds | (string & {});
|
|
380
|
+
type _SuggestAllEvent = _AllEventKeys | (string & {});
|
|
381
|
+
/** Flat resolve for unscoped service lookup. */
|
|
382
|
+
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;
|
|
383
|
+
/** Flat resolve for unscoped task lookup. FeatureMap stores payloads; wraps in TaskHandle. */
|
|
384
|
+
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;
|
|
385
|
+
/** Flat resolve for unscoped feature lookup. */
|
|
386
|
+
type _FlatResolveFeature<K extends string> = K extends keyof FeatureMap ? FeatureHandle : unknown;
|
|
387
|
+
/** Scoped context — used when `FId` is a concrete feature key. */
|
|
388
|
+
type TypedContext<FId extends keyof FeatureMap, ExcludeSvc extends string = never, ExcludeTask extends string = never> = {
|
|
389
|
+
signal: AbortSignal;
|
|
390
|
+
logger: LoggerContext;
|
|
391
|
+
getService: <K extends Exclude<_SuggestSvcKeys<FId>, ExcludeSvc>>(name: K) => _ResolveSvc<FId, K & string>;
|
|
392
|
+
getTask: <K extends Exclude<_SuggestTaskKeys<FId>, ExcludeTask>>(name: K) => _ResolveTask<FId, K & string>;
|
|
393
|
+
getFeature: <K extends _SuggestDepKeys<FId>>(name: K) => _ResolveFeature<FId, K & string>;
|
|
394
|
+
events: {
|
|
395
|
+
publish<K extends _OwnEventKeys<FId>>(event: K, ...args: undefined extends _ResolveOwnEvent<FId, K> ? [payload?: _ResolveOwnEvent<FId, K>] : [payload: _ResolveOwnEvent<FId, K>]): void;
|
|
396
|
+
on<K extends _OwnEventKeys<FId> | _DepEventKeys<FId>>(event: K, handler: (payload: _ResolveEvent<FId, K>) => void): () => void;
|
|
397
|
+
};
|
|
398
|
+
createWindow: <K extends _SuggestWindowKeys>(name: K) => _ResolveWindow<K & string>;
|
|
399
|
+
getWindow: <K extends _SuggestWindowKeys>(name: K) => _ResolveWindow<K & string> | null;
|
|
400
|
+
};
|
|
401
|
+
/** Unscoped context — flat suggestions from all features. */
|
|
402
|
+
type BaseContext = {
|
|
403
|
+
signal: AbortSignal;
|
|
404
|
+
logger: LoggerContext;
|
|
405
|
+
getService: <K extends _SuggestAllSvc>(name: K) => _FlatResolveSvc<K & string>;
|
|
406
|
+
getTask: <K extends _SuggestAllTask>(name: K) => _FlatResolveTask<K & string>;
|
|
407
|
+
getFeature: <K extends _SuggestAllFeature>(name: K) => _FlatResolveFeature<K & string>;
|
|
408
|
+
events: {
|
|
409
|
+
publish(event: _SuggestAllEvent, payload?: unknown): void;
|
|
410
|
+
on(event: string, handler: (payload: unknown) => void): () => void;
|
|
411
|
+
};
|
|
412
|
+
createWindow: <K extends _SuggestWindowKeys>(name: K) => _ResolveWindow<K & string>;
|
|
413
|
+
getWindow: <K extends _SuggestWindowKeys>(name: K) => _ResolveWindow<K & string> | null;
|
|
414
|
+
};
|
|
415
|
+
interface LoggerContext {
|
|
416
|
+
debug(code: string, message: string, details?: Record<string, unknown>): void;
|
|
417
|
+
warn(code: string, message: string, details?: Record<string, unknown>): void;
|
|
418
|
+
error(code: string, message: string, details?: Record<string, unknown>): void;
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/core/service/enums.d.ts
|
|
422
|
+
declare enum ServiceScope {
|
|
423
|
+
PRIVATE = "private",
|
|
424
|
+
INTERNAL = "internal",
|
|
425
|
+
EXPOSED = "exposed"
|
|
426
|
+
}
|
|
427
|
+
declare enum ServiceStatus {
|
|
428
|
+
REGISTERED = "registered",
|
|
429
|
+
ACTIVE = "active",
|
|
430
|
+
DESTROYED = "destroyed"
|
|
431
|
+
}
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/core/service/types.d.ts
|
|
434
|
+
type ServiceId = string;
|
|
435
|
+
type ServiceConfig<Scope extends ServiceScope = ServiceScope, TApi = unknown, TId extends ServiceId = ServiceId> = {
|
|
436
|
+
id: TId;
|
|
437
|
+
scope?: Scope;
|
|
438
|
+
api: (ctx: FeatureContext<_ServiceOwner<TId>, TId>) => TApi;
|
|
439
|
+
};
|
|
440
|
+
interface ServiceInfo {
|
|
441
|
+
serviceId: ServiceId;
|
|
442
|
+
scope: ServiceScope;
|
|
443
|
+
state: ServiceStatus;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Type-erased service interface for heterogeneous collections.
|
|
447
|
+
*
|
|
448
|
+
* Mirrors the public API of {@link Service} without exposing private fields.
|
|
449
|
+
* Used internally by {@link ServiceManager} and {@link FeatureConfig}.
|
|
450
|
+
*/
|
|
451
|
+
interface ServiceInstance {
|
|
452
|
+
readonly id: ServiceId;
|
|
453
|
+
readonly scope: ServiceScope;
|
|
454
|
+
build(ctx: FeatureContext<any>): void;
|
|
455
|
+
destroy(): void;
|
|
456
|
+
api(): unknown;
|
|
457
|
+
status(): ServiceInfo;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Public interface returned by {@link createService}.
|
|
461
|
+
*
|
|
462
|
+
* Hides class internals so consumers can safely
|
|
463
|
+
* `export const myService = createService({...})` without TypeScript
|
|
464
|
+
* "cannot be named" errors in declaration emit.
|
|
465
|
+
*
|
|
466
|
+
* Generic parameters preserve scope + API types for codegen inference
|
|
467
|
+
* (`_SvcApi<T>` infers from `api()`).
|
|
468
|
+
*/
|
|
469
|
+
interface CreatedService<Scope extends ServiceScope = ServiceScope, TApi = unknown> {
|
|
470
|
+
readonly id: ServiceId;
|
|
471
|
+
readonly scope: Scope;
|
|
472
|
+
build(ctx: FeatureContext<any>): void;
|
|
473
|
+
destroy(): void;
|
|
474
|
+
api(): TApi | null;
|
|
475
|
+
status(): ServiceInfo;
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/core/feature/types.d.ts
|
|
479
|
+
type FeatureId = string;
|
|
480
|
+
type FeatureContext<FId extends FeatureId = string, ExcludeSvc extends string = never, ExcludeTask extends string = never> = FId extends keyof FeatureMap ? TypedContext<FId, ExcludeSvc, ExcludeTask> : BaseContext;
|
|
481
|
+
/** Suggest known feature IDs while accepting arbitrary strings. */
|
|
482
|
+
type SuggestFeatureIds = (keyof FeatureMap & string) | (string & {});
|
|
483
|
+
type FeatureConfig<FId extends FeatureId> = {
|
|
484
|
+
id: FId;
|
|
485
|
+
critical?: boolean;
|
|
486
|
+
dependencies?: SuggestFeatureIds[];
|
|
487
|
+
services?: ServiceInstance[];
|
|
488
|
+
tasks?: TaskInstance[];
|
|
489
|
+
events?: EventInstance[];
|
|
490
|
+
/**
|
|
491
|
+
* OnInitialize
|
|
492
|
+
* Lifecycle hook called when feature starts initializing
|
|
493
|
+
* @param ctx Feature context
|
|
494
|
+
*/
|
|
495
|
+
onInitialize?: (ctx: FeatureContext<FId>) => void | Promise<void>;
|
|
496
|
+
/**
|
|
497
|
+
* OnActivate
|
|
498
|
+
* Lifecycle hook called when feature starts activating
|
|
499
|
+
* @param ctx Feature context
|
|
500
|
+
*/
|
|
501
|
+
onActivate?: (ctx: FeatureContext<FId>) => void | Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* OnDeactivate
|
|
504
|
+
* Lifecycle hook called when feature starts deactivating
|
|
505
|
+
* @param ctx Feature context
|
|
506
|
+
*/
|
|
507
|
+
onDeactivate?: (ctx: FeatureContext<FId>) => void | Promise<void>;
|
|
508
|
+
/**
|
|
509
|
+
* OnDestroy
|
|
510
|
+
* Lifecycle hook called when feature starts destroying
|
|
511
|
+
* @param ctx Feature context
|
|
512
|
+
*/
|
|
513
|
+
onDestroy?: (ctx: FeatureContext<FId>) => void | Promise<void>;
|
|
514
|
+
};
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/core/service/manager.d.ts
|
|
517
|
+
/**
|
|
518
|
+
* Per-feature registry and lifecycle coordinator for {@link Service} instances.
|
|
519
|
+
*
|
|
520
|
+
* One service per id — `get()` returns `{ api, scope }` directly.
|
|
521
|
+
*/
|
|
522
|
+
declare class ServiceManager {
|
|
523
|
+
private readonly ctx;
|
|
524
|
+
/** Primary storage: `id` → Service */
|
|
525
|
+
private services;
|
|
526
|
+
private _isShutdown;
|
|
527
|
+
constructor(ctx: FeatureContext<any>);
|
|
528
|
+
/** Add a service to the registry. Throws on duplicate id. */
|
|
529
|
+
register(service: ServiceInstance): void;
|
|
530
|
+
/** Remove a service by id. Destroys it before removing. */
|
|
531
|
+
unregister(serviceId: ServiceId): void;
|
|
532
|
+
/** Build all registered services. No-op after shutdown. */
|
|
533
|
+
startup(): void;
|
|
534
|
+
/** Destroy all registered services. Marks manager as shut down. */
|
|
535
|
+
shutdown(): void;
|
|
536
|
+
/**
|
|
537
|
+
* Get a service by id, returning its API and scope.
|
|
538
|
+
*
|
|
539
|
+
* @returns `{ api, scope }` or `null` if service id is unknown or not yet built
|
|
540
|
+
*/
|
|
541
|
+
get(serviceId: ServiceId): {
|
|
542
|
+
api: unknown;
|
|
543
|
+
scope: string;
|
|
544
|
+
} | null;
|
|
545
|
+
/** Return status for a given service id. Throws if unknown. */
|
|
546
|
+
status(serviceId: ServiceId): ServiceInfo;
|
|
547
|
+
/** Return status for all registered services. */
|
|
548
|
+
list(): ServiceInfo[];
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/core/state-machine/types.d.ts
|
|
552
|
+
type StateMachineConfig<TState extends string> = {
|
|
553
|
+
transitions: Record<TState, TState[]>;
|
|
554
|
+
initial: TState;
|
|
555
|
+
name?: string;
|
|
556
|
+
};
|
|
557
|
+
type TransitionListener<TState extends string> = (from: TState, to: TState) => void;
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/core/state-machine/state-machine.d.ts
|
|
560
|
+
declare class StateMachine<TState extends string> {
|
|
561
|
+
private _current;
|
|
562
|
+
private readonly _transitions;
|
|
563
|
+
private readonly _name;
|
|
564
|
+
private readonly _listeners;
|
|
565
|
+
constructor(config: StateMachineConfig<TState>);
|
|
566
|
+
get current(): TState;
|
|
567
|
+
transition(target: TState): void;
|
|
568
|
+
canTransition(target: TState): boolean;
|
|
569
|
+
assertState(...allowed: TState[]): void;
|
|
570
|
+
onTransition(cb: TransitionListener<TState>): () => void;
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/core/feature/manager.d.ts
|
|
574
|
+
declare class FeatureManager {
|
|
575
|
+
private logger;
|
|
576
|
+
private eventBus;
|
|
577
|
+
private readonly registry;
|
|
578
|
+
/** Global service ownership: serviceId → featureId. */
|
|
579
|
+
private readonly serviceOwners;
|
|
580
|
+
/** Global task ownership: taskId → featureId. */
|
|
581
|
+
private readonly taskOwners;
|
|
582
|
+
private windowManager;
|
|
583
|
+
constructor(logger: LoggerContext, eventBus?: EventBus | undefined);
|
|
584
|
+
/** @internal Set the window manager (called by Electron layer before bootstrap). */
|
|
585
|
+
setWindowManager(windowManager: WindowManager): void;
|
|
586
|
+
/**
|
|
587
|
+
* Register a feature or a list of features.
|
|
588
|
+
* If a feature with the same ID is already registered, a warning is logged and the feature is skipped.
|
|
589
|
+
* @throws If a service or task ID is already owned by another feature.
|
|
590
|
+
*/
|
|
591
|
+
register(features: FeatureConfig<any> | FeatureConfig<any>[]): void;
|
|
592
|
+
get(id: FeatureId): Feature<FeatureId> | undefined;
|
|
593
|
+
/** Returns all registered features. */
|
|
594
|
+
list(): Feature<FeatureId>[];
|
|
595
|
+
/**
|
|
596
|
+
* Bootstrap all features in dependency order.
|
|
597
|
+
* Calls initialize -> activate on each feature.
|
|
598
|
+
* The feature receives a context built externally (by Runtime).
|
|
599
|
+
*/
|
|
600
|
+
bootstrap(): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* Initialize a feature.
|
|
603
|
+
* Initializes the feature and sets its state to "ready" or "error".
|
|
604
|
+
*/
|
|
605
|
+
private initialize;
|
|
606
|
+
/**
|
|
607
|
+
* Activate a feature.
|
|
608
|
+
* @param id The ID of the feature to activate.
|
|
609
|
+
* @param allowRetry When true, ERROR state features can be retried (used by enable()).
|
|
610
|
+
*/
|
|
611
|
+
private activate;
|
|
612
|
+
/**
|
|
613
|
+
* Deactivate a feature.
|
|
614
|
+
* @param id The ID of the feature to deactivate.
|
|
615
|
+
*/
|
|
616
|
+
private deactivate;
|
|
617
|
+
private destroy;
|
|
618
|
+
/** Public: re-activate a DEACTIVATED or ERROR feature. */
|
|
619
|
+
enable(id: FeatureId): Promise<void>;
|
|
620
|
+
/** Public: deactivate an ACTIVATED feature. */
|
|
621
|
+
disable(id: FeatureId): Promise<void>;
|
|
622
|
+
shutdown(): Promise<void>;
|
|
623
|
+
private reorder;
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/core/feature/feature.d.ts
|
|
627
|
+
declare class Feature<FId extends FeatureId> {
|
|
628
|
+
readonly config: FeatureConfig<FId>;
|
|
629
|
+
readonly logger: LoggerContext;
|
|
630
|
+
readonly state: StateMachine<FeatureStatus>;
|
|
631
|
+
controller: AbortController;
|
|
632
|
+
context: FeatureContext<any>;
|
|
633
|
+
serviceManager: ServiceManager | null;
|
|
634
|
+
private taskManager;
|
|
635
|
+
private eventBus;
|
|
636
|
+
constructor(config: FeatureConfig<FId>, logger: LoggerContext);
|
|
637
|
+
get id(): FId;
|
|
638
|
+
get status(): FeatureStatus;
|
|
639
|
+
/**
|
|
640
|
+
* Validate and apply an FSM transition.
|
|
641
|
+
* @throws If the transition is not allowed from the current state.
|
|
642
|
+
*/
|
|
643
|
+
transition(target: FeatureStatus): void;
|
|
644
|
+
initialize(features: Feature<FeatureId>[], manager: FeatureManager, eventBus?: EventBus, windowManager?: WindowManager): Promise<void>;
|
|
645
|
+
activate(): Promise<void>;
|
|
646
|
+
deactivate(): Promise<void>;
|
|
647
|
+
destroy(): Promise<void>;
|
|
648
|
+
private buildContext;
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/core/feature/handle.d.ts
|
|
652
|
+
/**
|
|
653
|
+
* Ergonomic handle for a declared dependency Feature.
|
|
654
|
+
*
|
|
655
|
+
* Provides per-feature control: status, enable, disable.
|
|
656
|
+
* Created by Feature and bound to `ctx.getFeature(name)`.
|
|
657
|
+
*/
|
|
658
|
+
declare class FeatureHandle {
|
|
659
|
+
private readonly feature;
|
|
660
|
+
private readonly manager;
|
|
661
|
+
constructor(feature: Feature<FeatureId>, manager: FeatureManager);
|
|
662
|
+
/** Current lifecycle state. */
|
|
663
|
+
status(): FeatureStatus;
|
|
664
|
+
/** Re-activate the feature (from DEACTIVATED or ERROR). */
|
|
665
|
+
enable(): Promise<void>;
|
|
666
|
+
/** Deactivate the feature. */
|
|
667
|
+
disable(): Promise<void>;
|
|
668
|
+
}
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/core/feature/helpers.d.ts
|
|
671
|
+
/**
|
|
672
|
+
* Method for creating a feature
|
|
673
|
+
* @param config - The configuration object for the feature
|
|
674
|
+
* @returns The feature configuration object
|
|
675
|
+
*/
|
|
676
|
+
declare function createFeature<FId extends FeatureId>(config: FeatureConfig<FId>): FeatureConfig<FId>;
|
|
677
|
+
//#endregion
|
|
678
|
+
//#region src/core/logger/types.d.ts
|
|
679
|
+
type LogLevel = "debug" | "warn" | "error";
|
|
680
|
+
type LogEntry = {
|
|
681
|
+
level: LogLevel;
|
|
682
|
+
code: string;
|
|
683
|
+
message: string;
|
|
684
|
+
details?: Record<string, unknown>;
|
|
685
|
+
timestamp: number;
|
|
686
|
+
};
|
|
687
|
+
type LogHandler = (entry: LogEntry) => void;
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/core/runtime/enums.d.ts
|
|
690
|
+
declare enum RuntimeState {
|
|
691
|
+
CREATED = "created",
|
|
692
|
+
STARTING = "starting",
|
|
693
|
+
RUNNING = "running",
|
|
694
|
+
STOPPING = "stopping",
|
|
695
|
+
STOPPED = "stopped",
|
|
696
|
+
FAILED = "failed"
|
|
697
|
+
}
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/core/logger/logger.d.ts
|
|
700
|
+
declare class Logger implements LoggerContext {
|
|
701
|
+
private readonly handlers;
|
|
702
|
+
addHandler(handler: LogHandler): void;
|
|
703
|
+
removeHandler(handler: LogHandler): void;
|
|
704
|
+
debug(code: string, message: string, details?: Record<string, unknown>): void;
|
|
705
|
+
warn(code: string, message: string, details?: Record<string, unknown>): void;
|
|
706
|
+
error(code: string, message: string, details?: Record<string, unknown>): void;
|
|
707
|
+
private emit;
|
|
708
|
+
}
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region src/core/runtime/types.d.ts
|
|
711
|
+
type RuntimeConfig = {
|
|
712
|
+
features?: FeatureConfig<any>[];
|
|
713
|
+
logger?: {
|
|
714
|
+
handlers?: LogHandler[];
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region src/core/runtime/runtime.d.ts
|
|
719
|
+
declare class Runtime {
|
|
720
|
+
readonly state: StateMachine<RuntimeState>;
|
|
721
|
+
readonly logger: Logger;
|
|
722
|
+
private readonly featureManager;
|
|
723
|
+
private readonly eventBus;
|
|
724
|
+
private windowManager;
|
|
725
|
+
constructor(config?: RuntimeConfig);
|
|
726
|
+
/** @internal Inject window manager (called by Electron layer before start). */
|
|
727
|
+
_injectWindowManager(windowManager: WindowManager): void;
|
|
728
|
+
register(features: FeatureConfig<any> | FeatureConfig<any>[]): void;
|
|
729
|
+
start(): Promise<void>;
|
|
730
|
+
shutdown(): Promise<void>;
|
|
731
|
+
enable(id: FeatureId): Promise<void>;
|
|
732
|
+
disable(id: FeatureId): Promise<void>;
|
|
733
|
+
isDegraded(): boolean;
|
|
734
|
+
}
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/core/runtime/helpers.d.ts
|
|
737
|
+
declare function createRuntime(config?: RuntimeConfig): Runtime;
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region src/core/service/helpers.d.ts
|
|
740
|
+
/**
|
|
741
|
+
* Creates a {@link Service} instance from a configuration object.
|
|
742
|
+
*
|
|
743
|
+
* @param config - Service configuration with `id`, `scope`, and `api`.
|
|
744
|
+
* @returns A new `Service` instance ready for registration.
|
|
745
|
+
* @throws If `config.id` is empty.
|
|
746
|
+
*/
|
|
747
|
+
declare function createService<Scope extends ServiceScope, TApi, TId extends ServiceId = ServiceId>(config: ServiceConfig<Scope, TApi, TId>): CreatedService<Scope, TApi>;
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/core/task/helpers.d.ts
|
|
750
|
+
/** Create a {@link Task} from a config object. Throws if `id` is empty. */
|
|
751
|
+
declare function createTask<TId extends TaskId, TPayload = void>(config: TaskConfig<TId, TPayload>): CreatedTask<TId, TPayload>;
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/policy/types.d.ts
|
|
754
|
+
/** Outcome of a policy check. */
|
|
755
|
+
declare enum PolicyDecision {
|
|
756
|
+
ALLOWED = "ALLOWED",
|
|
757
|
+
ACCESS_DENIED = "ACCESS_DENIED",
|
|
758
|
+
WINDOW_NOT_FOUND = "WINDOW_NOT_FOUND"
|
|
759
|
+
}
|
|
760
|
+
/** Result of a policy check with context. */
|
|
761
|
+
interface PolicyResult {
|
|
762
|
+
readonly decision: PolicyDecision;
|
|
763
|
+
readonly windowName: string;
|
|
764
|
+
readonly featureId: string;
|
|
765
|
+
}
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/policy/engine.d.ts
|
|
768
|
+
/**
|
|
769
|
+
* Deny-by-default policy engine for window–feature access control.
|
|
770
|
+
*
|
|
771
|
+
* A window's renderer can only access exposed services of features
|
|
772
|
+
* listed in its `features: []` config. Everything else is denied.
|
|
773
|
+
*
|
|
774
|
+
* Used at:
|
|
775
|
+
* - **Build time** (codegen): generate preload stubs only for allowed features
|
|
776
|
+
* - **Runtime** (IPC routing): gate incoming calls from renderer
|
|
777
|
+
*/
|
|
778
|
+
declare class PolicyEngine {
|
|
779
|
+
private readonly policies;
|
|
780
|
+
constructor(windows: readonly WindowDefinition[]);
|
|
781
|
+
/** Full policy check with decision code and context. */
|
|
782
|
+
check(windowName: string, featureId: string): PolicyResult;
|
|
783
|
+
/** Convenience: returns true only when access is ALLOWED. */
|
|
784
|
+
canAccess(windowName: string, featureId: string): boolean;
|
|
785
|
+
/** Returns the allowed feature IDs for a window. Throws if window unknown. */
|
|
786
|
+
getAllowedFeatures(windowName: string): readonly string[];
|
|
787
|
+
/** Returns all registered window names. */
|
|
788
|
+
getWindowNames(): string[];
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
791
|
+
export { type BaseContext, type CreatedEvent, type CreatedService, type CreatedTask, type DefineConfigInput, type DefineRuntimeInput, type DefineWindowInput, type ElectroConfig, type ElectroWindow, EventAccessor, type EventHandler, type EventId, type EventInstance, type EventSubscription, type FeatureConfig, type FeatureContext, type FeatureHandle, type FeatureId, type FeatureMap, FeatureStatus, type LogEntry, type LogHandler, type LoggerContext, PolicyDecision, PolicyEngine, type PolicyResult, Runtime, type RuntimeConfig, type RuntimeDefinition, RuntimeState, type ServiceConfig, type ServiceId, type ServiceInfo, type ServiceOwnerMap, ServiceScope, ServiceStatus, type StopMode, type TaskConfig, type TaskExecutionContext, type TaskHandle, type TaskId, TaskOverlapStrategy, type TaskOwnerMap, TaskRetryStrategy, TaskStatus, type TaskStatusInfo, type TypedContext, type WindowBehavior, type WindowCloseBehavior, type WindowDefinition, type WindowFactory, type WindowInfo, type WindowLifecycle, type WindowMap, type WindowType, createEvent, createFeature, createRuntime, createService, createTask, defineConfig, defineRuntime, defineWindow };
|