poe-code 14.0.61 → 14.0.62
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.js +218 -70
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-VAYQP2VZ.js → chunk-F7TJSPDZ.js} +7 -3
- package/packages/safe-js/dist/chunks/chunk-F7TJSPDZ.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-ZTGKRKQH.js → chunk-VKGWGZBH.js} +181 -66
- package/packages/safe-js/dist/chunks/chunk-VKGWGZBH.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/async.js +3 -0
- package/packages/safe-js/dist/interp/function-string.d.ts +2 -0
- package/packages/safe-js/dist/interp/function-string.js +21 -0
- package/packages/safe-js/dist/interp/globals/misc.js +11 -12
- package/packages/safe-js/dist/interp/globals/numeric-parsers.d.ts +5 -0
- package/packages/safe-js/dist/interp/globals/numeric-parsers.js +47 -0
- package/packages/safe-js/dist/interp/globals/object-array.js +2 -10
- package/packages/safe-js/dist/interp/interpreter.js +1 -0
- package/packages/safe-js/dist/interp/methods/function.d.ts +2 -0
- package/packages/safe-js/dist/interp/methods/function.js +10 -1
- package/packages/safe-js/dist/interp/resources.d.ts +1 -0
- package/packages/safe-js/dist/interp/string-coercion.js +3 -0
- package/packages/safe-js/dist/interp/values.d.ts +3 -0
- package/packages/safe-js/dist/interp/values.js +3 -0
- package/packages/safe-js/dist/migrate.js +1 -1
- package/packages/safe-js/dist/parse/function-source.d.ts +7 -0
- package/packages/safe-js/dist/parse/function-source.js +1 -0
- package/packages/safe-js/dist/parse/hash.d.ts +2 -2
- package/packages/safe-js/dist/parse/hash.js +23 -9
- package/packages/safe-js/dist/parse/parser.js +36 -23
- package/packages/safe-js/dist/restore.js +2 -1
- package/packages/safe-js/dist/run.js +16 -5
- package/packages/safe-js/dist/snapshot/dump-format.d.ts +1 -1
- package/packages/safe-js/dist/snapshot/dump-format.js +1 -1
- package/packages/safe-js/dist/snapshot/migration.js +2 -2
- package/packages/safe-js/dist/snapshot/restore.js +2 -0
- package/packages/safe-js/dist/chunks/chunk-VAYQP2VZ.js.map +0 -7
- package/packages/safe-js/dist/chunks/chunk-ZTGKRKQH.js.map +0 -7
|
@@ -21,13 +21,14 @@ export function restore(snapshot, options, owner) {
|
|
|
21
21
|
validateSnapshotMigration(snapshot.migration, snapshot.sourceHash, owner);
|
|
22
22
|
if (snapshot.executionSemantics !== EXECUTION_SEMANTICS &&
|
|
23
23
|
snapshot.executionSemantics !== "jobs-v6" &&
|
|
24
|
+
snapshot.executionSemantics !== "jobs-v7" &&
|
|
24
25
|
(snapshot.executionSemantics !== undefined ||
|
|
25
26
|
snapshot.promiseReplay !== undefined ||
|
|
26
27
|
snapshot.replay !== undefined ||
|
|
27
28
|
snapshot.initialInputs !== undefined)) {
|
|
28
29
|
throw new SnapshotValidationError("unsupportedVersion", "$.executionSemantics", "incompatible execution semantics; resume with the SafeJS version that created this snapshot. Migration requires explicit reconciliation, not changing its version marker.");
|
|
29
30
|
}
|
|
30
|
-
const currentSourceHash = hashSource(options.source, owner);
|
|
31
|
+
const currentSourceHash = hashSource(options.source, owner, snapshot.executionSemantics !== "jobs-v6" && snapshot.executionSemantics !== "jobs-v7");
|
|
31
32
|
if (snapshot.sourceHash !== currentSourceHash) {
|
|
32
33
|
throw new SnapshotMismatchError(snapshot.sourceHash, currentSourceHash);
|
|
33
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { runWithExtensions } from "./realm.js";
|
|
3
3
|
import { hashParsedAst, hashSource } from "./parse/hash.js";
|
|
4
|
-
import { withRunResources } from "./interp/resources.js";
|
|
4
|
+
import { runResources, withRunResources } from "./interp/resources.js";
|
|
5
5
|
import { createReplayableRandom } from "./random.js";
|
|
6
6
|
import { attachErrorSpan, describeThrownValue, materializeWrappedErrorCause, replaceErrorStack } from "./error/shape.js";
|
|
7
7
|
import { findRegexLiteral, parseExecutableModule } from "./parse/parser.js";
|
|
@@ -76,7 +76,11 @@ export function run(source, options = {}) {
|
|
|
76
76
|
const restoredSnapshot = options.snapshot === undefined
|
|
77
77
|
? undefined
|
|
78
78
|
: restore(options.snapshot, { source }, operation.owner);
|
|
79
|
-
const executionSemantics = restoredSnapshot?.executionSemantics === "jobs-v6"
|
|
79
|
+
const executionSemantics = restoredSnapshot?.executionSemantics === "jobs-v6" ||
|
|
80
|
+
restoredSnapshot?.executionSemantics === "jobs-v7"
|
|
81
|
+
? restoredSnapshot.executionSemantics
|
|
82
|
+
: EXECUTION_SEMANTICS;
|
|
83
|
+
runResources.getStore().functionSourceText = executionSemantics === EXECUTION_SEMANTICS;
|
|
80
84
|
const convertInitialInput = (convert) => executionSemantics === "jobs-v6" ? convert() : promiseReplayContext.exit(convert);
|
|
81
85
|
if (restoredSnapshot !== undefined) {
|
|
82
86
|
leaveSnapshotRun = enterSnapshotRun(restoredSnapshot);
|
|
@@ -86,8 +90,8 @@ export function run(source, options = {}) {
|
|
|
86
90
|
const module = parseExecutableModule(source, filename, operation.owner);
|
|
87
91
|
promiseReplay.validateNodes(module);
|
|
88
92
|
const sourceHash = findRegexLiteral(module) === undefined
|
|
89
|
-
? hashSource(source, operation.owner)
|
|
90
|
-
: hashParsedAst(module);
|
|
93
|
+
? hashSource(source, operation.owner, executionSemantics === EXECUTION_SEMANTICS)
|
|
94
|
+
: hashParsedAst(module, executionSemantics === EXECUTION_SEMANTICS);
|
|
91
95
|
const hostCalls = new HostCallJournal(sourceHash, readHostCallSnapshot(restoredSnapshot), options.hostCallResumeProvider, restoredSnapshot?.replay, budget, operation.owner);
|
|
92
96
|
leaveHostReplay = hostCalls.dispose.bind(hostCalls);
|
|
93
97
|
promiseReplay.validateCallbacks(hostCalls.callbackPositions());
|
|
@@ -110,7 +114,14 @@ export function run(source, options = {}) {
|
|
|
110
114
|
signal: options.signal,
|
|
111
115
|
lifecycle
|
|
112
116
|
}));
|
|
113
|
-
const builtinBindings = createBuiltinBindings({
|
|
117
|
+
const builtinBindings = createBuiltinBindings({
|
|
118
|
+
compileOwner: operation.owner,
|
|
119
|
+
budget,
|
|
120
|
+
hostCalls,
|
|
121
|
+
sink: options.sink,
|
|
122
|
+
random: random?.generator.next,
|
|
123
|
+
clock: options.clock
|
|
124
|
+
});
|
|
114
125
|
const importMeta = convertInitialInput(() => deepCopyToSandbox(options.importMeta ?? {}));
|
|
115
126
|
if (restoredSnapshot?.migration !== undefined) {
|
|
116
127
|
if (Object.hasOwn(importMeta, "migration"))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const DUMP_FORMAT_VERSION = 1;
|
|
2
|
-
export const EXECUTION_SEMANTICS = "jobs-
|
|
2
|
+
export const EXECUTION_SEMANTICS = "jobs-v8";
|
|
3
3
|
import { assertSnapshotGraphDepth } from "../graph-depth.js";
|
|
4
4
|
import { hasGuestObjectState } from "../interp/object-model.js";
|
|
5
5
|
import { sandboxErrorTypes } from "../error/shape.js";
|
|
@@ -3,8 +3,8 @@ import { decodeReplayData } from "./replay-data.js";
|
|
|
3
3
|
import { validateSnapshotData } from "./validation.js";
|
|
4
4
|
import { CompileScope } from "../interp/regex/compile-guard.js";
|
|
5
5
|
export function validateMigrationSemantics(value) {
|
|
6
|
-
if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6", "jobs-v7"].includes(value))
|
|
7
|
-
throw new TypeError("Migration requires a supported execution-semantics marker (jobs-v1 through jobs-
|
|
6
|
+
if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6", "jobs-v7", "jobs-v8"].includes(value))
|
|
7
|
+
throw new TypeError("Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v8).");
|
|
8
8
|
}
|
|
9
9
|
export function validateMigrationJournal(sourceHash, replay, hostCalls = [], owner) {
|
|
10
10
|
if (replay === undefined)
|
|
@@ -8,6 +8,7 @@ import { sandboxErrorTypes } from "../error/shape.js";
|
|
|
8
8
|
import { SnapshotMismatchError } from "../restore.js";
|
|
9
9
|
import { Scope, setSandboxProperty } from "../interp/interpreter.js";
|
|
10
10
|
import { getGuestFunctionProperties, getGuestFunctionProperty, getSandboxDataProperty, registerGuestClosure, setSandboxPrototype } from "../interp/object-model.js";
|
|
11
|
+
import { functionSources } from "../parse/function-source.js";
|
|
11
12
|
import { wrapCallerInjectedBindings } from "../interp/host-bridge.js";
|
|
12
13
|
import { restoreSandboxCollectionIterator } from "../interp/collection-iterator.js";
|
|
13
14
|
import { isSandboxMap, isSandboxSet } from "../interp/values.js";
|
|
@@ -454,6 +455,7 @@ function restoreClosureValue(astNodeId, capturedScopeId, state) {
|
|
|
454
455
|
throw new Error(`Snapshot references unknown closure AST node ${astNodeId}.`);
|
|
455
456
|
}
|
|
456
457
|
const baseClosure = createSandboxClosure({
|
|
458
|
+
sourceRange: functionSources.get(node),
|
|
457
459
|
async: node.async,
|
|
458
460
|
sandbox: true,
|
|
459
461
|
length: getFunctionLength(node.params),
|