@poe-platform/safe-js 0.1.798 → 0.1.800

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.
Files changed (44) hide show
  1. package/README.md +3 -1
  2. package/dist/safe-js/chunks/{chunk-ULPZIHB5.js → chunk-5RLD4TVI.js} +174 -127
  3. package/dist/safe-js/chunks/{chunk-TBZILU4U.js → chunk-7THYP46K.js} +1 -1
  4. package/dist/safe-js/chunks/{chunk-UU4T2KIT.js → chunk-CK3YK2EC.js} +1 -1
  5. package/dist/safe-js/chunks/{chunk-3O7HA6WT.js → chunk-F6Y734YA.js} +2 -2
  6. package/dist/safe-js/chunks/{chunk-OPYN6N5M.js → chunk-HPHCQNFV.js} +154 -1
  7. package/dist/safe-js/chunks/{chunk-W6C3Q6U4.js → chunk-LWHXSNF6.js} +2 -2
  8. package/dist/safe-js/chunks/{chunk-ZKLJW27N.js → chunk-PMOXSLM5.js} +1 -1
  9. package/dist/safe-js/chunks/{chunk-M6S3F3WM.js → chunk-QEDOBN2G.js} +4 -4
  10. package/dist/safe-js/chunks/chunk-QRWRR6IA.js +78 -0
  11. package/dist/safe-js/chunks/{chunk-MCFRB5X3.js → chunk-SHMRT4QX.js} +76 -6
  12. package/dist/safe-js/chunks/{chunk-KULEMOAE.js → chunk-XAV2RKLO.js} +3 -154
  13. package/dist/safe-js/chunks/{chunk-MDJ7MJYI.js → chunk-XOMGWE37.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-QTCPJ7FN.js → chunk-XV5OYKND.js} +1 -1
  15. package/dist/safe-js/chunks/{chunk-OTVZWRYE.js → chunk-YAHDXC7P.js} +1 -1
  16. package/dist/safe-js/chunks/{cli-runtime-DYXJZCGV.js → cli-runtime-OCWFX4TM.js} +15 -15
  17. package/dist/safe-js/chunks/{dump-XDJEF2LG.js → dump-KUPBSXSL.js} +2 -2
  18. package/dist/safe-js/chunks/{harness-32OOFC5A.js → harness-3DDUS3RY.js} +2 -2
  19. package/dist/safe-js/chunks/{mcp-PTCA53MN.js → mcp-4D3WWY7U.js} +3 -3
  20. package/dist/safe-js/chunks/{migration-file-EEGIOHQB.js → migration-file-4CYSJ6LO.js} +3 -3
  21. package/dist/safe-js/chunks/{restore-U3CCH36B.js → restore-GDHBT5ZD.js} +3 -3
  22. package/dist/safe-js/chunks/{run-Q74MU3QQ.js → run-3X6J7FPV.js} +5 -5
  23. package/dist/safe-js/chunks/{runtime-modules-SL5D6LAJ.js → runtime-modules-MGSXY4BN.js} +2 -2
  24. package/dist/safe-js/cli.js +2 -2
  25. package/dist/safe-js/core.d.ts +6 -0
  26. package/dist/safe-js/core.js +33 -7
  27. package/dist/safe-js/index.js +24 -93
  28. package/dist/safe-js/interp/data-copy.d.ts +3 -2
  29. package/dist/safe-js/interp/host-bridge.d.ts +5 -4
  30. package/dist/safe-js/modules/fs.js +2 -2
  31. package/dist/safe-js/node-unavailable.d.ts +1 -0
  32. package/dist/safe-js/portable/chunks/chunk-H5X3T5VP.js +909 -0
  33. package/dist/safe-js/portable/chunks/chunk-KYJVK33V.js +58698 -0
  34. package/dist/safe-js/portable/chunks/chunk-XCTU25SU.js +111 -0
  35. package/dist/safe-js/portable/chunks/source-files-CVU252FB.js +7 -0
  36. package/dist/safe-js/portable/core.js +14757 -0
  37. package/dist/safe-js/portable/modules/fs.js +9 -0
  38. package/dist/safe-js/snapshot/arguments.d.ts +2 -0
  39. package/dist/safe-js/snapshot/property-descriptors.d.ts +2 -0
  40. package/dist/safe-js/snapshot/regexp-properties.d.ts +2 -0
  41. package/dist/safe-js/snapshot/symbols.d.ts +2 -0
  42. package/dist/safe-js/workerd.d.ts +3 -0
  43. package/dist/safe-js/workerd.js +74425 -0
  44. package/package.json +30 -6
@@ -222,8 +222,20 @@ var prototype = Object.getPrototypeOf((function* () {
222
222
  })());
223
223
  var next = prototype.next;
224
224
  var raise = prototype.throw;
225
+ var finish = prototype.return;
225
226
  var apply = Reflect.apply;
226
227
  var setPrototypeOf = Object.setPrototypeOf;
