@poe-platform/safe-js 0.1.722 → 0.1.724
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 +1 -1
- package/dist/safe-js/chunks/{chunk-K3ZRBAG5.js → chunk-2DISWAVU.js} +3 -3
- package/dist/safe-js/chunks/{chunk-EH5A2EQI.js → chunk-5M2P3GUC.js} +6 -6
- package/dist/safe-js/chunks/{chunk-WF7HYDJ4.js → chunk-6OE64YMG.js} +2 -2
- package/dist/safe-js/chunks/{chunk-D3GC5QPZ.js → chunk-BRBOVGNC.js} +1 -1
- package/dist/safe-js/chunks/{chunk-D3GC5QPZ.js.map → chunk-BRBOVGNC.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-FA5CQO6V.js → chunk-BYX6GUCC.js} +2 -2
- package/dist/safe-js/chunks/{chunk-GCOLKRMY.js → chunk-CSRNI5HI.js} +4 -4
- package/dist/safe-js/chunks/{chunk-55RIIUGG.js → chunk-E5VQVLWF.js} +37 -3
- package/dist/safe-js/chunks/chunk-E5VQVLWF.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-QL2ALAE6.js → chunk-GM32LIKF.js} +4 -4
- package/dist/safe-js/chunks/{chunk-XHSOM5CG.js → chunk-GYT2ECWI.js} +2 -2
- package/dist/safe-js/chunks/{chunk-3QQYJ4RQ.js → chunk-HG5QP5UC.js} +2 -2
- package/dist/safe-js/chunks/{chunk-RYVHEOHM.js → chunk-KOO6YGQG.js} +21 -5
- package/dist/safe-js/chunks/chunk-KOO6YGQG.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-7SBQ7WTV.js → chunk-TMRO2MK6.js} +4 -4
- package/dist/safe-js/chunks/{chunk-S2GFVXSI.js → chunk-WYY65M7Z.js} +3 -3
- package/dist/safe-js/chunks/{chunk-BNIEPGDU.js → chunk-ZHJPXLUJ.js} +849 -489
- package/dist/safe-js/chunks/{chunk-BNIEPGDU.js.map → chunk-ZHJPXLUJ.js.map} +4 -4
- package/dist/safe-js/chunks/{cli-runtime-6QPGM3TX.js → cli-runtime-PHNOLXPN.js} +14 -14
- package/dist/safe-js/chunks/{dump-TU6SYRFD.js → dump-HAU2HFBZ.js} +4 -4
- package/dist/safe-js/chunks/{fs-HTZT32MQ.js → fs-6PHK3Q3V.js} +4 -4
- package/dist/safe-js/chunks/harness-E3FVGKIR.js +10 -0
- package/dist/safe-js/chunks/mcp-HGLB4YOP.js +11 -0
- package/dist/safe-js/chunks/migration-file-4GNB4HDL.js +12 -0
- package/dist/safe-js/chunks/restore-ZFU4NJOM.js +13 -0
- package/dist/safe-js/chunks/run-AAOCYT5M.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-OPLHKWMC.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/index.js +14 -14
- package/dist/safe-js/interp/arguments.d.ts +1 -2
- package/dist/safe-js/interp/host-bridge.d.ts +1 -0
- package/dist/safe-js/interp/scope.d.ts +1 -0
- package/dist/safe-js/interp/values.d.ts +1 -0
- package/dist/safe-js/parse/compact-spans.d.ts +4 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-55RIIUGG.js.map +0 -7
- package/dist/safe-js/chunks/chunk-RYVHEOHM.js.map +0 -7
- package/dist/safe-js/chunks/harness-RYAMI444.js +0 -10
- package/dist/safe-js/chunks/mcp-DO2IRFGQ.js +0 -11
- package/dist/safe-js/chunks/migration-file-K7UH5ZG6.js +0 -12
- package/dist/safe-js/chunks/restore-7LRP4BM3.js +0 -13
- package/dist/safe-js/chunks/run-6SETM7SV.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-MCQS2SHQ.js +0 -10
- /package/dist/safe-js/chunks/{chunk-K3ZRBAG5.js.map → chunk-2DISWAVU.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-EH5A2EQI.js.map → chunk-5M2P3GUC.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-WF7HYDJ4.js.map → chunk-6OE64YMG.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-FA5CQO6V.js.map → chunk-BYX6GUCC.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-GCOLKRMY.js.map → chunk-CSRNI5HI.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-QL2ALAE6.js.map → chunk-GM32LIKF.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-XHSOM5CG.js.map → chunk-GYT2ECWI.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-3QQYJ4RQ.js.map → chunk-HG5QP5UC.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-7SBQ7WTV.js.map → chunk-TMRO2MK6.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-S2GFVXSI.js.map → chunk-WYY65M7Z.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-6QPGM3TX.js.map → cli-runtime-PHNOLXPN.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-TU6SYRFD.js.map → dump-HAU2HFBZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-HTZT32MQ.js.map → fs-6PHK3Q3V.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-RYAMI444.js.map → harness-E3FVGKIR.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-DO2IRFGQ.js.map → mcp-HGLB4YOP.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-K7UH5ZG6.js.map → migration-file-4GNB4HDL.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-7LRP4BM3.js.map → restore-ZFU4NJOM.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-6SETM7SV.js.map → run-AAOCYT5M.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-MCQS2SHQ.js.map → runtime-modules-OPLHKWMC.js.map} +0 -0
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
sandboxErrorTypes,
|
|
40
40
|
syntaxDiagnostics,
|
|
41
41
|
templateRealms
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-KOO6YGQG.js";
|
|
43
43
|
|
|
44
44
|
// packages/safe-js/src/interp/native-promise-properties.ts
|
|
45
45
|
import { types } from "node:util";
|
|
@@ -95,6 +95,7 @@ async function withRunResources(signal, execute) {
|
|
|
95
95
|
let failure;
|
|
96
96
|
const resources = {
|
|
97
97
|
signal: controller.signal,
|
|
98
|
+
nativeDataResults: true,
|
|
98
99
|
referenceReleases: /* @__PURE__ */ new Set(),
|
|
99
100
|
reportError(reason) {
|
|
100
101
|
failure ??= { reason };
|
|
@@ -350,14 +351,14 @@ function copySandboxArgumentProperties(source, target, copyValue) {
|
|
|
350
351
|
}
|
|
351
352
|
Object.defineProperty(target, key, { ...descriptor, value: copyValue(descriptor.value, key) });
|
|
352
353
|
}
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
354
|
+
const iterator2 = Object.getOwnPropertyDescriptor(source, Symbol.iterator);
|
|
355
|
+
if (iterator2 === void 0) {
|
|
355
356
|
Reflect.deleteProperty(target, Symbol.iterator);
|
|
356
357
|
} else {
|
|
357
|
-
if (
|
|
358
|
+
if (iterator2.value !== Array.prototype.values) {
|
|
358
359
|
throw new TypeError("Cannot copy a replaced arguments iterator.");
|
|
359
360
|
}
|
|
360
|
-
Object.defineProperty(target, Symbol.iterator,
|
|
361
|
+
Object.defineProperty(target, Symbol.iterator, iterator2);
|
|
361
362
|
}
|
|
362
363
|
if (!Object.isExtensible(source)) Object.preventExtensions(target);
|
|
363
364
|
}
|
|
@@ -377,10 +378,10 @@ function isSandboxCollectionIterator(value) {
|
|
|
377
378
|
return typeof value === "object" && value !== null && states.has(value);
|
|
378
379
|
}
|
|
379
380
|
function createSandboxCollectionIterator(collection, method, budget) {
|
|
380
|
-
const
|
|
381
|
+
const iterator2 = restoreSandboxCollectionIterator({ collection, collectionKind: collection.kind, method, index: 0, exhausted: false });
|
|
381
382
|
const prototype = budget === void 0 ? void 0 : collectionIteratorPrototypes.get(budget)?.[collection.kind];
|
|
382
|
-
if (prototype !== void 0) setSandboxPrototype(
|
|
383
|
-
return
|
|
383
|
+
if (prototype !== void 0) setSandboxPrototype(iterator2, prototype, budget);
|
|
384
|
+
return iterator2;
|
|
384
385
|
}
|
|
385
386
|
function restoreSandboxCollectionIterator(snapshot, target = /* @__PURE__ */ Object.create(null)) {
|
|
386
387
|
const { collection, collectionKind, method, index, exhausted } = snapshot;
|
|
@@ -388,12 +389,12 @@ function restoreSandboxCollectionIterator(snapshot, target = /* @__PURE__ */ Obj
|
|
|
388
389
|
throw new TypeError("Collection iterator source has the wrong brand.");
|
|
389
390
|
if (!exhausted && collection === void 0)
|
|
390
391
|
throw new TypeError("Live collection iterator requires its source collection.");
|
|
391
|
-
const
|
|
392
|
+
const iterator2 = exhausted ? void 0 : nativeIterator(collection, method);
|
|
392
393
|
for (let skipped = 0; skipped < index; skipped += 1) {
|
|
393
|
-
if (
|
|
394
|
+
if (iterator2 === void 0 || iterator2.next().done)
|
|
394
395
|
throw new TypeError("Collection iterator cursor exceeds its source.");
|
|
395
396
|
}
|
|
396
|
-
states.set(target, { collection: exhausted ? void 0 : collection, collectionKind, method, exhausted, iterator });
|
|
397
|
+
states.set(target, { collection: exhausted ? void 0 : collection, collectionKind, method, exhausted, iterator: iterator2 });
|
|
397
398
|
return target;
|
|
398
399
|
}
|
|
399
400
|
function collectionIteratorState(value) {
|
|
@@ -766,7 +767,7 @@ function appendScopeDataRoot(values, value) {
|
|
|
766
767
|
var scopeDataRoots = Object.freeze({
|
|
767
768
|
get: nativeGet,
|
|
768
769
|
set(root, data) {
|
|
769
|
-
const snapshot = hasOwn(data, "value") ? freeze({
|
|
770
|
+
const snapshot = hasOwn(data, "value") ? freeze(setPrototypeOf({ value: data.value }, null)) : hasOwn(data, "arguments") ? freeze(setPrototypeOf({ arguments: freeze(data.arguments) }, null)) : hasOwn(data, "deferred") ? freeze(setPrototypeOf({ deferred: freeze(data.deferred) }, null)) : freeze(setPrototypeOf({ values: freeze(data.values) }, null));
|
|
770
771
|
nativeSet(root, snapshot);
|
|
771
772
|
}
|
|
772
773
|
});
|
|
@@ -1468,23 +1469,23 @@ function createSandboxSegments(state) {
|
|
|
1468
1469
|
function isSandboxSegments(value) {
|
|
1469
1470
|
return typeof value === "object" && value !== null && segments.has(value);
|
|
1470
1471
|
}
|
|
1471
|
-
function segmentState(value,
|
|
1472
|
-
if (!isSandboxSegments(value) ||
|
|
1473
|
-
throw new TypeError(
|
|
1472
|
+
function segmentState(value, iterator2) {
|
|
1473
|
+
if (!isSandboxSegments(value) || iterator2 !== void 0 && segments.get(value).index !== void 0 !== iterator2)
|
|
1474
|
+
throw new TypeError(iterator2 ? "Segment iterator requires a segment iterator receiver." : "Segments method requires a Segments receiver.");
|
|
1474
1475
|
return segments.get(value);
|
|
1475
1476
|
}
|
|
1476
|
-
function containingSegment(value, index,
|
|
1477
|
-
const state = segmentState(value,
|
|
1477
|
+
function containingSegment(value, index, iterator2, budget) {
|
|
1478
|
+
const state = segmentState(value, iterator2);
|
|
1478
1479
|
budget.visitNode(state.input.length + 1);
|
|
1479
1480
|
const result = findContainingSegment(state.native, state.input.length, index);
|
|
1480
|
-
if (
|
|
1481
|
+
if (iterator2 && result !== void 0) state.index = result.index + result.segment.length;
|
|
1481
1482
|
return result === void 0 ? void 0 : { ...result };
|
|
1482
1483
|
}
|
|
1483
1484
|
function findContainingSegment(native, length, index) {
|
|
1484
1485
|
if (index < 0 || index >= length) return void 0;
|
|
1485
|
-
const
|
|
1486
|
+
const iterator2 = Reflect.apply(nativeIterator2, native, []);
|
|
1486
1487
|
for (; ; ) {
|
|
1487
|
-
const next = Reflect.apply(nativeNext,
|
|
1488
|
+
const next = Reflect.apply(nativeNext, iterator2, []);
|
|
1488
1489
|
if (next.done) return void 0;
|
|
1489
1490
|
if (index < next.value.index + next.value.segment.length) return next.value;
|
|
1490
1491
|
}
|
|
@@ -4339,8 +4340,8 @@ function typeTag(value, builtinOnly = false) {
|
|
|
4339
4340
|
var typedArrayPrototypes = /* @__PURE__ */ new WeakMap();
|
|
4340
4341
|
|
|
4341
4342
|
// packages/safe-js/src/interp/methods/regexp-iterator.ts
|
|
4342
|
-
function nextRegExpIterator(
|
|
4343
|
-
const state = regexpIteratorState(
|
|
4343
|
+
function nextRegExpIterator(iterator2, budget) {
|
|
4344
|
+
const state = regexpIteratorState(iterator2);
|
|
4344
4345
|
budget?.visitNode();
|
|
4345
4346
|
if (state.exhausted) return createIteratorResult(void 0, true, budget);
|
|
4346
4347
|
const matcher = state.matcher;
|
|
@@ -4361,14 +4362,14 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
4361
4362
|
}
|
|
4362
4363
|
return createIteratorResult(toMatchArray(match, input, budget), false, budget);
|
|
4363
4364
|
}
|
|
4364
|
-
async function nextObservableRegExpIterator(
|
|
4365
|
-
const state = regexpIteratorState(
|
|
4365
|
+
async function nextObservableRegExpIterator(iterator2, budget, context) {
|
|
4366
|
+
const state = regexpIteratorState(iterator2);
|
|
4366
4367
|
if (state.exhausted) return createIteratorResult(void 0, true, budget);
|
|
4367
4368
|
const matcher = state.matcher;
|
|
4368
4369
|
const input = state.input;
|
|
4369
4370
|
let result;
|
|
4370
4371
|
let field;
|
|
4371
|
-
const release = retainValues(budget, () => [
|
|
4372
|
+
const release = retainValues(budget, () => [iterator2, matcher, input, result, field]);
|
|
4372
4373
|
const read = (value, key) => {
|
|
4373
4374
|
if (context.getProperty !== void 0) return context.getProperty(value, key);
|
|
4374
4375
|
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
@@ -4623,13 +4624,13 @@ async function restoreSandboxIterator(snapshot, budget, context, signal) {
|
|
|
4623
4624
|
if (snapshot.kind === "guest") return guestIterator(snapshot.value, snapshot.next, snapshot.async, budget, context, signal);
|
|
4624
4625
|
if (snapshot.kind === "async-from-sync") return asyncFromSyncIterator(await restoreSandboxIterator(snapshot.inner, budget, context, signal), budget, signal, context);
|
|
4625
4626
|
if (Array.isArray(snapshot.value)) return arrayIterator(snapshot.value, context, budget, snapshot.index);
|
|
4626
|
-
const
|
|
4627
|
+
const iterator2 = isSandboxGenerator(snapshot.value) ? {
|
|
4627
4628
|
...generatorObjectIterator(snapshot.value, budget, context),
|
|
4628
4629
|
...snapshot.value.async ? { asyncProtocol: true } : {}
|
|
4629
4630
|
} : getSandboxIterator(snapshot.value, budget, context);
|
|
4630
|
-
if (
|
|
4631
|
-
for (let index = 0; index < snapshot.index; index++) await
|
|
4632
|
-
return
|
|
4631
|
+
if (iterator2 === void 0) throw new TypeError("Invalid builtin iterator snapshot.");
|
|
4632
|
+
for (let index = 0; index < snapshot.index; index++) await iterator2.next();
|
|
4633
|
+
return iterator2;
|
|
4633
4634
|
}
|
|
4634
4635
|
async function acquireSandboxIterator(value, budget, context, asyncProtocol = false, signal) {
|
|
4635
4636
|
const key = asyncProtocol ? Symbol.asyncIterator : Symbol.iterator;
|
|
@@ -4649,8 +4650,8 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
4649
4650
|
if (!asyncProtocol) return getSandboxIterator(value, budget, context);
|
|
4650
4651
|
if (isSandboxGenerator(value) && value.async && !hasExplicitSandboxPrototype(value))
|
|
4651
4652
|
return getSandboxAsyncIterator(value, budget, context, signal);
|
|
4652
|
-
const
|
|
4653
|
-
return
|
|
4653
|
+
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
4654
|
+
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
4654
4655
|
}
|
|
4655
4656
|
const factory = await context.getProperty(value, key);
|
|
4656
4657
|
if (!asyncProtocol && factory === void 0 && Array.isArray(value) && !hasExplicitSandboxPrototype(value)) {
|
|
@@ -4660,8 +4661,8 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
4660
4661
|
}
|
|
4661
4662
|
if (factory === null || factory === void 0) {
|
|
4662
4663
|
if (!asyncProtocol) return void 0;
|
|
4663
|
-
const
|
|
4664
|
-
return
|
|
4664
|
+
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
4665
|
+
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
4665
4666
|
}
|
|
4666
4667
|
return getSandboxIteratorFromMethod(value, factory, budget, context, asyncProtocol, signal);
|
|
4667
4668
|
}
|
|
@@ -4672,20 +4673,20 @@ async function getSandboxIteratorFromMethod(value, factory, budget, context, asy
|
|
|
4672
4673
|
if (!isSandboxClosure(factory)) {
|
|
4673
4674
|
if (typeof factory !== "function") throw new TypeError("Iterator method must be callable.");
|
|
4674
4675
|
if (asyncProtocol) return nativeAsyncIterator(value, factory, signal);
|
|
4675
|
-
const
|
|
4676
|
-
if (typeof
|
|
4676
|
+
const iterator3 = Reflect.apply(factory, value, []);
|
|
4677
|
+
if (typeof iterator3 !== "object" && typeof iterator3 !== "function" || iterator3 === null)
|
|
4677
4678
|
throw new TypeError("Iterator must be an object.");
|
|
4678
|
-
return syncIterator(
|
|
4679
|
+
return syncIterator(iterator3);
|
|
4679
4680
|
}
|
|
4680
|
-
const
|
|
4681
|
-
if (typeof
|
|
4681
|
+
const iterator2 = await invokeBuiltinClosure(factory, [], budget, context, value);
|
|
4682
|
+
if (typeof iterator2 !== "object" && typeof iterator2 !== "function" || iterator2 === null)
|
|
4682
4683
|
throw new TypeError("Iterator must be an object.");
|
|
4683
|
-
if (!asyncProtocol && isSandboxGenerator(
|
|
4684
|
-
return getSandboxIterator(
|
|
4685
|
-
const next = await context.getProperty(
|
|
4686
|
-
return guestIterator(
|
|
4684
|
+
if (!asyncProtocol && isSandboxGenerator(iterator2) && !iterator2.async && !hasExplicitSandboxPrototype(iterator2) && getSandboxPropertyDescriptor(iterator2, "next", budget) === void 0)
|
|
4685
|
+
return getSandboxIterator(iterator2, budget, context);
|
|
4686
|
+
const next = await context.getProperty(iterator2, "next");
|
|
4687
|
+
return guestIterator(iterator2, next, asyncProtocol, budget, context, signal);
|
|
4687
4688
|
}
|
|
4688
|
-
function guestIterator(
|
|
4689
|
+
function guestIterator(iterator2, next, asyncProtocol, budget, context, signal) {
|
|
4689
4690
|
const resumeAwait = async (state, value) => {
|
|
4690
4691
|
if (state.kind !== "result") throw new TypeError("Invalid async iterator await state.");
|
|
4691
4692
|
const result = await value();
|
|
@@ -4695,7 +4696,7 @@ function guestIterator(iterator, next, asyncProtocol, budget, context, signal) {
|
|
|
4695
4696
|
};
|
|
4696
4697
|
const invoke = async (operation, args) => {
|
|
4697
4698
|
if (!isSandboxClosure(operation)) throw new TypeError("Iterator operation must be callable.");
|
|
4698
|
-
const returned = await invokeBuiltinClosure(operation, args, budget, context,
|
|
4699
|
+
const returned = await invokeBuiltinClosure(operation, args, budget, context, iterator2);
|
|
4699
4700
|
if (asyncProtocol && wrapper.awaitValue !== void 0)
|
|
4700
4701
|
return resumeAwait({ kind: "result" }, () => wrapper.awaitValue(returned, { kind: "result" }));
|
|
4701
4702
|
const result = asyncProtocol ? await awaitSandboxValue(returned, signal, budget, context) : returned;
|
|
@@ -4707,11 +4708,11 @@ function guestIterator(iterator, next, asyncProtocol, budget, context, signal) {
|
|
|
4707
4708
|
resumeAwait,
|
|
4708
4709
|
...asyncProtocol ? { asyncProtocol: true } : {},
|
|
4709
4710
|
asynchronous: true,
|
|
4710
|
-
retainedValue: [
|
|
4711
|
-
snapshot: () => ({ kind: "guest", value:
|
|
4711
|
+
retainedValue: [iterator2, next],
|
|
4712
|
+
snapshot: () => ({ kind: "guest", value: iterator2, next, async: asyncProtocol }),
|
|
4712
4713
|
next: (...args) => invoke(next, args),
|
|
4713
4714
|
getOperation: async (method) => {
|
|
4714
|
-
const operation = method === "next" ? next : await context.getProperty(
|
|
4715
|
+
const operation = method === "next" ? next : await context.getProperty(iterator2, method);
|
|
4715
4716
|
return method !== "next" && (operation === void 0 || operation === null) ? void 0 : (...args) => invoke(operation, args);
|
|
4716
4717
|
},
|
|
4717
4718
|
readResultProperty: async (result, property) => ({
|
|
@@ -4720,8 +4721,8 @@ function guestIterator(iterator, next, asyncProtocol, budget, context, signal) {
|
|
|
4720
4721
|
};
|
|
4721
4722
|
return wrapper;
|
|
4722
4723
|
}
|
|
4723
|
-
async function readIteratorResult(
|
|
4724
|
-
return
|
|
4724
|
+
async function readIteratorResult(iterator2, result, property) {
|
|
4725
|
+
return iterator2.readResultProperty === void 0 ? { value: result[property] } : iterator2.readResultProperty(result, property);
|
|
4725
4726
|
}
|
|
4726
4727
|
function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
4727
4728
|
if (isSandboxGenerator(value) && value.async) {
|
|
@@ -4733,20 +4734,20 @@ function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
|
4733
4734
|
return nativeAsyncIterator(value, method, signal);
|
|
4734
4735
|
}
|
|
4735
4736
|
}
|
|
4736
|
-
const
|
|
4737
|
-
return
|
|
4737
|
+
const iterator2 = getSandboxIterator(value, budget, context);
|
|
4738
|
+
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
4738
4739
|
}
|
|
4739
4740
|
function nativeAsyncIterator(value, method, signal) {
|
|
4740
4741
|
if (typeof method !== "function") throw new TypeError("Async iterator method must be callable.");
|
|
4741
|
-
const
|
|
4742
|
-
if (typeof
|
|
4742
|
+
const iterator2 = Reflect.apply(method, value, []);
|
|
4743
|
+
if (typeof iterator2 !== "object" && typeof iterator2 !== "function" || iterator2 === null) {
|
|
4743
4744
|
throw new TypeError("Async iterator must be an object.");
|
|
4744
4745
|
}
|
|
4745
|
-
const next =
|
|
4746
|
+
const next = iterator2.next;
|
|
4746
4747
|
const invoke = async (operation, args) => {
|
|
4747
4748
|
if (typeof operation !== "function")
|
|
4748
4749
|
throw new TypeError("Async iterator operation must be callable.");
|
|
4749
|
-
const pending = Promise.resolve(Reflect.apply(operation,
|
|
4750
|
+
const pending = Promise.resolve(Reflect.apply(operation, iterator2, args)).then((result2) => ({
|
|
4750
4751
|
result: result2
|
|
4751
4752
|
}));
|
|
4752
4753
|
const { result } = await awaitWithSignal(pending, signal);
|
|
@@ -4767,42 +4768,42 @@ function nativeAsyncIterator(value, method, signal) {
|
|
|
4767
4768
|
retainedValue: value,
|
|
4768
4769
|
next: (...args) => invoke(next, args),
|
|
4769
4770
|
get return() {
|
|
4770
|
-
const operation =
|
|
4771
|
+
const operation = iterator2.return;
|
|
4771
4772
|
return operation === void 0 || operation === null ? void 0 : (...args) => invoke(operation, args);
|
|
4772
4773
|
},
|
|
4773
4774
|
get throw() {
|
|
4774
|
-
const operation =
|
|
4775
|
+
const operation = iterator2.throw;
|
|
4775
4776
|
return operation === void 0 || operation === null ? void 0 : (...args) => invoke(operation, args);
|
|
4776
4777
|
}
|
|
4777
4778
|
};
|
|
4778
4779
|
}
|
|
4779
|
-
function asyncFromSyncIterator(
|
|
4780
|
+
function asyncFromSyncIterator(iterator2, budget, signal, context) {
|
|
4780
4781
|
const resumeAwait = async (state, value) => {
|
|
4781
4782
|
if (state.kind !== "value") throw new TypeError("Invalid async-from-sync await state.");
|
|
4782
4783
|
try {
|
|
4783
4784
|
return { done: state.done, value: await value() };
|
|
4784
4785
|
} catch (error) {
|
|
4785
4786
|
if (isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
4786
|
-
if (state.closeOnReject) await closeIterator(
|
|
4787
|
+
if (state.closeOnReject) await closeIterator(iterator2, true);
|
|
4787
4788
|
throw error;
|
|
4788
4789
|
}
|
|
4789
4790
|
};
|
|
4790
4791
|
const invoke = async (method, args) => {
|
|
4791
|
-
const operation =
|
|
4792
|
+
const operation = iterator2.getOperation === void 0 ? iterator2[method] : await iterator2.getOperation(method);
|
|
4792
4793
|
if (operation === void 0) {
|
|
4793
4794
|
if (method === "throw") {
|
|
4794
|
-
await closeIterator(
|
|
4795
|
+
await closeIterator(iterator2);
|
|
4795
4796
|
throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
4796
4797
|
}
|
|
4797
4798
|
return { done: true, value: args[0] };
|
|
4798
4799
|
}
|
|
4799
4800
|
const returned = operation(...args);
|
|
4800
|
-
const result =
|
|
4801
|
+
const result = iterator2.generator || iterator2.asynchronous ? await returned : returned;
|
|
4801
4802
|
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
4802
4803
|
throw new TypeError("Iterator result must be an object.");
|
|
4803
4804
|
}
|
|
4804
|
-
const done = Boolean((await readIteratorResult(
|
|
4805
|
-
const resultValue = (await readIteratorResult(
|
|
4805
|
+
const done = Boolean((await readIteratorResult(iterator2, result, "done")).value);
|
|
4806
|
+
const resultValue = (await readIteratorResult(iterator2, result, "value")).value;
|
|
4806
4807
|
if (wrapper.awaitValue !== void 0) {
|
|
4807
4808
|
const state = { kind: "value", done, closeOnReject: !done && method !== "return" };
|
|
4808
4809
|
return resumeAwait(state, () => wrapper.awaitValue(resultValue, state));
|
|
@@ -4811,17 +4812,17 @@ function asyncFromSyncIterator(iterator, budget, signal, context) {
|
|
|
4811
4812
|
return { done, value: await awaitSandboxValue(resultValue, signal, budget, context) };
|
|
4812
4813
|
} catch (error) {
|
|
4813
4814
|
if (isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
4814
|
-
if (!done && method !== "return") await closeIterator(
|
|
4815
|
+
if (!done && method !== "return") await closeIterator(iterator2, true);
|
|
4815
4816
|
throw error;
|
|
4816
4817
|
}
|
|
4817
4818
|
};
|
|
4818
4819
|
const wrapper = {
|
|
4819
4820
|
resumeAwait,
|
|
4820
4821
|
asyncProtocol: true,
|
|
4821
|
-
snapshotIndex:
|
|
4822
|
-
snapshot: () => ({ kind: "async-from-sync", inner:
|
|
4822
|
+
snapshotIndex: iterator2.snapshotIndex,
|
|
4823
|
+
snapshot: () => ({ kind: "async-from-sync", inner: iterator2.snapshot?.() ?? { kind: "unsupported" } }),
|
|
4823
4824
|
get retainedValue() {
|
|
4824
|
-
return
|
|
4825
|
+
return iterator2.retainedValue;
|
|
4825
4826
|
},
|
|
4826
4827
|
next: (...args) => invoke("next", args),
|
|
4827
4828
|
return: (...args) => invoke("return", args),
|
|
@@ -4829,12 +4830,12 @@ function asyncFromSyncIterator(iterator, budget, signal, context) {
|
|
|
4829
4830
|
};
|
|
4830
4831
|
return wrapper;
|
|
4831
4832
|
}
|
|
4832
|
-
async function closeIterator(
|
|
4833
|
+
async function closeIterator(iterator2, preserveThrow = false, awaitResult = suspendJob) {
|
|
4833
4834
|
try {
|
|
4834
|
-
const close =
|
|
4835
|
+
const close = iterator2.getOperation === void 0 ? iterator2.return : await iterator2.getOperation("return");
|
|
4835
4836
|
if (close === void 0) return;
|
|
4836
4837
|
const returned = close();
|
|
4837
|
-
const result =
|
|
4838
|
+
const result = iterator2.asyncProtocol ? iterator2.awaitValue === void 0 ? await awaitResult(Promise.resolve(returned)) : await returned : iterator2.generator || iterator2.asynchronous ? await returned : returned;
|
|
4838
4839
|
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
4839
4840
|
throw new TypeError("Iterator return result must be an object.");
|
|
4840
4841
|
}
|
|
@@ -4847,7 +4848,7 @@ function getSandboxIterator(value, budget, context) {
|
|
|
4847
4848
|
if (isSandboxBox(value) && typeof boxedValue(value) === "string") {
|
|
4848
4849
|
const primitive = boxedValue(value);
|
|
4849
4850
|
let text;
|
|
4850
|
-
let
|
|
4851
|
+
let iterator3;
|
|
4851
4852
|
let initialized;
|
|
4852
4853
|
return {
|
|
4853
4854
|
asynchronous: true,
|
|
@@ -4858,11 +4859,11 @@ function getSandboxIterator(value, budget, context) {
|
|
|
4858
4859
|
initialized ??= Promise.resolve(sandboxString(value, budget ?? new Budget(), context)).then(
|
|
4859
4860
|
(converted) => {
|
|
4860
4861
|
text = converted;
|
|
4861
|
-
|
|
4862
|
+
iterator3 = syncIterator(converted[Symbol.iterator]());
|
|
4862
4863
|
}
|
|
4863
4864
|
);
|
|
4864
4865
|
await initialized;
|
|
4865
|
-
return
|
|
4866
|
+
return iterator3.next();
|
|
4866
4867
|
}
|
|
4867
4868
|
};
|
|
4868
4869
|
}
|
|
@@ -4904,12 +4905,12 @@ function getSandboxIterator(value, budget, context) {
|
|
|
4904
4905
|
return generatorObjectIterator(value, budget, context);
|
|
4905
4906
|
}
|
|
4906
4907
|
if (typeof value === "string") {
|
|
4907
|
-
const
|
|
4908
|
+
const iterator3 = value[Symbol.iterator]();
|
|
4908
4909
|
let index = 0;
|
|
4909
4910
|
return {
|
|
4910
4911
|
snapshot: () => ({ kind: "builtin", value, index }),
|
|
4911
4912
|
next: () => {
|
|
4912
|
-
const result =
|
|
4913
|
+
const result = iterator3.next();
|
|
4913
4914
|
if (!result.done) index++;
|
|
4914
4915
|
return result;
|
|
4915
4916
|
}
|
|
@@ -4934,11 +4935,11 @@ function getSandboxIterator(value, budget, context) {
|
|
|
4934
4935
|
if (typeof iteratorMethod !== "function") {
|
|
4935
4936
|
throw new TypeError("Iterator method must be callable.");
|
|
4936
4937
|
}
|
|
4937
|
-
const
|
|
4938
|
-
if (typeof
|
|
4938
|
+
const iterator2 = Reflect.apply(iteratorMethod, value, []);
|
|
4939
|
+
if (typeof iterator2 !== "object" && typeof iterator2 !== "function" || iterator2 === null) {
|
|
4939
4940
|
throw new TypeError("Iterator must be an object.");
|
|
4940
4941
|
}
|
|
4941
|
-
return syncIterator(
|
|
4942
|
+
return syncIterator(iterator2);
|
|
4942
4943
|
}
|
|
4943
4944
|
function arrayIterator(value, context, budget, initialIndex = 0) {
|
|
4944
4945
|
let index = initialIndex;
|
|
@@ -4954,13 +4955,13 @@ function arrayIterator(value, context, budget, initialIndex = 0) {
|
|
|
4954
4955
|
};
|
|
4955
4956
|
}
|
|
4956
4957
|
function collectionIterator(collection, value) {
|
|
4957
|
-
let
|
|
4958
|
+
let iterator2 = collection[Symbol.iterator]();
|
|
4958
4959
|
let exhausted = false;
|
|
4959
4960
|
const adapter = {
|
|
4960
4961
|
...syncIterator({
|
|
4961
4962
|
next: () => {
|
|
4962
4963
|
if (exhausted) return { done: true, value: void 0 };
|
|
4963
|
-
const result =
|
|
4964
|
+
const result = iterator2.next();
|
|
4964
4965
|
exhausted = result.done === true;
|
|
4965
4966
|
return result;
|
|
4966
4967
|
}
|
|
@@ -4968,10 +4969,10 @@ function collectionIterator(collection, value) {
|
|
|
4968
4969
|
snapshotIndex: () => {
|
|
4969
4970
|
if (exhausted) return collection.size;
|
|
4970
4971
|
let remaining = 0;
|
|
4971
|
-
while (!
|
|
4972
|
+
while (!iterator2.next().done) remaining += 1;
|
|
4972
4973
|
const index = collection.size - remaining;
|
|
4973
|
-
|
|
4974
|
-
for (let skipped = 0; skipped < index; skipped += 1)
|
|
4974
|
+
iterator2 = collection[Symbol.iterator]();
|
|
4975
|
+
for (let skipped = 0; skipped < index; skipped += 1) iterator2.next();
|
|
4975
4976
|
return index;
|
|
4976
4977
|
}
|
|
4977
4978
|
};
|
|
@@ -4991,9 +4992,9 @@ function guestProtocolAdapter(value, budget, context, asyncProtocol, signal) {
|
|
|
4991
4992
|
};
|
|
4992
4993
|
let resolved;
|
|
4993
4994
|
let pending;
|
|
4994
|
-
const initialize = () => pending ??= acquireSandboxIterator(value, budget, bridge, asyncProtocol, signal).then((
|
|
4995
|
-
if (
|
|
4996
|
-
return resolved =
|
|
4995
|
+
const initialize = () => pending ??= acquireSandboxIterator(value, budget, bridge, asyncProtocol, signal).then((iterator2) => {
|
|
4996
|
+
if (iterator2 === void 0) throw new TypeError("Value does not provide an iterator protocol.");
|
|
4997
|
+
return resolved = iterator2;
|
|
4997
4998
|
});
|
|
4998
4999
|
return {
|
|
4999
5000
|
asynchronous: true,
|
|
@@ -5004,19 +5005,19 @@ function guestProtocolAdapter(value, budget, context, asyncProtocol, signal) {
|
|
|
5004
5005
|
snapshot: () => resolved?.snapshot?.() ?? { kind: "unsupported" },
|
|
5005
5006
|
next: async (...args) => (await initialize()).next(...args),
|
|
5006
5007
|
getOperation: async (method) => {
|
|
5007
|
-
const
|
|
5008
|
-
return
|
|
5008
|
+
const iterator2 = await initialize();
|
|
5009
|
+
return iterator2.getOperation === void 0 ? iterator2[method] : iterator2.getOperation(method);
|
|
5009
5010
|
},
|
|
5010
5011
|
readResultProperty: async (result, property) => readIteratorResult(await initialize(), result, property)
|
|
5011
5012
|
};
|
|
5012
5013
|
}
|
|
5013
5014
|
function generatorObjectIterator(generator, budget, context) {
|
|
5014
|
-
const
|
|
5015
|
-
if (context?.getProperty === void 0) return
|
|
5015
|
+
const iterator2 = generatorIterator(generator, budget, context);
|
|
5016
|
+
if (context?.getProperty === void 0) return iterator2;
|
|
5016
5017
|
return {
|
|
5017
|
-
...
|
|
5018
|
+
...iterator2,
|
|
5018
5019
|
getOperation: async (method) => {
|
|
5019
|
-
if (method === "next" || !hasExplicitSandboxPrototype(generator) && getSandboxPropertyDescriptor(generator, method, budget) === void 0) return
|
|
5020
|
+
if (method === "next" || !hasExplicitSandboxPrototype(generator) && getSandboxPropertyDescriptor(generator, method, budget) === void 0) return iterator2[method];
|
|
5020
5021
|
const operation = await context.getProperty(generator, method);
|
|
5021
5022
|
if (operation === void 0 || operation === null) return void 0;
|
|
5022
5023
|
if (!isSandboxClosure(operation)) throw new TypeError("Iterator operation must be callable.");
|
|
@@ -5059,12 +5060,12 @@ function generatorIterator(generator, budget, context) {
|
|
|
5059
5060
|
throw: (error) => request("throw", error)
|
|
5060
5061
|
};
|
|
5061
5062
|
}
|
|
5062
|
-
function syncIterator(
|
|
5063
|
-
const next =
|
|
5063
|
+
function syncIterator(iterator2) {
|
|
5064
|
+
const next = iterator2.next;
|
|
5064
5065
|
const invoke = (method, args) => {
|
|
5065
|
-
const leaveRunning = enterRunningState(
|
|
5066
|
+
const leaveRunning = enterRunningState(iterator2);
|
|
5066
5067
|
try {
|
|
5067
|
-
return Reflect.apply(method,
|
|
5068
|
+
return Reflect.apply(method, iterator2, args);
|
|
5068
5069
|
} finally {
|
|
5069
5070
|
leaveRunning();
|
|
5070
5071
|
}
|
|
@@ -5072,13 +5073,13 @@ function syncIterator(iterator) {
|
|
|
5072
5073
|
return {
|
|
5073
5074
|
next: (...args) => invoke(next, args),
|
|
5074
5075
|
get return() {
|
|
5075
|
-
const method =
|
|
5076
|
+
const method = iterator2.return;
|
|
5076
5077
|
if (method === void 0 || method === null) return void 0;
|
|
5077
5078
|
if (typeof method !== "function") throw new TypeError("Iterator return must be callable.");
|
|
5078
5079
|
return (...args) => invoke(method, args);
|
|
5079
5080
|
},
|
|
5080
5081
|
get throw() {
|
|
5081
|
-
const method =
|
|
5082
|
+
const method = iterator2.throw;
|
|
5082
5083
|
if (method === void 0 || method === null) return void 0;
|
|
5083
5084
|
if (typeof method !== "function") throw new TypeError("Iterator throw must be callable.");
|
|
5084
5085
|
return (...args) => invoke(method, args);
|
|
@@ -5201,7 +5202,7 @@ async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
|
5201
5202
|
const saved = pattern.nodeId === void 0 ? void 0 : context.restoredPatternState?.(pattern.nodeId);
|
|
5202
5203
|
if (saved !== void 0 && saved.kind !== "array-pattern") throw new TypeError("Invalid array pattern continuation.");
|
|
5203
5204
|
const callContext = context.callContext ?? { stack: [], thisValue: void 0, getProperty: context.getProperty };
|
|
5204
|
-
const
|
|
5205
|
+
const iterator2 = saved === void 0 ? await acquireSandboxIterator(
|
|
5205
5206
|
value,
|
|
5206
5207
|
budget,
|
|
5207
5208
|
context.callContext ?? {
|
|
@@ -5210,16 +5211,16 @@ async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
|
5210
5211
|
getProperty: context.getProperty
|
|
5211
5212
|
}
|
|
5212
5213
|
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, budget, callContext) : saved.iterator;
|
|
5213
|
-
if (
|
|
5214
|
+
if (iterator2 === void 0) throw new TypeError("Array destructuring requires an iterable.");
|
|
5214
5215
|
let done = saved?.done ?? false;
|
|
5215
5216
|
const next = async (readValue = true) => {
|
|
5216
5217
|
if (done) return { value: void 0 };
|
|
5217
5218
|
try {
|
|
5218
|
-
const result = await
|
|
5219
|
+
const result = await iterator2.next();
|
|
5219
5220
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
5220
5221
|
throw new TypeError("Iterator result must be an object.");
|
|
5221
|
-
done = Boolean((await readIteratorResult(
|
|
5222
|
-
return done || !readValue ? { value: void 0 } : await readIteratorResult(
|
|
5222
|
+
done = Boolean((await readIteratorResult(iterator2, result, "done")).value);
|
|
5223
|
+
return done || !readValue ? { value: void 0 } : await readIteratorResult(iterator2, result, "value");
|
|
5223
5224
|
} catch (error) {
|
|
5224
5225
|
done = true;
|
|
5225
5226
|
throw error;
|
|
@@ -5229,7 +5230,7 @@ async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
|
5229
5230
|
let continuation;
|
|
5230
5231
|
const release = retainValues(budget, () => [
|
|
5231
5232
|
value,
|
|
5232
|
-
|
|
5233
|
+
iterator2.retainedValue,
|
|
5233
5234
|
retained,
|
|
5234
5235
|
continuation?.current,
|
|
5235
5236
|
continuation?.referenceObject,
|
|
@@ -5250,9 +5251,9 @@ async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
|
5250
5251
|
index,
|
|
5251
5252
|
done,
|
|
5252
5253
|
current: void 0,
|
|
5253
|
-
iterator
|
|
5254
|
+
iterator: iterator2
|
|
5254
5255
|
};
|
|
5255
|
-
if (resuming) Object.assign(state, saved, { iterator });
|
|
5256
|
+
if (resuming) Object.assign(state, saved, { iterator: iterator2 });
|
|
5256
5257
|
continuation = state;
|
|
5257
5258
|
const elementContext = pattern.nodeId === void 0 ? context : context.withPatternState?.(pattern.nodeId, state) ?? context;
|
|
5258
5259
|
const binding = resuming && saved.phase === "binding" ? await bindPattern(
|
|
@@ -5295,18 +5296,18 @@ async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
|
5295
5296
|
if (!binding.ok) {
|
|
5296
5297
|
if (!done) {
|
|
5297
5298
|
done = true;
|
|
5298
|
-
await closeIterator(
|
|
5299
|
+
await closeIterator(iterator2, binding.result.kind === "throw");
|
|
5299
5300
|
}
|
|
5300
5301
|
return binding;
|
|
5301
5302
|
}
|
|
5302
5303
|
}
|
|
5303
5304
|
if (!done) {
|
|
5304
5305
|
done = true;
|
|
5305
|
-
await closeIterator(
|
|
5306
|
+
await closeIterator(iterator2);
|
|
5306
5307
|
}
|
|
5307
5308
|
return { ok: true };
|
|
5308
5309
|
} catch (error) {
|
|
5309
|
-
if (!done && !isFatalSandboxError(error)) await closeIterator(
|
|
5310
|
+
if (!done && !isFatalSandboxError(error)) await closeIterator(iterator2, true);
|
|
5310
5311
|
throw error;
|
|
5311
5312
|
} finally {
|
|
5312
5313
|
release();
|
|
@@ -5503,6 +5504,63 @@ var DeferredFunction = class {
|
|
|
5503
5504
|
}
|
|
5504
5505
|
};
|
|
5505
5506
|
|
|
5507
|
+
// packages/safe-js/src/interp/deferred-arguments.ts
|
|
5508
|
+
var freeze3 = Object.freeze;
|
|
5509
|
+
var setPrototypeOf2 = Object.setPrototypeOf;
|
|
5510
|
+
var indexString = String;
|
|
5511
|
+
var iterator = Symbol.iterator;
|
|
5512
|
+
var DeferredArguments = class {
|
|
5513
|
+
root = freeze3({ __proto__: null });
|
|
5514
|
+
eligible;
|
|
5515
|
+
#value;
|
|
5516
|
+
#resolving = false;
|
|
5517
|
+
#snapshot;
|
|
5518
|
+
constructor(values) {
|
|
5519
|
+
const captured = setPrototypeOf2([], null);
|
|
5520
|
+
const references = setPrototypeOf2([], null);
|
|
5521
|
+
let units = 8;
|
|
5522
|
+
let eligible = true;
|
|
5523
|
+
for (let index = 0; index < values.length; index++) {
|
|
5524
|
+
const value = values[index];
|
|
5525
|
+
captured[index] = value;
|
|
5526
|
+
units += 1 + indexString(index).length;
|
|
5527
|
+
if (typeof value === "string") units += value.length;
|
|
5528
|
+
else if (typeof value === "bigint") eligible = false;
|
|
5529
|
+
else if (typeof value === "symbol" || typeof value === "object" && value !== null)
|
|
5530
|
+
references[references.length] = value;
|
|
5531
|
+
}
|
|
5532
|
+
this.eligible = eligible;
|
|
5533
|
+
this.#snapshot = freeze3({
|
|
5534
|
+
values: freeze3(captured),
|
|
5535
|
+
references: freeze3(references),
|
|
5536
|
+
length: values.length,
|
|
5537
|
+
units,
|
|
5538
|
+
iterator
|
|
5539
|
+
});
|
|
5540
|
+
scopeDataRoots.set(this.root, {
|
|
5541
|
+
arguments: {
|
|
5542
|
+
read: () => this.#value,
|
|
5543
|
+
capture: () => this.#snapshot
|
|
5544
|
+
}
|
|
5545
|
+
});
|
|
5546
|
+
}
|
|
5547
|
+
resolve() {
|
|
5548
|
+
if (this.#value !== void 0) return this.#value;
|
|
5549
|
+
if (this.#resolving) throw new TypeError("Cannot reenter deferred arguments initialization.");
|
|
5550
|
+
this.#resolving = true;
|
|
5551
|
+
try {
|
|
5552
|
+
const snapshot = this.#snapshot;
|
|
5553
|
+
const value = createSandboxArguments(snapshot.values);
|
|
5554
|
+
if (value.length !== snapshot.length) value.length = snapshot.length;
|
|
5555
|
+
this.#value = value;
|
|
5556
|
+
this.#snapshot = void 0;
|
|
5557
|
+
return value;
|
|
5558
|
+
} finally {
|
|
5559
|
+
this.#resolving = false;
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
5562
|
+
};
|
|
5563
|
+
|
|
5506
5564
|
// packages/safe-js/src/modules/empty-environment.ts
|
|
5507
5565
|
var environments = /* @__PURE__ */ new WeakSet();
|
|
5508
5566
|
var has = WeakSet.prototype.has.bind(environments);
|
|
@@ -5516,24 +5574,25 @@ function registerImmutableEmptyModuleEnvironment(environment) {
|
|
|
5516
5574
|
// packages/safe-js/src/interp/scope-binding-storage.ts
|
|
5517
5575
|
var NativeMap = Map;
|
|
5518
5576
|
var NativeSet = Set;
|
|
5519
|
-
var
|
|
5520
|
-
var
|
|
5521
|
-
var
|
|
5522
|
-
var
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5525
|
-
var
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
var
|
|
5529
|
-
var
|
|
5530
|
-
var
|
|
5531
|
-
var
|
|
5532
|
-
var
|
|
5533
|
-
|
|
5577
|
+
var mapGet = Function.prototype.call.bind(Map.prototype.get);
|
|
5578
|
+
var mapSet = Function.prototype.call.bind(Map.prototype.set);
|
|
5579
|
+
var mapHas = Function.prototype.call.bind(Map.prototype.has);
|
|
5580
|
+
var mapDelete = Function.prototype.call.bind(Map.prototype.delete);
|
|
5581
|
+
var mapEntries2 = Function.prototype.call.bind(Map.prototype.entries);
|
|
5582
|
+
var mapValues = Function.prototype.call.bind(Map.prototype.values);
|
|
5583
|
+
var mapSize2 = Function.prototype.call.bind(
|
|
5584
|
+
Object.getOwnPropertyDescriptor(Map.prototype, "size").get
|
|
5585
|
+
);
|
|
5586
|
+
var mapNext = Function.prototype.call.bind(Object.getPrototypeOf((/* @__PURE__ */ new Map()).values()).next);
|
|
5587
|
+
var setAdd = Function.prototype.call.bind(Set.prototype.add);
|
|
5588
|
+
var setHas = Function.prototype.call.bind(Set.prototype.has);
|
|
5589
|
+
var setDelete = Function.prototype.call.bind(Set.prototype.delete);
|
|
5590
|
+
var setValues2 = Function.prototype.call.bind(Set.prototype.values);
|
|
5591
|
+
var setNext = Function.prototype.call.bind(Object.getPrototypeOf((/* @__PURE__ */ new Set()).values()).next);
|
|
5592
|
+
function privateIterator(iterator2, next) {
|
|
5534
5593
|
return {
|
|
5535
5594
|
next() {
|
|
5536
|
-
return
|
|
5595
|
+
return next(iterator2);
|
|
5537
5596
|
},
|
|
5538
5597
|
[Symbol.iterator]() {
|
|
5539
5598
|
return this;
|
|
@@ -5543,25 +5602,25 @@ function privateIterator(iterator, next) {
|
|
|
5543
5602
|
var ScopeBindingMap = class {
|
|
5544
5603
|
#data = new NativeMap();
|
|
5545
5604
|
get size() {
|
|
5546
|
-
return
|
|
5605
|
+
return mapSize2(this.#data);
|
|
5547
5606
|
}
|
|
5548
5607
|
get(key) {
|
|
5549
|
-
return
|
|
5608
|
+
return mapGet(this.#data, key);
|
|
5550
5609
|
}
|
|
5551
5610
|
has(key) {
|
|
5552
|
-
return
|
|
5611
|
+
return mapHas(this.#data, key);
|
|
5553
5612
|
}
|
|
5554
5613
|
set(key, value) {
|
|
5555
|
-
|
|
5614
|
+
mapSet(this.#data, key, value);
|
|
5556
5615
|
}
|
|
5557
5616
|
delete(key) {
|
|
5558
|
-
return
|
|
5617
|
+
return mapDelete(this.#data, key);
|
|
5559
5618
|
}
|
|
5560
5619
|
entries() {
|
|
5561
|
-
return privateIterator(
|
|
5620
|
+
return privateIterator(mapEntries2(this.#data), mapNext);
|
|
5562
5621
|
}
|
|
5563
5622
|
values() {
|
|
5564
|
-
return privateIterator(
|
|
5623
|
+
return privateIterator(mapValues(this.#data), mapNext);
|
|
5565
5624
|
}
|
|
5566
5625
|
[Symbol.iterator]() {
|
|
5567
5626
|
return this.entries();
|
|
@@ -5570,16 +5629,16 @@ var ScopeBindingMap = class {
|
|
|
5570
5629
|
var ScopeBindingSet = class {
|
|
5571
5630
|
#data = new NativeSet();
|
|
5572
5631
|
has(value) {
|
|
5573
|
-
return
|
|
5632
|
+
return setHas(this.#data, value);
|
|
5574
5633
|
}
|
|
5575
5634
|
add(value) {
|
|
5576
|
-
|
|
5635
|
+
setAdd(this.#data, value);
|
|
5577
5636
|
}
|
|
5578
5637
|
delete(value) {
|
|
5579
|
-
return
|
|
5638
|
+
return setDelete(this.#data, value);
|
|
5580
5639
|
}
|
|
5581
5640
|
[Symbol.iterator]() {
|
|
5582
|
-
return privateIterator(
|
|
5641
|
+
return privateIterator(setValues2(this.#data), setNext);
|
|
5583
5642
|
}
|
|
5584
5643
|
};
|
|
5585
5644
|
|
|
@@ -5889,6 +5948,16 @@ var Scope = class _Scope {
|
|
|
5889
5948
|
this.#bindings.get(name).deferred = new DeferredFunction(create3, collect);
|
|
5890
5949
|
this.#bindingDataRoot = void 0;
|
|
5891
5950
|
}
|
|
5951
|
+
declareDeferredArguments(name, kind, values) {
|
|
5952
|
+
const deferred2 = new DeferredArguments(values);
|
|
5953
|
+
if (!deferred2.eligible) {
|
|
5954
|
+
this.declare(name, kind, deferred2.resolve());
|
|
5955
|
+
return;
|
|
5956
|
+
}
|
|
5957
|
+
this.declare(name, kind, void 0);
|
|
5958
|
+
this.#bindings.get(name).deferred = deferred2;
|
|
5959
|
+
this.#bindingDataRoot = void 0;
|
|
5960
|
+
}
|
|
5892
5961
|
declareAlias(name, target) {
|
|
5893
5962
|
if (this.#bindings.has(name)) throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
5894
5963
|
const binding = this.#bindings.get(target);
|
|
@@ -6383,7 +6452,7 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
6383
6452
|
const construction = context.functionEnvironment?.construction;
|
|
6384
6453
|
const constructionState = construction === void 0 ? void 0 : constructionStates.get(construction);
|
|
6385
6454
|
const construct = node.type !== "ArrowFunctionExpression" && !(node.type === "FunctionExpression" && node.method === true) && !node.async ? async (args, callContext) => {
|
|
6386
|
-
const thisValue = {};
|
|
6455
|
+
const thisValue = createIntrinsicObject({});
|
|
6387
6456
|
const newTarget = callContext?.newTarget ?? closure;
|
|
6388
6457
|
const prototype = callContext?.getProperty === void 0 ? getGuestFunctionProperty(newTarget, "prototype") : await callContext.getProperty(newTarget, "prototype");
|
|
6389
6458
|
const selected = typeof prototype === "object" && prototype !== null ? prototype : getFunctionRealmPrototype(newTarget, "Object", getSandboxPrototype(thisValue, context.budget));
|
|
@@ -6765,7 +6834,12 @@ async function createClosureScope(node, args, thisValue, context, evaluateNode2)
|
|
|
6765
6834
|
else scope.declare("this", "const", thisValue);
|
|
6766
6835
|
if (needsArguments) {
|
|
6767
6836
|
context.budget.allocateArrayLength(args.length);
|
|
6768
|
-
if (!mapped)
|
|
6837
|
+
if (!mapped) {
|
|
6838
|
+
const kind = functionStrictness.get(node) === false && !separateParameters ? "var" : "let";
|
|
6839
|
+
if (context.scriptScope !== void 0 || context.moduleInstantiated !== void 0)
|
|
6840
|
+
scope.declareDeferredArguments("arguments", kind, args);
|
|
6841
|
+
else scope.declare("arguments", kind, createSandboxArguments(args));
|
|
6842
|
+
}
|
|
6769
6843
|
}
|
|
6770
6844
|
await construction?.initialize(scope);
|
|
6771
6845
|
}
|
|
@@ -8584,13 +8658,14 @@ function functionString(value) {
|
|
|
8584
8658
|
|
|
8585
8659
|
// packages/safe-js/src/interp/bound-function.ts
|
|
8586
8660
|
function createBoundFunction(state, name, length, callClosure) {
|
|
8661
|
+
const retainedValues = () => [state.target, state.thisValue, ...state.args, bound.name];
|
|
8587
8662
|
const bound = createSandboxClosure({
|
|
8588
8663
|
guest: true,
|
|
8589
8664
|
sandbox: true,
|
|
8590
8665
|
name,
|
|
8591
8666
|
length,
|
|
8592
8667
|
boundTarget: state.target,
|
|
8593
|
-
retainedValues
|
|
8668
|
+
retainedValues,
|
|
8594
8669
|
call: (args, context) => callClosure(state.target, [...state.args, ...args], context?.stack ?? [], state.thisValue, void 0, void 0, context),
|
|
8595
8670
|
...state.target.construct === void 0 ? {} : {
|
|
8596
8671
|
construct: (args, context) => callClosure(
|
|
@@ -8604,6 +8679,12 @@ function createBoundFunction(state, name, length, callClosure) {
|
|
|
8604
8679
|
)
|
|
8605
8680
|
}
|
|
8606
8681
|
});
|
|
8682
|
+
registerClosureCaptureCollector(bound, retainedValues, (append) => {
|
|
8683
|
+
append(state.target);
|
|
8684
|
+
append(state.thisValue);
|
|
8685
|
+
for (const value of state.args) append(value);
|
|
8686
|
+
append(bound.name);
|
|
8687
|
+
});
|
|
8607
8688
|
boundFunctionStates.set(bound, state);
|
|
8608
8689
|
return bound;
|
|
8609
8690
|
}
|
|
@@ -16802,21 +16883,21 @@ async function allocateTypedArrayInput(source, budget, Native, context) {
|
|
|
16802
16883
|
invokeClosure: context?.invokeClosure ?? ((callee, values2, receiver, construct, newTarget) => invokeBuiltinClosure(callee, values2, budget, callerContext, receiver, construct, newTarget))
|
|
16803
16884
|
};
|
|
16804
16885
|
const values = [];
|
|
16805
|
-
let
|
|
16886
|
+
let iterator2;
|
|
16806
16887
|
let current;
|
|
16807
16888
|
let result;
|
|
16808
|
-
const release = retainValues(budget, () => [source, values,
|
|
16889
|
+
const release = retainValues(budget, () => [source, values, iterator2?.retainedValue, current, result]);
|
|
16809
16890
|
const checkData = createDataCheckpoint(budget, bridge);
|
|
16810
16891
|
try {
|
|
16811
|
-
|
|
16892
|
+
iterator2 = await acquireSandboxIterator(source, budget, bridge);
|
|
16812
16893
|
let length;
|
|
16813
|
-
if (
|
|
16894
|
+
if (iterator2 !== void 0) {
|
|
16814
16895
|
while (true) {
|
|
16815
16896
|
budget.visitNode();
|
|
16816
|
-
const next = await
|
|
16897
|
+
const next = await iterator2.next();
|
|
16817
16898
|
if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
|
|
16818
|
-
if ((await readIteratorResult(
|
|
16819
|
-
current = (await readIteratorResult(
|
|
16899
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
16900
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
16820
16901
|
budget.allocateArrayLength(values.length + 1);
|
|
16821
16902
|
values.push(current);
|
|
16822
16903
|
checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
|
|
@@ -16832,7 +16913,7 @@ async function allocateTypedArrayInput(source, budget, Native, context) {
|
|
|
16832
16913
|
checkData(result, 0, true);
|
|
16833
16914
|
for (let index = 0; index < length; index++) {
|
|
16834
16915
|
budget.visitNode();
|
|
16835
|
-
current =
|
|
16916
|
+
current = iterator2 === void 0 ? await bridge.getProperty(source, String(index)) : values[index];
|
|
16836
16917
|
result[index] = await typedArrayElement(current, Native, budget, bridge);
|
|
16837
16918
|
}
|
|
16838
16919
|
return result;
|
|
@@ -16911,21 +16992,21 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
|
16911
16992
|
};
|
|
16912
16993
|
let result;
|
|
16913
16994
|
let current;
|
|
16914
|
-
let
|
|
16995
|
+
let iterator2;
|
|
16915
16996
|
const values = [];
|
|
16916
|
-
const release = retainValues(budget, () => [target, result, current,
|
|
16997
|
+
const release = retainValues(budget, () => [target, result, current, iterator2?.retainedValue, values, ...args]);
|
|
16917
16998
|
const checkData = createDataCheckpoint(budget, context);
|
|
16918
16999
|
const read = (key) => context?.getProperty === void 0 ? getSandboxDataProperty(source, key, budget) : context.getProperty(source, key);
|
|
16919
17000
|
try {
|
|
16920
|
-
|
|
17001
|
+
iterator2 = await acquireSandboxIterator(source, budget, context);
|
|
16921
17002
|
let length;
|
|
16922
|
-
if (
|
|
17003
|
+
if (iterator2 !== void 0) {
|
|
16923
17004
|
while (true) {
|
|
16924
17005
|
budget.visitNode();
|
|
16925
|
-
const next = await
|
|
17006
|
+
const next = await iterator2.next();
|
|
16926
17007
|
if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
|
|
16927
|
-
if ((await readIteratorResult(
|
|
16928
|
-
current = (await readIteratorResult(
|
|
17008
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
17009
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
16929
17010
|
budget.allocateArrayLength(values.length + 1);
|
|
16930
17011
|
values.push(current);
|
|
16931
17012
|
checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
|
|
@@ -16941,7 +17022,7 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
|
16941
17022
|
checkData(result, 0, true);
|
|
16942
17023
|
for (let index = 0; index < length; index++) {
|
|
16943
17024
|
budget.visitNode();
|
|
16944
|
-
current =
|
|
17025
|
+
current = iterator2 === void 0 ? await read(String(index)) : values[index];
|
|
16945
17026
|
if (mapper !== void 0)
|
|
16946
17027
|
current = await invokeBuiltinClosure(mapper, [current, index], budget, context, receiver);
|
|
16947
17028
|
result[index] = await typedArrayElement(current, typedArrayStorage(result).Native, budget, context);
|
|
@@ -17831,6 +17912,13 @@ async function callStringPadding(value, method, args, budget, context) {
|
|
|
17831
17912
|
}
|
|
17832
17913
|
|
|
17833
17914
|
// packages/safe-js/src/interp/methods/string.ts
|
|
17915
|
+
var nativeStringPrototype = String.prototype;
|
|
17916
|
+
var nativeObjectPrototype = Object.prototype;
|
|
17917
|
+
var nativeStringSplit = nativeStringPrototype.split;
|
|
17918
|
+
var nativeSplitSymbol = Symbol.split;
|
|
17919
|
+
var nativeSplitDescriptor = Object.getOwnPropertyDescriptor;
|
|
17920
|
+
var nativeSplitPrototype = Object.getPrototypeOf;
|
|
17921
|
+
var nativeSplitApply = Reflect.apply;
|
|
17834
17922
|
var stringMethodLengths = {
|
|
17835
17923
|
...Object.fromEntries(Object.entries(stringHtmlMethods).map(([name, [, attribute]]) => [name, attribute === "" ? 0 : 1])),
|
|
17836
17924
|
at: 1,
|
|
@@ -17923,7 +18011,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
17923
18011
|
if (value === null || value === void 0)
|
|
17924
18012
|
throw new TypeError(`String#${methodName} requires a non-null receiver.`);
|
|
17925
18013
|
const fallback = (coercePattern = false) => {
|
|
17926
|
-
const
|
|
18014
|
+
const apply = (string) => {
|
|
17927
18015
|
if (coercePattern && (methodName === "match" || methodName === "matchAll" || methodName === "search"))
|
|
17928
18016
|
return callStringPattern(string, methodName, args[0], budget, parent, context);
|
|
17929
18017
|
const useRegex = isSandboxRegex(args[0]) && !coercePattern;
|
|
@@ -17932,7 +18020,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
17932
18020
|
if (methodName === "split") return callSplit(string, args, budget, useRegex, parent, context);
|
|
17933
18021
|
return callStringMethodBody(string, methodName, args, budget, parent, context);
|
|
17934
18022
|
};
|
|
17935
|
-
return typeof value === "string" ?
|
|
18023
|
+
return typeof value === "string" ? apply(value) : Promise.resolve(sandboxString(value, budget, context)).then(apply);
|
|
17936
18024
|
};
|
|
17937
18025
|
const symbol = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "matchAll" ? Symbol.matchAll : methodName === "replace" || methodName === "replaceAll" ? Symbol.replace : methodName === "split" ? Symbol.split : void 0;
|
|
17938
18026
|
const pattern = args[0];
|
|
@@ -18001,14 +18089,14 @@ function callStringMethodBody(value, methodName, args, budget, parent, context)
|
|
|
18001
18089
|
return callStringPadding(value, methodName, args, budget, context);
|
|
18002
18090
|
}
|
|
18003
18091
|
if (methodName === "repeat" || methodName === "at" || methodName === "charAt" || methodName === "charCodeAt" || methodName === "codePointAt") {
|
|
18004
|
-
const
|
|
18092
|
+
const apply = (number2) => {
|
|
18005
18093
|
const result = value[methodName](number2);
|
|
18006
18094
|
return typeof result === "string" ? budget.allocateString(result) : result;
|
|
18007
18095
|
};
|
|
18008
18096
|
const number = sandboxNumber(args[0], budget, context);
|
|
18009
|
-
if (typeof number === "number") return
|
|
18097
|
+
if (typeof number === "number") return apply(number);
|
|
18010
18098
|
const release = retainValues(budget, () => [value, ...args]);
|
|
18011
|
-
return number.then(
|
|
18099
|
+
return number.then(apply).finally(release);
|
|
18012
18100
|
}
|
|
18013
18101
|
if (methodName === "isWellFormed") {
|
|
18014
18102
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -18433,7 +18521,26 @@ function splitNormalized(value, separator, limit, budget, parent) {
|
|
|
18433
18521
|
operation.release();
|
|
18434
18522
|
}
|
|
18435
18523
|
}
|
|
18436
|
-
const
|
|
18524
|
+
const arrayLimit = budget.limits.arrayLength;
|
|
18525
|
+
if (arrayLimit !== void 0) {
|
|
18526
|
+
let count = 1;
|
|
18527
|
+
if (separator === "") {
|
|
18528
|
+
count = Math.min(value.length, limit);
|
|
18529
|
+
} else if (separator !== void 0) {
|
|
18530
|
+
let offset = 0;
|
|
18531
|
+
while (count < limit && count <= arrayLimit) {
|
|
18532
|
+
const index = value.indexOf(separator, offset);
|
|
18533
|
+
if (index === -1) break;
|
|
18534
|
+
count++;
|
|
18535
|
+
offset = index + separator.length;
|
|
18536
|
+
}
|
|
18537
|
+
}
|
|
18538
|
+
budget.allocateArrayLength(count);
|
|
18539
|
+
}
|
|
18540
|
+
const split = value.split;
|
|
18541
|
+
const owned = runResources.getStore()?.nativeDataResults !== true && split === nativeStringSplit && (separator === void 0 || nativeSplitPrototype(nativeStringPrototype) === nativeObjectPrototype && nativeSplitPrototype(nativeObjectPrototype) === null && nativeSplitDescriptor(nativeStringPrototype, nativeSplitSymbol) === void 0 && nativeSplitDescriptor(nativeObjectPrototype, nativeSplitSymbol) === void 0);
|
|
18542
|
+
const nativeResult = nativeSplitApply(split, value, [separator, limit]);
|
|
18543
|
+
const result = owned ? createIntrinsicArray(nativeResult) : nativeResult;
|
|
18437
18544
|
budget.allocateArrayLength(result.length);
|
|
18438
18545
|
for (const part of result) budget.allocateString(part);
|
|
18439
18546
|
return result;
|
|
@@ -20795,8 +20902,8 @@ function serializeArguments(value, serializeValue) {
|
|
|
20795
20902
|
writable: descriptor.writable === true
|
|
20796
20903
|
};
|
|
20797
20904
|
}
|
|
20798
|
-
const
|
|
20799
|
-
if (
|
|
20905
|
+
const iterator2 = Object.getOwnPropertyDescriptor(value, Symbol.iterator);
|
|
20906
|
+
if (iterator2 !== void 0 && iterator2.value !== Array.prototype.values) {
|
|
20800
20907
|
throw new TypeError("Cannot snapshot a replaced arguments iterator.");
|
|
20801
20908
|
}
|
|
20802
20909
|
const names = Object.getOwnPropertyNames(value);
|
|
@@ -20804,10 +20911,10 @@ function serializeArguments(value, serializeValue) {
|
|
|
20804
20911
|
kind: "arguments",
|
|
20805
20912
|
extensible: Object.isExtensible(value),
|
|
20806
20913
|
lengthBeforeCallee: names.includes("length") && names.indexOf("length") < names.indexOf("callee"),
|
|
20807
|
-
iterator:
|
|
20808
|
-
configurable:
|
|
20809
|
-
enumerable:
|
|
20810
|
-
writable:
|
|
20914
|
+
iterator: iterator2 === void 0 ? null : {
|
|
20915
|
+
configurable: iterator2.configurable === true,
|
|
20916
|
+
enumerable: iterator2.enumerable === true,
|
|
20917
|
+
writable: iterator2.writable === true
|
|
20811
20918
|
},
|
|
20812
20919
|
properties
|
|
20813
20920
|
};
|
|
@@ -21819,6 +21926,10 @@ var hostErrorMetadata = {
|
|
|
21819
21926
|
syscall: "string"
|
|
21820
21927
|
};
|
|
21821
21928
|
var awaitedHostOperations = /* @__PURE__ */ new WeakSet();
|
|
21929
|
+
var budgetedHostOperations = /* @__PURE__ */ new WeakMap();
|
|
21930
|
+
function declareBudgetedHostOperation(operation, invoke) {
|
|
21931
|
+
budgetedHostOperations.set(operation, invoke);
|
|
21932
|
+
}
|
|
21822
21933
|
var hostOperationPolicies = /* @__PURE__ */ new WeakMap();
|
|
21823
21934
|
var hostOperationReplayHandlers = /* @__PURE__ */ new WeakMap();
|
|
21824
21935
|
function declareHostOperation(operation, policy, options = {}) {
|
|
@@ -21898,6 +22009,8 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21898
22009
|
});
|
|
21899
22010
|
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
21900
22011
|
const hostArgs = captured?.args ?? copyArguments(args);
|
|
22012
|
+
const budgetedOperation = budgetedHostOperations.get(callable);
|
|
22013
|
+
const callOperation = () => budgetedOperation === void 0 ? Reflect.apply(callable, void 0, hostArgs) : budgetedOperation(hostArgs, options.budget);
|
|
21901
22014
|
const hostCalls = options.hostCalls;
|
|
21902
22015
|
const operation = options.operation ?? bindingName;
|
|
21903
22016
|
const moduleId = options.moduleId ?? "<bindings>";
|
|
@@ -21906,13 +22019,13 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21906
22019
|
let result2;
|
|
21907
22020
|
if (options.realm !== void 0) {
|
|
21908
22021
|
try {
|
|
21909
|
-
result2 = options.realm.invoke(callable,
|
|
22022
|
+
result2 = options.realm.invoke(callable, callOperation);
|
|
21910
22023
|
} catch (error) {
|
|
21911
22024
|
captured.rollback();
|
|
21912
22025
|
throw error;
|
|
21913
22026
|
}
|
|
21914
22027
|
} else {
|
|
21915
|
-
result2 = invokeHostCallback(
|
|
22028
|
+
result2 = invokeHostCallback(callOperation, options);
|
|
21916
22029
|
}
|
|
21917
22030
|
if (awaitResult) {
|
|
21918
22031
|
return wrapHostPromiseWithSignal(Promise.resolve(result2), options.signal).then((value2) => copyHostResultToSandbox(value2, stackFrames, options), (error) => {
|
|
@@ -22000,7 +22113,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
22000
22113
|
const result = executeHostCall(
|
|
22001
22114
|
issued.record,
|
|
22002
22115
|
issued.restored,
|
|
22003
|
-
() => invokeHostCallback(
|
|
22116
|
+
() => invokeHostCallback(callOperation, options),
|
|
22004
22117
|
stackFrames,
|
|
22005
22118
|
options,
|
|
22006
22119
|
context?.span,
|
|
@@ -23041,7 +23154,7 @@ function readStringProperty(value, key) {
|
|
|
23041
23154
|
return descriptor !== void 0 && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
|
|
23042
23155
|
}
|
|
23043
23156
|
function copyFunctionProperties(callable, stackFrames, options, state, path) {
|
|
23044
|
-
const properties = {};
|
|
23157
|
+
const properties = createIntrinsicObject({});
|
|
23045
23158
|
const metadata = /* @__PURE__ */ new Map();
|
|
23046
23159
|
for (const key of Object.getOwnPropertyNames(callable)) {
|
|
23047
23160
|
const descriptor = Object.getOwnPropertyDescriptor(callable, key);
|
|
@@ -23294,8 +23407,8 @@ function callGeneratorMethod(target, method, value, budget, context, async) {
|
|
|
23294
23407
|
const result = (async () => {
|
|
23295
23408
|
if (!isSandboxGenerator(target) || target.async === true !== async)
|
|
23296
23409
|
throw new TypeError(`${async ? "AsyncGenerator" : "Generator"}.${method} requires a matching generator receiver.`);
|
|
23297
|
-
const
|
|
23298
|
-
const result2 = await
|
|
23410
|
+
const iterator2 = generatorIterator(target, budget, context);
|
|
23411
|
+
const result2 = await iterator2[method](value);
|
|
23299
23412
|
return allocateProducedSandboxValue(result2, budget);
|
|
23300
23413
|
})();
|
|
23301
23414
|
return async ? createSandboxPromise(result) : result;
|
|
@@ -23484,9 +23597,9 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23484
23597
|
const candidate = await readErrorProperty(newTarget, "prototype", budget, context);
|
|
23485
23598
|
const prototype = candidate !== null && typeof candidate === "object" ? candidate : getFunctionRealmPrototype(newTarget, name, errorPrototypes.get(budget).get(name));
|
|
23486
23599
|
let error;
|
|
23487
|
-
let
|
|
23600
|
+
let iterator2;
|
|
23488
23601
|
const errors = [];
|
|
23489
|
-
const release = retainValues(budget, () => [prototype, error,
|
|
23602
|
+
const release = retainValues(budget, () => [prototype, error, iterator2?.retainedValue, ...errors, ...args]);
|
|
23490
23603
|
try {
|
|
23491
23604
|
const message = name === "SuppressedError" ? args[2] : name === "AggregateError" ? args[1] : args[0];
|
|
23492
23605
|
const options = name === "SuppressedError" ? void 0 : name === "AggregateError" ? args[2] : args[1];
|
|
@@ -23506,15 +23619,15 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23506
23619
|
if (name === "AggregateError") {
|
|
23507
23620
|
const errorsPrototype = getSandboxPrototype(errors, budget);
|
|
23508
23621
|
if (errorsPrototype !== null) setSandboxPrototype(errors, errorsPrototype, budget);
|
|
23509
|
-
|
|
23510
|
-
if (
|
|
23622
|
+
iterator2 = context === void 0 ? getSandboxIterator(args[0], budget) : await acquireSandboxIterator(args[0], budget, context);
|
|
23623
|
+
if (iterator2 === void 0) throw new TypeError("AggregateError errors must be iterable.");
|
|
23511
23624
|
while (true) {
|
|
23512
23625
|
budget.visitNode();
|
|
23513
|
-
const result = await
|
|
23626
|
+
const result = await iterator2.next();
|
|
23514
23627
|
if (result === null || typeof result !== "object") throw new TypeError("Iterator result must be an object.");
|
|
23515
|
-
if ((await readIteratorResult(
|
|
23628
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
23516
23629
|
budget.allocateArrayLength(errors.length + 1);
|
|
23517
|
-
errors.push((await readIteratorResult(
|
|
23630
|
+
errors.push((await readIteratorResult(iterator2, result, "value")).value);
|
|
23518
23631
|
}
|
|
23519
23632
|
Object.defineProperty(error, "errors", { value: errors, writable: true, configurable: true });
|
|
23520
23633
|
}
|
|
@@ -24046,7 +24159,7 @@ async function evaluateArrayExpression(node, context) {
|
|
|
24046
24159
|
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
24047
24160
|
if (restored !== void 0 && (restored.kind !== "array" || !Array.isArray(restored.values)))
|
|
24048
24161
|
throw new TypeError("Invalid array expression continuation.");
|
|
24049
|
-
const values = restored?.kind === "array" ? restored.values : [];
|
|
24162
|
+
const values = restored?.kind === "array" ? restored.values : context.scriptScope !== void 0 || context.moduleInstantiated !== void 0 ? createIntrinsicArray() : [];
|
|
24050
24163
|
if (restored === void 0) {
|
|
24051
24164
|
const prototype = getSandboxPrototype(values, context.budget);
|
|
24052
24165
|
if (prototype !== null) setSandboxPrototype(values, prototype, context.budget);
|
|
@@ -25170,13 +25283,13 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25170
25283
|
let resumeCurrent = saved !== void 0 && saved.phase !== "next";
|
|
25171
25284
|
let resumeNext = saved?.phase === "next";
|
|
25172
25285
|
let index = saved?.index ?? consumeRestoredLoopIterationIndex(node, context);
|
|
25173
|
-
const
|
|
25174
|
-
if (
|
|
25286
|
+
const iterator2 = saved === void 0 ? await acquireSandboxIterator(value, context.budget, createCoercionContext(context), node.await, context.signal) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, context.budget, createCoercionContext(context), context.signal) : saved.iterator;
|
|
25287
|
+
if (iterator2 === void 0) {
|
|
25175
25288
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
25176
25289
|
}
|
|
25177
25290
|
const nextIteration = async () => {
|
|
25178
|
-
if ((context.asyncFunction || context.asyncGeneratorFrame !== void 0) && node.await &&
|
|
25179
|
-
|
|
25291
|
+
if ((context.asyncFunction || context.asyncGeneratorFrame !== void 0) && node.await && iterator2.resumeAwait !== void 0 && node.nodeId !== void 0) {
|
|
25292
|
+
iterator2.awaitValue = (awaited, awaitState) => suspendAsyncFunctionValue(awaited, node, {
|
|
25180
25293
|
...context,
|
|
25181
25294
|
generatorExpressionStates: new Map([
|
|
25182
25295
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25189,7 +25302,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25189
25302
|
current: void 0,
|
|
25190
25303
|
index,
|
|
25191
25304
|
scope: context.scope,
|
|
25192
|
-
iterator
|
|
25305
|
+
iterator: iterator2
|
|
25193
25306
|
}]
|
|
25194
25307
|
])
|
|
25195
25308
|
}, void 0, createCoercionContext(context));
|
|
@@ -25197,14 +25310,14 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25197
25310
|
if (resumeNext) {
|
|
25198
25311
|
resumeNext = false;
|
|
25199
25312
|
if (saved?.awaitState === void 0) throw new TypeError("Missing iterator await continuation.");
|
|
25200
|
-
return await
|
|
25313
|
+
return await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25201
25314
|
}
|
|
25202
|
-
return await
|
|
25315
|
+
return await iterator2.next();
|
|
25203
25316
|
} finally {
|
|
25204
|
-
delete
|
|
25317
|
+
delete iterator2.awaitValue;
|
|
25205
25318
|
}
|
|
25206
25319
|
}
|
|
25207
|
-
const pending = Promise.resolve(
|
|
25320
|
+
const pending = Promise.resolve(iterator2.next());
|
|
25208
25321
|
if (!node.await) return pending;
|
|
25209
25322
|
context.onSuspend?.();
|
|
25210
25323
|
const leaveAwait = context.budget.enterAwait();
|
|
@@ -25215,16 +25328,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25215
25328
|
}
|
|
25216
25329
|
};
|
|
25217
25330
|
const completion = context.evalCompletion ? new StatementCompletion(context.budget, true) : void 0;
|
|
25218
|
-
const releaseIterator = retainValues(context.budget, () => [value,
|
|
25331
|
+
const releaseIterator = retainValues(context.budget, () => [value, iterator2.retainedValue]);
|
|
25219
25332
|
const closeLoopIterator = async (completion2) => {
|
|
25220
25333
|
const preserveThrow = completion2.kind === "throw";
|
|
25221
|
-
if (!context.asyncFunction && context.asyncGeneratorFrame === void 0 || !node.await ||
|
|
25222
|
-
await closeIterator(
|
|
25334
|
+
if (!context.asyncFunction && context.asyncGeneratorFrame === void 0 || !node.await || iterator2.resumeAwait === void 0 || node.nodeId === void 0 || completion2.kind === "error") {
|
|
25335
|
+
await closeIterator(iterator2, preserveThrow);
|
|
25223
25336
|
return;
|
|
25224
25337
|
}
|
|
25225
25338
|
const { node: ignoredNode, stackFrames, ...metadata } = completion2;
|
|
25226
25339
|
const closeCompletion = { ...metadata, ...stackFrames === void 0 ? {} : { stackFrames: [...stackFrames] } };
|
|
25227
|
-
|
|
25340
|
+
iterator2.awaitValue = (awaited, awaitState) => suspendAsyncFunctionValue(awaited, node, {
|
|
25228
25341
|
...context,
|
|
25229
25342
|
generatorExpressionStates: new Map([
|
|
25230
25343
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25238,19 +25351,19 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25238
25351
|
current: void 0,
|
|
25239
25352
|
index,
|
|
25240
25353
|
scope: context.scope,
|
|
25241
|
-
iterator
|
|
25354
|
+
iterator: iterator2
|
|
25242
25355
|
}]
|
|
25243
25356
|
])
|
|
25244
25357
|
}, void 0, createCoercionContext(context));
|
|
25245
25358
|
try {
|
|
25246
25359
|
if (saved?.phase === "close" && context.generatorResume?.completed !== true) {
|
|
25247
25360
|
if (saved.awaitState === void 0) throw new TypeError("Missing iterator close continuation.");
|
|
25248
|
-
await
|
|
25249
|
-
} else await closeIterator(
|
|
25361
|
+
await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25362
|
+
} else await closeIterator(iterator2, preserveThrow);
|
|
25250
25363
|
} catch (error) {
|
|
25251
25364
|
if (!preserveThrow || isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
25252
25365
|
} finally {
|
|
25253
|
-
delete
|
|
25366
|
+
delete iterator2.awaitValue;
|
|
25254
25367
|
}
|
|
25255
25368
|
};
|
|
25256
25369
|
try {
|
|
@@ -25265,7 +25378,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25265
25378
|
if (typeof skippedIteration !== "object" || skippedIteration === null) {
|
|
25266
25379
|
throw new TypeError("Iterator result must be an object.");
|
|
25267
25380
|
}
|
|
25268
|
-
if ((await readIteratorResult(
|
|
25381
|
+
if ((await readIteratorResult(iterator2, skippedIteration, "done")).value) {
|
|
25269
25382
|
return completion?.normal() ?? normalEmptyResult();
|
|
25270
25383
|
}
|
|
25271
25384
|
}
|
|
@@ -25277,16 +25390,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25277
25390
|
if (typeof iteration !== "object" || iteration === null) {
|
|
25278
25391
|
throw new TypeError("Iterator result must be an object.");
|
|
25279
25392
|
}
|
|
25280
|
-
if ((await readIteratorResult(
|
|
25393
|
+
if ((await readIteratorResult(iterator2, iteration, "done")).value) {
|
|
25281
25394
|
context.activeLoopIterations.delete(nodeId);
|
|
25282
25395
|
return completion?.normal() ?? normalEmptyResult();
|
|
25283
25396
|
}
|
|
25284
|
-
const nextValue = (await readIteratorResult(
|
|
25397
|
+
const nextValue = (await readIteratorResult(iterator2, iteration, "value")).value;
|
|
25285
25398
|
context.activeLoopIterations.set(
|
|
25286
25399
|
nodeId,
|
|
25287
|
-
|
|
25400
|
+
iterator2.snapshotIndex === void 0 ? index : {
|
|
25288
25401
|
get index() {
|
|
25289
|
-
return
|
|
25402
|
+
return iterator2.snapshotIndex();
|
|
25290
25403
|
},
|
|
25291
25404
|
values: [value, nextValue]
|
|
25292
25405
|
}
|
|
@@ -25297,7 +25410,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25297
25410
|
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
25298
25411
|
generatorExpressionStates: new Map([
|
|
25299
25412
|
...context.generatorExpressionStates ?? [],
|
|
25300
|
-
[node.nodeId, { kind: "for-of-iterator", phase, async: node.await === true, value, current: nextValue, index, scope, iterator }]
|
|
25413
|
+
[node.nodeId, { kind: "for-of-iterator", phase, async: node.await === true, value, current: nextValue, index, scope, iterator: iterator2 }]
|
|
25301
25414
|
])
|
|
25302
25415
|
}
|
|
25303
25416
|
});
|
|
@@ -25797,14 +25910,14 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25797
25910
|
return argument;
|
|
25798
25911
|
}
|
|
25799
25912
|
if (context.generatorResume?.completed === true) context.generatorResume = void 0;
|
|
25800
|
-
const
|
|
25913
|
+
const iterator2 = saved === void 0 ? await acquireSandboxIterator(
|
|
25801
25914
|
argument.value,
|
|
25802
25915
|
context.budget,
|
|
25803
25916
|
createCoercionContext(context),
|
|
25804
25917
|
context.asyncGenerator,
|
|
25805
25918
|
context.signal
|
|
25806
25919
|
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, context.budget, createCoercionContext(context), context.signal) : saved.iterator;
|
|
25807
|
-
if (
|
|
25920
|
+
if (iterator2 === void 0) {
|
|
25808
25921
|
throw new TypeError(`${String(argument.value)} is not a supported iterable`);
|
|
25809
25922
|
}
|
|
25810
25923
|
const state = {
|
|
@@ -25812,21 +25925,21 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25812
25925
|
async: context.asyncGenerator === true,
|
|
25813
25926
|
value: argument.value,
|
|
25814
25927
|
current: saved?.current,
|
|
25815
|
-
iterator,
|
|
25928
|
+
iterator: iterator2,
|
|
25816
25929
|
...saved?.phase === void 0 ? {} : { phase: saved.phase, awaitState: saved.awaitState, completion: saved.completion }
|
|
25817
25930
|
};
|
|
25818
25931
|
if (node.nodeId !== void 0) context = {
|
|
25819
25932
|
...context,
|
|
25820
25933
|
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
25821
25934
|
};
|
|
25822
|
-
if (context.asyncGeneratorFrame !== void 0 &&
|
|
25823
|
-
|
|
25935
|
+
if (context.asyncGeneratorFrame !== void 0 && iterator2.resumeAwait !== void 0)
|
|
25936
|
+
iterator2.awaitValue = (value, awaitState) => {
|
|
25824
25937
|
state.awaitState = awaitState;
|
|
25825
25938
|
return suspendAsyncFunctionValue(value, node, context, void 0, createCoercionContext(context));
|
|
25826
25939
|
};
|
|
25827
25940
|
const releaseIterator = retainValues(context.budget, () => [
|
|
25828
25941
|
argument.value,
|
|
25829
|
-
|
|
25942
|
+
iterator2.retainedValue,
|
|
25830
25943
|
state.current
|
|
25831
25944
|
]);
|
|
25832
25945
|
try {
|
|
@@ -25851,20 +25964,20 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25851
25964
|
let result;
|
|
25852
25965
|
if (resumeOperation) {
|
|
25853
25966
|
resumeOperation = false;
|
|
25854
|
-
if (
|
|
25967
|
+
if (iterator2.resumeAwait === void 0 || iterator2.awaitValue === void 0 || saved?.awaitState === void 0)
|
|
25855
25968
|
throw new TypeError("Missing delegated iterator await continuation.");
|
|
25856
|
-
result = await
|
|
25969
|
+
result = await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25857
25970
|
if (saved.phase === "close") throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25858
25971
|
context.generatorResume = void 0;
|
|
25859
25972
|
} else {
|
|
25860
|
-
const iteratorMethod =
|
|
25973
|
+
const iteratorMethod = iterator2.getOperation === void 0 ? iterator2[method] : await iterator2.getOperation(method);
|
|
25861
25974
|
if (iteratorMethod === void 0) {
|
|
25862
25975
|
if (completion.type === "throw") {
|
|
25863
|
-
if (
|
|
25976
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25864
25977
|
state.phase = "close";
|
|
25865
25978
|
state.completion = completion;
|
|
25866
25979
|
}
|
|
25867
|
-
await closeIterator(
|
|
25980
|
+
await closeIterator(iterator2, false, context.asyncGeneratorFrame === void 0 ? suspendJob : async (pending) => await suspendAsyncFunctionValue(createSandboxPromise(pending), node, context, void 0, createCoercionContext(context)));
|
|
25868
25981
|
throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25869
25982
|
}
|
|
25870
25983
|
if (context.asyncGenerator && completion.type === "return") {
|
|
@@ -25875,12 +25988,12 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25875
25988
|
}
|
|
25876
25989
|
return generatorCompletionResult(completion);
|
|
25877
25990
|
}
|
|
25878
|
-
if (
|
|
25991
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25879
25992
|
state.phase = "await";
|
|
25880
25993
|
state.completion = completion;
|
|
25881
25994
|
}
|
|
25882
25995
|
const pendingResult = Promise.resolve(iteratorMethod(completion.value));
|
|
25883
|
-
result = context.asyncGeneratorFrame !== void 0 &&
|
|
25996
|
+
result = context.asyncGeneratorFrame !== void 0 && iterator2.awaitValue === void 0 ? await suspendAsyncFunctionValue(createSandboxPromise(pendingResult), node, context, void 0, createCoercionContext(context)) : await (context.asyncGenerator && iterator2.awaitValue === void 0 ? suspendJob(pendingResult) : pendingResult);
|
|
25884
25997
|
}
|
|
25885
25998
|
delete state.phase;
|
|
25886
25999
|
delete state.awaitState;
|
|
@@ -25888,8 +26001,8 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25888
26001
|
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
25889
26002
|
throw new TypeError("Iterator result must be an object.");
|
|
25890
26003
|
}
|
|
25891
|
-
const done = (await readIteratorResult(
|
|
25892
|
-
const value = done || context.asyncGenerator ? (await readIteratorResult(
|
|
26004
|
+
const done = (await readIteratorResult(iterator2, result, "done")).value;
|
|
26005
|
+
const value = done || context.asyncGenerator ? (await readIteratorResult(iterator2, result, "value")).value : result;
|
|
25893
26006
|
if (done) {
|
|
25894
26007
|
if (completion.type === "return") {
|
|
25895
26008
|
return generatorCompletionResult({ type: "return", value });
|
|
@@ -25910,7 +26023,7 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25910
26023
|
context.generatorResume = void 0;
|
|
25911
26024
|
}
|
|
25912
26025
|
} finally {
|
|
25913
|
-
delete
|
|
26026
|
+
delete iterator2.awaitValue;
|
|
25914
26027
|
releaseIterator();
|
|
25915
26028
|
}
|
|
25916
26029
|
}
|
|
@@ -27378,23 +27491,23 @@ async function evaluateSpreadElement(node, context) {
|
|
|
27378
27491
|
result: value
|
|
27379
27492
|
};
|
|
27380
27493
|
}
|
|
27381
|
-
const
|
|
27382
|
-
if (
|
|
27494
|
+
const iterator2 = await acquireSandboxIterator(value.value, context.budget, createCoercionContext(context));
|
|
27495
|
+
if (iterator2 === void 0) {
|
|
27383
27496
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
27384
27497
|
}
|
|
27385
27498
|
const spreadValues = [];
|
|
27386
|
-
const release = retainValues(context.budget, () => [value.value,
|
|
27499
|
+
const release = retainValues(context.budget, () => [value.value, iterator2.retainedValue, ...spreadValues]);
|
|
27387
27500
|
try {
|
|
27388
27501
|
while (true) {
|
|
27389
|
-
const next = await
|
|
27502
|
+
const next = await iterator2.next();
|
|
27390
27503
|
if (typeof next !== "object" || next === null) {
|
|
27391
27504
|
throw new TypeError("Iterator result must be an object.");
|
|
27392
27505
|
}
|
|
27393
|
-
const done =
|
|
27506
|
+
const done = iterator2.readResultProperty === void 0 ? next.done : (await readIteratorResult(iterator2, next, "done")).value;
|
|
27394
27507
|
if (done) {
|
|
27395
27508
|
break;
|
|
27396
27509
|
}
|
|
27397
|
-
const item =
|
|
27510
|
+
const item = iterator2.readResultProperty === void 0 ? next.value : (await readIteratorResult(iterator2, next, "value")).value;
|
|
27398
27511
|
spreadValues.push(item);
|
|
27399
27512
|
context.budget.allocateArrayLength(spreadValues.length);
|
|
27400
27513
|
}
|
|
@@ -27994,16 +28107,16 @@ function createGroupBy(budget, keyMode) {
|
|
|
27994
28107
|
call: async ([items, callback], context) => {
|
|
27995
28108
|
if (items === null || items === void 0) throw new TypeError("groupBy requires an iterable.");
|
|
27996
28109
|
if (!isSandboxClosure(callback)) throw new TypeError("groupBy requires a callable callback.");
|
|
27997
|
-
const
|
|
27998
|
-
if (
|
|
28110
|
+
const iterator2 = context === void 0 ? getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context);
|
|
28111
|
+
if (iterator2 === void 0) throw new TypeError("groupBy requires an iterable.");
|
|
27999
28112
|
const groups = createSandboxMap([]);
|
|
28000
28113
|
let value;
|
|
28001
28114
|
let key;
|
|
28002
|
-
const release = retainValues(budget, () => [groups, callback,
|
|
28115
|
+
const release = retainValues(budget, () => [groups, callback, iterator2.retainedValue, value, key]);
|
|
28003
28116
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
28004
28117
|
const closeOnThrow = async (error) => {
|
|
28005
28118
|
try {
|
|
28006
|
-
await closeIterator(
|
|
28119
|
+
await closeIterator(iterator2, true);
|
|
28007
28120
|
} catch (closeError) {
|
|
28008
28121
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28009
28122
|
}
|
|
@@ -28018,9 +28131,9 @@ function createGroupBy(budget, keyMode) {
|
|
|
28018
28131
|
} catch (error) {
|
|
28019
28132
|
await closeOnThrow(error);
|
|
28020
28133
|
}
|
|
28021
|
-
const next = await
|
|
28022
|
-
if ((await readIteratorResult(
|
|
28023
|
-
value = (await readIteratorResult(
|
|
28134
|
+
const next = await iterator2.next();
|
|
28135
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
28136
|
+
value = (await readIteratorResult(iterator2, next, "value")).value;
|
|
28024
28137
|
try {
|
|
28025
28138
|
key = await invokeBuiltinClosure(callback, [value, index], budget, context, void 0);
|
|
28026
28139
|
if (keyMode === "property") key = await toPropertyKey(key, budget, context);
|
|
@@ -28204,9 +28317,9 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
28204
28317
|
const receiver = context?.thisValue;
|
|
28205
28318
|
if (receiver === null || receiver === void 0) throw new TypeError("String iterator requires a receiver.");
|
|
28206
28319
|
const input = await sandboxString(receiver, budget, context);
|
|
28207
|
-
const
|
|
28208
|
-
setSandboxPrototype(
|
|
28209
|
-
return
|
|
28320
|
+
const iterator2 = restoreSandboxStringIterator({ input, index: 0 });
|
|
28321
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28322
|
+
return iterator2;
|
|
28210
28323
|
}
|
|
28211
28324
|
}), writable: true, configurable: true });
|
|
28212
28325
|
}
|
|
@@ -28394,7 +28507,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28394
28507
|
sandbox: true,
|
|
28395
28508
|
call: async ([prototype, descriptors2], context) => {
|
|
28396
28509
|
if (prototype !== null) objectProperties(prototype);
|
|
28397
|
-
const value =
|
|
28510
|
+
const value = createIntrinsicObject();
|
|
28398
28511
|
setSandboxPrototype(value, prototype, options.budget);
|
|
28399
28512
|
if (descriptors2 !== void 0) {
|
|
28400
28513
|
await definePropertiesFromObject(value, descriptors2, options.budget, context);
|
|
@@ -28414,19 +28527,19 @@ function createObjectArrayGlobals(options) {
|
|
|
28414
28527
|
fromEntries: createSandboxClosure({
|
|
28415
28528
|
sandbox: true,
|
|
28416
28529
|
call: ([value], context) => {
|
|
28417
|
-
if (context !== void 0) return acquireSandboxIterator(value, options.budget, context).then((
|
|
28418
|
-
if (
|
|
28419
|
-
return objectFromSandboxEntries(value,
|
|
28530
|
+
if (context !== void 0) return acquireSandboxIterator(value, options.budget, context).then((iterator3) => {
|
|
28531
|
+
if (iterator3 === void 0) throw new TypeError("Object.fromEntries requires an iterable.");
|
|
28532
|
+
return objectFromSandboxEntries(value, iterator3, options.budget, context);
|
|
28420
28533
|
});
|
|
28421
|
-
const
|
|
28422
|
-
if (
|
|
28534
|
+
const iterator2 = getSandboxIterator(value, options.budget, context);
|
|
28535
|
+
if (iterator2 === void 0) {
|
|
28423
28536
|
throw new TypeError("Object.fromEntries requires an iterable.");
|
|
28424
28537
|
}
|
|
28425
|
-
if (context === void 0 && !
|
|
28538
|
+
if (context === void 0 && !iterator2.generator && !iterator2.asynchronous) {
|
|
28426
28539
|
const object = allocateProducedSandboxValue(
|
|
28427
28540
|
Object.setPrototypeOf(
|
|
28428
28541
|
Reflect.apply(Object.fromEntries, Object, [
|
|
28429
|
-
{ [Symbol.iterator]: () =>
|
|
28542
|
+
{ [Symbol.iterator]: () => iterator2 }
|
|
28430
28543
|
]),
|
|
28431
28544
|
null
|
|
28432
28545
|
),
|
|
@@ -28436,7 +28549,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28436
28549
|
if (prototype !== null) setSandboxPrototype(object, prototype, options.budget);
|
|
28437
28550
|
return object;
|
|
28438
28551
|
}
|
|
28439
|
-
return objectFromSandboxEntries(value,
|
|
28552
|
+
return objectFromSandboxEntries(value, iterator2, options.budget, context);
|
|
28440
28553
|
},
|
|
28441
28554
|
name: "fromEntries",
|
|
28442
28555
|
length: 1
|
|
@@ -28701,9 +28814,9 @@ function createArrayGlobal(budget) {
|
|
|
28701
28814
|
const receiver = context?.thisValue;
|
|
28702
28815
|
if (receiver === null || receiver === void 0) throw new TypeError("Array iterator method requires a receiver.");
|
|
28703
28816
|
const source = typeof receiver === "object" ? receiver : createSandboxBox(receiver);
|
|
28704
|
-
const
|
|
28705
|
-
setSandboxPrototype(
|
|
28706
|
-
return
|
|
28817
|
+
const iterator2 = restoreSandboxArrayIterator({ source, index: 0, method });
|
|
28818
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28819
|
+
return iterator2;
|
|
28707
28820
|
}
|
|
28708
28821
|
});
|
|
28709
28822
|
Object.defineProperty(prototype, method, { value: closure, writable: true, configurable: true });
|
|
@@ -28822,7 +28935,7 @@ function createArrayGlobal(budget) {
|
|
|
28822
28935
|
installArrayPrototype(budget, prototype, constructor);
|
|
28823
28936
|
return constructor;
|
|
28824
28937
|
}
|
|
28825
|
-
async function objectFromSandboxEntries(items,
|
|
28938
|
+
async function objectFromSandboxEntries(items, iterator2, budget, context) {
|
|
28826
28939
|
const object = /* @__PURE__ */ Object.create(null);
|
|
28827
28940
|
const prototype = getSandboxPrototype(object, budget);
|
|
28828
28941
|
if (prototype !== null) setSandboxPrototype(object, prototype, budget);
|
|
@@ -28833,7 +28946,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28833
28946
|
const retained = {};
|
|
28834
28947
|
budget.setRetainedValues(retained, () => [
|
|
28835
28948
|
items,
|
|
28836
|
-
|
|
28949
|
+
iterator2.retainedValue,
|
|
28837
28950
|
object,
|
|
28838
28951
|
entry,
|
|
28839
28952
|
key,
|
|
@@ -28844,7 +28957,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28844
28957
|
const closeOnThrow = async (error) => {
|
|
28845
28958
|
failure = isCapturedException(error) ? error.reason : error;
|
|
28846
28959
|
try {
|
|
28847
|
-
await closeIterator(
|
|
28960
|
+
await closeIterator(iterator2, true);
|
|
28848
28961
|
} catch (closeError) {
|
|
28849
28962
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28850
28963
|
}
|
|
@@ -28858,12 +28971,12 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28858
28971
|
} catch (error) {
|
|
28859
28972
|
await closeOnThrow(error);
|
|
28860
28973
|
}
|
|
28861
|
-
const result = await
|
|
28974
|
+
const result = await iterator2.next();
|
|
28862
28975
|
if (typeof result !== "object" || result === null) {
|
|
28863
28976
|
throw new TypeError("Iterator result must be an object.");
|
|
28864
28977
|
}
|
|
28865
|
-
if ((await readIteratorResult(
|
|
28866
|
-
entry = (await readIteratorResult(
|
|
28978
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
28979
|
+
entry = (await readIteratorResult(iterator2, result, "value")).value;
|
|
28867
28980
|
try {
|
|
28868
28981
|
if (typeof entry !== "object" || entry === null) {
|
|
28869
28982
|
throw new TypeError("Object.fromEntries requires entry objects.");
|
|
@@ -28953,12 +29066,13 @@ function objectProperties(value, _mutable = false) {
|
|
|
28953
29066
|
return value;
|
|
28954
29067
|
}
|
|
28955
29068
|
function exposePropertyDescriptor(descriptor, budget) {
|
|
28956
|
-
const
|
|
29069
|
+
const properties = "value" in descriptor ? descriptor : {
|
|
28957
29070
|
get: accessorClosure(descriptor.get, budget),
|
|
28958
29071
|
set: accessorClosure(descriptor.set, budget),
|
|
28959
29072
|
enumerable: descriptor.enumerable,
|
|
28960
29073
|
configurable: descriptor.configurable
|
|
28961
29074
|
};
|
|
29075
|
+
const result = runResources.getStore()?.nativeDataResults === true ? properties : createIntrinsicObject(properties);
|
|
28962
29076
|
const prototype = getSandboxPrototype(result, budget);
|
|
28963
29077
|
if (prototype !== null) setSandboxPrototype(result, prototype, budget);
|
|
28964
29078
|
return result;
|
|
@@ -29128,8 +29242,8 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29128
29242
|
const iteratorMethod = observableMethod ? await context.getProperty(items, Symbol.iterator) : void 0;
|
|
29129
29243
|
if (iteratorMethod !== null && iteratorMethod !== void 0 && !isSandboxClosure(iteratorMethod) && typeof iteratorMethod !== "function")
|
|
29130
29244
|
throw new TypeError("Iterator method must be callable.");
|
|
29131
|
-
let
|
|
29132
|
-
const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 :
|
|
29245
|
+
let iterator2 = observableMethod ? void 0 : context === void 0 ? asyncProtocol ? getSandboxAsyncIterator(items, budget) : getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context, asyncProtocol);
|
|
29246
|
+
const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 : iterator2 !== void 0;
|
|
29133
29247
|
const constructor = context?.thisValue;
|
|
29134
29248
|
let result;
|
|
29135
29249
|
let currentValue;
|
|
@@ -29138,9 +29252,9 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29138
29252
|
budget.setRetainedValues(retained, () => [
|
|
29139
29253
|
// Once acquired, a rooted protocol iterator owns the remaining input. Keep
|
|
29140
29254
|
// the original only for array-like reads or implicit unrooted iterators.
|
|
29141
|
-
|
|
29255
|
+
iterator2?.retainedValue === void 0 ? items : void 0,
|
|
29142
29256
|
iteratorMethod,
|
|
29143
|
-
|
|
29257
|
+
iterator2?.retainedValue,
|
|
29144
29258
|
mapFn,
|
|
29145
29259
|
thisValue,
|
|
29146
29260
|
constructor,
|
|
@@ -29152,7 +29266,7 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29152
29266
|
const closeOnThrow = async (error) => {
|
|
29153
29267
|
failure = isCapturedException(error) ? error.reason : error;
|
|
29154
29268
|
try {
|
|
29155
|
-
if (
|
|
29269
|
+
if (iterator2 !== void 0) await closeIterator(iterator2, true);
|
|
29156
29270
|
} catch (closeError) {
|
|
29157
29271
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
29158
29272
|
}
|
|
@@ -29174,23 +29288,23 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29174
29288
|
) : createArrayFromConstructorArgs([length], budget);
|
|
29175
29289
|
checkData(result, 0, true);
|
|
29176
29290
|
if (observableMethod && iterable)
|
|
29177
|
-
|
|
29291
|
+
iterator2 = await getSandboxIteratorFromMethod(items, iteratorMethod, budget, context);
|
|
29178
29292
|
let index = 0;
|
|
29179
|
-
while (
|
|
29293
|
+
while (iterator2 !== void 0 || index < length) {
|
|
29180
29294
|
try {
|
|
29181
29295
|
budget.visitNode();
|
|
29182
|
-
if (
|
|
29296
|
+
if (iterator2 !== void 0 && index >= Number.MAX_SAFE_INTEGER)
|
|
29183
29297
|
throw new TypeError("Array.from input is too long.");
|
|
29184
29298
|
} catch (error) {
|
|
29185
29299
|
await closeOnThrow(error);
|
|
29186
29300
|
}
|
|
29187
|
-
if (
|
|
29188
|
-
const pending = Promise.resolve(
|
|
29301
|
+
if (iterator2 !== void 0) {
|
|
29302
|
+
const pending = Promise.resolve(iterator2.next());
|
|
29189
29303
|
const next = await (asyncProtocol ? awaitAsync(pending) : pending);
|
|
29190
29304
|
if (typeof next !== "object" || next === null)
|
|
29191
29305
|
throw new TypeError("Iterator result must be an object.");
|
|
29192
|
-
if ((await readIteratorResult(
|
|
29193
|
-
currentValue = (await readIteratorResult(
|
|
29306
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
29307
|
+
currentValue = (await readIteratorResult(iterator2, next, "value")).value;
|
|
29194
29308
|
} else {
|
|
29195
29309
|
currentValue = await read(index);
|
|
29196
29310
|
if (asyncProtocol) currentValue = await awaitAsync(awaitSandboxValue(currentValue, void 0, budget, context));
|
|
@@ -30079,17 +30193,17 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30079
30193
|
const promiseResolve = await readPromiseReceiverProperty(constructor, "resolve", prototype, context);
|
|
30080
30194
|
if (!isSandboxClosure(promiseResolve))
|
|
30081
30195
|
throw new TypeError("Promise constructor requires a callable resolve.");
|
|
30082
|
-
const
|
|
30083
|
-
if (
|
|
30084
|
-
const releaseIterator = retainValues(budget, () => [
|
|
30196
|
+
const iterator2 = context === void 0 ? getSandboxIterator(iterable, budget) : await acquireSandboxIterator(iterable, budget, context);
|
|
30197
|
+
if (iterator2 === void 0) throw new TypeError("Promise helpers require an iterable.");
|
|
30198
|
+
const releaseIterator = retainValues(budget, () => [iterator2.retainedValue]);
|
|
30085
30199
|
try {
|
|
30086
30200
|
while (true) {
|
|
30087
30201
|
budget.visitNode();
|
|
30088
|
-
const next =
|
|
30202
|
+
const next = iterator2.generator || iterator2.asynchronous ? await iterator2.next() : iterator2.next();
|
|
30089
30203
|
if (typeof next !== "object" || next === null)
|
|
30090
30204
|
throw new TypeError("Iterator result must be an object.");
|
|
30091
|
-
if ((await readIteratorResult(
|
|
30092
|
-
const value = (await readIteratorResult(
|
|
30205
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
30206
|
+
const value = (await readIteratorResult(iterator2, next, "value")).value;
|
|
30093
30207
|
try {
|
|
30094
30208
|
budget.allocateArrayLength(aggregate.size + 1);
|
|
30095
30209
|
const entryIndex = aggregate.size++;
|
|
@@ -30123,7 +30237,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30123
30237
|
}
|
|
30124
30238
|
}
|
|
30125
30239
|
} catch (error) {
|
|
30126
|
-
await closeIterator(
|
|
30240
|
+
await closeIterator(iterator2, true);
|
|
30127
30241
|
throw error;
|
|
30128
30242
|
}
|
|
30129
30243
|
}
|
|
@@ -31663,11 +31777,11 @@ function createSetOperation(name, budget) {
|
|
|
31663
31777
|
const read = async (object, key) => context?.getProperty !== void 0 ? context.getProperty(object, key) : readPropertyDescriptor(getSandboxPropertyDescriptor(object, key, budget) ?? { value: void 0 }, object, context);
|
|
31664
31778
|
const iterationContext = { ...context, thisValue: receiver, stack: context?.stack ?? [], getProperty: read };
|
|
31665
31779
|
const result = createSandboxSet([]);
|
|
31666
|
-
let
|
|
31780
|
+
let iterator2;
|
|
31667
31781
|
let current;
|
|
31668
31782
|
let has2;
|
|
31669
31783
|
let keys;
|
|
31670
|
-
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys,
|
|
31784
|
+
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys, iterator2?.retainedValue]);
|
|
31671
31785
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
31672
31786
|
const add2 = (value) => {
|
|
31673
31787
|
budget.visitNode();
|
|
@@ -31688,7 +31802,7 @@ function createSetOperation(name, budget) {
|
|
|
31688
31802
|
if (name === "isSubsetOf" && receiver.values.size > size || name === "isSupersetOf" && receiver.values.size < size) return false;
|
|
31689
31803
|
const visitReceiver = name === "isSubsetOf" || (name === "intersection" || name === "difference" || name === "isDisjointFrom") && receiver.values.size <= size;
|
|
31690
31804
|
if (name === "union" || name === "symmetricDifference")
|
|
31691
|
-
|
|
31805
|
+
iterator2 = await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31692
31806
|
if (name === "union" || name === "symmetricDifference" || name === "difference")
|
|
31693
31807
|
for (const value of receiver.values) add2(value);
|
|
31694
31808
|
if (visitReceiver) {
|
|
@@ -31707,15 +31821,15 @@ function createSetOperation(name, budget) {
|
|
|
31707
31821
|
cursor.leave();
|
|
31708
31822
|
}
|
|
31709
31823
|
} else {
|
|
31710
|
-
|
|
31824
|
+
iterator2 ??= await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31711
31825
|
while (true) {
|
|
31712
31826
|
budget.visitNode();
|
|
31713
|
-
const next = await
|
|
31714
|
-
if ((await readIteratorResult(
|
|
31715
|
-
current = (await readIteratorResult(
|
|
31827
|
+
const next = await iterator2.next();
|
|
31828
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
31829
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
31716
31830
|
const found = receiver.values.has(current);
|
|
31717
31831
|
if (name === "isSupersetOf" && !found || name === "isDisjointFrom" && found) {
|
|
31718
|
-
await closeIterator(
|
|
31832
|
+
await closeIterator(iterator2);
|
|
31719
31833
|
return false;
|
|
31720
31834
|
}
|
|
31721
31835
|
if (name === "union" || name === "intersection" && found || name === "symmetricDifference" && !found) add2(current);
|
|
@@ -31785,7 +31899,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31785
31899
|
return context.thisValue.values.size;
|
|
31786
31900
|
}
|
|
31787
31901
|
});
|
|
31788
|
-
for (const { name, constructor, methods: methods4, size, iterator } of [
|
|
31902
|
+
for (const { name, constructor, methods: methods4, size, iterator: iterator2 } of [
|
|
31789
31903
|
{ name: "Map", constructor: mapConstructor, methods: mapMethods, size: mapSize3, iterator: mapMethods.entries },
|
|
31790
31904
|
{ name: "Set", constructor: setConstructor, methods: setMethods, size: setSize2, iterator: setMethods.values }
|
|
31791
31905
|
]) {
|
|
@@ -31804,7 +31918,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31804
31918
|
Object.defineProperty(prototype, key, { value: method, writable: true, configurable: true });
|
|
31805
31919
|
Object.defineProperty(prototype, "size", { get: accessorAdapter(size, "get"), configurable: true });
|
|
31806
31920
|
Object.defineProperty(prototype, Symbol.toStringTag, { value: name, configurable: true });
|
|
31807
|
-
Object.defineProperty(prototype, Symbol.iterator, { value:
|
|
31921
|
+
Object.defineProperty(prototype, Symbol.iterator, { value: iterator2, writable: true, configurable: true });
|
|
31808
31922
|
installCollectionPrototype(budget, name, prototype, constructor);
|
|
31809
31923
|
for (const method of /* @__PURE__ */ new Set([...Object.values(methods4), size, species])) registerIntrinsicFunction(budget, method);
|
|
31810
31924
|
}
|
|
@@ -31932,14 +32046,14 @@ function populateCollection(source, collection, {
|
|
|
31932
32046
|
}) {
|
|
31933
32047
|
budget.allocateCollectionEntries(0);
|
|
31934
32048
|
let adder;
|
|
31935
|
-
const populate = (
|
|
31936
|
-
if (
|
|
32049
|
+
const populate = (iterator2) => {
|
|
32050
|
+
if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
31937
32051
|
let entry;
|
|
31938
32052
|
let failure;
|
|
31939
32053
|
const retained = {};
|
|
31940
32054
|
budget.setRetainedValues(retained, () => [
|
|
31941
32055
|
source,
|
|
31942
|
-
|
|
32056
|
+
iterator2.retainedValue,
|
|
31943
32057
|
collection,
|
|
31944
32058
|
adder,
|
|
31945
32059
|
entry,
|
|
@@ -31953,13 +32067,13 @@ function populateCollection(source, collection, {
|
|
|
31953
32067
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
31954
32068
|
throw error;
|
|
31955
32069
|
};
|
|
31956
|
-
if (
|
|
31957
|
-
return closeIterator(
|
|
32070
|
+
if (iterator2.getOperation !== void 0)
|
|
32071
|
+
return closeIterator(iterator2, true).then(() => {
|
|
31958
32072
|
throw error;
|
|
31959
32073
|
}, rethrow);
|
|
31960
32074
|
try {
|
|
31961
|
-
const closing =
|
|
31962
|
-
if (
|
|
32075
|
+
const closing = iterator2.return?.();
|
|
32076
|
+
if (iterator2.generator || iterator2.asynchronous)
|
|
31963
32077
|
return Promise.resolve(closing).then(() => {
|
|
31964
32078
|
throw error;
|
|
31965
32079
|
}, rethrow);
|
|
@@ -31989,16 +32103,16 @@ function populateCollection(source, collection, {
|
|
|
31989
32103
|
}
|
|
31990
32104
|
return false;
|
|
31991
32105
|
};
|
|
31992
|
-
if (
|
|
32106
|
+
if (iterator2.generator || iterator2.asynchronous || context !== void 0 || adder !== void 0) {
|
|
31993
32107
|
return (async () => {
|
|
31994
32108
|
try {
|
|
31995
32109
|
checkData(collection, 0, true);
|
|
31996
32110
|
while (true) {
|
|
31997
|
-
const result = await
|
|
32111
|
+
const result = await iterator2.next();
|
|
31998
32112
|
if (typeof result !== "object" || result === null)
|
|
31999
32113
|
throw new TypeError("Iterator result must be an object.");
|
|
32000
|
-
if ((await readIteratorResult(
|
|
32001
|
-
const value = (await readIteratorResult(
|
|
32114
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32115
|
+
const value = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32002
32116
|
await consume({ done: false, value });
|
|
32003
32117
|
}
|
|
32004
32118
|
checkData(collection, 0, true);
|
|
@@ -32010,7 +32124,7 @@ function populateCollection(source, collection, {
|
|
|
32010
32124
|
}
|
|
32011
32125
|
try {
|
|
32012
32126
|
checkData(collection, 0, true);
|
|
32013
|
-
while (!consume(
|
|
32127
|
+
while (!consume(iterator2.next())) {
|
|
32014
32128
|
}
|
|
32015
32129
|
checkData(collection, 0, true);
|
|
32016
32130
|
return collection;
|
|
@@ -32022,8 +32136,8 @@ function populateCollection(source, collection, {
|
|
|
32022
32136
|
const start = (candidate) => {
|
|
32023
32137
|
if (!isSandboxClosure(candidate)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32024
32138
|
if (getIntrinsicIdentity(candidate) !== JSON.stringify([name, "prototype", method])) adder = candidate;
|
|
32025
|
-
const
|
|
32026
|
-
return
|
|
32139
|
+
const iterator2 = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
|
|
32140
|
+
return iterator2 instanceof Promise ? iterator2.then(populate) : populate(iterator2);
|
|
32027
32141
|
};
|
|
32028
32142
|
const initialize = (prototype2) => {
|
|
32029
32143
|
if (typeof prototype2 !== "object" || prototype2 === null)
|
|
@@ -32070,14 +32184,14 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32070
32184
|
if (source === void 0 || source === null) return collection;
|
|
32071
32185
|
adder = await read(collection, adderName);
|
|
32072
32186
|
if (!isSandboxClosure(adder)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32073
|
-
const
|
|
32074
|
-
if (
|
|
32075
|
-
const releaseIterator = retainValues(budget, () => [
|
|
32187
|
+
const iterator2 = context === void 0 ? getSandboxIterator(source, budget) : await acquireSandboxIterator(source, budget, context);
|
|
32188
|
+
if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
32189
|
+
const releaseIterator = retainValues(budget, () => [iterator2.retainedValue]);
|
|
32076
32190
|
try {
|
|
32077
32191
|
while (true) {
|
|
32078
|
-
const next = await
|
|
32079
|
-
if ((await readIteratorResult(
|
|
32080
|
-
entry = (await readIteratorResult(
|
|
32192
|
+
const next = await iterator2.next();
|
|
32193
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
32194
|
+
entry = (await readIteratorResult(iterator2, next, "value")).value;
|
|
32081
32195
|
try {
|
|
32082
32196
|
budget.visitNode();
|
|
32083
32197
|
if (kind === "map") {
|
|
@@ -32089,7 +32203,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32089
32203
|
entry = key = value = void 0;
|
|
32090
32204
|
} catch (error) {
|
|
32091
32205
|
try {
|
|
32092
|
-
await closeIterator(
|
|
32206
|
+
await closeIterator(iterator2, true);
|
|
32093
32207
|
} catch (closeError) {
|
|
32094
32208
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
32095
32209
|
}
|
|
@@ -32169,7 +32283,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32169
32283
|
|
|
32170
32284
|
// packages/safe-js/src/interp/globals/math-sum-precise.ts
|
|
32171
32285
|
async function sumPrecise(source, budget, context) {
|
|
32172
|
-
let
|
|
32286
|
+
let iterator2;
|
|
32173
32287
|
let current;
|
|
32174
32288
|
let recordValue;
|
|
32175
32289
|
let sum = 0n;
|
|
@@ -32179,25 +32293,25 @@ async function sumPrecise(source, budget, context) {
|
|
|
32179
32293
|
let count = 0;
|
|
32180
32294
|
const storage = new DataView(new ArrayBuffer(8));
|
|
32181
32295
|
const checkData = createDataCheckpoint(budget, context);
|
|
32182
|
-
const release = retainValues(budget, () => [source,
|
|
32296
|
+
const release = retainValues(budget, () => [source, iterator2?.retainedValue, recordValue, current, sum]);
|
|
32183
32297
|
try {
|
|
32184
32298
|
if (source === void 0 || source === null) throw new TypeError("Math.sumPrecise requires an iterable.");
|
|
32185
|
-
|
|
32186
|
-
if (
|
|
32299
|
+
iterator2 = context === void 0 ? getSandboxIterator(source, budget) : await acquireSandboxIterator(source, budget, context);
|
|
32300
|
+
if (iterator2 === void 0) throw new TypeError("Math.sumPrecise requires an iterable.");
|
|
32187
32301
|
checkData(source, 0, true);
|
|
32188
32302
|
while (true) {
|
|
32189
32303
|
budget.visitNode();
|
|
32190
|
-
const next =
|
|
32191
|
-
const result =
|
|
32304
|
+
const next = iterator2.next();
|
|
32305
|
+
const result = iterator2.asynchronous || iterator2.generator ? await next : next;
|
|
32192
32306
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
32193
32307
|
throw new TypeError("Iterator result must be an object.");
|
|
32194
32308
|
recordValue = result;
|
|
32195
32309
|
const record4 = result;
|
|
32196
|
-
if ((await readIteratorResult(
|
|
32197
|
-
current = (await readIteratorResult(
|
|
32310
|
+
if ((await readIteratorResult(iterator2, record4, "done")).value) break;
|
|
32311
|
+
current = (await readIteratorResult(iterator2, record4, "value")).value;
|
|
32198
32312
|
if (count >= Number.MAX_SAFE_INTEGER || typeof current !== "number") {
|
|
32199
32313
|
const error = count >= Number.MAX_SAFE_INTEGER ? new RangeError("Math.sumPrecise received too many elements.") : new TypeError("Math.sumPrecise requires number elements.");
|
|
32200
|
-
await closeIterator(
|
|
32314
|
+
await closeIterator(iterator2, true);
|
|
32201
32315
|
throw error;
|
|
32202
32316
|
}
|
|
32203
32317
|
count++;
|
|
@@ -32818,21 +32932,21 @@ async function cloneWithOptions(value, options, budget, context) {
|
|
|
32818
32932
|
})
|
|
32819
32933
|
};
|
|
32820
32934
|
let current;
|
|
32821
|
-
let
|
|
32935
|
+
let iterator2;
|
|
32822
32936
|
const items = [];
|
|
32823
|
-
const release = retainValues(budget, () => [value, options, current, items,
|
|
32937
|
+
const release = retainValues(budget, () => [value, options, current, items, iterator2?.retainedValue]);
|
|
32824
32938
|
try {
|
|
32825
32939
|
current = await bridge.getProperty(options, "transfer");
|
|
32826
32940
|
if (current !== void 0) {
|
|
32827
32941
|
if (current === null || typeof current !== "object") throw new TypeError("Transfer list must be an iterable object.");
|
|
32828
|
-
|
|
32829
|
-
if (
|
|
32942
|
+
iterator2 = await acquireSandboxIterator(current, budget, bridge);
|
|
32943
|
+
if (iterator2 === void 0) throw new TypeError("Transfer list must be iterable.");
|
|
32830
32944
|
for (; ; ) {
|
|
32831
32945
|
budget.visitNode();
|
|
32832
|
-
const result = await
|
|
32946
|
+
const result = await iterator2.next();
|
|
32833
32947
|
current = result;
|
|
32834
|
-
if ((await readIteratorResult(
|
|
32835
|
-
current = (await readIteratorResult(
|
|
32948
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32949
|
+
current = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32836
32950
|
if (current === null || typeof current !== "object") {
|
|
32837
32951
|
throw new TypeError("Transfer list elements must be objects.");
|
|
32838
32952
|
}
|
|
@@ -32907,8 +33021,8 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32907
33021
|
operation.release();
|
|
32908
33022
|
}
|
|
32909
33023
|
}
|
|
32910
|
-
const
|
|
32911
|
-
const first =
|
|
33024
|
+
const iterator2 = execute();
|
|
33025
|
+
const first = iterator2.next();
|
|
32912
33026
|
if (first.done) return first.value;
|
|
32913
33027
|
return (async () => {
|
|
32914
33028
|
let step = first;
|
|
@@ -32917,15 +33031,15 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32917
33031
|
const request = step.value;
|
|
32918
33032
|
if ("stringValue" in request) {
|
|
32919
33033
|
createDataCheckpoint(budget, context)(request.stringValue, 0, true);
|
|
32920
|
-
step =
|
|
33034
|
+
step = iterator2.next(await sandboxString(request.stringValue, budget, context));
|
|
32921
33035
|
} else {
|
|
32922
33036
|
createDataCheckpoint(budget, context)(request.receiver, 0, true);
|
|
32923
|
-
step =
|
|
33037
|
+
step = iterator2.next(await readPropertyDescriptor(request.descriptor, request.receiver, context));
|
|
32924
33038
|
}
|
|
32925
33039
|
}
|
|
32926
33040
|
return step.value;
|
|
32927
33041
|
} finally {
|
|
32928
|
-
|
|
33042
|
+
iterator2.return(void 0);
|
|
32929
33043
|
}
|
|
32930
33044
|
})();
|
|
32931
33045
|
}
|
|
@@ -37598,20 +37712,20 @@ function installIteratorFrom(constructor, budget) {
|
|
|
37598
37712
|
context = callContext(context);
|
|
37599
37713
|
if (input === null || typeof input !== "object" && typeof input !== "string")
|
|
37600
37714
|
throw new TypeError("Iterator.from requires an object or string.");
|
|
37601
|
-
let
|
|
37715
|
+
let iterator2 = input;
|
|
37602
37716
|
let next;
|
|
37603
|
-
const release = retainValues(budget, () => [input,
|
|
37717
|
+
const release = retainValues(budget, () => [input, iterator2, next]);
|
|
37604
37718
|
try {
|
|
37605
37719
|
const method = await context.getProperty(input, Symbol.iterator);
|
|
37606
37720
|
if (method !== void 0 && method !== null) {
|
|
37607
37721
|
if (!isSandboxClosure(method)) throw new TypeError("Symbol.iterator must be callable.");
|
|
37608
|
-
|
|
37722
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, input);
|
|
37609
37723
|
}
|
|
37610
|
-
if (
|
|
37611
|
-
next = await context.getProperty(
|
|
37612
|
-
if (await ordinaryHasInstance(
|
|
37724
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
37725
|
+
next = await context.getProperty(iterator2, "next");
|
|
37726
|
+
if (await ordinaryHasInstance(iterator2, constructor, budget, context)) return iterator2;
|
|
37613
37727
|
const wrapper = /* @__PURE__ */ Object.create(null);
|
|
37614
|
-
iteratorWrapperStates.set(wrapper, { iterator, next });
|
|
37728
|
+
iteratorWrapperStates.set(wrapper, { iterator: iterator2, next });
|
|
37615
37729
|
setSandboxPrototype(wrapper, prototype, budget);
|
|
37616
37730
|
createDataCheckpoint(budget, context)(wrapper, 0, true);
|
|
37617
37731
|
return wrapper;
|
|
@@ -37676,7 +37790,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37676
37790
|
}
|
|
37677
37791
|
const release = retainValues(budget, () => [receiver, callback, next, accumulator, value, values]);
|
|
37678
37792
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
37679
|
-
const
|
|
37793
|
+
const iterator2 = {
|
|
37680
37794
|
asynchronous: true,
|
|
37681
37795
|
next: async () => {
|
|
37682
37796
|
if (!isSandboxClosure(next)) throw new TypeError("Iterator next must be callable.");
|
|
@@ -37693,7 +37807,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37693
37807
|
};
|
|
37694
37808
|
try {
|
|
37695
37809
|
if (name !== "toArray" && !isSandboxClosure(callback)) {
|
|
37696
|
-
await closeIterator(
|
|
37810
|
+
await closeIterator(iterator2, true);
|
|
37697
37811
|
throw new TypeError("Iterator callback must be callable.");
|
|
37698
37812
|
}
|
|
37699
37813
|
next = await bridge.getProperty(receiver, "next");
|
|
@@ -37701,7 +37815,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37701
37815
|
let index = 0;
|
|
37702
37816
|
while (true) {
|
|
37703
37817
|
budget.visitNode();
|
|
37704
|
-
const result = await
|
|
37818
|
+
const result = await iterator2.next();
|
|
37705
37819
|
if (await bridge.getProperty(result, "done")) {
|
|
37706
37820
|
if (!initialized) throw new TypeError("Cannot reduce an empty iterator without an initial value.");
|
|
37707
37821
|
if (name === "toArray") return values;
|
|
@@ -37729,12 +37843,12 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37729
37843
|
void 0
|
|
37730
37844
|
);
|
|
37731
37845
|
} catch (error) {
|
|
37732
|
-
if (!isFatalSandboxError(error)) await closeIterator(
|
|
37846
|
+
if (!isFatalSandboxError(error)) await closeIterator(iterator2, true);
|
|
37733
37847
|
throw error;
|
|
37734
37848
|
}
|
|
37735
37849
|
if (name === "reduce") accumulator = selected;
|
|
37736
37850
|
else if ((name === "some" || name === "find") && selected || name === "every" && !selected) {
|
|
37737
|
-
await closeIterator(
|
|
37851
|
+
await closeIterator(iterator2);
|
|
37738
37852
|
return name === "find" ? value : name === "some";
|
|
37739
37853
|
}
|
|
37740
37854
|
}
|
|
@@ -37780,17 +37894,17 @@ function installJointIteratorHelpers(prototype, constructor, budget, protocol) {
|
|
|
37780
37894
|
}
|
|
37781
37895
|
async function acquire(value, context, flattenable) {
|
|
37782
37896
|
if (value === null || typeof value !== "object") throw new TypeError("Joint iteration inputs must be objects.");
|
|
37783
|
-
let
|
|
37897
|
+
let iterator2 = value;
|
|
37784
37898
|
let method;
|
|
37785
|
-
const release = retainValues(budget, () => [value,
|
|
37899
|
+
const release = retainValues(budget, () => [value, iterator2, method]);
|
|
37786
37900
|
try {
|
|
37787
37901
|
method = await context.getProperty(value, Symbol.iterator);
|
|
37788
37902
|
if (!flattenable || method !== void 0 && method !== null) {
|
|
37789
37903
|
if (!isSandboxClosure(method)) throw new TypeError("Input must be iterable.");
|
|
37790
|
-
|
|
37791
|
-
if (
|
|
37904
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, value);
|
|
37905
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
37792
37906
|
}
|
|
37793
|
-
return { iterator, next: await context.getProperty(
|
|
37907
|
+
return { iterator: iterator2, next: await context.getProperty(iterator2, "next") };
|
|
37794
37908
|
} finally {
|
|
37795
37909
|
release();
|
|
37796
37910
|
}
|
|
@@ -38018,10 +38132,10 @@ function installLazyIteratorHelpers(common, budget, constructor) {
|
|
|
38018
38132
|
complete(state);
|
|
38019
38133
|
return createIteratorResult(void 0, true, budget);
|
|
38020
38134
|
}
|
|
38021
|
-
const
|
|
38022
|
-
if (
|
|
38023
|
-
state.outer = { iterator, next: void 0 };
|
|
38024
|
-
state.outer.next = await context.getProperty(
|
|
38135
|
+
const iterator2 = await invokeBuiltinClosure(input.open, [], budget, context, input.iterable);
|
|
38136
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
38137
|
+
state.outer = { iterator: iterator2, next: void 0 };
|
|
38138
|
+
state.outer.next = await context.getProperty(iterator2, "next");
|
|
38025
38139
|
state.iterables.shift();
|
|
38026
38140
|
}
|
|
38027
38141
|
const result2 = await step(state.outer, context);
|
|
@@ -40258,20 +40372,20 @@ function createListFormatConstructor(budget) {
|
|
|
40258
40372
|
const receiver = context?.thisValue;
|
|
40259
40373
|
listFormatState(receiver);
|
|
40260
40374
|
const strings = [];
|
|
40261
|
-
let
|
|
40262
|
-
const release = retainValues(budget, () => [receiver, strings,
|
|
40375
|
+
let iterator2;
|
|
40376
|
+
const release = retainValues(budget, () => [receiver, strings, iterator2?.retainedValue]);
|
|
40263
40377
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
40264
40378
|
try {
|
|
40265
40379
|
if (input !== void 0) {
|
|
40266
|
-
|
|
40267
|
-
if (
|
|
40380
|
+
iterator2 = context === void 0 ? getSandboxIterator(input, budget) : await acquireSandboxIterator(input, budget, context);
|
|
40381
|
+
if (iterator2 === void 0) throw new TypeError("ListFormat requires an iterable.");
|
|
40268
40382
|
while (true) {
|
|
40269
40383
|
budget.visitNode();
|
|
40270
|
-
const result = await
|
|
40271
|
-
if ((await readIteratorResult(
|
|
40272
|
-
const value = (await readIteratorResult(
|
|
40384
|
+
const result = await iterator2.next();
|
|
40385
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
40386
|
+
const value = (await readIteratorResult(iterator2, result, "value")).value;
|
|
40273
40387
|
if (typeof value !== "string") {
|
|
40274
|
-
await closeIterator(
|
|
40388
|
+
await closeIterator(iterator2, true);
|
|
40275
40389
|
throw new TypeError("ListFormat requires string elements.");
|
|
40276
40390
|
}
|
|
40277
40391
|
budget.visitNode(value.length);
|
|
@@ -41237,8 +41351,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41237
41351
|
validateGuestHeapNode({ kind: "guest-object", state: node2.state }, heap, maxArrayLength);
|
|
41238
41352
|
const properties = array(record3(record3(node2.state).properties).properties).map(array);
|
|
41239
41353
|
if (node2.nativeIterator) {
|
|
41240
|
-
const
|
|
41241
|
-
if (
|
|
41354
|
+
const iterator2 = properties.find(([key]) => typeof key === "object" && key !== null && record3(heap[String(record3(key).id)]).wellKnown === "iterator");
|
|
41355
|
+
if (iterator2 === void 0 || record3(iterator2[1]).kind !== "data" || !absent(record3(iterator2[1]).value))
|
|
41242
41356
|
throw new TypeError("Invalid native arguments iterator descriptor.");
|
|
41243
41357
|
}
|
|
41244
41358
|
const indices = /* @__PURE__ */ new Set(), names = /* @__PURE__ */ new Set();
|
|
@@ -41956,8 +42070,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41956
42070
|
state(node.state);
|
|
41957
42071
|
} else if (node.kind === "iterator-wrapper") {
|
|
41958
42072
|
fields(node, ["kind", "iterator", "next", "state"]);
|
|
41959
|
-
const
|
|
41960
|
-
if (
|
|
42073
|
+
const iterator2 = reference(node.iterator);
|
|
42074
|
+
if (iterator2.kind === "symbol" || iterator2.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
|
|
41961
42075
|
state(node.state);
|
|
41962
42076
|
} else if (node.kind === "disposable-stack") {
|
|
41963
42077
|
fields(node, ["kind", "disposed", "resources", "state"]);
|
|
@@ -42328,34 +42442,34 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
42328
42442
|
if (expression.kind !== "yield-delegate") integer(expression.index);
|
|
42329
42443
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
42330
42444
|
else {
|
|
42331
|
-
let
|
|
42445
|
+
let iterator2 = record3(expression.iterator);
|
|
42332
42446
|
let depth = 0;
|
|
42333
42447
|
let protocol = false;
|
|
42334
|
-
while (
|
|
42448
|
+
while (iterator2.kind === "async-from-sync") {
|
|
42335
42449
|
if (++depth > 1) throw new TypeError("Invalid nested async iterator adapter.");
|
|
42336
|
-
fields(
|
|
42337
|
-
|
|
42450
|
+
fields(iterator2, ["kind", "inner"]);
|
|
42451
|
+
iterator2 = record3(iterator2.inner);
|
|
42338
42452
|
protocol = true;
|
|
42339
42453
|
}
|
|
42340
42454
|
if ((expression.kind === "for-of-iterator" && (expression.phase === "next" || expression.phase === "close") || expression.kind === "yield-delegate" && expression.phase !== void 0 && expression.phase !== "return") && record3(expression.awaitState).kind !== (depth === 1 ? "value" : "result"))
|
|
42341
42455
|
throw new TypeError("Iterator await state does not match its adapter.");
|
|
42342
|
-
if (
|
|
42343
|
-
fields(
|
|
42344
|
-
if (typeof
|
|
42345
|
-
if (depth > 0 &&
|
|
42346
|
-
protocol ||=
|
|
42347
|
-
reference(
|
|
42348
|
-
callable(
|
|
42349
|
-
} else if (
|
|
42350
|
-
fields(
|
|
42351
|
-
integer(
|
|
42352
|
-
if (typeof
|
|
42456
|
+
if (iterator2.kind === "guest") {
|
|
42457
|
+
fields(iterator2, ["kind", "value", "next", "async"]);
|
|
42458
|
+
if (typeof iterator2.async !== "boolean") throw new TypeError("Invalid iterator protocol.");
|
|
42459
|
+
if (depth > 0 && iterator2.async) throw new TypeError("Invalid async-from-sync source.");
|
|
42460
|
+
protocol ||= iterator2.async;
|
|
42461
|
+
reference(iterator2.value);
|
|
42462
|
+
callable(iterator2.next);
|
|
42463
|
+
} else if (iterator2.kind === "builtin") {
|
|
42464
|
+
fields(iterator2, ["kind", "value", "index"]);
|
|
42465
|
+
integer(iterator2.index);
|
|
42466
|
+
if (typeof iterator2.value === "string" && iterator2.index > iterator2.value.length)
|
|
42353
42467
|
throw new TypeError("Invalid string iterator cursor.");
|
|
42354
|
-
if (typeof
|
|
42355
|
-
const target = reference(
|
|
42356
|
-
if (["guest-generator", "collection-iterator", "regexp-iterator"].includes(String(target.kind)) &&
|
|
42468
|
+
if (typeof iterator2.value !== "string") {
|
|
42469
|
+
const target = reference(iterator2.value, ["array", "guest-array", "map", "set", "guest-generator", "collection-iterator", "regexp-iterator"]);
|
|
42470
|
+
if (["guest-generator", "collection-iterator", "regexp-iterator"].includes(String(target.kind)) && iterator2.index !== 0)
|
|
42357
42471
|
throw new TypeError("Invalid stateful iterator cursor.");
|
|
42358
|
-
if (target.kind === "map" &&
|
|
42472
|
+
if (target.kind === "map" && iterator2.index > array(target.entries).length || target.kind === "set" && iterator2.index > array(target.values).length)
|
|
42359
42473
|
throw new TypeError("Invalid collection iterator cursor.");
|
|
42360
42474
|
if (target.kind === "guest-generator" && target.async === true) {
|
|
42361
42475
|
if (depth > 0) throw new TypeError("Invalid async-from-sync generator.");
|
|
@@ -43425,8 +43539,8 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43425
43539
|
}
|
|
43426
43540
|
const properties = requireRecord(record4.properties, `${path}.properties`);
|
|
43427
43541
|
if (record4.iterator !== null) {
|
|
43428
|
-
const
|
|
43429
|
-
for (const key of Object.keys(
|
|
43542
|
+
const iterator2 = requireRecord(record4.iterator, `${path}.iterator`);
|
|
43543
|
+
for (const key of Object.keys(iterator2)) {
|
|
43430
43544
|
if (!["configurable", "enumerable", "writable"].includes(key)) {
|
|
43431
43545
|
fail(
|
|
43432
43546
|
"invalidValue",
|
|
@@ -43436,7 +43550,7 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43436
43550
|
}
|
|
43437
43551
|
}
|
|
43438
43552
|
for (const flag of ["configurable", "enumerable", "writable"]) {
|
|
43439
|
-
if (typeof
|
|
43553
|
+
if (typeof iterator2[flag] !== "boolean")
|
|
43440
43554
|
fail("invalidType", `${path}.iterator.${flag}`, "expected boolean");
|
|
43441
43555
|
}
|
|
43442
43556
|
}
|
|
@@ -43465,10 +43579,20 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43465
43579
|
}
|
|
43466
43580
|
}
|
|
43467
43581
|
}
|
|
43468
|
-
function
|
|
43469
|
-
if (types21.isProxy(value)
|
|
43582
|
+
function validateSnapshotProxy(value, path, dataPropertiesOnly = false) {
|
|
43583
|
+
if (!types21.isProxy(value)) return;
|
|
43584
|
+
if (!dataPropertiesOnly && isTrackedIntrinsicObject(value)) {
|
|
43585
|
+
const prototype = Object.getPrototypeOf(value);
|
|
43586
|
+
if (prototype !== null && prototype !== (Array.isArray(value) ? Array.prototype : Object.prototype))
|
|
43587
|
+
fail("invalidType", path, "runtime snapshot objects must not have a custom native prototype");
|
|
43588
|
+
return;
|
|
43589
|
+
}
|
|
43590
|
+
if (dataPropertiesOnly || getIntrinsicIdentity(value) === void 0 && !isSandboxModuleNamespace(value)) {
|
|
43470
43591
|
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43471
43592
|
}
|
|
43593
|
+
}
|
|
43594
|
+
function validateGenericValue(value, path, depth, state) {
|
|
43595
|
+
validateSnapshotProxy(value, path, state.dataPropertiesOnly);
|
|
43472
43596
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.allowHostFunctionState && (isSandboxModuleNamespace(value) || isSandboxClosure(value) && !isGuestClosure(value)))) {
|
|
43473
43597
|
fail("invalidState", path, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
43474
43598
|
}
|
|
@@ -43534,8 +43658,7 @@ function validateRuntimeSnapshotDescriptors(snapshot) {
|
|
|
43534
43658
|
let entries = 0;
|
|
43535
43659
|
while (pending.length > 0) {
|
|
43536
43660
|
const { value, path, depth } = pending.pop();
|
|
43537
|
-
|
|
43538
|
-
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43661
|
+
validateSnapshotProxy(value, path);
|
|
43539
43662
|
if (seen.has(value)) continue;
|
|
43540
43663
|
seen.add(value);
|
|
43541
43664
|
if (depth > MAX_DATA_DEPTH)
|
|
@@ -45836,12 +45959,20 @@ import { types as nodeTypes } from "node:util";
|
|
|
45836
45959
|
var frozenClosureData = /* @__PURE__ */ new WeakMap();
|
|
45837
45960
|
var readFrozenClosureData = WeakMap.prototype.get.bind(frozenClosureData);
|
|
45838
45961
|
var writeFrozenClosureData = WeakMap.prototype.set.bind(frozenClosureData);
|
|
45839
|
-
var
|
|
45840
|
-
var
|
|
45962
|
+
var freezeValueShape = Object.freeze;
|
|
45963
|
+
var captureValueSymbols = Object.getOwnPropertySymbols;
|
|
45964
|
+
var sealValueShape = Object.seal;
|
|
45965
|
+
var sealedValueSymbols = /* @__PURE__ */ new WeakMap();
|
|
45966
|
+
var readSealedValueSymbols = WeakMap.prototype.get.bind(sealedValueSymbols);
|
|
45967
|
+
var writeSealedValueSymbols = WeakMap.prototype.set.bind(sealedValueSymbols);
|
|
45841
45968
|
var captureClosureDescriptor = Object.getOwnPropertyDescriptor;
|
|
45842
45969
|
var hasClosureDescriptorField = Object.hasOwn;
|
|
45843
45970
|
var invokeClosureGetter = Reflect.apply;
|
|
45844
|
-
var closureGetterArguments =
|
|
45971
|
+
var closureGetterArguments = freezeValueShape([]);
|
|
45972
|
+
function captureSealedValueSymbols(value) {
|
|
45973
|
+
writeSealedValueSymbols(value, freezeValueShape(captureValueSymbols(value)));
|
|
45974
|
+
return value;
|
|
45975
|
+
}
|
|
45845
45976
|
function readClosureProperties(closure, data) {
|
|
45846
45977
|
const getter = data?.propertiesGetter;
|
|
45847
45978
|
return getter === void 0 ? closure.properties : invokeClosureGetter(getter, closure, closureGetterArguments);
|
|
@@ -45923,12 +46054,12 @@ function createSandboxClosure(input) {
|
|
|
45923
46054
|
value: input.retainedValues
|
|
45924
46055
|
});
|
|
45925
46056
|
}
|
|
45926
|
-
|
|
46057
|
+
freezeValueShape(closure);
|
|
45927
46058
|
const properties = captureClosureDescriptor(closure, "properties");
|
|
45928
46059
|
writeFrozenClosureData(
|
|
45929
46060
|
closure,
|
|
45930
|
-
|
|
45931
|
-
symbols:
|
|
46061
|
+
freezeValueShape({
|
|
46062
|
+
symbols: freezeValueShape(captureValueSymbols(closure)),
|
|
45932
46063
|
closure: captureClosureDescriptor(closure, sandboxClosureBrand) !== void 0,
|
|
45933
46064
|
propertiesGetter: properties !== void 0 && hasClosureDescriptorField(properties, "get") ? properties.get : void 0
|
|
45934
46065
|
})
|
|
@@ -45939,7 +46070,13 @@ function registerDeferredClosureChargeIdentity(closure, identity) {
|
|
|
45939
46070
|
const data = readFrozenClosureData(closure);
|
|
45940
46071
|
if (data?.closure !== true || data.chargeIdentity !== void 0)
|
|
45941
46072
|
throw new TypeError("Deferred initialization requires a fresh SDK-created function.");
|
|
45942
|
-
writeFrozenClosureData(closure,
|
|
46073
|
+
writeFrozenClosureData(closure, freezeValueShape({ ...data, chargeIdentity: identity }));
|
|
46074
|
+
}
|
|
46075
|
+
function registerClosureCaptureCollector(closure, provider, collect) {
|
|
46076
|
+
if (readFrozenClosureData(closure)?.closure !== true) return;
|
|
46077
|
+
const descriptor = captureClosureDescriptor(closure, sandboxRetainedValues);
|
|
46078
|
+
if (descriptor !== void 0 && hasClosureDescriptorField(descriptor, "value") && descriptor.value === provider)
|
|
46079
|
+
registerIndexedClosureCaptures(closure, collect);
|
|
45943
46080
|
}
|
|
45944
46081
|
function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
45945
46082
|
if (isGuestHostObject(value)) {
|
|
@@ -46053,7 +46190,7 @@ function createSandboxPromise(promise, metadata = {}) {
|
|
|
46053
46190
|
);
|
|
46054
46191
|
trackSandboxPromise(sandboxPromise);
|
|
46055
46192
|
registerPromiseCancellation(sandboxPromise);
|
|
46056
|
-
return
|
|
46193
|
+
return captureSealedValueSymbols(freezeValueShape(sandboxPromise));
|
|
46057
46194
|
}
|
|
46058
46195
|
function createSandboxGenerator(channel, metadata = void 0) {
|
|
46059
46196
|
const generator = {
|
|
@@ -46084,7 +46221,7 @@ function createSandboxMap(entries = []) {
|
|
|
46084
46221
|
enumerable: false,
|
|
46085
46222
|
value: true
|
|
46086
46223
|
});
|
|
46087
|
-
return
|
|
46224
|
+
return captureSealedValueSymbols(freezeValueShape(map));
|
|
46088
46225
|
}
|
|
46089
46226
|
function createSandboxSet(values = []) {
|
|
46090
46227
|
const set3 = {};
|
|
@@ -46101,7 +46238,7 @@ function createSandboxSet(values = []) {
|
|
|
46101
46238
|
enumerable: false,
|
|
46102
46239
|
value: true
|
|
46103
46240
|
});
|
|
46104
|
-
return
|
|
46241
|
+
return captureSealedValueSymbols(freezeValueShape(set3));
|
|
46105
46242
|
}
|
|
46106
46243
|
function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
46107
46244
|
if (typeof source !== "string" || typeof flags !== "string") {
|
|
@@ -46137,7 +46274,7 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
|
46137
46274
|
[sandboxRegexBrand]: { value: true },
|
|
46138
46275
|
[sandboxRegexPattern]: { value: pattern, writable: true }
|
|
46139
46276
|
});
|
|
46140
|
-
return
|
|
46277
|
+
return captureSealedValueSymbols(sealValueShape(regex));
|
|
46141
46278
|
}
|
|
46142
46279
|
function getSandboxRegexPattern(regex) {
|
|
46143
46280
|
return regex[sandboxRegexPattern];
|
|
@@ -46289,28 +46426,47 @@ function* cloneStructuredGraph(value, state, budget, depth = 0) {
|
|
|
46289
46426
|
var nativeDataArrayAppend = Function.prototype.call.bind(Array.prototype.push);
|
|
46290
46427
|
var nativeDataArraySetPrototype = Object.setPrototypeOf;
|
|
46291
46428
|
var MAX_REUSABLE_CAPTURE_LENGTH = 64;
|
|
46429
|
+
var NativeMeasurementSet = Set;
|
|
46430
|
+
var retainedMeasurementCode;
|
|
46431
|
+
function createMeasurementCollector(target) {
|
|
46432
|
+
return {
|
|
46433
|
+
append(value) {
|
|
46434
|
+
target?.(value);
|
|
46435
|
+
},
|
|
46436
|
+
close() {
|
|
46437
|
+
target = void 0;
|
|
46438
|
+
}
|
|
46439
|
+
};
|
|
46440
|
+
}
|
|
46292
46441
|
function measureSandboxData(values, options = {}) {
|
|
46442
|
+
if (retainedMeasurementCode === void 0)
|
|
46443
|
+
withMeasurementSeen((seen) => measureSandboxDataWithSeen([], {}, seen, true));
|
|
46444
|
+
retainedMeasurementCode(void 0);
|
|
46293
46445
|
return withMeasurementSeen((seen) => measureSandboxDataWithSeen(values, options, seen));
|
|
46294
46446
|
}
|
|
46295
|
-
function measureSandboxDataWithSeen(values, options, seen) {
|
|
46296
|
-
const seenSymbols = /* @__PURE__ */ new Set();
|
|
46447
|
+
function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
|
|
46448
|
+
const seenSymbols = retainCode ? new NativeMeasurementSet() : /* @__PURE__ */ new Set();
|
|
46297
46449
|
let usage = 0;
|
|
46298
46450
|
const projectedPrimitives = [];
|
|
46451
|
+
let pendingArguments;
|
|
46452
|
+
let pendingFunctions;
|
|
46453
|
+
let pendingFunctionDepths;
|
|
46299
46454
|
let waiting;
|
|
46300
46455
|
let ready;
|
|
46301
46456
|
let pending;
|
|
46302
46457
|
let pendingCount = 0;
|
|
46303
|
-
const appendContinuation = (values2, depth, capture) => {
|
|
46458
|
+
const appendContinuation = (values2, depth, capture, proxy) => {
|
|
46304
46459
|
const frames = pending ??= nativeDataArraySetPrototype([], null);
|
|
46305
46460
|
let frame = frames[pendingCount];
|
|
46306
46461
|
if (frame === void 0) {
|
|
46307
|
-
frame = { values: values2, index: 1, depth, capture };
|
|
46462
|
+
frame = { values: values2, index: 1, depth, capture, proxy };
|
|
46308
46463
|
nativeDataArrayAppend(frames, frame);
|
|
46309
46464
|
} else {
|
|
46310
46465
|
frame.values = values2;
|
|
46311
46466
|
frame.index = 1;
|
|
46312
46467
|
frame.depth = depth;
|
|
46313
46468
|
frame.capture = capture;
|
|
46469
|
+
frame.proxy = proxy;
|
|
46314
46470
|
}
|
|
46315
46471
|
pendingCount++;
|
|
46316
46472
|
};
|
|
@@ -46351,6 +46507,47 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46351
46507
|
}
|
|
46352
46508
|
captures = appendCapture(captures, value);
|
|
46353
46509
|
};
|
|
46510
|
+
const collector = createMeasurementCollector(appendNativeCapture);
|
|
46511
|
+
const visitTemporalIntl = (value, depth) => {
|
|
46512
|
+
if (isSandboxTemporalInstant(value)) visit(temporalInstantEpoch(value), depth + 1);
|
|
46513
|
+
if (isSandboxTemporalDuration(value)) usage += temporalDurationFieldNames.length * 8;
|
|
46514
|
+
if (isSandboxTemporalPlainTime(value)) usage += temporalPlainTimeFieldNames.length * 8;
|
|
46515
|
+
if (isSandboxTemporalPlainDateTime(value)) usage += temporalPlainDateTimeNumericFields.length * 8 + temporalPlainDateTimeFields(value).calendar.length;
|
|
46516
|
+
if (isSandboxTemporalPlainDate(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainDateFields(value).calendar.length;
|
|
46517
|
+
if (isSandboxTemporalPlainMonthDay(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainMonthDayFields(value).calendar.length;
|
|
46518
|
+
if (isSandboxTemporalPlainYearMonth(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainYearMonthFields(value).calendar.length;
|
|
46519
|
+
if (isSandboxTemporalZonedDateTime(value)) {
|
|
46520
|
+
const fields2 = temporalZonedDateTimeFields(value);
|
|
46521
|
+
visit(fields2.epochNanoseconds, depth + 1);
|
|
46522
|
+
usage += fields2.timeZone.length + fields2.calendar.length;
|
|
46523
|
+
}
|
|
46524
|
+
if (isSandboxLocale(value)) usage += localeTag(value).length;
|
|
46525
|
+
if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
|
|
46526
|
+
if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
|
|
46527
|
+
if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
|
|
46528
|
+
if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
|
|
46529
|
+
if (isSandboxDurationFormat(value)) {
|
|
46530
|
+
const state = durationFormatState(value);
|
|
46531
|
+
visit(state.settings, depth + 1);
|
|
46532
|
+
visit(state.options, depth + 1);
|
|
46533
|
+
}
|
|
46534
|
+
if (isSandboxNumberFormat(value)) {
|
|
46535
|
+
const state = numberFormatState(value);
|
|
46536
|
+
visit(state.options, depth + 1);
|
|
46537
|
+
visit(state.format, depth + 1);
|
|
46538
|
+
}
|
|
46539
|
+
if (isSandboxDateTimeFormat(value)) {
|
|
46540
|
+
const state = dateTimeFormatState(value);
|
|
46541
|
+
visit(state.options, depth + 1);
|
|
46542
|
+
visit(state.requestedOptions, depth + 1);
|
|
46543
|
+
visit(state.format, depth + 1);
|
|
46544
|
+
}
|
|
46545
|
+
if (isSandboxCollator(value)) {
|
|
46546
|
+
const state = collatorState(value);
|
|
46547
|
+
visit(state.options, depth + 1);
|
|
46548
|
+
visit(state.compare, depth + 1);
|
|
46549
|
+
}
|
|
46550
|
+
};
|
|
46354
46551
|
const visit = (value, depth = 0) => {
|
|
46355
46552
|
const floor = pendingCount;
|
|
46356
46553
|
walk: while (true) {
|
|
@@ -46390,6 +46587,30 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46390
46587
|
const bindingRoot = scopeDataRoots.get(value);
|
|
46391
46588
|
if (bindingRoot !== void 0) {
|
|
46392
46589
|
seen.add(value);
|
|
46590
|
+
if ("arguments" in bindingRoot) {
|
|
46591
|
+
const state = bindingRoot.arguments;
|
|
46592
|
+
const current = state.read();
|
|
46593
|
+
if (current !== void 0) {
|
|
46594
|
+
value = current;
|
|
46595
|
+
continue walk;
|
|
46596
|
+
}
|
|
46597
|
+
assertSandboxDataDepth(depth);
|
|
46598
|
+
const snapshot = state.capture();
|
|
46599
|
+
const includeIterator = !internalSymbols.has(snapshot.iterator);
|
|
46600
|
+
const includeBrand = !internalSymbols.has(sandboxArgumentsBrand);
|
|
46601
|
+
const units = snapshot.units + (includeIterator ? 1 : 0) + (includeBrand ? 1 : 0);
|
|
46602
|
+
usage += units;
|
|
46603
|
+
pendingArguments ??= nativeDataArraySetPrototype([], null);
|
|
46604
|
+
nativeDataArrayAppend(pendingArguments, { state, units, depth });
|
|
46605
|
+
if (includeIterator) visit(snapshot.iterator, depth + 1);
|
|
46606
|
+
if (includeBrand) visit(sandboxArgumentsBrand, depth + 1);
|
|
46607
|
+
const references = snapshot.references;
|
|
46608
|
+
if (references.length === 0) break entry;
|
|
46609
|
+
if (references.length > 1) appendContinuation(references, depth + 1);
|
|
46610
|
+
value = references[0];
|
|
46611
|
+
depth++;
|
|
46612
|
+
continue walk;
|
|
46613
|
+
}
|
|
46393
46614
|
if ("deferred" in bindingRoot) {
|
|
46394
46615
|
const deferred2 = bindingRoot.deferred;
|
|
46395
46616
|
const current = deferred2.read();
|
|
@@ -46402,10 +46623,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46402
46623
|
seen.add(deferred2.chargeIdentity);
|
|
46403
46624
|
usage++;
|
|
46404
46625
|
}
|
|
46626
|
+
if (pendingFunctions === void 0) {
|
|
46627
|
+
pendingFunctions = nativeDataArraySetPrototype([], null);
|
|
46628
|
+
pendingFunctionDepths = nativeDataArraySetPrototype([], null);
|
|
46629
|
+
}
|
|
46630
|
+
const pendingIndex = pendingFunctions.length;
|
|
46631
|
+
pendingFunctions[pendingIndex] = deferred2;
|
|
46632
|
+
pendingFunctionDepths[pendingIndex] = depth;
|
|
46405
46633
|
if (options.ignoreClosures || options.ignoreClosureCaptures) break entry;
|
|
46406
46634
|
let roots2;
|
|
46407
46635
|
try {
|
|
46408
|
-
deferred2.collect(
|
|
46636
|
+
deferred2.collect(collector.append);
|
|
46409
46637
|
roots2 = captures;
|
|
46410
46638
|
} finally {
|
|
46411
46639
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46466,8 +46694,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46466
46694
|
for (const cell of finalization.state.cells) visit(cell.heldValue, depth + 1);
|
|
46467
46695
|
}
|
|
46468
46696
|
if (proxyState !== void 0) {
|
|
46469
|
-
if (proxyState.target !== null)
|
|
46470
|
-
|
|
46697
|
+
if (proxyState.target !== null) {
|
|
46698
|
+
value = proxyState.target;
|
|
46699
|
+
appendContinuation(void 0, depth + 1, void 0, proxyState);
|
|
46700
|
+
depth++;
|
|
46701
|
+
continue walk;
|
|
46702
|
+
}
|
|
46703
|
+
if (proxyState.handler !== null) {
|
|
46704
|
+
value = proxyState.handler;
|
|
46705
|
+
depth++;
|
|
46706
|
+
continue walk;
|
|
46707
|
+
}
|
|
46471
46708
|
break entry;
|
|
46472
46709
|
}
|
|
46473
46710
|
if (dynamicSourceRecords.has(value)) {
|
|
@@ -46504,9 +46741,22 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46504
46741
|
const managedArray = arrayLength !== void 0 && hasManagedDescriptors(value);
|
|
46505
46742
|
let arrayDescriptors;
|
|
46506
46743
|
let arrayElements;
|
|
46507
|
-
|
|
46744
|
+
const arrayData = arrayLength !== void 0 && !managedArray ? trackedArrayElementData(value) : void 0;
|
|
46745
|
+
if (arrayLength !== void 0 && arrayData === void 0) {
|
|
46508
46746
|
if (managedArray) arrayDescriptors = nativeDataArraySetPrototype([], null);
|
|
46509
|
-
|
|
46747
|
+
const trackedDescriptors2 = trackedPropertyDataDescriptors(value);
|
|
46748
|
+
if (trackedDescriptors2 !== void 0) {
|
|
46749
|
+
for (let index = 0; index < trackedDescriptors2.length; index++) {
|
|
46750
|
+
const entry = trackedDescriptors2[index];
|
|
46751
|
+
const key = entry[0], descriptor = entry[1];
|
|
46752
|
+
if (key === "length") {
|
|
46753
|
+
if (!managedArray) break;
|
|
46754
|
+
continue;
|
|
46755
|
+
}
|
|
46756
|
+
if (arrayDescriptors !== void 0) nativeDataArrayAppend(arrayDescriptors, [key, descriptor]);
|
|
46757
|
+
else if ("value" in descriptor && typeof descriptor.value !== "number") arrayElements = appendCapture(arrayElements, descriptor.value);
|
|
46758
|
+
}
|
|
46759
|
+
} else if (!managedArray && nodeTypes.isProxy(value)) {
|
|
46510
46760
|
for (let index = 0; index < arrayLength; index += 1) {
|
|
46511
46761
|
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
46512
46762
|
if (descriptor !== void 0 && "value" in descriptor) arrayElements = appendCapture(arrayElements, descriptor.value);
|
|
@@ -46541,23 +46791,54 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46541
46791
|
}
|
|
46542
46792
|
}
|
|
46543
46793
|
if (knownClosure || !isGuestHostObject(value)) {
|
|
46544
|
-
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value);
|
|
46794
|
+
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value) ?? readSealedValueSymbols(value);
|
|
46795
|
+
let firstSymbol;
|
|
46796
|
+
let firstDescriptor;
|
|
46545
46797
|
let descriptors2;
|
|
46546
46798
|
if (ownedSymbols !== void 0) {
|
|
46547
|
-
for (let index = 0; index < ownedSymbols.length; index++)
|
|
46548
|
-
|
|
46799
|
+
for (let index = 0; index < ownedSymbols.length; index++) {
|
|
46800
|
+
const key = ownedSymbols[index];
|
|
46801
|
+
if (internalSymbols.has(key)) continue;
|
|
46802
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
46803
|
+
if (descriptor === void 0) continue;
|
|
46804
|
+
if (firstDescriptor === void 0) {
|
|
46805
|
+
firstSymbol = key;
|
|
46806
|
+
firstDescriptor = descriptor;
|
|
46807
|
+
} else {
|
|
46808
|
+
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
46809
|
+
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
46810
|
+
}
|
|
46811
|
+
}
|
|
46549
46812
|
} else {
|
|
46550
46813
|
const symbols = isNumericTypedArray(value) ? typedArraySymbolKeys(value) : Object.getOwnPropertySymbols(value);
|
|
46551
|
-
for (const key of symbols)
|
|
46814
|
+
for (const key of symbols) {
|
|
46815
|
+
if (internalSymbols.has(key)) continue;
|
|
46816
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
46817
|
+
if (descriptor === void 0) continue;
|
|
46818
|
+
if (firstDescriptor === void 0) {
|
|
46819
|
+
firstSymbol = key;
|
|
46820
|
+
firstDescriptor = descriptor;
|
|
46821
|
+
} else {
|
|
46822
|
+
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
46823
|
+
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
46824
|
+
}
|
|
46825
|
+
}
|
|
46552
46826
|
}
|
|
46553
|
-
if (
|
|
46554
|
-
const key = descriptors2[index];
|
|
46555
|
-
const descriptor = descriptors2[index + 1];
|
|
46827
|
+
if (firstDescriptor !== void 0) {
|
|
46556
46828
|
usage += 1;
|
|
46557
|
-
visit(
|
|
46558
|
-
if ("value" in
|
|
46559
|
-
else for (const closure of retainedAccessorClosures(
|
|
46829
|
+
visit(firstSymbol, depth + 1);
|
|
46830
|
+
if ("value" in firstDescriptor) visit(firstDescriptor.value, depth + 1);
|
|
46831
|
+
else for (const closure of retainedAccessorClosures(firstDescriptor)) visit(closure, depth + 1);
|
|
46560
46832
|
}
|
|
46833
|
+
if (descriptors2 !== void 0)
|
|
46834
|
+
for (let index = 0; index < descriptors2.length; index += 2) {
|
|
46835
|
+
const key = descriptors2[index];
|
|
46836
|
+
const descriptor = descriptors2[index + 1];
|
|
46837
|
+
usage += 1;
|
|
46838
|
+
visit(key, depth + 1);
|
|
46839
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
46840
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
46841
|
+
}
|
|
46561
46842
|
}
|
|
46562
46843
|
if (knownClosure || isSandboxClosure(value)) {
|
|
46563
46844
|
const closure = value;
|
|
@@ -46578,7 +46859,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46578
46859
|
if (collect !== void 0) {
|
|
46579
46860
|
let roots2;
|
|
46580
46861
|
try {
|
|
46581
|
-
collect(
|
|
46862
|
+
collect(collector.append);
|
|
46582
46863
|
roots2 = captures;
|
|
46583
46864
|
} finally {
|
|
46584
46865
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46592,7 +46873,11 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46592
46873
|
depth++;
|
|
46593
46874
|
continue walk;
|
|
46594
46875
|
}
|
|
46595
|
-
} else
|
|
46876
|
+
} else {
|
|
46877
|
+
const roots2 = closure[sandboxRetainedValues]?.();
|
|
46878
|
+
if (roots2 !== void 0 && roots2 !== null)
|
|
46879
|
+
for (const root of roots2) visit(root, depth + 1);
|
|
46880
|
+
}
|
|
46596
46881
|
}
|
|
46597
46882
|
break entry;
|
|
46598
46883
|
}
|
|
@@ -46650,44 +46935,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46650
46935
|
visit(helperState.callback, depth + 1);
|
|
46651
46936
|
}
|
|
46652
46937
|
if (isSandboxDate(value)) usage += 8;
|
|
46653
|
-
|
|
46654
|
-
if (isSandboxTemporalDuration(value)) usage += temporalDurationFieldNames.length * 8;
|
|
46655
|
-
if (isSandboxTemporalPlainTime(value)) usage += temporalPlainTimeFieldNames.length * 8;
|
|
46656
|
-
if (isSandboxTemporalPlainDateTime(value)) usage += temporalPlainDateTimeNumericFields.length * 8 + temporalPlainDateTimeFields(value).calendar.length;
|
|
46657
|
-
if (isSandboxTemporalPlainDate(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainDateFields(value).calendar.length;
|
|
46658
|
-
if (isSandboxTemporalPlainMonthDay(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainMonthDayFields(value).calendar.length;
|
|
46659
|
-
if (isSandboxTemporalPlainYearMonth(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainYearMonthFields(value).calendar.length;
|
|
46660
|
-
if (isSandboxTemporalZonedDateTime(value)) {
|
|
46661
|
-
const fields2 = temporalZonedDateTimeFields(value);
|
|
46662
|
-
visit(fields2.epochNanoseconds, depth + 1);
|
|
46663
|
-
usage += fields2.timeZone.length + fields2.calendar.length;
|
|
46664
|
-
}
|
|
46665
|
-
if (isSandboxLocale(value)) usage += localeTag(value).length;
|
|
46666
|
-
if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
|
|
46667
|
-
if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
|
|
46668
|
-
if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
|
|
46669
|
-
if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
|
|
46670
|
-
if (isSandboxDurationFormat(value)) {
|
|
46671
|
-
const state = durationFormatState(value);
|
|
46672
|
-
visit(state.settings, depth + 1);
|
|
46673
|
-
visit(state.options, depth + 1);
|
|
46674
|
-
}
|
|
46675
|
-
if (isSandboxNumberFormat(value)) {
|
|
46676
|
-
const state = numberFormatState(value);
|
|
46677
|
-
visit(state.options, depth + 1);
|
|
46678
|
-
visit(state.format, depth + 1);
|
|
46679
|
-
}
|
|
46680
|
-
if (isSandboxDateTimeFormat(value)) {
|
|
46681
|
-
const state = dateTimeFormatState(value);
|
|
46682
|
-
visit(state.options, depth + 1);
|
|
46683
|
-
visit(state.requestedOptions, depth + 1);
|
|
46684
|
-
visit(state.format, depth + 1);
|
|
46685
|
-
}
|
|
46686
|
-
if (isSandboxCollator(value)) {
|
|
46687
|
-
const state = collatorState(value);
|
|
46688
|
-
visit(state.options, depth + 1);
|
|
46689
|
-
visit(state.compare, depth + 1);
|
|
46690
|
-
}
|
|
46938
|
+
visitTemporalIntl(value, depth);
|
|
46691
46939
|
if (isGuestHostObject(value)) {
|
|
46692
46940
|
usage += measureHostObjectData(value);
|
|
46693
46941
|
const root = hostObjectGuestRoot(value);
|
|
@@ -46722,6 +46970,15 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46722
46970
|
}
|
|
46723
46971
|
if (arrayLength !== void 0) {
|
|
46724
46972
|
usage += arrayLength;
|
|
46973
|
+
if (arrayData !== void 0) {
|
|
46974
|
+
usage += arrayData.units;
|
|
46975
|
+
const references = arrayData.references;
|
|
46976
|
+
if (references.length === 0) break entry;
|
|
46977
|
+
if (references.length > 1) appendContinuation(references, depth + 1);
|
|
46978
|
+
value = references[0];
|
|
46979
|
+
depth++;
|
|
46980
|
+
continue walk;
|
|
46981
|
+
}
|
|
46725
46982
|
let retained = arrayElements;
|
|
46726
46983
|
if (arrayDescriptors !== void 0) {
|
|
46727
46984
|
for (let index = 0; index < arrayDescriptors.length; index++) {
|
|
@@ -46934,7 +47191,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46934
47191
|
try {
|
|
46935
47192
|
for (let index = 0; index < (trackedDescriptors?.length ?? keys.length); index++) {
|
|
46936
47193
|
const key = trackedDescriptors === void 0 ? keys[index] : trackedDescriptors[index][0];
|
|
46937
|
-
const descriptor = trackedDescriptors === void 0 ? proxyDescriptors === void 0 ? Object.getOwnPropertyDescriptor(value, key) : proxyDescriptors[index] : trackedDescriptors[index][1];
|
|
47194
|
+
const descriptor = trackedDescriptors === void 0 || metadata !== void 0 && trackedPropertyDataDescriptors(value) !== trackedDescriptors ? proxyDescriptors === void 0 ? Object.getOwnPropertyDescriptor(value, key) : proxyDescriptors[index] : trackedDescriptors[index][1];
|
|
46938
47195
|
if (descriptor === void 0) continue;
|
|
46939
47196
|
if (!descriptor.enumerable && !includeNonEnumerable) continue;
|
|
46940
47197
|
const initial = metadata?.get(key);
|
|
@@ -46963,6 +47220,18 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46963
47220
|
while (pendingCount > floor) {
|
|
46964
47221
|
const frame = pending[pendingCount - 1];
|
|
46965
47222
|
const references = frame.values;
|
|
47223
|
+
if (references === void 0) {
|
|
47224
|
+
const proxy = frame.proxy;
|
|
47225
|
+
const handlerDepth = frame.depth;
|
|
47226
|
+
frame.proxy = void 0;
|
|
47227
|
+
pendingCount--;
|
|
47228
|
+
if (proxy.handler !== null) {
|
|
47229
|
+
value = proxy.handler;
|
|
47230
|
+
depth = handlerDepth;
|
|
47231
|
+
continue walk;
|
|
47232
|
+
}
|
|
47233
|
+
continue;
|
|
47234
|
+
}
|
|
46966
47235
|
if (frame.index < (frame.capture?.length ?? references.length)) {
|
|
46967
47236
|
value = references[frame.index++];
|
|
46968
47237
|
depth = frame.depth;
|
|
@@ -46976,20 +47245,57 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46976
47245
|
return;
|
|
46977
47246
|
}
|
|
46978
47247
|
};
|
|
47248
|
+
if (retainCode) {
|
|
47249
|
+
retainedMeasurementCode = visit;
|
|
47250
|
+
collector.close();
|
|
47251
|
+
return 0;
|
|
47252
|
+
}
|
|
46979
47253
|
try {
|
|
46980
47254
|
for (const value of values) visit(value);
|
|
46981
|
-
|
|
46982
|
-
|
|
46983
|
-
|
|
46984
|
-
|
|
46985
|
-
|
|
46986
|
-
|
|
46987
|
-
|
|
46988
|
-
|
|
46989
|
-
|
|
46990
|
-
|
|
47255
|
+
let readyIndex = 0;
|
|
47256
|
+
let primitiveIndex = 0;
|
|
47257
|
+
let materialized;
|
|
47258
|
+
do {
|
|
47259
|
+
materialized = false;
|
|
47260
|
+
for (; readyIndex < (ready?.length ?? 0); readyIndex++) {
|
|
47261
|
+
const contribution = ready[readyIndex];
|
|
47262
|
+
usage += 1;
|
|
47263
|
+
visit(contribution.value, contribution.depth);
|
|
47264
|
+
}
|
|
47265
|
+
for (let index = 0; index < (pendingArguments?.length ?? 0); index++) {
|
|
47266
|
+
const projection = pendingArguments[index];
|
|
47267
|
+
if (projection.units === void 0) continue;
|
|
47268
|
+
const current = projection.state.read();
|
|
47269
|
+
if (current === void 0) continue;
|
|
47270
|
+
usage -= projection.units;
|
|
47271
|
+
projection.units = void 0;
|
|
47272
|
+
if (!seen.has(current)) {
|
|
47273
|
+
visit(current, projection.depth);
|
|
47274
|
+
materialized = true;
|
|
47275
|
+
}
|
|
47276
|
+
}
|
|
47277
|
+
for (let index = 0; index < (pendingFunctions?.length ?? 0); index++) {
|
|
47278
|
+
const state = pendingFunctions[index];
|
|
47279
|
+
if (state === void 0) continue;
|
|
47280
|
+
const current = state.read();
|
|
47281
|
+
if (current === void 0) continue;
|
|
47282
|
+
pendingFunctions[index] = void 0;
|
|
47283
|
+
materialized = true;
|
|
47284
|
+
if (!seen.has(current)) visit(current, pendingFunctionDepths[index]);
|
|
47285
|
+
}
|
|
47286
|
+
const previousPrimitiveIndex = primitiveIndex;
|
|
47287
|
+
for (; primitiveIndex < projectedPrimitives.length; primitiveIndex++) {
|
|
47288
|
+
const projection = projectedPrimitives[primitiveIndex];
|
|
47289
|
+
if (seen.has(projection.target)) continue;
|
|
47290
|
+
for (const item of projection.values)
|
|
47291
|
+
if ((typeof item !== "object" || item === null) && typeof item !== "symbol") visit(item, projection.depth);
|
|
47292
|
+
}
|
|
47293
|
+
if ((pendingArguments !== void 0 || pendingFunctions !== void 0) && primitiveIndex !== previousPrimitiveIndex)
|
|
47294
|
+
materialized = true;
|
|
47295
|
+
} while ((pendingArguments !== void 0 || pendingFunctions !== void 0) && (materialized || readyIndex < (ready?.length ?? 0)));
|
|
46991
47296
|
return usage;
|
|
46992
47297
|
} finally {
|
|
47298
|
+
collector.close();
|
|
46993
47299
|
firstSeenCapture = void 0;
|
|
46994
47300
|
secondSeenCapture = void 0;
|
|
46995
47301
|
thirdSeenCapture = void 0;
|
|
@@ -46999,6 +47305,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46999
47305
|
if (frame.capture !== void 0) releaseCaptures(frame.capture);
|
|
47000
47306
|
frame.capture = void 0;
|
|
47001
47307
|
frame.values = void 0;
|
|
47308
|
+
frame.proxy = void 0;
|
|
47002
47309
|
}
|
|
47003
47310
|
}
|
|
47004
47311
|
}
|
|
@@ -47031,15 +47338,6 @@ function reconcileCompiledValues(budget, values, compilation, parent, escaping =
|
|
|
47031
47338
|
for (const ticket of retained) compilation?.tickets.delete(ticket);
|
|
47032
47339
|
if (compilation !== void 0 && parent !== void 0) compilation.forward(included, parent);
|
|
47033
47340
|
}
|
|
47034
|
-
function captureRetainedSymbolProperty(value, key, descriptors2) {
|
|
47035
|
-
if (internalSymbols.has(key)) return descriptors2;
|
|
47036
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
47037
|
-
if (descriptor !== void 0) {
|
|
47038
|
-
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
47039
|
-
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
47040
|
-
}
|
|
47041
|
-
return descriptors2;
|
|
47042
|
-
}
|
|
47043
47341
|
function captureRegexData(value) {
|
|
47044
47342
|
const source = Object.getOwnPropertyDescriptor(value, "source");
|
|
47045
47343
|
const flags = Object.getOwnPropertyDescriptor(value, "flags");
|
|
@@ -48132,6 +48430,7 @@ var nativePropertyHasOwn = Object.hasOwn;
|
|
|
48132
48430
|
var nativePropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
48133
48431
|
var nativePropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
48134
48432
|
var nativePropertyPrototype = Object.getPrototypeOf;
|
|
48433
|
+
var nativePropertySetPrototype = Object.setPrototypeOf;
|
|
48135
48434
|
var nativePropertyFreeze = Object.freeze;
|
|
48136
48435
|
var nativePropertyWrite = Reflect.defineProperty;
|
|
48137
48436
|
var nativePropertyDelete = Reflect.deleteProperty;
|
|
@@ -48197,18 +48496,43 @@ function trackedPropertySymbols(value) {
|
|
|
48197
48496
|
}
|
|
48198
48497
|
function adjustScalarProperty(state, key, descriptor, direction) {
|
|
48199
48498
|
if (descriptor === void 0) return;
|
|
48499
|
+
if (state.array) {
|
|
48500
|
+
const index = +key;
|
|
48501
|
+
if (index < 0 || index >= 4294967295 || index % 1 !== 0 || `${index}` !== key) return;
|
|
48502
|
+
}
|
|
48200
48503
|
const hasValue = nativePropertyHasOwn(descriptor, "value");
|
|
48201
48504
|
const item = hasValue ? descriptor.value : void 0;
|
|
48202
48505
|
const scalar = hasValue && typeof item !== "bigint" && typeof item !== "symbol" && (typeof item !== "object" || item === null);
|
|
48203
48506
|
if (!scalar) state.nonScalarProperties += direction;
|
|
48204
|
-
const units = 1 + key.length + (typeof item === "string" ? item.length : 0);
|
|
48507
|
+
const units = (state.array ? 0 : 1 + key.length) + (typeof item === "string" ? item.length : 0);
|
|
48205
48508
|
state.allScalarUnits += direction * units;
|
|
48206
48509
|
if (descriptor.enumerable) state.enumerableScalarUnits += direction * units;
|
|
48207
48510
|
}
|
|
48208
48511
|
var emptyPropertyReferences = nativePropertyFreeze([]);
|
|
48512
|
+
function trackedArrayElementData(value) {
|
|
48513
|
+
const state = nativePropertyDataGet(value);
|
|
48514
|
+
if (state === void 0 || !state.array) return void 0;
|
|
48515
|
+
if (state.elements !== void 0) return state.elements;
|
|
48516
|
+
if (state.nonScalarProperties === 0)
|
|
48517
|
+
return state.elements = nativePropertyFreeze({ units: state.allScalarUnits, references: emptyPropertyReferences });
|
|
48518
|
+
const descriptors2 = trackedPropertyDataDescriptors(value);
|
|
48519
|
+
let units = 0;
|
|
48520
|
+
const references = [];
|
|
48521
|
+
for (let index = 0; index < descriptors2.length; index++) {
|
|
48522
|
+
const entry = descriptors2[index];
|
|
48523
|
+
if (entry[0] === "length") break;
|
|
48524
|
+
const descriptor = entry[1];
|
|
48525
|
+
if (!nativePropertyHasOwn(descriptor, "value")) return void 0;
|
|
48526
|
+
const item = descriptor.value;
|
|
48527
|
+
if (typeof item === "string") units += item.length;
|
|
48528
|
+
else if (typeof item === "bigint" || typeof item === "symbol" || typeof item === "object" && item !== null)
|
|
48529
|
+
nativePropertyWrite(references, references.length, { value: item, writable: true, enumerable: true, configurable: true });
|
|
48530
|
+
}
|
|
48531
|
+
return state.elements = nativePropertyFreeze({ units, references: nativePropertyFreeze(references) });
|
|
48532
|
+
}
|
|
48209
48533
|
function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
48210
48534
|
const state = nativePropertyDataGet(value);
|
|
48211
|
-
if (state === void 0 || state.
|
|
48535
|
+
if (state === void 0 || state.array) return void 0;
|
|
48212
48536
|
if (state.strings === void 0 && state.nonScalarProperties === 0) {
|
|
48213
48537
|
state.strings = nativePropertyFreeze({
|
|
48214
48538
|
all: nativePropertyFreeze({ units: state.allScalarUnits, references: emptyPropertyReferences }),
|
|
@@ -48223,8 +48547,16 @@ function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
|
48223
48547
|
const entry = descriptors2[index];
|
|
48224
48548
|
const key = entry[0], descriptor = entry[1];
|
|
48225
48549
|
if (!nativePropertyHasOwn(descriptor, "value")) {
|
|
48226
|
-
|
|
48227
|
-
|
|
48550
|
+
const units2 = 1 + key.length;
|
|
48551
|
+
allUnits += units2;
|
|
48552
|
+
if (descriptor.enumerable) enumerableUnits += units2;
|
|
48553
|
+
const closures2 = retainedAccessorClosures(descriptor);
|
|
48554
|
+
for (let cursor = 0; cursor < closures2.length; cursor++) {
|
|
48555
|
+
const item2 = closures2[cursor];
|
|
48556
|
+
nativePropertyWrite(allReferences, allReferences.length, { value: item2, writable: true, enumerable: true, configurable: true });
|
|
48557
|
+
if (descriptor.enumerable) nativePropertyWrite(enumerableReferences, enumerableReferences.length, { value: item2, writable: true, enumerable: true, configurable: true });
|
|
48558
|
+
}
|
|
48559
|
+
continue;
|
|
48228
48560
|
}
|
|
48229
48561
|
const item = descriptor.value;
|
|
48230
48562
|
const units = 1 + key.length + (typeof item === "string" ? item.length : 0);
|
|
@@ -48291,37 +48623,63 @@ function createIntrinsicObject(initial = /* @__PURE__ */ Object.create(null)) {
|
|
|
48291
48623
|
nativeIntrinsicObjectAdd(tracked);
|
|
48292
48624
|
return tracked;
|
|
48293
48625
|
}
|
|
48626
|
+
function createIntrinsicArray(initial) {
|
|
48627
|
+
const properties = [];
|
|
48628
|
+
if (initial !== void 0) {
|
|
48629
|
+
nativePropertySetPrototype(properties, nativePropertyPrototype(initial));
|
|
48630
|
+
nativePropertyDefine(properties, nativePropertyDescriptors(initial));
|
|
48631
|
+
}
|
|
48632
|
+
const tracked = trackPropertyTable(properties, true);
|
|
48633
|
+
nativeIntrinsicObjectAdd(tracked);
|
|
48634
|
+
return tracked;
|
|
48635
|
+
}
|
|
48294
48636
|
function isTrackedIntrinsicObject(value) {
|
|
48295
48637
|
return nativeIntrinsicObjectHas(value);
|
|
48296
48638
|
}
|
|
48297
|
-
function trackPropertyTable(properties) {
|
|
48639
|
+
function trackPropertyTable(properties, array2 = false) {
|
|
48298
48640
|
const state = { revision: 0 };
|
|
48299
48641
|
const data = {
|
|
48300
48642
|
backing: properties,
|
|
48643
|
+
array: array2,
|
|
48301
48644
|
allScalarUnits: 0,
|
|
48302
48645
|
enumerableScalarUnits: 0,
|
|
48303
48646
|
nonScalarProperties: 0,
|
|
48304
48647
|
symbols: void 0,
|
|
48305
48648
|
descriptors: void 0,
|
|
48306
|
-
strings: void 0
|
|
48649
|
+
strings: void 0,
|
|
48650
|
+
elements: void 0
|
|
48307
48651
|
};
|
|
48308
48652
|
const keys = nativePropertyNames(properties);
|
|
48309
48653
|
for (let index = 0; index < keys.length; index++) {
|
|
48310
48654
|
const key = keys[index];
|
|
48311
48655
|
adjustScalarProperty(data, key, nativePropertyDescriptor(properties, key), 1);
|
|
48312
48656
|
}
|
|
48313
|
-
const tracked = new NativePropertyProxy(properties, {
|
|
48657
|
+
const tracked = new NativePropertyProxy(properties, nativePropertySetPrototype({
|
|
48314
48658
|
defineProperty(target, key, descriptor) {
|
|
48659
|
+
const ownDescriptor = { __proto__: null, ...descriptor };
|
|
48315
48660
|
const previous = typeof key === "string" ? nativePropertyDescriptor(target, key) : void 0;
|
|
48316
|
-
const
|
|
48317
|
-
|
|
48661
|
+
const previousLength = array2 && key === "length" ? target.length : void 0;
|
|
48662
|
+
const changed = nativePropertyWrite(target, key, ownDescriptor);
|
|
48663
|
+
if (changed || array2) {
|
|
48318
48664
|
if (typeof key === "string") {
|
|
48319
|
-
|
|
48320
|
-
|
|
48665
|
+
if (previousLength !== void 0 && target.length < previousLength) {
|
|
48666
|
+
data.allScalarUnits = 0;
|
|
48667
|
+
data.enumerableScalarUnits = 0;
|
|
48668
|
+
data.nonScalarProperties = 0;
|
|
48669
|
+
const keys2 = nativePropertyNames(target);
|
|
48670
|
+
for (let index = 0; index < keys2.length; index++) {
|
|
48671
|
+
const name = keys2[index];
|
|
48672
|
+
adjustScalarProperty(data, name, nativePropertyDescriptor(target, name), 1);
|
|
48673
|
+
}
|
|
48674
|
+
} else {
|
|
48675
|
+
adjustScalarProperty(data, key, previous, -1);
|
|
48676
|
+
adjustScalarProperty(data, key, nativePropertyDescriptor(target, key), 1);
|
|
48677
|
+
}
|
|
48321
48678
|
} else data.symbols = void 0;
|
|
48322
48679
|
state.revision++;
|
|
48323
48680
|
data.descriptors = void 0;
|
|
48324
48681
|
data.strings = void 0;
|
|
48682
|
+
data.elements = void 0;
|
|
48325
48683
|
state.measuredDescriptors = void 0;
|
|
48326
48684
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48327
48685
|
}
|
|
@@ -48338,12 +48696,13 @@ function trackPropertyTable(properties) {
|
|
|
48338
48696
|
state.revision++;
|
|
48339
48697
|
data.descriptors = void 0;
|
|
48340
48698
|
data.strings = void 0;
|
|
48699
|
+
data.elements = void 0;
|
|
48341
48700
|
state.measuredDescriptors = void 0;
|
|
48342
48701
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48343
48702
|
}
|
|
48344
48703
|
return changed;
|
|
48345
48704
|
}
|
|
48346
|
-
});
|
|
48705
|
+
}, null));
|
|
48347
48706
|
nativePropertyStateSet(tracked, state);
|
|
48348
48707
|
nativePropertyDataSet(tracked, data);
|
|
48349
48708
|
return tracked;
|
|
@@ -48811,6 +49170,7 @@ export {
|
|
|
48811
49170
|
createReplayEncodingContext,
|
|
48812
49171
|
encodeReplayData,
|
|
48813
49172
|
decodeReplayData,
|
|
49173
|
+
declareBudgetedHostOperation,
|
|
48814
49174
|
declareHostOperation,
|
|
48815
49175
|
wrapCallerInjectedBindings,
|
|
48816
49176
|
copyHostValueToSandbox,
|
|
@@ -48920,4 +49280,4 @@ authorization of the copyright holder.
|
|
|
48920
49280
|
SPDX-License-Identifier: Unicode-3.0
|
|
48921
49281
|
|
|
48922
49282
|
*/
|
|
48923
|
-
//# sourceMappingURL=chunk-
|
|
49283
|
+
//# sourceMappingURL=chunk-ZHJPXLUJ.js.map
|