@poe-platform/safe-js 0.1.247 → 0.1.249
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/safe-js/chunks/{chunk-7ZMFUFNG.js → chunk-2I5DAEWD.js} +2 -2
- package/dist/safe-js/chunks/{chunk-TL2QKHPX.js → chunk-IKHGVNT5.js} +52 -8
- package/dist/safe-js/chunks/chunk-IKHGVNT5.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/snapshot/dump-format.d.ts +1 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-TL2QKHPX.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-7ZMFUFNG.js.map → chunk-2I5DAEWD.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-IKHGVNT5.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-2I5DAEWD.js.map
|
|
@@ -7859,7 +7859,8 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
|
7859
7859
|
}
|
|
7860
7860
|
function registerIntrinsicFunction(budget, closure) {
|
|
7861
7861
|
if (closure.name === void 0) throw new TypeError("Intrinsic functions require an installation name.");
|
|
7862
|
-
|
|
7862
|
+
if (getIntrinsicIdentity(closure) === void 0)
|
|
7863
|
+
registerBuiltinIdentities(budget, { [closure.name]: closure });
|
|
7863
7864
|
trackIntrinsicState(budget, closure, closure, [closure]);
|
|
7864
7865
|
}
|
|
7865
7866
|
function trackIntrinsicState(budget, root, owner, targets) {
|
|
@@ -12551,12 +12552,12 @@ function createObjectArrayGlobals(options) {
|
|
|
12551
12552
|
}),
|
|
12552
12553
|
fromCharCode: createSandboxClosure({
|
|
12553
12554
|
sandbox: true,
|
|
12554
|
-
call: (args) =>
|
|
12555
|
+
call: (args, context) => stringFromCodes(args, String.fromCharCode, options.budget, context),
|
|
12555
12556
|
name: "fromCharCode"
|
|
12556
12557
|
}),
|
|
12557
12558
|
fromCodePoint: createSandboxClosure({
|
|
12558
12559
|
sandbox: true,
|
|
12559
|
-
call: (args) =>
|
|
12560
|
+
call: (args, context) => stringFromCodes(args, String.fromCodePoint, options.budget, context),
|
|
12560
12561
|
name: "fromCodePoint"
|
|
12561
12562
|
})
|
|
12562
12563
|
}
|
|
@@ -12948,6 +12949,32 @@ function budgetSandboxValue2(value, budget) {
|
|
|
12948
12949
|
const sandboxValue = deepCopyToSandbox(value);
|
|
12949
12950
|
return allocateProducedSandboxValue(sandboxValue, budget);
|
|
12950
12951
|
}
|
|
12952
|
+
function stringFromCodes(args, convert, budget, context) {
|
|
12953
|
+
let result = "";
|
|
12954
|
+
let index = 0;
|
|
12955
|
+
const release = retainValues(budget, () => [...args, result]);
|
|
12956
|
+
try {
|
|
12957
|
+
const output = advance();
|
|
12958
|
+
if (typeof output !== "string") return output.finally(release);
|
|
12959
|
+
release();
|
|
12960
|
+
return output;
|
|
12961
|
+
} catch (error) {
|
|
12962
|
+
release();
|
|
12963
|
+
throw error;
|
|
12964
|
+
}
|
|
12965
|
+
function advance() {
|
|
12966
|
+
while (index < args.length) {
|
|
12967
|
+
budget.visitNode();
|
|
12968
|
+
const number = sandboxNumber(args[index++], budget, context);
|
|
12969
|
+
if (number instanceof Promise) return number.then((value) => {
|
|
12970
|
+
result = budget.allocateString(result + convert(value));
|
|
12971
|
+
return advance();
|
|
12972
|
+
});
|
|
12973
|
+
result = budget.allocateString(result + convert(number));
|
|
12974
|
+
}
|
|
12975
|
+
return result;
|
|
12976
|
+
}
|
|
12977
|
+
}
|
|
12951
12978
|
function stringRaw(args, budget, context) {
|
|
12952
12979
|
const [template, ...substitutions] = args;
|
|
12953
12980
|
if (context?.getProperty !== void 0)
|
|
@@ -21280,6 +21307,7 @@ function serializeDate(value, encode) {
|
|
|
21280
21307
|
|
|
21281
21308
|
// packages/safe-js/src/snapshot/dump-format.ts
|
|
21282
21309
|
var DUMP_FORMAT_VERSION = 2;
|
|
21310
|
+
var inMemoryRunSnapshots = /* @__PURE__ */ new WeakSet();
|
|
21283
21311
|
var EXECUTION_SEMANTICS = "jobs-v8";
|
|
21284
21312
|
var SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
21285
21313
|
function serializeSafeJSSnapshot(snapshot) {
|
|
@@ -21710,10 +21738,11 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
|
21710
21738
|
// packages/safe-js/src/interp/globals/console-json.ts
|
|
21711
21739
|
function createConsoleJsonGlobals(options) {
|
|
21712
21740
|
const sink = options.sink ?? console;
|
|
21713
|
-
|
|
21741
|
+
const globals = {
|
|
21714
21742
|
JSON: {
|
|
21715
21743
|
rawJSON: createSandboxClosure({
|
|
21716
21744
|
sandbox: true,
|
|
21745
|
+
guest: true,
|
|
21717
21746
|
name: "rawJSON",
|
|
21718
21747
|
length: 1,
|
|
21719
21748
|
call: async ([value], context) => {
|
|
@@ -21724,12 +21753,14 @@ function createConsoleJsonGlobals(options) {
|
|
|
21724
21753
|
}),
|
|
21725
21754
|
isRawJSON: createSandboxClosure({
|
|
21726
21755
|
sandbox: true,
|
|
21756
|
+
guest: true,
|
|
21727
21757
|
name: "isRawJSON",
|
|
21728
21758
|
length: 1,
|
|
21729
21759
|
call: ([value]) => isRawJson(value)
|
|
21730
21760
|
}),
|
|
21731
21761
|
parse: createSandboxClosure({
|
|
21732
21762
|
sandbox: true,
|
|
21763
|
+
guest: true,
|
|
21733
21764
|
length: 2,
|
|
21734
21765
|
call: async ([text, reviver], context) => {
|
|
21735
21766
|
const converted = sandboxString(text, options.budget, context);
|
|
@@ -21744,6 +21775,8 @@ function createConsoleJsonGlobals(options) {
|
|
|
21744
21775
|
}),
|
|
21745
21776
|
stringify: createSandboxClosure({
|
|
21746
21777
|
sandbox: true,
|
|
21778
|
+
guest: true,
|
|
21779
|
+
length: 3,
|
|
21747
21780
|
call: async ([value, replacer, indent], context) => stringifyJson(value, replacer, indent, options.budget, context),
|
|
21748
21781
|
name: "stringify"
|
|
21749
21782
|
})
|
|
@@ -21806,6 +21839,9 @@ function createConsoleJsonGlobals(options) {
|
|
|
21806
21839
|
}
|
|
21807
21840
|
)
|
|
21808
21841
|
};
|
|
21842
|
+
registerBuiltinIdentities(options.budget, { JSON: globals.JSON });
|
|
21843
|
+
for (const method of Object.values(globals.JSON)) registerIntrinsicFunction(options.budget, method);
|
|
21844
|
+
return globals;
|
|
21809
21845
|
}
|
|
21810
21846
|
async function stringifyJson(value, replacer, indent, budget, context) {
|
|
21811
21847
|
const allocation = {};
|
|
@@ -26306,7 +26342,13 @@ var SnapshotMismatchError = class extends Error {
|
|
|
26306
26342
|
};
|
|
26307
26343
|
function restore(snapshot, options, owner) {
|
|
26308
26344
|
assertSnapshotInactive(snapshot);
|
|
26309
|
-
|
|
26345
|
+
try {
|
|
26346
|
+
validateDumpEnvelope(snapshot);
|
|
26347
|
+
} catch (error) {
|
|
26348
|
+
if (!(error instanceof SnapshotValidationError) || error.code !== "invalidState" || !inMemoryRunSnapshots.has(snapshot)) throw error;
|
|
26349
|
+
snapshot = JSON.parse(serializeSafeJSSnapshot(snapshot));
|
|
26350
|
+
validateDumpEnvelope(snapshot);
|
|
26351
|
+
}
|
|
26310
26352
|
validateSnapshotMigration(snapshot.migration, snapshot.sourceHash, owner);
|
|
26311
26353
|
if (snapshot.executionSemantics !== EXECUTION_SEMANTICS && snapshot.executionSemantics !== "jobs-v6" && snapshot.executionSemantics !== "jobs-v7" && (snapshot.executionSemantics !== void 0 || snapshot.promiseReplay !== void 0 || snapshot.replay !== void 0 || snapshot.initialInputs !== void 0)) {
|
|
26312
26354
|
throw new SnapshotValidationError(
|
|
@@ -38978,7 +39020,7 @@ function run(source, options = {}) {
|
|
|
38978
39020
|
runResources.getStore().functionSourceText = executionSemantics === EXECUTION_SEMANTICS;
|
|
38979
39021
|
const convertInitialInput = (convert) => executionSemantics === "jobs-v6" ? convert() : promiseReplayContext.exit(convert);
|
|
38980
39022
|
if (restoredSnapshot !== void 0) {
|
|
38981
|
-
leaveSnapshotRun = enterSnapshotRun(restoredSnapshot);
|
|
39023
|
+
leaveSnapshotRun = enterSnapshotRun(options.snapshot ?? restoredSnapshot);
|
|
38982
39024
|
}
|
|
38983
39025
|
promiseReplay.attachBudget(budget);
|
|
38984
39026
|
const filename = options.filename ?? "<input>";
|
|
@@ -39404,7 +39446,7 @@ function createExecutableNode(module) {
|
|
|
39404
39446
|
};
|
|
39405
39447
|
}
|
|
39406
39448
|
function createRunSnapshot(input) {
|
|
39407
|
-
|
|
39449
|
+
const snapshot = {
|
|
39408
39450
|
version: DUMP_FORMAT_VERSION,
|
|
39409
39451
|
executionSemantics: input.executionSemantics,
|
|
39410
39452
|
sourceHash: input.sourceHash,
|
|
@@ -39424,6 +39466,8 @@ function createRunSnapshot(input) {
|
|
|
39424
39466
|
state: input.random.generator.snapshot()
|
|
39425
39467
|
}
|
|
39426
39468
|
};
|
|
39469
|
+
inMemoryRunSnapshots.add(snapshot);
|
|
39470
|
+
return snapshot;
|
|
39427
39471
|
}
|
|
39428
39472
|
function readHostCallSnapshot(snapshot) {
|
|
39429
39473
|
if (snapshot === void 0 || !Array.isArray(snapshot.hostCalls)) {
|
|
@@ -39521,4 +39565,4 @@ export {
|
|
|
39521
39565
|
FileSnapshotBackend,
|
|
39522
39566
|
run
|
|
39523
39567
|
};
|
|
39524
|
-
//# sourceMappingURL=chunk-
|
|
39568
|
+
//# sourceMappingURL=chunk-IKHGVNT5.js.map
|