@antelopejs/interface-core 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/caller-binding.d.ts +11 -0
- package/dist/caller-binding.js +97 -0
- package/dist/caller-binding.js.map +1 -0
- package/dist/config.d.ts +27 -1
- package/dist/config.js.map +1 -1
- package/dist/internal.d.ts +8 -10
- package/dist/internal.js +1 -2
- package/dist/internal.js.map +1 -1
- package/dist/modules.d.ts +47 -0
- package/dist/modules.js +44 -3
- package/dist/modules.js.map +1 -1
- package/dist/proxies.d.ts +17 -16
- package/dist/proxies.js +86 -169
- package/dist/proxies.js.map +1 -1
- package/dist/tests/caller-context.test.js +139 -0
- package/dist/tests/caller-context.test.js.map +1 -0
- package/dist/tests/generation-cleanup.test.js +0 -2
- package/dist/tests/generation-cleanup.test.js.map +1 -1
- package/dist/tests/provider-context.test.js +0 -8
- package/dist/tests/provider-context.test.js.map +1 -1
- package/dist/tests/release-owner.test.d.ts +1 -0
- package/dist/tests/release-owner.test.js +34 -0
- package/dist/tests/release-owner.test.js.map +1 -0
- package/dist/tests/responsible-module.test.js +2 -2
- package/dist/tests/responsible-module.test.js.map +1 -1
- package/dist/tests/runtime-protocol.test.js +8 -11
- package/dist/tests/runtime-protocol.test.js.map +1 -1
- package/dist/tests/single-provider.test.d.ts +1 -0
- package/dist/tests/single-provider.test.js +55 -0
- package/dist/tests/single-provider.test.js.map +1 -0
- package/docs/2.proxies.md +18 -5
- package/docs/5.modules.md +32 -3
- package/docs/7.configuration.md +12 -7
- package/package.json +2 -2
- package/dist/tests/provider-routing.test.js +0 -78
- package/dist/tests/provider-routing.test.js.map +0 -1
- /package/dist/tests/{provider-routing.test.d.ts → caller-context.test.d.ts} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binds the functions a caller hands to an interface proxy to the caller's
|
|
3
|
+
* module context, so they run as the caller's work whoever invokes them.
|
|
4
|
+
*
|
|
5
|
+
* Functions, and functions held in plain objects and arrays, are bound; plain
|
|
6
|
+
* data, class instances and proxies cross unchanged. A value is bound once per
|
|
7
|
+
* context, and a value that is already bound keeps its original context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function bindCallerArguments<T extends unknown[]>(args: T): T;
|
|
10
|
+
/** Binds a single caller function to the caller's module context. */
|
|
11
|
+
export declare function bindCallerFunction<T extends (...args: any[]) => unknown>(callback: T): T;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bindCallerArguments = bindCallerArguments;
|
|
4
|
+
exports.bindCallerFunction = bindCallerFunction;
|
|
5
|
+
const node_util_1 = require("node:util");
|
|
6
|
+
const internal_1 = require("./internal");
|
|
7
|
+
const bindingsBySource = new WeakMap();
|
|
8
|
+
const boundValues = new WeakSet();
|
|
9
|
+
function hasPlainPrototype(value) {
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const prototype = Object.getPrototypeOf(value);
|
|
14
|
+
return prototype === Object.prototype || prototype === null;
|
|
15
|
+
}
|
|
16
|
+
function isBindableContainer(value) {
|
|
17
|
+
return (typeof value === "object" &&
|
|
18
|
+
value !== null &&
|
|
19
|
+
!node_util_1.types.isProxy(value) &&
|
|
20
|
+
hasPlainPrototype(value));
|
|
21
|
+
}
|
|
22
|
+
function holdsFunction(value, visited) {
|
|
23
|
+
if (typeof value === "function") {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (!isBindableContainer(value) || visited.has(value)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
visited.add(value);
|
|
30
|
+
return Object.values(value).some((member) => holdsFunction(member, visited));
|
|
31
|
+
}
|
|
32
|
+
function needsBinding(value) {
|
|
33
|
+
if (typeof value === "function") {
|
|
34
|
+
return !boundValues.has(value);
|
|
35
|
+
}
|
|
36
|
+
return (isBindableContainer(value) &&
|
|
37
|
+
!boundValues.has(value) &&
|
|
38
|
+
holdsFunction(value, new Set()));
|
|
39
|
+
}
|
|
40
|
+
function createFunctionBinding(target, context) {
|
|
41
|
+
return new Proxy(target, {
|
|
42
|
+
apply: (callable, thisArg, argumentsList) => (0, internal_1.runWithCapturedModuleContext)(context, () => callable.apply(thisArg, argumentsList)),
|
|
43
|
+
construct: (callable, argumentsList, newTarget) => (0, internal_1.runWithCapturedModuleContext)(context, () => Reflect.construct(callable, argumentsList, newTarget)),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function createContainerBinding(target, context) {
|
|
47
|
+
return new Proxy(target, {
|
|
48
|
+
get: (container, property) => {
|
|
49
|
+
const member = container[property];
|
|
50
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(container, property);
|
|
51
|
+
const isFixed = descriptor !== undefined &&
|
|
52
|
+
!descriptor.configurable &&
|
|
53
|
+
"value" in descriptor &&
|
|
54
|
+
!descriptor.writable;
|
|
55
|
+
return isFixed ? member : bindValue(member, context);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function bindValue(value, context) {
|
|
60
|
+
if (!needsBinding(value)) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
const cached = bindingsBySource.get(value)?.get(context);
|
|
64
|
+
if (cached) {
|
|
65
|
+
return cached;
|
|
66
|
+
}
|
|
67
|
+
const bound = typeof value === "function"
|
|
68
|
+
? createFunctionBinding(value, context)
|
|
69
|
+
: createContainerBinding(value, context);
|
|
70
|
+
const contexts = bindingsBySource.get(value) ??
|
|
71
|
+
new WeakMap();
|
|
72
|
+
contexts.set(context, bound);
|
|
73
|
+
bindingsBySource.set(value, contexts);
|
|
74
|
+
boundValues.add(bound);
|
|
75
|
+
return bound;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Binds the functions a caller hands to an interface proxy to the caller's
|
|
79
|
+
* module context, so they run as the caller's work whoever invokes them.
|
|
80
|
+
*
|
|
81
|
+
* Functions, and functions held in plain objects and arrays, are bound; plain
|
|
82
|
+
* data, class instances and proxies cross unchanged. A value is bound once per
|
|
83
|
+
* context, and a value that is already bound keeps its original context.
|
|
84
|
+
*/
|
|
85
|
+
function bindCallerArguments(args) {
|
|
86
|
+
const context = (0, internal_1.captureModuleContext)();
|
|
87
|
+
if (!context) {
|
|
88
|
+
return args;
|
|
89
|
+
}
|
|
90
|
+
return args.map((argument) => bindValue(argument, context));
|
|
91
|
+
}
|
|
92
|
+
/** Binds a single caller function to the caller's module context. */
|
|
93
|
+
function bindCallerFunction(callback) {
|
|
94
|
+
const context = (0, internal_1.captureModuleContext)();
|
|
95
|
+
return context ? bindValue(callback, context) : callback;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=caller-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caller-binding.js","sourceRoot":"","sources":["../src/caller-binding.ts"],"names":[],"mappings":";;AAqHA,kDAMC;AAGD,gDAKC;AAnID,yCAA+C;AAE/C,yCAAgF;AAOhF,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAGjC,CAAC;AACJ,MAAM,WAAW,GAAG,IAAI,OAAO,EAAiB,CAAC;AAEjD,SAAS,iBAAiB,CAAC,KAA2B;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,iBAAS,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,iBAAiB,CAAC,KAA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,KAAK,CAAC,CAAC;IAC7B,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAsB,IAAO;IAC9D,MAAM,OAAO,GAAG,IAAA,+BAAoB,GAAE,CAAC;IACvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAM,CAAC;AACnE,CAAC;AAED,qEAAqE;AACrE,SAAgB,kBAAkB,CAChC,QAAW;IAEX,MAAM,OAAO,GAAG,IAAA,+BAAoB,GAAE,CAAC;IACvC,OAAO,OAAO,CAAC,CAAC,CAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -73,9 +73,16 @@ export interface AntelopeConfig {
|
|
|
73
73
|
environments?: Record<string, Partial<AntelopeConfig>>;
|
|
74
74
|
test?: AntelopeTestConfig;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Binds an interface a module uses, directly or through the interfaces it uses,
|
|
78
|
+
* to one provider module. The first entry for an interface pins it; further
|
|
79
|
+
* entries are connections reached by `id`. An entry for a standalone interface
|
|
80
|
+
* may omit `source`: it then declares a connection to the self-hosted interface,
|
|
81
|
+
* built on that connection's other bindings.
|
|
82
|
+
*/
|
|
76
83
|
export interface ImportOverride {
|
|
77
84
|
interface: string;
|
|
78
|
-
source
|
|
85
|
+
source?: string;
|
|
79
86
|
id?: string;
|
|
80
87
|
}
|
|
81
88
|
export interface AntelopeModuleConfig {
|
|
@@ -84,6 +91,25 @@ export interface AntelopeModuleConfig {
|
|
|
84
91
|
config?: unknown;
|
|
85
92
|
importOverrides?: ImportOverride[] | Record<string, string>;
|
|
86
93
|
disabledExports?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Priority of this module as the default provider of the interfaces it
|
|
96
|
+
* implements, keyed by interface name. The provider with the highest priority
|
|
97
|
+
* is chosen where nothing pins the interface; unlisted interfaces have
|
|
98
|
+
* priority 0.
|
|
99
|
+
*/
|
|
100
|
+
exportPriority?: Record<string, number>;
|
|
101
|
+
/**
|
|
102
|
+
* Keeps the module declared, with its configuration, without loading it.
|
|
103
|
+
* A disabled module is left out of the project as if it were not listed.
|
|
104
|
+
*/
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Lets the project start without this module. An optional module is
|
|
108
|
+
* loaded once the others have started; when it fails to download,
|
|
109
|
+
* construct or start, the failure is logged and the project runs on
|
|
110
|
+
* without it.
|
|
111
|
+
*/
|
|
112
|
+
optional?: boolean;
|
|
87
113
|
}
|
|
88
114
|
export interface AntelopeLogging {
|
|
89
115
|
enabled?: boolean;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;AAmKtB,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAkB;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
export declare const RUNTIME_PROTOCOL_VERSION =
|
|
2
|
+
export declare const RUNTIME_PROTOCOL_VERSION = 4;
|
|
3
3
|
export declare const RUNTIME_SYMBOL: unique symbol;
|
|
4
4
|
/** Provider connection metadata visible to an interface consumer. */
|
|
5
5
|
export interface InterfaceConnection {
|
|
6
6
|
/** Optional connection alias. */
|
|
7
7
|
id?: string;
|
|
8
|
-
/**
|
|
8
|
+
/** Path to `require()` for the interface instance this connection is bound to. */
|
|
9
9
|
path: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Module ID of the provider represented by this connection; absent for a
|
|
12
|
+
* connection to a self-hosted interface.
|
|
13
|
+
*/
|
|
14
|
+
provider?: string;
|
|
15
|
+
/** Whether this connection is the one a plain import of the interface reaches. */
|
|
13
16
|
selected: boolean;
|
|
14
17
|
}
|
|
15
18
|
/** Module identity and provider routes propagated through asynchronous work. */
|
|
@@ -32,10 +35,6 @@ export interface ProxyBrand {
|
|
|
32
35
|
kind: "async" | "registering" | "event";
|
|
33
36
|
identity: string;
|
|
34
37
|
}
|
|
35
|
-
export interface RuntimeProxyState {
|
|
36
|
-
kind: ProxyBrand["kind"];
|
|
37
|
-
value: unknown;
|
|
38
|
-
}
|
|
39
38
|
export interface RuntimeCleanup {
|
|
40
39
|
cleanup(): void;
|
|
41
40
|
unregisterModule?(module: string): void;
|
|
@@ -71,7 +70,6 @@ export interface InterfaceRuntime {
|
|
|
71
70
|
interfaceConnections: Record<string, Record<string, InterfaceConnection[]>>;
|
|
72
71
|
executionContext: AsyncLocalStorage<ActiveModuleExecutionContext>;
|
|
73
72
|
activeOwnerTokens: Map<string, symbol>;
|
|
74
|
-
proxyStates: Map<string, RuntimeProxyState>;
|
|
75
73
|
nextProxyIdentity: number;
|
|
76
74
|
nextLeaseGeneration: number;
|
|
77
75
|
maxPendingOperations: number;
|
package/dist/internal.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.getModuleContext = getModuleContext;
|
|
|
9
9
|
exports.invalidateModuleContext = invalidateModuleContext;
|
|
10
10
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
11
11
|
const errors_1 = require("./errors");
|
|
12
|
-
exports.RUNTIME_PROTOCOL_VERSION =
|
|
12
|
+
exports.RUNTIME_PROTOCOL_VERSION = 4;
|
|
13
13
|
exports.RUNTIME_SYMBOL = Symbol.for("@antelopejs/interface-core/runtime");
|
|
14
14
|
function addToMapSet(map, key, value) {
|
|
15
15
|
const values = map.get(key) ?? new Set();
|
|
@@ -28,7 +28,6 @@ function createRuntime() {
|
|
|
28
28
|
interfaceConnections: Object.create(null),
|
|
29
29
|
executionContext: new node_async_hooks_1.AsyncLocalStorage(),
|
|
30
30
|
activeOwnerTokens: new Map(),
|
|
31
|
-
proxyStates: new Map(),
|
|
32
31
|
nextProxyIdentity: 1,
|
|
33
32
|
nextLeaseGeneration: 1,
|
|
34
33
|
maxPendingOperations: 1_000,
|
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":";;;AA0KA,oDAkBC;AAED,oDAQC;AAED,oEAMC;AAED,8CAEC;AAED,4CAEC;AAED,0DAEC;AA1ND,uDAAqD;AAErD,qCAAyD;AAE5C,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAyF/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,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;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,3 +1,4 @@
|
|
|
1
|
+
import type { AntelopeModuleConfig } from "./config";
|
|
1
2
|
import { EventProxy } from "./proxies";
|
|
2
3
|
import { type ModuleExecutionContext } from "./internal";
|
|
3
4
|
/** Runs work with module ownership and an optional provider route across awaits. */
|
|
@@ -49,6 +50,13 @@ export declare namespace Events {
|
|
|
49
50
|
*/
|
|
50
51
|
const ModuleDestroyed: EventProxy<(module: string) => void>;
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Releases everything an owner that is not a module generation attached or
|
|
55
|
+
* registered, and invalidates its context, as a module's destruction does.
|
|
56
|
+
*
|
|
57
|
+
* @internal Used by the core to retire an interface instance's own owner.
|
|
58
|
+
*/
|
|
59
|
+
export declare function ReleaseOwner(owner: string): void;
|
|
52
60
|
/**
|
|
53
61
|
* Configuration for defining a module to be loaded into the system.
|
|
54
62
|
*
|
|
@@ -169,3 +177,42 @@ export declare const DestroyModule: (module: string) => Promise<void>;
|
|
|
169
177
|
* @throws Error if the module cannot be reloaded
|
|
170
178
|
*/
|
|
171
179
|
export declare const ReloadModule: (module: string) => Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* A module as the project's configuration file declares it, under its key in
|
|
182
|
+
* `modules`, with the shorthand forms expanded.
|
|
183
|
+
*/
|
|
184
|
+
export type ModuleDeclaration = Pick<AntelopeModuleConfig, "source" | "config" | "disabled" | "optional">;
|
|
185
|
+
/**
|
|
186
|
+
* The fields of a module's declaration to write. A field left out keeps what
|
|
187
|
+
* the file already holds.
|
|
188
|
+
*/
|
|
189
|
+
export type ModuleDeclarationChanges = Partial<ModuleDeclaration>;
|
|
190
|
+
/**
|
|
191
|
+
* List the modules the project's configuration file declares, by key,
|
|
192
|
+
* disabled ones included.
|
|
193
|
+
*
|
|
194
|
+
* @returns The declarations of the top-level `modules` of the file
|
|
195
|
+
*/
|
|
196
|
+
export declare const ListModuleDeclarations: () => Promise<Record<string, ModuleDeclaration>>;
|
|
197
|
+
/**
|
|
198
|
+
* Write a module's declaration into the project's configuration file.
|
|
199
|
+
*
|
|
200
|
+
* Only the given fields of the module's entry are rewritten, and the entry is
|
|
201
|
+
* added when the file has none: every other line of the file, comments and
|
|
202
|
+
* expressions included, stays as it was. The running project is not
|
|
203
|
+
* restarted for this write; the caller loads, stops or reloads the module
|
|
204
|
+
* itself.
|
|
205
|
+
*
|
|
206
|
+
* @param module The module's key in `modules`
|
|
207
|
+
* @param changes The fields to write
|
|
208
|
+
* @throws Error if the file has no `modules` object it can edit, such as a
|
|
209
|
+
* configuration built by a function
|
|
210
|
+
*/
|
|
211
|
+
export declare const SaveModuleDeclaration: (module: string, changes: Partial<ModuleDeclaration>) => Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Remove a module's entry from the project's configuration file, leaving the
|
|
214
|
+
* rest of the file as it was and the running project unrestarted.
|
|
215
|
+
*
|
|
216
|
+
* @param module The module's key in `modules`
|
|
217
|
+
*/
|
|
218
|
+
export declare const RemoveModuleDeclaration: (module: string) => Promise<void>;
|
package/dist/modules.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReloadModule = exports.DestroyModule = exports.StopModule = exports.StartModule = exports.LoadModule = exports.GetModuleInfo = exports.ListModules = exports.Events = void 0;
|
|
3
|
+
exports.RemoveModuleDeclaration = exports.SaveModuleDeclaration = exports.ListModuleDeclarations = 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
|
+
exports.ReleaseOwner = ReleaseOwner;
|
|
6
7
|
const proxies_1 = require("./proxies");
|
|
7
8
|
const internal_1 = require("./internal");
|
|
8
9
|
/** Runs work with module ownership and an optional provider route across awaits. */
|
|
@@ -121,8 +122,7 @@ function releaseOwnerRegistrations(module, owner) {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
-
const owner = getDestroyedOwner(module);
|
|
125
|
+
function releaseOwner(module, owner) {
|
|
126
126
|
try {
|
|
127
127
|
releaseOwnerRegistrations(module, owner);
|
|
128
128
|
}
|
|
@@ -130,7 +130,19 @@ Events.ModuleDestroyed.register((module) => {
|
|
|
130
130
|
// Only now: nothing else may claim to act for this generation.
|
|
131
131
|
(0, internal_1.invalidateModuleContext)(owner);
|
|
132
132
|
}
|
|
133
|
+
}
|
|
134
|
+
Events.ModuleDestroyed.register((module) => {
|
|
135
|
+
releaseOwner(module, getDestroyedOwner(module));
|
|
133
136
|
});
|
|
137
|
+
/**
|
|
138
|
+
* Releases everything an owner that is not a module generation attached or
|
|
139
|
+
* registered, and invalidates its context, as a module's destruction does.
|
|
140
|
+
*
|
|
141
|
+
* @internal Used by the core to retire an interface instance's own owner.
|
|
142
|
+
*/
|
|
143
|
+
function ReleaseOwner(owner) {
|
|
144
|
+
releaseOwner(owner, owner);
|
|
145
|
+
}
|
|
134
146
|
/**
|
|
135
147
|
* List all loaded modules.
|
|
136
148
|
*
|
|
@@ -202,4 +214,33 @@ exports.DestroyModule = (0, proxies_1.InterfaceFunction)("modules.DestroyModule"
|
|
|
202
214
|
* @throws Error if the module cannot be reloaded
|
|
203
215
|
*/
|
|
204
216
|
exports.ReloadModule = (0, proxies_1.InterfaceFunction)("modules.ReloadModule");
|
|
217
|
+
/**
|
|
218
|
+
* List the modules the project's configuration file declares, by key,
|
|
219
|
+
* disabled ones included.
|
|
220
|
+
*
|
|
221
|
+
* @returns The declarations of the top-level `modules` of the file
|
|
222
|
+
*/
|
|
223
|
+
exports.ListModuleDeclarations = (0, proxies_1.InterfaceFunction)("modules.ListModuleDeclarations");
|
|
224
|
+
/**
|
|
225
|
+
* Write a module's declaration into the project's configuration file.
|
|
226
|
+
*
|
|
227
|
+
* Only the given fields of the module's entry are rewritten, and the entry is
|
|
228
|
+
* added when the file has none: every other line of the file, comments and
|
|
229
|
+
* expressions included, stays as it was. The running project is not
|
|
230
|
+
* restarted for this write; the caller loads, stops or reloads the module
|
|
231
|
+
* itself.
|
|
232
|
+
*
|
|
233
|
+
* @param module The module's key in `modules`
|
|
234
|
+
* @param changes The fields to write
|
|
235
|
+
* @throws Error if the file has no `modules` object it can edit, such as a
|
|
236
|
+
* configuration built by a function
|
|
237
|
+
*/
|
|
238
|
+
exports.SaveModuleDeclaration = (0, proxies_1.InterfaceFunction)("modules.SaveModuleDeclaration");
|
|
239
|
+
/**
|
|
240
|
+
* Remove a module's entry from the project's configuration file, leaving the
|
|
241
|
+
* rest of the file as it was and the running project unrestarted.
|
|
242
|
+
*
|
|
243
|
+
* @param module The module's key in `modules`
|
|
244
|
+
*/
|
|
245
|
+
exports.RemoveModuleDeclaration = (0, proxies_1.InterfaceFunction)("modules.RemoveModuleDeclaration");
|
|
205
246
|
//# 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":";;;AAaA,oDAKC;AAGD,4CAEC;AAiJD,oCAEC;AAzKD,uCAA0D;AAC1D,yCAQoB;AAEpB,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;AAC5B,CAAC;AAID;;;;;GAKG;AACH,IAAiB,MAAM,CAgDtB;AAhDD,WAAiB,MAAM;IACrB;;;;;;;OAOG;IACU,wBAAiB,GAAG,IAAI,oBAAU,CAC7C,2BAA2B,CAC5B,CAAC;IAEF;;;;;;;OAOG;IACU,oBAAa,GAAG,IAAI,oBAAU,CACzC,uBAAuB,CACxB,CAAC;IAEF;;;;;;;OAOG;IACU,oBAAa,GAAG,IAAI,oBAAU,CACzC,uBAAuB,CACxB,CAAC;IAEF;;;;;;;OAOG;IACU,sBAAe,GAAG,IAAI,oBAAU,CAC3C,yBAAyB,CAC1B,CAAC;AACJ,CAAC,EAhDgB,MAAM,sBAAN,MAAM,QAgDtB;AAED,SAAS,UAAU,CACjB,OAA4C,EAC5C,MAAc,EACd,SAAiB;IAEjB,IAAI,CAAC;QACH,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,EAAE,CAAC;QAC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,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;AAiBF;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,IAAA,2BAAiB,EAErD,gCAAgC,CAAC,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACU,QAAA,qBAAqB,GAAG,IAAA,2BAAiB,EAEpD,+BAA+B,CAAC,CAAC;AAEnC;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,IAAA,2BAAiB,EAEtD,iCAAiC,CAAC,CAAC"}
|
package/dist/proxies.d.ts
CHANGED
|
@@ -5,51 +5,53 @@ type RID<T> = T extends (id: infer P, ...args: any[]) => void ? P : never;
|
|
|
5
5
|
type RArgs<T> = T extends (id: any, ...args: infer P) => void ? P : never;
|
|
6
6
|
type ProxyKind = ProxyBrand["kind"];
|
|
7
7
|
declare const PROXY_BRAND: unique symbol;
|
|
8
|
+
/** The handle of one provider attachment, used to detach exactly that attachment. */
|
|
8
9
|
export interface AttachmentLease {
|
|
9
10
|
generation: number;
|
|
10
11
|
owner: string;
|
|
11
|
-
provider: string;
|
|
12
12
|
}
|
|
13
13
|
/** Returns whether a value implements this runtime's stable proxy protocol. */
|
|
14
14
|
export declare function IsInterfaceProxy(value: unknown, kind?: ProxyKind): boolean;
|
|
15
|
-
/** Returns the
|
|
15
|
+
/** Returns the identity a proxy was declared with, for diagnostics. */
|
|
16
16
|
export declare function GetInterfaceProxyIdentity(value: unknown): string | undefined;
|
|
17
17
|
/** @internal */
|
|
18
18
|
export declare function InvalidateResponsibleModule(module: string): void;
|
|
19
19
|
/** Runs work with explicit module ownership across asynchronous boundaries. */
|
|
20
20
|
export declare function RunWithResponsibleModule<T>(module: string, callback: () => T): T;
|
|
21
|
-
/** Proxy for an asynchronous interface function. */
|
|
21
|
+
/** Proxy for an asynchronous interface function, served by a single provider. */
|
|
22
22
|
export declare class AsyncProxy<T extends Func = Func, R = Awaited<ReturnType<T>>> {
|
|
23
23
|
readonly [PROXY_BRAND]: ProxyBrand;
|
|
24
|
-
private
|
|
24
|
+
private attachment?;
|
|
25
|
+
private queue;
|
|
25
26
|
constructor(identity?: string);
|
|
26
|
-
/** Attaches
|
|
27
|
+
/** Attaches the provider callback, replacing any previous one, and replays queued calls. */
|
|
27
28
|
onCall(callback: T, manualDetach?: boolean): AttachmentLease;
|
|
28
|
-
/** Detaches
|
|
29
|
+
/** Detaches the leased attachment, or the current one when called without a lease. */
|
|
29
30
|
detach(lease?: AttachmentLease): void;
|
|
30
|
-
/** Calls the provider
|
|
31
|
+
/** Calls the provider, or queues the call until a provider attaches. */
|
|
31
32
|
call(...args: Parameters<T>): Promise<R>;
|
|
32
33
|
private invoke;
|
|
33
34
|
private replayQueue;
|
|
34
35
|
}
|
|
35
36
|
/** Creates an interface function backed by an asynchronous proxy. */
|
|
36
37
|
export declare function InterfaceFunction<T extends Func = Func, R = Awaited<ReturnType<T>>>(identity?: string): (...args: Parameters<T>) => Promise<R>;
|
|
37
|
-
/** Proxy for
|
|
38
|
+
/** Proxy for register and unregister handlers, served by a single provider. */
|
|
38
39
|
export declare class RegisteringProxy<T extends RegisterFunction = RegisterFunction> {
|
|
39
40
|
readonly [PROXY_BRAND]: ProxyBrand;
|
|
40
|
-
private
|
|
41
|
+
private handlers;
|
|
42
|
+
private readonly registered;
|
|
41
43
|
constructor(identity?: string);
|
|
42
44
|
/** Attaches a register callback. */
|
|
43
45
|
onRegister(callback: T, manualDetach?: boolean): AttachmentLease;
|
|
44
|
-
/** Attaches an unregister callback
|
|
46
|
+
/** Attaches an unregister callback, sharing the register callback's owner when it is the caller's. */
|
|
45
47
|
onUnregister(callback: (id: RID<T>) => void): AttachmentLease;
|
|
46
48
|
/** Atomically attaches both registration handlers. */
|
|
47
49
|
onHandlers(register: T, unregister: (id: RID<T>) => void, manualDetach?: boolean): AttachmentLease;
|
|
48
|
-
/** Detaches
|
|
50
|
+
/** Detaches the leased handlers, or both handlers when called without a lease. */
|
|
49
51
|
detach(lease?: AttachmentLease): void;
|
|
50
|
-
/** Registers an entry with the
|
|
52
|
+
/** Registers an entry with the provider and keeps it for replay on (re)attach. */
|
|
51
53
|
register(id: RID<T>, ...args: RArgs<T>): void;
|
|
52
|
-
/** Unregisters an entry from the provider
|
|
54
|
+
/** Unregisters an entry from the provider. */
|
|
53
55
|
unregister(id: RID<T>): void;
|
|
54
56
|
/** Unregisters every entry owned by a destroyed module. */
|
|
55
57
|
unregisterModule(module: string): void;
|
|
@@ -59,15 +61,14 @@ export declare class RegisteringProxy<T extends RegisterFunction = RegisterFunct
|
|
|
59
61
|
private attachRegister;
|
|
60
62
|
private attachUnregister;
|
|
61
63
|
private trackAttachment;
|
|
62
|
-
private createLease;
|
|
63
64
|
private createAttachment;
|
|
64
65
|
private replayRegistrations;
|
|
65
66
|
}
|
|
66
67
|
type EventFunction = (...args: any[]) => void;
|
|
67
|
-
/** Module-aware event handler collection. */
|
|
68
|
+
/** Module-aware event handler collection; each handler runs in its registrant's context. */
|
|
68
69
|
export declare class EventProxy<T extends EventFunction = EventFunction> {
|
|
69
70
|
readonly [PROXY_BRAND]: ProxyBrand;
|
|
70
|
-
private
|
|
71
|
+
private registered;
|
|
71
72
|
constructor(identity?: string);
|
|
72
73
|
/** Emits to every handler, reporting failures without aborting later handlers. */
|
|
73
74
|
emit(...args: Parameters<T>): void;
|