@antelopejs/interface-core 0.0.8 → 0.0.10
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/errors.d.ts +20 -0
- package/dist/errors.js +33 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +92 -25
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +68 -12
- package/dist/internal.js +93 -21
- package/dist/internal.js.map +1 -1
- package/dist/modules.d.ts +6 -0
- package/dist/modules.js +58 -25
- package/dist/modules.js.map +1 -1
- package/dist/proxies.d.ts +58 -119
- package/dist/proxies.js +298 -184
- package/dist/proxies.js.map +1 -1
- package/dist/runtime.js +2 -2
- package/dist/runtime.js.map +1 -1
- package/dist/tests/implement-interface-validation.test.d.ts +1 -0
- package/dist/tests/implement-interface-validation.test.js +45 -0
- package/dist/tests/implement-interface-validation.test.js.map +1 -0
- package/dist/tests/module-ownership-context.test.d.ts +1 -0
- package/dist/tests/module-ownership-context.test.js +215 -0
- package/dist/tests/module-ownership-context.test.js.map +1 -0
- package/dist/tests/provider-routing.test.d.ts +1 -0
- package/dist/tests/provider-routing.test.js +78 -0
- package/dist/tests/provider-routing.test.js.map +1 -0
- package/dist/tests/queue-and-cleanup.test.d.ts +1 -0
- package/dist/tests/queue-and-cleanup.test.js +73 -0
- package/dist/tests/queue-and-cleanup.test.js.map +1 -0
- package/dist/tests/registering-proxy-replay.test.js +9 -0
- package/dist/tests/registering-proxy-replay.test.js.map +1 -1
- package/dist/tests/runtime-protocol.test.d.ts +1 -0
- package/dist/tests/runtime-protocol.test.js +45 -0
- package/dist/tests/runtime-protocol.test.js.map +1 -0
- package/dist/tests/runtime.test.js +18 -2
- package/dist/tests/runtime.test.js.map +1 -1
- package/docs/2.proxies.md +18 -1
- package/package.json +1 -1
package/dist/proxies.js
CHANGED
|
@@ -1,228 +1,346 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventProxy = exports.RegisteringProxy = exports.AsyncProxy = void 0;
|
|
4
|
+
exports.IsInterfaceProxy = IsInterfaceProxy;
|
|
5
|
+
exports.GetInterfaceProxyIdentity = GetInterfaceProxyIdentity;
|
|
6
|
+
exports.InvalidateResponsibleModule = InvalidateResponsibleModule;
|
|
7
|
+
exports.RunWithResponsibleModule = RunWithResponsibleModule;
|
|
4
8
|
exports.GetResponsibleModule = GetResponsibleModule;
|
|
5
9
|
const errors_1 = require("./errors");
|
|
6
10
|
const internal_1 = require("./internal");
|
|
7
11
|
const responsible_module_1 = require("./responsible-module");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const PROXY_BRAND = Symbol.for("@antelopejs/interface-core/proxy");
|
|
13
|
+
const DEFAULT_PROVIDER = "@antelopejs/interface-core/default-provider";
|
|
14
|
+
function createIdentity(kind, identity) {
|
|
15
|
+
if (identity) {
|
|
16
|
+
return `${kind}:${identity}`;
|
|
17
|
+
}
|
|
18
|
+
const nextIdentity = internal_1.internal.nextProxyIdentity++;
|
|
19
|
+
return `${kind}:anonymous:${nextIdentity}`;
|
|
20
|
+
}
|
|
21
|
+
function getProxyState(brand, create) {
|
|
22
|
+
const existing = internal_1.internal.proxyStates.get(brand.identity);
|
|
23
|
+
if (existing && existing.kind !== brand.kind) {
|
|
24
|
+
throw new Error(`Proxy identity ${brand.identity} has conflicting kinds.`);
|
|
25
|
+
}
|
|
26
|
+
if (existing) {
|
|
27
|
+
return existing.value;
|
|
28
|
+
}
|
|
29
|
+
const value = create();
|
|
30
|
+
internal_1.internal.proxyStates.set(brand.identity, { kind: brand.kind, value });
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function createBrand(kind, identity) {
|
|
34
|
+
return Object.freeze({
|
|
35
|
+
protocol: internal_1.RUNTIME_PROTOCOL_VERSION,
|
|
36
|
+
kind,
|
|
37
|
+
identity: createIdentity(kind, identity),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function readBrand(value) {
|
|
41
|
+
if ((typeof value !== "object" && typeof value !== "function") || !value) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const brand = value[PROXY_BRAND];
|
|
45
|
+
if (!brand || brand.protocol !== internal_1.RUNTIME_PROTOCOL_VERSION) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
return brand;
|
|
49
|
+
}
|
|
50
|
+
/** Returns whether a value implements this runtime's stable proxy protocol. */
|
|
51
|
+
function IsInterfaceProxy(value, kind) {
|
|
52
|
+
const brand = readBrand(value);
|
|
53
|
+
return Boolean(brand && (!kind || brand.kind === kind));
|
|
54
|
+
}
|
|
55
|
+
/** Returns the stable identity used to bind a proxy to a provider route. */
|
|
56
|
+
function GetInterfaceProxyIdentity(value) {
|
|
57
|
+
return readBrand(value)?.identity;
|
|
58
|
+
}
|
|
59
|
+
function getAttachmentRoute(manualDetach) {
|
|
60
|
+
const context = (0, internal_1.getModuleContext)();
|
|
61
|
+
const responsible = manualDetach || context?.module ? undefined : GetResponsibleModule();
|
|
62
|
+
const owner = context?.module ?? responsible ?? DEFAULT_PROVIDER;
|
|
63
|
+
return { owner, provider: context?.provider ?? owner };
|
|
64
|
+
}
|
|
65
|
+
function getRequestedProvider(proxyIdentity) {
|
|
66
|
+
const context = (0, internal_1.getModuleContext)();
|
|
67
|
+
return context?.providerRoutes?.[proxyIdentity] ?? context?.provider;
|
|
68
|
+
}
|
|
69
|
+
function selectProvider(callbacks, proxyIdentity, requested) {
|
|
70
|
+
if (requested) {
|
|
71
|
+
const callback = callbacks.get(requested);
|
|
72
|
+
if (!callback && callbacks.size > 0) {
|
|
73
|
+
throw new errors_1.MissingProviderError(`Interface proxy ${proxyIdentity} has no provider for route ${requested}.`);
|
|
74
|
+
}
|
|
75
|
+
return callback;
|
|
76
|
+
}
|
|
77
|
+
if (callbacks.size <= 1) {
|
|
78
|
+
return callbacks.values().next().value;
|
|
79
|
+
}
|
|
80
|
+
throw new errors_1.AmbiguousProviderError(proxyIdentity, [...callbacks.keys()]);
|
|
81
|
+
}
|
|
82
|
+
function reportRuntimeError(error, operation, proxyIdentity, module, registrationId) {
|
|
83
|
+
internal_1.internal.runtimeErrorReporter?.(error, {
|
|
84
|
+
operation,
|
|
85
|
+
module,
|
|
86
|
+
proxyIdentity,
|
|
87
|
+
registrationId,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
function InvalidateResponsibleModule(module) {
|
|
92
|
+
(0, internal_1.invalidateModuleContext)(module);
|
|
93
|
+
}
|
|
94
|
+
/** Runs work with explicit module ownership across asynchronous boundaries. */
|
|
95
|
+
function RunWithResponsibleModule(module, callback) {
|
|
96
|
+
return (0, internal_1.runWithModuleContext)({ module }, callback);
|
|
97
|
+
}
|
|
98
|
+
/** Proxy for an asynchronous interface function. */
|
|
14
99
|
class AsyncProxy {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
100
|
+
[PROXY_BRAND];
|
|
101
|
+
state;
|
|
102
|
+
constructor(identity) {
|
|
103
|
+
this[PROXY_BRAND] = createBrand("async", identity);
|
|
104
|
+
this.state = getProxyState(this[PROXY_BRAND], () => ({
|
|
105
|
+
callbacks: new Map(),
|
|
106
|
+
queue: [],
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
/** Attaches a provider callback and replays compatible queued calls. */
|
|
26
110
|
onCall(callback, manualDetach) {
|
|
27
|
-
|
|
111
|
+
const route = getAttachmentRoute(manualDetach);
|
|
112
|
+
const lease = { ...route, generation: internal_1.internal.nextLeaseGeneration++ };
|
|
113
|
+
this.state.callbacks.set(route.provider, { callback, ...lease });
|
|
28
114
|
if (!manualDetach) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
internal_1.internal.addAsyncProxy(caller, this);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (this.queue.length > 0) {
|
|
35
|
-
this.queue.forEach(({ args, resolve, reject }) => {
|
|
36
|
-
try {
|
|
37
|
-
resolve(callback(...args));
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
reject(err);
|
|
41
|
-
}
|
|
115
|
+
internal_1.internal.addAsyncProxy(route.owner, {
|
|
116
|
+
cleanup: () => this.detach(lease),
|
|
42
117
|
});
|
|
43
|
-
this.queue.splice(0, this.queue.length);
|
|
44
118
|
}
|
|
119
|
+
this.replayQueue(route.provider, callback);
|
|
120
|
+
return lease;
|
|
45
121
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
122
|
+
/** Detaches one leased provider, or every provider when called without a lease. */
|
|
123
|
+
detach(lease) {
|
|
124
|
+
if (!lease) {
|
|
125
|
+
this.state.callbacks.clear();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const current = this.state.callbacks.get(lease.provider);
|
|
129
|
+
if (current?.generation === lease.generation &&
|
|
130
|
+
current.owner === lease.owner) {
|
|
131
|
+
this.state.callbacks.delete(lease.provider);
|
|
132
|
+
}
|
|
51
133
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Call the function attached to this proxy.
|
|
54
|
-
*
|
|
55
|
-
* If a callback has not been attached yet, the call is queued up for later.
|
|
56
|
-
*/
|
|
134
|
+
/** Calls the provider selected by the current module execution context. */
|
|
57
135
|
call(...args) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
136
|
+
let requested;
|
|
137
|
+
let attachment;
|
|
138
|
+
try {
|
|
139
|
+
requested = getRequestedProvider(this[PROXY_BRAND].identity);
|
|
140
|
+
attachment = selectProvider(this.state.callbacks, this[PROXY_BRAND].identity, requested);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return Promise.reject(error);
|
|
144
|
+
}
|
|
145
|
+
if (attachment) {
|
|
146
|
+
return this.invoke(attachment.callback, args);
|
|
65
147
|
}
|
|
66
148
|
if (internal_1.internal.testStubMode) {
|
|
67
149
|
return Promise.reject(new errors_1.MissingProviderError());
|
|
68
150
|
}
|
|
69
|
-
|
|
151
|
+
if (this.state.queue.length >= internal_1.internal.maxPendingOperations) {
|
|
152
|
+
return Promise.reject(new errors_1.ProviderQueueFullError(this[PROXY_BRAND].identity, internal_1.internal.maxPendingOperations));
|
|
153
|
+
}
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
this.state.queue.push({ args, provider: requested, resolve, reject });
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
invoke(callback, args) {
|
|
159
|
+
try {
|
|
160
|
+
return Promise.resolve(callback(...args));
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
return Promise.reject(error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
replayQueue(provider, callback) {
|
|
167
|
+
const remaining = [];
|
|
168
|
+
for (const pending of this.state.queue) {
|
|
169
|
+
if (pending.provider && pending.provider !== provider) {
|
|
170
|
+
remaining.push(pending);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
this.invoke(callback, pending.args).then(pending.resolve, pending.reject);
|
|
174
|
+
}
|
|
175
|
+
this.state.queue = remaining;
|
|
70
176
|
}
|
|
71
177
|
}
|
|
72
178
|
exports.AsyncProxy = AsyncProxy;
|
|
73
|
-
/**
|
|
74
|
-
* Proxy for a pair of register/unregister functions.
|
|
75
|
-
*
|
|
76
|
-
* Manages registration of handlers and ensures proper cleanup when modules are unloaded.
|
|
77
|
-
* This allows for module-aware event registration with automatic cleanup.
|
|
78
|
-
*/
|
|
179
|
+
/** Proxy for provider-aware register and unregister handlers. */
|
|
79
180
|
class RegisteringProxy {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
181
|
+
[PROXY_BRAND];
|
|
182
|
+
state;
|
|
183
|
+
constructor(identity) {
|
|
184
|
+
this[PROXY_BRAND] = createBrand("registering", identity);
|
|
185
|
+
this.state = getProxyState(this[PROXY_BRAND], () => ({
|
|
186
|
+
callbacks: new Map(),
|
|
187
|
+
registered: new Map(),
|
|
188
|
+
}));
|
|
189
|
+
internal_1.internal.registeringProxies.add(this);
|
|
190
|
+
}
|
|
191
|
+
/** Attaches a register callback. */
|
|
91
192
|
onRegister(callback, manualDetach) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (caller) {
|
|
96
|
-
internal_1.internal.addRegisteringProxy(caller, this);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
for (const [id, { args }] of this.registered) {
|
|
100
|
-
try {
|
|
101
|
-
callback(id, ...args);
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
// Best-effort replay: one throwing consumer must not strand the others.
|
|
105
|
-
if (internal_1.internal.replayErrorReporter) {
|
|
106
|
-
internal_1.internal.replayErrorReporter(id, err);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
193
|
+
const route = getAttachmentRoute(manualDetach);
|
|
194
|
+
const current = this.state.callbacks.get(route.provider);
|
|
195
|
+
return this.attachHandlers(callback, current?.unregister, manualDetach, true, route);
|
|
110
196
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Attaches an unregister callback to the proxy
|
|
113
|
-
*
|
|
114
|
-
* Detached at the same time as the register callback.
|
|
115
|
-
*
|
|
116
|
-
* @param callback Function to attach as the unregister callback
|
|
117
|
-
*/
|
|
197
|
+
/** Attaches an unregister callback to the current provider route. */
|
|
118
198
|
onUnregister(callback) {
|
|
119
|
-
|
|
199
|
+
const context = (0, internal_1.getModuleContext)();
|
|
200
|
+
const requested = context?.provider ?? context?.module;
|
|
201
|
+
const current = selectProvider(this.state.callbacks, this[PROXY_BRAND].identity, requested);
|
|
202
|
+
const route = current
|
|
203
|
+
? { owner: current.owner, provider: current.provider }
|
|
204
|
+
: getAttachmentRoute();
|
|
205
|
+
return this.attachHandlers(current?.register, callback, current?.manualDetach, false, route);
|
|
206
|
+
}
|
|
207
|
+
/** Atomically attaches both registration handlers. */
|
|
208
|
+
onHandlers(register, unregister, manualDetach) {
|
|
209
|
+
return this.attachHandlers(register, unregister, manualDetach);
|
|
120
210
|
}
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
211
|
+
/** Detaches one leased provider, or every provider when called without a lease. */
|
|
212
|
+
detach(lease) {
|
|
213
|
+
if (!lease) {
|
|
214
|
+
this.state.callbacks.clear();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const current = this.state.callbacks.get(lease.provider);
|
|
218
|
+
if (current?.generation === lease.generation &&
|
|
219
|
+
current.owner === lease.owner) {
|
|
220
|
+
this.state.callbacks.delete(lease.provider);
|
|
221
|
+
}
|
|
127
222
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Call the register callback attached to this proxy.
|
|
130
|
-
*
|
|
131
|
-
* If a callback has not been attached yet, the call is queued up for later.
|
|
132
|
-
*
|
|
133
|
-
* @param id Unique identifier used to unregister
|
|
134
|
-
* @param args Extra arguments
|
|
135
|
-
*/
|
|
223
|
+
/** Registers an entry with the selected provider or queues it for bootstrap. */
|
|
136
224
|
register(id, ...args) {
|
|
137
|
-
|
|
225
|
+
const requested = getRequestedProvider(this[PROXY_BRAND].identity);
|
|
226
|
+
const callback = selectProvider(this.state.callbacks, this[PROXY_BRAND].identity, requested);
|
|
227
|
+
if (!callback && internal_1.internal.testStubMode) {
|
|
138
228
|
throw new errors_1.MissingProviderError();
|
|
139
229
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.
|
|
230
|
+
if (!callback &&
|
|
231
|
+
!this.state.registered.has(id) &&
|
|
232
|
+
this.state.registered.size >= internal_1.internal.maxPendingOperations) {
|
|
233
|
+
throw new errors_1.ProviderQueueFullError(this[PROXY_BRAND].identity, internal_1.internal.maxPendingOperations);
|
|
144
234
|
}
|
|
235
|
+
this.state.registered.set(id, {
|
|
236
|
+
module: GetResponsibleModule(),
|
|
237
|
+
provider: requested ?? callback?.provider,
|
|
238
|
+
args,
|
|
239
|
+
});
|
|
240
|
+
callback?.register?.(id, ...args);
|
|
145
241
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Call the unregister callback attached to this proxy.
|
|
148
|
-
*
|
|
149
|
-
* @param id Unique identifier to unregister
|
|
150
|
-
*/
|
|
242
|
+
/** Unregisters an entry from the provider that accepted it. */
|
|
151
243
|
unregister(id) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
244
|
+
const entry = this.state.registered.get(id);
|
|
245
|
+
if (!entry) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const callback = selectProvider(this.state.callbacks, this[PROXY_BRAND].identity, entry.provider);
|
|
249
|
+
try {
|
|
250
|
+
callback?.unregister?.(id);
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
this.state.registered.delete(id);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** Unregisters every entry owned by a destroyed module. */
|
|
257
|
+
unregisterModule(module) {
|
|
258
|
+
for (const [id, entry] of this.state.registered) {
|
|
259
|
+
if (entry.module !== module) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
this.unregister(id);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
reportRuntimeError(error, "unregister", this[PROXY_BRAND].identity, module, id);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
this.state.registered.delete(id);
|
|
155
270
|
}
|
|
156
|
-
this.registered.delete(id);
|
|
157
271
|
}
|
|
158
272
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
273
|
+
attachHandlers(register, unregister, manualDetach, shouldReplay = true, attachmentRoute) {
|
|
274
|
+
const route = attachmentRoute ?? getAttachmentRoute(manualDetach);
|
|
275
|
+
const lease = { ...route, generation: internal_1.internal.nextLeaseGeneration++ };
|
|
276
|
+
this.state.callbacks.set(route.provider, {
|
|
277
|
+
register,
|
|
278
|
+
unregister,
|
|
279
|
+
manualDetach: Boolean(manualDetach),
|
|
280
|
+
...lease,
|
|
281
|
+
});
|
|
282
|
+
if (!manualDetach) {
|
|
283
|
+
internal_1.internal.addRegisteringProxy(route.owner, {
|
|
284
|
+
cleanup: () => this.detach(lease),
|
|
285
|
+
unregisterModule: (module) => this.unregisterModule(module),
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (register && shouldReplay) {
|
|
289
|
+
this.replayRegistrations(route.provider, register);
|
|
290
|
+
}
|
|
291
|
+
return lease;
|
|
292
|
+
}
|
|
293
|
+
replayRegistrations(provider, callback) {
|
|
294
|
+
for (const [id, entry] of this.state.registered) {
|
|
295
|
+
if (entry.provider && entry.provider !== provider) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
try {
|
|
299
|
+
callback(id, ...entry.args);
|
|
300
|
+
entry.provider = provider;
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
internal_1.internal.replayErrorReporter?.(id, error);
|
|
304
|
+
reportRuntimeError(error, "register-replay", this[PROXY_BRAND].identity, entry.module, id);
|
|
172
305
|
}
|
|
173
306
|
}
|
|
174
307
|
}
|
|
175
308
|
}
|
|
176
309
|
exports.RegisteringProxy = RegisteringProxy;
|
|
177
|
-
/**
|
|
178
|
-
* Event handler list that automatically removes handlers from unloaded modules.
|
|
179
|
-
*
|
|
180
|
-
* Provides a module-aware event system that cleans up event handlers when modules are unloaded,
|
|
181
|
-
* preventing memory leaks and ensuring proper modularity.
|
|
182
|
-
*/
|
|
310
|
+
/** Module-aware event handler collection. */
|
|
183
311
|
class EventProxy {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
312
|
+
[PROXY_BRAND];
|
|
313
|
+
state;
|
|
314
|
+
constructor(identity) {
|
|
315
|
+
this[PROXY_BRAND] = createBrand("event", identity);
|
|
316
|
+
this.state = getProxyState(this[PROXY_BRAND], () => ({ registered: [] }));
|
|
317
|
+
internal_1.internal.knownEvents.add(this);
|
|
187
318
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Call all the event handlers with the specified arguments.
|
|
190
|
-
*
|
|
191
|
-
* @param args Arguments
|
|
192
|
-
*/
|
|
319
|
+
/** Emits to every handler, reporting failures without aborting later handlers. */
|
|
193
320
|
emit(...args) {
|
|
194
|
-
for (const { func } of this.registered) {
|
|
195
|
-
|
|
321
|
+
for (const { func, module } of this.state.registered) {
|
|
322
|
+
try {
|
|
323
|
+
func(...args);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
reportRuntimeError(error, "event-emit", this[PROXY_BRAND].identity, module);
|
|
327
|
+
}
|
|
196
328
|
}
|
|
197
329
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Register a new handler for this event.
|
|
200
|
-
*
|
|
201
|
-
* @param func Handler
|
|
202
|
-
*/
|
|
330
|
+
/** Registers a handler once. */
|
|
203
331
|
register(func) {
|
|
204
|
-
if (this.registered.some((existing) => existing.func === func)) {
|
|
332
|
+
if (this.state.registered.some((existing) => existing.func === func)) {
|
|
205
333
|
return;
|
|
206
334
|
}
|
|
207
|
-
|
|
208
|
-
this.registered.push({ module, func });
|
|
335
|
+
this.state.registered.push({ module: GetResponsibleModule(), func });
|
|
209
336
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Unregister a handler on this event.
|
|
212
|
-
*
|
|
213
|
-
* @param fn The handler that was passed to {@link register}
|
|
214
|
-
*/
|
|
337
|
+
/** Unregisters a handler. */
|
|
215
338
|
unregister(fn) {
|
|
216
|
-
this.registered = this.registered.filter(({ func }) => func !== fn);
|
|
339
|
+
this.state.registered = this.state.registered.filter(({ func }) => func !== fn);
|
|
217
340
|
}
|
|
218
|
-
/**
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
*
|
|
222
|
-
* @param mod Module ID
|
|
223
|
-
*/
|
|
224
|
-
unregisterModule(mod) {
|
|
225
|
-
this.registered = this.registered.filter(({ module }) => module !== mod);
|
|
341
|
+
/** Unregisters handlers owned by a destroyed module. */
|
|
342
|
+
unregisterModule(module) {
|
|
343
|
+
this.state.registered = this.state.registered.filter((entry) => entry.module !== module);
|
|
226
344
|
}
|
|
227
345
|
}
|
|
228
346
|
exports.EventProxy = EventProxy;
|
|
@@ -231,23 +349,19 @@ function captureCallStack(startFrame = 0) {
|
|
|
231
349
|
const oldLimit = Error.stackTraceLimit;
|
|
232
350
|
Error.stackTraceLimit = Infinity;
|
|
233
351
|
Error.prepareStackTrace = (_, trace) => trace;
|
|
234
|
-
const
|
|
235
|
-
Error.captureStackTrace(
|
|
236
|
-
const trace =
|
|
352
|
+
const error = {};
|
|
353
|
+
Error.captureStackTrace(error, GetResponsibleModule);
|
|
354
|
+
const trace = error.stack;
|
|
237
355
|
Error.prepareStackTrace = oldHandler;
|
|
238
356
|
Error.stackTraceLimit = oldLimit;
|
|
239
357
|
return trace.slice(startFrame);
|
|
240
358
|
}
|
|
241
|
-
/**
|
|
242
|
-
* Gets the responsible module for the current execution context.
|
|
243
|
-
*
|
|
244
|
-
* Determines which module is responsible for the current code execution by analyzing the call stack.
|
|
245
|
-
* This is used for automatic proxy detachment and event handler cleanup.
|
|
246
|
-
*
|
|
247
|
-
* @param startFrame The starting frame in the stack trace to analyze
|
|
248
|
-
* @returns The module ID or undefined if no module is found
|
|
249
|
-
*/
|
|
359
|
+
/** Gets the responsible module from explicit async context or the call stack. */
|
|
250
360
|
function GetResponsibleModule(startFrame = 0) {
|
|
361
|
+
const contextModule = (0, internal_1.getModuleContext)()?.module;
|
|
362
|
+
if (contextModule) {
|
|
363
|
+
return contextModule;
|
|
364
|
+
}
|
|
251
365
|
const trace = captureCallStack(startFrame);
|
|
252
366
|
const responsible = (0, responsible_module_1.findResponsibleFile)(trace);
|
|
253
367
|
if (responsible.module) {
|
package/dist/proxies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../src/proxies.ts"],"names":[],"mappings":";;;AAwRA,oDAQC;AAhSD,qCAAgD;AAChD,yCAAsC;AACtC,6DAA2D;AAI3D;;;;;GAKG;AACH,MAAa,UAAU;IACb,QAAQ,CAAK;IACb,KAAK,GAIR,EAAE,CAAC;IAER;;;;;;;;OAQG;IACI,MAAM,CAAC,QAAW,EAAE,YAAsB;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;YACtC,IAAI,MAAM,EAAE,CAAC;gBACX,mBAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC/C,IAAI,CAAC;oBACH,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBAC7B,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC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C;IACxC,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAqC,CAAC;IAC1D,KAAK,CAAC,iBAAiB,GAAG,UAAU,CAAC;IACrC,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;IACjC,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAED,iFAAiF;AACjF,SAAgB,oBAAoB,CAAC,UAAU,GAAG,CAAC;IACjD,MAAM,aAAa,GAAG,IAAA,2BAAgB,GAAE,EAAE,MAAM,CAAC;IACjD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAA,wCAAmB,EAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;IACD,mBAAQ,CAAC,oBAAoB,EAAE,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,WAAW,CAAC,aAAa,CAAC;AACnC,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.DEV_REGISTRY_PATH = ".antelope/dev.json";
|
|
|
11
11
|
*
|
|
12
12
|
* @returns Runtime information including dev mode, project path and environment
|
|
13
13
|
*/
|
|
14
|
-
exports.GetRuntimeInfo = (0, _1.InterfaceFunction)();
|
|
14
|
+
exports.GetRuntimeInfo = (0, _1.InterfaceFunction)("runtime.GetRuntimeInfo");
|
|
15
15
|
/**
|
|
16
16
|
* Register a development server and the endpoints it is listening on.
|
|
17
17
|
*
|
|
@@ -22,5 +22,5 @@ exports.GetRuntimeInfo = (0, _1.InterfaceFunction)();
|
|
|
22
22
|
* @param name Unique name of the server (e.g. 'api')
|
|
23
23
|
* @param endpoints Endpoints the server is listening on
|
|
24
24
|
*/
|
|
25
|
-
exports.RegisterDevServer = (0, _1.InterfaceFunction)();
|
|
25
|
+
exports.RegisterDevServer = (0, _1.InterfaceFunction)("runtime.RegisterDevServer");
|
|
26
26
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;AAAA,wBAAsC;AA4EtC;;GAEG;AACU,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;;GAIG;AACU,QAAA,cAAc,GAAG,IAAA,oBAAiB,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;AAAA,wBAAsC;AA4EtC;;GAEG;AACU,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;;GAIG;AACU,QAAA,cAAc,GAAG,IAAA,oBAAiB,EAC7C,wBAAwB,CACzB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,IAAA,oBAAiB,EAEhD,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_vm_1 = require("node:vm");
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const internal_1 = require("../internal");
|
|
7
|
+
describe("ImplementInterface validation", () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
internal_1.internal.testStubMode = false;
|
|
10
|
+
});
|
|
11
|
+
it("validates every handler before attaching any of them", async () => {
|
|
12
|
+
const first = new __1.AsyncProxy("test.atomic.first");
|
|
13
|
+
const second = new __1.AsyncProxy("test.atomic.second");
|
|
14
|
+
(0, chai_1.expect)(() => (0, __1.ImplementInterface)({ first, second }, {
|
|
15
|
+
first: () => "attached",
|
|
16
|
+
})).to.throw("implementation.second");
|
|
17
|
+
internal_1.internal.testStubMode = true;
|
|
18
|
+
const error = await first.call().then(() => undefined, (reason) => reason);
|
|
19
|
+
(0, chai_1.expect)(error).to.be.instanceOf(Error);
|
|
20
|
+
});
|
|
21
|
+
it("rejects malformed registering handlers atomically", () => {
|
|
22
|
+
const proxy = new __1.RegisteringProxy("test.malformed-registering");
|
|
23
|
+
(0, chai_1.expect)(() => (0, __1.ImplementInterface)({ proxy }, {
|
|
24
|
+
proxy: { register: () => undefined },
|
|
25
|
+
})).to.throw("implementation.proxy.unregister");
|
|
26
|
+
});
|
|
27
|
+
it("rejects cycles in declarations and implementations", () => {
|
|
28
|
+
const declaration = {};
|
|
29
|
+
declaration.self = declaration;
|
|
30
|
+
(0, chai_1.expect)(() => (0, __1.ImplementInterface)(declaration, {})).to.throw("declaration contains a cycle");
|
|
31
|
+
const implementation = {};
|
|
32
|
+
implementation.self = implementation;
|
|
33
|
+
(0, chai_1.expect)(() => (0, __1.ImplementInterface)({}, implementation)).to.throw("implementation contains a cycle");
|
|
34
|
+
});
|
|
35
|
+
it("awaits thenables and promises created in another realm", async () => {
|
|
36
|
+
const proxy = new __1.AsyncProxy("test.cross-realm-promise");
|
|
37
|
+
const declaration = (0, node_vm_1.runInNewContext)("Promise.resolve(value)", {
|
|
38
|
+
value: { proxy },
|
|
39
|
+
});
|
|
40
|
+
const implementation = (0, node_vm_1.runInNewContext)("({ then(resolve) { resolve(value); } })", { value: { proxy: () => "resolved" } });
|
|
41
|
+
await (0, __1.ImplementInterface)(declaration, implementation);
|
|
42
|
+
(0, chai_1.expect)(await proxy.call()).to.equal("resolved");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=implement-interface-validation.test.js.map
|