@poe-platform/safe-js 0.1.723 → 0.1.725
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/safe-js/chunks/{chunk-WF7HYDJ4.js → chunk-6OE64YMG.js} +2 -2
- package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js → chunk-6YSHQ5ET.js} +2 -2
- package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js → chunk-ECTNNLWN.js} +4 -4
- package/dist/safe-js/chunks/{chunk-5MT2LF3W.js → chunk-FYSWUSHN.js} +3 -3
- package/dist/safe-js/chunks/{chunk-3QQYJ4RQ.js → chunk-HG5QP5UC.js} +2 -2
- package/dist/safe-js/chunks/{chunk-QMZG576E.js → chunk-K6F5QLZQ.js} +3 -3
- 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-SWQHZKYM.js → chunk-O2CPPE6M.js} +2 -2
- package/dist/safe-js/chunks/{chunk-M6HUSN7X.js → chunk-PKRGP34X.js} +37 -10
- package/dist/safe-js/chunks/chunk-PKRGP34X.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-IZ52PAOD.js → chunk-QU2F65UQ.js} +890 -495
- package/dist/safe-js/chunks/{chunk-IZ52PAOD.js.map → chunk-QU2F65UQ.js.map} +4 -4
- package/dist/safe-js/chunks/{chunk-KHJDAEET.js → chunk-V2ESZF34.js} +4 -4
- package/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js → chunk-Y7LSEUWV.js} +3 -3
- package/dist/safe-js/chunks/{chunk-HY3Q377V.js → chunk-YRALPIEZ.js} +2 -2
- package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js → cli-runtime-5HVEFMDB.js} +13 -13
- package/dist/safe-js/chunks/{dump-TWVEBH5W.js → dump-VKSKINUI.js} +4 -4
- package/dist/safe-js/chunks/{fs-DSNHTHBT.js → fs-CZ2TAPHK.js} +4 -4
- package/dist/safe-js/chunks/harness-WNABEKDH.js +10 -0
- package/dist/safe-js/chunks/mcp-ZZDGN5CA.js +11 -0
- package/dist/safe-js/chunks/migration-file-QVT4W464.js +12 -0
- package/dist/safe-js/chunks/restore-PTIQHGKI.js +13 -0
- package/dist/safe-js/chunks/run-WNR7QYUJ.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-YEOG62RU.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/extensions.d.ts +2 -0
- package/dist/safe-js/index.js +13 -13
- package/dist/safe-js/interp/arguments.d.ts +1 -2
- package/dist/safe-js/interp/host-bridge.d.ts +1 -1
- 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-M6HUSN7X.js.map +0 -7
- 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-WF7HYDJ4.js.map → chunk-6OE64YMG.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js.map → chunk-6YSHQ5ET.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js.map → chunk-ECTNNLWN.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-5MT2LF3W.js.map → chunk-FYSWUSHN.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-QMZG576E.js.map → chunk-K6F5QLZQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-SWQHZKYM.js.map → chunk-O2CPPE6M.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-KHJDAEET.js.map → chunk-V2ESZF34.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js.map → chunk-Y7LSEUWV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-HY3Q377V.js.map → chunk-YRALPIEZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js.map → cli-runtime-5HVEFMDB.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-TWVEBH5W.js.map → dump-VKSKINUI.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-DSNHTHBT.js.map → fs-CZ2TAPHK.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-RLA643GD.js.map → harness-WNABEKDH.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-IEY7HXXT.js.map → mcp-ZZDGN5CA.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-QMI45CSP.js.map → migration-file-QVT4W464.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-R5PLLBST.js.map → restore-PTIQHGKI.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-QATVEFVQ.js.map → run-WNR7QYUJ.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-5D7KDFMZ.js.map → runtime-modules-YEOG62RU.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);
|
|
@@ -6371,11 +6440,30 @@ async function evaluateFunctionExpression(node, context, evaluateNode2) {
|
|
|
6371
6440
|
value: closure
|
|
6372
6441
|
};
|
|
6373
6442
|
}
|
|
6443
|
+
var captureContextHasOwn = Object.hasOwn;
|
|
6444
|
+
function createOwnedCaptureCollector(scope, sourceReference, environment, constructionState) {
|
|
6445
|
+
return (append) => {
|
|
6446
|
+
visitScopeDataRoots(scope, append);
|
|
6447
|
+
append(sourceReference);
|
|
6448
|
+
append(environment?.homeObject);
|
|
6449
|
+
append(environment?.newTarget);
|
|
6450
|
+
if (constructionState !== void 0) {
|
|
6451
|
+
append(constructionState.constructor);
|
|
6452
|
+
append(constructionState.newTarget);
|
|
6453
|
+
append(constructionState.prototype);
|
|
6454
|
+
append(constructionState.thisValue);
|
|
6455
|
+
if (constructionState.thisScope !== void 0)
|
|
6456
|
+
visitScopeDataRoots(constructionState.thisScope, append);
|
|
6457
|
+
}
|
|
6458
|
+
};
|
|
6459
|
+
}
|
|
6374
6460
|
function createInterpretedClosure(node, context, evaluateNode2, homeObject, initializeGeneratorPrototype = true) {
|
|
6461
|
+
let ownsCaptureContext = false;
|
|
6375
6462
|
if (context.callee !== void 0 || context.evalCompletion)
|
|
6376
6463
|
context = { ...context, callee: void 0, evalCompletion: void 0 };
|
|
6377
6464
|
if (node.type !== "ArrowFunctionExpression") {
|
|
6378
6465
|
context = { ...context, functionEnvironment: { homeObject } };
|
|
6466
|
+
ownsCaptureContext = true;
|
|
6379
6467
|
}
|
|
6380
6468
|
if (node.type !== "ArrowFunctionExpression" && node.generator) {
|
|
6381
6469
|
return createGeneratorClosure(node, context, evaluateNode2, initializeGeneratorPrototype);
|
|
@@ -6383,7 +6471,7 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
6383
6471
|
const construction = context.functionEnvironment?.construction;
|
|
6384
6472
|
const constructionState = construction === void 0 ? void 0 : constructionStates.get(construction);
|
|
6385
6473
|
const construct = node.type !== "ArrowFunctionExpression" && !(node.type === "FunctionExpression" && node.method === true) && !node.async ? async (args, callContext) => {
|
|
6386
|
-
const thisValue = {};
|
|
6474
|
+
const thisValue = createIntrinsicObject({});
|
|
6387
6475
|
const newTarget = callContext?.newTarget ?? closure;
|
|
6388
6476
|
const prototype = callContext?.getProperty === void 0 ? getGuestFunctionProperty(newTarget, "prototype") : await callContext.getProperty(newTarget, "prototype");
|
|
6389
6477
|
const selected = typeof prototype === "object" && prototype !== null ? prototype : getFunctionRealmPrototype(newTarget, "Object", getSandboxPrototype(thisValue, context.budget));
|
|
@@ -6491,10 +6579,13 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
6491
6579
|
}, context.budget, callContext, context.signal);
|
|
6492
6580
|
}
|
|
6493
6581
|
});
|
|
6494
|
-
registerIndexedClosureCaptures(
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6582
|
+
registerIndexedClosureCaptures(
|
|
6583
|
+
closure,
|
|
6584
|
+
ownsCaptureContext && captureContextHasOwn(context, "scope") && captureContextHasOwn(context, "sourceReference") && captureContextHasOwn(context, "functionEnvironment") ? createOwnedCaptureCollector(context.scope, context.sourceReference, context.functionEnvironment, constructionState) : (append) => {
|
|
6585
|
+
visitScopeDataRoots(context.scope, append);
|
|
6586
|
+
appendCapturedValues(append);
|
|
6587
|
+
}
|
|
6588
|
+
);
|
|
6498
6589
|
registerClosureOrigin(closure, node, context);
|
|
6499
6590
|
return closure;
|
|
6500
6591
|
}
|
|
@@ -6765,7 +6856,12 @@ async function createClosureScope(node, args, thisValue, context, evaluateNode2)
|
|
|
6765
6856
|
else scope.declare("this", "const", thisValue);
|
|
6766
6857
|
if (needsArguments) {
|
|
6767
6858
|
context.budget.allocateArrayLength(args.length);
|
|
6768
|
-
if (!mapped)
|
|
6859
|
+
if (!mapped) {
|
|
6860
|
+
const kind = functionStrictness.get(node) === false && !separateParameters ? "var" : "let";
|
|
6861
|
+
if (context.scriptScope !== void 0 || context.moduleInstantiated !== void 0)
|
|
6862
|
+
scope.declareDeferredArguments("arguments", kind, args);
|
|
6863
|
+
else scope.declare("arguments", kind, createSandboxArguments(args));
|
|
6864
|
+
}
|
|
6769
6865
|
}
|
|
6770
6866
|
await construction?.initialize(scope);
|
|
6771
6867
|
}
|
|
@@ -8584,13 +8680,14 @@ function functionString(value) {
|
|
|
8584
8680
|
|
|
8585
8681
|
// packages/safe-js/src/interp/bound-function.ts
|
|
8586
8682
|
function createBoundFunction(state, name, length, callClosure) {
|
|
8683
|
+
const retainedValues = () => [state.target, state.thisValue, ...state.args, bound.name];
|
|
8587
8684
|
const bound = createSandboxClosure({
|
|
8588
8685
|
guest: true,
|
|
8589
8686
|
sandbox: true,
|
|
8590
8687
|
name,
|
|
8591
8688
|
length,
|
|
8592
8689
|
boundTarget: state.target,
|
|
8593
|
-
retainedValues
|
|
8690
|
+
retainedValues,
|
|
8594
8691
|
call: (args, context) => callClosure(state.target, [...state.args, ...args], context?.stack ?? [], state.thisValue, void 0, void 0, context),
|
|
8595
8692
|
...state.target.construct === void 0 ? {} : {
|
|
8596
8693
|
construct: (args, context) => callClosure(
|
|
@@ -8604,6 +8701,12 @@ function createBoundFunction(state, name, length, callClosure) {
|
|
|
8604
8701
|
)
|
|
8605
8702
|
}
|
|
8606
8703
|
});
|
|
8704
|
+
registerClosureCaptureCollector(bound, retainedValues, (append) => {
|
|
8705
|
+
append(state.target);
|
|
8706
|
+
append(state.thisValue);
|
|
8707
|
+
for (const value of state.args) append(value);
|
|
8708
|
+
append(bound.name);
|
|
8709
|
+
});
|
|
8607
8710
|
boundFunctionStates.set(bound, state);
|
|
8608
8711
|
return bound;
|
|
8609
8712
|
}
|
|
@@ -16802,21 +16905,21 @@ async function allocateTypedArrayInput(source, budget, Native, context) {
|
|
|
16802
16905
|
invokeClosure: context?.invokeClosure ?? ((callee, values2, receiver, construct, newTarget) => invokeBuiltinClosure(callee, values2, budget, callerContext, receiver, construct, newTarget))
|
|
16803
16906
|
};
|
|
16804
16907
|
const values = [];
|
|
16805
|
-
let
|
|
16908
|
+
let iterator2;
|
|
16806
16909
|
let current;
|
|
16807
16910
|
let result;
|
|
16808
|
-
const release = retainValues(budget, () => [source, values,
|
|
16911
|
+
const release = retainValues(budget, () => [source, values, iterator2?.retainedValue, current, result]);
|
|
16809
16912
|
const checkData = createDataCheckpoint(budget, bridge);
|
|
16810
16913
|
try {
|
|
16811
|
-
|
|
16914
|
+
iterator2 = await acquireSandboxIterator(source, budget, bridge);
|
|
16812
16915
|
let length;
|
|
16813
|
-
if (
|
|
16916
|
+
if (iterator2 !== void 0) {
|
|
16814
16917
|
while (true) {
|
|
16815
16918
|
budget.visitNode();
|
|
16816
|
-
const next = await
|
|
16919
|
+
const next = await iterator2.next();
|
|
16817
16920
|
if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
|
|
16818
|
-
if ((await readIteratorResult(
|
|
16819
|
-
current = (await readIteratorResult(
|
|
16921
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
16922
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
16820
16923
|
budget.allocateArrayLength(values.length + 1);
|
|
16821
16924
|
values.push(current);
|
|
16822
16925
|
checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
|
|
@@ -16832,7 +16935,7 @@ async function allocateTypedArrayInput(source, budget, Native, context) {
|
|
|
16832
16935
|
checkData(result, 0, true);
|
|
16833
16936
|
for (let index = 0; index < length; index++) {
|
|
16834
16937
|
budget.visitNode();
|
|
16835
|
-
current =
|
|
16938
|
+
current = iterator2 === void 0 ? await bridge.getProperty(source, String(index)) : values[index];
|
|
16836
16939
|
result[index] = await typedArrayElement(current, Native, budget, bridge);
|
|
16837
16940
|
}
|
|
16838
16941
|
return result;
|
|
@@ -16911,21 +17014,21 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
|
16911
17014
|
};
|
|
16912
17015
|
let result;
|
|
16913
17016
|
let current;
|
|
16914
|
-
let
|
|
17017
|
+
let iterator2;
|
|
16915
17018
|
const values = [];
|
|
16916
|
-
const release = retainValues(budget, () => [target, result, current,
|
|
17019
|
+
const release = retainValues(budget, () => [target, result, current, iterator2?.retainedValue, values, ...args]);
|
|
16917
17020
|
const checkData = createDataCheckpoint(budget, context);
|
|
16918
17021
|
const read = (key) => context?.getProperty === void 0 ? getSandboxDataProperty(source, key, budget) : context.getProperty(source, key);
|
|
16919
17022
|
try {
|
|
16920
|
-
|
|
17023
|
+
iterator2 = await acquireSandboxIterator(source, budget, context);
|
|
16921
17024
|
let length;
|
|
16922
|
-
if (
|
|
17025
|
+
if (iterator2 !== void 0) {
|
|
16923
17026
|
while (true) {
|
|
16924
17027
|
budget.visitNode();
|
|
16925
|
-
const next = await
|
|
17028
|
+
const next = await iterator2.next();
|
|
16926
17029
|
if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
|
|
16927
|
-
if ((await readIteratorResult(
|
|
16928
|
-
current = (await readIteratorResult(
|
|
17030
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
17031
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
16929
17032
|
budget.allocateArrayLength(values.length + 1);
|
|
16930
17033
|
values.push(current);
|
|
16931
17034
|
checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
|
|
@@ -16941,7 +17044,7 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
|
16941
17044
|
checkData(result, 0, true);
|
|
16942
17045
|
for (let index = 0; index < length; index++) {
|
|
16943
17046
|
budget.visitNode();
|
|
16944
|
-
current =
|
|
17047
|
+
current = iterator2 === void 0 ? await read(String(index)) : values[index];
|
|
16945
17048
|
if (mapper !== void 0)
|
|
16946
17049
|
current = await invokeBuiltinClosure(mapper, [current, index], budget, context, receiver);
|
|
16947
17050
|
result[index] = await typedArrayElement(current, typedArrayStorage(result).Native, budget, context);
|
|
@@ -17831,6 +17934,13 @@ async function callStringPadding(value, method, args, budget, context) {
|
|
|
17831
17934
|
}
|
|
17832
17935
|
|
|
17833
17936
|
// packages/safe-js/src/interp/methods/string.ts
|
|
17937
|
+
var nativeStringPrototype = String.prototype;
|
|
17938
|
+
var nativeObjectPrototype = Object.prototype;
|
|
17939
|
+
var nativeStringSplit = nativeStringPrototype.split;
|
|
17940
|
+
var nativeSplitSymbol = Symbol.split;
|
|
17941
|
+
var nativeSplitDescriptor = Object.getOwnPropertyDescriptor;
|
|
17942
|
+
var nativeSplitPrototype = Object.getPrototypeOf;
|
|
17943
|
+
var nativeSplitApply = Reflect.apply;
|
|
17834
17944
|
var stringMethodLengths = {
|
|
17835
17945
|
...Object.fromEntries(Object.entries(stringHtmlMethods).map(([name, [, attribute]]) => [name, attribute === "" ? 0 : 1])),
|
|
17836
17946
|
at: 1,
|
|
@@ -17923,7 +18033,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
17923
18033
|
if (value === null || value === void 0)
|
|
17924
18034
|
throw new TypeError(`String#${methodName} requires a non-null receiver.`);
|
|
17925
18035
|
const fallback = (coercePattern = false) => {
|
|
17926
|
-
const
|
|
18036
|
+
const apply = (string) => {
|
|
17927
18037
|
if (coercePattern && (methodName === "match" || methodName === "matchAll" || methodName === "search"))
|
|
17928
18038
|
return callStringPattern(string, methodName, args[0], budget, parent, context);
|
|
17929
18039
|
const useRegex = isSandboxRegex(args[0]) && !coercePattern;
|
|
@@ -17932,7 +18042,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
17932
18042
|
if (methodName === "split") return callSplit(string, args, budget, useRegex, parent, context);
|
|
17933
18043
|
return callStringMethodBody(string, methodName, args, budget, parent, context);
|
|
17934
18044
|
};
|
|
17935
|
-
return typeof value === "string" ?
|
|
18045
|
+
return typeof value === "string" ? apply(value) : Promise.resolve(sandboxString(value, budget, context)).then(apply);
|
|
17936
18046
|
};
|
|
17937
18047
|
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
18048
|
const pattern = args[0];
|
|
@@ -18001,14 +18111,14 @@ function callStringMethodBody(value, methodName, args, budget, parent, context)
|
|
|
18001
18111
|
return callStringPadding(value, methodName, args, budget, context);
|
|
18002
18112
|
}
|
|
18003
18113
|
if (methodName === "repeat" || methodName === "at" || methodName === "charAt" || methodName === "charCodeAt" || methodName === "codePointAt") {
|
|
18004
|
-
const
|
|
18114
|
+
const apply = (number2) => {
|
|
18005
18115
|
const result = value[methodName](number2);
|
|
18006
18116
|
return typeof result === "string" ? budget.allocateString(result) : result;
|
|
18007
18117
|
};
|
|
18008
18118
|
const number = sandboxNumber(args[0], budget, context);
|
|
18009
|
-
if (typeof number === "number") return
|
|
18119
|
+
if (typeof number === "number") return apply(number);
|
|
18010
18120
|
const release = retainValues(budget, () => [value, ...args]);
|
|
18011
|
-
return number.then(
|
|
18121
|
+
return number.then(apply).finally(release);
|
|
18012
18122
|
}
|
|
18013
18123
|
if (methodName === "isWellFormed") {
|
|
18014
18124
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -18449,7 +18559,10 @@ function splitNormalized(value, separator, limit, budget, parent) {
|
|
|
18449
18559
|
}
|
|
18450
18560
|
budget.allocateArrayLength(count);
|
|
18451
18561
|
}
|
|
18452
|
-
const
|
|
18562
|
+
const split = value.split;
|
|
18563
|
+
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);
|
|
18564
|
+
const nativeResult = nativeSplitApply(split, value, [separator, limit]);
|
|
18565
|
+
const result = owned ? createIntrinsicArray(nativeResult) : nativeResult;
|
|
18453
18566
|
budget.allocateArrayLength(result.length);
|
|
18454
18567
|
for (const part of result) budget.allocateString(part);
|
|
18455
18568
|
return result;
|
|
@@ -20811,8 +20924,8 @@ function serializeArguments(value, serializeValue) {
|
|
|
20811
20924
|
writable: descriptor.writable === true
|
|
20812
20925
|
};
|
|
20813
20926
|
}
|
|
20814
|
-
const
|
|
20815
|
-
if (
|
|
20927
|
+
const iterator2 = Object.getOwnPropertyDescriptor(value, Symbol.iterator);
|
|
20928
|
+
if (iterator2 !== void 0 && iterator2.value !== Array.prototype.values) {
|
|
20816
20929
|
throw new TypeError("Cannot snapshot a replaced arguments iterator.");
|
|
20817
20930
|
}
|
|
20818
20931
|
const names = Object.getOwnPropertyNames(value);
|
|
@@ -20820,10 +20933,10 @@ function serializeArguments(value, serializeValue) {
|
|
|
20820
20933
|
kind: "arguments",
|
|
20821
20934
|
extensible: Object.isExtensible(value),
|
|
20822
20935
|
lengthBeforeCallee: names.includes("length") && names.indexOf("length") < names.indexOf("callee"),
|
|
20823
|
-
iterator:
|
|
20824
|
-
configurable:
|
|
20825
|
-
enumerable:
|
|
20826
|
-
writable:
|
|
20936
|
+
iterator: iterator2 === void 0 ? null : {
|
|
20937
|
+
configurable: iterator2.configurable === true,
|
|
20938
|
+
enumerable: iterator2.enumerable === true,
|
|
20939
|
+
writable: iterator2.writable === true
|
|
20827
20940
|
},
|
|
20828
20941
|
properties
|
|
20829
20942
|
};
|
|
@@ -21902,19 +22015,19 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21902
22015
|
restored: []
|
|
21903
22016
|
};
|
|
21904
22017
|
const exportedSharedArguments = [];
|
|
21905
|
-
const copyArguments = (values) => deepCopyFromSandbox([...values], {
|
|
22018
|
+
const copyArguments = (values, wrapClosure) => deepCopyFromSandbox([...values], {
|
|
21906
22019
|
compilation,
|
|
21907
22020
|
onSharedBuffer: (value2) => {
|
|
21908
22021
|
exportedSharedArguments.push(value2);
|
|
21909
22022
|
},
|
|
21910
22023
|
unwrapHostObject: options.realm === void 0 ? void 0 : (object) => exportHostCapability(object, options.realm.owner),
|
|
21911
|
-
wrapClosure: (closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
22024
|
+
wrapClosure: wrapClosure ?? ((closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
21912
22025
|
closure,
|
|
21913
22026
|
stackFrames,
|
|
21914
22027
|
options.budget,
|
|
21915
22028
|
operationLease.owner,
|
|
21916
22029
|
callbacks
|
|
21917
|
-
)
|
|
22030
|
+
))
|
|
21918
22031
|
});
|
|
21919
22032
|
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
21920
22033
|
const hostArgs = captured?.args ?? copyArguments(args);
|
|
@@ -23063,7 +23176,7 @@ function readStringProperty(value, key) {
|
|
|
23063
23176
|
return descriptor !== void 0 && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
|
|
23064
23177
|
}
|
|
23065
23178
|
function copyFunctionProperties(callable, stackFrames, options, state, path) {
|
|
23066
|
-
const properties = {};
|
|
23179
|
+
const properties = createIntrinsicObject({});
|
|
23067
23180
|
const metadata = /* @__PURE__ */ new Map();
|
|
23068
23181
|
for (const key of Object.getOwnPropertyNames(callable)) {
|
|
23069
23182
|
const descriptor = Object.getOwnPropertyDescriptor(callable, key);
|
|
@@ -23316,8 +23429,8 @@ function callGeneratorMethod(target, method, value, budget, context, async) {
|
|
|
23316
23429
|
const result = (async () => {
|
|
23317
23430
|
if (!isSandboxGenerator(target) || target.async === true !== async)
|
|
23318
23431
|
throw new TypeError(`${async ? "AsyncGenerator" : "Generator"}.${method} requires a matching generator receiver.`);
|
|
23319
|
-
const
|
|
23320
|
-
const result2 = await
|
|
23432
|
+
const iterator2 = generatorIterator(target, budget, context);
|
|
23433
|
+
const result2 = await iterator2[method](value);
|
|
23321
23434
|
return allocateProducedSandboxValue(result2, budget);
|
|
23322
23435
|
})();
|
|
23323
23436
|
return async ? createSandboxPromise(result) : result;
|
|
@@ -23506,9 +23619,9 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23506
23619
|
const candidate = await readErrorProperty(newTarget, "prototype", budget, context);
|
|
23507
23620
|
const prototype = candidate !== null && typeof candidate === "object" ? candidate : getFunctionRealmPrototype(newTarget, name, errorPrototypes.get(budget).get(name));
|
|
23508
23621
|
let error;
|
|
23509
|
-
let
|
|
23622
|
+
let iterator2;
|
|
23510
23623
|
const errors = [];
|
|
23511
|
-
const release = retainValues(budget, () => [prototype, error,
|
|
23624
|
+
const release = retainValues(budget, () => [prototype, error, iterator2?.retainedValue, ...errors, ...args]);
|
|
23512
23625
|
try {
|
|
23513
23626
|
const message = name === "SuppressedError" ? args[2] : name === "AggregateError" ? args[1] : args[0];
|
|
23514
23627
|
const options = name === "SuppressedError" ? void 0 : name === "AggregateError" ? args[2] : args[1];
|
|
@@ -23528,15 +23641,15 @@ async function createNativeError(name, args, budget, context, constructor) {
|
|
|
23528
23641
|
if (name === "AggregateError") {
|
|
23529
23642
|
const errorsPrototype = getSandboxPrototype(errors, budget);
|
|
23530
23643
|
if (errorsPrototype !== null) setSandboxPrototype(errors, errorsPrototype, budget);
|
|
23531
|
-
|
|
23532
|
-
if (
|
|
23644
|
+
iterator2 = context === void 0 ? getSandboxIterator(args[0], budget) : await acquireSandboxIterator(args[0], budget, context);
|
|
23645
|
+
if (iterator2 === void 0) throw new TypeError("AggregateError errors must be iterable.");
|
|
23533
23646
|
while (true) {
|
|
23534
23647
|
budget.visitNode();
|
|
23535
|
-
const result = await
|
|
23648
|
+
const result = await iterator2.next();
|
|
23536
23649
|
if (result === null || typeof result !== "object") throw new TypeError("Iterator result must be an object.");
|
|
23537
|
-
if ((await readIteratorResult(
|
|
23650
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
23538
23651
|
budget.allocateArrayLength(errors.length + 1);
|
|
23539
|
-
errors.push((await readIteratorResult(
|
|
23652
|
+
errors.push((await readIteratorResult(iterator2, result, "value")).value);
|
|
23540
23653
|
}
|
|
23541
23654
|
Object.defineProperty(error, "errors", { value: errors, writable: true, configurable: true });
|
|
23542
23655
|
}
|
|
@@ -24068,7 +24181,7 @@ async function evaluateArrayExpression(node, context) {
|
|
|
24068
24181
|
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
24069
24182
|
if (restored !== void 0 && (restored.kind !== "array" || !Array.isArray(restored.values)))
|
|
24070
24183
|
throw new TypeError("Invalid array expression continuation.");
|
|
24071
|
-
const values = restored?.kind === "array" ? restored.values : [];
|
|
24184
|
+
const values = restored?.kind === "array" ? restored.values : context.scriptScope !== void 0 || context.moduleInstantiated !== void 0 ? createIntrinsicArray() : [];
|
|
24072
24185
|
if (restored === void 0) {
|
|
24073
24186
|
const prototype = getSandboxPrototype(values, context.budget);
|
|
24074
24187
|
if (prototype !== null) setSandboxPrototype(values, prototype, context.budget);
|
|
@@ -25192,13 +25305,13 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25192
25305
|
let resumeCurrent = saved !== void 0 && saved.phase !== "next";
|
|
25193
25306
|
let resumeNext = saved?.phase === "next";
|
|
25194
25307
|
let index = saved?.index ?? consumeRestoredLoopIterationIndex(node, context);
|
|
25195
|
-
const
|
|
25196
|
-
if (
|
|
25308
|
+
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;
|
|
25309
|
+
if (iterator2 === void 0) {
|
|
25197
25310
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
25198
25311
|
}
|
|
25199
25312
|
const nextIteration = async () => {
|
|
25200
|
-
if ((context.asyncFunction || context.asyncGeneratorFrame !== void 0) && node.await &&
|
|
25201
|
-
|
|
25313
|
+
if ((context.asyncFunction || context.asyncGeneratorFrame !== void 0) && node.await && iterator2.resumeAwait !== void 0 && node.nodeId !== void 0) {
|
|
25314
|
+
iterator2.awaitValue = (awaited, awaitState) => suspendAsyncFunctionValue(awaited, node, {
|
|
25202
25315
|
...context,
|
|
25203
25316
|
generatorExpressionStates: new Map([
|
|
25204
25317
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25211,7 +25324,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25211
25324
|
current: void 0,
|
|
25212
25325
|
index,
|
|
25213
25326
|
scope: context.scope,
|
|
25214
|
-
iterator
|
|
25327
|
+
iterator: iterator2
|
|
25215
25328
|
}]
|
|
25216
25329
|
])
|
|
25217
25330
|
}, void 0, createCoercionContext(context));
|
|
@@ -25219,14 +25332,14 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25219
25332
|
if (resumeNext) {
|
|
25220
25333
|
resumeNext = false;
|
|
25221
25334
|
if (saved?.awaitState === void 0) throw new TypeError("Missing iterator await continuation.");
|
|
25222
|
-
return await
|
|
25335
|
+
return await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25223
25336
|
}
|
|
25224
|
-
return await
|
|
25337
|
+
return await iterator2.next();
|
|
25225
25338
|
} finally {
|
|
25226
|
-
delete
|
|
25339
|
+
delete iterator2.awaitValue;
|
|
25227
25340
|
}
|
|
25228
25341
|
}
|
|
25229
|
-
const pending = Promise.resolve(
|
|
25342
|
+
const pending = Promise.resolve(iterator2.next());
|
|
25230
25343
|
if (!node.await) return pending;
|
|
25231
25344
|
context.onSuspend?.();
|
|
25232
25345
|
const leaveAwait = context.budget.enterAwait();
|
|
@@ -25237,16 +25350,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25237
25350
|
}
|
|
25238
25351
|
};
|
|
25239
25352
|
const completion = context.evalCompletion ? new StatementCompletion(context.budget, true) : void 0;
|
|
25240
|
-
const releaseIterator = retainValues(context.budget, () => [value,
|
|
25353
|
+
const releaseIterator = retainValues(context.budget, () => [value, iterator2.retainedValue]);
|
|
25241
25354
|
const closeLoopIterator = async (completion2) => {
|
|
25242
25355
|
const preserveThrow = completion2.kind === "throw";
|
|
25243
|
-
if (!context.asyncFunction && context.asyncGeneratorFrame === void 0 || !node.await ||
|
|
25244
|
-
await closeIterator(
|
|
25356
|
+
if (!context.asyncFunction && context.asyncGeneratorFrame === void 0 || !node.await || iterator2.resumeAwait === void 0 || node.nodeId === void 0 || completion2.kind === "error") {
|
|
25357
|
+
await closeIterator(iterator2, preserveThrow);
|
|
25245
25358
|
return;
|
|
25246
25359
|
}
|
|
25247
25360
|
const { node: ignoredNode, stackFrames, ...metadata } = completion2;
|
|
25248
25361
|
const closeCompletion = { ...metadata, ...stackFrames === void 0 ? {} : { stackFrames: [...stackFrames] } };
|
|
25249
|
-
|
|
25362
|
+
iterator2.awaitValue = (awaited, awaitState) => suspendAsyncFunctionValue(awaited, node, {
|
|
25250
25363
|
...context,
|
|
25251
25364
|
generatorExpressionStates: new Map([
|
|
25252
25365
|
...context.generatorExpressionStates ?? [],
|
|
@@ -25260,19 +25373,19 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25260
25373
|
current: void 0,
|
|
25261
25374
|
index,
|
|
25262
25375
|
scope: context.scope,
|
|
25263
|
-
iterator
|
|
25376
|
+
iterator: iterator2
|
|
25264
25377
|
}]
|
|
25265
25378
|
])
|
|
25266
25379
|
}, void 0, createCoercionContext(context));
|
|
25267
25380
|
try {
|
|
25268
25381
|
if (saved?.phase === "close" && context.generatorResume?.completed !== true) {
|
|
25269
25382
|
if (saved.awaitState === void 0) throw new TypeError("Missing iterator close continuation.");
|
|
25270
|
-
await
|
|
25271
|
-
} else await closeIterator(
|
|
25383
|
+
await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25384
|
+
} else await closeIterator(iterator2, preserveThrow);
|
|
25272
25385
|
} catch (error) {
|
|
25273
25386
|
if (!preserveThrow || isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
25274
25387
|
} finally {
|
|
25275
|
-
delete
|
|
25388
|
+
delete iterator2.awaitValue;
|
|
25276
25389
|
}
|
|
25277
25390
|
};
|
|
25278
25391
|
try {
|
|
@@ -25287,7 +25400,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25287
25400
|
if (typeof skippedIteration !== "object" || skippedIteration === null) {
|
|
25288
25401
|
throw new TypeError("Iterator result must be an object.");
|
|
25289
25402
|
}
|
|
25290
|
-
if ((await readIteratorResult(
|
|
25403
|
+
if ((await readIteratorResult(iterator2, skippedIteration, "done")).value) {
|
|
25291
25404
|
return completion?.normal() ?? normalEmptyResult();
|
|
25292
25405
|
}
|
|
25293
25406
|
}
|
|
@@ -25299,16 +25412,16 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25299
25412
|
if (typeof iteration !== "object" || iteration === null) {
|
|
25300
25413
|
throw new TypeError("Iterator result must be an object.");
|
|
25301
25414
|
}
|
|
25302
|
-
if ((await readIteratorResult(
|
|
25415
|
+
if ((await readIteratorResult(iterator2, iteration, "done")).value) {
|
|
25303
25416
|
context.activeLoopIterations.delete(nodeId);
|
|
25304
25417
|
return completion?.normal() ?? normalEmptyResult();
|
|
25305
25418
|
}
|
|
25306
|
-
const nextValue = (await readIteratorResult(
|
|
25419
|
+
const nextValue = (await readIteratorResult(iterator2, iteration, "value")).value;
|
|
25307
25420
|
context.activeLoopIterations.set(
|
|
25308
25421
|
nodeId,
|
|
25309
|
-
|
|
25422
|
+
iterator2.snapshotIndex === void 0 ? index : {
|
|
25310
25423
|
get index() {
|
|
25311
|
-
return
|
|
25424
|
+
return iterator2.snapshotIndex();
|
|
25312
25425
|
},
|
|
25313
25426
|
values: [value, nextValue]
|
|
25314
25427
|
}
|
|
@@ -25319,7 +25432,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
25319
25432
|
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
25320
25433
|
generatorExpressionStates: new Map([
|
|
25321
25434
|
...context.generatorExpressionStates ?? [],
|
|
25322
|
-
[node.nodeId, { kind: "for-of-iterator", phase, async: node.await === true, value, current: nextValue, index, scope, iterator }]
|
|
25435
|
+
[node.nodeId, { kind: "for-of-iterator", phase, async: node.await === true, value, current: nextValue, index, scope, iterator: iterator2 }]
|
|
25323
25436
|
])
|
|
25324
25437
|
}
|
|
25325
25438
|
});
|
|
@@ -25819,14 +25932,14 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25819
25932
|
return argument;
|
|
25820
25933
|
}
|
|
25821
25934
|
if (context.generatorResume?.completed === true) context.generatorResume = void 0;
|
|
25822
|
-
const
|
|
25935
|
+
const iterator2 = saved === void 0 ? await acquireSandboxIterator(
|
|
25823
25936
|
argument.value,
|
|
25824
25937
|
context.budget,
|
|
25825
25938
|
createCoercionContext(context),
|
|
25826
25939
|
context.asyncGenerator,
|
|
25827
25940
|
context.signal
|
|
25828
25941
|
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, context.budget, createCoercionContext(context), context.signal) : saved.iterator;
|
|
25829
|
-
if (
|
|
25942
|
+
if (iterator2 === void 0) {
|
|
25830
25943
|
throw new TypeError(`${String(argument.value)} is not a supported iterable`);
|
|
25831
25944
|
}
|
|
25832
25945
|
const state = {
|
|
@@ -25834,21 +25947,21 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25834
25947
|
async: context.asyncGenerator === true,
|
|
25835
25948
|
value: argument.value,
|
|
25836
25949
|
current: saved?.current,
|
|
25837
|
-
iterator,
|
|
25950
|
+
iterator: iterator2,
|
|
25838
25951
|
...saved?.phase === void 0 ? {} : { phase: saved.phase, awaitState: saved.awaitState, completion: saved.completion }
|
|
25839
25952
|
};
|
|
25840
25953
|
if (node.nodeId !== void 0) context = {
|
|
25841
25954
|
...context,
|
|
25842
25955
|
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
25843
25956
|
};
|
|
25844
|
-
if (context.asyncGeneratorFrame !== void 0 &&
|
|
25845
|
-
|
|
25957
|
+
if (context.asyncGeneratorFrame !== void 0 && iterator2.resumeAwait !== void 0)
|
|
25958
|
+
iterator2.awaitValue = (value, awaitState) => {
|
|
25846
25959
|
state.awaitState = awaitState;
|
|
25847
25960
|
return suspendAsyncFunctionValue(value, node, context, void 0, createCoercionContext(context));
|
|
25848
25961
|
};
|
|
25849
25962
|
const releaseIterator = retainValues(context.budget, () => [
|
|
25850
25963
|
argument.value,
|
|
25851
|
-
|
|
25964
|
+
iterator2.retainedValue,
|
|
25852
25965
|
state.current
|
|
25853
25966
|
]);
|
|
25854
25967
|
try {
|
|
@@ -25873,20 +25986,20 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25873
25986
|
let result;
|
|
25874
25987
|
if (resumeOperation) {
|
|
25875
25988
|
resumeOperation = false;
|
|
25876
|
-
if (
|
|
25989
|
+
if (iterator2.resumeAwait === void 0 || iterator2.awaitValue === void 0 || saved?.awaitState === void 0)
|
|
25877
25990
|
throw new TypeError("Missing delegated iterator await continuation.");
|
|
25878
|
-
result = await
|
|
25991
|
+
result = await iterator2.resumeAwait(saved.awaitState, () => iterator2.awaitValue(void 0, saved.awaitState));
|
|
25879
25992
|
if (saved.phase === "close") throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25880
25993
|
context.generatorResume = void 0;
|
|
25881
25994
|
} else {
|
|
25882
|
-
const iteratorMethod =
|
|
25995
|
+
const iteratorMethod = iterator2.getOperation === void 0 ? iterator2[method] : await iterator2.getOperation(method);
|
|
25883
25996
|
if (iteratorMethod === void 0) {
|
|
25884
25997
|
if (completion.type === "throw") {
|
|
25885
|
-
if (
|
|
25998
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25886
25999
|
state.phase = "close";
|
|
25887
26000
|
state.completion = completion;
|
|
25888
26001
|
}
|
|
25889
|
-
await closeIterator(
|
|
26002
|
+
await closeIterator(iterator2, false, context.asyncGeneratorFrame === void 0 ? suspendJob : async (pending) => await suspendAsyncFunctionValue(createSandboxPromise(pending), node, context, void 0, createCoercionContext(context)));
|
|
25890
26003
|
throw new TypeError("Delegated iterator does not provide a throw method.");
|
|
25891
26004
|
}
|
|
25892
26005
|
if (context.asyncGenerator && completion.type === "return") {
|
|
@@ -25897,12 +26010,12 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25897
26010
|
}
|
|
25898
26011
|
return generatorCompletionResult(completion);
|
|
25899
26012
|
}
|
|
25900
|
-
if (
|
|
26013
|
+
if (iterator2.awaitValue !== void 0) {
|
|
25901
26014
|
state.phase = "await";
|
|
25902
26015
|
state.completion = completion;
|
|
25903
26016
|
}
|
|
25904
26017
|
const pendingResult = Promise.resolve(iteratorMethod(completion.value));
|
|
25905
|
-
result = context.asyncGeneratorFrame !== void 0 &&
|
|
26018
|
+
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
26019
|
}
|
|
25907
26020
|
delete state.phase;
|
|
25908
26021
|
delete state.awaitState;
|
|
@@ -25910,8 +26023,8 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25910
26023
|
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
25911
26024
|
throw new TypeError("Iterator result must be an object.");
|
|
25912
26025
|
}
|
|
25913
|
-
const done = (await readIteratorResult(
|
|
25914
|
-
const value = done || context.asyncGenerator ? (await readIteratorResult(
|
|
26026
|
+
const done = (await readIteratorResult(iterator2, result, "done")).value;
|
|
26027
|
+
const value = done || context.asyncGenerator ? (await readIteratorResult(iterator2, result, "value")).value : result;
|
|
25915
26028
|
if (done) {
|
|
25916
26029
|
if (completion.type === "return") {
|
|
25917
26030
|
return generatorCompletionResult({ type: "return", value });
|
|
@@ -25932,7 +26045,7 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
25932
26045
|
context.generatorResume = void 0;
|
|
25933
26046
|
}
|
|
25934
26047
|
} finally {
|
|
25935
|
-
delete
|
|
26048
|
+
delete iterator2.awaitValue;
|
|
25936
26049
|
releaseIterator();
|
|
25937
26050
|
}
|
|
25938
26051
|
}
|
|
@@ -27400,23 +27513,23 @@ async function evaluateSpreadElement(node, context) {
|
|
|
27400
27513
|
result: value
|
|
27401
27514
|
};
|
|
27402
27515
|
}
|
|
27403
|
-
const
|
|
27404
|
-
if (
|
|
27516
|
+
const iterator2 = await acquireSandboxIterator(value.value, context.budget, createCoercionContext(context));
|
|
27517
|
+
if (iterator2 === void 0) {
|
|
27405
27518
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
27406
27519
|
}
|
|
27407
27520
|
const spreadValues = [];
|
|
27408
|
-
const release = retainValues(context.budget, () => [value.value,
|
|
27521
|
+
const release = retainValues(context.budget, () => [value.value, iterator2.retainedValue, ...spreadValues]);
|
|
27409
27522
|
try {
|
|
27410
27523
|
while (true) {
|
|
27411
|
-
const next = await
|
|
27524
|
+
const next = await iterator2.next();
|
|
27412
27525
|
if (typeof next !== "object" || next === null) {
|
|
27413
27526
|
throw new TypeError("Iterator result must be an object.");
|
|
27414
27527
|
}
|
|
27415
|
-
const done =
|
|
27528
|
+
const done = iterator2.readResultProperty === void 0 ? next.done : (await readIteratorResult(iterator2, next, "done")).value;
|
|
27416
27529
|
if (done) {
|
|
27417
27530
|
break;
|
|
27418
27531
|
}
|
|
27419
|
-
const item =
|
|
27532
|
+
const item = iterator2.readResultProperty === void 0 ? next.value : (await readIteratorResult(iterator2, next, "value")).value;
|
|
27420
27533
|
spreadValues.push(item);
|
|
27421
27534
|
context.budget.allocateArrayLength(spreadValues.length);
|
|
27422
27535
|
}
|
|
@@ -28016,16 +28129,16 @@ function createGroupBy(budget, keyMode) {
|
|
|
28016
28129
|
call: async ([items, callback], context) => {
|
|
28017
28130
|
if (items === null || items === void 0) throw new TypeError("groupBy requires an iterable.");
|
|
28018
28131
|
if (!isSandboxClosure(callback)) throw new TypeError("groupBy requires a callable callback.");
|
|
28019
|
-
const
|
|
28020
|
-
if (
|
|
28132
|
+
const iterator2 = context === void 0 ? getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context);
|
|
28133
|
+
if (iterator2 === void 0) throw new TypeError("groupBy requires an iterable.");
|
|
28021
28134
|
const groups = createSandboxMap([]);
|
|
28022
28135
|
let value;
|
|
28023
28136
|
let key;
|
|
28024
|
-
const release = retainValues(budget, () => [groups, callback,
|
|
28137
|
+
const release = retainValues(budget, () => [groups, callback, iterator2.retainedValue, value, key]);
|
|
28025
28138
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
28026
28139
|
const closeOnThrow = async (error) => {
|
|
28027
28140
|
try {
|
|
28028
|
-
await closeIterator(
|
|
28141
|
+
await closeIterator(iterator2, true);
|
|
28029
28142
|
} catch (closeError) {
|
|
28030
28143
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28031
28144
|
}
|
|
@@ -28040,9 +28153,9 @@ function createGroupBy(budget, keyMode) {
|
|
|
28040
28153
|
} catch (error) {
|
|
28041
28154
|
await closeOnThrow(error);
|
|
28042
28155
|
}
|
|
28043
|
-
const next = await
|
|
28044
|
-
if ((await readIteratorResult(
|
|
28045
|
-
value = (await readIteratorResult(
|
|
28156
|
+
const next = await iterator2.next();
|
|
28157
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
28158
|
+
value = (await readIteratorResult(iterator2, next, "value")).value;
|
|
28046
28159
|
try {
|
|
28047
28160
|
key = await invokeBuiltinClosure(callback, [value, index], budget, context, void 0);
|
|
28048
28161
|
if (keyMode === "property") key = await toPropertyKey(key, budget, context);
|
|
@@ -28226,9 +28339,9 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
28226
28339
|
const receiver = context?.thisValue;
|
|
28227
28340
|
if (receiver === null || receiver === void 0) throw new TypeError("String iterator requires a receiver.");
|
|
28228
28341
|
const input = await sandboxString(receiver, budget, context);
|
|
28229
|
-
const
|
|
28230
|
-
setSandboxPrototype(
|
|
28231
|
-
return
|
|
28342
|
+
const iterator2 = restoreSandboxStringIterator({ input, index: 0 });
|
|
28343
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28344
|
+
return iterator2;
|
|
28232
28345
|
}
|
|
28233
28346
|
}), writable: true, configurable: true });
|
|
28234
28347
|
}
|
|
@@ -28416,7 +28529,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28416
28529
|
sandbox: true,
|
|
28417
28530
|
call: async ([prototype, descriptors2], context) => {
|
|
28418
28531
|
if (prototype !== null) objectProperties(prototype);
|
|
28419
|
-
const value =
|
|
28532
|
+
const value = createIntrinsicObject();
|
|
28420
28533
|
setSandboxPrototype(value, prototype, options.budget);
|
|
28421
28534
|
if (descriptors2 !== void 0) {
|
|
28422
28535
|
await definePropertiesFromObject(value, descriptors2, options.budget, context);
|
|
@@ -28436,19 +28549,19 @@ function createObjectArrayGlobals(options) {
|
|
|
28436
28549
|
fromEntries: createSandboxClosure({
|
|
28437
28550
|
sandbox: true,
|
|
28438
28551
|
call: ([value], context) => {
|
|
28439
|
-
if (context !== void 0) return acquireSandboxIterator(value, options.budget, context).then((
|
|
28440
|
-
if (
|
|
28441
|
-
return objectFromSandboxEntries(value,
|
|
28552
|
+
if (context !== void 0) return acquireSandboxIterator(value, options.budget, context).then((iterator3) => {
|
|
28553
|
+
if (iterator3 === void 0) throw new TypeError("Object.fromEntries requires an iterable.");
|
|
28554
|
+
return objectFromSandboxEntries(value, iterator3, options.budget, context);
|
|
28442
28555
|
});
|
|
28443
|
-
const
|
|
28444
|
-
if (
|
|
28556
|
+
const iterator2 = getSandboxIterator(value, options.budget, context);
|
|
28557
|
+
if (iterator2 === void 0) {
|
|
28445
28558
|
throw new TypeError("Object.fromEntries requires an iterable.");
|
|
28446
28559
|
}
|
|
28447
|
-
if (context === void 0 && !
|
|
28560
|
+
if (context === void 0 && !iterator2.generator && !iterator2.asynchronous) {
|
|
28448
28561
|
const object = allocateProducedSandboxValue(
|
|
28449
28562
|
Object.setPrototypeOf(
|
|
28450
28563
|
Reflect.apply(Object.fromEntries, Object, [
|
|
28451
|
-
{ [Symbol.iterator]: () =>
|
|
28564
|
+
{ [Symbol.iterator]: () => iterator2 }
|
|
28452
28565
|
]),
|
|
28453
28566
|
null
|
|
28454
28567
|
),
|
|
@@ -28458,7 +28571,7 @@ function createObjectArrayGlobals(options) {
|
|
|
28458
28571
|
if (prototype !== null) setSandboxPrototype(object, prototype, options.budget);
|
|
28459
28572
|
return object;
|
|
28460
28573
|
}
|
|
28461
|
-
return objectFromSandboxEntries(value,
|
|
28574
|
+
return objectFromSandboxEntries(value, iterator2, options.budget, context);
|
|
28462
28575
|
},
|
|
28463
28576
|
name: "fromEntries",
|
|
28464
28577
|
length: 1
|
|
@@ -28723,9 +28836,9 @@ function createArrayGlobal(budget) {
|
|
|
28723
28836
|
const receiver = context?.thisValue;
|
|
28724
28837
|
if (receiver === null || receiver === void 0) throw new TypeError("Array iterator method requires a receiver.");
|
|
28725
28838
|
const source = typeof receiver === "object" ? receiver : createSandboxBox(receiver);
|
|
28726
|
-
const
|
|
28727
|
-
setSandboxPrototype(
|
|
28728
|
-
return
|
|
28839
|
+
const iterator2 = restoreSandboxArrayIterator({ source, index: 0, method });
|
|
28840
|
+
setSandboxPrototype(iterator2, iteratorPrototype, budget);
|
|
28841
|
+
return iterator2;
|
|
28729
28842
|
}
|
|
28730
28843
|
});
|
|
28731
28844
|
Object.defineProperty(prototype, method, { value: closure, writable: true, configurable: true });
|
|
@@ -28844,7 +28957,7 @@ function createArrayGlobal(budget) {
|
|
|
28844
28957
|
installArrayPrototype(budget, prototype, constructor);
|
|
28845
28958
|
return constructor;
|
|
28846
28959
|
}
|
|
28847
|
-
async function objectFromSandboxEntries(items,
|
|
28960
|
+
async function objectFromSandboxEntries(items, iterator2, budget, context) {
|
|
28848
28961
|
const object = /* @__PURE__ */ Object.create(null);
|
|
28849
28962
|
const prototype = getSandboxPrototype(object, budget);
|
|
28850
28963
|
if (prototype !== null) setSandboxPrototype(object, prototype, budget);
|
|
@@ -28855,7 +28968,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28855
28968
|
const retained = {};
|
|
28856
28969
|
budget.setRetainedValues(retained, () => [
|
|
28857
28970
|
items,
|
|
28858
|
-
|
|
28971
|
+
iterator2.retainedValue,
|
|
28859
28972
|
object,
|
|
28860
28973
|
entry,
|
|
28861
28974
|
key,
|
|
@@ -28866,7 +28979,7 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28866
28979
|
const closeOnThrow = async (error) => {
|
|
28867
28980
|
failure = isCapturedException(error) ? error.reason : error;
|
|
28868
28981
|
try {
|
|
28869
|
-
await closeIterator(
|
|
28982
|
+
await closeIterator(iterator2, true);
|
|
28870
28983
|
} catch (closeError) {
|
|
28871
28984
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
28872
28985
|
}
|
|
@@ -28880,12 +28993,12 @@ async function objectFromSandboxEntries(items, iterator, budget, context) {
|
|
|
28880
28993
|
} catch (error) {
|
|
28881
28994
|
await closeOnThrow(error);
|
|
28882
28995
|
}
|
|
28883
|
-
const result = await
|
|
28996
|
+
const result = await iterator2.next();
|
|
28884
28997
|
if (typeof result !== "object" || result === null) {
|
|
28885
28998
|
throw new TypeError("Iterator result must be an object.");
|
|
28886
28999
|
}
|
|
28887
|
-
if ((await readIteratorResult(
|
|
28888
|
-
entry = (await readIteratorResult(
|
|
29000
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
29001
|
+
entry = (await readIteratorResult(iterator2, result, "value")).value;
|
|
28889
29002
|
try {
|
|
28890
29003
|
if (typeof entry !== "object" || entry === null) {
|
|
28891
29004
|
throw new TypeError("Object.fromEntries requires entry objects.");
|
|
@@ -28975,12 +29088,13 @@ function objectProperties(value, _mutable = false) {
|
|
|
28975
29088
|
return value;
|
|
28976
29089
|
}
|
|
28977
29090
|
function exposePropertyDescriptor(descriptor, budget) {
|
|
28978
|
-
const
|
|
29091
|
+
const properties = "value" in descriptor ? descriptor : {
|
|
28979
29092
|
get: accessorClosure(descriptor.get, budget),
|
|
28980
29093
|
set: accessorClosure(descriptor.set, budget),
|
|
28981
29094
|
enumerable: descriptor.enumerable,
|
|
28982
29095
|
configurable: descriptor.configurable
|
|
28983
29096
|
};
|
|
29097
|
+
const result = runResources.getStore()?.nativeDataResults === true ? properties : createIntrinsicObject(properties);
|
|
28984
29098
|
const prototype = getSandboxPrototype(result, budget);
|
|
28985
29099
|
if (prototype !== null) setSandboxPrototype(result, prototype, budget);
|
|
28986
29100
|
return result;
|
|
@@ -29150,8 +29264,8 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29150
29264
|
const iteratorMethod = observableMethod ? await context.getProperty(items, Symbol.iterator) : void 0;
|
|
29151
29265
|
if (iteratorMethod !== null && iteratorMethod !== void 0 && !isSandboxClosure(iteratorMethod) && typeof iteratorMethod !== "function")
|
|
29152
29266
|
throw new TypeError("Iterator method must be callable.");
|
|
29153
|
-
let
|
|
29154
|
-
const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 :
|
|
29267
|
+
let iterator2 = observableMethod ? void 0 : context === void 0 ? asyncProtocol ? getSandboxAsyncIterator(items, budget) : getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context, asyncProtocol);
|
|
29268
|
+
const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 : iterator2 !== void 0;
|
|
29155
29269
|
const constructor = context?.thisValue;
|
|
29156
29270
|
let result;
|
|
29157
29271
|
let currentValue;
|
|
@@ -29160,9 +29274,9 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29160
29274
|
budget.setRetainedValues(retained, () => [
|
|
29161
29275
|
// Once acquired, a rooted protocol iterator owns the remaining input. Keep
|
|
29162
29276
|
// the original only for array-like reads or implicit unrooted iterators.
|
|
29163
|
-
|
|
29277
|
+
iterator2?.retainedValue === void 0 ? items : void 0,
|
|
29164
29278
|
iteratorMethod,
|
|
29165
|
-
|
|
29279
|
+
iterator2?.retainedValue,
|
|
29166
29280
|
mapFn,
|
|
29167
29281
|
thisValue,
|
|
29168
29282
|
constructor,
|
|
@@ -29174,7 +29288,7 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29174
29288
|
const closeOnThrow = async (error) => {
|
|
29175
29289
|
failure = isCapturedException(error) ? error.reason : error;
|
|
29176
29290
|
try {
|
|
29177
|
-
if (
|
|
29291
|
+
if (iterator2 !== void 0) await closeIterator(iterator2, true);
|
|
29178
29292
|
} catch (closeError) {
|
|
29179
29293
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
29180
29294
|
}
|
|
@@ -29196,23 +29310,23 @@ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
|
|
|
29196
29310
|
) : createArrayFromConstructorArgs([length], budget);
|
|
29197
29311
|
checkData(result, 0, true);
|
|
29198
29312
|
if (observableMethod && iterable)
|
|
29199
|
-
|
|
29313
|
+
iterator2 = await getSandboxIteratorFromMethod(items, iteratorMethod, budget, context);
|
|
29200
29314
|
let index = 0;
|
|
29201
|
-
while (
|
|
29315
|
+
while (iterator2 !== void 0 || index < length) {
|
|
29202
29316
|
try {
|
|
29203
29317
|
budget.visitNode();
|
|
29204
|
-
if (
|
|
29318
|
+
if (iterator2 !== void 0 && index >= Number.MAX_SAFE_INTEGER)
|
|
29205
29319
|
throw new TypeError("Array.from input is too long.");
|
|
29206
29320
|
} catch (error) {
|
|
29207
29321
|
await closeOnThrow(error);
|
|
29208
29322
|
}
|
|
29209
|
-
if (
|
|
29210
|
-
const pending = Promise.resolve(
|
|
29323
|
+
if (iterator2 !== void 0) {
|
|
29324
|
+
const pending = Promise.resolve(iterator2.next());
|
|
29211
29325
|
const next = await (asyncProtocol ? awaitAsync(pending) : pending);
|
|
29212
29326
|
if (typeof next !== "object" || next === null)
|
|
29213
29327
|
throw new TypeError("Iterator result must be an object.");
|
|
29214
|
-
if ((await readIteratorResult(
|
|
29215
|
-
currentValue = (await readIteratorResult(
|
|
29328
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
29329
|
+
currentValue = (await readIteratorResult(iterator2, next, "value")).value;
|
|
29216
29330
|
} else {
|
|
29217
29331
|
currentValue = await read(index);
|
|
29218
29332
|
if (asyncProtocol) currentValue = await awaitAsync(awaitSandboxValue(currentValue, void 0, budget, context));
|
|
@@ -30101,17 +30215,17 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30101
30215
|
const promiseResolve = await readPromiseReceiverProperty(constructor, "resolve", prototype, context);
|
|
30102
30216
|
if (!isSandboxClosure(promiseResolve))
|
|
30103
30217
|
throw new TypeError("Promise constructor requires a callable resolve.");
|
|
30104
|
-
const
|
|
30105
|
-
if (
|
|
30106
|
-
const releaseIterator = retainValues(budget, () => [
|
|
30218
|
+
const iterator2 = context === void 0 ? getSandboxIterator(iterable, budget) : await acquireSandboxIterator(iterable, budget, context);
|
|
30219
|
+
if (iterator2 === void 0) throw new TypeError("Promise helpers require an iterable.");
|
|
30220
|
+
const releaseIterator = retainValues(budget, () => [iterator2.retainedValue]);
|
|
30107
30221
|
try {
|
|
30108
30222
|
while (true) {
|
|
30109
30223
|
budget.visitNode();
|
|
30110
|
-
const next =
|
|
30224
|
+
const next = iterator2.generator || iterator2.asynchronous ? await iterator2.next() : iterator2.next();
|
|
30111
30225
|
if (typeof next !== "object" || next === null)
|
|
30112
30226
|
throw new TypeError("Iterator result must be an object.");
|
|
30113
|
-
if ((await readIteratorResult(
|
|
30114
|
-
const value = (await readIteratorResult(
|
|
30227
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
30228
|
+
const value = (await readIteratorResult(iterator2, next, "value")).value;
|
|
30115
30229
|
try {
|
|
30116
30230
|
budget.allocateArrayLength(aggregate.size + 1);
|
|
30117
30231
|
const entryIndex = aggregate.size++;
|
|
@@ -30145,7 +30259,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
30145
30259
|
}
|
|
30146
30260
|
}
|
|
30147
30261
|
} catch (error) {
|
|
30148
|
-
await closeIterator(
|
|
30262
|
+
await closeIterator(iterator2, true);
|
|
30149
30263
|
throw error;
|
|
30150
30264
|
}
|
|
30151
30265
|
}
|
|
@@ -31685,11 +31799,11 @@ function createSetOperation(name, budget) {
|
|
|
31685
31799
|
const read = async (object, key) => context?.getProperty !== void 0 ? context.getProperty(object, key) : readPropertyDescriptor(getSandboxPropertyDescriptor(object, key, budget) ?? { value: void 0 }, object, context);
|
|
31686
31800
|
const iterationContext = { ...context, thisValue: receiver, stack: context?.stack ?? [], getProperty: read };
|
|
31687
31801
|
const result = createSandboxSet([]);
|
|
31688
|
-
let
|
|
31802
|
+
let iterator2;
|
|
31689
31803
|
let current;
|
|
31690
31804
|
let has2;
|
|
31691
31805
|
let keys;
|
|
31692
|
-
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys,
|
|
31806
|
+
const release = retainValues(budget, () => [receiver, other, result, current, has2, keys, iterator2?.retainedValue]);
|
|
31693
31807
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
31694
31808
|
const add2 = (value) => {
|
|
31695
31809
|
budget.visitNode();
|
|
@@ -31710,7 +31824,7 @@ function createSetOperation(name, budget) {
|
|
|
31710
31824
|
if (name === "isSubsetOf" && receiver.values.size > size || name === "isSupersetOf" && receiver.values.size < size) return false;
|
|
31711
31825
|
const visitReceiver = name === "isSubsetOf" || (name === "intersection" || name === "difference" || name === "isDisjointFrom") && receiver.values.size <= size;
|
|
31712
31826
|
if (name === "union" || name === "symmetricDifference")
|
|
31713
|
-
|
|
31827
|
+
iterator2 = await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31714
31828
|
if (name === "union" || name === "symmetricDifference" || name === "difference")
|
|
31715
31829
|
for (const value of receiver.values) add2(value);
|
|
31716
31830
|
if (visitReceiver) {
|
|
@@ -31729,15 +31843,15 @@ function createSetOperation(name, budget) {
|
|
|
31729
31843
|
cursor.leave();
|
|
31730
31844
|
}
|
|
31731
31845
|
} else {
|
|
31732
|
-
|
|
31846
|
+
iterator2 ??= await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
|
|
31733
31847
|
while (true) {
|
|
31734
31848
|
budget.visitNode();
|
|
31735
|
-
const next = await
|
|
31736
|
-
if ((await readIteratorResult(
|
|
31737
|
-
current = (await readIteratorResult(
|
|
31849
|
+
const next = await iterator2.next();
|
|
31850
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
31851
|
+
current = (await readIteratorResult(iterator2, next, "value")).value;
|
|
31738
31852
|
const found = receiver.values.has(current);
|
|
31739
31853
|
if (name === "isSupersetOf" && !found || name === "isDisjointFrom" && found) {
|
|
31740
|
-
await closeIterator(
|
|
31854
|
+
await closeIterator(iterator2);
|
|
31741
31855
|
return false;
|
|
31742
31856
|
}
|
|
31743
31857
|
if (name === "union" || name === "intersection" && found || name === "symmetricDifference" && !found) add2(current);
|
|
@@ -31807,7 +31921,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31807
31921
|
return context.thisValue.values.size;
|
|
31808
31922
|
}
|
|
31809
31923
|
});
|
|
31810
|
-
for (const { name, constructor, methods: methods4, size, iterator } of [
|
|
31924
|
+
for (const { name, constructor, methods: methods4, size, iterator: iterator2 } of [
|
|
31811
31925
|
{ name: "Map", constructor: mapConstructor, methods: mapMethods, size: mapSize3, iterator: mapMethods.entries },
|
|
31812
31926
|
{ name: "Set", constructor: setConstructor, methods: setMethods, size: setSize2, iterator: setMethods.values }
|
|
31813
31927
|
]) {
|
|
@@ -31826,7 +31940,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
31826
31940
|
Object.defineProperty(prototype, key, { value: method, writable: true, configurable: true });
|
|
31827
31941
|
Object.defineProperty(prototype, "size", { get: accessorAdapter(size, "get"), configurable: true });
|
|
31828
31942
|
Object.defineProperty(prototype, Symbol.toStringTag, { value: name, configurable: true });
|
|
31829
|
-
Object.defineProperty(prototype, Symbol.iterator, { value:
|
|
31943
|
+
Object.defineProperty(prototype, Symbol.iterator, { value: iterator2, writable: true, configurable: true });
|
|
31830
31944
|
installCollectionPrototype(budget, name, prototype, constructor);
|
|
31831
31945
|
for (const method of /* @__PURE__ */ new Set([...Object.values(methods4), size, species])) registerIntrinsicFunction(budget, method);
|
|
31832
31946
|
}
|
|
@@ -31954,14 +32068,14 @@ function populateCollection(source, collection, {
|
|
|
31954
32068
|
}) {
|
|
31955
32069
|
budget.allocateCollectionEntries(0);
|
|
31956
32070
|
let adder;
|
|
31957
|
-
const populate = (
|
|
31958
|
-
if (
|
|
32071
|
+
const populate = (iterator2) => {
|
|
32072
|
+
if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
31959
32073
|
let entry;
|
|
31960
32074
|
let failure;
|
|
31961
32075
|
const retained = {};
|
|
31962
32076
|
budget.setRetainedValues(retained, () => [
|
|
31963
32077
|
source,
|
|
31964
|
-
|
|
32078
|
+
iterator2.retainedValue,
|
|
31965
32079
|
collection,
|
|
31966
32080
|
adder,
|
|
31967
32081
|
entry,
|
|
@@ -31975,13 +32089,13 @@ function populateCollection(source, collection, {
|
|
|
31975
32089
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
31976
32090
|
throw error;
|
|
31977
32091
|
};
|
|
31978
|
-
if (
|
|
31979
|
-
return closeIterator(
|
|
32092
|
+
if (iterator2.getOperation !== void 0)
|
|
32093
|
+
return closeIterator(iterator2, true).then(() => {
|
|
31980
32094
|
throw error;
|
|
31981
32095
|
}, rethrow);
|
|
31982
32096
|
try {
|
|
31983
|
-
const closing =
|
|
31984
|
-
if (
|
|
32097
|
+
const closing = iterator2.return?.();
|
|
32098
|
+
if (iterator2.generator || iterator2.asynchronous)
|
|
31985
32099
|
return Promise.resolve(closing).then(() => {
|
|
31986
32100
|
throw error;
|
|
31987
32101
|
}, rethrow);
|
|
@@ -32011,16 +32125,16 @@ function populateCollection(source, collection, {
|
|
|
32011
32125
|
}
|
|
32012
32126
|
return false;
|
|
32013
32127
|
};
|
|
32014
|
-
if (
|
|
32128
|
+
if (iterator2.generator || iterator2.asynchronous || context !== void 0 || adder !== void 0) {
|
|
32015
32129
|
return (async () => {
|
|
32016
32130
|
try {
|
|
32017
32131
|
checkData(collection, 0, true);
|
|
32018
32132
|
while (true) {
|
|
32019
|
-
const result = await
|
|
32133
|
+
const result = await iterator2.next();
|
|
32020
32134
|
if (typeof result !== "object" || result === null)
|
|
32021
32135
|
throw new TypeError("Iterator result must be an object.");
|
|
32022
|
-
if ((await readIteratorResult(
|
|
32023
|
-
const value = (await readIteratorResult(
|
|
32136
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32137
|
+
const value = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32024
32138
|
await consume({ done: false, value });
|
|
32025
32139
|
}
|
|
32026
32140
|
checkData(collection, 0, true);
|
|
@@ -32032,7 +32146,7 @@ function populateCollection(source, collection, {
|
|
|
32032
32146
|
}
|
|
32033
32147
|
try {
|
|
32034
32148
|
checkData(collection, 0, true);
|
|
32035
|
-
while (!consume(
|
|
32149
|
+
while (!consume(iterator2.next())) {
|
|
32036
32150
|
}
|
|
32037
32151
|
checkData(collection, 0, true);
|
|
32038
32152
|
return collection;
|
|
@@ -32044,8 +32158,8 @@ function populateCollection(source, collection, {
|
|
|
32044
32158
|
const start = (candidate) => {
|
|
32045
32159
|
if (!isSandboxClosure(candidate)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32046
32160
|
if (getIntrinsicIdentity(candidate) !== JSON.stringify([name, "prototype", method])) adder = candidate;
|
|
32047
|
-
const
|
|
32048
|
-
return
|
|
32161
|
+
const iterator2 = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
|
|
32162
|
+
return iterator2 instanceof Promise ? iterator2.then(populate) : populate(iterator2);
|
|
32049
32163
|
};
|
|
32050
32164
|
const initialize = (prototype2) => {
|
|
32051
32165
|
if (typeof prototype2 !== "object" || prototype2 === null)
|
|
@@ -32092,14 +32206,14 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32092
32206
|
if (source === void 0 || source === null) return collection;
|
|
32093
32207
|
adder = await read(collection, adderName);
|
|
32094
32208
|
if (!isSandboxClosure(adder)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
32095
|
-
const
|
|
32096
|
-
if (
|
|
32097
|
-
const releaseIterator = retainValues(budget, () => [
|
|
32209
|
+
const iterator2 = context === void 0 ? getSandboxIterator(source, budget) : await acquireSandboxIterator(source, budget, context);
|
|
32210
|
+
if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
32211
|
+
const releaseIterator = retainValues(budget, () => [iterator2.retainedValue]);
|
|
32098
32212
|
try {
|
|
32099
32213
|
while (true) {
|
|
32100
|
-
const next = await
|
|
32101
|
-
if ((await readIteratorResult(
|
|
32102
|
-
entry = (await readIteratorResult(
|
|
32214
|
+
const next = await iterator2.next();
|
|
32215
|
+
if ((await readIteratorResult(iterator2, next, "done")).value) break;
|
|
32216
|
+
entry = (await readIteratorResult(iterator2, next, "value")).value;
|
|
32103
32217
|
try {
|
|
32104
32218
|
budget.visitNode();
|
|
32105
32219
|
if (kind === "map") {
|
|
@@ -32111,7 +32225,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32111
32225
|
entry = key = value = void 0;
|
|
32112
32226
|
} catch (error) {
|
|
32113
32227
|
try {
|
|
32114
|
-
await closeIterator(
|
|
32228
|
+
await closeIterator(iterator2, true);
|
|
32115
32229
|
} catch (closeError) {
|
|
32116
32230
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
32117
32231
|
}
|
|
@@ -32191,7 +32305,7 @@ function createWeakCollectionGlobals(budget) {
|
|
|
32191
32305
|
|
|
32192
32306
|
// packages/safe-js/src/interp/globals/math-sum-precise.ts
|
|
32193
32307
|
async function sumPrecise(source, budget, context) {
|
|
32194
|
-
let
|
|
32308
|
+
let iterator2;
|
|
32195
32309
|
let current;
|
|
32196
32310
|
let recordValue;
|
|
32197
32311
|
let sum = 0n;
|
|
@@ -32201,25 +32315,25 @@ async function sumPrecise(source, budget, context) {
|
|
|
32201
32315
|
let count = 0;
|
|
32202
32316
|
const storage = new DataView(new ArrayBuffer(8));
|
|
32203
32317
|
const checkData = createDataCheckpoint(budget, context);
|
|
32204
|
-
const release = retainValues(budget, () => [source,
|
|
32318
|
+
const release = retainValues(budget, () => [source, iterator2?.retainedValue, recordValue, current, sum]);
|
|
32205
32319
|
try {
|
|
32206
32320
|
if (source === void 0 || source === null) throw new TypeError("Math.sumPrecise requires an iterable.");
|
|
32207
|
-
|
|
32208
|
-
if (
|
|
32321
|
+
iterator2 = context === void 0 ? getSandboxIterator(source, budget) : await acquireSandboxIterator(source, budget, context);
|
|
32322
|
+
if (iterator2 === void 0) throw new TypeError("Math.sumPrecise requires an iterable.");
|
|
32209
32323
|
checkData(source, 0, true);
|
|
32210
32324
|
while (true) {
|
|
32211
32325
|
budget.visitNode();
|
|
32212
|
-
const next =
|
|
32213
|
-
const result =
|
|
32326
|
+
const next = iterator2.next();
|
|
32327
|
+
const result = iterator2.asynchronous || iterator2.generator ? await next : next;
|
|
32214
32328
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
32215
32329
|
throw new TypeError("Iterator result must be an object.");
|
|
32216
32330
|
recordValue = result;
|
|
32217
32331
|
const record4 = result;
|
|
32218
|
-
if ((await readIteratorResult(
|
|
32219
|
-
current = (await readIteratorResult(
|
|
32332
|
+
if ((await readIteratorResult(iterator2, record4, "done")).value) break;
|
|
32333
|
+
current = (await readIteratorResult(iterator2, record4, "value")).value;
|
|
32220
32334
|
if (count >= Number.MAX_SAFE_INTEGER || typeof current !== "number") {
|
|
32221
32335
|
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(
|
|
32336
|
+
await closeIterator(iterator2, true);
|
|
32223
32337
|
throw error;
|
|
32224
32338
|
}
|
|
32225
32339
|
count++;
|
|
@@ -32840,21 +32954,21 @@ async function cloneWithOptions(value, options, budget, context) {
|
|
|
32840
32954
|
})
|
|
32841
32955
|
};
|
|
32842
32956
|
let current;
|
|
32843
|
-
let
|
|
32957
|
+
let iterator2;
|
|
32844
32958
|
const items = [];
|
|
32845
|
-
const release = retainValues(budget, () => [value, options, current, items,
|
|
32959
|
+
const release = retainValues(budget, () => [value, options, current, items, iterator2?.retainedValue]);
|
|
32846
32960
|
try {
|
|
32847
32961
|
current = await bridge.getProperty(options, "transfer");
|
|
32848
32962
|
if (current !== void 0) {
|
|
32849
32963
|
if (current === null || typeof current !== "object") throw new TypeError("Transfer list must be an iterable object.");
|
|
32850
|
-
|
|
32851
|
-
if (
|
|
32964
|
+
iterator2 = await acquireSandboxIterator(current, budget, bridge);
|
|
32965
|
+
if (iterator2 === void 0) throw new TypeError("Transfer list must be iterable.");
|
|
32852
32966
|
for (; ; ) {
|
|
32853
32967
|
budget.visitNode();
|
|
32854
|
-
const result = await
|
|
32968
|
+
const result = await iterator2.next();
|
|
32855
32969
|
current = result;
|
|
32856
|
-
if ((await readIteratorResult(
|
|
32857
|
-
current = (await readIteratorResult(
|
|
32970
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
32971
|
+
current = (await readIteratorResult(iterator2, result, "value")).value;
|
|
32858
32972
|
if (current === null || typeof current !== "object") {
|
|
32859
32973
|
throw new TypeError("Transfer list elements must be objects.");
|
|
32860
32974
|
}
|
|
@@ -32929,8 +33043,8 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32929
33043
|
operation.release();
|
|
32930
33044
|
}
|
|
32931
33045
|
}
|
|
32932
|
-
const
|
|
32933
|
-
const first =
|
|
33046
|
+
const iterator2 = execute();
|
|
33047
|
+
const first = iterator2.next();
|
|
32934
33048
|
if (first.done) return first.value;
|
|
32935
33049
|
return (async () => {
|
|
32936
33050
|
let step = first;
|
|
@@ -32939,15 +33053,15 @@ function cloneStructuredValue(value, transfers, budget, context) {
|
|
|
32939
33053
|
const request = step.value;
|
|
32940
33054
|
if ("stringValue" in request) {
|
|
32941
33055
|
createDataCheckpoint(budget, context)(request.stringValue, 0, true);
|
|
32942
|
-
step =
|
|
33056
|
+
step = iterator2.next(await sandboxString(request.stringValue, budget, context));
|
|
32943
33057
|
} else {
|
|
32944
33058
|
createDataCheckpoint(budget, context)(request.receiver, 0, true);
|
|
32945
|
-
step =
|
|
33059
|
+
step = iterator2.next(await readPropertyDescriptor(request.descriptor, request.receiver, context));
|
|
32946
33060
|
}
|
|
32947
33061
|
}
|
|
32948
33062
|
return step.value;
|
|
32949
33063
|
} finally {
|
|
32950
|
-
|
|
33064
|
+
iterator2.return(void 0);
|
|
32951
33065
|
}
|
|
32952
33066
|
})();
|
|
32953
33067
|
}
|
|
@@ -37620,20 +37734,20 @@ function installIteratorFrom(constructor, budget) {
|
|
|
37620
37734
|
context = callContext(context);
|
|
37621
37735
|
if (input === null || typeof input !== "object" && typeof input !== "string")
|
|
37622
37736
|
throw new TypeError("Iterator.from requires an object or string.");
|
|
37623
|
-
let
|
|
37737
|
+
let iterator2 = input;
|
|
37624
37738
|
let next;
|
|
37625
|
-
const release = retainValues(budget, () => [input,
|
|
37739
|
+
const release = retainValues(budget, () => [input, iterator2, next]);
|
|
37626
37740
|
try {
|
|
37627
37741
|
const method = await context.getProperty(input, Symbol.iterator);
|
|
37628
37742
|
if (method !== void 0 && method !== null) {
|
|
37629
37743
|
if (!isSandboxClosure(method)) throw new TypeError("Symbol.iterator must be callable.");
|
|
37630
|
-
|
|
37744
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, input);
|
|
37631
37745
|
}
|
|
37632
|
-
if (
|
|
37633
|
-
next = await context.getProperty(
|
|
37634
|
-
if (await ordinaryHasInstance(
|
|
37746
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
37747
|
+
next = await context.getProperty(iterator2, "next");
|
|
37748
|
+
if (await ordinaryHasInstance(iterator2, constructor, budget, context)) return iterator2;
|
|
37635
37749
|
const wrapper = /* @__PURE__ */ Object.create(null);
|
|
37636
|
-
iteratorWrapperStates.set(wrapper, { iterator, next });
|
|
37750
|
+
iteratorWrapperStates.set(wrapper, { iterator: iterator2, next });
|
|
37637
37751
|
setSandboxPrototype(wrapper, prototype, budget);
|
|
37638
37752
|
createDataCheckpoint(budget, context)(wrapper, 0, true);
|
|
37639
37753
|
return wrapper;
|
|
@@ -37698,7 +37812,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37698
37812
|
}
|
|
37699
37813
|
const release = retainValues(budget, () => [receiver, callback, next, accumulator, value, values]);
|
|
37700
37814
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
37701
|
-
const
|
|
37815
|
+
const iterator2 = {
|
|
37702
37816
|
asynchronous: true,
|
|
37703
37817
|
next: async () => {
|
|
37704
37818
|
if (!isSandboxClosure(next)) throw new TypeError("Iterator next must be callable.");
|
|
@@ -37715,7 +37829,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37715
37829
|
};
|
|
37716
37830
|
try {
|
|
37717
37831
|
if (name !== "toArray" && !isSandboxClosure(callback)) {
|
|
37718
|
-
await closeIterator(
|
|
37832
|
+
await closeIterator(iterator2, true);
|
|
37719
37833
|
throw new TypeError("Iterator callback must be callable.");
|
|
37720
37834
|
}
|
|
37721
37835
|
next = await bridge.getProperty(receiver, "next");
|
|
@@ -37723,7 +37837,7 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37723
37837
|
let index = 0;
|
|
37724
37838
|
while (true) {
|
|
37725
37839
|
budget.visitNode();
|
|
37726
|
-
const result = await
|
|
37840
|
+
const result = await iterator2.next();
|
|
37727
37841
|
if (await bridge.getProperty(result, "done")) {
|
|
37728
37842
|
if (!initialized) throw new TypeError("Cannot reduce an empty iterator without an initial value.");
|
|
37729
37843
|
if (name === "toArray") return values;
|
|
@@ -37751,12 +37865,12 @@ function installIteratorConsumers(prototype, budget) {
|
|
|
37751
37865
|
void 0
|
|
37752
37866
|
);
|
|
37753
37867
|
} catch (error) {
|
|
37754
|
-
if (!isFatalSandboxError(error)) await closeIterator(
|
|
37868
|
+
if (!isFatalSandboxError(error)) await closeIterator(iterator2, true);
|
|
37755
37869
|
throw error;
|
|
37756
37870
|
}
|
|
37757
37871
|
if (name === "reduce") accumulator = selected;
|
|
37758
37872
|
else if ((name === "some" || name === "find") && selected || name === "every" && !selected) {
|
|
37759
|
-
await closeIterator(
|
|
37873
|
+
await closeIterator(iterator2);
|
|
37760
37874
|
return name === "find" ? value : name === "some";
|
|
37761
37875
|
}
|
|
37762
37876
|
}
|
|
@@ -37802,17 +37916,17 @@ function installJointIteratorHelpers(prototype, constructor, budget, protocol) {
|
|
|
37802
37916
|
}
|
|
37803
37917
|
async function acquire(value, context, flattenable) {
|
|
37804
37918
|
if (value === null || typeof value !== "object") throw new TypeError("Joint iteration inputs must be objects.");
|
|
37805
|
-
let
|
|
37919
|
+
let iterator2 = value;
|
|
37806
37920
|
let method;
|
|
37807
|
-
const release = retainValues(budget, () => [value,
|
|
37921
|
+
const release = retainValues(budget, () => [value, iterator2, method]);
|
|
37808
37922
|
try {
|
|
37809
37923
|
method = await context.getProperty(value, Symbol.iterator);
|
|
37810
37924
|
if (!flattenable || method !== void 0 && method !== null) {
|
|
37811
37925
|
if (!isSandboxClosure(method)) throw new TypeError("Input must be iterable.");
|
|
37812
|
-
|
|
37813
|
-
if (
|
|
37926
|
+
iterator2 = await invokeBuiltinClosure(method, [], budget, context, value);
|
|
37927
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
37814
37928
|
}
|
|
37815
|
-
return { iterator, next: await context.getProperty(
|
|
37929
|
+
return { iterator: iterator2, next: await context.getProperty(iterator2, "next") };
|
|
37816
37930
|
} finally {
|
|
37817
37931
|
release();
|
|
37818
37932
|
}
|
|
@@ -38040,10 +38154,10 @@ function installLazyIteratorHelpers(common, budget, constructor) {
|
|
|
38040
38154
|
complete(state);
|
|
38041
38155
|
return createIteratorResult(void 0, true, budget);
|
|
38042
38156
|
}
|
|
38043
|
-
const
|
|
38044
|
-
if (
|
|
38045
|
-
state.outer = { iterator, next: void 0 };
|
|
38046
|
-
state.outer.next = await context.getProperty(
|
|
38157
|
+
const iterator2 = await invokeBuiltinClosure(input.open, [], budget, context, input.iterable);
|
|
38158
|
+
if (iterator2 === null || typeof iterator2 !== "object") throw new TypeError("Iterator must be an object.");
|
|
38159
|
+
state.outer = { iterator: iterator2, next: void 0 };
|
|
38160
|
+
state.outer.next = await context.getProperty(iterator2, "next");
|
|
38047
38161
|
state.iterables.shift();
|
|
38048
38162
|
}
|
|
38049
38163
|
const result2 = await step(state.outer, context);
|
|
@@ -40280,20 +40394,20 @@ function createListFormatConstructor(budget) {
|
|
|
40280
40394
|
const receiver = context?.thisValue;
|
|
40281
40395
|
listFormatState(receiver);
|
|
40282
40396
|
const strings = [];
|
|
40283
|
-
let
|
|
40284
|
-
const release = retainValues(budget, () => [receiver, strings,
|
|
40397
|
+
let iterator2;
|
|
40398
|
+
const release = retainValues(budget, () => [receiver, strings, iterator2?.retainedValue]);
|
|
40285
40399
|
const checkpoint = createDataCheckpoint(budget, context);
|
|
40286
40400
|
try {
|
|
40287
40401
|
if (input !== void 0) {
|
|
40288
|
-
|
|
40289
|
-
if (
|
|
40402
|
+
iterator2 = context === void 0 ? getSandboxIterator(input, budget) : await acquireSandboxIterator(input, budget, context);
|
|
40403
|
+
if (iterator2 === void 0) throw new TypeError("ListFormat requires an iterable.");
|
|
40290
40404
|
while (true) {
|
|
40291
40405
|
budget.visitNode();
|
|
40292
|
-
const result = await
|
|
40293
|
-
if ((await readIteratorResult(
|
|
40294
|
-
const value = (await readIteratorResult(
|
|
40406
|
+
const result = await iterator2.next();
|
|
40407
|
+
if ((await readIteratorResult(iterator2, result, "done")).value) break;
|
|
40408
|
+
const value = (await readIteratorResult(iterator2, result, "value")).value;
|
|
40295
40409
|
if (typeof value !== "string") {
|
|
40296
|
-
await closeIterator(
|
|
40410
|
+
await closeIterator(iterator2, true);
|
|
40297
40411
|
throw new TypeError("ListFormat requires string elements.");
|
|
40298
40412
|
}
|
|
40299
40413
|
budget.visitNode(value.length);
|
|
@@ -41259,8 +41373,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41259
41373
|
validateGuestHeapNode({ kind: "guest-object", state: node2.state }, heap, maxArrayLength);
|
|
41260
41374
|
const properties = array(record3(record3(node2.state).properties).properties).map(array);
|
|
41261
41375
|
if (node2.nativeIterator) {
|
|
41262
|
-
const
|
|
41263
|
-
if (
|
|
41376
|
+
const iterator2 = properties.find(([key]) => typeof key === "object" && key !== null && record3(heap[String(record3(key).id)]).wellKnown === "iterator");
|
|
41377
|
+
if (iterator2 === void 0 || record3(iterator2[1]).kind !== "data" || !absent(record3(iterator2[1]).value))
|
|
41264
41378
|
throw new TypeError("Invalid native arguments iterator descriptor.");
|
|
41265
41379
|
}
|
|
41266
41380
|
const indices = /* @__PURE__ */ new Set(), names = /* @__PURE__ */ new Set();
|
|
@@ -41978,8 +42092,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
41978
42092
|
state(node.state);
|
|
41979
42093
|
} else if (node.kind === "iterator-wrapper") {
|
|
41980
42094
|
fields(node, ["kind", "iterator", "next", "state"]);
|
|
41981
|
-
const
|
|
41982
|
-
if (
|
|
42095
|
+
const iterator2 = reference(node.iterator);
|
|
42096
|
+
if (iterator2.kind === "symbol" || iterator2.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
|
|
41983
42097
|
state(node.state);
|
|
41984
42098
|
} else if (node.kind === "disposable-stack") {
|
|
41985
42099
|
fields(node, ["kind", "disposed", "resources", "state"]);
|
|
@@ -42350,34 +42464,34 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
42350
42464
|
if (expression.kind !== "yield-delegate") integer(expression.index);
|
|
42351
42465
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
42352
42466
|
else {
|
|
42353
|
-
let
|
|
42467
|
+
let iterator2 = record3(expression.iterator);
|
|
42354
42468
|
let depth = 0;
|
|
42355
42469
|
let protocol = false;
|
|
42356
|
-
while (
|
|
42470
|
+
while (iterator2.kind === "async-from-sync") {
|
|
42357
42471
|
if (++depth > 1) throw new TypeError("Invalid nested async iterator adapter.");
|
|
42358
|
-
fields(
|
|
42359
|
-
|
|
42472
|
+
fields(iterator2, ["kind", "inner"]);
|
|
42473
|
+
iterator2 = record3(iterator2.inner);
|
|
42360
42474
|
protocol = true;
|
|
42361
42475
|
}
|
|
42362
42476
|
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
42477
|
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
|
|
42478
|
+
if (iterator2.kind === "guest") {
|
|
42479
|
+
fields(iterator2, ["kind", "value", "next", "async"]);
|
|
42480
|
+
if (typeof iterator2.async !== "boolean") throw new TypeError("Invalid iterator protocol.");
|
|
42481
|
+
if (depth > 0 && iterator2.async) throw new TypeError("Invalid async-from-sync source.");
|
|
42482
|
+
protocol ||= iterator2.async;
|
|
42483
|
+
reference(iterator2.value);
|
|
42484
|
+
callable(iterator2.next);
|
|
42485
|
+
} else if (iterator2.kind === "builtin") {
|
|
42486
|
+
fields(iterator2, ["kind", "value", "index"]);
|
|
42487
|
+
integer(iterator2.index);
|
|
42488
|
+
if (typeof iterator2.value === "string" && iterator2.index > iterator2.value.length)
|
|
42375
42489
|
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)) &&
|
|
42490
|
+
if (typeof iterator2.value !== "string") {
|
|
42491
|
+
const target = reference(iterator2.value, ["array", "guest-array", "map", "set", "guest-generator", "collection-iterator", "regexp-iterator"]);
|
|
42492
|
+
if (["guest-generator", "collection-iterator", "regexp-iterator"].includes(String(target.kind)) && iterator2.index !== 0)
|
|
42379
42493
|
throw new TypeError("Invalid stateful iterator cursor.");
|
|
42380
|
-
if (target.kind === "map" &&
|
|
42494
|
+
if (target.kind === "map" && iterator2.index > array(target.entries).length || target.kind === "set" && iterator2.index > array(target.values).length)
|
|
42381
42495
|
throw new TypeError("Invalid collection iterator cursor.");
|
|
42382
42496
|
if (target.kind === "guest-generator" && target.async === true) {
|
|
42383
42497
|
if (depth > 0) throw new TypeError("Invalid async-from-sync generator.");
|
|
@@ -43447,8 +43561,8 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43447
43561
|
}
|
|
43448
43562
|
const properties = requireRecord(record4.properties, `${path}.properties`);
|
|
43449
43563
|
if (record4.iterator !== null) {
|
|
43450
|
-
const
|
|
43451
|
-
for (const key of Object.keys(
|
|
43564
|
+
const iterator2 = requireRecord(record4.iterator, `${path}.iterator`);
|
|
43565
|
+
for (const key of Object.keys(iterator2)) {
|
|
43452
43566
|
if (!["configurable", "enumerable", "writable"].includes(key)) {
|
|
43453
43567
|
fail(
|
|
43454
43568
|
"invalidValue",
|
|
@@ -43458,7 +43572,7 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43458
43572
|
}
|
|
43459
43573
|
}
|
|
43460
43574
|
for (const flag of ["configurable", "enumerable", "writable"]) {
|
|
43461
|
-
if (typeof
|
|
43575
|
+
if (typeof iterator2[flag] !== "boolean")
|
|
43462
43576
|
fail("invalidType", `${path}.iterator.${flag}`, "expected boolean");
|
|
43463
43577
|
}
|
|
43464
43578
|
}
|
|
@@ -43487,10 +43601,20 @@ function validateArgumentsProperties(record4, path) {
|
|
|
43487
43601
|
}
|
|
43488
43602
|
}
|
|
43489
43603
|
}
|
|
43490
|
-
function
|
|
43491
|
-
if (types21.isProxy(value)
|
|
43604
|
+
function validateSnapshotProxy(value, path, dataPropertiesOnly = false) {
|
|
43605
|
+
if (!types21.isProxy(value)) return;
|
|
43606
|
+
if (!dataPropertiesOnly && isTrackedIntrinsicObject(value)) {
|
|
43607
|
+
const prototype = Object.getPrototypeOf(value);
|
|
43608
|
+
if (prototype !== null && prototype !== (Array.isArray(value) ? Array.prototype : Object.prototype))
|
|
43609
|
+
fail("invalidType", path, "runtime snapshot objects must not have a custom native prototype");
|
|
43610
|
+
return;
|
|
43611
|
+
}
|
|
43612
|
+
if (dataPropertiesOnly || getIntrinsicIdentity(value) === void 0 && !isSandboxModuleNamespace(value)) {
|
|
43492
43613
|
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43493
43614
|
}
|
|
43615
|
+
}
|
|
43616
|
+
function validateGenericValue(value, path, depth, state) {
|
|
43617
|
+
validateSnapshotProxy(value, path, state.dataPropertiesOnly);
|
|
43494
43618
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.allowHostFunctionState && (isSandboxModuleNamespace(value) || isSandboxClosure(value) && !isGuestClosure(value)))) {
|
|
43495
43619
|
fail("invalidState", path, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
43496
43620
|
}
|
|
@@ -43556,8 +43680,7 @@ function validateRuntimeSnapshotDescriptors(snapshot) {
|
|
|
43556
43680
|
let entries = 0;
|
|
43557
43681
|
while (pending.length > 0) {
|
|
43558
43682
|
const { value, path, depth } = pending.pop();
|
|
43559
|
-
|
|
43560
|
-
fail("invalidType", path, "proxy objects are not snapshot data");
|
|
43683
|
+
validateSnapshotProxy(value, path);
|
|
43561
43684
|
if (seen.has(value)) continue;
|
|
43562
43685
|
seen.add(value);
|
|
43563
43686
|
if (depth > MAX_DATA_DEPTH)
|
|
@@ -45858,12 +45981,20 @@ import { types as nodeTypes } from "node:util";
|
|
|
45858
45981
|
var frozenClosureData = /* @__PURE__ */ new WeakMap();
|
|
45859
45982
|
var readFrozenClosureData = WeakMap.prototype.get.bind(frozenClosureData);
|
|
45860
45983
|
var writeFrozenClosureData = WeakMap.prototype.set.bind(frozenClosureData);
|
|
45861
|
-
var
|
|
45862
|
-
var
|
|
45984
|
+
var freezeValueShape = Object.freeze;
|
|
45985
|
+
var captureValueSymbols = Object.getOwnPropertySymbols;
|
|
45986
|
+
var sealValueShape = Object.seal;
|
|
45987
|
+
var sealedValueSymbols = /* @__PURE__ */ new WeakMap();
|
|
45988
|
+
var readSealedValueSymbols = WeakMap.prototype.get.bind(sealedValueSymbols);
|
|
45989
|
+
var writeSealedValueSymbols = WeakMap.prototype.set.bind(sealedValueSymbols);
|
|
45863
45990
|
var captureClosureDescriptor = Object.getOwnPropertyDescriptor;
|
|
45864
45991
|
var hasClosureDescriptorField = Object.hasOwn;
|
|
45865
45992
|
var invokeClosureGetter = Reflect.apply;
|
|
45866
|
-
var closureGetterArguments =
|
|
45993
|
+
var closureGetterArguments = freezeValueShape([]);
|
|
45994
|
+
function captureSealedValueSymbols(value) {
|
|
45995
|
+
writeSealedValueSymbols(value, freezeValueShape(captureValueSymbols(value)));
|
|
45996
|
+
return value;
|
|
45997
|
+
}
|
|
45867
45998
|
function readClosureProperties(closure, data) {
|
|
45868
45999
|
const getter = data?.propertiesGetter;
|
|
45869
46000
|
return getter === void 0 ? closure.properties : invokeClosureGetter(getter, closure, closureGetterArguments);
|
|
@@ -45945,12 +46076,12 @@ function createSandboxClosure(input) {
|
|
|
45945
46076
|
value: input.retainedValues
|
|
45946
46077
|
});
|
|
45947
46078
|
}
|
|
45948
|
-
|
|
46079
|
+
freezeValueShape(closure);
|
|
45949
46080
|
const properties = captureClosureDescriptor(closure, "properties");
|
|
45950
46081
|
writeFrozenClosureData(
|
|
45951
46082
|
closure,
|
|
45952
|
-
|
|
45953
|
-
symbols:
|
|
46083
|
+
freezeValueShape({
|
|
46084
|
+
symbols: freezeValueShape(captureValueSymbols(closure)),
|
|
45954
46085
|
closure: captureClosureDescriptor(closure, sandboxClosureBrand) !== void 0,
|
|
45955
46086
|
propertiesGetter: properties !== void 0 && hasClosureDescriptorField(properties, "get") ? properties.get : void 0
|
|
45956
46087
|
})
|
|
@@ -45961,7 +46092,13 @@ function registerDeferredClosureChargeIdentity(closure, identity) {
|
|
|
45961
46092
|
const data = readFrozenClosureData(closure);
|
|
45962
46093
|
if (data?.closure !== true || data.chargeIdentity !== void 0)
|
|
45963
46094
|
throw new TypeError("Deferred initialization requires a fresh SDK-created function.");
|
|
45964
|
-
writeFrozenClosureData(closure,
|
|
46095
|
+
writeFrozenClosureData(closure, freezeValueShape({ ...data, chargeIdentity: identity }));
|
|
46096
|
+
}
|
|
46097
|
+
function registerClosureCaptureCollector(closure, provider, collect) {
|
|
46098
|
+
if (readFrozenClosureData(closure)?.closure !== true) return;
|
|
46099
|
+
const descriptor = captureClosureDescriptor(closure, sandboxRetainedValues);
|
|
46100
|
+
if (descriptor !== void 0 && hasClosureDescriptorField(descriptor, "value") && descriptor.value === provider)
|
|
46101
|
+
registerIndexedClosureCaptures(closure, collect);
|
|
45965
46102
|
}
|
|
45966
46103
|
function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
45967
46104
|
if (isGuestHostObject(value)) {
|
|
@@ -46075,7 +46212,7 @@ function createSandboxPromise(promise, metadata = {}) {
|
|
|
46075
46212
|
);
|
|
46076
46213
|
trackSandboxPromise(sandboxPromise);
|
|
46077
46214
|
registerPromiseCancellation(sandboxPromise);
|
|
46078
|
-
return
|
|
46215
|
+
return captureSealedValueSymbols(freezeValueShape(sandboxPromise));
|
|
46079
46216
|
}
|
|
46080
46217
|
function createSandboxGenerator(channel, metadata = void 0) {
|
|
46081
46218
|
const generator = {
|
|
@@ -46106,7 +46243,7 @@ function createSandboxMap(entries = []) {
|
|
|
46106
46243
|
enumerable: false,
|
|
46107
46244
|
value: true
|
|
46108
46245
|
});
|
|
46109
|
-
return
|
|
46246
|
+
return captureSealedValueSymbols(freezeValueShape(map));
|
|
46110
46247
|
}
|
|
46111
46248
|
function createSandboxSet(values = []) {
|
|
46112
46249
|
const set3 = {};
|
|
@@ -46123,7 +46260,7 @@ function createSandboxSet(values = []) {
|
|
|
46123
46260
|
enumerable: false,
|
|
46124
46261
|
value: true
|
|
46125
46262
|
});
|
|
46126
|
-
return
|
|
46263
|
+
return captureSealedValueSymbols(freezeValueShape(set3));
|
|
46127
46264
|
}
|
|
46128
46265
|
function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
46129
46266
|
if (typeof source !== "string" || typeof flags !== "string") {
|
|
@@ -46159,7 +46296,7 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
|
46159
46296
|
[sandboxRegexBrand]: { value: true },
|
|
46160
46297
|
[sandboxRegexPattern]: { value: pattern, writable: true }
|
|
46161
46298
|
});
|
|
46162
|
-
return
|
|
46299
|
+
return captureSealedValueSymbols(sealValueShape(regex));
|
|
46163
46300
|
}
|
|
46164
46301
|
function getSandboxRegexPattern(regex) {
|
|
46165
46302
|
return regex[sandboxRegexPattern];
|
|
@@ -46311,28 +46448,47 @@ function* cloneStructuredGraph(value, state, budget, depth = 0) {
|
|
|
46311
46448
|
var nativeDataArrayAppend = Function.prototype.call.bind(Array.prototype.push);
|
|
46312
46449
|
var nativeDataArraySetPrototype = Object.setPrototypeOf;
|
|
46313
46450
|
var MAX_REUSABLE_CAPTURE_LENGTH = 64;
|
|
46451
|
+
var NativeMeasurementSet = Set;
|
|
46452
|
+
var retainedMeasurementCode;
|
|
46453
|
+
function createMeasurementCollector(target) {
|
|
46454
|
+
return {
|
|
46455
|
+
append(value) {
|
|
46456
|
+
target?.(value);
|
|
46457
|
+
},
|
|
46458
|
+
close() {
|
|
46459
|
+
target = void 0;
|
|
46460
|
+
}
|
|
46461
|
+
};
|
|
46462
|
+
}
|
|
46314
46463
|
function measureSandboxData(values, options = {}) {
|
|
46464
|
+
if (retainedMeasurementCode === void 0)
|
|
46465
|
+
withMeasurementSeen((seen) => measureSandboxDataWithSeen([], {}, seen, true));
|
|
46466
|
+
retainedMeasurementCode(void 0);
|
|
46315
46467
|
return withMeasurementSeen((seen) => measureSandboxDataWithSeen(values, options, seen));
|
|
46316
46468
|
}
|
|
46317
|
-
function measureSandboxDataWithSeen(values, options, seen) {
|
|
46318
|
-
const seenSymbols = /* @__PURE__ */ new Set();
|
|
46469
|
+
function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
|
|
46470
|
+
const seenSymbols = retainCode ? new NativeMeasurementSet() : /* @__PURE__ */ new Set();
|
|
46319
46471
|
let usage = 0;
|
|
46320
46472
|
const projectedPrimitives = [];
|
|
46473
|
+
let pendingArguments;
|
|
46474
|
+
let pendingFunctions;
|
|
46475
|
+
let pendingFunctionDepths;
|
|
46321
46476
|
let waiting;
|
|
46322
46477
|
let ready;
|
|
46323
46478
|
let pending;
|
|
46324
46479
|
let pendingCount = 0;
|
|
46325
|
-
const appendContinuation = (values2, depth, capture) => {
|
|
46480
|
+
const appendContinuation = (values2, depth, capture, proxy) => {
|
|
46326
46481
|
const frames = pending ??= nativeDataArraySetPrototype([], null);
|
|
46327
46482
|
let frame = frames[pendingCount];
|
|
46328
46483
|
if (frame === void 0) {
|
|
46329
|
-
frame = { values: values2, index: 1, depth, capture };
|
|
46484
|
+
frame = { values: values2, index: 1, depth, capture, proxy };
|
|
46330
46485
|
nativeDataArrayAppend(frames, frame);
|
|
46331
46486
|
} else {
|
|
46332
46487
|
frame.values = values2;
|
|
46333
46488
|
frame.index = 1;
|
|
46334
46489
|
frame.depth = depth;
|
|
46335
46490
|
frame.capture = capture;
|
|
46491
|
+
frame.proxy = proxy;
|
|
46336
46492
|
}
|
|
46337
46493
|
pendingCount++;
|
|
46338
46494
|
};
|
|
@@ -46359,11 +46515,35 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46359
46515
|
let secondSeenCapture;
|
|
46360
46516
|
let thirdSeenCapture;
|
|
46361
46517
|
let fourthSeenCapture;
|
|
46518
|
+
let fifthSeenCapture;
|
|
46519
|
+
let sixthSeenCapture;
|
|
46520
|
+
let seventhSeenCapture;
|
|
46521
|
+
let eighthSeenCapture;
|
|
46522
|
+
let ninthSeenCapture;
|
|
46523
|
+
let tenthSeenCapture;
|
|
46524
|
+
let eleventhSeenCapture;
|
|
46525
|
+
let twelfthSeenCapture;
|
|
46526
|
+
let thirteenthSeenCapture;
|
|
46527
|
+
let fourteenthSeenCapture;
|
|
46528
|
+
let fifteenthSeenCapture;
|
|
46529
|
+
let sixteenthSeenCapture;
|
|
46362
46530
|
const appendNativeCapture = (value) => {
|
|
46363
46531
|
if (value === void 0) return;
|
|
46364
46532
|
if (typeof value === "object" && value !== null) {
|
|
46365
|
-
if (value === firstSeenCapture || value === secondSeenCapture || value === thirdSeenCapture || value === fourthSeenCapture) return;
|
|
46533
|
+
if (value === firstSeenCapture || value === secondSeenCapture || value === thirdSeenCapture || value === fourthSeenCapture || value === fifthSeenCapture || value === sixthSeenCapture || value === seventhSeenCapture || value === eighthSeenCapture || value === ninthSeenCapture || value === tenthSeenCapture || value === eleventhSeenCapture || value === twelfthSeenCapture || value === thirteenthSeenCapture || value === fourteenthSeenCapture || value === fifteenthSeenCapture || value === sixteenthSeenCapture) return;
|
|
46366
46534
|
if (seen.has(value)) {
|
|
46535
|
+
sixteenthSeenCapture = fifteenthSeenCapture;
|
|
46536
|
+
fifteenthSeenCapture = fourteenthSeenCapture;
|
|
46537
|
+
fourteenthSeenCapture = thirteenthSeenCapture;
|
|
46538
|
+
thirteenthSeenCapture = twelfthSeenCapture;
|
|
46539
|
+
twelfthSeenCapture = eleventhSeenCapture;
|
|
46540
|
+
eleventhSeenCapture = tenthSeenCapture;
|
|
46541
|
+
tenthSeenCapture = ninthSeenCapture;
|
|
46542
|
+
ninthSeenCapture = eighthSeenCapture;
|
|
46543
|
+
eighthSeenCapture = seventhSeenCapture;
|
|
46544
|
+
seventhSeenCapture = sixthSeenCapture;
|
|
46545
|
+
sixthSeenCapture = fifthSeenCapture;
|
|
46546
|
+
fifthSeenCapture = fourthSeenCapture;
|
|
46367
46547
|
fourthSeenCapture = thirdSeenCapture;
|
|
46368
46548
|
thirdSeenCapture = secondSeenCapture;
|
|
46369
46549
|
secondSeenCapture = firstSeenCapture;
|
|
@@ -46373,6 +46553,47 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46373
46553
|
}
|
|
46374
46554
|
captures = appendCapture(captures, value);
|
|
46375
46555
|
};
|
|
46556
|
+
const collector = createMeasurementCollector(appendNativeCapture);
|
|
46557
|
+
const visitTemporalIntl = (value, depth) => {
|
|
46558
|
+
if (isSandboxTemporalInstant(value)) visit(temporalInstantEpoch(value), depth + 1);
|
|
46559
|
+
if (isSandboxTemporalDuration(value)) usage += temporalDurationFieldNames.length * 8;
|
|
46560
|
+
if (isSandboxTemporalPlainTime(value)) usage += temporalPlainTimeFieldNames.length * 8;
|
|
46561
|
+
if (isSandboxTemporalPlainDateTime(value)) usage += temporalPlainDateTimeNumericFields.length * 8 + temporalPlainDateTimeFields(value).calendar.length;
|
|
46562
|
+
if (isSandboxTemporalPlainDate(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainDateFields(value).calendar.length;
|
|
46563
|
+
if (isSandboxTemporalPlainMonthDay(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainMonthDayFields(value).calendar.length;
|
|
46564
|
+
if (isSandboxTemporalPlainYearMonth(value)) usage += temporalPlainDateNumericFields.length * 8 + temporalPlainYearMonthFields(value).calendar.length;
|
|
46565
|
+
if (isSandboxTemporalZonedDateTime(value)) {
|
|
46566
|
+
const fields2 = temporalZonedDateTimeFields(value);
|
|
46567
|
+
visit(fields2.epochNanoseconds, depth + 1);
|
|
46568
|
+
usage += fields2.timeZone.length + fields2.calendar.length;
|
|
46569
|
+
}
|
|
46570
|
+
if (isSandboxLocale(value)) usage += localeTag(value).length;
|
|
46571
|
+
if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
|
|
46572
|
+
if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
|
|
46573
|
+
if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
|
|
46574
|
+
if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
|
|
46575
|
+
if (isSandboxDurationFormat(value)) {
|
|
46576
|
+
const state = durationFormatState(value);
|
|
46577
|
+
visit(state.settings, depth + 1);
|
|
46578
|
+
visit(state.options, depth + 1);
|
|
46579
|
+
}
|
|
46580
|
+
if (isSandboxNumberFormat(value)) {
|
|
46581
|
+
const state = numberFormatState(value);
|
|
46582
|
+
visit(state.options, depth + 1);
|
|
46583
|
+
visit(state.format, depth + 1);
|
|
46584
|
+
}
|
|
46585
|
+
if (isSandboxDateTimeFormat(value)) {
|
|
46586
|
+
const state = dateTimeFormatState(value);
|
|
46587
|
+
visit(state.options, depth + 1);
|
|
46588
|
+
visit(state.requestedOptions, depth + 1);
|
|
46589
|
+
visit(state.format, depth + 1);
|
|
46590
|
+
}
|
|
46591
|
+
if (isSandboxCollator(value)) {
|
|
46592
|
+
const state = collatorState(value);
|
|
46593
|
+
visit(state.options, depth + 1);
|
|
46594
|
+
visit(state.compare, depth + 1);
|
|
46595
|
+
}
|
|
46596
|
+
};
|
|
46376
46597
|
const visit = (value, depth = 0) => {
|
|
46377
46598
|
const floor = pendingCount;
|
|
46378
46599
|
walk: while (true) {
|
|
@@ -46412,6 +46633,30 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46412
46633
|
const bindingRoot = scopeDataRoots.get(value);
|
|
46413
46634
|
if (bindingRoot !== void 0) {
|
|
46414
46635
|
seen.add(value);
|
|
46636
|
+
if ("arguments" in bindingRoot) {
|
|
46637
|
+
const state = bindingRoot.arguments;
|
|
46638
|
+
const current = state.read();
|
|
46639
|
+
if (current !== void 0) {
|
|
46640
|
+
value = current;
|
|
46641
|
+
continue walk;
|
|
46642
|
+
}
|
|
46643
|
+
assertSandboxDataDepth(depth);
|
|
46644
|
+
const snapshot = state.capture();
|
|
46645
|
+
const includeIterator = !internalSymbols.has(snapshot.iterator);
|
|
46646
|
+
const includeBrand = !internalSymbols.has(sandboxArgumentsBrand);
|
|
46647
|
+
const units = snapshot.units + (includeIterator ? 1 : 0) + (includeBrand ? 1 : 0);
|
|
46648
|
+
usage += units;
|
|
46649
|
+
pendingArguments ??= nativeDataArraySetPrototype([], null);
|
|
46650
|
+
nativeDataArrayAppend(pendingArguments, { state, units, depth });
|
|
46651
|
+
if (includeIterator) visit(snapshot.iterator, depth + 1);
|
|
46652
|
+
if (includeBrand) visit(sandboxArgumentsBrand, depth + 1);
|
|
46653
|
+
const references = snapshot.references;
|
|
46654
|
+
if (references.length === 0) break entry;
|
|
46655
|
+
if (references.length > 1) appendContinuation(references, depth + 1);
|
|
46656
|
+
value = references[0];
|
|
46657
|
+
depth++;
|
|
46658
|
+
continue walk;
|
|
46659
|
+
}
|
|
46415
46660
|
if ("deferred" in bindingRoot) {
|
|
46416
46661
|
const deferred2 = bindingRoot.deferred;
|
|
46417
46662
|
const current = deferred2.read();
|
|
@@ -46424,10 +46669,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46424
46669
|
seen.add(deferred2.chargeIdentity);
|
|
46425
46670
|
usage++;
|
|
46426
46671
|
}
|
|
46672
|
+
if (pendingFunctions === void 0) {
|
|
46673
|
+
pendingFunctions = nativeDataArraySetPrototype([], null);
|
|
46674
|
+
pendingFunctionDepths = nativeDataArraySetPrototype([], null);
|
|
46675
|
+
}
|
|
46676
|
+
const pendingIndex = pendingFunctions.length;
|
|
46677
|
+
pendingFunctions[pendingIndex] = deferred2;
|
|
46678
|
+
pendingFunctionDepths[pendingIndex] = depth;
|
|
46427
46679
|
if (options.ignoreClosures || options.ignoreClosureCaptures) break entry;
|
|
46428
46680
|
let roots2;
|
|
46429
46681
|
try {
|
|
46430
|
-
deferred2.collect(
|
|
46682
|
+
deferred2.collect(collector.append);
|
|
46431
46683
|
roots2 = captures;
|
|
46432
46684
|
} finally {
|
|
46433
46685
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46488,8 +46740,17 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46488
46740
|
for (const cell of finalization.state.cells) visit(cell.heldValue, depth + 1);
|
|
46489
46741
|
}
|
|
46490
46742
|
if (proxyState !== void 0) {
|
|
46491
|
-
if (proxyState.target !== null)
|
|
46492
|
-
|
|
46743
|
+
if (proxyState.target !== null) {
|
|
46744
|
+
value = proxyState.target;
|
|
46745
|
+
appendContinuation(void 0, depth + 1, void 0, proxyState);
|
|
46746
|
+
depth++;
|
|
46747
|
+
continue walk;
|
|
46748
|
+
}
|
|
46749
|
+
if (proxyState.handler !== null) {
|
|
46750
|
+
value = proxyState.handler;
|
|
46751
|
+
depth++;
|
|
46752
|
+
continue walk;
|
|
46753
|
+
}
|
|
46493
46754
|
break entry;
|
|
46494
46755
|
}
|
|
46495
46756
|
if (dynamicSourceRecords.has(value)) {
|
|
@@ -46526,9 +46787,22 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46526
46787
|
const managedArray = arrayLength !== void 0 && hasManagedDescriptors(value);
|
|
46527
46788
|
let arrayDescriptors;
|
|
46528
46789
|
let arrayElements;
|
|
46529
|
-
|
|
46790
|
+
const arrayData = arrayLength !== void 0 && !managedArray ? trackedArrayElementData(value) : void 0;
|
|
46791
|
+
if (arrayLength !== void 0 && arrayData === void 0) {
|
|
46530
46792
|
if (managedArray) arrayDescriptors = nativeDataArraySetPrototype([], null);
|
|
46531
|
-
|
|
46793
|
+
const trackedDescriptors2 = trackedPropertyDataDescriptors(value);
|
|
46794
|
+
if (trackedDescriptors2 !== void 0) {
|
|
46795
|
+
for (let index = 0; index < trackedDescriptors2.length; index++) {
|
|
46796
|
+
const entry = trackedDescriptors2[index];
|
|
46797
|
+
const key = entry[0], descriptor = entry[1];
|
|
46798
|
+
if (key === "length") {
|
|
46799
|
+
if (!managedArray) break;
|
|
46800
|
+
continue;
|
|
46801
|
+
}
|
|
46802
|
+
if (arrayDescriptors !== void 0) nativeDataArrayAppend(arrayDescriptors, [key, descriptor]);
|
|
46803
|
+
else if ("value" in descriptor && typeof descriptor.value !== "number") arrayElements = appendCapture(arrayElements, descriptor.value);
|
|
46804
|
+
}
|
|
46805
|
+
} else if (!managedArray && nodeTypes.isProxy(value)) {
|
|
46532
46806
|
for (let index = 0; index < arrayLength; index += 1) {
|
|
46533
46807
|
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
46534
46808
|
if (descriptor !== void 0 && "value" in descriptor) arrayElements = appendCapture(arrayElements, descriptor.value);
|
|
@@ -46563,23 +46837,54 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46563
46837
|
}
|
|
46564
46838
|
}
|
|
46565
46839
|
if (knownClosure || !isGuestHostObject(value)) {
|
|
46566
|
-
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value);
|
|
46840
|
+
const ownedSymbols = closureData?.symbols ?? trackedPropertySymbols(value) ?? readSealedValueSymbols(value);
|
|
46841
|
+
let firstSymbol;
|
|
46842
|
+
let firstDescriptor;
|
|
46567
46843
|
let descriptors2;
|
|
46568
46844
|
if (ownedSymbols !== void 0) {
|
|
46569
|
-
for (let index = 0; index < ownedSymbols.length; index++)
|
|
46570
|
-
|
|
46845
|
+
for (let index = 0; index < ownedSymbols.length; index++) {
|
|
46846
|
+
const key = ownedSymbols[index];
|
|
46847
|
+
if (internalSymbols.has(key)) continue;
|
|
46848
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
46849
|
+
if (descriptor === void 0) continue;
|
|
46850
|
+
if (firstDescriptor === void 0) {
|
|
46851
|
+
firstSymbol = key;
|
|
46852
|
+
firstDescriptor = descriptor;
|
|
46853
|
+
} else {
|
|
46854
|
+
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
46855
|
+
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
46856
|
+
}
|
|
46857
|
+
}
|
|
46571
46858
|
} else {
|
|
46572
46859
|
const symbols = isNumericTypedArray(value) ? typedArraySymbolKeys(value) : Object.getOwnPropertySymbols(value);
|
|
46573
|
-
for (const key of symbols)
|
|
46860
|
+
for (const key of symbols) {
|
|
46861
|
+
if (internalSymbols.has(key)) continue;
|
|
46862
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
46863
|
+
if (descriptor === void 0) continue;
|
|
46864
|
+
if (firstDescriptor === void 0) {
|
|
46865
|
+
firstSymbol = key;
|
|
46866
|
+
firstDescriptor = descriptor;
|
|
46867
|
+
} else {
|
|
46868
|
+
descriptors2 ??= nativeDataArraySetPrototype([], null);
|
|
46869
|
+
nativeDataArrayAppend(descriptors2, key, descriptor);
|
|
46870
|
+
}
|
|
46871
|
+
}
|
|
46574
46872
|
}
|
|
46575
|
-
if (
|
|
46576
|
-
const key = descriptors2[index];
|
|
46577
|
-
const descriptor = descriptors2[index + 1];
|
|
46873
|
+
if (firstDescriptor !== void 0) {
|
|
46578
46874
|
usage += 1;
|
|
46579
|
-
visit(
|
|
46580
|
-
if ("value" in
|
|
46581
|
-
else for (const closure of retainedAccessorClosures(
|
|
46875
|
+
visit(firstSymbol, depth + 1);
|
|
46876
|
+
if ("value" in firstDescriptor) visit(firstDescriptor.value, depth + 1);
|
|
46877
|
+
else for (const closure of retainedAccessorClosures(firstDescriptor)) visit(closure, depth + 1);
|
|
46582
46878
|
}
|
|
46879
|
+
if (descriptors2 !== void 0)
|
|
46880
|
+
for (let index = 0; index < descriptors2.length; index += 2) {
|
|
46881
|
+
const key = descriptors2[index];
|
|
46882
|
+
const descriptor = descriptors2[index + 1];
|
|
46883
|
+
usage += 1;
|
|
46884
|
+
visit(key, depth + 1);
|
|
46885
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
46886
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
46887
|
+
}
|
|
46583
46888
|
}
|
|
46584
46889
|
if (knownClosure || isSandboxClosure(value)) {
|
|
46585
46890
|
const closure = value;
|
|
@@ -46600,7 +46905,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46600
46905
|
if (collect !== void 0) {
|
|
46601
46906
|
let roots2;
|
|
46602
46907
|
try {
|
|
46603
|
-
collect(
|
|
46908
|
+
collect(collector.append);
|
|
46604
46909
|
roots2 = captures;
|
|
46605
46910
|
} finally {
|
|
46606
46911
|
if (roots2 === void 0 && captures !== void 0) releaseCaptures(captures);
|
|
@@ -46614,7 +46919,11 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46614
46919
|
depth++;
|
|
46615
46920
|
continue walk;
|
|
46616
46921
|
}
|
|
46617
|
-
} else
|
|
46922
|
+
} else {
|
|
46923
|
+
const roots2 = closure[sandboxRetainedValues]?.();
|
|
46924
|
+
if (roots2 !== void 0 && roots2 !== null)
|
|
46925
|
+
for (const root of roots2) visit(root, depth + 1);
|
|
46926
|
+
}
|
|
46618
46927
|
}
|
|
46619
46928
|
break entry;
|
|
46620
46929
|
}
|
|
@@ -46672,44 +46981,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46672
46981
|
visit(helperState.callback, depth + 1);
|
|
46673
46982
|
}
|
|
46674
46983
|
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
|
-
}
|
|
46984
|
+
visitTemporalIntl(value, depth);
|
|
46713
46985
|
if (isGuestHostObject(value)) {
|
|
46714
46986
|
usage += measureHostObjectData(value);
|
|
46715
46987
|
const root = hostObjectGuestRoot(value);
|
|
@@ -46744,6 +47016,15 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46744
47016
|
}
|
|
46745
47017
|
if (arrayLength !== void 0) {
|
|
46746
47018
|
usage += arrayLength;
|
|
47019
|
+
if (arrayData !== void 0) {
|
|
47020
|
+
usage += arrayData.units;
|
|
47021
|
+
const references = arrayData.references;
|
|
47022
|
+
if (references.length === 0) break entry;
|
|
47023
|
+
if (references.length > 1) appendContinuation(references, depth + 1);
|
|
47024
|
+
value = references[0];
|
|
47025
|
+
depth++;
|
|
47026
|
+
continue walk;
|
|
47027
|
+
}
|
|
46747
47028
|
let retained = arrayElements;
|
|
46748
47029
|
if (arrayDescriptors !== void 0) {
|
|
46749
47030
|
for (let index = 0; index < arrayDescriptors.length; index++) {
|
|
@@ -46956,7 +47237,7 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46956
47237
|
try {
|
|
46957
47238
|
for (let index = 0; index < (trackedDescriptors?.length ?? keys.length); index++) {
|
|
46958
47239
|
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];
|
|
47240
|
+
const descriptor = trackedDescriptors === void 0 || metadata !== void 0 && trackedPropertyDataDescriptors(value) !== trackedDescriptors ? proxyDescriptors === void 0 ? Object.getOwnPropertyDescriptor(value, key) : proxyDescriptors[index] : trackedDescriptors[index][1];
|
|
46960
47241
|
if (descriptor === void 0) continue;
|
|
46961
47242
|
if (!descriptor.enumerable && !includeNonEnumerable) continue;
|
|
46962
47243
|
const initial = metadata?.get(key);
|
|
@@ -46985,6 +47266,18 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46985
47266
|
while (pendingCount > floor) {
|
|
46986
47267
|
const frame = pending[pendingCount - 1];
|
|
46987
47268
|
const references = frame.values;
|
|
47269
|
+
if (references === void 0) {
|
|
47270
|
+
const proxy = frame.proxy;
|
|
47271
|
+
const handlerDepth = frame.depth;
|
|
47272
|
+
frame.proxy = void 0;
|
|
47273
|
+
pendingCount--;
|
|
47274
|
+
if (proxy.handler !== null) {
|
|
47275
|
+
value = proxy.handler;
|
|
47276
|
+
depth = handlerDepth;
|
|
47277
|
+
continue walk;
|
|
47278
|
+
}
|
|
47279
|
+
continue;
|
|
47280
|
+
}
|
|
46988
47281
|
if (frame.index < (frame.capture?.length ?? references.length)) {
|
|
46989
47282
|
value = references[frame.index++];
|
|
46990
47283
|
depth = frame.depth;
|
|
@@ -46998,29 +47291,79 @@ function measureSandboxDataWithSeen(values, options, seen) {
|
|
|
46998
47291
|
return;
|
|
46999
47292
|
}
|
|
47000
47293
|
};
|
|
47294
|
+
if (retainCode) {
|
|
47295
|
+
retainedMeasurementCode = visit;
|
|
47296
|
+
collector.close();
|
|
47297
|
+
return 0;
|
|
47298
|
+
}
|
|
47001
47299
|
try {
|
|
47002
47300
|
for (const value of values) visit(value);
|
|
47003
|
-
|
|
47004
|
-
|
|
47005
|
-
|
|
47006
|
-
|
|
47007
|
-
|
|
47008
|
-
|
|
47009
|
-
|
|
47010
|
-
|
|
47011
|
-
|
|
47012
|
-
|
|
47301
|
+
let readyIndex = 0;
|
|
47302
|
+
let primitiveIndex = 0;
|
|
47303
|
+
let materialized;
|
|
47304
|
+
do {
|
|
47305
|
+
materialized = false;
|
|
47306
|
+
for (; readyIndex < (ready?.length ?? 0); readyIndex++) {
|
|
47307
|
+
const contribution = ready[readyIndex];
|
|
47308
|
+
usage += 1;
|
|
47309
|
+
visit(contribution.value, contribution.depth);
|
|
47310
|
+
}
|
|
47311
|
+
for (let index = 0; index < (pendingArguments?.length ?? 0); index++) {
|
|
47312
|
+
const projection = pendingArguments[index];
|
|
47313
|
+
if (projection.units === void 0) continue;
|
|
47314
|
+
const current = projection.state.read();
|
|
47315
|
+
if (current === void 0) continue;
|
|
47316
|
+
usage -= projection.units;
|
|
47317
|
+
projection.units = void 0;
|
|
47318
|
+
if (!seen.has(current)) {
|
|
47319
|
+
visit(current, projection.depth);
|
|
47320
|
+
materialized = true;
|
|
47321
|
+
}
|
|
47322
|
+
}
|
|
47323
|
+
for (let index = 0; index < (pendingFunctions?.length ?? 0); index++) {
|
|
47324
|
+
const state = pendingFunctions[index];
|
|
47325
|
+
if (state === void 0) continue;
|
|
47326
|
+
const current = state.read();
|
|
47327
|
+
if (current === void 0) continue;
|
|
47328
|
+
pendingFunctions[index] = void 0;
|
|
47329
|
+
materialized = true;
|
|
47330
|
+
if (!seen.has(current)) visit(current, pendingFunctionDepths[index]);
|
|
47331
|
+
}
|
|
47332
|
+
const previousPrimitiveIndex = primitiveIndex;
|
|
47333
|
+
for (; primitiveIndex < projectedPrimitives.length; primitiveIndex++) {
|
|
47334
|
+
const projection = projectedPrimitives[primitiveIndex];
|
|
47335
|
+
if (seen.has(projection.target)) continue;
|
|
47336
|
+
for (const item of projection.values)
|
|
47337
|
+
if ((typeof item !== "object" || item === null) && typeof item !== "symbol") visit(item, projection.depth);
|
|
47338
|
+
}
|
|
47339
|
+
if ((pendingArguments !== void 0 || pendingFunctions !== void 0) && primitiveIndex !== previousPrimitiveIndex)
|
|
47340
|
+
materialized = true;
|
|
47341
|
+
} while ((pendingArguments !== void 0 || pendingFunctions !== void 0) && (materialized || readyIndex < (ready?.length ?? 0)));
|
|
47013
47342
|
return usage;
|
|
47014
47343
|
} finally {
|
|
47344
|
+
collector.close();
|
|
47015
47345
|
firstSeenCapture = void 0;
|
|
47016
47346
|
secondSeenCapture = void 0;
|
|
47017
47347
|
thirdSeenCapture = void 0;
|
|
47018
47348
|
fourthSeenCapture = void 0;
|
|
47349
|
+
fifthSeenCapture = void 0;
|
|
47350
|
+
sixthSeenCapture = void 0;
|
|
47351
|
+
seventhSeenCapture = void 0;
|
|
47352
|
+
eighthSeenCapture = void 0;
|
|
47353
|
+
ninthSeenCapture = void 0;
|
|
47354
|
+
tenthSeenCapture = void 0;
|
|
47355
|
+
eleventhSeenCapture = void 0;
|
|
47356
|
+
twelfthSeenCapture = void 0;
|
|
47357
|
+
thirteenthSeenCapture = void 0;
|
|
47358
|
+
fourteenthSeenCapture = void 0;
|
|
47359
|
+
fifteenthSeenCapture = void 0;
|
|
47360
|
+
sixteenthSeenCapture = void 0;
|
|
47019
47361
|
while (pendingCount > 0) {
|
|
47020
47362
|
const frame = pending[--pendingCount];
|
|
47021
47363
|
if (frame.capture !== void 0) releaseCaptures(frame.capture);
|
|
47022
47364
|
frame.capture = void 0;
|
|
47023
47365
|
frame.values = void 0;
|
|
47366
|
+
frame.proxy = void 0;
|
|
47024
47367
|
}
|
|
47025
47368
|
}
|
|
47026
47369
|
}
|
|
@@ -47053,15 +47396,6 @@ function reconcileCompiledValues(budget, values, compilation, parent, escaping =
|
|
|
47053
47396
|
for (const ticket of retained) compilation?.tickets.delete(ticket);
|
|
47054
47397
|
if (compilation !== void 0 && parent !== void 0) compilation.forward(included, parent);
|
|
47055
47398
|
}
|
|
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
47399
|
function captureRegexData(value) {
|
|
47066
47400
|
const source = Object.getOwnPropertyDescriptor(value, "source");
|
|
47067
47401
|
const flags = Object.getOwnPropertyDescriptor(value, "flags");
|
|
@@ -48154,6 +48488,7 @@ var nativePropertyHasOwn = Object.hasOwn;
|
|
|
48154
48488
|
var nativePropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
48155
48489
|
var nativePropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
48156
48490
|
var nativePropertyPrototype = Object.getPrototypeOf;
|
|
48491
|
+
var nativePropertySetPrototype = Object.setPrototypeOf;
|
|
48157
48492
|
var nativePropertyFreeze = Object.freeze;
|
|
48158
48493
|
var nativePropertyWrite = Reflect.defineProperty;
|
|
48159
48494
|
var nativePropertyDelete = Reflect.deleteProperty;
|
|
@@ -48219,18 +48554,43 @@ function trackedPropertySymbols(value) {
|
|
|
48219
48554
|
}
|
|
48220
48555
|
function adjustScalarProperty(state, key, descriptor, direction) {
|
|
48221
48556
|
if (descriptor === void 0) return;
|
|
48557
|
+
if (state.array) {
|
|
48558
|
+
const index = +key;
|
|
48559
|
+
if (index < 0 || index >= 4294967295 || index % 1 !== 0 || `${index}` !== key) return;
|
|
48560
|
+
}
|
|
48222
48561
|
const hasValue = nativePropertyHasOwn(descriptor, "value");
|
|
48223
48562
|
const item = hasValue ? descriptor.value : void 0;
|
|
48224
48563
|
const scalar = hasValue && typeof item !== "bigint" && typeof item !== "symbol" && (typeof item !== "object" || item === null);
|
|
48225
48564
|
if (!scalar) state.nonScalarProperties += direction;
|
|
48226
|
-
const units = 1 + key.length + (typeof item === "string" ? item.length : 0);
|
|
48565
|
+
const units = (state.array ? 0 : 1 + key.length) + (typeof item === "string" ? item.length : 0);
|
|
48227
48566
|
state.allScalarUnits += direction * units;
|
|
48228
48567
|
if (descriptor.enumerable) state.enumerableScalarUnits += direction * units;
|
|
48229
48568
|
}
|
|
48230
48569
|
var emptyPropertyReferences = nativePropertyFreeze([]);
|
|
48570
|
+
function trackedArrayElementData(value) {
|
|
48571
|
+
const state = nativePropertyDataGet(value);
|
|
48572
|
+
if (state === void 0 || !state.array) return void 0;
|
|
48573
|
+
if (state.elements !== void 0) return state.elements;
|
|
48574
|
+
if (state.nonScalarProperties === 0)
|
|
48575
|
+
return state.elements = nativePropertyFreeze({ units: state.allScalarUnits, references: emptyPropertyReferences });
|
|
48576
|
+
const descriptors2 = trackedPropertyDataDescriptors(value);
|
|
48577
|
+
let units = 0;
|
|
48578
|
+
const references = [];
|
|
48579
|
+
for (let index = 0; index < descriptors2.length; index++) {
|
|
48580
|
+
const entry = descriptors2[index];
|
|
48581
|
+
if (entry[0] === "length") break;
|
|
48582
|
+
const descriptor = entry[1];
|
|
48583
|
+
if (!nativePropertyHasOwn(descriptor, "value")) return void 0;
|
|
48584
|
+
const item = descriptor.value;
|
|
48585
|
+
if (typeof item === "string") units += item.length;
|
|
48586
|
+
else if (typeof item === "bigint" || typeof item === "symbol" || typeof item === "object" && item !== null)
|
|
48587
|
+
nativePropertyWrite(references, references.length, { value: item, writable: true, enumerable: true, configurable: true });
|
|
48588
|
+
}
|
|
48589
|
+
return state.elements = nativePropertyFreeze({ units, references: nativePropertyFreeze(references) });
|
|
48590
|
+
}
|
|
48231
48591
|
function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
48232
48592
|
const state = nativePropertyDataGet(value);
|
|
48233
|
-
if (state === void 0 || state.
|
|
48593
|
+
if (state === void 0 || state.array) return void 0;
|
|
48234
48594
|
if (state.strings === void 0 && state.nonScalarProperties === 0) {
|
|
48235
48595
|
state.strings = nativePropertyFreeze({
|
|
48236
48596
|
all: nativePropertyFreeze({ units: state.allScalarUnits, references: emptyPropertyReferences }),
|
|
@@ -48245,8 +48605,16 @@ function trackedPropertyStringData(value, includeNonEnumerable) {
|
|
|
48245
48605
|
const entry = descriptors2[index];
|
|
48246
48606
|
const key = entry[0], descriptor = entry[1];
|
|
48247
48607
|
if (!nativePropertyHasOwn(descriptor, "value")) {
|
|
48248
|
-
|
|
48249
|
-
|
|
48608
|
+
const units2 = 1 + key.length;
|
|
48609
|
+
allUnits += units2;
|
|
48610
|
+
if (descriptor.enumerable) enumerableUnits += units2;
|
|
48611
|
+
const closures2 = retainedAccessorClosures(descriptor);
|
|
48612
|
+
for (let cursor = 0; cursor < closures2.length; cursor++) {
|
|
48613
|
+
const item2 = closures2[cursor];
|
|
48614
|
+
nativePropertyWrite(allReferences, allReferences.length, { value: item2, writable: true, enumerable: true, configurable: true });
|
|
48615
|
+
if (descriptor.enumerable) nativePropertyWrite(enumerableReferences, enumerableReferences.length, { value: item2, writable: true, enumerable: true, configurable: true });
|
|
48616
|
+
}
|
|
48617
|
+
continue;
|
|
48250
48618
|
}
|
|
48251
48619
|
const item = descriptor.value;
|
|
48252
48620
|
const units = 1 + key.length + (typeof item === "string" ? item.length : 0);
|
|
@@ -48293,7 +48661,7 @@ function materializeFunctionProperties(closure, initialProperties) {
|
|
|
48293
48661
|
name: { value: closure.name ?? "", configurable: true }
|
|
48294
48662
|
});
|
|
48295
48663
|
if (isGuestClosure(closure) && closure.construct !== void 0 && closure.boundTarget === void 0) {
|
|
48296
|
-
const prototype =
|
|
48664
|
+
const prototype = createIntrinsicObject();
|
|
48297
48665
|
nativePropertyDefineOne(prototype, "constructor", {
|
|
48298
48666
|
value: closure,
|
|
48299
48667
|
writable: true,
|
|
@@ -48313,37 +48681,63 @@ function createIntrinsicObject(initial = /* @__PURE__ */ Object.create(null)) {
|
|
|
48313
48681
|
nativeIntrinsicObjectAdd(tracked);
|
|
48314
48682
|
return tracked;
|
|
48315
48683
|
}
|
|
48684
|
+
function createIntrinsicArray(initial) {
|
|
48685
|
+
const properties = [];
|
|
48686
|
+
if (initial !== void 0) {
|
|
48687
|
+
nativePropertySetPrototype(properties, nativePropertyPrototype(initial));
|
|
48688
|
+
nativePropertyDefine(properties, nativePropertyDescriptors(initial));
|
|
48689
|
+
}
|
|
48690
|
+
const tracked = trackPropertyTable(properties, true);
|
|
48691
|
+
nativeIntrinsicObjectAdd(tracked);
|
|
48692
|
+
return tracked;
|
|
48693
|
+
}
|
|
48316
48694
|
function isTrackedIntrinsicObject(value) {
|
|
48317
48695
|
return nativeIntrinsicObjectHas(value);
|
|
48318
48696
|
}
|
|
48319
|
-
function trackPropertyTable(properties) {
|
|
48697
|
+
function trackPropertyTable(properties, array2 = false) {
|
|
48320
48698
|
const state = { revision: 0 };
|
|
48321
48699
|
const data = {
|
|
48322
48700
|
backing: properties,
|
|
48701
|
+
array: array2,
|
|
48323
48702
|
allScalarUnits: 0,
|
|
48324
48703
|
enumerableScalarUnits: 0,
|
|
48325
48704
|
nonScalarProperties: 0,
|
|
48326
48705
|
symbols: void 0,
|
|
48327
48706
|
descriptors: void 0,
|
|
48328
|
-
strings: void 0
|
|
48707
|
+
strings: void 0,
|
|
48708
|
+
elements: void 0
|
|
48329
48709
|
};
|
|
48330
48710
|
const keys = nativePropertyNames(properties);
|
|
48331
48711
|
for (let index = 0; index < keys.length; index++) {
|
|
48332
48712
|
const key = keys[index];
|
|
48333
48713
|
adjustScalarProperty(data, key, nativePropertyDescriptor(properties, key), 1);
|
|
48334
48714
|
}
|
|
48335
|
-
const tracked = new NativePropertyProxy(properties, {
|
|
48715
|
+
const tracked = new NativePropertyProxy(properties, nativePropertySetPrototype({
|
|
48336
48716
|
defineProperty(target, key, descriptor) {
|
|
48717
|
+
const ownDescriptor = { __proto__: null, ...descriptor };
|
|
48337
48718
|
const previous = typeof key === "string" ? nativePropertyDescriptor(target, key) : void 0;
|
|
48338
|
-
const
|
|
48339
|
-
|
|
48719
|
+
const previousLength = array2 && key === "length" ? target.length : void 0;
|
|
48720
|
+
const changed = nativePropertyWrite(target, key, ownDescriptor);
|
|
48721
|
+
if (changed || array2) {
|
|
48340
48722
|
if (typeof key === "string") {
|
|
48341
|
-
|
|
48342
|
-
|
|
48723
|
+
if (previousLength !== void 0 && target.length < previousLength) {
|
|
48724
|
+
data.allScalarUnits = 0;
|
|
48725
|
+
data.enumerableScalarUnits = 0;
|
|
48726
|
+
data.nonScalarProperties = 0;
|
|
48727
|
+
const keys2 = nativePropertyNames(target);
|
|
48728
|
+
for (let index = 0; index < keys2.length; index++) {
|
|
48729
|
+
const name = keys2[index];
|
|
48730
|
+
adjustScalarProperty(data, name, nativePropertyDescriptor(target, name), 1);
|
|
48731
|
+
}
|
|
48732
|
+
} else {
|
|
48733
|
+
adjustScalarProperty(data, key, previous, -1);
|
|
48734
|
+
adjustScalarProperty(data, key, nativePropertyDescriptor(target, key), 1);
|
|
48735
|
+
}
|
|
48343
48736
|
} else data.symbols = void 0;
|
|
48344
48737
|
state.revision++;
|
|
48345
48738
|
data.descriptors = void 0;
|
|
48346
48739
|
data.strings = void 0;
|
|
48740
|
+
data.elements = void 0;
|
|
48347
48741
|
state.measuredDescriptors = void 0;
|
|
48348
48742
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48349
48743
|
}
|
|
@@ -48360,12 +48754,13 @@ function trackPropertyTable(properties) {
|
|
|
48360
48754
|
state.revision++;
|
|
48361
48755
|
data.descriptors = void 0;
|
|
48362
48756
|
data.strings = void 0;
|
|
48757
|
+
data.elements = void 0;
|
|
48363
48758
|
state.measuredDescriptors = void 0;
|
|
48364
48759
|
if (intrinsicRetentionTables.has(tracked)) intrinsicMutationToken = {};
|
|
48365
48760
|
}
|
|
48366
48761
|
return changed;
|
|
48367
48762
|
}
|
|
48368
|
-
});
|
|
48763
|
+
}, null));
|
|
48369
48764
|
nativePropertyStateSet(tracked, state);
|
|
48370
48765
|
nativePropertyDataSet(tracked, data);
|
|
48371
48766
|
return tracked;
|
|
@@ -48943,4 +49338,4 @@ authorization of the copyright holder.
|
|
|
48943
49338
|
SPDX-License-Identifier: Unicode-3.0
|
|
48944
49339
|
|
|
48945
49340
|
*/
|
|
48946
|
-
//# sourceMappingURL=chunk-
|
|
49341
|
+
//# sourceMappingURL=chunk-QU2F65UQ.js.map
|