skeleton-crew-runtime 0.1.2 → 0.1.4
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/.tsbuildinfo +1 -0
- package/dist/action-engine.d.ts +0 -75
- package/dist/action-engine.d.ts.map +1 -1
- package/dist/action-engine.js +13 -96
- package/dist/action-engine.js.map +1 -1
- package/dist/event-bus.d.ts +0 -44
- package/dist/event-bus.d.ts.map +1 -1
- package/dist/event-bus.js +13 -59
- package/dist/event-bus.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/performance.d.ts +18 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +31 -0
- package/dist/performance.js.map +1 -0
- package/dist/plugin-registry.d.ts +0 -8
- package/dist/plugin-registry.d.ts.map +1 -1
- package/dist/plugin-registry.js +2 -23
- package/dist/plugin-registry.js.map +1 -1
- package/dist/runtime-context.d.ts +13 -66
- package/dist/runtime-context.d.ts.map +1 -1
- package/dist/runtime-context.js +20 -98
- package/dist/runtime-context.js.map +1 -1
- package/dist/runtime.d.ts +1 -98
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -135
- package/dist/runtime.js.map +1 -1
- package/dist/screen-registry.d.ts +0 -40
- package/dist/screen-registry.d.ts.map +1 -1
- package/dist/screen-registry.js +0 -44
- package/dist/screen-registry.js.map +1 -1
- package/dist/types.d.ts +1 -70
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -27
- package/dist/types.js.map +1 -1
- package/dist/ui-bridge.d.ts +0 -27
- package/dist/ui-bridge.d.ts.map +1 -1
- package/dist/ui-bridge.js +0 -29
- package/dist/ui-bridge.js.map +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../src/performance.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,MAAM,CAAC;IACxC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAKD,qBAAa,sBAAuB,YAAW,kBAAkB;IAC/D,UAAU,IAAI,MAAM,MAAM;IAI1B,YAAY,IAAI,IAAI;IAIpB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGrC;AAKD,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,OAAO,CAAC,OAAO,CAAkC;IAEjD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,MAAM;IASvC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/C,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGrC;AAKD,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,OAAe,GAAG,kBAAkB,CAErF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class NoOpPerformanceMonitor {
|
|
2
|
+
startTimer() {
|
|
3
|
+
return () => 0;
|
|
4
|
+
}
|
|
5
|
+
recordMetric() {
|
|
6
|
+
}
|
|
7
|
+
getMetrics() {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class SimplePerformanceMonitor {
|
|
12
|
+
metrics = new Map();
|
|
13
|
+
startTimer(label) {
|
|
14
|
+
const start = performance.now();
|
|
15
|
+
return () => {
|
|
16
|
+
const duration = performance.now() - start;
|
|
17
|
+
this.recordMetric(label, duration);
|
|
18
|
+
return duration;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
recordMetric(name, value) {
|
|
22
|
+
this.metrics.set(name, value);
|
|
23
|
+
}
|
|
24
|
+
getMetrics() {
|
|
25
|
+
return Object.fromEntries(this.metrics);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createPerformanceMonitor(enabled = false) {
|
|
29
|
+
return enabled ? new SimplePerformanceMonitor() : new NoOpPerformanceMonitor();
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../src/performance.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,sBAAsB;IACjC,UAAU;QACR,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,YAAY;IAEZ,CAAC;IAED,UAAU;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAKD,MAAM,OAAO,wBAAwB;IAC3B,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEjD,UAAU,CAAC,KAAa;QACtB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YAC3C,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACnC,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,KAAa;QACtC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,UAAU;QACR,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AAKD,MAAM,UAAU,wBAAwB,CAAC,UAAmB,KAAK;IAC/D,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC,CAAC,IAAI,sBAAsB,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -7,14 +7,6 @@ export declare class PluginRegistry {
|
|
|
7
7
|
registerPlugin(plugin: PluginDefinition): void;
|
|
8
8
|
getPlugin(name: string): PluginDefinition | null;
|
|
9
9
|
getAllPlugins(): PluginDefinition[];
|
|
10
|
-
/**
|
|
11
|
-
* Returns the names of all successfully initialized plugins.
|
|
12
|
-
* Returns an array copy to prevent external mutation.
|
|
13
|
-
*
|
|
14
|
-
* @returns Array of initialized plugin names in initialization order
|
|
15
|
-
*
|
|
16
|
-
* Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
|
|
17
|
-
*/
|
|
18
10
|
getInitializedPlugins(): string[];
|
|
19
11
|
executeSetup(context: RuntimeContext): Promise<void>;
|
|
20
12
|
executeDispose(context: RuntimeContext): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAA+C,MAAM,YAAY,CAAC;AAEnH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,kBAAkB,CAAW;IACrC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAM1B,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAoB9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIhD,aAAa,IAAI,gBAAgB,EAAE;
|
|
1
|
+
{"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAA+C,MAAM,YAAY,CAAC;AAEnH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,kBAAkB,CAAW;IACrC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAM1B,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAoB9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIhD,aAAa,IAAI,gBAAgB,EAAE;IAanC,qBAAqB,IAAI,MAAM,EAAE;IAK3B,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CpD,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB5D,KAAK,IAAI,IAAI;CAId"}
|
package/dist/plugin-registry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ValidationError, DuplicateRegistrationError } from './types.js';
|
|
2
2
|
export class PluginRegistry {
|
|
3
3
|
plugins;
|
|
4
|
-
initializedPlugins;
|
|
4
|
+
initializedPlugins;
|
|
5
5
|
logger;
|
|
6
6
|
constructor(logger) {
|
|
7
7
|
this.plugins = new Map();
|
|
@@ -9,7 +9,6 @@ export class PluginRegistry {
|
|
|
9
9
|
this.logger = logger;
|
|
10
10
|
}
|
|
11
11
|
registerPlugin(plugin) {
|
|
12
|
-
// Validate required fields with ValidationError
|
|
13
12
|
if (!plugin.name || typeof plugin.name !== 'string') {
|
|
14
13
|
throw new ValidationError('Plugin', 'name');
|
|
15
14
|
}
|
|
@@ -19,7 +18,6 @@ export class PluginRegistry {
|
|
|
19
18
|
if (!plugin.setup || typeof plugin.setup !== 'function') {
|
|
20
19
|
throw new ValidationError('Plugin', 'setup', plugin.name);
|
|
21
20
|
}
|
|
22
|
-
// Check for duplicate plugin name with DuplicateRegistrationError
|
|
23
21
|
if (this.plugins.has(plugin.name)) {
|
|
24
22
|
throw new DuplicateRegistrationError('Plugin', plugin.name);
|
|
25
23
|
}
|
|
@@ -29,38 +27,24 @@ export class PluginRegistry {
|
|
|
29
27
|
return this.plugins.get(name) ?? null;
|
|
30
28
|
}
|
|
31
29
|
getAllPlugins() {
|
|
32
|
-
// Return array copy to prevent external mutation
|
|
33
30
|
return Array.from(this.plugins.values());
|
|
34
31
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Returns the names of all successfully initialized plugins.
|
|
37
|
-
* Returns an array copy to prevent external mutation.
|
|
38
|
-
*
|
|
39
|
-
* @returns Array of initialized plugin names in initialization order
|
|
40
|
-
*
|
|
41
|
-
* Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
|
|
42
|
-
*/
|
|
43
32
|
getInitializedPlugins() {
|
|
44
|
-
// Return array copy to prevent external mutation
|
|
45
33
|
return [...this.initializedPlugins];
|
|
46
34
|
}
|
|
47
35
|
async executeSetup(context) {
|
|
48
36
|
const initialized = [];
|
|
49
37
|
let failingPluginName;
|
|
50
38
|
try {
|
|
51
|
-
// Execute plugin setup callbacks sequentially in registration order
|
|
52
39
|
for (const plugin of this.plugins.values()) {
|
|
53
|
-
failingPluginName = plugin.name;
|
|
54
|
-
// Support both sync and async setup callbacks
|
|
40
|
+
failingPluginName = plugin.name;
|
|
55
41
|
await plugin.setup(context);
|
|
56
|
-
// Track successfully initialized plugins
|
|
57
42
|
initialized.push(plugin.name);
|
|
58
43
|
this.initializedPlugins.push(plugin.name);
|
|
59
44
|
this.logger.debug(`Plugin "${plugin.name}" initialized successfully`);
|
|
60
45
|
}
|
|
61
46
|
}
|
|
62
47
|
catch (error) {
|
|
63
|
-
// Rollback: dispose already-initialized plugins in reverse order
|
|
64
48
|
this.logger.error('Plugin setup failed, rolling back initialized plugins');
|
|
65
49
|
for (let i = initialized.length - 1; i >= 0; i--) {
|
|
66
50
|
const pluginName = initialized[i];
|
|
@@ -75,26 +59,21 @@ export class PluginRegistry {
|
|
|
75
59
|
}
|
|
76
60
|
}
|
|
77
61
|
}
|
|
78
|
-
// Clear initializedPlugins after rollback
|
|
79
62
|
this.initializedPlugins = [];
|
|
80
|
-
// Re-throw with context including plugin name
|
|
81
63
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
64
|
throw new Error(`Plugin "${failingPluginName}" setup failed: ${errorMessage}`);
|
|
83
65
|
}
|
|
84
66
|
}
|
|
85
67
|
async executeDispose(context) {
|
|
86
|
-
// Dispose in reverse order of initialization
|
|
87
68
|
for (let i = this.initializedPlugins.length - 1; i >= 0; i--) {
|
|
88
69
|
const pluginName = this.initializedPlugins[i];
|
|
89
70
|
const plugin = this.plugins.get(pluginName);
|
|
90
71
|
if (plugin?.dispose) {
|
|
91
72
|
try {
|
|
92
|
-
// Support both sync and async dispose callbacks
|
|
93
73
|
await plugin.dispose(context);
|
|
94
74
|
this.logger.debug(`Disposed plugin: ${pluginName}`);
|
|
95
75
|
}
|
|
96
76
|
catch (error) {
|
|
97
|
-
// Log dispose errors but continue cleanup
|
|
98
77
|
this.logger.error(`Plugin "${pluginName}" dispose failed`, error);
|
|
99
78
|
}
|
|
100
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,eAAe,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEnH,MAAM,OAAO,cAAc;IACjB,OAAO,CAAgC;IACvC,kBAAkB,CAAW
|
|
1
|
+
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,eAAe,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEnH,MAAM,OAAO,cAAc;IACjB,OAAO,CAAgC;IACvC,kBAAkB,CAAW;IAC7B,MAAM,CAAS;IAEvB,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,cAAc,CAAC,MAAwB;QAErC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KA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K,CAAC,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,WAAW,iBAAiB,mBAAmB,YAAY,EAAE,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAuB;QAE1C,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAE5C,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,IAAI,CAAC;oBAEH,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;gBACtD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAEf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,UAAU,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { RuntimeContext,
|
|
1
|
+
import type { RuntimeContext, IntrospectionAPI } from './types.js';
|
|
2
2
|
import type { ScreenRegistry } from './screen-registry.js';
|
|
3
3
|
import type { ActionEngine } from './action-engine.js';
|
|
4
4
|
import type { PluginRegistry } from './plugin-registry.js';
|
|
5
5
|
import type { EventBus } from './event-bus.js';
|
|
6
6
|
import type { Runtime } from './types.js';
|
|
7
|
-
/**
|
|
8
|
-
* RuntimeContext provides a safe API facade for subsystems.
|
|
9
|
-
* Passed to plugins and action handlers without exposing internal mutable structures.
|
|
10
|
-
*
|
|
11
|
-
* Requirements: 1.2, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
|
|
12
|
-
*/
|
|
13
7
|
export declare class RuntimeContextImpl implements RuntimeContext {
|
|
14
8
|
private screenRegistry;
|
|
15
9
|
private actionEngine;
|
|
@@ -18,69 +12,22 @@ export declare class RuntimeContextImpl implements RuntimeContext {
|
|
|
18
12
|
private runtime;
|
|
19
13
|
private frozenHostContext;
|
|
20
14
|
private introspectionAPI;
|
|
15
|
+
private cachedScreensAPI;
|
|
16
|
+
private cachedActionsAPI;
|
|
17
|
+
private cachedPluginsAPI;
|
|
18
|
+
private cachedEventsAPI;
|
|
21
19
|
constructor(screenRegistry: ScreenRegistry, actionEngine: ActionEngine, pluginRegistry: PluginRegistry, eventBus: EventBus, runtime: Runtime, hostContext: Record<string, unknown>);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
get
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Actions API - exposes Action Engine operations
|
|
33
|
-
* Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
|
|
34
|
-
*/
|
|
35
|
-
get actions(): {
|
|
36
|
-
registerAction: <P = unknown, R = unknown>(action: ActionDefinition<P, R>) => (() => void);
|
|
37
|
-
runAction: <P = unknown, R = unknown>(id: string, params?: P) => Promise<R>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Plugins API - exposes Plugin Registry operations
|
|
41
|
-
* Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
|
|
42
|
-
*/
|
|
43
|
-
get plugins(): {
|
|
44
|
-
registerPlugin: (plugin: PluginDefinition) => void;
|
|
45
|
-
getPlugin: (name: string) => PluginDefinition | null;
|
|
46
|
-
getAllPlugins: () => PluginDefinition[];
|
|
47
|
-
getInitializedPlugins: () => string[];
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Events API - exposes Event Bus operations
|
|
51
|
-
* Requirements: 12.1, 12.2, 12.3, 12.4, 12.5
|
|
52
|
-
*/
|
|
53
|
-
get events(): {
|
|
54
|
-
emit: (event: string, data?: unknown) => void;
|
|
55
|
-
emitAsync: (event: string, data?: unknown) => Promise<void>;
|
|
56
|
-
on: (event: string, handler: (data: unknown) => void) => (() => void);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Returns the Runtime instance
|
|
60
|
-
* Requirement: 9.6
|
|
61
|
-
*/
|
|
20
|
+
get screens(): any;
|
|
21
|
+
private createScreensAPI;
|
|
22
|
+
get actions(): any;
|
|
23
|
+
private createActionsAPI;
|
|
24
|
+
get plugins(): any;
|
|
25
|
+
private createPluginsAPI;
|
|
26
|
+
get events(): any;
|
|
27
|
+
private createEventsAPI;
|
|
62
28
|
getRuntime(): Runtime;
|
|
63
|
-
/**
|
|
64
|
-
* Host context - readonly access to injected host services
|
|
65
|
-
* Requirements: 1.2, 1.3, 1.4
|
|
66
|
-
*
|
|
67
|
-
* Returns a cached frozen shallow copy of the host context to prevent mutation.
|
|
68
|
-
* This ensures plugins can access host services but cannot modify them.
|
|
69
|
-
* The frozen copy is cached to avoid memory leaks from repeated access.
|
|
70
|
-
*/
|
|
71
29
|
get host(): Readonly<Record<string, unknown>>;
|
|
72
|
-
/**
|
|
73
|
-
* Introspection API - query runtime metadata
|
|
74
|
-
* Requirements: 3.1, 4.1, 5.1, 6.1
|
|
75
|
-
*
|
|
76
|
-
* Returns a cached introspection API object to prevent memory leaks
|
|
77
|
-
* from repeated access.
|
|
78
|
-
*/
|
|
79
30
|
get introspect(): IntrospectionAPI;
|
|
80
|
-
/**
|
|
81
|
-
* Creates the introspection API object.
|
|
82
|
-
* Called once during construction and cached.
|
|
83
|
-
*/
|
|
84
31
|
private createIntrospectionAPI;
|
|
85
32
|
}
|
|
86
33
|
//# sourceMappingURL=runtime-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwD,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAwC1C,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,iBAAiB,CAAoC;IAC7D,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,eAAe,CAAM;gBAG3B,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA0BtC,IAAI,OAAO,QAEV;IAED,OAAO,CAAC,gBAAgB;IAkBxB,IAAI,OAAO,QAEV;IAED,OAAO,CAAC,gBAAgB;IAexB,IAAI,OAAO,QAEV;IAED,OAAO,CAAC,gBAAgB;IAqBxB,IAAI,MAAM,QAET;IAED,OAAO,CAAC,eAAe;IAkBvB,UAAU,IAAI,OAAO;IAYrB,IAAI,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE5C;IASD,IAAI,UAAU,IAAI,gBAAgB,CAEjC;IAMD,OAAO,CAAC,sBAAsB;CAkG/B"}
|
package/dist/runtime-context.js
CHANGED
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep freeze utility - recursively freezes an object and all nested objects.
|
|
3
|
-
* Internal use only, not exported.
|
|
4
|
-
*
|
|
5
|
-
* Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
|
|
6
|
-
*
|
|
7
|
-
* @param obj - The object to deep freeze
|
|
8
|
-
* @returns The frozen object with proper typing
|
|
9
|
-
*/
|
|
10
1
|
function deepFreeze(obj) {
|
|
11
|
-
// Freeze the object itself (Requirement 7.1)
|
|
12
2
|
Object.freeze(obj);
|
|
13
|
-
// Iterate over all properties (Requirement 7.2)
|
|
14
3
|
Object.getOwnPropertyNames(obj).forEach(prop => {
|
|
15
4
|
const value = obj[prop];
|
|
16
|
-
// Skip functions (Requirement 7.4)
|
|
17
5
|
if (typeof value === 'function') {
|
|
18
6
|
return;
|
|
19
7
|
}
|
|
20
|
-
// Skip already frozen objects (Requirement 7.5)
|
|
21
8
|
if (value && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
22
|
-
// Recursively freeze nested objects and arrays (Requirements 7.2, 7.3)
|
|
23
9
|
deepFreeze(value);
|
|
24
10
|
}
|
|
25
11
|
});
|
|
26
12
|
return obj;
|
|
27
13
|
}
|
|
28
|
-
/**
|
|
29
|
-
* RuntimeContext provides a safe API facade for subsystems.
|
|
30
|
-
* Passed to plugins and action handlers without exposing internal mutable structures.
|
|
31
|
-
*
|
|
32
|
-
* Requirements: 1.2, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
|
|
33
|
-
*/
|
|
34
14
|
export class RuntimeContextImpl {
|
|
35
15
|
screenRegistry;
|
|
36
16
|
actionEngine;
|
|
@@ -39,24 +19,27 @@ export class RuntimeContextImpl {
|
|
|
39
19
|
runtime;
|
|
40
20
|
frozenHostContext;
|
|
41
21
|
introspectionAPI;
|
|
22
|
+
cachedScreensAPI;
|
|
23
|
+
cachedActionsAPI;
|
|
24
|
+
cachedPluginsAPI;
|
|
25
|
+
cachedEventsAPI;
|
|
42
26
|
constructor(screenRegistry, actionEngine, pluginRegistry, eventBus, runtime, hostContext) {
|
|
43
27
|
this.screenRegistry = screenRegistry;
|
|
44
28
|
this.actionEngine = actionEngine;
|
|
45
29
|
this.pluginRegistry = pluginRegistry;
|
|
46
30
|
this.eventBus = eventBus;
|
|
47
31
|
this.runtime = runtime;
|
|
48
|
-
// Cache the frozen copy to avoid creating new objects on every access
|
|
49
|
-
// This prevents memory leaks when host context is accessed repeatedly
|
|
50
32
|
this.frozenHostContext = Object.freeze({ ...hostContext });
|
|
51
|
-
// Cache the introspection API to avoid creating new objects on every access
|
|
52
|
-
// This prevents memory leaks when introspection is used repeatedly
|
|
53
33
|
this.introspectionAPI = this.createIntrospectionAPI();
|
|
34
|
+
this.cachedScreensAPI = this.createScreensAPI();
|
|
35
|
+
this.cachedActionsAPI = this.createActionsAPI();
|
|
36
|
+
this.cachedPluginsAPI = this.createPluginsAPI();
|
|
37
|
+
this.cachedEventsAPI = this.createEventsAPI();
|
|
54
38
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Screens API - exposes Screen Registry operations
|
|
57
|
-
* Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 10.1, 10.2, 10.3, 10.4, 10.5
|
|
58
|
-
*/
|
|
59
39
|
get screens() {
|
|
40
|
+
return this.cachedScreensAPI;
|
|
41
|
+
}
|
|
42
|
+
createScreensAPI() {
|
|
60
43
|
return {
|
|
61
44
|
registerScreen: (screen) => {
|
|
62
45
|
return this.screenRegistry.registerScreen(screen);
|
|
@@ -69,11 +52,10 @@ export class RuntimeContextImpl {
|
|
|
69
52
|
}
|
|
70
53
|
};
|
|
71
54
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Actions API - exposes Action Engine operations
|
|
74
|
-
* Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
|
|
75
|
-
*/
|
|
76
55
|
get actions() {
|
|
56
|
+
return this.cachedActionsAPI;
|
|
57
|
+
}
|
|
58
|
+
createActionsAPI() {
|
|
77
59
|
return {
|
|
78
60
|
registerAction: (action) => {
|
|
79
61
|
return this.actionEngine.registerAction(action);
|
|
@@ -83,11 +65,10 @@ export class RuntimeContextImpl {
|
|
|
83
65
|
}
|
|
84
66
|
};
|
|
85
67
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Plugins API - exposes Plugin Registry operations
|
|
88
|
-
* Requirements: 13.1, 13.2, 13.3, 13.4, 13.5
|
|
89
|
-
*/
|
|
90
68
|
get plugins() {
|
|
69
|
+
return this.cachedPluginsAPI;
|
|
70
|
+
}
|
|
71
|
+
createPluginsAPI() {
|
|
91
72
|
return {
|
|
92
73
|
registerPlugin: (plugin) => {
|
|
93
74
|
this.pluginRegistry.registerPlugin(plugin);
|
|
@@ -103,11 +84,10 @@ export class RuntimeContextImpl {
|
|
|
103
84
|
}
|
|
104
85
|
};
|
|
105
86
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Events API - exposes Event Bus operations
|
|
108
|
-
* Requirements: 12.1, 12.2, 12.3, 12.4, 12.5
|
|
109
|
-
*/
|
|
110
87
|
get events() {
|
|
88
|
+
return this.cachedEventsAPI;
|
|
89
|
+
}
|
|
90
|
+
createEventsAPI() {
|
|
111
91
|
return {
|
|
112
92
|
emit: (event, data) => {
|
|
113
93
|
this.eventBus.emit(event, data);
|
|
@@ -120,114 +100,57 @@ export class RuntimeContextImpl {
|
|
|
120
100
|
}
|
|
121
101
|
};
|
|
122
102
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Returns the Runtime instance
|
|
125
|
-
* Requirement: 9.6
|
|
126
|
-
*/
|
|
127
103
|
getRuntime() {
|
|
128
104
|
return this.runtime;
|
|
129
105
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Host context - readonly access to injected host services
|
|
132
|
-
* Requirements: 1.2, 1.3, 1.4
|
|
133
|
-
*
|
|
134
|
-
* Returns a cached frozen shallow copy of the host context to prevent mutation.
|
|
135
|
-
* This ensures plugins can access host services but cannot modify them.
|
|
136
|
-
* The frozen copy is cached to avoid memory leaks from repeated access.
|
|
137
|
-
*/
|
|
138
106
|
get host() {
|
|
139
107
|
return this.frozenHostContext;
|
|
140
108
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Introspection API - query runtime metadata
|
|
143
|
-
* Requirements: 3.1, 4.1, 5.1, 6.1
|
|
144
|
-
*
|
|
145
|
-
* Returns a cached introspection API object to prevent memory leaks
|
|
146
|
-
* from repeated access.
|
|
147
|
-
*/
|
|
148
109
|
get introspect() {
|
|
149
110
|
return this.introspectionAPI;
|
|
150
111
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Creates the introspection API object.
|
|
153
|
-
* Called once during construction and cached.
|
|
154
|
-
*/
|
|
155
112
|
createIntrospectionAPI() {
|
|
156
113
|
return {
|
|
157
|
-
/**
|
|
158
|
-
* List all registered action IDs
|
|
159
|
-
* Requirements: 3.1
|
|
160
|
-
*/
|
|
161
114
|
listActions: () => {
|
|
162
115
|
return this.actionEngine.getAllActions().map(action => action.id);
|
|
163
116
|
},
|
|
164
|
-
/**
|
|
165
|
-
* Get action metadata by ID (excludes handler function)
|
|
166
|
-
* Requirements: 3.2, 3.3, 3.4, 3.5
|
|
167
|
-
*/
|
|
168
117
|
getActionDefinition: (id) => {
|
|
169
118
|
const action = this.actionEngine.getAction(id);
|
|
170
119
|
if (!action)
|
|
171
120
|
return null;
|
|
172
|
-
// Extract only id and timeout (exclude handler function)
|
|
173
121
|
const metadata = {
|
|
174
122
|
id: action.id,
|
|
175
123
|
timeout: action.timeout
|
|
176
124
|
};
|
|
177
|
-
// Deep freeze the metadata
|
|
178
125
|
return deepFreeze(metadata);
|
|
179
126
|
},
|
|
180
|
-
/**
|
|
181
|
-
* List all registered plugin names
|
|
182
|
-
* Requirements: 4.1
|
|
183
|
-
*/
|
|
184
127
|
listPlugins: () => {
|
|
185
128
|
return this.pluginRegistry.getAllPlugins().map(plugin => plugin.name);
|
|
186
129
|
},
|
|
187
|
-
/**
|
|
188
|
-
* Get plugin metadata by name (excludes setup/dispose functions)
|
|
189
|
-
* Requirements: 4.2, 4.3, 4.4, 4.5
|
|
190
|
-
*/
|
|
191
130
|
getPluginDefinition: (name) => {
|
|
192
131
|
const plugin = this.pluginRegistry.getPlugin(name);
|
|
193
132
|
if (!plugin)
|
|
194
133
|
return null;
|
|
195
|
-
// Extract only name and version (exclude setup/dispose functions)
|
|
196
134
|
const metadata = {
|
|
197
135
|
name: plugin.name,
|
|
198
136
|
version: plugin.version
|
|
199
137
|
};
|
|
200
|
-
// Deep freeze the metadata
|
|
201
138
|
return deepFreeze(metadata);
|
|
202
139
|
},
|
|
203
|
-
/**
|
|
204
|
-
* List all registered screen IDs
|
|
205
|
-
* Requirements: 5.1
|
|
206
|
-
*/
|
|
207
140
|
listScreens: () => {
|
|
208
141
|
return this.screenRegistry.getAllScreens().map(screen => screen.id);
|
|
209
142
|
},
|
|
210
|
-
/**
|
|
211
|
-
* Get screen definition by ID (includes all properties)
|
|
212
|
-
* Requirements: 5.2, 5.3, 5.4, 5.5
|
|
213
|
-
*/
|
|
214
143
|
getScreenDefinition: (id) => {
|
|
215
144
|
const screen = this.screenRegistry.getScreen(id);
|
|
216
145
|
if (!screen)
|
|
217
146
|
return null;
|
|
218
|
-
// Include all screen properties
|
|
219
147
|
const metadata = {
|
|
220
148
|
id: screen.id,
|
|
221
149
|
title: screen.title,
|
|
222
150
|
component: screen.component
|
|
223
151
|
};
|
|
224
|
-
// Deep freeze the metadata
|
|
225
152
|
return deepFreeze(metadata);
|
|
226
153
|
},
|
|
227
|
-
/**
|
|
228
|
-
* Get runtime metadata with statistics
|
|
229
|
-
* Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
|
|
230
|
-
*/
|
|
231
154
|
getMetadata: () => {
|
|
232
155
|
const metadata = {
|
|
233
156
|
runtimeVersion: '0.1.0',
|
|
@@ -235,7 +158,6 @@ export class RuntimeContextImpl {
|
|
|
235
158
|
totalPlugins: this.pluginRegistry.getAllPlugins().length,
|
|
236
159
|
totalScreens: this.screenRegistry.getAllScreens().length
|
|
237
160
|
};
|
|
238
|
-
// Deep freeze the metadata
|
|
239
161
|
return deepFreeze(metadata);
|
|
240
162
|
}
|
|
241
163
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-context.js","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-context.js","sourceRoot":"","sources":["../src/runtime-context.ts"],"names":[],"mappings":"AAgBA,SAAS,UAAU,CAAI,GAAM;IAE3B,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAGnB,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7C,MAAM,KAAK,GAAI,GAAW,CAAC,IAAI,CAAC,CAAC;QAGjC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAGD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAElE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAkB,CAAC;AAC5B,CAAC;AAQD,MAAM,OAAO,kBAAkB;IACrB,cAAc,CAAiB;IAC/B,YAAY,CAAe;IAC3B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,EAAE,CAAC,MAAM;iBACzD,CAAC;gBAGF,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { RuntimeContext, UIProvider, PluginDefinition, RuntimeOptions } from './types.js';
|
|
2
2
|
import { RuntimeState } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Runtime is the main orchestrator that coordinates all subsystems.
|
|
5
|
-
* Handles initialization, shutdown, and lifecycle state tracking.
|
|
6
|
-
*
|
|
7
|
-
* Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 3.1, 3.5, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 9.7, 9.9, 15.1, 15.3, 15.5, 16.1, 16.2, 16.3, 16.4, 16.5
|
|
8
|
-
*/
|
|
9
3
|
export declare class Runtime {
|
|
10
4
|
private plugins;
|
|
11
5
|
private screens;
|
|
@@ -18,108 +12,17 @@ export declare class Runtime {
|
|
|
18
12
|
private logger;
|
|
19
13
|
private state;
|
|
20
14
|
private hostContext;
|
|
21
|
-
|
|
22
|
-
* Creates a new Runtime instance with optional configuration.
|
|
23
|
-
*
|
|
24
|
-
* @param options - Optional configuration object
|
|
25
|
-
* @param options.logger - Custom logger implementation (defaults to ConsoleLogger)
|
|
26
|
-
* @param options.hostContext - Host application services to inject (defaults to empty object)
|
|
27
|
-
*
|
|
28
|
-
* Requirements: 1.1, 1.5, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6
|
|
29
|
-
*/
|
|
15
|
+
private performanceMonitor;
|
|
30
16
|
constructor(options?: RuntimeOptions);
|
|
31
|
-
/**
|
|
32
|
-
* Validates host context and logs warnings for common mistakes.
|
|
33
|
-
* Does not throw errors or modify the context.
|
|
34
|
-
*
|
|
35
|
-
* @param context - The host context to validate
|
|
36
|
-
*
|
|
37
|
-
* Requirements: 2.1, 2.2, 2.3, 2.4
|
|
38
|
-
*/
|
|
39
17
|
private validateHostContext;
|
|
40
|
-
/**
|
|
41
|
-
* Registers a plugin before initialization.
|
|
42
|
-
* Plugins registered this way will have their setup callbacks executed during initialize().
|
|
43
|
-
*
|
|
44
|
-
* @param plugin - The plugin definition to register
|
|
45
|
-
* @throws Error if runtime is already initialized
|
|
46
|
-
*/
|
|
47
18
|
registerPlugin(plugin: PluginDefinition): void;
|
|
48
|
-
/**
|
|
49
|
-
* Initializes the runtime following the strict initialization sequence.
|
|
50
|
-
* Creates all subsystems in order, then executes plugin setup callbacks.
|
|
51
|
-
* Emits runtime:initialized event after successful initialization.
|
|
52
|
-
*
|
|
53
|
-
* @throws Error if initialize is called twice
|
|
54
|
-
* @throws Error if any plugin setup fails
|
|
55
|
-
*
|
|
56
|
-
* Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 3.1, 3.5, 15.1, 15.3, 15.5, 16.1, 16.2, 16.3, 16.4, 16.5, 17.1, 17.2, 17.3
|
|
57
|
-
*/
|
|
58
19
|
initialize(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Shuts down the runtime following the strict shutdown sequence.
|
|
61
|
-
* Emits runtime:shutdown event at start of shutdown.
|
|
62
|
-
* Disposes initialized plugins, shuts down UI provider, clears all registries, and releases resources.
|
|
63
|
-
* Safe to call multiple times (idempotent).
|
|
64
|
-
*
|
|
65
|
-
* Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 9.5, 15.2, 15.4, 15.6, 16.1, 16.2, 16.3, 16.4, 16.5, 17.4, 17.5
|
|
66
|
-
*/
|
|
67
20
|
shutdown(): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Returns the RuntimeContext for this runtime instance.
|
|
70
|
-
*
|
|
71
|
-
* @returns The RuntimeContext
|
|
72
|
-
* @throws Error if runtime is not initialized
|
|
73
|
-
*
|
|
74
|
-
* Requirement: 9.1
|
|
75
|
-
*/
|
|
76
21
|
getContext(): RuntimeContext;
|
|
77
|
-
/**
|
|
78
|
-
* Returns whether the runtime has been initialized.
|
|
79
|
-
*
|
|
80
|
-
* @returns true if runtime is initialized, false otherwise
|
|
81
|
-
*
|
|
82
|
-
* Requirements: 16.1, 16.2, 16.3
|
|
83
|
-
*/
|
|
84
22
|
isInitialized(): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Returns the current lifecycle state of the runtime.
|
|
87
|
-
*
|
|
88
|
-
* @returns The current RuntimeState
|
|
89
|
-
*
|
|
90
|
-
* Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
|
|
91
|
-
*/
|
|
92
23
|
getState(): RuntimeState;
|
|
93
|
-
/**
|
|
94
|
-
* Registers a UI provider with the runtime.
|
|
95
|
-
* Delegates to UIBridge subsystem.
|
|
96
|
-
* Can be called after initialization completes.
|
|
97
|
-
*
|
|
98
|
-
* @param provider - The UI provider implementation
|
|
99
|
-
* @throws Error if provider is invalid or already registered
|
|
100
|
-
*
|
|
101
|
-
* Requirements: 10.3, 10.9
|
|
102
|
-
*/
|
|
103
24
|
setUIProvider(provider: UIProvider): void;
|
|
104
|
-
/**
|
|
105
|
-
* Returns the registered UI provider.
|
|
106
|
-
* Delegates to UIBridge subsystem.
|
|
107
|
-
*
|
|
108
|
-
* @returns The registered UIProvider or null if none registered
|
|
109
|
-
*
|
|
110
|
-
* Requirement: 10.4
|
|
111
|
-
*/
|
|
112
25
|
getUIProvider(): UIProvider | null;
|
|
113
|
-
/**
|
|
114
|
-
* Renders a screen by looking it up in the ScreenRegistry and delegating to UIBridge.
|
|
115
|
-
*
|
|
116
|
-
* @param screenId - The screen identifier to render
|
|
117
|
-
* @returns The result from the UI provider's render method
|
|
118
|
-
* @throws Error if screen is not found
|
|
119
|
-
* @throws Error if no UI provider is registered
|
|
120
|
-
*
|
|
121
|
-
* Requirement: 10.5
|
|
122
|
-
*/
|
|
123
26
|
renderScreen(screenId: string): unknown;
|
|
124
27
|
}
|
|
125
28
|
//# sourceMappingURL=runtime.d.ts.map
|