@poe-platform/safe-js 0.1.723 → 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/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js → chunk-2DISWAVU.js} +3 -3
- package/dist/safe-js/chunks/{chunk-M6HUSN7X.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-HY3Q377V.js → chunk-BYX6GUCC.js} +2 -2
- package/dist/safe-js/chunks/{chunk-QMZG576E.js → chunk-CSRNI5HI.js} +3 -3
- package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js → chunk-E5VQVLWF.js} +2 -2
- package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js → chunk-GM32LIKF.js} +4 -4
- package/dist/safe-js/chunks/{chunk-SWQHZKYM.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-KHJDAEET.js → chunk-TMRO2MK6.js} +4 -4
- package/dist/safe-js/chunks/{chunk-5MT2LF3W.js → chunk-WYY65M7Z.js} +3 -3
- package/dist/safe-js/chunks/{chunk-IZ52PAOD.js → chunk-ZHJPXLUJ.js} +823 -486
- package/dist/safe-js/chunks/{chunk-IZ52PAOD.js.map → chunk-ZHJPXLUJ.js.map} +4 -4
- package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js → cli-runtime-PHNOLXPN.js} +13 -13
- package/dist/safe-js/chunks/{dump-TWVEBH5W.js → dump-HAU2HFBZ.js} +4 -4
- package/dist/safe-js/chunks/{fs-DSNHTHBT.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 +13 -13
- package/dist/safe-js/interp/arguments.d.ts +1 -2
- 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-RYVHEOHM.js.map +0 -7
- package/dist/safe-js/chunks/harness-RLA643GD.js +0 -10
- package/dist/safe-js/chunks/mcp-IEY7HXXT.js +0 -11
- package/dist/safe-js/chunks/migration-file-QMI45CSP.js +0 -12
- package/dist/safe-js/chunks/restore-R5PLLBST.js +0 -13
- package/dist/safe-js/chunks/run-QATVEFVQ.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-5D7KDFMZ.js +0 -10
- /package/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js.map → chunk-2DISWAVU.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-M6HUSN7X.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-HY3Q377V.js.map → chunk-BYX6GUCC.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-QMZG576E.js.map → chunk-CSRNI5HI.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js.map → chunk-E5VQVLWF.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js.map → chunk-GM32LIKF.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-SWQHZKYM.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-KHJDAEET.js.map → chunk-TMRO2MK6.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-5MT2LF3W.js.map → chunk-WYY65M7Z.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js.map → cli-runtime-PHNOLXPN.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-TWVEBH5W.js.map → dump-HAU2HFBZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-DSNHTHBT.js.map → fs-6PHK3Q3V.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-RLA643GD.js.map → harness-E3FVGKIR.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-IEY7HXXT.js.map → mcp-HGLB4YOP.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-QMI45CSP.js.map → migration-file-4GNB4HDL.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-R5PLLBST.js.map → restore-ZFU4NJOM.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-QATVEFVQ.js.map → run-AAOCYT5M.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-5D7KDFMZ.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++) {
|
|
@@ -18449,7 +18537,10 @@ function splitNormalized(value, separator, limit, budget, parent) {
|
|
|
18449
18537
|
}
|
|
18450
18538
|
budget.allocateArrayLength(count);
|
|
18451
18539
|
}
|
|
18452
|
-
const
|
|
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;
|
|
18453
18544
|
budget.allocateArrayLength(result.length);
|
|
18454
18545
|
for (const part of result) budget.allocateString(part);
|
|
18455
18546
|
return result;
|
|
@@ -20811,8 +20902,8 @@ function serializeArguments(value, serializeValue) {
|
|
|
20811
20902
|
writable: descriptor.writable === true
|
|
20812
20903
|
};
|
|
20813
20904
|
}
|
|
20814
|
-
const
|
|
20815
|
-
if (
|
|
20905
|
+
const iterator2 = Object.getOwnPropertyDescriptor(value, Symbol.iterator);
|
|
20906
|
+
if (iterator2 !== void 0 && iterator2.value !== Array.prototype.values) {
|
|
20816
20907
|
throw new TypeError("Cannot snapshot a replaced arguments iterator.");
|
|
20817
20908
|
}
|
|
20818
20909
|
const names = Object.getOwnPropertyNames(value);
|
|
@@ -20820,10 +20911,10 @@ function serializeArguments(value, serializeValue) {
|
|
|
20820
20911
|
kind: "arguments",
|
|
20821
20912
|
extensible: Object.isExtensible(value),
|
|
20822
20913
|
lengthBeforeCallee: names.includes("length") && names.indexOf("length") < names.indexOf("callee"),
|
|
20823
|
-
iterator:
|
|
20824
|
-
configurable:
|
|
20825
|
-
enumerable:
|
|
20826
|
-
writable:
|
|
20914
|
+
iterator: iterator2 === void 0 ? null : {
|
|
20915
|
+
configurable: iterator2.configurable === true,
|
|
20916
|
+
enumerable: iterator2.enumerable === true,
|
|
20917
|
+
writable: iterator2.writable === true
|
|
20827
20918
|
},
|
|
20828
20919
|
properties
|
|
20829
20920
|
};
|
|
@@ -23063,7 +23154,7 @@ function readStringProperty(value, key) {
|
|
|
23063
23154
|
return descriptor !== void 0 && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
|
|
23064
23155
|
}
|
|
23065
23156
|
function copyFunctionProperties(callable, stackFrames, options, state, path) {
|
|
23066
|
-
const properties = {};
|
|
23157
|
+
const properties = createIntrinsicObject({});
|
|
23067
23158
|
const metadata = /* @__PURE__ */ new Map();
|
|
23068
23159
|
for (const key of Object.getOwnPropertyNames(callable)) {
|
|
23069
23160
|
const descriptor = Object.getOwnPropertyDescriptor(callable, key);
|
|
@@ -23316,8 +23407,8 @@ function callGeneratorMethod(target, method, value, budget, context, async) {
|
|
|
23316
23407
|
const result = (async () => {
|
|
23317
23408
|
if (!isSandboxGenerator(target) || target.async === true !== async)
|
|
23318
23409
|
throw new TypeError(`${async ? "AsyncGenerator" : "Generator"}.${method} requires a matching generator receiver.`);
|
|
23319
|
-
const
|
|
23320
|
-
const result2 = await
|
|
23410
|
+
const iterator2 = generatorIterator(target, budget, context);
|
|
23411
|
+
const result2 = await iterator2[method](value);
|
|
23321
23412
|
return allocateProducedSandboxValue(result2, budget);
|
|
23322
23413
|
})();
|
|
23323
23414
|
return async ? createSandboxPromise(result) : result;
|
|
@@ -23506,9 +23597,9 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23506
23597
|
const candidate = await readErrorProperty(newTarget, "prototype", budget, context);
|
|
23507
23598
|
const prototype = candidate !== null && typeof candidate === "object" ? candidate : getFunctionRealmPrototype(newTarget, name, errorPrototypes.get(budget).get(name));
|
|
23508
23599
|
let error;
|
|
23509
|
-
let
|
|
23600
|
+
let iterator2;
|
|
23510
23601
|
const errors = [];
|
|
23511
|
-
const release = retainValues(budget, () => [prototype, error,
|
|
23602
|
+
const release = retainValues(budget, () => [prototype, error, iterator2?.retainedValue, ...errors, ...args]);
|
|
23512
23603
|
try {
|
|
23513
23604
|
const message = name === "SuppressedError" ? args[2] : name === "AggregateError" ? args[1] : args[0];
|
|
23514
23605
|
const options = name === "SuppressedError" ? void 0 : name === "AggregateError" ? args[2] : args[1];
|
|
@@ -23528,15 +23619,15 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23528
23619
|
if (name === "AggregateError") {
|
|
23529
23620
|
const errorsPrototype = getSandboxPrototype(errors, budget);
|
|
23530
23621
|
if (errorsPrototype !== null) setSandboxPrototype(errors, errorsPrototype, budget);
|
|
23531
|
-
|
|
23532
|
-
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.");
|
|
23533
23624
|
while (true) {
|
|
23534
23625
|
budget.visitNode();
|
|
23535
|
-
const result = await
|
|
23626
|
+
const result = await iterator2.next();
|
|
23536
23627
|
if (result === null || typeof result !== "object") throw new TypeError("Iterator result must be an object.");
|
|
23537
|
-
if ((await readIteratorResult(
|
|
23628
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
23538
23629
|
budget.allocateArrayLength(errors.length + 1);
|
|
23539
|
-
errors.push((await readIteratorResult(
|
|
23630
|
+
errors.push((await readIteratorResult(iterator2, result, "value")).value);
|
|
23540
23631
|
}
|
|
23541
23632
|
Object.defineProperty(error, "errors", { value: errors, writable: true, configurable: true });
|
|
23542
23633
|
}
|
|
@@ -24068,7 +24159,7 @@ async function evaluateArrayExpression(node, context) {
|
|
|
24068
24159
|
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
24069
24160
|
if (restored !== void 0 && (restored.kind !== "array" || !Array.isArray(restored.values)))
|
|
24070
24161
|
throw new TypeError("Invalid array expression continuation.");
|
|
24071
|
-
const values = restored?.kind === "array" ? restored.values : [];
|
|
24162
|
+
const values = restored?.kind === "array" ? restored.values : context.scriptScope !== void 0 || context.moduleInstantiated !== void 0 ? createIntrinsicArray() : [];
|
|
24072
24163
|
if (restored === void 0) {
|
|
24073
24164
|
const prototype = getSandboxPrototype(values, context.budget);
|
|
24074
24165
|
if (prototype !== null) setSandboxPrototype(values, prototype, context.budget);
|
|
@@ -25192,13 +25283,13 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25192
25283
|
let resumeCurrent = saved !== void 0 && saved.phase !== "next";
|
|
25193
25284
|
let resumeNext = saved?.phase === "next";
|
|
25194
25285
|
let index = saved?.index ?? consumeRestoredLoopIterationIndex(node, context);
|
|
25195
|
-
const
|
|
25196
|
-
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) {
|
|
25197
25288
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
25198
25289
|
}
|
|
25199
25290
|
const nextIteration = async () => {
|
|
25200
|
-
if ((context.asyncFunction || context.asyncGeneratorFrame !== void 0) && node.await &&
|
|
25201
|
-
|
|
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, {
|
|
25202
25293
|
...context,
|
|
25203
25294
|
generatorExpressionStates: new Map([
|
|
25204
25295
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25211,7 +25302,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25211
25302
|
current: void 0,
|
|
25212
25303
|
index,
|
|
25213
25304
|
scope: context.scope,
|
|
25214
|
-
iterator
|
|
25305
|
+
iterator: iterator2
|
|
25215
25306
|
}]
|
|
25216
25307
|
])
|
|
25217
25308
|
}, void 0, createCoercionContext(context));
|
|
@@ -25219,14 +25310,14 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25219
25310
|
if (resumeNext) {
|
|
25220
25311
|
resumeNext = false;
|
|
25221
25312
|
if (saved?.awaitState === void 0) throw new TypeError("Missing iterator await continuation.");
|
|
25222
|
-
return await
|
|
25313
|
+
return await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25223
25314
|
}
|
|
25224
|
-
return await
|
|
25315
|
+
return await iterator2.next();
|
|
25225
25316
|
} finally {
|
|
25226
|
-
delete
|
|
25317
|
+
delete iterator2.awaitValue;
|
|
25227
25318
|
}
|
|
25228
25319
|
}
|
|
25229
|
-
const pending = Promise.resolve(
|
|
25320
|
+
const pending = Promise.resolve(iterator2.next());
|
|
25230
25321
|
if (!node.await) return pending;
|
|
25231
25322
|
context.onSuspend?.();
|
|
25232
25323
|
const leaveAwait = context.budget.enterAwait();
|
|
@@ -25237,16 +25328,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25237
25328
|
}
|
|
25238
25329
|
};
|
|
25239
25330
|
const completion = context.evalCompletion ? new StatementCompletion(context.budget, true) : void 0;
|
|
25240
|
-
const releaseIterator = retainValues(context.budget, () => [value,
|
|
25331
|
+
const releaseIterator = retainValues(context.budget, () => [value, iterator2.retainedValue]);
|
|
25241
25332
|
const closeLoopIterator = async (completion2) => {
|
|
25242
25333
|
const preserveThrow = completion2.kind === "throw";
|
|
25243
|
-
if (!context.asyncFunction && context.asyncGeneratorFrame === void 0 || !node.await ||
|
|
25244
|
-
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);
|
|
25245
25336
|
return;
|
|
25246
25337
|
}
|
|
25247
25338
|
const { node: ignoredNode, stackFrames, ...metadata } = completion2;
|
|
25248
25339
|
const closeCompletion = { ...metadata, ...stackFrames === void 0 ? {} : { stackFrames: [...stackFrames] } };
|
|
25249
|
-
|
|
25340
|
+
iterator2.awaitValue = (awaited, awaitState) => suspendAsyncFunctionValue(awaited, node, {
|
|
25250
25341
|
...context,
|
|
25251
25342
|
generatorExpressionStates: new Map([
|
|
25252
25343
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25260,19 +25351,19 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25260
25351
|
current: void 0,
|
|
25261
25352
|
index,
|
|
25262
25353
|
scope: context.scope,
|
|
25263
|
-
iterator
|
|
25354
|
+
iterator: iterator2
|
|
25264
25355
|
}]
|
|
25265
25356
|
])
|
|
25266
25357
|
}, void 0, createCoercionContext(context));
|
|
25267
25358
|
try {
|
|
25268
25359
|
if (saved?.phase === "close" && context.generatorResume?.completed !== true) {
|
|
25269
25360
|
if (saved.awaitState === void 0) throw new TypeError("Missing iterator close continuation.");
|
|
25270
|
-
await
|
|
25271
|
-
} else await closeIterator(
|
|
25361
|
+
await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25362
|
+
} else await closeIterator(iterator2, preserveThrow);
|
|
25272
25363
|
} catch (error) {
|
|
25273
25364
|
if (!preserveThrow || isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
25274
25365
|
} finally {
|
|
25275
|
-
delete
|
|
25366
|
+
delete iterator2.awaitValue;
|
|
25276
25367
|
}
|
|
25277
25368
|
};
|
|
25278
25369
|
try {
|
|
@@ -25287,7 +25378,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25287
25378
|
if (typeof skippedIteration !== "object" || skippedIteration === null) {
|
|
25288
25379
|
throw new TypeError("Iterator result must be an object.");
|
|
25289
25380
|
}
|
|
25290
|
-
if ((await readIteratorResult(
|
|
25381
|
+
if ((await readIteratorResult(iterator2, skippedIteration, "done")).value) {
|
|
25291
25382
|
return completion?.normal() ?? normalEmptyResult();
|
|
25292
25383
|
}
|
|
25293
25384
|
}
|
|
@@ -25299,16 +25390,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25299
25390
|
if (typeof iteration !== "object" || iteration === null) {
|
|
25300
25391
|
throw new TypeError("Iterator result must be an object.");
|
|
25301
25392
|
}
|
|
25302
|
-
if ((await readIteratorResult(
|
|
25393
|
+
if ((await readIteratorResult(iterator2, iteration, "done")).value) {
|
|
25303
25394
|
context.activeLoopIterations.delete(nodeId);
|
|
25304
25395
|
return completion?.normal() ?? normalEmptyResult();
|
|
25305
25396
|
}
|
|
25306
|
-
const nextValue = (await readIteratorResult(
|
|
25397
|
+
const nextValue = (await readIteratorResult(iterator2, iteration, "value")).value;
|
|
25307
25398
|
context.activeLoopIterations.set(
|
|
25308
25399
|
nodeId,
|
|
25309
|
-
|
|
25400
|
+
iterator2.snapshotIndex === void 0 ? index : {
|
|
25310
25401
|
get index() {
|
|
25311
|
-
return
|
|
25402
|
+
return iterator2.snapshotIndex();
|
|
25312
25403
|
},
|
|
25313
25404
|
values: [value, nextValue]
|
|
25314
25405
|
}
|
|
@@ -25319,7 +25410,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25319
25410
|
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
25320
25411
|
generatorExpressionStates: new Map([
|
|
25321
25412
|
...context.generatorExpressionStates ?? [],
|
|
25322
|
-
[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 }]
|
|
25323
25414
|
])
|
|
25324
25415
|
}
|
|
25325
25416
|
});
|
|
@@ -25819,14 +25910,14 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25819
25910
|
return argument;
|
|
25820
25911
|
}
|
|
25821
25912
|
if (context.generatorResume?.completed === true) context.generatorResume = void 0;
|
|
25822
|
-
const
|
|
25913
|
+
const iterator2 = saved === void 0 ? await acquireSandboxIterator(
|
|
25823
25914
|
argument.value,
|
|
25824
25915
|
context.budget,
|
|
25825
25916
|
createCoercionContext(context),
|
|
25826
25917
|
context.asyncGenerator,
|
|
25827
25918
|
context.signal
|
|
25828
25919
|
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, context.budget, createCoercionContext(context), context.signal) : saved.iterator;
|
|
25829
|
-
if (
|
|
25920
|
+
if (iterator2 === void 0) {
|
|
25830
25921
|
throw new TypeError(`${String(argument.value)} is not a supported iterable`);
|
|
25831
25922
|
}
|
|
25832
25923
|
const state = {
|
|
@@ -25834,21 +25925,21 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25834
25925
|
async: context.asyncGenerator === true,
|
|
25835
25926
|
value: argument.value,
|
|
25836
25927
|
current: saved?.current,
|
|
25837
|
-
iterator,
|
|
25928
|
+
iterator: iterator2,
|
|
25838
25929
|
...saved?.phase === void 0 ? {} : { phase: saved.phase, awaitState: saved.awaitState, completion: saved.completion }
|
|
25839
25930
|
};
|
|
25840
25931
|
if (node.nodeId !== void 0) context = {
|
|
25841
25932
|
...context,
|
|
25842
25933
|
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
25843
25934
|
};
|
|
25844
|
-
if (context.asyncGeneratorFrame !== void 0 &&
|
|
25845
|
-
|
|
25935
|
+
if (context.asyncGeneratorFrame !== void 0 && iterator2.resumeAwait !== void 0)
|
|
25936
|
+
iterator2.awaitValue = (value, awaitState) => {
|
|
25846
25937
|
state.awaitState = awaitState;
|
|
25847
25938
|
return suspendAsyncFunctionValue(value, node, context, void 0, createCoercionContext(context));
|
|
25848
25939
|
};
|
|
25849
25940
|
const releaseIterator = retainValues(context.budget, () => [
|
|
25850
25941
|
argument.value,
|
|
25851
|
-
|
|
25942
|
+
iterator2.retainedValue,
|
|
25852
25943
|
state.current
|
|
25853
25944
|
]);
|
|
25854
25945
|
try {
|
|
@@ -25873,20 +25964,20 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25873
25964
|
let result;
|
|
25874
25965
|
if (resumeOperation) {
|
|
25875
25966
|
resumeOperation = false;
|
|
25876
|
-
if (
|
|
25967
|
+
if (iterator2.resumeAwait === void 0 || iterator2.awaitValue === void 0 || saved?.awaitState === void 0)
|
|
25877
25968
|
throw new TypeError("Missing delegated iterator await continuation.");
|
|
25878
|
-
result = await
|
|
25969
|
+
result = await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25879
25970
|
if (saved.phase === "close") throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25880
25971
|
context.generatorResume = void 0;
|
|
25881
25972
|
} else {
|
|
25882
|
-
const iteratorMethod =
|
|
25973
|
+
const iteratorMethod = iterator2.getOperation === void 0 ? iterator2[method] : await iterator2.getOperation(method);
|
|
25883
25974
|
if (iteratorMethod === void 0) {
|
|
25884
25975
|
if (completion.type === "throw") {
|
|
25885
|
-
if (
|
|
25976
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25886
25977
|
state.phase = "close";
|
|
25887
25978
|
state.completion = completion;
|
|
25888
25979
|
}
|
|
25889
|
-
await closeIterator(
|
|
25980
|
+
await closeIterator(iterator2, false, context.asyncGeneratorFrame === void 0 ? suspendJob : async (pending) => await suspendAsyncFunctionValue(createSandboxPromise(pending), node, context, void 0, createCoercionContext(context)));
|
|
25890
25981
|
throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25891
25982
|
}
|
|
25892
25983
|
if (context.asyncGenerator && completion.type === "return") {
|
|
@@ -25897,12 +25988,12 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25897
25988
|
}
|
|
25898
25989
|
return generatorCompletionResult(completion);
|
|
25899
25990
|
}
|
|
25900
|
-
if (
|
|
25991
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25901
25992
|
state.phase = "await";
|
|
25902
25993
|
state.completion = completion;
|
|
25903
25994
|
}
|
|
25904
25995
|
const pendingResult = Promise.resolve(iteratorMethod(completion.value));
|
|
25905
|
-
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);
|
|
25906
25997
|
}
|
|
25907
25998
|
delete state.phase;
|
|
25908
25999
|
delete state.awaitState;
|
|
@@ -25910,8 +26001,8 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25910
26001
|
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
25911
26002
|
throw new TypeError("Iterator result must be an object.");
|
|
25912
26003
|
}
|
|
25913
|
-
const done = (await readIteratorResult(
|
|
25914
|
-
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;
|
|
25915
26006
|
if (done) {
|
|
25916
26007
|
if (completion.type === "return") {
|
|
25917
26008
|
return generatorCompletionResult({ type: "return", value });
|
|
@@ -25932,7 +26023,7 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25932
26023
|
context.generatorResume = void 0;
|
|
25933
26024
|
}
|
|
25934
26025
|
} finally {
|
|
25935
|
-
delete
|
|
26026
|
+
delete iterator2.awaitValue;
|
|
25936
26027
|
releaseIterator();
|
|
25937
26028
|
}
|
|
25938
26029
|
}
|
|
@@ -27400,23 +27491,23 @@ async function evaluateSpreadElement(node, context) {
|
|
|
27400
27491
|
result: value
|
|
27401
27492
|
};
|
|
27402
27493
|
}
|
|
27403
|
-
const
|
|
27404
|
-
if (
|
|
27494
|
+
const iterator2 = await acquireSandboxIterator(value.value, context.budget, createCoercionContext(context));
|
|
27495
|
+
if (iterator2 === void 0) {
|
|
27405
27496
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
27406
27497
|
}
|
|
27407
27498
|
const spreadValues = [];
|
|
27408
|
-
const release = retainValues(context.budget, () => [value.value,
|
|
27499
|
+
const release = retainValues(context.budget, () => [value.value, iterator2.retainedValue, ...spreadValues]);
|
|
27409
27500
|
try {
|
|
27410
27501
|
while (true) {
|
|
27411
|
-
const next = await
|
|
27502
|
+
const next = await iterator2.next();
|
|
27412
27503
|
if (typeof next !== "object" || next === null) {
|
|
27413
27504
|
throw new TypeError("Iterator result must be an object.");
|
|
27414
27505
|
}
|
|
27415
|
-
const done =
|
|
27506
|
+
const done = iterator2.readResultProperty === void 0 ? next.done : (await readIteratorResult(iterator2, next, "done")).value;
|
|
27416
27507
|
if (done) {
|
|
27417
27508
|
break;
|
|
27418
27509
|
}
|
|
27419
|
-
const item =
|
|
27510
|
+
const item = iterator2.readResultProperty === void 0 ? next.value : (await readIteratorResult(iterator2, next, "value")).value;
|
|
27420
27511
|
spreadValues.push(item);
|
|
27421
27512
|
context.budget.allocateArrayLength(spreadValues.length);
|
|
27422
27513
|
}
|
|
@@ -28016,16 +28107,16 @@ function createGroupBy(budget, keyMode) {
|
|
|
28016
28107
|
call: async ([items, callback], context) => {
|
|
28017
28108
|
if (items === null || items === void 0) throw new TypeError("groupBy requires an iterable.");
|
|
28018
28109
|
if (!isSandboxClosure(callback)) throw new TypeError("groupBy requires a callable callback.");
|
|
28019
|
-
const
|
|
28020
|
-
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.");
|
|
28021
28112
|
const groups = createSandboxMap([]);
|
|
28022
28113
|
let value;
|
|
28023
28114
|
let key;
|
|
28024
|
-
const release = retainValues(budget, () => [groups, callback,
|
|
28115
|
+
const release = retainValues(budget, () => [groups, callback, iterator2.retainedValue, value, key]);
|
|
28025
28116
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
28026
28117
|
const closeOnThrow = async (error) => {
|
|
28027
28118
|
try {
|
|
28028
|
-
await closeIterator(
|
|
28119
|
+
await closeIterator(iterator2, true);
|
|
28029
28120
|
} catch (closeError) {
|
|
28030
28121
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28031
28122
|
}
|
|
@@ -28040,9 +28131,9 @@ function createGroupBy(budget, keyMode) {
|
|
|
28040
28131
|
} catch (error) {
|
|
28041
28132
|
await closeOnThrow(error);
|
|
28042
28133
|
}
|
|
28043
|
-
const next = await
|
|
28044
|
-
if ((await readIteratorResult(
|
|
28045
|
-
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;
|
|
28046
28137
|
try {
|
|
28047
28138
|
key = await invokeBuiltinClosure(callback, [value, index], budget, context, void 0);
|
|
28048
28139
|
if (keyMode === "property") key = await toPropertyKey(key, budget, context);
|
|
@@ -28226,9 +28317,9 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
28226
28317
|
const receiver = context?.thisValue;
|
|
28227
28318
|
if (receiver === null || receiver === void 0) throw new TypeError("String iterator requires a receiver.");
|
|
28228
28319
|
const input = await sandboxString(receiver, budget, context);
|
|
28229
|
-
const
|
|
28230
|
-
setSandboxPrototype(
|
|
28231
|
-
return
|
|
28320
|
+
const iterator2 = restoreSandboxStringIterator({ input, index: 0 });
|
|
28321
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28322
|
+
return iterator2;
|
|
28232
28323
|
}
|
|
28233
28324
|
}), writable: true, configurable: true });
|
|
28234
28325
|
}
|
|
@@ -28416,7 +28507,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28416
28507
|
sandbox: true,
|
|
28417
28508
|
call: async ([prototype, descriptors2], context) => {
|
|
28418
28509
|
if (prototype !== null) objectProperties(prototype);
|
|
28419
|
-
const value =
|
|
28510
|
+
const value = createIntrinsicObject();
|
|
28420
28511
|
setSandboxPrototype(value, prototype, options.budget);
|
|
28421
28512
|
if (descriptors2 !== void 0) {
|
|
28422
28513
|
await definePropertiesFromObject(value, descriptors2, options.budget, context);
|
|
@@ -28436,19 +28527,19 @@ function createObjectArrayGlobals(options) {
|
|
|
28436
28527
|
fromEntries: createSandboxClosure({
|
|
28437
28528
|
sandbox: true,
|
|
28438
28529
|
call: ([value], context) => {
|
|
28439
|
-
if (context !== void 0) return acquireSandboxIterator(value, options.budget, context).then((
|
|
28440
|
-
if (
|
|
28441
|
-
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);
|
|
28442
28533
|
});
|
|
28443
|
-
const
|
|
28444
|
-
if (
|
|
28534
|
+
const iterator2 = getSandboxIterator(value, options.budget, context);
|
|
28535
|
+
if (iterator2 === void 0) {
|
|
28445
28536
|
throw new TypeError("Object.fromEntries requires an iterable.");
|
|
28446
28537
|
}
|
|
28447
|
-
if (context === void 0 && !
|
|
28538
|
+
if (context === void 0 && !iterator2.generator && !iterator2.asynchronous) {
|
|
28448
28539
|
const object = allocateProducedSandboxValue(
|
|
28449
28540
|
Object.setPrototypeOf(
|
|
28450
28541
|
Reflect.apply(Object.fromEntries, Object, [
|
|
28451
|
-
{ [Symbol.iterator]: () =>
|
|
28542
|
+
{ [Symbol.iterator]: () => iterator2 }
|
|
28452
28543
|
]),
|
|
28453
28544
|
null
|
|
28454
28545
|
),
|
|
@@ -28458,7 +28549,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28458
28549
|
if (prototype !== null) setSandboxPrototype(object, prototype, options.budget);
|
|
28459
28550
|
return object;
|
|
28460
28551
|
}
|
|
28461
|
-
return objectFromSandboxEntries(value,
|
|
28552
|
+
return objectFromSandboxEntries(value, iterator2, options.budget, context);
|
|
28462
28553
|
},
|
|
28463
28554
|
name: "fromEntries",
|
|
28464
28555
|
length: 1
|
|
@@ -28723,9 +28814,9 @@ function createArrayGlobal(budget) {
|
|
|
28723
28814
|
const receiver = context?.thisValue;
|
|
28724
28815
|
if (receiver === null || receiver === void 0) throw new TypeError("Array iterator method requires a receiver.");
|
|
28725
28816
|
const source = typeof receiver === "object" ? receiver : createSandboxBox(receiver);
|
|
28726
|
-
const
|
|
28727
|
-
setSandboxPrototype(
|
|
28728
|
-
return
|
|
28817
|
+
const iterator2 = restoreSandboxArrayIterator({ source, index: 0, method });
|
|
28818
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28819
|
+
return iterator2;
|
|
28729
28820
|
}
|
|
28730
28821
|
});
|
|
28731
28822
|
Object.defineProperty(prototype, method, { value: closure, writable: true, configurable: true });
|
|
@@ -28844,7 +28935,7 @@ function createArrayGlobal(budget) {
|
|
|
28844
28935
|
installArrayPrototype(budget, prototype, constructor);
|
|
28845
28936
|
return constructor;
|
|
28846
28937
|
}
|
|
28847
|
-
async function objectFromSandboxEntries(items,
|
|
28938
|
+
async function objectFromSandboxEntries(items, iterator2, budget, context) {
|
|
28848
28939
|
const object = /* @__PURE__ */ Object.create(null);
|
|
28849
28940
|
const prototype = getSandboxPrototype(object, budget);
|
|
28850
28941
|
if (prototype !== null) setSandboxPrototype(object, prototype, budget);
|
|
@@ -28855,7 +28946,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28855
28946
|
const retained = {};
|
|
28856
28947
|
budget.setRetainedValues(retained, () => [
|
|
28857
28948
|
items,
|
|
28858
|
-
|
|
28949
|
+
iterator2.retainedValue,
|
|
28859
28950
|
object,
|
|
28860
28951
|
entry,
|
|
28861
28952
|
key,
|
|
@@ -28866,7 +28957,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28866
28957
|
const closeOnThrow = async (error) => {
|
|
28867
28958
|
failure = isCapturedException(error) ? error.reason : error;
|
|
28868
28959
|
try {
|
|
28869
|
-
await closeIterator(
|
|
28960
|
+
await closeIterator(iterator2, true);
|
|
28870
28961
|
} catch (closeError) {
|
|
28871
28962
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28872
28963
|
}
|
|
@@ -28880,12 +28971,12 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28880
28971
|
} catch (error) {
|
|
28881
28972
|
await closeOnThrow(error);
|
|
28882
28973
|
}
|
|
28883
|
-
const result = await
|
|
28974
|
+
const result = await iterator2.next();
|
|
28884
28975
|
if (typeof result !== "object" || result === null) {
|
|
28885
28976
|
throw new TypeError("Iterator result must be an object.");
|
|
28886
28977
|
}
|
|
28887
|
-
if ((await readIteratorResult(
|
|
28888
|
-
entry = (await readIteratorResult(
|
|
28978
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
28979
|
+
entry = (await readIteratorResult(iterator2, result, "value")).value;
|
|
28889
28980
|
try {
|
|
28890
28981
|
if (typeof entry !== "object" || entry === null) {
|
|
28891
28982
|
throw new TypeError("Object.fromEntries requires entry objects.");
|
|
@@ -28975,12 +29066,13 @@ function objectProperties(value, _mutable = false) {
|
|
|
28975
29066
|
return value;
|
|
28976
29067
|
}
|
|
28977
29068
|
function exposePropertyDescriptor(descriptor, budget) {
|
|
28978
|
-
const
|
|
29069
|
+
const properties = "value" in descriptor ? descriptor : {
|
|
28979
29070
|
get: accessorClosure(descriptor.get, budget),
|
|
28980
29071
|
set: accessorClosure(descriptor.set, budget),
|
|
28981
29072
|
enumerable: descriptor.enumerable,
|
|
28982
29073
|
configurable: descriptor.configurable
|
|
28983
29074
|
};
|
|
29075
|
+
const result = runResources.getStore()?.nativeDataResults === true ? properties : createIntrinsicObject(properties);
|
|
28984
29076
|
const prototype = getSandboxPrototype(result, budget);
|
|
28985
29077
|
if (prototype !== null) setSandboxPrototype(result, prototype, budget);
|
|
28986
29078
|
return result;
|
|
@@ -29150,8 +29242,8 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29150
29242
|
const iteratorMethod = observableMethod ? await context.getProperty(items, Symbol.iterator) : void 0;
|
|
29151
29243
|
if (iteratorMethod !== null && iteratorMethod !== void 0 && !isSandboxClosure(iteratorMethod) && typeof iteratorMethod !== "function")
|
|
29152
29244
|
throw new TypeError("Iterator method must be callable.");
|
|
29153
|
-
let
|
|
29154
|
-
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;
|
|
29155
29247
|
const constructor = context?.thisValue;
|
|
29156
29248
|
let result;
|
|
29157
29249
|
let currentValue;
|
|
@@ -29160,9 +29252,9 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29160
29252
|
budget.setRetainedValues(retained, () => [
|
|
29161
29253
|
// Once acquired, a rooted protocol iterator owns the remaining input. Keep
|
|
29162
29254
|
// the original only for array-like reads or implicit unrooted iterators.
|
|
29163
|
-
|
|
29255
|
+
iterator2?.retainedValue === void 0 ? items : void 0,
|
|
29164
29256
|
iteratorMethod,
|
|
29165
|
-
|
|
29257
|
+
iterator2?.retainedValue,
|
|
29166
29258
|
mapFn,
|
|
29167
29259
|
thisValue,
|
|
29168
29260
|
constructor,
|
|
@@ -29174,7 +29266,7 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29174
29266
|
const closeOnThrow = async (error) => {
|
|
29175
29267
|
failure = isCapturedException(error) ? error.reason : error;
|
|
29176
29268
|
try {
|
|
29177
|
-
if (
|
|
29269
|
+
if (iterator2 !== void 0) await closeIterator(iterator2, true);
|
|
29178
29270
|
} catch (closeError) {
|
|
29179
29271
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
29180
29272
|
}
|
|
@@ -29196,23 +29288,23 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29196
29288
|
) : createArrayFromConstructorArgs([length], budget);
|
|
29197
29289
|
checkData(result, 0, true);
|
|
29198
29290
|
if (observableMethod && iterable)
|
|
29199
|
-
|
|
29291
|
+
iterator2 = await getSandboxIteratorFromMethod(items, iteratorMethod, budget, context);
|
|
29200
29292
|
let index = 0;
|
|
29201
|
-
while (
|
|
29293
|
+
while (iterator2 !== void 0 || index < length) {
|
|
29202
29294
|
try {
|
|
29203
29295
|
budget.visitNode();
|
|
29204
|
-
if (
|
|
29296
|
+
if (iterator2 !== void 0 && index >= Number.MAX_SAFE_INTEGER)
|
|
29205
29297
|
throw new TypeError("Array.from input is too long.");
|
|
29206
29298
|
} catch (error) {
|
|
29207
29299
|
await closeOnThrow(error);
|
|
29208
29300
|
}
|
|
29209
|
-
if (
|
|
29210
|
-
const pending = Promise.resolve(
|
|
29301
|
+
if (iterator2 !== void 0) {
|
|
29302
|
+
const pending = Promise.resolve(iterator2.next());
|
|
29211
29303
|
const next = await (asyncProtocol ? awaitAsync(pending) : pending);
|
|
29212
29304
|
if (typeof next !== "object" || next === null)
|
|
29213
29305
|
throw new TypeError("Iterator result must be an object.");
|
|
29214
|
-
if ((await readIteratorResult(
|
|
29215
|
-
currentValue = (await readIteratorResult(
|
|
29306
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
29307
|
+
currentValue = (await readIteratorResult(iterator2, next, "value")).value;
|
|
29216
29308
|
} else {
|
|
29217
29309
|
currentValue = await read(index);
|
|
29218
29310
|
if (asyncProtocol) currentValue = await awaitAsync(awaitSandboxValue(currentValue, void 0, budget, context));
|
|
@@ -30101,17 +30193,17 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30101
30193
|
const promiseResolve = await readPromiseReceiverProperty(constructor, "resolve", prototype, context);
|
|
30102
30194
|
if (!isSandboxClosure(promiseResolve))
|
|
30103
30195
|
throw new TypeError("Promise constructor requires a callable resolve.");
|
|
30104
|
-
const
|
|
30105
|
-
if (
|
|
30106
|
-
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]);
|
|
30107
30199
|
try {
|
|
30108
30200
|
while (true) {
|
|
30109
30201
|
budget.visitNode();
|
|
30110
|
-
const next =
|
|
30202
|
+
const next = iterator2.generator || iterator2.asynchronous ? await iterator2.next() : iterator2.next();
|
|
30111
30203
|
if (typeof next !== "object" || next === null)
|
|
30112
30204
|
throw new TypeError("Iterator result must be an object.");
|
|
30113
|
-
if ((await readIteratorResult(
|
|
30114
|
-
const value = (await readIteratorResult(
|
|
30205
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
30206
|
+
const value = (await readIteratorResult(iterator2, next, "value")).value;
|
|
30115
30207
|
try {
|
|
30116
30208
|
budget.allocateArrayLength(aggregate.size + 1);
|
|
30117
30209
|
const entryIndex = aggregate.size++;
|
|
@@ -30145,7 +30237,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30145
30237
|
}
|
|
30146
30238
|
}
|
|
30147
30239
|
} catch (error) {
|
|
30148
|
-
await closeIterator(
|
|
30240
|
+
await closeIterator(iterator2, true);
|
|
30149
30241
|
throw error;
|
|
30150
30242
|
}
|
|
30151
30243
|
}
|
|
@@ -31685,11 +31777,11 @@ function createSetOperation(name, budget) {
|
|
|
31685
31777
|
const read = async (object, key) => context?.getProperty !== void 0 ? context.getProperty(object, key) : readPropertyDescriptor(getSandboxPropertyDescriptor(object, key, budget) ?? { value: void 0 }, object, context);
|
|
31686
31778
|
const iterationContext = { ...context, thisValue: receiver, stack: context?.stack ?? [], getProperty: read };
|
|
31687
31779
|
const result = createSandboxSet([]);
|
|
31688
|
-
let
|
|
31780
|
+
let iterator2;
|
|
31689
31781
|
let current;
|
|
31690
31782
|
let has2;
|
|
31691
31783
|
let keys;
|
|
31692
|
-
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys,
|
|
31784
|
+
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys, iterator2?.retainedValue]);
|
|
31693
31785
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
31694
31786
|
const add2 = (value) => {
|
|
31695
31787
|
budget.visitNode();
|
|
@@ -31710,7 +31802,7 @@ function createSetOperation(name, budget) {
|
|
|
31710
31802
|
if (name === "isSubsetOf" && receiver.values.size > size || name === "isSupersetOf" && receiver.values.size < size) return false;
|
|
31711
31803
|
const visitReceiver = name === "isSubsetOf" || (name === "intersection" || name === "difference" || name === "isDisjointFrom") && receiver.values.size <= size;
|
|
31712
31804
|
if (name === "union" || name === "symmetricDifference")
|
|
31713
|
-
|
|
31805
|
+
iterator2 = await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31714
31806
|
if (name === "union" || name === "symmetricDifference" || name === "difference")
|
|
31715
31807
|
for (const value of receiver.values) add2(value);
|
|
31716
31808
|
if (visitReceiver) {
|
|
@@ -31729,15 +31821,15 @@ function createSetOperation(name, budget) {
|
|
|
31729
31821
|
cursor.leave();
|
|
31730
31822
|
}
|
|
31731
31823
|
} else {
|
|
31732
|
-
|
|
31824
|
+
iterator2 ??= await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31733
31825
|
while (true) {
|
|
31734
31826
|
budget.visitNode();
|
|
31735
|
-
const next = await
|
|
31736
|
-
if ((await readIteratorResult(
|
|
31737
|
-
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;
|
|
31738
31830
|
const found = receiver.values.has(current);
|
|
31739
31831
|
if (name === "isSupersetOf" && !found || name === "isDisjointFrom" && found) {
|
|
31740
|
-
await closeIterator(
|
|
31832
|
+
await closeIterator(iterator2);
|
|
31741
31833
|
return false;
|
|
31742
31834
|
}
|
|
31743
31835
|
if (name === "union" || name === "intersection" && found || name === "symmetricDifference" && !found) add2(current);
|
|
@@ -31807,7 +31899,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31807
31899
|
return context.thisValue.values.size;
|
|
31808
31900
|
}
|
|
31809
31901
|
});
|
|
31810
|
-
for (const { name, constructor, methods: methods4, size, iterator } of [
|
|
31902
|
+
for (const { name, constructor, methods: methods4, size, iterator: iterator2 } of [
|
|
31811
31903
|
{ name: "Map", constructor: mapConstructor, methods: mapMethods, size: mapSize3, iterator: mapMethods.entries },
|
|
31812
31904
|
{ name: "Set", constructor: setConstructor, methods: setMethods, size: setSize2, iterator: setMethods.values }
|
|
31813
31905
|
]) {
|
|
@@ -31826,7 +31918,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31826
31918
|
Object.defineProperty(prototype, key, { value: method, writable: true, configurable: true });
|
|
31827
31919
|
Object.defineProperty(prototype, "size", { get: accessorAdapter(size, "get"), configurable: true });
|
|
31828
31920
|
Object.defineProperty(prototype, Symbol.toStringTag, { value: name, configurable: true });
|
|
31829
|
-
Object.defineProperty(prototype, Symbol.iterator, { value:
|
|
31921
|
+
Object.defineProperty(prototype, Symbol.iterator, { value: iterator2, writable: true, configurable: true });
|
|
31830
31922
|
installCollectionPrototype(budget, name, prototype, constructor);
|
|
31831
31923
|
for (const method of /* @__PURE__ */ new Set([...Object.values(methods4), size, species])) registerIntrinsicFunction(budget, method);
|
|
31832
31924
|
}
|
|
@@ -31954,14 +32046,14 @@ function populateCollection(source, collection, {
|
|
|
31954
32046
|
}) {
|
|
31955
32047
|
budget.allocateCollectionEntries(0);
|
|
31956
32048
|
let adder;
|
|
31957
|
-
const populate = (
|
|
31958
|
-
if (
|
|
32049
|
+
const populate = (iterator2) => {
|
|
32050
|
+
if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
31959
32051
|
let entry;
|
|
31960
32052
|
let failure;
|
|
31961
32053
|
const retained = {};
|
|
31962
32054
|
budget.setRetainedValues(retained, () => [
|
|
31963
32055
|
source,
|
|
31964
|
-
|
|
32056
|
+
iterator2.retainedValue,
|
|
31965
32057
|
collection,
|
|
31966
32058
|
adder,
|
|
31967
32059
|
entry,
|
|
@@ -31975,13 +32067,13 @@ function populateCollection(source, collection, {
|
|
|
31975
32067
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
31976
32068
|
throw error;
|
|
31977
32069
|
};
|
|
31978
|
-
if (
|
|
31979
|
-
return closeIterator(
|
|
32070
|
+
if (iterator2.getOperation !== void 0)
|
|
32071
|
+
return closeIterator(iterator2, true).then(() => {
|
|
31980
32072
|
throw error;
|
|
31981
32073
|
}, rethrow);
|
|
31982
32074
|
try {
|
|
31983
|
-
const closing =
|
|
31984
|
-
if (
|
|
32075
|
+
const closing = iterator2.return?.();
|
|
32076
|
+
if (iterator2.generator || iterator2.asynchronous)
|
|
31985
32077
|
return Promise.resolve(closing).then(() => {
|
|
31986
32078
|
throw error;
|
|
31987
32079
|
}, rethrow);
|
|
@@ -32011,16 +32103,16 @@ function populateCollection(source, collection, {
|
|
|
32011
32103
|
}
|
|
32012
32104
|
return false;
|
|
32013
32105
|
};
|
|
32014
|
-
if (
|
|
32106
|
+
if (iterator2.generator || iterator2.asynchronous || context !== void 0 || adder !== void 0) {
|
|
32015
32107
|
return (async () => {
|
|
32016
32108
|
try {
|
|
32017
32109
|
checkData(collection, 0, true);
|
|
32018
32110
|
while (true) {
|
|
32019
|
-
const result = await
|
|
32111
|
+
const result = await iterator2.next();
|
|
32020
32112
|
if (typeof result !== "object" || result === null)
|
|
32021
32113
|
throw new TypeError("Iterator result must be an object.");
|
|
32022
|
-
if ((await readIteratorResult(
|
|
32023
|
-
const value = (await readIteratorResult(
|
|
32114
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32115
|
+
const value = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32024
32116
|
await consume({ done: false, value });
|
|
32025
32117
|
}
|
|
32026
32118
|
checkData(collection, 0, true);
|
|
@@ -32032,7 +32124,7 @@ function populateCollection(source, collection, {
|
|
|
32032
32124
|
}
|
|
32033
32125
|
try {
|
|
32034
32126
|
checkData(collection, 0, true);
|
|
32035
|
-
while (!consume(
|
|
32127
|
+
while (!consume(iterator2.next())) {
|
|
32036
32128
|
}
|
|
32037
32129
|
checkData(collection, 0, true);
|
|
32038
32130
|
return collection;
|
|
@@ -32044,8 +32136,8 @@ function populateCollection(source, collection, {
|
|
|
32044
32136
|
const start = (candidate) => {
|
|
32045
32137
|
if (!isSandboxClosure(candidate)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32046
32138
|
if (getIntrinsicIdentity(candidate) !== JSON.stringify([name, "prototype", method])) adder = candidate;
|
|
32047
|
-
const
|
|
32048
|
-
return
|
|
32139
|
+
const iterator2 = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
|
|
32140
|
+
return iterator2 instanceof Promise ? iterator2.then(populate) : populate(iterator2);
|
|
32049
32141
|
};
|
|
32050
32142
|
const initialize = (prototype2) => {
|
|
32051
32143
|
if (typeof prototype2 !== "object" || prototype2 === null)
|
|
@@ -32092,14 +32184,14 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32092
32184
|
if (source === void 0 || source === null) return collection;
|
|
32093
32185
|
adder = await read(collection, adderName);
|
|
32094
32186
|
if (!isSandboxClosure(adder)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32095
|
-
const
|
|
32096
|
-
if (
|
|
32097
|
-
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]);
|
|
32098
32190
|
try {
|
|
32099
32191
|
while (true) {
|
|
32100
|
-
const next = await
|
|
32101
|
-
if ((await readIteratorResult(
|
|
32102
|
-
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;
|
|
32103
32195
|
try {
|
|
32104
32196
|
budget.visitNode();
|
|
32105
32197
|
if (kind === "map") {
|
|
@@ -32111,7 +32203,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32111
32203
|
entry = key = value = void 0;
|
|
32112
32204
|
} catch (error) {
|
|
32113
32205
|
try {
|
|
32114
|
-
await closeIterator(
|
|
32206
|
+
await closeIterator(iterator2, true);
|
|
32115
32207
|
} catch (closeError) {
|
|
32116
32208
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
32117
32209
|
}
|
|
@@ -32191,7 +32283,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32191
32283
|
|
|
32192
32284
|
// packages/safe-js/src/interp/globals/math-sum-precise.ts
|
|
32193
32285
|
async function sumPrecise(source, budget, context) {
|
|
32194
|
-
let
|
|
32286
|
+
let iterator2;
|
|
32195
32287
|
let current;
|
|
32196
32288
|
let recordValue;
|
|
32197
32289
|
let sum = 0n;
|
|
@@ -32201,25 +32293,25 @@ async function sumPrecise(source, budget, context) {
|
|
|
32201
32293
|
let count = 0;
|
|
32202
32294
|
const storage = new DataView(new ArrayBuffer(8));
|
|
32203
32295
|
const checkData = createDataCheckpoint(budget, context);
|
|
32204
|
-
const release = retainValues(budget, () => [source,
|
|
32296
|
+
const release = retainValues(budget, () => [source, iterator2?.retainedValue, recordValue, current, sum]);
|
|
32205
32297
|
try {
|
|
32206
32298
|
if (source === void 0 || source === null) throw new TypeError("Math.sumPrecise requires an iterable.");
|
|
32207
|
-
|
|
32208
|
-
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.");
|
|
32209
32301
|
checkData(source, 0, true);
|
|
32210
32302
|
while (true) {
|
|
32211
32303
|
budget.visitNode();
|
|
32212
|
-
const next =
|
|
32213
|
-
const result =
|
|
32304
|
+
const next = iterator2.next();
|
|
32305
|
+
const result = iterator2.asynchronous || iterator2.generator ? await next : next;
|
|
32214
32306
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
32215
32307
|
throw new TypeError("Iterator result must be an object.");
|
|
32216
32308
|
recordValue = result;
|
|
32217
32309
|
const record4 = result;
|
|
32218
|
-
if ((await readIteratorResult(
|
|
32219
|
-
current = (await readIteratorResult(
|
|
32310
|
+
if ((await readIteratorResult(iterator2, record4, "done")).value) break;
|
|
32311
|
+
current = (await readIteratorResult(iterator2, record4, "value")).value;
|
|
32220
32312
|
if (count >= Number.MAX_SAFE_INTEGER || typeof current !== "number") {
|
|
32221
32313
|
const error = count >= Number.MAX_SAFE_INTEGER ? new RangeError("Math.sumPrecise received too many elements.") : new TypeError("Math.sumPrecise requires number elements.");
|
|
32222
|
-
await closeIterator(
|
|
32314
|
+
await closeIterator(iterator2, true);
|
|
32223
32315
|
throw error;
|
|
32224
32316
|
}
|
|
32225
32317
|
count++;
|
|
@@ -32840,21 +32932,21 @@ async function cloneWithOptions(value, options, budget, context) {
|
|
|
32840
32932
|
})
|
|
32841
32933
|
};
|
|
32842
32934
|
let current;
|
|
32843
|
-
let
|
|
32935
|
+
let iterator2;
|
|
32844
32936
|
const items = [];
|
|
32845
|
-
const release = retainValues(budget, () => [value, options, current, items,
|
|
32937
|
+
const release = retainValues(budget, () => [value, options, current, items, iterator2?.retainedValue]);
|
|
32846
32938
|
try {
|
|
32847
32939
|
current = await bridge.getProperty(options, "transfer");
|
|
32848
32940
|
if (current !== void 0) {
|
|
32849
32941
|
if (current === null || typeof current !== "object") throw new TypeError("Transfer list must be an iterable object.");
|
|
32850
|
-
|
|
32851
|
-
if (
|
|
32942
|
+
iterator2 = await acquireSandboxIterator(current, budget, bridge);
|
|
32943
|
+
if (iterator2 === void 0) throw new TypeError("Transfer list must be iterable.");
|
|
32852
32944
|
for (; ; ) {
|
|
32853
32945
|
budget.visitNode();
|
|
32854
|
-
const result = await
|
|
32946
|
+
const result = await iterator2.next();
|
|
32855
32947
|
current = result;
|
|
32856
|
-
if ((await readIteratorResult(
|
|
32857
|
-
current = (await readIteratorResult(
|
|
32948
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32949
|
+
current = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32858
32950
|
if (current === null || typeof current !== "object") {
|
|
32859
32951
|
throw new TypeError("Transfer list elements must be objects.");
|
|
32860
32952
|
}
|
|
@@ -32929,8 +33021,8 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32929
33021
|
operation.release();
|
|
32930
33022
|
}
|
|
32931
33023
|
}
|
|
32932
|
-
const
|
|
32933
|
-
const first =
|
|
33024
|
+
const iterator2 = execute();
|
|
33025
|
+
const first = iterator2.next();
|
|
32934
33026
|
if (first.done) return first.value;
|
|
32935
33027
|
return (async () => {
|
|
32936
33028
|
let step = first;
|
|
@@ -32939,15 +33031,15 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32939
33031
|
const request = step.value;
|
|
32940
33032
|
if ("stringValue" in request) {
|
|
32941
33033
|
createDataCheckpoint(budget, context)(request.stringValue, 0, true);
|
|
32942
|
-
step =
|
|
33034
|
+
step = iterator2.next(await sandboxString(request.stringValue, budget, context));
|
|
32943
33035
|
} else {
|
|
32944
33036
|
createDataCheckpoint(budget, context)(request.receiver, 0, true);
|
|
32945
|
-
step =
|
|
33037
|
+
step = iterator2.next(await readPropertyDescriptor(request.descriptor, request.receiver, context));
|
|
32946
33038
|
}
|
|
32947
33039
|
}
|
|
32948
33040
|
return step.value;
|
|
32949
33041
|
} finally {
|
|
32950
|
-
|
|
33042
|
+
iterator2.return(void 0);
|
|
32951
33043
|
}
|
|
32952
33044
|
})();
|
|
32953
33045
|
}
|
|
@@ -37620,20 +37712,20 @@ function installIteratorFrom(constructor, budget) {
|
|
|
37620
37712
|
context = callContext(context);
|
|
37621
37713
|
if (input === null || typeof input !== "object" && typeof input !== "string")
|
|
37622
37714
|
throw new TypeError("Iterator.from requires an object or string.");
|
|
37623
|
-
let
|
|
37715
|
+
let iterator2 = input;
|
|
37624
37716
|
let next;
|
|
37625
|
-
const release = retainValues(budget, () => [input,
|
|
37717
|
+
const release = retainValues(budget, () => [input, iterator2, next]);
|
|
37626
37718
|
try {
|
|
37627
37719
|
const method = await context.getProperty(input, Symbol.iterator);
|
|
37628
37720
|
if (method !== void 0 && method !== null) {
|
|
37629
37721
|
if (!isSandboxClosure(method)) throw new TypeError("Symbol.iterator must be callable.");
|
|
37630
|
-
|
|
37722
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, input);
|
|
37631
37723
|
}
|
|
37632
|
-
if (
|
|
37633
|
-
next = await context.getProperty(
|
|
37634
|
-
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;
|
|
37635
37727
|
const wrapper = /* @__PURE__ */ Object.create(null);
|
|
37636
|
-
iteratorWrapperStates.set(wrapper, { iterator, next });
|
|
37728
|
+
iteratorWrapperStates.set(wrapper, { iterator: iterator2, next });
|
|
37637
37729
|
setSandboxPrototype(wrapper, prototype, budget);
|
|
37638
37730
|
createDataCheckpoint(budget, context)(wrapper, 0, true);
|
|
37639
37731
|
return wrapper;
|
|
@@ -37698,7 +37790,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37698
37790
|
}
|
|
37699
37791
|
const release = retainValues(budget, () => [receiver, callback, next, accumulator, value, values]);
|
|
37700
37792
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
37701
|
-
const
|
|
37793
|
+
const iterator2 = {
|
|
37702
37794
|
asynchronous: true,
|
|
37703
37795
|
next: async () => {
|
|
37704
37796
|
if (!isSandboxClosure(next)) throw new TypeError("Iterator next must be callable.");
|
|
@@ -37715,7 +37807,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37715
37807
|
};
|
|
37716
37808
|
try {
|
|
37717
37809
|
if (name !== "toArray" && !isSandboxClosure(callback)) {
|
|
37718
|
-
await closeIterator(
|
|
37810
|
+
await closeIterator(iterator2, true);
|
|
37719
37811
|
throw new TypeError("Iterator callback must be callable.");
|
|
37720
37812
|
}
|
|
37721
37813
|
next = await bridge.getProperty(receiver, "next");
|
|
@@ -37723,7 +37815,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37723
37815
|
let index = 0;
|
|
37724
37816
|
while (true) {
|
|
37725
37817
|
budget.visitNode();
|
|
37726
|
-
const result = await
|
|
37818
|
+
const result = await iterator2.next();
|
|
37727
37819
|
if (await bridge.getProperty(result, "done")) {
|
|
37728
37820
|
if (!initialized) throw new TypeError("Cannot reduce an empty iterator without an initial value.");
|
|
37729
37821
|
if (name === "toArray") return values;
|
|
@@ -37751,12 +37843,12 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37751
37843
|
void 0
|
|
37752
37844
|
);
|
|
37753
37845
|
} catch (error) {
|
|
37754
|
-
if (!isFatalSandboxError(error)) await closeIterator(
|
|
37846
|
+
if (!isFatalSandboxError(error)) await closeIterator(iterator2, true);
|
|
37755
37847
|
throw error;
|
|
37756
37848
|
}
|
|
37757
37849
|
if (name === "reduce") accumulator = selected;
|
|
37758
37850
|
else if ((name === "some" || name === "find") && selected || name === "every" && !selected) {
|
|
37759
|
-
await closeIterator(
|
|
37851
|
+
await closeIterator(iterator2);
|
|
37760
37852
|
return name === "find" ? value : name === "some";
|
|
37761
37853
|
}
|
|
37762
37854
|
}
|
|
@@ -37802,17 +37894,17 @@ function installJointIteratorHelpers(prototype, constructor, budget, protocol) {
|
|
|
37802
37894
|
}
|
|
37803
37895
|
async function acquire(value, context, flattenable) {
|
|
37804
37896
|
if (value === null || typeof value !== "object") throw new TypeError("Joint iteration inputs must be objects.");
|
|
37805
|
-
let
|
|
37897
|
+
let iterator2 = value;
|
|
37806
37898
|
let method;
|
|
37807
|
-
const release = retainValues(budget, () => [value,
|
|
37899
|
+
const release = retainValues(budget, () => [value, iterator2, method]);
|
|
37808
37900
|
try {
|
|
37809
37901
|
method = await context.getProperty(value, Symbol.iterator);
|
|
37810
37902
|
if (!flattenable || method !== void 0 && method !== null) {
|
|
37811
37903
|
if (!isSandboxClosure(method)) throw new TypeError("Input must be iterable.");
|
|
37812
|
-
|
|
37813
|
-
if (
|
|
37904
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, value);
|
|
37905
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
37814
37906
|
}
|
|
37815
|
-
return { iterator, next: await context.getProperty(
|
|
37907
|
+
return { iterator: iterator2, next: await context.getProperty(iterator2, "next") };
|
|
37816
37908
|
} finally {
|
|
37817
37909
|
release();
|
|
37818
37910
|
}
|
|
@@ -38040,10 +38132,10 @@ function installLazyIteratorHelpers(common, budget, constructor) {
|
|
|
38040
38132
|
complete(state);
|
|
38041
38133
|
return createIteratorResult(void 0, true, budget);
|
|
38042
38134
|
}
|
|
38043
|
-
const
|
|
38044
|
-
if (
|
|
38045
|
-
state.outer = { iterator, next: void 0 };
|
|
38046
|
-
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");
|
|
38047
38139
|
state.iterables.shift();
|
|
38048
38140
|
}
|
|
38049
38141
|
const result2 = await step(state.outer, context);
|
|
@@ -40280,20 +40372,20 @@ function createListFormatConstructor(budget) {
|
|
|
40280
40372
|
const receiver = context?.thisValue;
|
|
40281
40373
|
listFormatState(receiver);
|
|
40282
40374
|
const strings = [];
|
|
40283
|
-
let
|
|
40284
|
-
const release = retainValues(budget, () => [receiver, strings,
|
|
40375
|
+
let iterator2;
|
|
40376
|
+
const release = retainValues(budget, () => [receiver, strings, iterator2?.retainedValue]);
|
|
40285
40377
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
40286
40378
|
try {
|
|
40287
40379
|
if (input !== void 0) {
|
|
40288
|
-
|
|
40289
|
-
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.");
|
|
40290
40382
|
while (true) {
|
|
40291
40383
|
budget.visitNode();
|
|
40292
|
-
const result = await
|
|
40293
|
-
if ((await readIteratorResult(
|
|
40294
|
-
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;
|
|
40295
40387
|
if (typeof value !== "string") {
|
|
40296
|
-
await closeIterator(
|
|
40388
|
+
await closeIterator(iterator2, true);
|
|
40297
40389
|
throw new TypeError("ListFormat requires string elements.");
|
|
40298
40390
|
}
|
|
40299
40391
|
budget.visitNode(value.length);
|
|
@@ -41259,8 +41351,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41259
41351
|
validateGuestHeapNode({ kind: "guest-object", state: node2.state }, heap, maxArrayLength);
|
|
41260
41352
|
const properties = array(record3(record3(node2.state).properties).properties).map(array);
|
|
41261
41353
|
if (node2.nativeIterator) {
|
|
41262
|
-
const
|
|
41263
|
-
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))
|
|
41264
41356
|
throw new TypeError("Invalid native arguments iterator descriptor.");
|
|
41265
41357
|
}
|
|
41266
41358
|
const indices = /* @__PURE__ */ new Set(), names = /* @__PURE__ */ new Set();
|
|
@@ -41978,8 +42070,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41978
42070
|
state(node.state);
|
|
41979
42071
|
} else if (node.kind === "iterator-wrapper") {
|
|
41980
42072
|
fields(node, ["kind", "iterator", "next", "state"]);
|
|
41981
|
-
const
|
|
41982
|
-
if (
|
|
42073
|
+
const iterator2 = reference(node.iterator);
|
|
42074
|
+
if (iterator2.kind === "symbol" || iterator2.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
|
|
41983
42075
|
state(node.state);
|
|
41984
42076
|
} else if (node.kind === "disposable-stack") {
|
|
41985
42077
|
fields(node, ["kind", "disposed", "resources", "state"]);
|
|
@@ -42350,34 +42442,34 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
42350
42442
|
if (expression.kind !== "yield-delegate") integer(expression.index);
|
|
42351
42443
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
42352
42444
|
else {
|
|
42353
|
-
let
|
|
42445
|
+
let iterator2 = record3(expression.iterator);
|
|
42354
42446
|
let depth = 0;
|
|
42355
42447
|
let protocol = false;
|
|
42356
|
-
while (
|
|
42448
|
+
while (iterator2.kind === "async-from-sync") {
|
|
42357
42449
|
if (++depth > 1) throw new TypeError("Invalid nested async iterator adapter.");
|
|
42358
|
-
fields(
|
|
42359
|
-
|
|
42450
|
+
fields(iterator2, ["kind", "inner"]);
|
|
42451
|
+
iterator2 = record3(iterator2.inner);
|
|
42360
42452
|
protocol = true;
|
|
42361
42453
|
}
|
|
42362
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"))
|
|
42363
42455
|
throw new TypeError("Iterator await state does not match its adapter.");
|
|
42364
|
-
if (
|
|
42365
|
-
fields(
|
|
42366
|
-
if (typeof
|
|
42367
|
-
if (depth > 0 &&
|
|
42368
|
-
protocol ||=
|
|
42369
|
-
reference(
|
|
42370
|
-
callable(
|
|
42371
|
-
} else if (
|
|
42372
|
-
fields(
|
|
42373
|
-
integer(
|
|
42374
|
-
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)
|
|
42375
42467
|
throw new TypeError("Invalid string iterator cursor.");
|
|
42376
|
-
if (typeof
|
|
42377
|
-
const target = reference(
|
|
42378
|
-
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)
|
|
42379
42471
|
throw new TypeError("Invalid stateful iterator cursor.");
|
|
42380
|
-
if (target.kind === "map" &&
|
|
42472
|
+
if (target.kind === "map" && iterator2.index > array(target.entries).length || target.kind === "set" && iterator2.index > array(target.values).length)
|
|
42381
42473
|
throw new TypeError("Invalid collection iterator cursor.");
|
|
42382
42474
|
if (target.kind === "guest-generator" && target.async === true) {
|
|
42383
42475
|
if (depth > 0) throw new TypeError("Invalid async-from-sync generator.");
|
|
@@ -43447,8 +43539,8 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43447
43539
|
}
|
|
43448
43540
|
const properties = requireRecord(record4.properties, `${path}.properties`);
|
|
43449
43541
|
if (record4.iterator !== null) {
|
|
43450
|
-
const
|
|
43451
|
-
for (const key of Object.keys(
|
|
43542
|
+
const iterator2 = requireRecord(record4.iterator, `${path}.iterator`);
|
|
43543
|
+
for (const key of Object.keys(iterator2)) {
|
|
43452
43544
|
if (!["configurable", "enumerable", "writable"].includes(key)) {
|
|
43453
43545
|
fail(
|
|
43454
43546
|
"invalidValue",
|
|
@@ -43458,7 +43550,7 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43458
43550
|
}
|
|
43459
43551
|
}
|
|
43460
43552
|
for (const flag of ["configurable", "enumerable", "writable"]) {
|
|
43461
|
-
if (typeof
|
|
43553
|
+
if (typeof iterator2[flag] !== "boolean")
|
|
43462
43554
|
fail("invalidType", `${path}.iterator.${flag}`, "expected boolean");
|
|
43463
43555
|
}
|
|
43464
43556
|
}
|
|
@@ -43487,10 +43579,20 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43487
43579
|
}
|
|
43488
43580
|
}
|
|
43489
43581
|
}
|
|
43490
|
-
function
|
|
43491
|
-
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)) {
|
|
43492
43591
|
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43493
43592
|
}
|
|
43593
|
+
}
|
|
43594
|
+
function validateGenericValue(value, path, depth, state) {
|
|
43595
|
+
validateSnapshotProxy(value, path, state.dataPropertiesOnly);
|
|
43494
43596
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.allowHostFunctionState && (isSandboxModuleNamespace(value) || isSandboxClosure(value) && !isGuestClosure(value)))) {
|
|
43495
43597
|
fail("invalidState", path, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
43496
43598
|
}
|
|
@@ -43556,8 +43658,7 @@ function validateRuntimeSnapshotDescriptors(snapshot) {
|
|
|
43556
43658
|
let entries = 0;
|
|
43557
43659
|
while (pending.length > 0) {
|
|
43558
43660
|
const { value, path, depth } = pending.pop();
|
|
43559
|
-
|
|
43560
|
-
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43661
|
+
validateSnapshotProxy(value, path);
|
|
43561
43662
|
if (seen.has(value)) continue;
|
|
43562
43663
|
seen.add(value);
|
|
43563
43664
|
if (depth > MAX_DATA_DEPTH)
|
|
@@ -45858,12 +45959,20 @@ import { types as nodeTypes } from "node:util";
|
|
|
45858
45959
|
var frozenClosureData = /* @__PURE__ */ new WeakMap();
|
|
45859
45960
|
var readFrozenClosureData = WeakMap.prototype.get.bind(frozenClosureData);
|
|
45860
45961
|
var writeFrozenClosureData = WeakMap.prototype.set.bind(frozenClosureData);
|
|
45861
|
-
var
|
|
45862
|
-
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);
|
|
45863
45968
|
var captureClosureDescriptor = Object.getOwnPropertyDescriptor;
|
|
45864
45969
|
var hasClosureDescriptorField = Object.hasOwn;
|
|
45865
45970
|
var invokeClosureGetter = Reflect.apply;
|
|
45866
|
-
var closureGetterArguments =
|
|
45971
|
+
var closureGetterArguments = freezeValueShape([]);
|
|
45972
|
+
function captureSealedValueSymbols(value) {
|
|
45973
|
+
writeSealedValueSymbols(value, freezeValueShape(captureValueSymbols(value)));
|
|
45974
|
+
return value;
|
|
45975
|
+
}
|
|
45867
45976
|
function readClosureProperties(closure, data) {
|
|
45868
45977
|
const getter = data?.propertiesGetter;
|
|
45869
45978
|
return getter === void 0 ? closure.properties : invokeClosureGetter(getter, closure, closureGetterArguments);
|
|
@@ -45945,12 +46054,12 @@ function createSandboxClosure(input) {
|
|
|
45945
46054
|
value: input.retainedValues
|
|
45946
46055
|
});
|
|
45947
46056
|
}
|
|
45948
|
-
|
|
46057
|
+
freezeValueShape(closure);
|
|
45949
46058
|
const properties = captureClosureDescriptor(closure, "properties");
|
|
45950
46059
|
writeFrozenClosureData(
|
|
45951
46060
|
closure,
|
|
45952
|
-
|
|
45953
|
-
symbols:
|
|
46061
|
+
freezeValueShape({
|
|
46062
|
+
symbols: freezeValueShape(captureValueSymbols(closure)),
|
|
45954
46063
|
closure: captureClosureDescriptor(closure, sandboxClosureBrand) !== void 0,
|
|
45955
46064
|
propertiesGetter: properties !== void 0 && hasClosureDescriptorField(properties, "get") ? properties.get : void 0
|
|
45956
46065
|
})
|
|
@@ -45961,7 +46070,13 @@ function registerDeferredClosureChargeIdentity(closure, identity) {
|
|
|
45961
46070
|
const data = readFrozenClosureData(closure);
|
|
45962
46071
|
if (data?.closure !== true || data.chargeIdentity !== void 0)
|
|
45963
46072
|
throw new TypeError("Deferred initialization requires a fresh SDK-created function.");
|
|
45964
|
-
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);
|
|
45965
46080
|
}
|
|
45966
46081
|
function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
45967
46082
|
if (isGuestHostObject(value)) {
|
|
@@ -46075,7 +46190,7 @@ function createSandboxPromise(promise, metadata = {}) {
|
|
|
46075
46190
|
);
|
|
46076
46191
|
trackSandboxPromise(sandboxPromise);
|
|
46077
46192
|
registerPromiseCancellation(sandboxPromise);
|
|
46078
|
-
return
|
|
46193
|
+
return captureSealedValueSymbols(freezeValueShape(sandboxPromise));
|
|
46079
46194
|
}
|
|
46080
46195
|
function createSandboxGenerator(channel, metadata = void 0) {
|
|
46081
46196
|
const generator = {
|
|
@@ -46106,7 +46221,7 @@ function createSandboxMap(entries = []) {
|
|
|
46106
46221
|
enumerable: false,
|
|
46107
46222
|
value: true
|
|
46108
46223
|
});
|
|
46109
|
-
return
|
|
46224
|
+
return captureSealedValueSymbols(freezeValueShape(map));
|
|
46110
46225
|
}
|
|
46111
46226
|
function createSandboxSet(values = []) {
|
|
46112
46227
|
const set3 = {};
|
|
@@ -46123,7 +46238,7 @@ function createSandboxSet(values = []) {
|
|
|
46123
46238
|
enumerable: false,
|
|
46124
46239
|
value: true
|
|
46125
46240
|
});
|
|
46126
|
-
return
|
|
46241
|
+
return captureSealedValueSymbols(freezeValueShape(set3));
|
|
46127
46242
|
}
|
|
46128
46243
|
function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
46129
46244
|
if (typeof source !== "string" || typeof flags !== "string") {
|
|
@@ -46159,7 +46274,7 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
|
46159
46274
|
[sandboxRegexBrand]: { value: true },
|
|
46160
46275
|
[sandboxRegexPattern]: { value: pattern, writable: true }
|
|
46161
46276
|
});
|
|
46162
|
-
return
|
|
46277
|
+
return captureSealedValueSymbols(sealValueShape(regex));
|
|
46163
46278
|
}
|
|
46164
46279
|
function getSandboxRegexPattern(regex) {
|
|
46165
46280
|
return regex[sandboxRegexPattern];
|
|
@@ -46311,28 +46426,47 @@ function* cloneStructuredGraph(value, state, budget, depth = 0) {
|
|
|
46311
46426
|
var nativeDataArrayAppend = Function.prototype.call.bind(Array.prototype.push);
|
|
46312
46427
|
var nativeDataArraySetPrototype = Object.setPrototypeOf;
|
|
46313
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
|
+
}
|
|
46314
46441
|
function measureSandboxData(values, options = {}) {
|
|
46442
|
+
if (retainedMeasurementCode === void 0)
|
|
46443
|
+
withMeasurementSeen((seen) => measureSandboxDataWithSeen([], {}, seen, true));
|
|
46444
|
+
retainedMeasurementCode(void 0);
|
|
46315
46445
|
return withMeasurementSeen((seen) => measureSandboxDataWithSeen(values, options, seen));
|
|
46316
46446
|
}
|
|
46317
|
-
function measureSandboxDataWithSeen(values, options, seen) {
|
|
46318
|
-
const seenSymbols = /* @__PURE__ */ new Set();
|
|
46447
|
+
function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
|
|
46448
|
+
const seenSymbols = retainCode ? new NativeMeasurementSet() : /* @__PURE__ */ new Set();
|
|
46319
46449
|
let usage = 0;
|
|
46320
46450
|
const projectedPrimitives = [];
|
|
46451
|
+
let pendingArguments;
|
|
46452
|
+
let pendingFunctions;
|
|
46453
|
+
let pendingFunctionDepths;
|
|
46321
46454
|
let waiting;
|
|
46322
46455
|
let ready;
|
|
46323
46456
|
let pending;
|
|
46324
46457
|
let pendingCount = 0;
|
|
46325
|
-
const appendContinuation = (values2, depth, capture) => {
|
|
46458
|
+
const appendContinuation = (values2, depth, capture, proxy) => {
|
|
46326
46459
|
const frames = pending ??= nativeDataArraySetPrototype([], null);
|
|
46327
46460
|
let frame = frames[pendingCount];
|
|
46328
46461
|
if (frame === void 0) {
|
|
46329
|
-
frame = { values: values2, index: 1, depth, capture };
|
|
46462
|
+
frame = { values: values2, index: 1, depth, capture, proxy };
|
|
46330
46463
|
nativeDataArrayAppend(frames, frame);
|
|
46331
46464
|
} else {
|
|
46332
46465
|
frame.values = values2;
|
|
46333
46466
|
frame.index = 1;
|
|
46334
46467
|
frame.depth = depth;
|
|
46335
46468
|
frame.capture = capture;
|
|
46469
|
+
frame.proxy = proxy;
|
|
46336
46470
|
}
|
|
46337
46471
|
pendingCount++;
|
|
46338
46472
|
};
|
|
@@ -46373,6 +46507,47 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46373
46507
|
}
|
|
46374
46508
|
captures = appendCapture(captures, value);
|
|
46375
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
|
+
};
|
|
46376
46551
|
const visit = (value, depth = 0) => {
|
|
46377
46552
|
const floor = pendingCount;
|
|
46378
46553
|
walk: while (true) {
|
|
@@ -46412,6 +46587,30 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46412
46587
|
const bindingRoot = scopeDataRoots.get(value);
|
|
46413
46588
|
if (bindingRoot !== void 0) {
|
|
46414
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
|
+
}
|
|
46415
46614
|
if ("deferred" in bindingRoot) {
|
|
46416
46615
|
const deferred2 = bindingRoot.deferred;
|
|
46417
46616
|
const current = deferred2.read();
|
|
@@ -46424,10 +46623,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46424
46623
|
seen.add(deferred2.chargeIdentity);
|
|
46425
46624
|
usage++;
|
|
46426
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;
|
|
46427
46633
|
if (options.ignoreClosures || options.ignoreClosureCaptures) break entry;
|
|
46428
46634
|
let roots2;
|
|
46429
46635
|
try {
|
|
46430
|
-
deferred2.collect(
|
|
46636
|
+
deferred2.collect(collector.append);
|
|
46431
46637
|
roots2 = captures;
|
|
46432
46638
|
} finally {
|
|
46433
46639
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46488,8 +46694,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46488
46694
|
for (const cell of finalization.state.cells) visit(cell.heldValue, depth + 1);
|
|
46489
46695
|
}
|
|
46490
46696
|
if (proxyState !== void 0) {
|
|
46491
|
-
if (proxyState.target !== null)
|
|
46492
|
-
|
|
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
|
+
}
|
|
46493
46708
|
break entry;
|
|
46494
46709
|
}
|
|
46495
46710
|
if (dynamicSourceRecords.has(value)) {
|
|
@@ -46526,9 +46741,22 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46526
46741
|
const managedArray = arrayLength !== void 0 && hasManagedDescriptors(value);
|
|
46527
46742
|
let arrayDescriptors;
|
|
46528
46743
|
let arrayElements;
|
|
46529
|
-
|
|
46744
|
+
const arrayData = arrayLength !== void 0 && !managedArray ? trackedArrayElementData(value) : void 0;
|
|
46745
|
+
if (arrayLength !== void 0 && arrayData === void 0) {
|
|
46530
46746
|
if (managedArray) arrayDescriptors = nativeDataArraySetPrototype([], null);
|
|
46531
|
-
|
|
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)) {
|
|
46532
46760
|
for (let index = 0; index < arrayLength; index += 1) {
|
|
46533
46761
|
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
46534
46762
|
if (descriptor !== void 0 && "value" in descriptor) arrayElements = appendCapture(arrayElements, descriptor.value);
|
|
@@ -46563,23 +46791,54 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46563
46791
|
}
|
|
46564
46792
|
}
|
|
46565
46793
|
if (knownClosure || !isGuestHostObject(value)) {
|
|
46566
|
-
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value);
|
|
46794
|
+
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value) ?? readSealedValueSymbols(value);
|
|
46795
|
+
let firstSymbol;
|
|
46796
|
+
let firstDescriptor;
|
|
46567
46797
|
let descriptors2;
|
|
46568
46798
|
if (ownedSymbols !== void 0) {
|
|
46569
|
-
for (let index = 0; index < ownedSymbols.length; index++)
|
|
46570
|
-
|
|
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
|
+
}
|
|
46571
46812
|
} else {
|
|
46572
46813
|
const symbols = isNumericTypedArray(value) ? typedArraySymbolKeys(value) : Object.getOwnPropertySymbols(value);
|
|
46573
|
-
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
|
+
}
|
|
46574
46826
|
}
|
|
46575
|
-
if (
|
|
46576
|
-
const key = descriptors2[index];
|
|
46577
|
-
const descriptor = descriptors2[index + 1];
|
|
46827
|
+
if (firstDescriptor !== void 0) {
|
|
46578
46828
|
usage += 1;
|
|
46579
|
-
visit(
|
|
46580
|
-
if ("value" in
|
|
46581
|
-
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);
|
|
46582
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
|
+
}
|
|
46583
46842
|
}
|
|
46584
46843
|
if (knownClosure || isSandboxClosure(value)) {
|
|
46585
46844
|
const closure = value;
|
|
@@ -46600,7 +46859,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46600
46859
|
if (collect !== void 0) {
|
|
46601
46860
|
let roots2;
|
|
46602
46861
|
try {
|
|
46603
|
-
collect(
|
|
46862
|
+
collect(collector.append);
|
|
46604
46863
|
roots2 = captures;
|
|
46605
46864
|
} finally {
|
|
46606
46865
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46614,7 +46873,11 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46614
46873
|
depth++;
|
|
46615
46874
|
continue walk;
|
|
46616
46875
|
}
|
|
46617
|
-
} 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
|
+
}
|
|
46618
46881
|
}
|
|
46619
46882
|
break entry;
|
|
46620
46883
|
}
|
|
@@ -46672,44 +46935,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46672
46935
|
visit(helperState.callback, depth + 1);
|
|
46673
46936
|
}
|
|
46674
46937
|
if (isSandboxDate(value)) usage += 8;
|
|
46675
|
-
|
|
46676
|
-
if (isSandboxTemporalDuration(value)) usage += temporalDurationFieldNames.length * 8;
|
|
46677
|
-
if (isSandboxTemporalPlainTime(value)) usage += temporalPlainTimeFieldNames.length * 8;
|
|
46678
|
-
if (isSandboxTemporalPlainDateTime(value)) usage += temporalPlainDateTimeNumericFields.length * 8 + temporalPlainDateTimeFields(value).calendar.length;
|
|
46679
|
-
if (isSandboxTemporalPlainDate(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainDateFields(value).calendar.length;
|
|
46680
|
-
if (isSandboxTemporalPlainMonthDay(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainMonthDayFields(value).calendar.length;
|
|
46681
|
-
if (isSandboxTemporalPlainYearMonth(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainYearMonthFields(value).calendar.length;
|
|
46682
|
-
if (isSandboxTemporalZonedDateTime(value)) {
|
|
46683
|
-
const fields2 = temporalZonedDateTimeFields(value);
|
|
46684
|
-
visit(fields2.epochNanoseconds, depth + 1);
|
|
46685
|
-
usage += fields2.timeZone.length + fields2.calendar.length;
|
|
46686
|
-
}
|
|
46687
|
-
if (isSandboxLocale(value)) usage += localeTag(value).length;
|
|
46688
|
-
if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
|
|
46689
|
-
if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
|
|
46690
|
-
if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
|
|
46691
|
-
if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
|
|
46692
|
-
if (isSandboxDurationFormat(value)) {
|
|
46693
|
-
const state = durationFormatState(value);
|
|
46694
|
-
visit(state.settings, depth + 1);
|
|
46695
|
-
visit(state.options, depth + 1);
|
|
46696
|
-
}
|
|
46697
|
-
if (isSandboxNumberFormat(value)) {
|
|
46698
|
-
const state = numberFormatState(value);
|
|
46699
|
-
visit(state.options, depth + 1);
|
|
46700
|
-
visit(state.format, depth + 1);
|
|
46701
|
-
}
|
|
46702
|
-
if (isSandboxDateTimeFormat(value)) {
|
|
46703
|
-
const state = dateTimeFormatState(value);
|
|
46704
|
-
visit(state.options, depth + 1);
|
|
46705
|
-
visit(state.requestedOptions, depth + 1);
|
|
46706
|
-
visit(state.format, depth + 1);
|
|
46707
|
-
}
|
|
46708
|
-
if (isSandboxCollator(value)) {
|
|
46709
|
-
const state = collatorState(value);
|
|
46710
|
-
visit(state.options, depth + 1);
|
|
46711
|
-
visit(state.compare, depth + 1);
|
|
46712
|
-
}
|
|
46938
|
+
visitTemporalIntl(value, depth);
|
|
46713
46939
|
if (isGuestHostObject(value)) {
|
|
46714
46940
|
usage += measureHostObjectData(value);
|
|
46715
46941
|
const root = hostObjectGuestRoot(value);
|
|
@@ -46744,6 +46970,15 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46744
46970
|
}
|
|
46745
46971
|
if (arrayLength !== void 0) {
|
|
46746
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
|
+
}
|
|
46747
46982
|
let retained = arrayElements;
|
|
46748
46983
|
if (arrayDescriptors !== void 0) {
|
|
46749
46984
|
for (let index = 0; index < arrayDescriptors.length; index++) {
|
|
@@ -46956,7 +47191,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46956
47191
|
try {
|
|
46957
47192
|
for (let index = 0; index < (trackedDescriptors?.length ?? keys.length); index++) {
|
|
46958
47193
|
const key = trackedDescriptors === void 0 ? keys[index] : trackedDescriptors[index][0];
|
|
46959
|
-
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];
|
|
46960
47195
|
if (descriptor === void 0) continue;
|
|
46961
47196
|
if (!descriptor.enumerable && !includeNonEnumerable) continue;
|
|
46962
47197
|
const initial = metadata?.get(key);
|
|
@@ -46985,6 +47220,18 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46985
47220
|
while (pendingCount > floor) {
|
|
46986
47221
|
const frame = pending[pendingCount - 1];
|
|
46987
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
|
+
}
|
|
46988
47235
|
if (frame.index < (frame.capture?.length ?? references.length)) {
|
|
46989
47236
|
value = references[frame.index++];
|
|
46990
47237
|
depth = frame.depth;
|
|
@@ -46998,20 +47245,57 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46998
47245
|
return;
|
|
46999
47246
|
}
|
|
47000
47247
|
};
|
|
47248
|
+
if (retainCode) {
|
|
47249
|
+
retainedMeasurementCode = visit;
|
|
47250
|
+
collector.close();
|
|
47251
|
+
return 0;
|
|
47252
|
+
}
|
|
47001
47253
|
try {
|
|
47002
47254
|
for (const value of values) visit(value);
|
|
47003
|
-
|
|
47004
|
-
|
|
47005
|
-
|
|
47006
|
-
|
|
47007
|
-
|
|
47008
|
-
|
|
47009
|
-
|
|
47010
|
-
|
|
47011
|
-
|
|
47012
|
-
|
|
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)));
|
|
47013
47296
|
return usage;
|
|
47014
47297
|
} finally {
|
|
47298
|
+
collector.close();
|
|
47015
47299
|
firstSeenCapture = void 0;
|
|
47016
47300
|
secondSeenCapture = void 0;
|
|
47017
47301
|
thirdSeenCapture = void 0;
|
|
@@ -47021,6 +47305,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
47021
47305
|
if (frame.capture !== void 0) releaseCaptures(frame.capture);
|
|
47022
47306
|
frame.capture = void 0;
|
|
47023
47307
|
frame.values = void 0;
|
|
47308
|
+
frame.proxy = void 0;
|
|
47024
47309
|
}
|
|
47025
47310
|
}
|
|
47026
47311
|
}
|
|
@@ -47053,15 +47338,6 @@ function reconcileCompiledValues(budget, values, compilation, parent, escaping =
|
|
|
47053
47338
|
for (const ticket of retained) compilation?.tickets.delete(ticket);
|
|
47054
47339
|
if (compilation !== void 0 && parent !== void 0) compilation.forward(included, parent);
|
|
47055
47340
|
}
|
|
47056
|
-
function captureRetainedSymbolProperty(value, key, descriptors2) {
|
|
47057
|
-
if (internalSymbols.has(key)) return descriptors2;
|
|
47058
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
47059
|
-
if (descriptor !== void 0) {
|
|
47060
|
-
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
47061
|
-
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
47062
|
-
}
|
|
47063
|
-
return descriptors2;
|
|
47064
|
-
}
|
|
47065
47341
|
function captureRegexData(value) {
|
|
47066
47342
|
const source = Object.getOwnPropertyDescriptor(value, "source");
|
|
47067
47343
|
const flags = Object.getOwnPropertyDescriptor(value, "flags");
|
|
@@ -48154,6 +48430,7 @@ var nativePropertyHasOwn = Object.hasOwn;
|
|
|
48154
48430
|
var nativePropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
48155
48431
|
var nativePropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
48156
48432
|
var nativePropertyPrototype = Object.getPrototypeOf;
|
|
48433
|
+
var nativePropertySetPrototype = Object.setPrototypeOf;
|
|
48157
48434
|
var nativePropertyFreeze = Object.freeze;
|
|
48158
48435
|
var nativePropertyWrite = Reflect.defineProperty;
|
|
48159
48436
|
var nativePropertyDelete = Reflect.deleteProperty;
|
|
@@ -48219,18 +48496,43 @@ function trackedPropertySymbols(value) {
|
|
|
48219
48496
|
}
|
|
48220
48497
|
function adjustScalarProperty(state, key, descriptor, direction) {
|
|
48221
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
|
+
}
|
|
48222
48503
|
const hasValue = nativePropertyHasOwn(descriptor, "value");
|
|
48223
48504
|
const item = hasValue ? descriptor.value : void 0;
|
|
48224
48505
|
const scalar = hasValue && typeof item !== "bigint" && typeof item !== "symbol" && (typeof item !== "object" || item === null);
|
|
48225
48506
|
if (!scalar) state.nonScalarProperties += direction;
|
|
48226
|
-
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);
|
|
48227
48508
|
state.allScalarUnits += direction * units;
|
|
48228
48509
|
if (descriptor.enumerable) state.enumerableScalarUnits += direction * units;
|
|
48229
48510
|
}
|
|
48230
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
|
+
}
|
|
48231
48533
|
function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
48232
48534
|
const state = nativePropertyDataGet(value);
|
|
48233
|
-
if (state === void 0 || state.
|
|
48535
|
+
if (state === void 0 || state.array) return void 0;
|
|
48234
48536
|
if (state.strings === void 0 && state.nonScalarProperties === 0) {
|
|
48235
48537
|
state.strings = nativePropertyFreeze({
|
|
48236
48538
|
all: nativePropertyFreeze({ units: state.allScalarUnits, references: emptyPropertyReferences }),
|
|
@@ -48245,8 +48547,16 @@ function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
|
48245
48547
|
const entry = descriptors2[index];
|
|
48246
48548
|
const key = entry[0], descriptor = entry[1];
|
|
48247
48549
|
if (!nativePropertyHasOwn(descriptor, "value")) {
|
|
48248
|
-
|
|
48249
|
-
|
|
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;
|
|
48250
48560
|
}
|
|
48251
48561
|
const item = descriptor.value;
|
|
48252
48562
|
const units = 1 + key.length + (typeof item === "string" ? item.length : 0);
|
|
@@ -48313,37 +48623,63 @@ function createIntrinsicObject(initial = /* @__PURE__ */ Object.create(null)) {
|
|
|
48313
48623
|
nativeIntrinsicObjectAdd(tracked);
|
|
48314
48624
|
return tracked;
|
|
48315
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
|
+
}
|
|
48316
48636
|
function isTrackedIntrinsicObject(value) {
|
|
48317
48637
|
return nativeIntrinsicObjectHas(value);
|
|
48318
48638
|
}
|
|
48319
|
-
function trackPropertyTable(properties) {
|
|
48639
|
+
function trackPropertyTable(properties, array2 = false) {
|
|
48320
48640
|
const state = { revision: 0 };
|
|
48321
48641
|
const data = {
|
|
48322
48642
|
backing: properties,
|
|
48643
|
+
array: array2,
|
|
48323
48644
|
allScalarUnits: 0,
|
|
48324
48645
|
enumerableScalarUnits: 0,
|
|
48325
48646
|
nonScalarProperties: 0,
|
|
48326
48647
|
symbols: void 0,
|
|
48327
48648
|
descriptors: void 0,
|
|
48328
|
-
strings: void 0
|
|
48649
|
+
strings: void 0,
|
|
48650
|
+
elements: void 0
|
|
48329
48651
|
};
|
|
48330
48652
|
const keys = nativePropertyNames(properties);
|
|
48331
48653
|
for (let index = 0; index < keys.length; index++) {
|
|
48332
48654
|
const key = keys[index];
|
|
48333
48655
|
adjustScalarProperty(data, key, nativePropertyDescriptor(properties, key), 1);
|
|
48334
48656
|
}
|
|
48335
|
-
const tracked = new NativePropertyProxy(properties, {
|
|
48657
|
+
const tracked = new NativePropertyProxy(properties, nativePropertySetPrototype({
|
|
48336
48658
|
defineProperty(target, key, descriptor) {
|
|
48659
|
+
const ownDescriptor = { __proto__: null, ...descriptor };
|
|
48337
48660
|
const previous = typeof key === "string" ? nativePropertyDescriptor(target, key) : void 0;
|
|
48338
|
-
const
|
|
48339
|
-
|
|
48661
|
+
const previousLength = array2 && key === "length" ? target.length : void 0;
|
|
48662
|
+
const changed = nativePropertyWrite(target, key, ownDescriptor);
|
|
48663
|
+
if (changed || array2) {
|
|
48340
48664
|
if (typeof key === "string") {
|
|
48341
|
-
|
|
48342
|
-
|
|
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
|
+
}
|
|
48343
48678
|
} else data.symbols = void 0;
|
|
48344
48679
|
state.revision++;
|
|
48345
48680
|
data.descriptors = void 0;
|
|
48346
48681
|
data.strings = void 0;
|
|
48682
|
+
data.elements = void 0;
|
|
48347
48683
|
state.measuredDescriptors = void 0;
|
|
48348
48684
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48349
48685
|
}
|
|
@@ -48360,12 +48696,13 @@ function trackPropertyTable(properties) {
|
|
|
48360
48696
|
state.revision++;
|
|
48361
48697
|
data.descriptors = void 0;
|
|
48362
48698
|
data.strings = void 0;
|
|
48699
|
+
data.elements = void 0;
|
|
48363
48700
|
state.measuredDescriptors = void 0;
|
|
48364
48701
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48365
48702
|
}
|
|
48366
48703
|
return changed;
|
|
48367
48704
|
}
|
|
48368
|
-
});
|
|
48705
|
+
}, null));
|
|
48369
48706
|
nativePropertyStateSet(tracked, state);
|
|
48370
48707
|
nativePropertyDataSet(tracked, data);
|
|
48371
48708
|
return tracked;
|
|
@@ -48943,4 +49280,4 @@ authorization of the copyright holder.
|
|
|
48943
49280
|
SPDX-License-Identifier: Unicode-3.0
|
|
48944
49281
|
|
|
48945
49282
|
*/
|
|
48946
|
-
//# sourceMappingURL=chunk-
|
|
49283
|
+
//# sourceMappingURL=chunk-ZHJPXLUJ.js.map
|