228
+ function dataCopyIterable(operation) {
229
+ return {
230
+ [Symbol.iterator]() {
231
+ return {
232
+ next: (value) => apply(next, operation, [value]),
233
+ throw: (error) => apply(raise, operation, [error]),
234
+ return: (value) => apply(finish, operation, [value])
235
+ };
236
+ }
237
+ };
238
+ }
227
239
  function runDataCopy(operation) {
228
240
  const parents = setPrototypeOf([], null);
229
241
  let depth = 0;
@@ -1430,11 +1442,6 @@ function getCollectionProperties(value) {
1430
1442
  if (properties === void 0) throw new TypeError("Invalid sandbox collection storage.");
1431
1443
  return properties;
1432
1444
  }
1433
- function copyCollectionProperties(source, target, encode) {
1434
- runDataCopy(copyCollectionPropertiesOperation(source, target, function* (value, key) {
1435
- return encode(value, key);
1436
- }));
1437
- }
1438
1445
  function* copyCollectionPropertiesOperation(source, target, encode) {
1439
1446
  const properties = collectionGuestProperties.get(source) ?? source;
1440
1447
  for (const key of Reflect.ownKeys(properties)) {
@@ -2060,11 +2067,18 @@ function ownSerializableSymbolKeys(value) {
2060
2067
  return Object.getOwnPropertySymbols(value).filter((key) => !internalSymbols.has(key));
2061
2068
  }
2062
2069
  function serializeSymbolProperties(value, encode) {
2063
- return ownSerializableSymbolKeys(value).map((key) => {
2070
+ return runDataCopy(serializeSymbolPropertiesOperation(value, function* (entry) {
2071
+ return encode(entry);
2072
+ }));
2073
+ }
2074
+ function* serializeSymbolPropertiesOperation(value, encode) {
2075
+ const properties = [];
2076
+ for (const key of ownSerializableSymbolKeys(value)) {
2064
2077
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
2065
2078
  if (!("value" in descriptor)) throw new TypeError("Symbol accessor properties cannot be serialized.");
2066
- return [encode(key), { value: encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }];
2067
- });
2079
+ properties.push([yield encode(key), { value: yield encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }]);
2080
+ }
2081
+ return properties;
2068
2082
  }
2069
2083
  function restoreSymbolProperties(target, entries, decode) {
2070
2084
  for (const [key, descriptor] of entries ?? []) {
@@ -2080,6 +2094,11 @@ function hasCustomRegexProperties(value) {
2080
2094
  return Reflect.ownKeys(properties).length !== 1 || !Object.isExtensible(properties) || Object.getOwnPropertyDescriptor(properties, "lastIndex")?.writable !== true;
2081
2095
  }
2082
2096
  function serializeRegexProperties(value, encode) {
2097
+ return runDataCopy(serializeRegexPropertiesOperation(value, function* (entry) {
2098
+ return encode(entry);
2099
+ }));
2100
+ }
2101
+ function* serializeRegexPropertiesOperation(value, encode) {
2083
2102
  if (!hasCustomRegexProperties(value)) return {};
2084
2103
  const source = getRegexProperties(value);
2085
2104
  const properties = /* @__PURE__ */ Object.create(null);
@@ -2087,13 +2106,13 @@ function serializeRegexProperties(value, encode) {
2087
2106
  const descriptor = Object.getOwnPropertyDescriptor(source, key);
2088
2107
  if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be serialized as data.");
2089
2108
  properties[key] = {
2090
- value: encode(descriptor.value),
2109
+ value: yield encode(descriptor.value),
2091
2110
  enumerable: descriptor.enumerable === true,
2092
2111
  configurable: descriptor.configurable === true,
2093
2112
  writable: descriptor.writable === true
2094
2113
  };
2095
2114
  }
2096
- const symbolEntries = serializeSymbolProperties(source, encode);
2115
+ const symbolEntries = yield* dataCopyIterable(serializeSymbolPropertiesOperation(source, encode));
2097
2116
  return {
2098
2117
  properties,
2099
2118
  ...symbolEntries.length === 0 ? {} : { symbolEntries },
@@ -5288,7 +5307,7 @@ function createPromiseGlobals(options) {
5288
5307
  if (typeof constructor !== "object" || constructor === null) {
5289
5308
  throw new TypeError("Promise.resolve requires an object receiver.");
5290
5309
  }
5291
- const finish = (actualConstructor2) => {
5310
+ const finish2 = (actualConstructor2) => {
5292
5311
  if (isSandboxPromise(value) && actualConstructor2 === constructor) return value;
5293
5312
  if (constructor === promiseConstructor) {
5294
5313
  const capability = createPendingPromiseCapability(options.budget, context);
@@ -5297,10 +5316,10 @@ function createPromiseGlobals(options) {
5297
5316
  }
5298
5317
  return settleConstructedPromise(constructor, value, "fulfilled", options.budget, context);
5299
5318
  };
5300
- if (!isSandboxPromise(value)) return finish(void 0);
5319
+ if (!isSandboxPromise(value)) return finish2(void 0);
5301
5320
  const descriptor = getSandboxPropertyDescriptor(value, "constructor", options.budget);
5302
5321
  const actualConstructor = descriptor === void 0 ? hasExplicitSandboxPrototype(value) ? void 0 : getPromiseMember("constructor", options.budget) : readPropertyDescriptor(descriptor, value, context, true);
5303
- return actualConstructor instanceof Promise ? actualConstructor.then(finish) : finish(actualConstructor);
5322
+ return actualConstructor instanceof Promise ? actualConstructor.then(finish2) : finish2(actualConstructor);
5304
5323
  },
5305
5324
  guest: true,
5306
5325
  name: "resolve",
@@ -5493,7 +5512,7 @@ function getPromisePrototype(budget) {
5493
5512
  const target = context?.thisValue;
5494
5513
  if (!isSandboxPromise(target))
5495
5514
  throw new TypeError("Promise.then requires a promise receiver.");
5496
- const finish = (constructor2) => attribution(() => {
5515
+ const finish2 = (constructor2) => attribution(() => {
5497
5516
  if (constructor2 !== intrinsicPromiseConstructors.get(budget)) {
5498
5517
  return createPromiseCapability(constructor2, budget, context).then((capability) => attribution(() => {
5499
5518
  observeSandboxPromise(target, isSandboxPromise(capability.promise));
@@ -5548,7 +5567,7 @@ function getPromisePrototype(budget) {
5548
5567
  return chained;
5549
5568
  });
5550
5569
  const constructor = getPromiseSpeciesConstructor(target, prototype2, budget, context);
5551
- return constructor instanceof Promise ? constructor.then(finish) : finish(constructor);
5570
+ return constructor instanceof Promise ? constructor.then(finish2) : finish2(constructor);
5552
5571
  },
5553
5572
  guest: true,
5554
5573
  name: "then",
@@ -5641,13 +5660,13 @@ function getPromisePrototype(budget) {
5641
5660
  newTarget: void 0
5642
5661
  });
5643
5662
  };
5644
- const finish = (constructor2) => {
5663
+ const finish2 = (constructor2) => {
5645
5664
  const descriptor = getSandboxPropertyDescriptor(target, "then", budget);
5646
5665
  const then = descriptor === void 0 ? readPromiseReceiverProperty(target, "then", prototype2, context) : readPropertyDescriptor(descriptor, target, context, true);
5647
5666
  return then instanceof Promise ? then.then((method) => invoke(method, constructor2)) : invoke(then, constructor2);
5648
5667
  };
5649
5668
  const constructor = getPromiseSpeciesConstructor(target, prototype2, budget, context);
5650
- return constructor instanceof Promise ? constructor.then(finish) : finish(constructor);
5669
+ return constructor instanceof Promise ? constructor.then(finish2) : finish2(constructor);
5651
5670
  },
5652
5671
  guest: true,
5653
5672
  name: "finally",
@@ -5675,14 +5694,14 @@ function getPromiseSpeciesConstructor(receiver, prototype2, budget, context) {
5675
5694
  if (constructor2 === void 0) return defaultConstructor;
5676
5695
  if (typeof constructor2 !== "object" || constructor2 === null)
5677
5696
  throw new TypeError("Promise constructor property must be an object.");
5678
- const finish = (species2) => {
5697
+ const finish2 = (species2) => {
5679
5698
  if (species2 === void 0 || species2 === null) return defaultConstructor;
5680
5699
  if (!isSandboxClosure(species2) || species2.construct === void 0)
5681
5700
  throw new TypeError("Promise species must be a constructor.");
5682
5701
  return species2;
5683
5702
  };
5684
5703
  const species = readPromiseProperty(constructor2, Symbol.species, prototype2, budget, context);
5685
- return species instanceof Promise ? species.then(finish) : finish(species);
5704
+ return species instanceof Promise ? species.then(finish2) : finish2(species);
5686
5705
  };
5687
5706
  const constructor = readPromiseProperty(receiver, "constructor", prototype2, budget, context);
5688
5707
  return constructor instanceof Promise ? constructor.then(validate) : validate(constructor);
@@ -5843,8 +5862,8 @@ function prepareAwaitedPromise(value, budget, context) {
5843
5862
  if (!intrinsicPromiseConstructors.has(budget)) createPromiseGlobals({ budget });
5844
5863
  const constructor = intrinsicPromiseConstructors.get(budget);
5845
5864
  const actualConstructor = readPromiseProperty(value, "constructor", getPromisePrototype(budget), budget, context);
5846
- const finish = (actual) => actual === constructor ? value : createSandboxPromise(resolveSandboxValue(value, { budget, context }), { trackReplay: false });
5847
- return actualConstructor instanceof Promise ? actualConstructor.then(finish) : finish(actualConstructor);
5865
+ const finish2 = (actual) => actual === constructor ? value : createSandboxPromise(resolveSandboxValue(value, { budget, context }), { trackReplay: false });
5866
+ return actualConstructor instanceof Promise ? actualConstructor.then(finish2) : finish2(actualConstructor);
5848
5867
  }
5849
5868
  function resolveSandboxValue(value, options = {}) {
5850
5869
  try {
@@ -6408,11 +6427,11 @@ function createObjectGlobal(methods4, budget) {
6408
6427
  return construct(args);
6409
6428
  const value = construct([]);
6410
6429
  const candidate = context.getProperty(context.newTarget, "prototype");
6411
- const finish = (selected) => {
6430
+ const finish2 = (selected) => {
6412
6431
  setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : getFunctionRealmPrototype(context.newTarget, "Object", prototype2), budget);
6413
6432
  return value;
6414
6433
  };
6415
- return candidate instanceof Promise ? candidate.then(finish) : finish(candidate);
6434
+ return candidate instanceof Promise ? candidate.then(finish2) : finish2(candidate);
6416
6435
  }
6417
6436
  });
6418
6437
  const properties = materializeFunctionProperties(constructor);
@@ -6460,12 +6479,12 @@ function createObjectGlobal(methods4, budget) {
6460
6479
  }
6461
6480
  );
6462
6481
  const fallback = typeTag(object, descriptor !== void 0 || hasExplicitSandboxPrototype(object));
6463
- const finish = (tag2) => budget.allocateString(`[object ${typeof tag2 === "string" ? tag2 : fallback}]`);
6482
+ const finish2 = (tag2) => budget.allocateString(`[object ${typeof tag2 === "string" ? tag2 : fallback}]`);
6464
6483
  if (proxyBoundary !== void 0)
6465
- return Promise.resolve(sandboxGetProperty(proxyBoundary, Symbol.toStringTag, object, budget, context)).then(finish);
6466
- if (descriptor === void 0) return finish(void 0);
6484
+ return Promise.resolve(sandboxGetProperty(proxyBoundary, Symbol.toStringTag, object, budget, context)).then(finish2);
6485
+ if (descriptor === void 0) return finish2(void 0);
6467
6486
  const tag = readPropertyDescriptor(descriptor, object, context, true);
6468
- return tag instanceof Promise ? tag.then(finish) : finish(tag);
6487
+ return tag instanceof Promise ? tag.then(finish2) : finish2(tag);
6469
6488
  }
6470
6489
  }),
6471
6490
  valueOf: createSandboxClosure({
@@ -20123,7 +20142,7 @@ function callStringRegexCursor(value, methodName, regex, budget, parent, context
20123
20142
  };
20124
20143
  const readCursor = () => {
20125
20144
  cursor = regex.lastIndex;
20126
- const finish = (lastIndex2) => {
20145
+ const finish2 = (lastIndex2) => {
20127
20146
  if (matcher !== void 0) {
20128
20147
  matcher.lastIndex = normalizeLastIndex(lastIndex2);
20129
20148
  return restoreSandboxRegExpIterator({ matcher, input: value, exhausted: false }, void 0, budget);
@@ -20131,7 +20150,7 @@ function callStringRegexCursor(value, methodName, regex, budget, parent, context
20131
20150
  return callMatchLikeMethod(value, methodName, [regex], compilation, lastIndex2);
20132
20151
  };
20133
20152
  const lastIndex = sandboxNumber(cursor, budget, context);
20134
- return lastIndex instanceof Promise ? lastIndex.then(finish) : finish(lastIndex);
20153
+ return lastIndex instanceof Promise ? lastIndex.then(finish2) : finish2(lastIndex);
20135
20154
  };
20136
20155
  const clone = (text) => {
20137
20156
  flags = text;
@@ -21264,12 +21283,19 @@ function decodeSharedArrayBufferStorage(value, resolve, budget) {
21264
21283
 
21265
21284
  // packages/safe-js/src/snapshot/property-descriptors.ts
21266
21285
  function serializePropertyDescriptors(target, encode) {
21286
+ return runDataCopy(serializePropertyDescriptorsOperation(target, function* (value) {
21287
+ return encode(value);
21288
+ }));
21289
+ }
21290
+ function* serializePropertyDescriptorsOperation(target, encode) {
21291
+ const properties = [];
21292
+ for (const key of Reflect.ownKeys(target).filter((key2) => typeof key2 !== "symbol" || !internalSymbols.has(key2))) {
21293
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
21294
+ const flags = { enumerable: descriptor.enumerable === true, configurable: descriptor.configurable === true };
21295
+ properties.push([yield encode(key), "value" in descriptor ? { kind: "data", ...flags, value: yield encode(descriptor.value), writable: descriptor.writable === true } : { kind: "accessor", ...flags, get: yield encode(accessorClosure(descriptor.get)), set: yield encode(accessorClosure(descriptor.set)) }]);
21296
+ }
21267
21297
  return {
21268
- properties: Reflect.ownKeys(target).filter((key) => typeof key !== "symbol" || !internalSymbols.has(key)).map((key) => {
21269
- const descriptor = Object.getOwnPropertyDescriptor(target, key);
21270
- const flags = { enumerable: descriptor.enumerable === true, configurable: descriptor.configurable === true };
21271
- return [encode(key), "value" in descriptor ? { kind: "data", ...flags, value: encode(descriptor.value), writable: descriptor.writable === true } : { kind: "accessor", ...flags, get: encode(accessorClosure(descriptor.get)), set: encode(accessorClosure(descriptor.set)) }];
21272
- }),
21298
+ properties,
21273
21299
  extensible: Object.isExtensible(target)
21274
21300
  };
21275
21301
  }
@@ -21351,12 +21377,17 @@ function applyDescriptors(target, descriptors2, extensible) {
21351
21377
 
21352
21378
  // packages/safe-js/src/snapshot/collection-properties.ts
21353
21379
  function serializeCollectionProperties(value, encode, dataOnly = false) {
21380
+ return runDataCopy(serializeCollectionPropertiesOperation(value, function* (entry) {
21381
+ return encode(entry);
21382
+ }, dataOnly));
21383
+ }
21384
+ function* serializeCollectionPropertiesOperation(value, encode, dataOnly = false) {
21354
21385
  const properties = getCollectionProperties(value);
21355
- const prototype2 = hasExplicitSandboxPrototype(value) ? { prototype: encode(getSandboxPrototype(value)) } : {};
21386
+ const prototype2 = hasExplicitSandboxPrototype(value) ? { prototype: yield encode(getSandboxPrototype(value)) } : {};
21356
21387
  if (Reflect.ownKeys(properties).length === 0 && Object.isExtensible(properties)) return prototype2;
21357
21388
  if (dataOnly && Reflect.ownKeys(properties).some((key) => !("value" in Object.getOwnPropertyDescriptor(properties, key))))
21358
21389
  throw new TypeError("Collection accessor properties cannot be serialized as replay data.");
21359
- return { ...prototype2, propertyState: serializePropertyDescriptors(properties, encode) };
21390
+ return { ...prototype2, propertyState: yield* dataCopyIterable(serializePropertyDescriptorsOperation(properties, encode)) };
21360
21391
  }
21361
21392
 
21362
21393
  // packages/safe-js/src/interp/atomic-wait-state.ts
@@ -22557,6 +22588,11 @@ function validateBoxedProperties(data) {
22557
22588
 
22558
22589
  // packages/safe-js/src/snapshot/arguments.ts
22559
22590
  function serializeArguments(value, serializeValue) {
22591
+ return runDataCopy(serializeArgumentsOperation(value, function* (entry, key) {
22592
+ return serializeValue(entry, key);
22593
+ }));
22594
+ }
22595
+ function* serializeArgumentsOperation(value, serializeValue) {
22560
22596
  const properties = /* @__PURE__ */ Object.create(null);
22561
22597
  for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
22562
22598
  if (!("value" in descriptor)) {
@@ -22564,7 +22600,7 @@ function serializeArguments(value, serializeValue) {
22564
22600
  continue;
22565
22601
  }
22566
22602
  properties[key] = {
22567
- value: serializeValue(descriptor.value, key),
22603
+ value: yield serializeValue(descriptor.value, key),
22568
22604
  configurable: descriptor.configurable === true,
22569
22605
  enumerable: descriptor.enumerable === true,
22570
22606
  writable: descriptor.writable === true
@@ -22606,7 +22642,7 @@ function encodeReplayData(value, options = {}) {
22606
22642
  if (context.failed) throw new TypeError("Cannot extend an incomplete graph.");
22607
22643
  const { nodes: nodes2, seen, symbols, float32Buffers, sharedBlocks: sharedBlocks2 } = context;
22608
22644
  const initialNodeCount = nodes2.length;
22609
- const encode = (entry, depth, path, capabilityProperties = false) => {
22645
+ const encode = function* (entry, depth, path, capabilityProperties = false) {
22610
22646
  if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
22611
22647
  if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
22612
22648
  if (entry === void 0) return { tag: "undefined" };
@@ -22646,7 +22682,7 @@ function encodeReplayData(value, options = {}) {
22646
22682
  nodes2[index] = {
22647
22683
  kind: "promise-capability",
22648
22684
  id: id2,
22649
- properties: encode(properties, depth + 1, [...path, "properties"], true)
22685
+ properties: yield encode(properties, depth + 1, [...path, "properties"], true)
22650
22686
  };
22651
22687
  return { tag: "ref", id: index };
22652
22688
  }
@@ -22665,7 +22701,7 @@ function encodeReplayData(value, options = {}) {
22665
22701
  options.onValueEncoded?.(index, entry);
22666
22702
  const scheduleId = options.identifyScheduledPromise?.(entry);
22667
22703
  const properties = importedPromisePropertySnapshots.get(entry) ?? getPromiseProperties(entry);
22668
- const propertyData = Reflect.ownKeys(properties).length === 0 && Object.isExtensible(properties) ? {} : { properties: encode(properties, depth + 1, [...path, "properties"], true) };
22704
+ const propertyData = Reflect.ownKeys(properties).length === 0 && Object.isExtensible(properties) ? {} : { properties: yield encode(properties, depth + 1, [...path, "properties"], true) };
22669
22705
  nodes2[index] = state === void 0 ? {
22670
22706
  kind: "pending-imported-promise",
22671
22707
  ...propertyData,
@@ -22675,7 +22711,7 @@ function encodeReplayData(value, options = {}) {
22675
22711
  status: state.status,
22676
22712
  ...scheduleId === void 0 ? {} : { scheduleId },
22677
22713
  ...propertyData,
22678
- outcome: encode(state.value, depth + 1, [...path, "<settlement>"])
22714
+ outcome: yield encode(state.value, depth + 1, [...path, "<settlement>"])
22679
22715
  };
22680
22716
  return { tag: "ref", id: index };
22681
22717
  }
@@ -22703,33 +22739,35 @@ function encodeReplayData(value, options = {}) {
22703
22739
  options.onValueEncoded?.(id, entry);
22704
22740
  const child = (value2, key) => encode(value2, depth + 1, [...path, key]);
22705
22741
  if (isSandboxModuleNamespace(entry)) {
22706
- nodes2[id] = { kind: "module-namespace", entries: Object.keys(entry).map((key) => [key, child(entry[key], key)]) };
22742
+ const entries = [];
22743
+ for (const key of Object.keys(entry)) entries.push([key, yield child(entry[key], key)]);
22744
+ nodes2[id] = { kind: "module-namespace", entries };
22707
22745
  } else if (isSandboxClosure(entry)) {
22708
22746
  nodes2[id] = {
22709
22747
  kind: "capability",
22710
22748
  id: capabilityId,
22711
- properties: encode(entry.properties, depth + 1, [...path, "properties"], true)
22749
+ properties: yield encode(entry.properties, depth + 1, [...path, "properties"], true)
22712
22750
  };
22713
22751
  } else if (isRawJson(entry)) {
22714
22752
  nodes2[id] = { kind: "raw-json", text: entry.rawJSON };
22715
22753
  } else if (nativeBoxedValue(entry) !== void 0) {
22716
22754
  const properties = /* @__PURE__ */ Object.create(null);
22717
22755
  let symbolIndex = 0;
22718
- const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22719
- nodes2[id] = { kind: "boxed", value: child(nativeBoxedValue(entry), "<payload>"), properties, extensible: Object.isExtensible(entry), ...symbolEntries.length === 0 ? {} : { symbolEntries } };
22756
+ const symbolEntries = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22757
+ nodes2[id] = { kind: "boxed", value: yield child(nativeBoxedValue(entry), "<payload>"), properties, extensible: Object.isExtensible(entry), ...symbolEntries.length === 0 ? {} : { symbolEntries } };
22720
22758
  for (const [key, descriptor] of boxedDataProperties(entry)) {
22721
22759
  if (!("value" in descriptor)) throw new TypeError(`Cannot record replay data accessor '${key}'.`);
22722
- properties[key] = { value: child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22760
+ properties[key] = { value: yield child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22723
22761
  }
22724
22762
  } else if (isSandboxTemporalPlainYearMonth(entry) || isSandboxTemporalPlainMonthDay(entry) || isSandboxTemporalInstant(entry) || isSandboxTemporalDuration(entry) || isSandboxTemporalPlainTime(entry) || isSandboxTemporalPlainDateTime(entry) || isSandboxTemporalPlainDate(entry) || isSandboxTemporalZonedDateTime(entry)) {
22725
22763
  const properties = /* @__PURE__ */ Object.create(null);
22726
22764
  for (const key of Object.getOwnPropertyNames(entry)) {
22727
22765
  const descriptor = Object.getOwnPropertyDescriptor(entry, key);
22728
22766
  if (!("value" in descriptor)) throw new TypeError(`Cannot record replay data accessor '${key}'.`);
22729
- properties[key] = { value: child(descriptor.value, key), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true };
22767
+ properties[key] = { value: yield child(descriptor.value, key), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true };
22730
22768
  }
22731
22769
  let symbolIndex = 0;
22732
- const symbolProperties = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22770
+ const symbolProperties = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22733
22771
  nodes2[id] = {
22734
22772
  ...isSandboxTemporalZonedDateTime(entry) ? { kind: "temporal-zoned-date-time", slots: {
22735
22773
  ...temporalZonedDateTimeFields(entry),
@@ -22744,10 +22782,10 @@ function encodeReplayData(value, options = {}) {
22744
22782
  const properties = /* @__PURE__ */ Object.create(null);
22745
22783
  for (const [key, descriptor] of dateDataProperties(entry)) {
22746
22784
  if (typeof key === "symbol") continue;
22747
- properties[key] = { value: child(descriptor.value, key), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true };
22785
+ properties[key] = { value: yield child(descriptor.value, key), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true };
22748
22786
  }
22749
22787
  let symbolIndex = 0;
22750
- const symbolProperties = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22788
+ const symbolProperties = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22751
22789
  nodes2[id] = {
22752
22790
  kind: "date",
22753
22791
  time: serializedDateTime(entry),
@@ -22757,27 +22795,27 @@ function encodeReplayData(value, options = {}) {
22757
22795
  ...Object.isExtensible(entry) ? {} : { extensible: false }
22758
22796
  };
22759
22797
  } else if (isSandboxArrayBuffer(entry) || isSandboxSharedArrayBuffer(entry) || isSandboxDataView(entry)) {
22760
- const storage = isSandboxDataView(entry) ? { ...encodeDataViewLayout(entry), buffer: child(dataViewBuffer(entry), "<buffer>") } : isSandboxSharedArrayBuffer(entry) ? encodeSharedArrayBufferStorage(entry, id, sharedBlocks2, (id2) => ({ tag: "ref", id: id2 })) : encodeArrayBufferStorage(entry, id, float32Buffers, (id2) => ({ tag: "ref", id: id2 }));
22798
+ const storage = isSandboxDataView(entry) ? { ...encodeDataViewLayout(entry), buffer: yield child(dataViewBuffer(entry), "<buffer>") } : isSandboxSharedArrayBuffer(entry) ? encodeSharedArrayBufferStorage(entry, id, sharedBlocks2, (id2) => ({ tag: "ref", id: id2 })) : encodeArrayBufferStorage(entry, id, float32Buffers, (id2) => ({ tag: "ref", id: id2 }));
22761
22799
  const properties = /* @__PURE__ */ Object.create(null);
22762
22800
  for (const [key, descriptor] of isSandboxDataView(entry) ? dataViewDataProperties(entry) : arrayBufferDataProperties(entry)) {
22763
22801
  if (typeof key === "symbol") continue;
22764
22802
  properties[key] = {
22765
- value: child(descriptor.value, key),
22803
+ value: yield child(descriptor.value, key),
22766
22804
  configurable: descriptor.configurable === true,
22767
22805
  enumerable: descriptor.enumerable === true,
22768
22806
  writable: descriptor.writable === true
22769
22807
  };
22770
22808
  }
22771
22809
  let symbolIndex = 0;
22772
- const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22810
+ const symbolEntries = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22773
22811
  nodes2[id] = { ...storage, properties, extensible: Object.isExtensible(entry), symbolEntries };
22774
22812
  } else if (isNumericTypedArray(entry)) {
22775
22813
  const backing = typedArrayStorage(entry);
22776
- const storage = { ...encodeTypedArrayLayout(entry), buffer: child(backing.buffer, "<buffer>") };
22814
+ const storage = { ...encodeTypedArrayLayout(entry), buffer: yield child(backing.buffer, "<buffer>") };
22777
22815
  const properties = /* @__PURE__ */ Object.create(null);
22778
22816
  for (const [key, descriptor] of typedArrayDataProperties(entry)) {
22779
22817
  properties[key] = {
22780
- value: child(descriptor.value, key),
22818
+ value: yield child(descriptor.value, key),
22781
22819
  configurable: descriptor.configurable === true,
22782
22820
  enumerable: descriptor.enumerable === true,
22783
22821
  writable: descriptor.writable === true
@@ -22789,14 +22827,14 @@ function encodeReplayData(value, options = {}) {
22789
22827
  const properties = /* @__PURE__ */ Object.create(null);
22790
22828
  for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(entry))) {
22791
22829
  if (!("value" in descriptor)) throw new TypeError(`Cannot record replay data accessor '${key}'.`);
22792
- properties[key] = { value: child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22830
+ properties[key] = { value: yield child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22793
22831
  }
22794
22832
  let symbolIndex = 0;
22795
- const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22833
+ const symbolEntries = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22796
22834
  nodes2[id] = {
22797
22835
  kind: "regexp-iterator",
22798
- matcher: child(snapshot.matcher, "<matcher>"),
22799
- input: child(snapshot.input, "<input>"),
22836
+ matcher: yield child(snapshot.matcher, "<matcher>"),
22837
+ input: yield child(snapshot.input, "<input>"),
22800
22838
  exhausted: snapshot.exhausted,
22801
22839
  properties,
22802
22840
  extensible: Object.isExtensible(entry),
@@ -22808,34 +22846,30 @@ function encodeReplayData(value, options = {}) {
22808
22846
  const properties = /* @__PURE__ */ Object.create(null);
22809
22847
  for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(entry))) {
22810
22848
  if (!("value" in descriptor)) throw new TypeError(`Cannot record replay data accessor '${key}'.`);
22811
- properties[key] = { value: child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22849
+ properties[key] = { value: yield child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
22812
22850
  }
22813
- nodes2[id] = { kind: "collection-iterator", collectionKind: snapshot.collectionKind, method: snapshot.method, collection: child(snapshot.collection, "<collection>"), index: snapshot.index, exhausted: snapshot.exhausted, properties, extensible: Object.isExtensible(entry) };
22851
+ nodes2[id] = { kind: "collection-iterator", collectionKind: snapshot.collectionKind, method: snapshot.method, collection: yield child(snapshot.collection, "<collection>"), index: snapshot.index, exhausted: snapshot.exhausted, properties, extensible: Object.isExtensible(entry) };
22814
22852
  } else if (isSandboxMap(entry)) {
22815
- nodes2[id] = {
22816
- kind: "map",
22817
- ...serializeCollectionProperties(entry, (value2) => child(value2, "<collection-property>"), true),
22818
- entries: [...entry.entries].map(([key, value2], index) => [
22819
- child(key, `key:${index}`),
22820
- child(value2, `value:${index}`)
22821
- ])
22822
- };
22853
+ const properties = yield* dataCopyIterable(serializeCollectionPropertiesOperation(entry, (value2) => child(value2, "<collection-property>"), true));
22854
+ const entries = [];
22855
+ for (const [index, [key, value2]] of [...entry.entries].entries())
22856
+ entries.push([yield child(key, `key:${index}`), yield child(value2, `value:${index}`)]);
22857
+ nodes2[id] = { kind: "map", ...properties, entries };
22823
22858
  } else if (isSandboxSet(entry)) {
22824
- nodes2[id] = {
22825
- kind: "set",
22826
- ...serializeCollectionProperties(entry, (value2) => child(value2, "<collection-property>"), true),
22827
- values: [...entry.values].map((value2, index) => child(value2, String(index)))
22828
- };
22859
+ const properties = yield* dataCopyIterable(serializeCollectionPropertiesOperation(entry, (value2) => child(value2, "<collection-property>"), true));
22860
+ const values = [];
22861
+ for (const [index, value2] of [...entry.values].entries()) values.push(yield child(value2, String(index)));
22862
+ nodes2[id] = { kind: "set", ...properties, values };
22829
22863
  } else if (isSandboxRegex(entry)) {
22830
22864
  nodes2[id] = {
22831
22865
  kind: "regex",
22832
22866
  source: entry.source,
22833
22867
  flags: entry.flags,
22834
- lastIndex: child(entry.lastIndex, "lastIndex"),
22835
- ...serializeRegexProperties(entry, (value2) => child(value2, "<regex-property>"))
22868
+ lastIndex: yield child(entry.lastIndex, "lastIndex"),
22869
+ ...yield* dataCopyIterable(serializeRegexPropertiesOperation(entry, (value2) => child(value2, "<regex-property>")))
22836
22870
  };
22837
22871
  } else if (isSandboxArguments(entry)) {
22838
- nodes2[id] = { kind: "arguments", data: serializeArguments(entry, child) };
22872
+ nodes2[id] = { kind: "arguments", data: yield* dataCopyIterable(serializeArgumentsOperation(entry, (value2, key) => child(value2, key))) };
22839
22873
  } else {
22840
22874
  const prototype2 = Object.getPrototypeOf(entry);
22841
22875
  if (!Array.isArray(entry) && prototype2 !== null && prototype2 !== Object.prototype) {
@@ -22843,13 +22877,13 @@ function encodeReplayData(value, options = {}) {
22843
22877
  }
22844
22878
  const properties = /* @__PURE__ */ Object.create(null);
22845
22879
  let symbolIndex = 0;
22846
- const symbolProperties = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
22880
+ const symbolProperties = yield* dataCopyIterable(serializeSymbolPropertiesOperation(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }])));
22847
22881
  const errorType = sandboxErrorTypes.get(entry);
22848
22882
  for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(entry))) {
22849
22883
  if (!("value" in descriptor))
22850
22884
  throw new TypeError(`Cannot record replay data accessor '${key}'.`);
22851
22885
  properties[key] = {
22852
- value: child(descriptor.value, key),
22886
+ value: yield child(descriptor.value, key),
22853
22887
  configurable: descriptor.configurable === true,
22854
22888
  enumerable: descriptor.enumerable === true,
22855
22889
  writable: descriptor.writable === true
@@ -22868,7 +22902,7 @@ function encodeReplayData(value, options = {}) {
22868
22902
  return { tag: "ref", id };
22869
22903
  };
22870
22904
  try {
22871
- return { root: encode(value, 0, options.path ?? []), nodes: nodes2 };
22905
+ return { root: runDataCopy(encode(value, 0, options.path ?? [])), nodes: nodes2 };
22872
22906
  } catch (error) {
22873
22907
  context.failed = true;
22874
22908
  nodes2.length = initialNodeCount;
@@ -23440,19 +23474,23 @@ function decodeReplayData(input, options = {}, parent, pendingWork, initialDepth
23440
23474
  if (kind === "map") {
23441
23475
  const result3 = createSandboxMap();
23442
23476
  restored.set(id, result3);
23443
- restoreCollectionDataProperties(result3, node, child);
23444
- for (const pair of list(own(node, "entries"))) {
23445
- const entries = list(pair);
23446
- if (entries.length !== 2) throw new TypeError("Invalid replay map entry.");
23447
- result3.entries.set(child(entries[0]), child(entries[1]));
23448
- }
23477
+ initializeValues.push(() => {
23478
+ restoreCollectionDataProperties(result3, node, child);
23479
+ for (const pair of list(own(node, "entries"))) {
23480
+ const entries = list(pair);
23481
+ if (entries.length !== 2) throw new TypeError("Invalid replay map entry.");
23482
+ result3.entries.set(child(entries[0]), child(entries[1]));
23483
+ }
23484
+ });
23449
23485
  return result3;
23450
23486
  }
23451
23487
  if (kind === "set") {
23452
23488
  const result3 = createSandboxSet();
23453
23489
  restored.set(id, result3);
23454
- restoreCollectionDataProperties(result3, node, child);
23455
- for (const value of list(own(node, "values"))) result3.values.add(child(value));
23490
+ initializeValues.push(() => {
23491
+ restoreCollectionDataProperties(result3, node, child);
23492
+ for (const value of list(own(node, "values"))) result3.values.add(child(value));
23493
+ });
23456
23494
  return result3;
23457
23495
  }
23458
23496
  if (kind === "regex") {
@@ -23461,8 +23499,10 @@ function decodeReplayData(input, options = {}, parent, pendingWork, initialDepth
23461
23499
  }
23462
23500
  const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
23463
23501
  restored.set(id, result3);
23464
- result3.lastIndex = child(own(node, "lastIndex"));
23465
- restoreRegexProperties(result3, node, child);
23502
+ initializeValues.push(() => {
23503
+ result3.lastIndex = child(own(node, "lastIndex"));
23504
+ restoreRegexProperties(result3, node, child);
23505
+ });
23466
23506
  return result3;
23467
23507
  }
23468
23508
  if (kind === "arguments") {
@@ -23471,15 +23511,17 @@ function decodeReplayData(input, options = {}, parent, pendingWork, initialDepth
23471
23511
  if (data.kind !== "arguments") throw new TypeError("Invalid replay arguments.");
23472
23512
  const args = createSandboxArguments([]);
23473
23513
  restored.set(id, args);
23474
- if (!data.lengthBeforeCallee) delete args.length;
23475
- defineProperties(args, record2(data.properties), child);
23476
- if (data.iterator === null) Reflect.deleteProperty(args, Symbol.iterator);
23477
- else
23478
- Object.defineProperty(args, Symbol.iterator, {
23479
- ...record2(data.iterator),
23480
- value: Array.prototype.values
23481
- });
23482
- if (!data.extensible) Object.preventExtensions(args);
23514
+ initializeValues.push(() => {
23515
+ if (!data.lengthBeforeCallee) delete args.length;
23516
+ defineProperties(args, record2(data.properties), child);
23517
+ if (data.iterator === null) Reflect.deleteProperty(args, Symbol.iterator);
23518
+ else
23519
+ Object.defineProperty(args, Symbol.iterator, {
23520
+ ...record2(data.iterator),
23521
+ value: Array.prototype.values
23522
+ });
23523
+ if (!data.extensible) Object.preventExtensions(args);
23524
+ });
23483
23525
  return args;
23484
23526
  }
23485
23527
  if (kind !== "array" && kind !== "object") throw new TypeError("Invalid replay data node.");
@@ -23496,9 +23538,11 @@ function decodeReplayData(input, options = {}, parent, pendingWork, initialDepth
23496
23538
  }
23497
23539
  if (kind === "array" && node.nullPrototype) Object.setPrototypeOf(result2, null);
23498
23540
  restored.set(id, result2);
23499
- defineProperties(result2, record2(own(node, "properties")), child, node.symbolProperties);
23500
- if (kind === "array") compilation.owner?.budget.allocateArrayLength(result2.length);
23501
- if (!node.extensible) Object.preventExtensions(result2);
23541
+ initializeValues.push(() => {
23542
+ defineProperties(result2, record2(own(node, "properties")), child, node.symbolProperties);
23543
+ if (kind === "array") compilation.owner?.budget.allocateArrayLength(result2.length);
23544
+ if (!node.extensible) Object.preventExtensions(result2);
23545
+ });
23502
23546
  return result2;
23503
23547
  };
23504
23548
  const result = decode(own(graph, "root"));
@@ -24398,6 +24442,9 @@ function wrapHostPromiseWithSignal(promise, signal) {
24398
24442
  });
24399
24443
  }
24400
24444
  function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24445
+ return runDataCopy(copyHostValueNode(value, stackFrames, options, state, path));
24446
+ }
24447
+ function* copyHostValueNode(value, stackFrames, options, state, path) {
24401
24448
  const { budget } = options;
24402
24449
  if (isLiveCapability(value)) {
24403
24450
  if (options.realm === void 0 || options.errorData || options.hostCalls !== void 0) throw new TypeError("Live capabilities are not portable replay or error data.");
@@ -24432,7 +24479,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24432
24479
  const existing = state.seen.get(value) ?? state.promiseIdentities?.get(value);
24433
24480
  if (existing !== void 0) return existing;
24434
24481
  observeSandboxPromise(value);
24435
- const copied = copyHostValueToSandbox(value.promise, stackFrames, options, state, path);
24482
+ const copied = yield copyHostValueNode(value.promise, stackFrames, options, state, path);
24436
24483
  if (!isSandboxPromise(copied)) throw new TypeError("Invalid copied imported Promise.");
24437
24484
  options.promiseReplacements.set(value, copied);
24438
24485
  state.seen.set(value, copied);
@@ -24444,7 +24491,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24444
24491
  if (typeof key === "symbol" && key.description !== void 0) budget.allocateString(key.description);
24445
24492
  Object.defineProperty(getPromiseProperties(copied), typeof key === "string" ? budget.allocateString(key) : key, {
24446
24493
  ...descriptor,
24447
- value: copyHostValueToSandbox(descriptor.value, stackFrames, options, state, joinPath(path, String(key)))
24494
+ value: yield copyHostValueNode(descriptor.value, stackFrames, options, state, joinPath(path, String(key)))
24448
24495
  });
24449
24496
  }
24450
24497
  if (!Object.isExtensible(properties)) Object.preventExtensions(getPromiseProperties(copied));
@@ -24468,7 +24515,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24468
24515
  if (typeof key !== "string") throw new TypeError("Host RegExp symbol properties require an explicit capability path.");
24469
24516
  Object.defineProperty(getRegexProperties(copy), budget.allocateString(key), {
24470
24517
  ...descriptor,
24471
- value: copyHostValueToSandbox(
24518
+ value: yield copyHostValueNode(
24472
24519
  descriptor.value,
24473
24520
  stackFrames,
24474
24521
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
@@ -24525,7 +24572,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24525
24572
  if (typeof key === "symbol" && key.description !== void 0) budget.allocateString(key.description);
24526
24573
  Object.defineProperty(copy, typeof key === "string" ? budget.allocateString(key) : key, {
24527
24574
  ...descriptor,
24528
- value: copyHostValueToSandbox(
24575
+ value: yield copyHostValueNode(
24529
24576
  descriptor.value,
24530
24577
  stackFrames,
24531
24578
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -24559,7 +24606,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24559
24606
  if (!("value" in descriptor)) throw new TypeError(`Unsupported sandbox value at ${joinPath(path, key)}: accessor property`);
24560
24607
  Object.defineProperty(copy, budget.allocateString(key), {
24561
24608
  ...descriptor,
24562
- value: copyHostValueToSandbox(
24609
+ value: yield copyHostValueNode(
24563
24610
  descriptor.value,
24564
24611
  stackFrames,
24565
24612
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
@@ -24588,7 +24635,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24588
24635
  budget.provisionDataUsage(length + 2)();
24589
24636
  const copy = copyDataViewStorage(value, state);
24590
24637
  state.seen.set(value, copy);
24591
- copyHostValueToSandbox(
24638
+ yield copyHostValueNode(
24592
24639
  buffer,
24593
24640
  stackFrames,
24594
24641
  { ...options, capabilityPath: [...options.capabilityPath ?? [], "buffer"] },
@@ -24599,7 +24646,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24599
24646
  if (typeof key !== "string") throw new TypeError("Host DataView symbol properties require an explicit capability path.");
24600
24647
  Object.defineProperty(copy, key, {
24601
24648
  ...descriptor,
24602
- value: copyHostValueToSandbox(
24649
+ value: yield copyHostValueNode(
24603
24650
  descriptor.value,
24604
24651
  stackFrames,
24605
24652
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
@@ -24624,7 +24671,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24624
24671
  if (typeof key === "symbol") throw new TypeError("Host ArrayBuffer symbol properties require an explicit capability path.");
24625
24672
  Object.defineProperty(copy, key, {
24626
24673
  ...descriptor,
24627
- value: copyHostValueToSandbox(
24674
+ value: yield copyHostValueNode(
24628
24675
  descriptor.value,
24629
24676
  stackFrames,
24630
24677
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
@@ -24645,7 +24692,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24645
24692
  checkTypedArrayAllocation(Math.ceil(storage.byteLength / storage.elementSize), budget, storage.elementSize);
24646
24693
  const copy = copyTypedArrayStorage(value, state, true);
24647
24694
  state.seen.set(value, copy);
24648
- copyHostValueToSandbox(
24695
+ yield copyHostValueNode(
24649
24696
  typedArrayStorage(value).buffer,
24650
24697
  stackFrames,
24651
24698
  { ...options, capabilityPath: [...options.capabilityPath ?? [], "buffer"] },
@@ -24655,7 +24702,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24655
24702
  for (const [key, descriptor] of typedArrayDataProperties(value)) {
24656
24703
  Object.defineProperty(copy, key, {
24657
24704
  ...descriptor,
24658
- value: copyHostValueToSandbox(
24705
+ value: yield copyHostValueNode(
24659
24706
  descriptor.value,
24660
24707
  stackFrames,
24661
24708
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
@@ -24714,7 +24761,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24714
24761
  const segment = hasSymbols ? JSON.stringify(typeof key === "symbol" ? ["symbol", index] : ["property", key]) : key;
24715
24762
  Object.defineProperty(properties, typeof key === "string" ? budget.allocateString(key) : key, {
24716
24763
  ...descriptor,
24717
- value: copyHostValueToSandbox(
24764
+ value: yield copyHostValueNode(
24718
24765
  descriptor.value,
24719
24766
  stackFrames,
24720
24767
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -24756,7 +24803,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24756
24803
  defineOwnDataProperty(
24757
24804
  copy,
24758
24805
  typeof key === "symbol" || indexed ? key : budget.allocateString(key),
24759
- copyHostValueToSandbox(
24806
+ yield copyHostValueNode(
24760
24807
  descriptor.value,
24761
24808
  stackFrames,
24762
24809
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -24779,11 +24826,11 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24779
24826
  budget.allocateCollectionEntries(isSandboxMap(value) ? value.entries.size : native.size);
24780
24827
  if (runResources.getStore()?.hostDataMetadata !== false) {
24781
24828
  let propertyIndex = 0;
24782
- copyCollectionProperties(value, getCollectionProperties(copy), (entry, key) => {
24829
+ yield copyCollectionPropertiesOperation(value, getCollectionProperties(copy), (entry, key) => {
24783
24830
  if (typeof key === "string") budget.allocateString(key);
24784
24831
  else if (key.description !== void 0) budget.allocateString(key.description);
24785
24832
  const segment = JSON.stringify(["property", typeof key === "symbol" ? ["symbol", propertyIndex++] : ["string", key]]);
24786
- return copyHostValueToSandbox(
24833
+ return copyHostValueNode(
24787
24834
  entry,
24788
24835
  stackFrames,
24789
24836
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -24795,14 +24842,14 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24795
24842
  for (const [key, entry] of entries) {
24796
24843
  const ordinal = copy.entries.size;
24797
24844
  copy.entries.set(
24798
- copyHostValueToSandbox(
24845
+ yield copyHostValueNode(
24799
24846
  key,
24800
24847
  stackFrames,
24801
24848
  { ...options, capabilityPath: [...options.capabilityPath ?? [], `key:${ordinal}`] },
24802
24849
  state,
24803
24850
  `${path}.<key>`
24804
24851
  ),
24805
- copyHostValueToSandbox(
24852
+ yield copyHostValueNode(
24806
24853
  entry,
24807
24854
  stackFrames,
24808
24855
  { ...options, capabilityPath: [...options.capabilityPath ?? [], `value:${ordinal}`] },
@@ -24825,11 +24872,11 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24825
24872
  budget.allocateCollectionEntries(isSandboxSet(value) ? value.values.size : native.size);
24826
24873
  if (runResources.getStore()?.hostDataMetadata !== false) {
24827
24874
  let propertyIndex = 0;
24828
- copyCollectionProperties(value, getCollectionProperties(copy), (entry, key) => {
24875
+ yield copyCollectionPropertiesOperation(value, getCollectionProperties(copy), (entry, key) => {
24829
24876
  if (typeof key === "string") budget.allocateString(key);
24830
24877
  else if (key.description !== void 0) budget.allocateString(key.description);
24831
24878
  const segment = JSON.stringify(["property", typeof key === "symbol" ? ["symbol", propertyIndex++] : ["string", key]]);
24832
- return copyHostValueToSandbox(
24879
+ return copyHostValueNode(
24833
24880
  entry,
24834
24881
  stackFrames,
24835
24882
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -24840,7 +24887,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24840
24887
  }
24841
24888
  for (const entry of entries) {
24842
24889
  copy.values.add(
24843
- copyHostValueToSandbox(
24890
+ yield copyHostValueNode(
24844
24891
  entry,
24845
24892
  stackFrames,
24846
24893
  {
@@ -24881,7 +24928,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24881
24928
  enumerable: true,
24882
24929
  configurable: true,
24883
24930
  writable: true,
24884
- value: copyHostValueToSandbox(
24931
+ value: yield copyHostValueNode(
24885
24932
  descriptor.value,
24886
24933
  stackFrames,
24887
24934
  { ...options, capabilityPath: [...options.capabilityPath ?? [], segment] },
@@ -29811,7 +29858,7 @@ function createPrimitiveConstructor(options, budget) {
29811
29858
  const prototype2 = createIntrinsicBox(initial);
29812
29859
  const allocate = (value, context) => {
29813
29860
  const box = createSandboxBox(value);
29814
- const finish = (selectedPrototype) => {
29861
+ const finish2 = (selectedPrototype) => {
29815
29862
  budget.chargeDataUsage(measureSandboxData([box]));
29816
29863
  setSandboxPrototype(
29817
29864
  box,
@@ -29822,9 +29869,9 @@ function createPrimitiveConstructor(options, budget) {
29822
29869
  };
29823
29870
  if (context?.newTarget !== void 0 && context.newTarget !== constructor) {
29824
29871
  const prototype3 = context.getProperty(context.newTarget, "prototype");
29825
- return prototype3 instanceof Promise ? prototype3.then(finish) : finish(prototype3);
29872
+ return prototype3 instanceof Promise ? prototype3.then(finish2) : finish2(prototype3);
29826
29873
  }
29827
- return finish(void 0);
29874
+ return finish2(void 0);
29828
29875
  };
29829
29876
  const constructor = createSandboxClosure({
29830
29877
  guest: true,
@@ -29953,12 +30000,12 @@ function createObjectArrayGlobals(options) {
29953
30000
  if (value === null || value === void 0)
29954
30001
  throw new TypeError("Cannot convert undefined or null to object.");
29955
30002
  const name = toPropertyKey(key, options.budget, context);
29956
- const finish = (property) => {
30003
+ const finish2 = (property) => {
29957
30004
  if (typeof value === "object" && guestProxyStates.has(value))
29958
30005
  return Promise.resolve(sandboxGetOwnPropertyDescriptor(value, property, options.budget, context)).then((descriptor) => descriptor !== void 0);
29959
30006
  return hasOwnSandboxProperty(value, property, false);
29960
30007
  };
29961
- return typeof name === "string" || typeof name === "symbol" ? finish(name) : name.then(finish);
30008
+ return typeof name === "string" || typeof name === "symbol" ? finish2(name) : name.then(finish2);
29962
30009
  },
29963
30010
  name: "hasOwn",
29964
30011
  length: 2