@poe-platform/safe-js 0.1.802 → 0.1.804
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 +4 -4
- package/dist/safe-js/bundled-yaml/LICENSE +13 -0
- package/dist/safe-js/bundled-yaml/index.js +6601 -0
- package/dist/safe-js/chunks/{chunk-HFRBLE6Y.js → chunk-36PBWSDR.js} +23 -11
- package/dist/safe-js/chunks/{chunk-CK3YK2EC.js → chunk-6AO2T2VZ.js} +1 -1
- package/dist/safe-js/chunks/{chunk-5RLD4TVI.js → chunk-BKNQTNHP.js} +36 -23
- package/dist/safe-js/chunks/{chunk-YCFOANSU.js → chunk-BYDDUKS3.js} +3 -3
- package/dist/safe-js/chunks/{chunk-6H5VC5W5.js → chunk-CKOGIOB3.js} +470 -464
- package/dist/safe-js/chunks/{chunk-XOMGWE37.js → chunk-CVPZFRCC.js} +3 -3
- package/dist/safe-js/chunks/{chunk-4KMUWNZD.js → chunk-ECMGBHAB.js} +13 -137
- package/dist/safe-js/chunks/{chunk-A3LXCGMJ.js → chunk-EQUBWQJN.js} +57 -34
- package/dist/safe-js/chunks/{chunk-QRWRR6IA.js → chunk-JMDWLOJV.js} +26 -3
- package/dist/safe-js/chunks/{chunk-3NFTBEZR.js → chunk-JQ5QJV5Q.js} +2 -2
- package/dist/safe-js/chunks/{chunk-MMN3IESA.js → chunk-KMBCLXER.js} +1 -1
- package/dist/safe-js/chunks/{chunk-PMOXSLM5.js → chunk-MJH73KJI.js} +2 -2
- package/dist/safe-js/chunks/{chunk-IB6WAQAE.js → chunk-P66QKVQC.js} +3 -3
- package/dist/safe-js/chunks/{chunk-HPHCQNFV.js → chunk-RPGCF4KE.js} +130 -3
- package/dist/safe-js/chunks/{chunk-F6Y734YA.js → chunk-SIR35W6T.js} +5 -5
- package/dist/safe-js/chunks/{chunk-7THYP46K.js → chunk-SMGNJNDU.js} +1 -1
- package/dist/safe-js/chunks/{chunk-XV5OYKND.js → chunk-VLRTLEDI.js} +2 -2
- package/dist/safe-js/chunks/{chunk-JCHJGIQA.js → chunk-VVOPJZRG.js} +2 -0
- package/dist/safe-js/chunks/{cli-runtime-L4IABN2W.js → cli-runtime-A353G7DR.js} +15 -15
- package/dist/safe-js/chunks/{dump-KUPBSXSL.js → dump-KQZFULX2.js} +4 -4
- package/dist/safe-js/chunks/harness-XT6K6X67.js +10 -0
- package/dist/safe-js/chunks/mcp-VWE444VD.js +11 -0
- package/dist/safe-js/chunks/migration-file-NSKXOMAO.js +14 -0
- package/dist/safe-js/chunks/restore-SHPORPY4.js +13 -0
- package/dist/safe-js/chunks/run-FQOSICOT.js +19 -0
- package/dist/safe-js/chunks/{runtime-modules-MGSXY4BN.js → runtime-modules-DBRXXRND.js} +4 -4
- package/dist/safe-js/chunks/{source-files-BSDM22Y2.js → source-files-A2WSOO6G.js} +3 -3
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.d.ts +19 -0
- package/dist/safe-js/core.js +39 -15
- package/dist/safe-js/error/format.d.ts +3 -0
- package/dist/safe-js/index.d.ts +1 -12
- package/dist/safe-js/index.js +30 -39
- package/dist/safe-js/interp/host-call.d.ts +1 -0
- package/dist/safe-js/interp/interpreter.d.ts +1 -3
- package/dist/safe-js/modules/fs.js +5 -5
- package/dist/safe-js/platform/node.d.ts +1 -0
- package/dist/safe-js/platform/node.js +1 -0
- package/dist/safe-js/platform/workerd.d.ts +1 -0
- package/dist/safe-js/platform/workerd.js +2 -0
- package/dist/safe-js/portable/chunks/{chunk-XCTU25SU.js → chunk-NLGXLZCK.js} +1 -1
- package/dist/safe-js/portable/chunks/{chunk-2FNMGWDK.js → chunk-SRMMDXD3.js} +127 -91
- package/dist/safe-js/portable/chunks/{chunk-H5X3T5VP.js → chunk-W6MZOTYR.js} +2 -0
- package/dist/safe-js/portable/chunks/{source-files-CVU252FB.js → source-files-AEDWESAJ.js} +2 -2
- package/dist/safe-js/portable/core.js +467 -249
- package/dist/safe-js/portable/modules/fs.js +2 -2
- package/dist/safe-js/workerd.js +57987 -57738
- package/package.json +6 -5
- package/dist/safe-js/chunks/harness-3DDUS3RY.js +0 -10
- package/dist/safe-js/chunks/mcp-5TMFK3UE.js +0 -11
- package/dist/safe-js/chunks/migration-file-4CYSJ6LO.js +0 -14
- package/dist/safe-js/chunks/restore-GDHBT5ZD.js +0 -13
- package/dist/safe-js/chunks/run-M6N5KCPF.js +0 -19
- package/dist/safe-js/node-unavailable.d.ts +0 -1
|
@@ -7,15 +7,15 @@ import {
|
|
|
7
7
|
} from "./chunk-ONWFPHUI.js";
|
|
8
8
|
import {
|
|
9
9
|
restore
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CVPZFRCC.js";
|
|
11
11
|
import {
|
|
12
12
|
hashParsedAst,
|
|
13
13
|
hashSource
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MJH73KJI.js";
|
|
15
15
|
import {
|
|
16
16
|
attachDumpController,
|
|
17
17
|
createDumpController
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VLRTLEDI.js";
|
|
19
19
|
import {
|
|
20
20
|
DUMP_FORMAT_VERSION,
|
|
21
21
|
EXECUTION_SEMANTICS,
|
|
@@ -107,7 +107,7 @@ import {
|
|
|
107
107
|
wrapCallerInjectedBindings,
|
|
108
108
|
wrapCancelableBindings,
|
|
109
109
|
wrapHostConstructor
|
|
110
|
-
} from "./chunk-
|
|
110
|
+
} from "./chunk-BKNQTNHP.js";
|
|
111
111
|
import {
|
|
112
112
|
Budget,
|
|
113
113
|
CompileScope,
|
|
@@ -122,16 +122,16 @@ import {
|
|
|
122
122
|
parseSourceModule,
|
|
123
123
|
replaceErrorStack,
|
|
124
124
|
safeAddEvent
|
|
125
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-EQUBWQJN.js";
|
|
126
126
|
import {
|
|
127
127
|
dirname
|
|
128
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-KMBCLXER.js";
|
|
129
129
|
import {
|
|
130
130
|
AsyncLocalStorage,
|
|
131
131
|
createHostCallbackContext,
|
|
132
132
|
hostFs,
|
|
133
133
|
types
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-VVOPJZRG.js";
|
|
135
135
|
|
|
136
136
|
// packages/safe-js/src/modules/source-graph.ts
|
|
137
137
|
var ambiguous = /* @__PURE__ */ Symbol("ambiguous module export");
|
|
@@ -2102,7 +2102,7 @@ var UnsnapshotableValueError = class extends Error {
|
|
|
2102
2102
|
};
|
|
2103
2103
|
|
|
2104
2104
|
// packages/safe-js/src/snapshot/replay-inputs.ts
|
|
2105
|
-
function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestored, compilation, onInputSymbols) {
|
|
2105
|
+
function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestored, compilation, onInputSymbols, restoredPromiseOrder = []) {
|
|
2106
2106
|
const identities = /* @__PURE__ */ new WeakMap();
|
|
2107
2107
|
const capabilities = /* @__PURE__ */ new Map();
|
|
2108
2108
|
const promises = /* @__PURE__ */ new Map();
|
|
@@ -2197,6 +2197,8 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2197
2197
|
return isSandboxClosure(value) ? value : void 0;
|
|
2198
2198
|
};
|
|
2199
2199
|
const memo = { nodes: context.nodes, values: /* @__PURE__ */ new Map() };
|
|
2200
|
+
const restoredRootPromises = /* @__PURE__ */ new Set();
|
|
2201
|
+
const restoredNamespacePromises = /* @__PURE__ */ new Map();
|
|
2200
2202
|
if (saved !== void 0) validateSnapshotData(saved);
|
|
2201
2203
|
const snapshot = saved === void 0 ? encodeReplayData(current, {
|
|
2202
2204
|
context,
|
|
@@ -2214,6 +2216,7 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2214
2216
|
resolveCapability,
|
|
2215
2217
|
resolvePromise: (id) => {
|
|
2216
2218
|
readCapability(id);
|
|
2219
|
+
restoredRootPromises.add(id);
|
|
2217
2220
|
return createSandboxPromise(Promise.resolve(void 0), { trackReplay: false });
|
|
2218
2221
|
}
|
|
2219
2222
|
}, validationScope);
|
|
@@ -2222,7 +2225,8 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2222
2225
|
if (snapshot.namespaceRoots === null || typeof snapshot.namespaceRoots !== "object" || Array.isArray(snapshot.namespaceRoots))
|
|
2223
2226
|
throw new TypeError("Invalid replay namespace roots.");
|
|
2224
2227
|
const validationCapability = createSandboxClosure({ call: () => void 0 });
|
|
2225
|
-
for (const root of Object.
|
|
2228
|
+
for (const [name, root] of Object.entries(snapshot.namespaceRoots)) {
|
|
2229
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2226
2230
|
const namespace = decodeReplayData({ root, nodes: snapshot.nodes }, {
|
|
2227
2231
|
resolveCapability: (id) => {
|
|
2228
2232
|
readCapability(id);
|
|
@@ -2230,10 +2234,12 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2230
2234
|
},
|
|
2231
2235
|
resolvePromise: (id) => {
|
|
2232
2236
|
readCapability(id);
|
|
2237
|
+
ids.add(id);
|
|
2233
2238
|
return createSandboxPromise(Promise.resolve(void 0), { trackReplay: false });
|
|
2234
2239
|
}
|
|
2235
2240
|
}, validationScope);
|
|
2236
2241
|
if (!isSandboxModuleNamespace(namespace)) throw new TypeError("Invalid replay module namespace.");
|
|
2242
|
+
restoredNamespacePromises.set(name, ids);
|
|
2237
2243
|
}
|
|
2238
2244
|
}
|
|
2239
2245
|
} finally {
|
|
@@ -2256,6 +2262,7 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2256
2262
|
promises.set(id, preparePromise(isSandboxPromise(value) ? value : void 0, id));
|
|
2257
2263
|
return promises.get(id);
|
|
2258
2264
|
};
|
|
2265
|
+
for (const id of restoredPromiseOrder) if (restoredRootPromises.has(id)) resolvePromise(id);
|
|
2259
2266
|
if (inputPromises.size > 0) {
|
|
2260
2267
|
memo.values.clear();
|
|
2261
2268
|
for (const [id, symbol] of inputSymbols) memo.values.set(id, symbol);
|
|
@@ -2286,6 +2293,10 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
2286
2293
|
captureNamespace,
|
|
2287
2294
|
prepareNamespace: (namespace, name) => {
|
|
2288
2295
|
captureNamespace(namespace, name);
|
|
2296
|
+
const ids = restoredNamespacePromises.get(name);
|
|
2297
|
+
if (ids !== void 0) {
|
|
2298
|
+
for (const id of restoredPromiseOrder) if (ids.has(id)) resolvePromise(id);
|
|
2299
|
+
}
|
|
2289
2300
|
return decodeReplayData(
|
|
2290
2301
|
{ root: snapshot.namespaceRoots[name], nodes: snapshot.nodes },
|
|
2291
2302
|
{ memo, resolveCapability, resolvePromise, onCapabilityRestored },
|
|
@@ -2328,7 +2339,7 @@ function run(source, options = {}) {
|
|
|
2328
2339
|
throw new TypeError("Source resolution requires sourceType: 'module'.");
|
|
2329
2340
|
if (options.sourceRoot !== void 0) {
|
|
2330
2341
|
if (options.sourceResolver !== void 0) throw new TypeError("Specify sourceRoot or sourceResolver, not both.");
|
|
2331
|
-
const { createRootedSourceResolver } = await import("./source-files-
|
|
2342
|
+
const { createRootedSourceResolver } = await import("./source-files-A2WSOO6G.js");
|
|
2332
2343
|
const { sourceRoot, ...resolved } = options;
|
|
2333
2344
|
const sourceResolver = await createRootedSourceResolver(sourceRoot);
|
|
2334
2345
|
return runWithExtensions(source, { ...resolved, filename: await sourceResolver.entryId(options.filename), sourceResolver }, jobs);
|
|
@@ -2492,7 +2503,8 @@ function run(source, options = {}) {
|
|
|
2492
2503
|
prepareInputPromise,
|
|
2493
2504
|
hostCalls.rebindHostCapability.bind(hostCalls),
|
|
2494
2505
|
compilation,
|
|
2495
|
-
hostCalls.registerInputSymbols.bind(hostCalls)
|
|
2506
|
+
hostCalls.registerInputSymbols.bind(hostCalls),
|
|
2507
|
+
hostCalls.inputPromiseOrder()
|
|
2496
2508
|
);
|
|
2497
2509
|
leaveInputReplay = () => {
|
|
2498
2510
|
budget.setRetainedDataUsage(initialInputs, 0);
|
|
@@ -41,13 +41,13 @@ import {
|
|
|
41
41
|
sandboxErrorTypes,
|
|
42
42
|
syntaxDiagnostics,
|
|
43
43
|
templateRealms
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-EQUBWQJN.js";
|
|
45
45
|
import {
|
|
46
46
|
AsyncLocalStorage,
|
|
47
47
|
cloneSharedBufferWrapper,
|
|
48
48
|
setImmediate,
|
|
49
49
|
types
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-VVOPJZRG.js";
|
|
51
51
|
|
|
52
52
|
// packages/safe-js/src/interp/native-promise-properties.ts
|
|
53
53
|
var admittedSymbols = /* @__PURE__ */ new WeakMap();
|
|
@@ -8173,7 +8173,9 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
8173
8173
|
}
|
|
8174
8174
|
});
|
|
8175
8175
|
const value = "hasValue" in result && result.hasValue ? result.value : void 0;
|
|
8176
|
-
|
|
8176
|
+
if (context.budget.limits.dataSize !== void 0 || compilation.tickets.size > 0) {
|
|
8177
|
+
reconcileCompiledValues(context.budget, [...scope.retainedDataRoots(), value], compilation, parent, [value]);
|
|
8178
|
+
}
|
|
8177
8179
|
if (result.kind === "error") throw result.error;
|
|
8178
8180
|
if (result.kind === "throw") throw result.value;
|
|
8179
8181
|
return value;
|
|
@@ -8422,13 +8424,15 @@ async function executeClosure(node, args, thisValue, context, evaluateNode2) {
|
|
|
8422
8424
|
scope
|
|
8423
8425
|
});
|
|
8424
8426
|
const value = "hasValue" in result && result.hasValue ? result.value : void 0;
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8427
|
+
if (context.budget.limits.dataSize !== void 0 || compilation.tickets.size > 0) {
|
|
8428
|
+
reconcileCompiledValues(
|
|
8429
|
+
context.budget,
|
|
8430
|
+
[...scope.retainedDataRoots(), value],
|
|
8431
|
+
compilation,
|
|
8432
|
+
parent,
|
|
8433
|
+
[value]
|
|
8434
|
+
);
|
|
8435
|
+
}
|
|
8432
8436
|
if (result.kind === "error") {
|
|
8433
8437
|
throw result.error;
|
|
8434
8438
|
}
|
|
@@ -25665,7 +25669,6 @@ async function evaluateNode(node, context, onReference) {
|
|
|
25665
25669
|
const evaluationContext = compilation === void 0 ? context : {
|
|
25666
25670
|
...context,
|
|
25667
25671
|
compilation,
|
|
25668
|
-
deferDataScans: context.deferDataScans || node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement",
|
|
25669
25672
|
get generatorResume() {
|
|
25670
25673
|
return context.generatorResume;
|
|
25671
25674
|
},
|
|
@@ -25675,16 +25678,17 @@ async function evaluateNode(node, context, onReference) {
|
|
|
25675
25678
|
};
|
|
25676
25679
|
try {
|
|
25677
25680
|
const result = node.type === "Identifier" && onReference !== void 0 ? await evaluateIdentifier(node, evaluationContext, onReference) : await handler(node, evaluationContext);
|
|
25678
|
-
|
|
25679
|
-
|
|
25680
|
-
|
|
25681
|
-
|
|
25682
|
-
|
|
25683
|
-
|
|
25684
|
-
|
|
25685
|
-
|
|
25686
|
-
|
|
25687
|
-
|
|
25681
|
+
const transient = "hasValue" in result && result.hasValue ? result.value : void 0;
|
|
25682
|
+
reconcileDataBudget(
|
|
25683
|
+
context.budget,
|
|
25684
|
+
context.stats,
|
|
25685
|
+
context.scope,
|
|
25686
|
+
transient,
|
|
25687
|
+
compilation,
|
|
25688
|
+
context.compilation,
|
|
25689
|
+
true,
|
|
25690
|
+
handler === evaluatePrimitiveLiteral ? typeof transient === "string" ? transient.length : 8 : void 0
|
|
25691
|
+
);
|
|
25688
25692
|
if (result.kind === "break" && result.label !== void 0 && "labels" in node && node.labels?.includes(result.label))
|
|
25689
25693
|
return { kind: "normal", hasValue: context.evalCompletion === true && result.hasValue, value: context.evalCompletion ? result.value : void 0 };
|
|
25690
25694
|
return result;
|
|
@@ -25709,14 +25713,20 @@ async function evaluateNode(node, context, onReference) {
|
|
|
25709
25713
|
context.scope,
|
|
25710
25714
|
completion.value,
|
|
25711
25715
|
compilation,
|
|
25712
|
-
context.compilation
|
|
25716
|
+
context.compilation,
|
|
25717
|
+
true
|
|
25713
25718
|
);
|
|
25714
25719
|
return completion;
|
|
25715
25720
|
} finally {
|
|
25716
25721
|
compilation?.dispose();
|
|
25717
25722
|
}
|
|
25718
25723
|
}
|
|
25719
|
-
function reconcileDataBudget(budget, stats, scope, transient, compilation, parent) {
|
|
25724
|
+
function reconcileDataBudget(budget, stats, scope, transient, compilation, parent, nodeCheckpoint = false, growth) {
|
|
25725
|
+
if (nodeCheckpoint && (compilation?.tickets.size ?? 0) === 0) {
|
|
25726
|
+
const limit = budget.limits.dataSize;
|
|
25727
|
+
if (limit === void 0 || limit === Infinity) return;
|
|
25728
|
+
if (growth !== void 0 && budget.currentDataSize + growth <= limit) return;
|
|
25729
|
+
}
|
|
25720
25730
|
reconcileCompiledValues(
|
|
25721
25731
|
budget,
|
|
25722
25732
|
[...scope.retainedDataRoots(), transient],
|
|
@@ -45183,6 +45193,9 @@ var HostCallJournal = class {
|
|
|
45183
45193
|
...outcome === void 0 ? {} : { outcome: copyOutcome(outcome) }
|
|
45184
45194
|
}));
|
|
45185
45195
|
}
|
|
45196
|
+
inputPromiseOrder() {
|
|
45197
|
+
return this.records.filter((record4) => record4.moduleId === "<inputs>").map((record4) => record4.operation);
|
|
45198
|
+
}
|
|
45186
45199
|
dispose() {
|
|
45187
45200
|
this.disposed = true;
|
|
45188
45201
|
for (const cancel of this.pendingReconciliations) cancel();
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
declareBudgetedHostOperation,
|
|
9
9
|
declareHostOperation
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BKNQTNHP.js";
|
|
11
11
|
import {
|
|
12
12
|
basename,
|
|
13
13
|
dirname,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
relative,
|
|
16
16
|
resolve,
|
|
17
17
|
sep
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KMBCLXER.js";
|
|
19
19
|
import {
|
|
20
20
|
accessDeniedSystemError,
|
|
21
21
|
constants,
|
|
22
22
|
hostFs,
|
|
23
23
|
hostPlatform,
|
|
24
24
|
inspect
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-VVOPJZRG.js";
|
|
26
26
|
|
|
27
27
|
// packages/safe-js/src/modules/fs.ts
|
|
28
28
|
import { createFsBridge } from "@poe-platform/safe-fs/core";
|