@poe-platform/safe-js 0.1.389 → 0.1.390
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-LUBKSEVF.js → chunk-QFWWDD7I.js} +2 -2
- package/dist/safe-js/chunks/{chunk-6Y27XODE.js → chunk-XBIXRS5K.js} +254 -25
- package/dist/safe-js/chunks/chunk-XBIXRS5K.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/interp/iterator-helper.d.ts +12 -0
- package/dist/safe-js/interp/iterator-wrapper.d.ts +6 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +17 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-6Y27XODE.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-LUBKSEVF.js.map → chunk-QFWWDD7I.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XBIXRS5K.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-QFWWDD7I.js.map
|
|
@@ -359,7 +359,7 @@ var Budget = class {
|
|
|
359
359
|
this.retainedDataSize -= usage;
|
|
360
360
|
this.currentDataSize -= usage;
|
|
361
361
|
}
|
|
362
|
-
reconcileCompileData(usage, included, transferred = included, retainedOwner,
|
|
362
|
+
reconcileCompileData(usage, included, transferred = included, retainedOwner, complete2 = false) {
|
|
363
363
|
let includedUsage = 0;
|
|
364
364
|
let transferredUsage = 0;
|
|
365
365
|
let discardedUsage = 0;
|
|
@@ -371,7 +371,7 @@ var Budget = class {
|
|
|
371
371
|
if (charge2 > 0 && transferred.has(ticket) && (this.provisionalScopes === 0 || retainedOwner !== void 0)) {
|
|
372
372
|
releasing.push(ticket);
|
|
373
373
|
transferredUsage += charge2;
|
|
374
|
-
} else if (charge2 > 0 &&
|
|
374
|
+
} else if (charge2 > 0 && complete2 && transferred.has(ticket)) {
|
|
375
375
|
retained.add(ticket);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -8549,6 +8549,9 @@ function nextStringIterator(value, budget) {
|
|
|
8549
8549
|
// packages/safe-js/src/interp/iterator-wrapper.ts
|
|
8550
8550
|
var iteratorWrapperStates = /* @__PURE__ */ new WeakMap();
|
|
8551
8551
|
|
|
8552
|
+
// packages/safe-js/src/interp/iterator-helper.ts
|
|
8553
|
+
var iteratorHelperStates = /* @__PURE__ */ new WeakMap();
|
|
8554
|
+
|
|
8552
8555
|
// packages/safe-js/src/interp/raw-json.ts
|
|
8553
8556
|
var rawJsonValues = /* @__PURE__ */ new WeakSet();
|
|
8554
8557
|
function createRawJson(text) {
|
|
@@ -9463,7 +9466,7 @@ function awaitSandboxValue(value, signal, budget, context) {
|
|
|
9463
9466
|
const outcome = signal === void 0 ? value2.promise : cancelableOutcomes.get(value2)?.get(signal) ?? value2.promise;
|
|
9464
9467
|
const resolved = new Promise((resolve, reject) => {
|
|
9465
9468
|
const detach = onFatalPromiseRejection(reject);
|
|
9466
|
-
const
|
|
9469
|
+
const complete2 = (state, result) => {
|
|
9467
9470
|
detach?.();
|
|
9468
9471
|
try {
|
|
9469
9472
|
consumeSettledHostCall(value2);
|
|
@@ -9474,8 +9477,8 @@ function awaitSandboxValue(value, signal, budget, context) {
|
|
|
9474
9477
|
}
|
|
9475
9478
|
};
|
|
9476
9479
|
outcome.then(
|
|
9477
|
-
(result) =>
|
|
9478
|
-
(reason) =>
|
|
9480
|
+
(result) => complete2("fulfilled", result),
|
|
9481
|
+
(reason) => complete2("rejected", reason)
|
|
9479
9482
|
);
|
|
9480
9483
|
});
|
|
9481
9484
|
return value2.synchronousPrefix !== void 0 || signal !== void 0 && cancelableOutcomes.get(value2)?.has(signal) ? resolved : awaitWithSignal(resolved, signal);
|
|
@@ -9510,13 +9513,13 @@ function awaitWithSignal(promise, signal) {
|
|
|
9510
9513
|
listenerActive = false;
|
|
9511
9514
|
signal.removeEventListener("abort", onAbort);
|
|
9512
9515
|
};
|
|
9513
|
-
const settle = (
|
|
9516
|
+
const settle = (complete2) => {
|
|
9514
9517
|
if (settled) {
|
|
9515
9518
|
return;
|
|
9516
9519
|
}
|
|
9517
9520
|
settled = true;
|
|
9518
9521
|
cleanup();
|
|
9519
|
-
|
|
9522
|
+
complete2();
|
|
9520
9523
|
};
|
|
9521
9524
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
9522
9525
|
Promise.resolve(promise).then(
|
|
@@ -21475,7 +21478,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21475
21478
|
const prototype = getPromisePrototype(budget);
|
|
21476
21479
|
const values = [];
|
|
21477
21480
|
let remaining = 1;
|
|
21478
|
-
const
|
|
21481
|
+
const complete2 = async () => {
|
|
21479
21482
|
if (remaining !== 0 || method === "race") return;
|
|
21480
21483
|
if (method === "any") {
|
|
21481
21484
|
const error = createSubsetErrorValue(
|
|
@@ -21547,7 +21550,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21547
21550
|
called = true;
|
|
21548
21551
|
values[entryIndex] = method === "allSettled" ? state === "fulfilled" ? { status: state, value: settlement } : { status: state, reason: settlement } : settlement;
|
|
21549
21552
|
remaining--;
|
|
21550
|
-
await
|
|
21553
|
+
await complete2();
|
|
21551
21554
|
return void 0;
|
|
21552
21555
|
}
|
|
21553
21556
|
});
|
|
@@ -21563,7 +21566,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21563
21566
|
}
|
|
21564
21567
|
}
|
|
21565
21568
|
remaining--;
|
|
21566
|
-
await
|
|
21569
|
+
await complete2();
|
|
21567
21570
|
} finally {
|
|
21568
21571
|
releaseIterator();
|
|
21569
21572
|
}
|
|
@@ -21665,7 +21668,7 @@ function resolveThenable(value, then, options) {
|
|
|
21665
21668
|
let settlement;
|
|
21666
21669
|
let completed = false;
|
|
21667
21670
|
let invocationPending = true;
|
|
21668
|
-
const
|
|
21671
|
+
const complete2 = () => {
|
|
21669
21672
|
if (completed || invocationPending || settlement === void 0) return;
|
|
21670
21673
|
completed = true;
|
|
21671
21674
|
try {
|
|
@@ -21685,7 +21688,7 @@ function resolveThenable(value, then, options) {
|
|
|
21685
21688
|
return;
|
|
21686
21689
|
}
|
|
21687
21690
|
settlement = { state, value: settledValue };
|
|
21688
|
-
queueMicrotask(
|
|
21691
|
+
queueMicrotask(complete2);
|
|
21689
21692
|
};
|
|
21690
21693
|
callInPromiseJob(
|
|
21691
21694
|
then,
|
|
@@ -21711,7 +21714,7 @@ function resolveThenable(value, then, options) {
|
|
|
21711
21714
|
{
|
|
21712
21715
|
fulfilled: () => {
|
|
21713
21716
|
invocationPending = false;
|
|
21714
|
-
|
|
21717
|
+
complete2();
|
|
21715
21718
|
},
|
|
21716
21719
|
rejected: (error) => {
|
|
21717
21720
|
invocationPending = false;
|
|
@@ -21721,7 +21724,7 @@ function resolveThenable(value, then, options) {
|
|
|
21721
21724
|
return;
|
|
21722
21725
|
}
|
|
21723
21726
|
recordSettlement("rejected", error);
|
|
21724
|
-
|
|
21727
|
+
complete2();
|
|
21725
21728
|
}
|
|
21726
21729
|
},
|
|
21727
21730
|
options.context
|
|
@@ -22033,6 +22036,21 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22033
22036
|
|
|
22034
22037
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22035
22038
|
function captureGuestHeapNode(value, encode) {
|
|
22039
|
+
const helper = iteratorHelperStates.get(value);
|
|
22040
|
+
if (helper !== void 0) {
|
|
22041
|
+
if (helper.status === "executing") throw new TypeError("Cannot snapshot an executing iterator helper.");
|
|
22042
|
+
return {
|
|
22043
|
+
kind: "iterator-helper",
|
|
22044
|
+
method: helper.method,
|
|
22045
|
+
status: helper.status,
|
|
22046
|
+
...helper.outer === void 0 ? {} : { outer: { iterator: encode(helper.outer.iterator), next: encode(helper.outer.next) } },
|
|
22047
|
+
...helper.inner === void 0 ? {} : { inner: { iterator: encode(helper.inner.iterator), next: encode(helper.inner.next) } },
|
|
22048
|
+
callback: encode(helper.callback),
|
|
22049
|
+
remaining: helper.remaining === Infinity ? "Infinity" : helper.remaining,
|
|
22050
|
+
index: helper.index,
|
|
22051
|
+
state: captureObjectState(value, encode)
|
|
22052
|
+
};
|
|
22053
|
+
}
|
|
22036
22054
|
const wrapper = iteratorWrapperStates.get(value);
|
|
22037
22055
|
if (wrapper !== void 0)
|
|
22038
22056
|
return { kind: "iterator-wrapper", iterator: encode(wrapper.iterator), next: encode(wrapper.next), state: captureObjectState(value, encode) };
|
|
@@ -24213,13 +24231,13 @@ function wrapHostPromiseWithSignal(promise, signal) {
|
|
|
24213
24231
|
const cleanup = () => {
|
|
24214
24232
|
signal.removeEventListener("abort", onAbort);
|
|
24215
24233
|
};
|
|
24216
|
-
const settle = (
|
|
24234
|
+
const settle = (complete2) => {
|
|
24217
24235
|
if (settled) {
|
|
24218
24236
|
return;
|
|
24219
24237
|
}
|
|
24220
24238
|
settled = true;
|
|
24221
24239
|
cleanup();
|
|
24222
|
-
|
|
24240
|
+
complete2();
|
|
24223
24241
|
};
|
|
24224
24242
|
const onAbort = () => {
|
|
24225
24243
|
settle(() => reject(readAbortReason2(signal)));
|
|
@@ -26506,6 +26524,183 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
26506
26524
|
}
|
|
26507
26525
|
}
|
|
26508
26526
|
|
|
26527
|
+
// packages/safe-js/src/interp/globals/iterator-lazy.ts
|
|
26528
|
+
function installLazyIteratorHelpers(common, budget) {
|
|
26529
|
+
const prototype = /* @__PURE__ */ Object.create(null);
|
|
26530
|
+
setSandboxPrototype(prototype, common);
|
|
26531
|
+
Object.defineProperty(prototype, Symbol.toStringTag, { value: "Iterator Helper", configurable: true });
|
|
26532
|
+
for (const operation of ["next", "return"]) {
|
|
26533
|
+
Object.defineProperty(prototype, operation, { writable: true, configurable: true, value: createSandboxClosure({
|
|
26534
|
+
guest: true,
|
|
26535
|
+
sandbox: true,
|
|
26536
|
+
name: operation,
|
|
26537
|
+
length: 0,
|
|
26538
|
+
call: async (_args, context) => {
|
|
26539
|
+
const receiver = context?.thisValue;
|
|
26540
|
+
const state = receiver !== null && typeof receiver === "object" ? iteratorHelperStates.get(receiver) : void 0;
|
|
26541
|
+
if (state === void 0) throw new TypeError("Iterator helper method requires a branded receiver.");
|
|
26542
|
+
if (state.status === "executing") throw new TypeError("Iterator helper is already executing.");
|
|
26543
|
+
if (state.status === "done") return { value: void 0, done: true };
|
|
26544
|
+
state.status = "executing";
|
|
26545
|
+
try {
|
|
26546
|
+
const outer = state.outer;
|
|
26547
|
+
if (operation === "return") {
|
|
26548
|
+
if (state.inner !== void 0) {
|
|
26549
|
+
try {
|
|
26550
|
+
await closeIterator(adapter(state.inner, context));
|
|
26551
|
+
} catch (error) {
|
|
26552
|
+
if (!isFatalSandboxError(error)) await closeIterator(adapter(outer, context), true);
|
|
26553
|
+
throw error;
|
|
26554
|
+
}
|
|
26555
|
+
}
|
|
26556
|
+
await closeIterator(adapter(outer, context));
|
|
26557
|
+
complete(state);
|
|
26558
|
+
return { value: void 0, done: true };
|
|
26559
|
+
}
|
|
26560
|
+
while (true) {
|
|
26561
|
+
budget.visitNode();
|
|
26562
|
+
if (state.inner !== void 0) {
|
|
26563
|
+
let innerResult;
|
|
26564
|
+
try {
|
|
26565
|
+
innerResult = await step(state.inner, context);
|
|
26566
|
+
} catch (error) {
|
|
26567
|
+
if (!isFatalSandboxError(error)) await closeIterator(adapter(outer, context), true);
|
|
26568
|
+
throw error;
|
|
26569
|
+
}
|
|
26570
|
+
if (!innerResult.done) {
|
|
26571
|
+
state.status = "yield";
|
|
26572
|
+
return innerResult;
|
|
26573
|
+
}
|
|
26574
|
+
state.inner = void 0;
|
|
26575
|
+
}
|
|
26576
|
+
if (state.method === "take" && state.remaining === 0) {
|
|
26577
|
+
await closeIterator(adapter(outer, context));
|
|
26578
|
+
complete(state);
|
|
26579
|
+
return { value: void 0, done: true };
|
|
26580
|
+
}
|
|
26581
|
+
const skipping = state.method === "drop" && state.remaining > 0;
|
|
26582
|
+
if ((state.method === "take" || skipping) && state.remaining !== Infinity) state.remaining--;
|
|
26583
|
+
const result = await step(outer, context, skipping);
|
|
26584
|
+
if (result.done) {
|
|
26585
|
+
complete(state);
|
|
26586
|
+
return result;
|
|
26587
|
+
}
|
|
26588
|
+
if (skipping) continue;
|
|
26589
|
+
if (state.method === "take" || state.method === "drop") {
|
|
26590
|
+
state.status = "yield";
|
|
26591
|
+
return result;
|
|
26592
|
+
}
|
|
26593
|
+
let mapped;
|
|
26594
|
+
const release = retainValues(budget, () => [result.value, mapped]);
|
|
26595
|
+
try {
|
|
26596
|
+
try {
|
|
26597
|
+
mapped = await invokeBuiltinClosure(state.callback, [result.value, state.index++], budget, context, void 0);
|
|
26598
|
+
if (state.method === "flatMap") {
|
|
26599
|
+
if (mapped === null || typeof mapped !== "object") throw new TypeError("flatMap callback must return an object.");
|
|
26600
|
+
const method = await read(mapped, Symbol.iterator, context);
|
|
26601
|
+
let inner = mapped;
|
|
26602
|
+
if (method !== void 0 && method !== null) {
|
|
26603
|
+
if (!isSandboxClosure(method)) throw new TypeError("Symbol.iterator must be callable.");
|
|
26604
|
+
const value = await invokeBuiltinClosure(method, [], budget, context, mapped);
|
|
26605
|
+
if (value === null || typeof value !== "object") throw new TypeError("Inner iterator must be an object.");
|
|
26606
|
+
inner = value;
|
|
26607
|
+
}
|
|
26608
|
+
state.inner = { iterator: inner, next: await read(inner, "next", context) };
|
|
26609
|
+
}
|
|
26610
|
+
} catch (error) {
|
|
26611
|
+
if (!isFatalSandboxError(error)) await closeIterator(adapter(outer, context), true);
|
|
26612
|
+
throw error;
|
|
26613
|
+
}
|
|
26614
|
+
if (state.method === "map") {
|
|
26615
|
+
state.status = "yield";
|
|
26616
|
+
return { value: mapped, done: false };
|
|
26617
|
+
}
|
|
26618
|
+
if (state.method === "filter" && mapped) {
|
|
26619
|
+
state.status = "yield";
|
|
26620
|
+
return result;
|
|
26621
|
+
}
|
|
26622
|
+
} finally {
|
|
26623
|
+
release();
|
|
26624
|
+
}
|
|
26625
|
+
}
|
|
26626
|
+
} catch (error) {
|
|
26627
|
+
complete(state);
|
|
26628
|
+
throw error;
|
|
26629
|
+
}
|
|
26630
|
+
}
|
|
26631
|
+
}) });
|
|
26632
|
+
}
|
|
26633
|
+
for (const method of ["map", "filter", "take", "drop", "flatMap"]) {
|
|
26634
|
+
Object.defineProperty(common, method, { writable: true, configurable: true, value: createSandboxClosure({
|
|
26635
|
+
guest: true,
|
|
26636
|
+
sandbox: true,
|
|
26637
|
+
name: method,
|
|
26638
|
+
length: 1,
|
|
26639
|
+
call: async ([argument], context) => {
|
|
26640
|
+
const receiver = context?.thisValue;
|
|
26641
|
+
if (receiver === null || typeof receiver !== "object") throw new TypeError("Iterator helper requires an object.");
|
|
26642
|
+
const outer = { iterator: receiver, next: void 0 };
|
|
26643
|
+
let remaining = 0;
|
|
26644
|
+
try {
|
|
26645
|
+
if (method === "take" || method === "drop") {
|
|
26646
|
+
const number = await sandboxNumber(argument, budget, context);
|
|
26647
|
+
if (Number.isNaN(number)) throw new RangeError("Iterator limit must not be NaN.");
|
|
26648
|
+
remaining = Math.trunc(number);
|
|
26649
|
+
if (remaining < 0) throw new RangeError("Iterator limit must not be negative.");
|
|
26650
|
+
} else if (!isSandboxClosure(argument)) throw new TypeError("Iterator callback must be callable.");
|
|
26651
|
+
} catch (error) {
|
|
26652
|
+
if (!isFatalSandboxError(error)) await closeIterator(adapter(outer, context), true);
|
|
26653
|
+
throw error;
|
|
26654
|
+
}
|
|
26655
|
+
outer.next = await read(receiver, "next", context);
|
|
26656
|
+
const helper = /* @__PURE__ */ Object.create(null);
|
|
26657
|
+
iteratorHelperStates.set(helper, { method, status: "start", outer, callback: method === "take" || method === "drop" ? void 0 : argument, remaining, index: 0 });
|
|
26658
|
+
setSandboxPrototype(helper, prototype, budget);
|
|
26659
|
+
createDataCheckpoint(budget, context)(helper, 0, true);
|
|
26660
|
+
return helper;
|
|
26661
|
+
}
|
|
26662
|
+
}) });
|
|
26663
|
+
}
|
|
26664
|
+
registerBuiltinIdentities(budget, { "%IteratorPrototype%": common, "%IteratorHelperPrototype%": prototype });
|
|
26665
|
+
registerIntrinsicObject(budget, prototype);
|
|
26666
|
+
registerIntrinsicObject(budget, common);
|
|
26667
|
+
function adapter(record4, context) {
|
|
26668
|
+
return { asynchronous: true, next: async () => {
|
|
26669
|
+
if (!isSandboxClosure(record4.next)) throw new TypeError("Iterator next must be callable.");
|
|
26670
|
+
const result = await invokeBuiltinClosure(record4.next, [], budget, context, record4.iterator);
|
|
26671
|
+
if (result === null || typeof result !== "object") throw new TypeError("Iterator result must be an object.");
|
|
26672
|
+
return result;
|
|
26673
|
+
}, getOperation: async () => {
|
|
26674
|
+
const method = await read(record4.iterator, "return", context);
|
|
26675
|
+
if (method === void 0 || method === null) return void 0;
|
|
26676
|
+
if (!isSandboxClosure(method)) throw new TypeError("Iterator return must be callable.");
|
|
26677
|
+
return async () => await invokeBuiltinClosure(method, [], budget, context, record4.iterator);
|
|
26678
|
+
} };
|
|
26679
|
+
}
|
|
26680
|
+
async function step(record4, context, skipValue = false) {
|
|
26681
|
+
let result;
|
|
26682
|
+
const release = retainValues(budget, () => [result]);
|
|
26683
|
+
try {
|
|
26684
|
+
result = await adapter(record4, context).next();
|
|
26685
|
+
if (await read(result, "done", context)) return { value: void 0, done: true };
|
|
26686
|
+
return { value: skipValue ? void 0 : await read(result, "value", context), done: false };
|
|
26687
|
+
} finally {
|
|
26688
|
+
release();
|
|
26689
|
+
}
|
|
26690
|
+
}
|
|
26691
|
+
async function read(value, key, context) {
|
|
26692
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
26693
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
26694
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
26695
|
+
}
|
|
26696
|
+
}
|
|
26697
|
+
function complete(state) {
|
|
26698
|
+
state.status = "done";
|
|
26699
|
+
state.outer = void 0;
|
|
26700
|
+
state.inner = void 0;
|
|
26701
|
+
state.callback = void 0;
|
|
26702
|
+
}
|
|
26703
|
+
|
|
26509
26704
|
// packages/safe-js/src/interp/globals/iterator.ts
|
|
26510
26705
|
function createIteratorGlobal(budget) {
|
|
26511
26706
|
const prototype = resolveIntrinsicIdentity(budget, '["%IteratorPrototype%"]');
|
|
@@ -26545,6 +26740,7 @@ function createIteratorGlobal(budget) {
|
|
|
26545
26740
|
registerIntrinsicFunction(budget, setter);
|
|
26546
26741
|
installIteratorFrom(constructor, budget);
|
|
26547
26742
|
installIteratorConsumers(prototype, budget);
|
|
26743
|
+
installLazyIteratorHelpers(prototype, budget);
|
|
26548
26744
|
registerIntrinsicFunction(budget, constructor);
|
|
26549
26745
|
registerIntrinsicObject(budget, prototype);
|
|
26550
26746
|
return constructor;
|
|
@@ -27250,7 +27446,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27250
27446
|
createRawJson(node.text);
|
|
27251
27447
|
return true;
|
|
27252
27448
|
}
|
|
27253
|
-
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "string-iterator", "iterator-wrapper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27449
|
+
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27254
27450
|
const reference = (value, kinds) => {
|
|
27255
27451
|
const ref = record3(value);
|
|
27256
27452
|
fields(ref, ["kind", "id"]);
|
|
@@ -27304,7 +27500,29 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27304
27500
|
});
|
|
27305
27501
|
return false;
|
|
27306
27502
|
}
|
|
27307
|
-
if (node.kind === "iterator-
|
|
27503
|
+
if (node.kind === "iterator-helper") {
|
|
27504
|
+
fields(node, ["kind", "method", "status", "callback", "remaining", "index", "state"], ["outer", "inner"]);
|
|
27505
|
+
if (!["map", "filter", "take", "drop", "flatMap"].includes(String(node.method)) || !["start", "yield", "done"].includes(String(node.status))) throw new TypeError("Invalid iterator helper mode.");
|
|
27506
|
+
integer(node.index);
|
|
27507
|
+
if (node.remaining !== "Infinity" && (typeof node.remaining !== "number" || !Number.isInteger(node.remaining) || node.remaining < 0))
|
|
27508
|
+
throw new TypeError("Invalid iterator helper limit.");
|
|
27509
|
+
for (const key of ["outer", "inner"]) {
|
|
27510
|
+
if (!Object.hasOwn(node, key)) continue;
|
|
27511
|
+
const cursor = record3(node[key]);
|
|
27512
|
+
fields(cursor, ["iterator", "next"]);
|
|
27513
|
+
const target = reference(cursor.iterator);
|
|
27514
|
+
if (target.kind === "symbol" || target.kind === "scope-frame") throw new TypeError("Invalid helper iterator.");
|
|
27515
|
+
}
|
|
27516
|
+
if (node.status === "done" === Object.hasOwn(node, "outer") || Object.hasOwn(node, "inner") && (node.method !== "flatMap" || node.status !== "yield"))
|
|
27517
|
+
throw new TypeError("Invalid iterator helper cursor state.");
|
|
27518
|
+
if (node.status === "done" || node.method === "take" || node.method === "drop") {
|
|
27519
|
+
if (!absent(node.callback)) throw new TypeError("Unexpected iterator helper callback.");
|
|
27520
|
+
} else {
|
|
27521
|
+
if (absent(node.callback)) throw new TypeError("Missing iterator helper callback.");
|
|
27522
|
+
callable(node.callback);
|
|
27523
|
+
}
|
|
27524
|
+
state(node.state);
|
|
27525
|
+
} else if (node.kind === "iterator-wrapper") {
|
|
27308
27526
|
fields(node, ["kind", "iterator", "next", "state"]);
|
|
27309
27527
|
const iterator = reference(node.iterator);
|
|
27310
27528
|
if (iterator.kind === "symbol" || iterator.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
|
|
@@ -29152,6 +29370,7 @@ function* cloneStructuredGraph(value, state, budget, depth = 0) {
|
|
|
29152
29370
|
if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxStringIterator(value) || isSandboxArguments(value))
|
|
29153
29371
|
throw new DOMException("Value cannot be structured cloned.", "DataCloneError");
|
|
29154
29372
|
if (typeof value !== "object" || value === null) return allocateProducedSandboxValue(value, budget);
|
|
29373
|
+
if (iteratorHelperStates.has(value)) throw new DOMException("Iterator helpers cannot be structured cloned.", "DataCloneError");
|
|
29155
29374
|
if (isLiveCapability(value)) throw new DOMException("Capabilities cannot be structured cloned.", "DataCloneError");
|
|
29156
29375
|
const existing = state.seen.get(value);
|
|
29157
29376
|
if (existing !== void 0) return existing;
|
|
@@ -29279,6 +29498,16 @@ function measureSandboxData(values, options = {}) {
|
|
|
29279
29498
|
visit(wrapperState.iterator, depth + 1);
|
|
29280
29499
|
visit(wrapperState.next, depth + 1);
|
|
29281
29500
|
}
|
|
29501
|
+
const helperState = iteratorHelperStates.get(value);
|
|
29502
|
+
if (helperState !== void 0) {
|
|
29503
|
+
for (const record4 of [helperState.outer, helperState.inner]) {
|
|
29504
|
+
if (record4 !== void 0) {
|
|
29505
|
+
visit(record4.iterator, depth + 1);
|
|
29506
|
+
visit(record4.next, depth + 1);
|
|
29507
|
+
}
|
|
29508
|
+
}
|
|
29509
|
+
visit(helperState.callback, depth + 1);
|
|
29510
|
+
}
|
|
29282
29511
|
if (isSandboxDate(value)) usage += 8;
|
|
29283
29512
|
if (isGuestHostObject(value)) {
|
|
29284
29513
|
usage += measureHostObjectData(value);
|
|
@@ -30605,7 +30834,7 @@ var HostCallJournal = class {
|
|
|
30605
30834
|
return waiter.promise;
|
|
30606
30835
|
}
|
|
30607
30836
|
trackCallbackCompletion(record4, callbacks) {
|
|
30608
|
-
const
|
|
30837
|
+
const complete2 = () => {
|
|
30609
30838
|
this.completedCallbackOwners.add(record4.id);
|
|
30610
30839
|
for (const [id, waiter] of this.capabilityWaiters) {
|
|
30611
30840
|
if (!id.startsWith(`${record4.id}/function/`)) continue;
|
|
@@ -30613,8 +30842,8 @@ var HostCallJournal = class {
|
|
|
30613
30842
|
this.capabilityWaiters.delete(id);
|
|
30614
30843
|
}
|
|
30615
30844
|
};
|
|
30616
|
-
if (callbacks.length === 0)
|
|
30617
|
-
else void Promise.allSettled(callbacks).then(
|
|
30845
|
+
if (callbacks.length === 0) complete2();
|
|
30846
|
+
else void Promise.allSettled(callbacks).then(complete2);
|
|
30618
30847
|
}
|
|
30619
30848
|
recordCallback(record4, id, args, step) {
|
|
30620
30849
|
const retainedSize = this.retainedSize + 1 + measureSandboxData([args], { ignoreClosures: true });
|
|
@@ -42805,13 +43034,13 @@ var RealmState = class {
|
|
|
42805
43034
|
);
|
|
42806
43035
|
};
|
|
42807
43036
|
startCallback = (callback, options = {}) => {
|
|
42808
|
-
let
|
|
43037
|
+
let complete2;
|
|
42809
43038
|
let fail2;
|
|
42810
43039
|
const synchronous = new Promise((resolve, reject) => {
|
|
42811
|
-
|
|
43040
|
+
complete2 = resolve;
|
|
42812
43041
|
fail2 = reject;
|
|
42813
43042
|
});
|
|
42814
|
-
const result = this.executeCallback(callback, options,
|
|
43043
|
+
const result = this.executeCallback(callback, options, complete2);
|
|
42815
43044
|
void result.catch(fail2);
|
|
42816
43045
|
void synchronous.catch(() => void 0);
|
|
42817
43046
|
return Object.freeze({ synchronous, result });
|
|
@@ -44408,4 +44637,4 @@ export {
|
|
|
44408
44637
|
FileSnapshotBackend,
|
|
44409
44638
|
run
|
|
44410
44639
|
};
|
|
44411
|
-
//# sourceMappingURL=chunk-
|
|
44640
|
+
//# sourceMappingURL=chunk-XBIXRS5K.js.map
|