@jplorg/jpl 2.1.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/main.js +13 -5
- package/dist/types/runtime/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/esm/main.js
CHANGED
|
@@ -460,13 +460,19 @@ function lt(e) {
|
|
|
460
460
|
// lib/runtime/index.ts
|
|
461
461
|
var ut = { vars: {} };
|
|
462
462
|
function I(e = {}, t = {}) {
|
|
463
|
-
return
|
|
463
|
+
return {
|
|
464
|
+
...r(e, t, "vars"),
|
|
465
|
+
signal: AbortSignal.any([e.signal, t.signal].filter((e) => e != null))
|
|
466
|
+
};
|
|
464
467
|
}
|
|
465
468
|
var dt = class {
|
|
466
469
|
#e;
|
|
467
470
|
#t;
|
|
471
|
+
#n;
|
|
468
472
|
constructor(e, t) {
|
|
469
|
-
this.#e = I(t?.runtime, ut), this.#t = e
|
|
473
|
+
this.#e = I(t?.runtime, ut), this.#t = e, this.#n = this.createScope({ vars: Object.fromEntries(this.muxOne([Object.entries(this.options.vars)], ([e, t]) => [e, this.normalizeValue(t)])) }), this.options.signal?.aborted && this.#n.signal.exit(), this.options.signal?.addEventListener("abort", () => {
|
|
474
|
+
this.#n.signal.exit();
|
|
475
|
+
});
|
|
470
476
|
}
|
|
471
477
|
get options() {
|
|
472
478
|
return this.#e;
|
|
@@ -474,13 +480,15 @@ var dt = class {
|
|
|
474
480
|
get program() {
|
|
475
481
|
return this.#t;
|
|
476
482
|
}
|
|
483
|
+
get rootScope() {
|
|
484
|
+
return this.#n;
|
|
485
|
+
}
|
|
477
486
|
createScope = (e) => new M(e);
|
|
478
487
|
execute = async (e) => {
|
|
479
|
-
let t = this.createScope({ vars: Object.fromEntries(this.muxOne([Object.entries(this.options.vars)], ([e, t]) => [e, this.normalizeValue(t)])) });
|
|
480
488
|
try {
|
|
481
|
-
return await this.executeInstructions(this.program.definition.instructions ?? [], e,
|
|
489
|
+
return await this.executeInstructions(this.program.definition.instructions ?? [], e, this.rootScope, this.options.adjustResult);
|
|
482
490
|
} finally {
|
|
483
|
-
|
|
491
|
+
this.rootScope.signal.exit();
|
|
484
492
|
}
|
|
485
493
|
};
|
|
486
494
|
executeInstructions = (e, t, n, r = (e) => [e]) => {
|
|
@@ -9,6 +9,7 @@ export type JPLRuntimeOptions = {
|
|
|
9
9
|
[name: string]: unknown;
|
|
10
10
|
};
|
|
11
11
|
adjustResult?: (result: unknown, scope: JPLRuntimeScope) => Promise<unknown[]> | unknown[];
|
|
12
|
+
signal?: AbortSignal;
|
|
12
13
|
};
|
|
13
14
|
export declare function applyRuntimeDefaults(options?: JPLRuntimeOptions, defaults?: JPLRuntimeOptions): JPLRuntimeOptions;
|
|
14
15
|
/** JPL runtime */
|
|
@@ -19,6 +20,8 @@ export default class JPLRuntime {
|
|
|
19
20
|
get options(): JPLRuntimeOptions;
|
|
20
21
|
/** Return the runtime's program */
|
|
21
22
|
get program(): JPLProgram;
|
|
23
|
+
/** Return the runtime's root scope */
|
|
24
|
+
get rootScope(): JPLRuntimeScope;
|
|
22
25
|
/** Create a new orphan scope */
|
|
23
26
|
createScope: (presets?: JPLRuntimeScopeConfig) => JPLRuntimeScope;
|
|
24
27
|
/** Execute a new dedicated program */
|