@antelopejs/interface-core 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -16
- package/dist/index.js +4 -16
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +22 -3
- package/dist/internal.js +26 -11
- package/dist/internal.js.map +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/modules.js +29 -21
- package/dist/modules.js.map +1 -1
- package/dist/proxies.d.ts +12 -1
- package/dist/proxies.js +118 -30
- package/dist/proxies.js.map +1 -1
- package/dist/runtime.js +3 -3
- package/dist/runtime.js.map +1 -1
- package/dist/tests/generation-cleanup.test.d.ts +1 -0
- package/dist/tests/generation-cleanup.test.js +116 -0
- package/dist/tests/generation-cleanup.test.js.map +1 -0
- package/dist/tests/interface-connections.test.d.ts +1 -0
- package/dist/tests/interface-connections.test.js +36 -0
- package/dist/tests/interface-connections.test.js.map +1 -0
- package/dist/tests/provider-context.test.d.ts +1 -0
- package/dist/tests/provider-context.test.js +117 -0
- package/dist/tests/provider-context.test.js.map +1 -0
- package/dist/tests/root-declarations.test.d.ts +1 -0
- package/dist/tests/root-declarations.test.js +94 -0
- package/dist/tests/root-declarations.test.js.map +1 -0
- package/dist/tests/runtime-protocol.test.js +10 -6
- package/dist/tests/runtime-protocol.test.js.map +1 -1
- package/docs/2.proxies.md +18 -1
- package/docs/5.modules.md +22 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import type { Class } from "./decorators";
|
|
3
|
-
import {
|
|
3
|
+
import { type InterfaceConnection } from "./internal";
|
|
4
|
+
import { type AsyncProxy, type EventProxy, type RegisteringProxy } from "./proxies";
|
|
4
5
|
export * from "./errors";
|
|
5
|
-
export {
|
|
6
|
+
export type { InterfaceConnection } from "./internal";
|
|
7
|
+
export { AsyncProxy, EventProxy, GetInterfaceProxyIdentity, GetResponsibleModule, InterfaceFunction, IsInterfaceProxy, RegisteringProxy, RunWithResponsibleModule, } from "./proxies";
|
|
6
8
|
/**
|
|
7
9
|
* Gets metadata for a target object using the specified metadata class.
|
|
8
10
|
*
|
|
@@ -17,16 +19,6 @@ export { AsyncProxy, EventProxy, GetInterfaceProxyIdentity, GetResponsibleModule
|
|
|
17
19
|
export declare function GetMetadata<T extends Record<string, any>, U extends Record<string, any>>(target: U, meta: Class<T, [U]> & {
|
|
18
20
|
key: symbol;
|
|
19
21
|
}, inherit?: boolean): T;
|
|
20
|
-
type Func<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
21
|
-
/**
|
|
22
|
-
* Creates an interface function proxy.
|
|
23
|
-
*
|
|
24
|
-
* Returns a function that routes calls through an AsyncProxy, allowing for module-aware
|
|
25
|
-
* asynchronous function calls that can be implemented by other modules.
|
|
26
|
-
*
|
|
27
|
-
* @returns A function that proxies calls to the implementation when available
|
|
28
|
-
*/
|
|
29
|
-
export declare function InterfaceFunction<T extends Func = Func, R = Awaited<ReturnType<T>>>(identity?: string): (...args: Parameters<T>) => Promise<R>;
|
|
30
22
|
type RID<T> = T extends (id: infer P, ...args: any[]) => void ? P : never;
|
|
31
23
|
type InterfaceImplType<T> = T extends RegisteringProxy<infer P> ? {
|
|
32
24
|
register: P;
|
|
@@ -56,10 +48,6 @@ export declare function ImplementInterface<T extends Record<string, unknown>, T2
|
|
|
56
48
|
declaration: Awaited<T>;
|
|
57
49
|
implementation: T2;
|
|
58
50
|
}>;
|
|
59
|
-
interface InterfaceConnection {
|
|
60
|
-
id?: string;
|
|
61
|
-
path: string;
|
|
62
|
-
}
|
|
63
51
|
/**
|
|
64
52
|
* Gets all instances of a specific interface across the system.
|
|
65
53
|
*
|
|
@@ -79,3 +67,5 @@ export declare function GetInterfaceInstances(interfaceID: string): InterfaceCon
|
|
|
79
67
|
* @returns The interface connection or undefined if not found
|
|
80
68
|
*/
|
|
81
69
|
export declare function GetInterfaceInstance(interfaceID: string, connectionID: string): InterfaceConnection | undefined;
|
|
70
|
+
export * from "./modules";
|
|
71
|
+
export * from "./runtime";
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.RunWithResponsibleModule = exports.RegisteringProxy = exports.IsInterfaceProxy = exports.GetResponsibleModule = exports.GetInterfaceProxyIdentity = exports.EventProxy = exports.AsyncProxy = void 0;
|
|
17
|
+
exports.RunWithResponsibleModule = exports.RegisteringProxy = exports.IsInterfaceProxy = exports.InterfaceFunction = exports.GetResponsibleModule = exports.GetInterfaceProxyIdentity = exports.EventProxy = exports.AsyncProxy = void 0;
|
|
18
18
|
exports.GetMetadata = GetMetadata;
|
|
19
|
-
exports.InterfaceFunction = InterfaceFunction;
|
|
20
19
|
exports.ImplementInterface = ImplementInterface;
|
|
21
20
|
exports.GetInterfaceInstances = GetInterfaceInstances;
|
|
22
21
|
exports.GetInterfaceInstance = GetInterfaceInstance;
|
|
@@ -30,6 +29,7 @@ Object.defineProperty(exports, "AsyncProxy", { enumerable: true, get: function (
|
|
|
30
29
|
Object.defineProperty(exports, "EventProxy", { enumerable: true, get: function () { return proxies_2.EventProxy; } });
|
|
31
30
|
Object.defineProperty(exports, "GetInterfaceProxyIdentity", { enumerable: true, get: function () { return proxies_2.GetInterfaceProxyIdentity; } });
|
|
32
31
|
Object.defineProperty(exports, "GetResponsibleModule", { enumerable: true, get: function () { return proxies_2.GetResponsibleModule; } });
|
|
32
|
+
Object.defineProperty(exports, "InterfaceFunction", { enumerable: true, get: function () { return proxies_2.InterfaceFunction; } });
|
|
33
33
|
Object.defineProperty(exports, "IsInterfaceProxy", { enumerable: true, get: function () { return proxies_2.IsInterfaceProxy; } });
|
|
34
34
|
Object.defineProperty(exports, "RegisteringProxy", { enumerable: true, get: function () { return proxies_2.RegisteringProxy; } });
|
|
35
35
|
Object.defineProperty(exports, "RunWithResponsibleModule", { enumerable: true, get: function () { return proxies_2.RunWithResponsibleModule; } });
|
|
@@ -78,20 +78,6 @@ function GetMetadata(target, meta, inherit = true) {
|
|
|
78
78
|
}
|
|
79
79
|
return data;
|
|
80
80
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates an interface function proxy.
|
|
83
|
-
*
|
|
84
|
-
* Returns a function that routes calls through an AsyncProxy, allowing for module-aware
|
|
85
|
-
* asynchronous function calls that can be implemented by other modules.
|
|
86
|
-
*
|
|
87
|
-
* @returns A function that proxies calls to the implementation when available
|
|
88
|
-
*/
|
|
89
|
-
function InterfaceFunction(identity) {
|
|
90
|
-
const proxy = new proxies_1.AsyncProxy(identity);
|
|
91
|
-
const func = (...args) => proxy.call(...args);
|
|
92
|
-
func.proxy = proxy;
|
|
93
|
-
return func;
|
|
94
|
-
}
|
|
95
81
|
function isObject(value) {
|
|
96
82
|
return typeof value === "object" && value !== null;
|
|
97
83
|
}
|
|
@@ -219,4 +205,6 @@ function GetInterfaceInstance(interfaceID, connectionID) {
|
|
|
219
205
|
const connections = internal_1.internal.interfaceConnections[module];
|
|
220
206
|
return (connections[interfaceID] ?? []).find((connection) => connection.id === connectionID);
|
|
221
207
|
}
|
|
208
|
+
__exportStar(require("./modules"), exports);
|
|
209
|
+
__exportStar(require("./runtime"), exports);
|
|
222
210
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmDA,kCAuBC;AAsLD,gDAmBC;AAUD,sDAMC;AAWD,oDAUC;AAx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ACzB,MAAM,IAAI,GAAG,cAAqC,CAAC;IACnD,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAU,EAAE,CAAC;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,WAAmB;IAEnB,MAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;IACtC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,mBAAQ,CAAC,oBAAoB,CAAC;QAAE,OAAO,EAAE,CAAC;IACrE,OAAO,mBAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,WAAmB,EACnB,YAAoB;IAEpB,MAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;IACtC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,mBAAQ,CAAC,oBAAoB,CAAC;QAAE,OAAO;IAClE,MAAM,WAAW,GAAG,mBAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,YAAY,CAC/C,CAAC;AACJ,CAAC;AAED,4CAA0B;AAC1B,4CAA0B"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
export declare const RUNTIME_PROTOCOL_VERSION =
|
|
2
|
+
export declare const RUNTIME_PROTOCOL_VERSION = 3;
|
|
3
3
|
export declare const RUNTIME_SYMBOL: unique symbol;
|
|
4
|
+
/** Provider connection metadata visible to an interface consumer. */
|
|
4
5
|
export interface InterfaceConnection {
|
|
6
|
+
/** Optional connection alias. */
|
|
5
7
|
id?: string;
|
|
8
|
+
/** Resolved interface package path. */
|
|
6
9
|
path: string;
|
|
10
|
+
/** Module ID of the provider represented by this connection. */
|
|
11
|
+
provider: string;
|
|
12
|
+
/** Whether this provider is selected for unqualified interface calls. */
|
|
13
|
+
selected: boolean;
|
|
7
14
|
}
|
|
15
|
+
/** Module identity and provider routes propagated through asynchronous work. */
|
|
8
16
|
export interface ModuleExecutionContext {
|
|
17
|
+
/** Stable module ID used by existing lifecycle and attribution APIs. */
|
|
9
18
|
module: string;
|
|
19
|
+
/** Unique lifecycle generation ID. Defaults to the module ID when omitted. */
|
|
20
|
+
owner?: string;
|
|
21
|
+
/** Provider ID used when attaching implementations. */
|
|
10
22
|
provider?: string;
|
|
23
|
+
/** Provider selections keyed by stable interface proxy identity. */
|
|
11
24
|
providerRoutes?: Readonly<Record<string, string>>;
|
|
12
25
|
}
|
|
13
26
|
interface ActiveModuleExecutionContext extends ModuleExecutionContext {
|
|
27
|
+
owner: string;
|
|
14
28
|
ownershipToken: symbol;
|
|
15
29
|
}
|
|
16
30
|
export interface ProxyBrand {
|
|
@@ -48,13 +62,15 @@ export interface InterfaceRuntime {
|
|
|
48
62
|
}>>;
|
|
49
63
|
registeringProxies: Set<{
|
|
50
64
|
unregisterModule(module: string): void;
|
|
65
|
+
unregisterOwner(owner: string): void;
|
|
51
66
|
}>;
|
|
52
67
|
knownEvents: Set<{
|
|
53
68
|
unregisterModule(module: string): void;
|
|
69
|
+
unregisterOwner(owner: string): void;
|
|
54
70
|
}>;
|
|
55
71
|
interfaceConnections: Record<string, Record<string, InterfaceConnection[]>>;
|
|
56
72
|
executionContext: AsyncLocalStorage<ActiveModuleExecutionContext>;
|
|
57
|
-
|
|
73
|
+
activeOwnerTokens: Map<string, symbol>;
|
|
58
74
|
proxyStates: Map<string, RuntimeProxyState>;
|
|
59
75
|
nextProxyIdentity: number;
|
|
60
76
|
nextLeaseGeneration: number;
|
|
@@ -72,6 +88,9 @@ export interface InterfaceRuntime {
|
|
|
72
88
|
/** @internal */
|
|
73
89
|
export declare const internal: InterfaceRuntime;
|
|
74
90
|
export declare function runWithModuleContext<T>(context: ModuleExecutionContext, callback: () => T): T;
|
|
91
|
+
export declare function captureModuleContext(): ActiveModuleExecutionContext | undefined;
|
|
92
|
+
export declare function runWithCapturedModuleContext<T>(context: ActiveModuleExecutionContext, callback: () => T): T;
|
|
93
|
+
export declare function peekModuleContext(): ModuleExecutionContext | undefined;
|
|
75
94
|
export declare function getModuleContext(): ModuleExecutionContext | undefined;
|
|
76
|
-
export declare function invalidateModuleContext(
|
|
95
|
+
export declare function invalidateModuleContext(owner: string): void;
|
|
77
96
|
export {};
|
package/dist/internal.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.internal = exports.RUNTIME_SYMBOL = exports.RUNTIME_PROTOCOL_VERSION = void 0;
|
|
4
4
|
exports.runWithModuleContext = runWithModuleContext;
|
|
5
|
+
exports.captureModuleContext = captureModuleContext;
|
|
6
|
+
exports.runWithCapturedModuleContext = runWithCapturedModuleContext;
|
|
7
|
+
exports.peekModuleContext = peekModuleContext;
|
|
5
8
|
exports.getModuleContext = getModuleContext;
|
|
6
9
|
exports.invalidateModuleContext = invalidateModuleContext;
|
|
7
10
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
8
11
|
const errors_1 = require("./errors");
|
|
9
|
-
exports.RUNTIME_PROTOCOL_VERSION =
|
|
12
|
+
exports.RUNTIME_PROTOCOL_VERSION = 3;
|
|
10
13
|
exports.RUNTIME_SYMBOL = Symbol.for("@antelopejs/interface-core/runtime");
|
|
11
14
|
function addToMapSet(map, key, value) {
|
|
12
15
|
const values = map.get(key) ?? new Set();
|
|
@@ -24,7 +27,7 @@ function createRuntime() {
|
|
|
24
27
|
knownEvents: new Set(),
|
|
25
28
|
interfaceConnections: Object.create(null),
|
|
26
29
|
executionContext: new node_async_hooks_1.AsyncLocalStorage(),
|
|
27
|
-
|
|
30
|
+
activeOwnerTokens: new Map(),
|
|
28
31
|
proxyStates: new Map(),
|
|
29
32
|
nextProxyIdentity: 1,
|
|
30
33
|
nextLeaseGeneration: 1,
|
|
@@ -58,17 +61,17 @@ function getRuntime() {
|
|
|
58
61
|
}
|
|
59
62
|
/** @internal */
|
|
60
63
|
exports.internal = getRuntime();
|
|
61
|
-
function
|
|
62
|
-
const activeToken = exports.internal.
|
|
64
|
+
function getOwnerToken(owner) {
|
|
65
|
+
const activeToken = exports.internal.activeOwnerTokens.get(owner);
|
|
63
66
|
if (activeToken) {
|
|
64
67
|
return activeToken;
|
|
65
68
|
}
|
|
66
|
-
const token = Symbol(
|
|
67
|
-
exports.internal.
|
|
69
|
+
const token = Symbol(owner);
|
|
70
|
+
exports.internal.activeOwnerTokens.set(owner, token);
|
|
68
71
|
return token;
|
|
69
72
|
}
|
|
70
73
|
function assertActiveModuleContext(context) {
|
|
71
|
-
if (exports.internal.
|
|
74
|
+
if (exports.internal.activeOwnerTokens.get(context.owner) !== context.ownershipToken) {
|
|
72
75
|
throw new errors_1.ModuleContextInvalidatedError(context.module);
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -80,20 +83,32 @@ function runWithModuleContext(context, callback) {
|
|
|
80
83
|
if (!context.module) {
|
|
81
84
|
throw new Error("Module execution context requires a module ID.");
|
|
82
85
|
}
|
|
86
|
+
const owner = context.owner ?? context.module;
|
|
83
87
|
const activeContext = {
|
|
84
88
|
...context,
|
|
85
|
-
|
|
89
|
+
owner,
|
|
90
|
+
ownershipToken: getOwnerToken(owner),
|
|
86
91
|
};
|
|
87
92
|
return exports.internal.executionContext.run(activeContext, callback);
|
|
88
93
|
}
|
|
89
|
-
function
|
|
94
|
+
function captureModuleContext() {
|
|
90
95
|
const context = exports.internal.executionContext.getStore();
|
|
91
96
|
if (context) {
|
|
92
97
|
assertActiveModuleContext(context);
|
|
93
98
|
}
|
|
94
99
|
return context;
|
|
95
100
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
101
|
+
function runWithCapturedModuleContext(context, callback) {
|
|
102
|
+
assertActiveModuleContext(context);
|
|
103
|
+
return exports.internal.executionContext.run(context, callback);
|
|
104
|
+
}
|
|
105
|
+
function peekModuleContext() {
|
|
106
|
+
return exports.internal.executionContext.getStore();
|
|
107
|
+
}
|
|
108
|
+
function getModuleContext() {
|
|
109
|
+
return captureModuleContext();
|
|
110
|
+
}
|
|
111
|
+
function invalidateModuleContext(owner) {
|
|
112
|
+
exports.internal.activeOwnerTokens.delete(owner);
|
|
98
113
|
}
|
|
99
114
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";;;AA6KA,oDAkBC;AAED,oDAQC;AAED,oEAMC;AAED,8CAEC;AAED,4CAEC;AAED,0DAEC;AA7ND,uDAAqD;AACrD,qCAAyD;AAE5C,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AA4F/E,SAAS,WAAW,CAAI,GAAwB,EAAE,GAAW,EAAE,KAAQ;IACrE,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAK,CAAC;IAC5C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,OAAO,GAAqB;QAChC,QAAQ,EAAE,gCAAwB;QAClC,cAAc,EAAE,EAAE;QAClB,YAAY,EAAE,KAAK;QACnB,UA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AC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED,SAAgB,oBAAoB;IAGlC,MAAM,OAAO,GAAG,gBAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,4BAA4B,CAC1C,OAAqC,EACrC,QAAiB;IAEjB,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,gBAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,gBAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC;AAED,SAAgB,uBAAuB,CAAC,KAAa;IACnD,gBAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/modules.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventProxy } from ".";
|
|
2
1
|
import { type ModuleExecutionContext } from "./internal";
|
|
2
|
+
import { EventProxy } from "./proxies";
|
|
3
3
|
/** Runs work with module ownership and an optional provider route across awaits. */
|
|
4
4
|
export declare function RunWithModuleContext<T>(context: ModuleExecutionContext, callback: () => T): T;
|
|
5
5
|
/** Returns the active module execution context, if one exists. */
|
package/dist/modules.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ReloadModule = exports.DestroyModule = exports.StopModule = exports.StartModule = exports.LoadModule = exports.GetModuleInfo = exports.ListModules = exports.Events = void 0;
|
|
4
4
|
exports.RunWithModuleContext = RunWithModuleContext;
|
|
5
5
|
exports.GetModuleContext = GetModuleContext;
|
|
6
|
-
const _1 = require(".");
|
|
7
6
|
const internal_1 = require("./internal");
|
|
7
|
+
const proxies_1 = require("./proxies");
|
|
8
8
|
/** Runs work with module ownership and an optional provider route across awaits. */
|
|
9
9
|
function RunWithModuleContext(context, callback) {
|
|
10
10
|
return (0, internal_1.runWithModuleContext)(context, callback);
|
|
@@ -29,7 +29,7 @@ var Events;
|
|
|
29
29
|
*
|
|
30
30
|
* @param module Module ID
|
|
31
31
|
*/
|
|
32
|
-
Events.ModuleConstructed = new
|
|
32
|
+
Events.ModuleConstructed = new proxies_1.EventProxy("modules.ModuleConstructed");
|
|
33
33
|
/**
|
|
34
34
|
* Event triggers when a module is started.
|
|
35
35
|
*
|
|
@@ -38,7 +38,7 @@ var Events;
|
|
|
38
38
|
*
|
|
39
39
|
* @param module Module ID
|
|
40
40
|
*/
|
|
41
|
-
Events.ModuleStarted = new
|
|
41
|
+
Events.ModuleStarted = new proxies_1.EventProxy("modules.ModuleStarted");
|
|
42
42
|
/**
|
|
43
43
|
* Event triggers when a module is stopped.
|
|
44
44
|
*
|
|
@@ -47,7 +47,7 @@ var Events;
|
|
|
47
47
|
*
|
|
48
48
|
* @param module Module ID
|
|
49
49
|
*/
|
|
50
|
-
Events.ModuleStopped = new
|
|
50
|
+
Events.ModuleStopped = new proxies_1.EventProxy("modules.ModuleStopped");
|
|
51
51
|
/**
|
|
52
52
|
* Event triggers when a module is destroyed.
|
|
53
53
|
*
|
|
@@ -56,7 +56,7 @@ var Events;
|
|
|
56
56
|
*
|
|
57
57
|
* @param module Module ID
|
|
58
58
|
*/
|
|
59
|
-
Events.ModuleDestroyed = new
|
|
59
|
+
Events.ModuleDestroyed = new proxies_1.EventProxy("modules.ModuleDestroyed");
|
|
60
60
|
})(Events || (exports.Events = Events = {}));
|
|
61
61
|
function runCleanup(cleanup, module, operation) {
|
|
62
62
|
try {
|
|
@@ -71,19 +71,27 @@ function runCleanup(cleanup, module, operation) {
|
|
|
71
71
|
internal_1.internal.runtimeErrorReporter?.(error, { operation, module });
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
function getDestroyedOwner(module) {
|
|
75
|
+
const context = (0, internal_1.peekModuleContext)();
|
|
76
|
+
if (context?.module !== module) {
|
|
77
|
+
return module;
|
|
78
|
+
}
|
|
79
|
+
return context.owner ?? module;
|
|
80
|
+
}
|
|
74
81
|
Events.ModuleDestroyed.register((module) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
const owner = getDestroyedOwner(module);
|
|
83
|
+
(0, internal_1.invalidateModuleContext)(owner);
|
|
84
|
+
for (const cleanup of internal_1.internal.knownAsync.get(owner) ?? []) {
|
|
85
|
+
runCleanup(cleanup, owner, "detach-async-provider");
|
|
78
86
|
}
|
|
79
|
-
internal_1.internal.knownAsync.delete(
|
|
80
|
-
for (const cleanup of internal_1.internal.knownRegisters.get(
|
|
81
|
-
runCleanup(cleanup,
|
|
87
|
+
internal_1.internal.knownAsync.delete(owner);
|
|
88
|
+
for (const cleanup of internal_1.internal.knownRegisters.get(owner) ?? []) {
|
|
89
|
+
runCleanup(cleanup, owner, "detach-registering-provider");
|
|
82
90
|
}
|
|
83
|
-
internal_1.internal.knownRegisters.delete(
|
|
91
|
+
internal_1.internal.knownRegisters.delete(owner);
|
|
84
92
|
for (const proxy of internal_1.internal.registeringProxies) {
|
|
85
93
|
try {
|
|
86
|
-
proxy.
|
|
94
|
+
proxy.unregisterOwner(owner);
|
|
87
95
|
}
|
|
88
96
|
catch (error) {
|
|
89
97
|
internal_1.internal.runtimeErrorReporter?.(error, {
|
|
@@ -94,7 +102,7 @@ Events.ModuleDestroyed.register((module) => {
|
|
|
94
102
|
}
|
|
95
103
|
for (const proxy of internal_1.internal.knownEvents) {
|
|
96
104
|
try {
|
|
97
|
-
proxy.
|
|
105
|
+
proxy.unregisterOwner(owner);
|
|
98
106
|
}
|
|
99
107
|
catch (error) {
|
|
100
108
|
internal_1.internal.runtimeErrorReporter?.(error, {
|
|
@@ -112,7 +120,7 @@ Events.ModuleDestroyed.register((module) => {
|
|
|
112
120
|
*
|
|
113
121
|
* @returns Array of module IDs
|
|
114
122
|
*/
|
|
115
|
-
exports.ListModules = (0,
|
|
123
|
+
exports.ListModules = (0, proxies_1.InterfaceFunction)("modules.ListModules");
|
|
116
124
|
/**
|
|
117
125
|
* Retrieve the configuration and status information of a loaded module.
|
|
118
126
|
*
|
|
@@ -122,7 +130,7 @@ exports.ListModules = (0, _1.InterfaceFunction)("modules.ListModules");
|
|
|
122
130
|
* @param module The module ID to get information for
|
|
123
131
|
* @returns Complete module information object
|
|
124
132
|
*/
|
|
125
|
-
exports.GetModuleInfo = (0,
|
|
133
|
+
exports.GetModuleInfo = (0, proxies_1.InterfaceFunction)("modules.GetModuleInfo");
|
|
126
134
|
/**
|
|
127
135
|
* Load a new module with the given ID and configuration.
|
|
128
136
|
*
|
|
@@ -133,7 +141,7 @@ exports.GetModuleInfo = (0, _1.InterfaceFunction)("modules.GetModuleInfo");
|
|
|
133
141
|
* @param configuration Module configuration including source information
|
|
134
142
|
* @param autostart Whether to automatically start the module after loading (default: false)
|
|
135
143
|
*/
|
|
136
|
-
exports.LoadModule = (0,
|
|
144
|
+
exports.LoadModule = (0, proxies_1.InterfaceFunction)("modules.LoadModule");
|
|
137
145
|
/**
|
|
138
146
|
* Start a loaded but inactive module.
|
|
139
147
|
*
|
|
@@ -143,7 +151,7 @@ exports.LoadModule = (0, _1.InterfaceFunction)("modules.LoadModule");
|
|
|
143
151
|
* @param module The module ID to start
|
|
144
152
|
* @throws Error if the module is not loaded or cannot be started
|
|
145
153
|
*/
|
|
146
|
-
exports.StartModule = (0,
|
|
154
|
+
exports.StartModule = (0, proxies_1.InterfaceFunction)("modules.StartModule");
|
|
147
155
|
/**
|
|
148
156
|
* Stop an active module.
|
|
149
157
|
*
|
|
@@ -153,7 +161,7 @@ exports.StartModule = (0, _1.InterfaceFunction)("modules.StartModule");
|
|
|
153
161
|
* @param module The module ID to stop
|
|
154
162
|
* @throws Error if the module is not loaded or cannot be stopped
|
|
155
163
|
*/
|
|
156
|
-
exports.StopModule = (0,
|
|
164
|
+
exports.StopModule = (0, proxies_1.InterfaceFunction)("modules.StopModule");
|
|
157
165
|
/**
|
|
158
166
|
* Destroy a stopped module.
|
|
159
167
|
*
|
|
@@ -163,7 +171,7 @@ exports.StopModule = (0, _1.InterfaceFunction)("modules.StopModule");
|
|
|
163
171
|
* @param module The module ID to destroy
|
|
164
172
|
* @throws Error if the module is active or not loaded
|
|
165
173
|
*/
|
|
166
|
-
exports.DestroyModule = (0,
|
|
174
|
+
exports.DestroyModule = (0, proxies_1.InterfaceFunction)("modules.DestroyModule");
|
|
167
175
|
/**
|
|
168
176
|
* Unload a module and retrigger its source mechanism.
|
|
169
177
|
*
|
|
@@ -174,5 +182,5 @@ exports.DestroyModule = (0, _1.InterfaceFunction)("modules.DestroyModule");
|
|
|
174
182
|
* @param module The module ID to reload
|
|
175
183
|
* @throws Error if the module cannot be reloaded
|
|
176
184
|
*/
|
|
177
|
-
exports.ReloadModule = (0,
|
|
185
|
+
exports.ReloadModule = (0, proxies_1.InterfaceFunction)("modules.ReloadModule");
|
|
178
186
|
//# sourceMappingURL=modules.js.map
|
package/dist/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":";;;AAYA,oDAKC;AAGD,4CAEC;AAtBD,yCAQoB;AACpB,uCAA0D;AAE1D,oFAAoF;AACpF,SAAgB,oBAAoB,CAClC,OAA+B,EAC/B,QAAiB;IAEjB,OAAO,IAAA,+BAAoB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,kEAAkE;AAClE,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,2BAAgB,GAAE,CAAC;A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A,2BAAiB,EAC5C,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,UAAU,GACrB,IAAA,2BAAiB,EAMf,oBAAoB,CAAC,CAAC;AAE1B;;;;;;;;GAQG;AACU,QAAA,WAAW,GAAG,IAAA,2BAAiB,EAC1C,qBAAqB,CACtB,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,UAAU,GACrB,IAAA,2BAAiB,EAA2B,oBAAoB,CAAC,CAAC;AAEpE;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,IAAA,2BAAiB,EAC5C,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,IAAA,2BAAiB,EAC3C,sBAAsB,CACvB,CAAC"}
|
package/dist/proxies.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare class AsyncProxy<T extends Func = Func, R = Awaited<ReturnType<T>
|
|
|
32
32
|
private invoke;
|
|
33
33
|
private replayQueue;
|
|
34
34
|
}
|
|
35
|
+
/** Creates an interface function backed by an asynchronous proxy. */
|
|
36
|
+
export declare function InterfaceFunction<T extends Func = Func, R = Awaited<ReturnType<T>>>(identity?: string): (...args: Parameters<T>) => Promise<R>;
|
|
35
37
|
/** Proxy for provider-aware register and unregister handlers. */
|
|
36
38
|
export declare class RegisteringProxy<T extends RegisterFunction = RegisterFunction> {
|
|
37
39
|
readonly [PROXY_BRAND]: ProxyBrand;
|
|
@@ -51,7 +53,14 @@ export declare class RegisteringProxy<T extends RegisterFunction = RegisterFunct
|
|
|
51
53
|
unregister(id: RID<T>): void;
|
|
52
54
|
/** Unregisters every entry owned by a destroyed module. */
|
|
53
55
|
unregisterModule(module: string): void;
|
|
54
|
-
|
|
56
|
+
/** Unregisters every entry owned by a destroyed module generation. */
|
|
57
|
+
unregisterOwner(owner: string): void;
|
|
58
|
+
private unregisterMatching;
|
|
59
|
+
private attachRegister;
|
|
60
|
+
private attachUnregister;
|
|
61
|
+
private trackAttachment;
|
|
62
|
+
private createLease;
|
|
63
|
+
private createAttachment;
|
|
55
64
|
private replayRegistrations;
|
|
56
65
|
}
|
|
57
66
|
type EventFunction = (...args: any[]) => void;
|
|
@@ -68,6 +77,8 @@ export declare class EventProxy<T extends EventFunction = EventFunction> {
|
|
|
68
77
|
unregister(fn: T): void;
|
|
69
78
|
/** Unregisters handlers owned by a destroyed module. */
|
|
70
79
|
unregisterModule(module: string): void;
|
|
80
|
+
/** Unregisters handlers owned by a destroyed module generation. */
|
|
81
|
+
unregisterOwner(owner: string): void;
|
|
71
82
|
}
|
|
72
83
|
/** Gets the responsible module from explicit async context or the call stack. */
|
|
73
84
|
export declare function GetResponsibleModule(startFrame?: number): string | undefined;
|