@poe-platform/safe-js 0.1.276 → 0.1.278
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-5MDRQKN6.js → chunk-6GA7LIXS.js} +47 -33
- package/dist/safe-js/chunks/chunk-6GA7LIXS.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-P44IU3A7.js → chunk-CNTJVUS5.js} +2 -2
- 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/interp/async.d.ts +2 -2
- package/dist/safe-js/interp/interpreter.d.ts +1 -0
- package/dist/safe-js/interp/iteration.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-5MDRQKN6.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-P44IU3A7.js.map → chunk-CNTJVUS5.js.map} +0 -0
|
@@ -11241,7 +11241,7 @@ function mapIteratorSnapshot(snapshot, map) {
|
|
|
11241
11241
|
async function restoreSandboxIterator(snapshot, budget, context, signal) {
|
|
11242
11242
|
if (snapshot.kind === "unsupported") throw new TypeError("Host-owned iterator cannot be restored.");
|
|
11243
11243
|
if (snapshot.kind === "guest") return guestIterator(snapshot.value, snapshot.next, snapshot.async, budget, context, signal);
|
|
11244
|
-
if (snapshot.kind === "async-from-sync") return asyncFromSyncIterator(await restoreSandboxIterator(snapshot.inner, budget, context, signal), budget, signal);
|
|
11244
|
+
if (snapshot.kind === "async-from-sync") return asyncFromSyncIterator(await restoreSandboxIterator(snapshot.inner, budget, context, signal), budget, signal, context);
|
|
11245
11245
|
if (Array.isArray(snapshot.value)) return arrayIterator(snapshot.value, context, budget, snapshot.index);
|
|
11246
11246
|
const iterator = isSandboxGenerator(snapshot.value) && snapshot.value.async ? getSandboxAsyncIterator(snapshot.value, budget, context, signal) : getSandboxIterator(snapshot.value, budget, context);
|
|
11247
11247
|
if (iterator === void 0) throw new TypeError("Invalid builtin iterator snapshot.");
|
|
@@ -11257,7 +11257,7 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
11257
11257
|
if (isSandboxGenerator(value) && value.async)
|
|
11258
11258
|
return getSandboxAsyncIterator(value, budget, context, signal);
|
|
11259
11259
|
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
11260
|
-
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal);
|
|
11260
|
+
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
11261
11261
|
}
|
|
11262
11262
|
const factory = await context.getProperty(value, key);
|
|
11263
11263
|
if (!asyncProtocol && (isSandboxMap(value) || isSandboxSet(value)) && typeof factory === "object" && factory !== null && getIntrinsicIdentity(factory) === JSON.stringify(isSandboxMap(value) ? ["Map", "prototype", "entries"] : ["Set", "prototype", "values"])) {
|
|
@@ -11266,7 +11266,7 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
11266
11266
|
if (factory === null || factory === void 0) {
|
|
11267
11267
|
if (!asyncProtocol) return void 0;
|
|
11268
11268
|
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
11269
|
-
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal);
|
|
11269
|
+
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
11270
11270
|
}
|
|
11271
11271
|
if (!isSandboxClosure(factory)) {
|
|
11272
11272
|
if (typeof factory !== "function") throw new TypeError("Iterator method must be callable.");
|
|
@@ -11286,7 +11286,7 @@ function guestIterator(iterator, next, asyncProtocol, budget, context, signal) {
|
|
|
11286
11286
|
const invoke = async (operation, args) => {
|
|
11287
11287
|
if (!isSandboxClosure(operation)) throw new TypeError("Iterator operation must be callable.");
|
|
11288
11288
|
const returned = await invokeBuiltinClosure(operation, args, budget, context, iterator);
|
|
11289
|
-
const result = asyncProtocol ? await awaitSandboxValue(returned, signal, budget) : returned;
|
|
11289
|
+
const result = asyncProtocol ? await awaitSandboxValue(returned, signal, budget, context) : returned;
|
|
11290
11290
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
11291
11291
|
throw new TypeError("Iterator result must be an object.");
|
|
11292
11292
|
return result;
|
|
@@ -11311,7 +11311,7 @@ async function readIteratorResult(iterator, result, property) {
|
|
|
11311
11311
|
}
|
|
11312
11312
|
function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
11313
11313
|
if (isSandboxGenerator(value) && value.async) {
|
|
11314
|
-
return { ...generatorIterator(value, budget), asyncProtocol: true };
|
|
11314
|
+
return { ...generatorIterator(value, budget, context), asyncProtocol: true };
|
|
11315
11315
|
}
|
|
11316
11316
|
if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
|
|
11317
11317
|
const method = value[Symbol.asyncIterator];
|
|
@@ -11320,7 +11320,7 @@ function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
|
11320
11320
|
}
|
|
11321
11321
|
}
|
|
11322
11322
|
const iterator = getSandboxIterator(value, budget, context);
|
|
11323
|
-
return iterator === void 0 ? void 0 : asyncFromSyncIterator(iterator, budget, signal);
|
|
11323
|
+
return iterator === void 0 ? void 0 : asyncFromSyncIterator(iterator, budget, signal, context);
|
|
11324
11324
|
}
|
|
11325
11325
|
function nativeAsyncIterator(value, method, signal) {
|
|
11326
11326
|
if (typeof method !== "function") throw new TypeError("Async iterator method must be callable.");
|
|
@@ -11362,7 +11362,7 @@ function nativeAsyncIterator(value, method, signal) {
|
|
|
11362
11362
|
}
|
|
11363
11363
|
};
|
|
11364
11364
|
}
|
|
11365
|
-
function asyncFromSyncIterator(iterator, budget, signal) {
|
|
11365
|
+
function asyncFromSyncIterator(iterator, budget, signal, context) {
|
|
11366
11366
|
const invoke = async (method, args) => {
|
|
11367
11367
|
const operation = iterator.getOperation === void 0 ? iterator[method] : await iterator.getOperation(method);
|
|
11368
11368
|
if (operation === void 0) {
|
|
@@ -11380,7 +11380,7 @@ function asyncFromSyncIterator(iterator, budget, signal) {
|
|
|
11380
11380
|
const done = Boolean((await readIteratorResult(iterator, result, "done")).value);
|
|
11381
11381
|
const resultValue = (await readIteratorResult(iterator, result, "value")).value;
|
|
11382
11382
|
try {
|
|
11383
|
-
return { done, value: await awaitSandboxValue(resultValue, signal, budget) };
|
|
11383
|
+
return { done, value: await awaitSandboxValue(resultValue, signal, budget, context) };
|
|
11384
11384
|
} catch (error) {
|
|
11385
11385
|
if (isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
11386
11386
|
if (!done && method !== "return") await closeIterator(iterator, true);
|
|
@@ -11538,7 +11538,7 @@ function collectionIterator(collection, value) {
|
|
|
11538
11538
|
return adapter;
|
|
11539
11539
|
}
|
|
11540
11540
|
var asyncGeneratorRequests = /* @__PURE__ */ new WeakMap();
|
|
11541
|
-
function generatorIterator(generator, budget) {
|
|
11541
|
+
function generatorIterator(generator, budget, context) {
|
|
11542
11542
|
const invoke = async (method, value) => {
|
|
11543
11543
|
const leaveRunning = enterRunningState(generator);
|
|
11544
11544
|
const initialState = generator.state;
|
|
@@ -11546,7 +11546,7 @@ function generatorIterator(generator, budget) {
|
|
|
11546
11546
|
try {
|
|
11547
11547
|
if (generator.async && method === "return" && (initialState === "start" || initialState === "done")) {
|
|
11548
11548
|
if (initialState === "start") await generator.channel.return();
|
|
11549
|
-
value = await awaitSandboxValue(value, void 0, budget);
|
|
11549
|
+
value = await awaitSandboxValue(value, void 0, budget, context);
|
|
11550
11550
|
}
|
|
11551
11551
|
const result = await generator.channel[method](value);
|
|
11552
11552
|
generator.state = result.done ? "done" : "suspended";
|
|
@@ -12201,6 +12201,13 @@ function budgetSandboxValue(value, budget) {
|
|
|
12201
12201
|
allocateSandboxValue(value, budget, /* @__PURE__ */ new WeakSet());
|
|
12202
12202
|
return value;
|
|
12203
12203
|
}
|
|
12204
|
+
function prepareAwaitedPromise(value, budget, context) {
|
|
12205
|
+
if (!intrinsicPromiseConstructors.has(budget)) createPromiseGlobals({ budget });
|
|
12206
|
+
const constructor = intrinsicPromiseConstructors.get(budget);
|
|
12207
|
+
const actualConstructor = readPromiseProperty(value, "constructor", getPromisePrototype(budget), budget, context);
|
|
12208
|
+
const finish = (actual) => actual === constructor ? value : createSandboxPromise(resolveSandboxValue(value, { budget, context }), { trackReplay: false });
|
|
12209
|
+
return actualConstructor instanceof Promise ? actualConstructor.then(finish) : finish(actualConstructor);
|
|
12210
|
+
}
|
|
12204
12211
|
function resolveSandboxValue(value, options = {}) {
|
|
12205
12212
|
try {
|
|
12206
12213
|
return resolveSandboxValueNow(value, options);
|
|
@@ -12617,17 +12624,19 @@ function registerCancelablePromises(value, signal) {
|
|
|
12617
12624
|
}
|
|
12618
12625
|
}
|
|
12619
12626
|
}
|
|
12620
|
-
function awaitSandboxValue(value, signal, budget) {
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
|
|
12627
|
+
function awaitSandboxValue(value, signal, budget, context) {
|
|
12628
|
+
if (!isSandboxPromise(value)) {
|
|
12629
|
+
return interruptOnFatalPromiseRejection(awaitWithSignal(resolveSandboxValue(value, { budget, context }), signal));
|
|
12630
|
+
}
|
|
12631
|
+
const observe = (value2) => {
|
|
12632
|
+
observeSandboxPromise(value2);
|
|
12633
|
+
const outcome = signal === void 0 ? value2.promise : cancelableOutcomes.get(value2)?.get(signal) ?? value2.promise;
|
|
12634
|
+
const resolved = new Promise((resolve, reject) => {
|
|
12626
12635
|
const detach = onFatalPromiseRejection(reject);
|
|
12627
12636
|
const complete = (state, result) => {
|
|
12628
12637
|
detach?.();
|
|
12629
12638
|
try {
|
|
12630
|
-
consumeSettledHostCall(
|
|
12639
|
+
consumeSettledHostCall(value2);
|
|
12631
12640
|
if (state === "fulfilled") resolve(result);
|
|
12632
12641
|
else reject(result);
|
|
12633
12642
|
} catch (error) {
|
|
@@ -12639,11 +12648,15 @@ function awaitSandboxValue(value, signal, budget) {
|
|
|
12639
12648
|
(reason) => complete("rejected", reason)
|
|
12640
12649
|
);
|
|
12641
12650
|
});
|
|
12642
|
-
|
|
12643
|
-
|
|
12651
|
+
return value2.synchronousPrefix !== void 0 || signal !== void 0 && cancelableOutcomes.get(value2)?.has(signal) ? resolved : awaitWithSignal(resolved, signal);
|
|
12652
|
+
};
|
|
12653
|
+
try {
|
|
12654
|
+
assertPromiseExecutionAllowed();
|
|
12655
|
+
const prepared = budget === void 0 ? value : prepareAwaitedPromise(value, budget, context);
|
|
12656
|
+
return prepared instanceof Promise ? interruptOnFatalPromiseRejection(awaitWithSignal(prepared.then(observe), signal)) : observe(prepared);
|
|
12657
|
+
} catch (error) {
|
|
12658
|
+
return Promise.reject(error);
|
|
12644
12659
|
}
|
|
12645
|
-
const pending = isSandboxPromise(value) && (value.synchronousPrefix !== void 0 || signal !== void 0 && cancelableOutcomes.get(value)?.has(signal)) ? resolved : awaitWithSignal(resolved, signal);
|
|
12646
|
-
return isSandboxPromise(value) ? pending : interruptOnFatalPromiseRejection(pending);
|
|
12647
12660
|
}
|
|
12648
12661
|
function awaitWithSignal(promise, signal) {
|
|
12649
12662
|
if (signal === void 0) return Promise.resolve(promise);
|
|
@@ -15879,8 +15892,8 @@ function getGeneratorMember(target, property, budget) {
|
|
|
15879
15892
|
return createSandboxClosure({
|
|
15880
15893
|
sandbox: true,
|
|
15881
15894
|
name: property,
|
|
15882
|
-
call: ([value]) => {
|
|
15883
|
-
const iterator = generatorIterator(target, budget);
|
|
15895
|
+
call: ([value], context) => {
|
|
15896
|
+
const iterator = generatorIterator(target, budget, context);
|
|
15884
15897
|
const result = Promise.resolve(iterator[property](value)).then((result2) => allocateProducedSandboxValue(
|
|
15885
15898
|
{ value: result2.value, done: result2.done === true },
|
|
15886
15899
|
budget
|
|
@@ -17891,7 +17904,7 @@ async function evaluateReturnStatement(node, context) {
|
|
|
17891
17904
|
return {
|
|
17892
17905
|
kind: "return",
|
|
17893
17906
|
hasValue: argument.hasValue,
|
|
17894
|
-
value: context.asyncGenerator ? await suspendJob(awaitSandboxValue(argument.value, context.signal, context.budget)) : argument.value
|
|
17907
|
+
value: context.asyncGenerator ? await suspendJob(awaitSandboxValue(argument.value, context.signal, context.budget, createCoercionContext(context))) : argument.value
|
|
17895
17908
|
};
|
|
17896
17909
|
}
|
|
17897
17910
|
async function evaluateYieldExpression(node, context) {
|
|
@@ -17915,7 +17928,7 @@ async function evaluateYieldExpression(node, context) {
|
|
|
17915
17928
|
return generatorCompletionResult(completion);
|
|
17916
17929
|
}
|
|
17917
17930
|
async function yieldGeneratorValue(value, node, context) {
|
|
17918
|
-
if (context.asyncGenerator && !node.delegate) value = await suspendJob(awaitSandboxValue(value, context.signal, context.budget));
|
|
17931
|
+
if (context.asyncGenerator && !node.delegate) value = await suspendJob(awaitSandboxValue(value, context.signal, context.budget, createCoercionContext(context)));
|
|
17919
17932
|
context.captureGeneratorScope?.(context.scope, context.generatorBlockScopes, context.finallyCompletions, context.generatorExpressionStates);
|
|
17920
17933
|
const completionPromise = context.generatorYield(allocateProducedSandboxValue(value, context.budget), node.nodeId);
|
|
17921
17934
|
emitResumeBreakpoint(context, {
|
|
@@ -17926,7 +17939,7 @@ async function yieldGeneratorValue(value, node, context) {
|
|
|
17926
17939
|
const completion = await (context.asyncGenerator ? suspendJob(completionPromise) : completionPromise);
|
|
17927
17940
|
if (context.asyncGenerator && completion.type === "return") {
|
|
17928
17941
|
try {
|
|
17929
|
-
return { type: "return", value: await suspendJob(awaitSandboxValue(completion.value, context.signal, context.budget)) };
|
|
17942
|
+
return { type: "return", value: await suspendJob(awaitSandboxValue(completion.value, context.signal, context.budget, createCoercionContext(context))) };
|
|
17930
17943
|
} catch (error) {
|
|
17931
17944
|
return { type: "throw", value: error };
|
|
17932
17945
|
}
|
|
@@ -18807,7 +18820,7 @@ function createCoercionContext(context) {
|
|
|
18807
18820
|
compilation: context.compilation,
|
|
18808
18821
|
getProperty: (value, property) => getPropertyValue(value, property, context),
|
|
18809
18822
|
reconcileData: (value) => reconcileDataBudget(context.budget, context.stats, context.scope, value, context.compilation, context.compilation?.parent),
|
|
18810
|
-
invokeClosure: (closure, args, thisValue, construct) => invokeSandboxClosure(closure, args, context, context.callStack, void 0, thisValue, construct)
|
|
18823
|
+
invokeClosure: (closure, args, thisValue, construct, newTarget) => invokeSandboxClosure(closure, args, context, context.callStack, void 0, thisValue, construct, newTarget)
|
|
18811
18824
|
};
|
|
18812
18825
|
}
|
|
18813
18826
|
function hasSandboxProperty(value, key, context) {
|
|
@@ -20860,14 +20873,15 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject) {
|
|
|
20860
20873
|
evaluateNode2
|
|
20861
20874
|
),
|
|
20862
20875
|
context.budget,
|
|
20863
|
-
context.signal
|
|
20876
|
+
context.signal,
|
|
20877
|
+
callContext
|
|
20864
20878
|
);
|
|
20865
20879
|
}
|
|
20866
20880
|
});
|
|
20867
20881
|
registerClosureOrigin(closure, node, context);
|
|
20868
20882
|
return closure;
|
|
20869
20883
|
}
|
|
20870
|
-
function executeAsyncFunction(execute, budget, signal) {
|
|
20884
|
+
function executeAsyncFunction(execute, budget, signal, callContext) {
|
|
20871
20885
|
let completePrefix;
|
|
20872
20886
|
const synchronousPrefix = new Promise((resolve) => {
|
|
20873
20887
|
completePrefix = resolve;
|
|
@@ -20878,7 +20892,7 @@ function executeAsyncFunction(execute, budget, signal) {
|
|
|
20878
20892
|
const value = await execute(completePrefix);
|
|
20879
20893
|
resolve(
|
|
20880
20894
|
requiresPromiseResolution(value, budget) ? awaitSandboxValue(
|
|
20881
|
-
createSandboxPromise(resolveSandboxValue(value, { budget }), {
|
|
20895
|
+
createSandboxPromise(resolveSandboxValue(value, { budget, context: callContext }), {
|
|
20882
20896
|
trackReplay: false
|
|
20883
20897
|
}),
|
|
20884
20898
|
signal,
|
|
@@ -20946,7 +20960,7 @@ function createGeneratorClosure(node, context, evaluateNode2) {
|
|
|
20946
20960
|
throw result.value;
|
|
20947
20961
|
}
|
|
20948
20962
|
const value = result.hasValue ? result.value : void 0;
|
|
20949
|
-
return node.async ? awaitSandboxValue(value, context.signal, context.budget) : value;
|
|
20963
|
+
return node.async ? awaitSandboxValue(value, context.signal, context.budget, createCoercionContext(context)) : value;
|
|
20950
20964
|
};
|
|
20951
20965
|
return node.async ? runAsyncPrefix(execute) : execute();
|
|
20952
20966
|
});
|
|
@@ -20980,7 +20994,7 @@ async function evaluateAwaitExpression(node, context, evaluateNode2) {
|
|
|
20980
20994
|
return {
|
|
20981
20995
|
kind: "normal",
|
|
20982
20996
|
hasValue: true,
|
|
20983
|
-
value: await suspendJob(awaitSandboxValue(argument.value, context.signal, context.budget))
|
|
20997
|
+
value: await suspendJob(awaitSandboxValue(argument.value, context.signal, context.budget, createCoercionContext(context)))
|
|
20984
20998
|
};
|
|
20985
20999
|
} finally {
|
|
20986
21000
|
leaveAwait();
|
|
@@ -40248,4 +40262,4 @@ export {
|
|
|
40248
40262
|
FileSnapshotBackend,
|
|
40249
40263
|
run
|
|
40250
40264
|
};
|
|
40251
|
-
//# sourceMappingURL=chunk-
|
|
40265
|
+
//# sourceMappingURL=chunk-6GA7LIXS.js.map
|