@poe-platform/safe-js 0.1.720 → 0.1.721
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/README.md +15 -2
- package/dist/safe-js/chunks/{chunk-APKV5Y6T.js → chunk-4CX3HYRY.js} +2 -2
- package/dist/safe-js/chunks/{chunk-NJM2Q74Z.js → chunk-A4L72WXV.js} +4 -4
- package/dist/safe-js/chunks/{chunk-B2SQLK4O.js → chunk-B4M6QVUV.js} +2 -2
- package/dist/safe-js/chunks/{chunk-A7CADQAD.js → chunk-BEXRQET4.js} +3 -3
- package/dist/safe-js/chunks/{chunk-OP3H3ZDN.js → chunk-BHYBD6SY.js} +2 -2
- package/dist/safe-js/chunks/{chunk-KP6I45ET.js → chunk-DNA7BMBY.js} +192 -38
- package/dist/safe-js/chunks/{chunk-KP6I45ET.js.map → chunk-DNA7BMBY.js.map} +3 -3
- package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js → chunk-GMPZBMPA.js} +3 -3
- package/dist/safe-js/chunks/{chunk-IDQ67DY2.js → chunk-ILYJBA2D.js} +24 -3
- package/dist/safe-js/chunks/chunk-ILYJBA2D.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js → chunk-IS7YUCOF.js} +2 -2
- package/dist/safe-js/chunks/{chunk-BGJXQN4A.js → chunk-JNLY7IMV.js} +4 -4
- package/dist/safe-js/chunks/{chunk-RML35GIF.js → chunk-LPBTSTDG.js} +3 -3
- package/dist/safe-js/chunks/{chunk-KK5NCR5R.js → chunk-Q7B6JIMI.js} +110 -46
- package/dist/safe-js/chunks/chunk-Q7B6JIMI.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-XMA6FOJU.js → chunk-Y4LNCDCP.js} +2 -2
- package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js → cli-runtime-YK2WE33M.js} +13 -13
- package/dist/safe-js/chunks/{dump-TRGFSCJ7.js → dump-ATWBOZWV.js} +4 -4
- package/dist/safe-js/chunks/{fs-4T5MZW5J.js → fs-D72Y52I5.js} +4 -4
- package/dist/safe-js/chunks/harness-LUYCGWHZ.js +10 -0
- package/dist/safe-js/chunks/mcp-IWKZB2R2.js +11 -0
- package/dist/safe-js/chunks/migration-file-IXO5MLP4.js +12 -0
- package/dist/safe-js/chunks/restore-SI7HOC6C.js +13 -0
- package/dist/safe-js/chunks/run-SHI2PYR6.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-OO72HTVF.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/extensions.d.ts +3 -1
- package/dist/safe-js/index.js +13 -13
- package/dist/safe-js/interp/budget.d.ts +3 -0
- package/dist/safe-js/interp/scope.d.ts +4 -1
- package/dist/safe-js/interp/typed-array.d.ts +3 -0
- package/dist/safe-js/parse/dynamic-source.d.ts +1 -1
- package/dist/safe-js/parse/parser.d.ts +1 -1
- package/dist/safe-js/realm.d.ts +1 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/note.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-IDQ67DY2.js.map +0 -7
- package/dist/safe-js/chunks/chunk-KK5NCR5R.js.map +0 -7
- package/dist/safe-js/chunks/harness-DLEQ2Z3O.js +0 -10
- package/dist/safe-js/chunks/mcp-TNVEFJ6K.js +0 -11
- package/dist/safe-js/chunks/migration-file-IDIUFLKY.js +0 -12
- package/dist/safe-js/chunks/restore-P27AUZR2.js +0 -13
- package/dist/safe-js/chunks/run-KGAEHYMV.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-KICK45EE.js +0 -10
- /package/dist/safe-js/chunks/{chunk-APKV5Y6T.js.map → chunk-4CX3HYRY.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-NJM2Q74Z.js.map → chunk-A4L72WXV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-B2SQLK4O.js.map → chunk-B4M6QVUV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-A7CADQAD.js.map → chunk-BEXRQET4.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-OP3H3ZDN.js.map → chunk-BHYBD6SY.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js.map → chunk-GMPZBMPA.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js.map → chunk-IS7YUCOF.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-BGJXQN4A.js.map → chunk-JNLY7IMV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-RML35GIF.js.map → chunk-LPBTSTDG.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-XMA6FOJU.js.map → chunk-Y4LNCDCP.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js.map → cli-runtime-YK2WE33M.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-TRGFSCJ7.js.map → dump-ATWBOZWV.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-4T5MZW5J.js.map → fs-D72Y52I5.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-DLEQ2Z3O.js.map → harness-LUYCGWHZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-TNVEFJ6K.js.map → mcp-IWKZB2R2.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-IDIUFLKY.js.map → migration-file-IXO5MLP4.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-P27AUZR2.js.map → restore-SI7HOC6C.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-KGAEHYMV.js.map → run-SHI2PYR6.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-KICK45EE.js.map → runtime-modules-OO72HTVF.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deepCopyToSandbox
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DNA7BMBY.js";
|
|
4
4
|
|
|
5
5
|
// packages/safe-js/src/modules/harness.ts
|
|
6
6
|
function makeHarnessModule(frontmatter, meta) {
|
|
@@ -52,4 +52,4 @@ ${prompt}`;
|
|
|
52
52
|
export {
|
|
53
53
|
makeHarnessModule
|
|
54
54
|
};
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-IS7YUCOF.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
validateMigrationReconciliation,
|
|
8
8
|
validateMigrationSemantics,
|
|
9
9
|
validateSnapshotMigration
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GMPZBMPA.js";
|
|
11
11
|
import {
|
|
12
12
|
DUMP_FORMAT_VERSION,
|
|
13
13
|
EXECUTION_SEMANTICS,
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
serializeSafeJSSnapshot,
|
|
18
18
|
validateDumpEnvelope,
|
|
19
19
|
validateSnapshotData
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DNA7BMBY.js";
|
|
21
21
|
import {
|
|
22
22
|
parseModule
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ILYJBA2D.js";
|
|
24
24
|
|
|
25
25
|
// packages/safe-js/src/migration-file.ts
|
|
26
26
|
import { randomUUID } from "node:crypto";
|
|
@@ -179,4 +179,4 @@ export {
|
|
|
179
179
|
migrateSnapshot,
|
|
180
180
|
migrateSnapshotFile
|
|
181
181
|
};
|
|
182
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-JNLY7IMV.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
declareHostOperation,
|
|
8
8
|
runResources
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DNA7BMBY.js";
|
|
10
10
|
import {
|
|
11
11
|
hostErrorData
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ILYJBA2D.js";
|
|
13
13
|
|
|
14
14
|
// packages/safe-js/src/modules/mcp.ts
|
|
15
15
|
var DEFAULT_TOOL_BATCH_CONCURRENCY = 4;
|
|
@@ -402,4 +402,4 @@ function isPlainObjectRecord(value) {
|
|
|
402
402
|
export {
|
|
403
403
|
makeMcpModule
|
|
404
404
|
};
|
|
405
|
-
//# sourceMappingURL=chunk-
|
|
405
|
+
//# sourceMappingURL=chunk-LPBTSTDG.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
restore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A4L72WXV.js";
|
|
4
4
|
import {
|
|
5
5
|
attachDumpController,
|
|
6
6
|
createDumpController
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BEXRQET4.js";
|
|
8
8
|
import {
|
|
9
9
|
getOwnErrorCode,
|
|
10
10
|
hasOwnErrorCode
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
hashParsedAst,
|
|
14
14
|
hashSource
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GMPZBMPA.js";
|
|
16
16
|
import {
|
|
17
17
|
DUMP_FORMAT_VERSION,
|
|
18
18
|
EXECUTION_SEMANTICS,
|
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
PromiseReplay,
|
|
22
22
|
SandboxJobQueue,
|
|
23
23
|
Scope,
|
|
24
|
+
arrayBufferDetached,
|
|
25
|
+
arrayBufferLength,
|
|
26
|
+
arrayBufferOptions,
|
|
24
27
|
attachExecutionControl,
|
|
25
28
|
attachSourceLoader,
|
|
26
29
|
awaitSandboxValue,
|
|
@@ -30,6 +33,7 @@ import {
|
|
|
30
33
|
consumeSettledHostCall,
|
|
31
34
|
copyHostValueToSandbox,
|
|
32
35
|
createBuiltinBindings,
|
|
36
|
+
createEvalSource,
|
|
33
37
|
createGuestReference,
|
|
34
38
|
createHostCallbackContext,
|
|
35
39
|
createLiveHostObject,
|
|
@@ -49,10 +53,12 @@ import {
|
|
|
49
53
|
enterSnapshotRun,
|
|
50
54
|
exportHostCapability,
|
|
51
55
|
getExtensionSetup,
|
|
56
|
+
getRealmGlobalObject,
|
|
52
57
|
guestProxyStates,
|
|
53
58
|
inMemoryRunSnapshots,
|
|
54
59
|
interpret,
|
|
55
60
|
invokeBuiltinClosure,
|
|
61
|
+
isSandboxArrayBuffer,
|
|
56
62
|
isSandboxClosure,
|
|
57
63
|
isSandboxCollectionIterator,
|
|
58
64
|
isSandboxMap,
|
|
@@ -75,6 +81,7 @@ import {
|
|
|
75
81
|
releaseObjectPrototype,
|
|
76
82
|
resolveModuleImports,
|
|
77
83
|
resolveModuleNamespace,
|
|
84
|
+
retainValues,
|
|
78
85
|
revokeGuestCallback,
|
|
79
86
|
revokeGuestReference,
|
|
80
87
|
revokeHostObject,
|
|
@@ -90,7 +97,7 @@ import {
|
|
|
90
97
|
withSandboxPromiseRejectionTracker,
|
|
91
98
|
wrapCallerInjectedBindings,
|
|
92
99
|
wrapCancelableBindings
|
|
93
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-DNA7BMBY.js";
|
|
94
101
|
import {
|
|
95
102
|
Budget,
|
|
96
103
|
CompileScope,
|
|
@@ -105,7 +112,7 @@ import {
|
|
|
105
112
|
parseSourceModule,
|
|
106
113
|
replaceErrorStack,
|
|
107
114
|
safeAddEvent
|
|
108
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-ILYJBA2D.js";
|
|
109
116
|
|
|
110
117
|
// packages/safe-js/src/realm.ts
|
|
111
118
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -491,6 +498,8 @@ function createReplayableRandom(options = {}) {
|
|
|
491
498
|
var RealmState = class {
|
|
492
499
|
constructor(options, queue = new SandboxJobQueue()) {
|
|
493
500
|
this.options = options;
|
|
501
|
+
if (options.classicScripts !== void 0 && typeof options.classicScripts !== "boolean")
|
|
502
|
+
throw new TypeError("Realm classicScripts must be a boolean.");
|
|
494
503
|
this.queue = queue;
|
|
495
504
|
const limitInput = readDataRecord(options.limits ?? {}, "Realm limits");
|
|
496
505
|
this.limits = {
|
|
@@ -524,6 +533,8 @@ var RealmState = class {
|
|
|
524
533
|
if (this.extensions.length > this.limits.extensions)
|
|
525
534
|
throw new RangeError("Realm extension limit exceeded.");
|
|
526
535
|
this.globals = readDataRecord(options.bindings ?? {}, "Realm bindings");
|
|
536
|
+
if (options.classicScripts && ["this", "globalThis"].some((name) => Object.hasOwn(this.globals, name)))
|
|
537
|
+
throw new TypeError("Classic Script receiver bindings cannot be replaced.");
|
|
527
538
|
this.modules = readModules(options.modules);
|
|
528
539
|
const grants = new Set(readStringList(options.grants ?? [], "Realm grants"));
|
|
529
540
|
for (const extension of this.extensions) getExtensionSetup(extension);
|
|
@@ -536,7 +547,7 @@ var RealmState = class {
|
|
|
536
547
|
this.consoleExtension = extensionName;
|
|
537
548
|
}
|
|
538
549
|
this.budget = options.budget ?? new Budget({ maxCallDepth: 1e3 });
|
|
539
|
-
this.lease = this.budget.
|
|
550
|
+
this.lease = this.budget.acquireRealmOwner();
|
|
540
551
|
this.compilation = new CompileScope(this.lease.owner);
|
|
541
552
|
this.bridge = {
|
|
542
553
|
owner: this,
|
|
@@ -570,6 +581,8 @@ var RealmState = class {
|
|
|
570
581
|
);
|
|
571
582
|
for (const extension of this.extensions) {
|
|
572
583
|
const manifest = extension.manifest;
|
|
584
|
+
if (options.classicScripts && manifest.globals?.some((name) => name === "this" || name === "globalThis"))
|
|
585
|
+
throw new TypeError("Classic Script receiver bindings cannot be replaced.");
|
|
573
586
|
if (names.has(manifest.name))
|
|
574
587
|
throw new TypeError(`Duplicate extension '${manifest.name}'.`);
|
|
575
588
|
names.add(manifest.name);
|
|
@@ -676,7 +689,7 @@ var RealmState = class {
|
|
|
676
689
|
}
|
|
677
690
|
if (captured.length > 0)
|
|
678
691
|
this.budget.reconcileDataUsage(
|
|
679
|
-
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()])
|
|
692
|
+
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots(), ...this.budget.retainedValues()])
|
|
680
693
|
);
|
|
681
694
|
return { args: values, rollback };
|
|
682
695
|
} catch (error) {
|
|
@@ -685,6 +698,40 @@ var RealmState = class {
|
|
|
685
698
|
throw error;
|
|
686
699
|
}
|
|
687
700
|
};
|
|
701
|
+
createArrayBufferReference = (buffer) => {
|
|
702
|
+
this.assertOpen();
|
|
703
|
+
if (!isSandboxArrayBuffer(buffer) || arrayBufferDetached(buffer) || arrayBufferOptions(buffer) !== void 0 || Reflect.ownKeys(buffer).length !== 0)
|
|
704
|
+
throw new TypeError(
|
|
705
|
+
"Live buffer references require a fixed, attached, plain ArrayBuffer without metadata."
|
|
706
|
+
);
|
|
707
|
+
let reference;
|
|
708
|
+
try {
|
|
709
|
+
this.budget.allocateArrayLength(arrayBufferLength(buffer));
|
|
710
|
+
this.checkCollection(
|
|
711
|
+
this.guestReferences.size + 1,
|
|
712
|
+
this.limits.guestReferences,
|
|
713
|
+
"guest reference"
|
|
714
|
+
);
|
|
715
|
+
const root = [buffer];
|
|
716
|
+
reference = createGuestReference(root, this, this.assertOpen);
|
|
717
|
+
this.guestReferences.set(reference, root);
|
|
718
|
+
this.budget.reconcileDataUsage(
|
|
719
|
+
measureSandboxData([
|
|
720
|
+
...this.scope?.retainedDataRoots() ?? [],
|
|
721
|
+
...this.retainedRoots(),
|
|
722
|
+
...this.budget.retainedValues()
|
|
723
|
+
])
|
|
724
|
+
);
|
|
725
|
+
return reference;
|
|
726
|
+
} catch (error) {
|
|
727
|
+
if (reference !== void 0) {
|
|
728
|
+
revokeGuestReference(reference, this);
|
|
729
|
+
this.guestReferences.delete(reference);
|
|
730
|
+
}
|
|
731
|
+
if (error instanceof SandboxError) this.poison(error);
|
|
732
|
+
throw error;
|
|
733
|
+
}
|
|
734
|
+
};
|
|
688
735
|
releaseGuestReference = (reference) => {
|
|
689
736
|
readGuestReference(reference, this);
|
|
690
737
|
revokeGuestReference(reference, this);
|
|
@@ -880,7 +927,7 @@ var RealmState = class {
|
|
|
880
927
|
});
|
|
881
928
|
try {
|
|
882
929
|
this.budget.reconcileDataUsage(
|
|
883
|
-
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()])
|
|
930
|
+
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots(), ...this.budget.retainedValues()])
|
|
884
931
|
);
|
|
885
932
|
} catch (error) {
|
|
886
933
|
this.poison(error);
|
|
@@ -965,7 +1012,7 @@ var RealmState = class {
|
|
|
965
1012
|
this.resources,
|
|
966
1013
|
() => withCancellationSignal(
|
|
967
1014
|
this.controller.signal,
|
|
968
|
-
() => active && this.phase.getStore()?.active ? runAsyncPrefix(invoke) : this.queue.run(invoke)
|
|
1015
|
+
() => active && this.phase.getStore()?.active ? runAsyncPrefix(invoke, completeSynchronous === void 0 && this.phase.getStore()?.extension !== void 0) : this.queue.run(invoke)
|
|
969
1016
|
)
|
|
970
1017
|
)
|
|
971
1018
|
);
|
|
@@ -997,6 +1044,12 @@ var RealmState = class {
|
|
|
997
1044
|
},
|
|
998
1045
|
chargeWork: this.chargeWork,
|
|
999
1046
|
createHostObject: this.createHostObject,
|
|
1047
|
+
createArrayBufferReference: (buffer) => {
|
|
1048
|
+
this.assertOpen();
|
|
1049
|
+
if (!extension.manifest.capabilities?.includes("array-buffer:share"))
|
|
1050
|
+
throw new TypeError("Live buffers require the array-buffer:share grant.");
|
|
1051
|
+
return this.createArrayBufferReference(buffer);
|
|
1052
|
+
},
|
|
1000
1053
|
startCallback: this.startCallback,
|
|
1001
1054
|
invokeCallback: this.invokeCallback,
|
|
1002
1055
|
releaseCallback: this.releaseCallback,
|
|
@@ -1081,8 +1134,10 @@ var RealmState = class {
|
|
|
1081
1134
|
const bindings = wrapCallerInjectedBindings(this.globals, this.bridgeOptions());
|
|
1082
1135
|
this.scope = new Scope(this.builtinBindings, void 0, void 0, { chargeData: false }).child(
|
|
1083
1136
|
bindings,
|
|
1084
|
-
{ functionBoundary: true }
|
|
1137
|
+
this.options.classicScripts ? { globalEnvironment: true } : { functionBoundary: true }
|
|
1085
1138
|
);
|
|
1139
|
+
if (this.options.classicScripts)
|
|
1140
|
+
this.scope.declare("this", "const", getRealmGlobalObject(this.budget));
|
|
1086
1141
|
}
|
|
1087
1142
|
async evaluateRaw(source, filename = "<realm>", nested = false, sourceType) {
|
|
1088
1143
|
this.assertOpen();
|
|
@@ -1101,46 +1156,54 @@ var RealmState = class {
|
|
|
1101
1156
|
surfaceUnhandledThrows: true
|
|
1102
1157
|
});
|
|
1103
1158
|
const before = this.sourceGraph.stats.nodeVisits;
|
|
1104
|
-
const namespace = await this.sourceGraph.evaluateSource({ id: filename, source }, (
|
|
1105
|
-
this.sourceModuleHash = hashParsedAst(
|
|
1159
|
+
const namespace = await this.sourceGraph.evaluateSource({ id: filename, source }, (module) => {
|
|
1160
|
+
this.sourceModuleHash = hashParsedAst(module);
|
|
1106
1161
|
});
|
|
1107
1162
|
await this.sourceGraph.settle();
|
|
1108
1163
|
return { ok: true, returnValue: namespace, snapshot: { bindings: {} }, stats: { nodeVisits: this.sourceGraph.stats.nodeVisits - before, currentDataSize: this.budget.currentDataSize, peakDataSize: this.budget.peakDataSize } };
|
|
1109
1164
|
}
|
|
1110
|
-
const
|
|
1111
|
-
this.
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
wrappedModules: this.convertedModules
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
body: module.body.filter((statement) => statement.type !== "ImportDeclaration"),
|
|
1128
|
-
span: module.span
|
|
1129
|
-
},
|
|
1130
|
-
{
|
|
1131
|
-
scope: this.scope,
|
|
1132
|
-
useScopeDirectly: true,
|
|
1133
|
-
budget: this.budget,
|
|
1134
|
-
compilation: this.compilation,
|
|
1135
|
-
signal: this.controller.signal,
|
|
1136
|
-
surfaceUnhandledThrows: true,
|
|
1137
|
-
jobs: this.queue,
|
|
1138
|
-
nested,
|
|
1139
|
-
assertActive: this.assertOpen
|
|
1165
|
+
const script = this.options.classicScripts ? createEvalSource(source, {}, this.lease.owner, filename) : void 0;
|
|
1166
|
+
const releaseSource = script ? retainValues(this.budget, () => [script.source]) : void 0;
|
|
1167
|
+
try {
|
|
1168
|
+
if (script) this.budget.chargeDataUsage(measureSandboxData([script.source]));
|
|
1169
|
+
const module = script?.node ?? parseExecutableModule(source, filename, this.lease.owner);
|
|
1170
|
+
this.initialize();
|
|
1171
|
+
const moduleEnvironment = createModuleEnvironment(this.modules, { ...this.bridgeOptions(), wrappedModules: this.convertedModules });
|
|
1172
|
+
const imports = script ? {} : resolveModuleImports(module, this.modules, {
|
|
1173
|
+
environment: moduleEnvironment,
|
|
1174
|
+
...this.bridgeOptions(),
|
|
1175
|
+
wrappedModules: this.convertedModules
|
|
1176
|
+
});
|
|
1177
|
+
this.scope.moduleEnvironment = moduleEnvironment;
|
|
1178
|
+
for (const [name, value] of Object.entries(imports)) {
|
|
1179
|
+
const binding = this.scope.lookup(name);
|
|
1180
|
+
if (!binding.found) this.scope.declare(name, "const", value);
|
|
1181
|
+
else if (binding.value !== value) throw new TypeError(`Conflicting import '${name}'.`);
|
|
1140
1182
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1183
|
+
const result = await interpret(
|
|
1184
|
+
{
|
|
1185
|
+
type: "BlockStatement",
|
|
1186
|
+
body: module.body.filter((statement) => statement.type !== "ImportDeclaration"),
|
|
1187
|
+
span: module.span
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
...script ? { script: { strict: script.strict } } : {},
|
|
1191
|
+
scope: this.scope,
|
|
1192
|
+
useScopeDirectly: true,
|
|
1193
|
+
budget: this.budget,
|
|
1194
|
+
compilation: this.compilation,
|
|
1195
|
+
signal: this.controller.signal,
|
|
1196
|
+
surfaceUnhandledThrows: true,
|
|
1197
|
+
jobs: this.queue,
|
|
1198
|
+
nested,
|
|
1199
|
+
assertActive: this.assertOpen
|
|
1200
|
+
}
|
|
1201
|
+
);
|
|
1202
|
+
this.assertOpen();
|
|
1203
|
+
return result;
|
|
1204
|
+
} finally {
|
|
1205
|
+
releaseSource?.();
|
|
1206
|
+
}
|
|
1144
1207
|
}
|
|
1145
1208
|
evaluateNested = async (source, extension) => {
|
|
1146
1209
|
this.assertOpen();
|
|
@@ -1352,6 +1415,7 @@ function readRealmOptions(value, oneShot = false) {
|
|
|
1352
1415
|
"clock",
|
|
1353
1416
|
"limits"
|
|
1354
1417
|
]);
|
|
1418
|
+
if (!oneShot) supported.add("classicScripts");
|
|
1355
1419
|
for (const [key, entry] of Object.entries(options)) {
|
|
1356
1420
|
if (supported.has(key) || oneShot && (key === "filename" || key === "sourceType" || entry === void 0)) continue;
|
|
1357
1421
|
throw new TypeError(`Unsupported ${oneShot ? "extension-run" : "realm"} option '${key}'.`);
|
|
@@ -2447,4 +2511,4 @@ export {
|
|
|
2447
2511
|
UnhandledRejectionError,
|
|
2448
2512
|
run
|
|
2449
2513
|
};
|
|
2450
|
-
//# sourceMappingURL=chunk-
|
|
2514
|
+
//# sourceMappingURL=chunk-Q7B6JIMI.js.map
|