@poe-platform/safe-js 0.1.298 → 0.1.299

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.
@@ -7013,6 +7013,17 @@ function serializedDateTime(value) {
7013
7013
  // packages/safe-js/src/interp/internal-symbols.ts
7014
7014
  var internalSymbols = /* @__PURE__ */ new Set();
7015
7015
 
7016
+ // packages/safe-js/src/interp/generator-properties.ts
7017
+ var generatorGuestProperties = /* @__PURE__ */ new WeakMap();
7018
+ function getGeneratorProperties(value) {
7019
+ let properties = generatorGuestProperties.get(value);
7020
+ if (properties === void 0) {
7021
+ properties = /* @__PURE__ */ Object.create(null);
7022
+ generatorGuestProperties.set(value, properties);
7023
+ }
7024
+ return properties;
7025
+ }
7026
+
7016
7027
  // packages/safe-js/src/interp/regexp-properties.ts
7017
7028
  var regexGuestProperties = /* @__PURE__ */ new WeakMap();
7018
7029
  function getRegexProperties(value) {
@@ -7355,7 +7366,7 @@ function walkGraphDepth(root, rootPath, assertDepth) {
7355
7366
  }
7356
7367
  }
7357
7368
  function graphEntries(value) {
7358
- const properties = regexGuestProperties.get(value);
7369
+ const properties = regexGuestProperties.get(value) ?? generatorGuestProperties.get(value);
7359
7370
  if (properties !== void 0) return Reflect.ownKeys(properties).flatMap((key) => {
7360
7371
  const descriptor = Object.getOwnPropertyDescriptor(properties, key);
7361
7372
  return "value" in descriptor ? [[`.${String(key)}`, descriptor.value]] : [];
@@ -8018,8 +8029,8 @@ function getSandboxPropertyDescriptor(value, key, budget) {
8018
8029
  return hostProperties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(hostProperties, key);
8019
8030
  let current = value;
8020
8031
  let depth = 0;
8021
- while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
8022
- const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
8032
+ while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxGenerator(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
8033
+ const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
8023
8034
  const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
8024
8035
  if (descriptor !== void 0) return descriptor;
8025
8036
  current = getSandboxPrototype(current, budget);
@@ -8037,6 +8048,10 @@ function getSandboxDataProperty(value, key, budget) {
8037
8048
  if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
8038
8049
  if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
8039
8050
  if (isSandboxPromise(current)) return Object.getOwnPropertyDescriptor(getPromiseProperties(current), key)?.value;
8051
+ if (isSandboxGenerator(current)) {
8052
+ const descriptor = Object.getOwnPropertyDescriptor(getGeneratorProperties(current), key);
8053
+ if (descriptor !== void 0) return descriptor.value;
8054
+ }
8040
8055
  if (isSandboxMap(current) || isSandboxSet(current)) return Object.getOwnPropertyDescriptor(getCollectionProperties(current), key)?.value;
8041
8056
  if (isGuestClosure(current)) {
8042
8057
  const entry = getGuestFunctionProperty(current, key);
@@ -8045,9 +8060,9 @@ function getSandboxDataProperty(value, key, budget) {
8045
8060
  const properties = current.properties;
8046
8061
  return properties !== void 0 && Object.hasOwn(properties, key) ? properties[key] : void 0;
8047
8062
  }
8048
- if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxGenerator(current))
8063
+ if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current))
8049
8064
  return void 0;
8050
- if (!isSandboxClosure(current) && Object.hasOwn(current, key)) return current[key];
8065
+ if (!isSandboxClosure(current) && !isSandboxGenerator(current) && Object.hasOwn(current, key)) return current[key];
8051
8066
  current = getSandboxPrototype(current, budget);
8052
8067
  if (current !== null) {
8053
8068
  budget?.visitNode();
@@ -8060,7 +8075,7 @@ function setSandboxPrototype(value, prototype, budget) {
8060
8075
  if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
8061
8076
  throw new TypeError("Object.prototype has an immutable null prototype.");
8062
8077
  }
8063
- if (!Array.isArray(value) && !isSandboxDate(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxDate(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
8078
+ if (!Array.isArray(value) && !isSandboxGenerator(value) && !isSandboxDate(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxGenerator(prototype) && !isSandboxDate(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
8064
8079
  throw new TypeError(
8065
8080
  "Prototype links require supported sandbox objects."
8066
8081
  );
@@ -8069,7 +8084,7 @@ function setSandboxPrototype(value, prototype, budget) {
8069
8084
  if (prototype === null) prototypes.set(value, null);
8070
8085
  return;
8071
8086
  }
8072
- if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
8087
+ if (!Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
8073
8088
  throw new TypeError("Cannot change the prototype of a non-extensible object.");
8074
8089
  }
8075
8090
  let depth = 0;
@@ -9384,7 +9399,10 @@ async function restoreSandboxIterator(snapshot, budget, context, signal) {
9384
9399
  if (snapshot.kind === "guest") return guestIterator(snapshot.value, snapshot.next, snapshot.async, budget, context, signal);
9385
9400
  if (snapshot.kind === "async-from-sync") return asyncFromSyncIterator(await restoreSandboxIterator(snapshot.inner, budget, context, signal), budget, signal, context);
9386
9401
  if (Array.isArray(snapshot.value)) return arrayIterator(snapshot.value, context, budget, snapshot.index);
9387
- const iterator = isSandboxGenerator(snapshot.value) && snapshot.value.async ? getSandboxAsyncIterator(snapshot.value, budget, context, signal) : getSandboxIterator(snapshot.value, budget, context);
9402
+ const iterator = isSandboxGenerator(snapshot.value) ? {
9403
+ ...generatorObjectIterator(snapshot.value, budget, context),
9404
+ ...snapshot.value.async ? { asyncProtocol: true } : {}
9405
+ } : getSandboxIterator(snapshot.value, budget, context);
9388
9406
  if (iterator === void 0) throw new TypeError("Invalid builtin iterator snapshot.");
9389
9407
  for (let index = 0; index < snapshot.index; index++) await iterator.next();
9390
9408
  return iterator;
@@ -9394,6 +9412,11 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
9394
9412
  if (context.getProperty === void 0 || isGuestHostObject(value))
9395
9413
  return asyncProtocol ? getSandboxAsyncIterator(value, budget, context, signal) : getSandboxIterator(value, budget, context);
9396
9414
  if (getSandboxPropertyDescriptor(value, key, budget) === void 0 && !(isSandboxRegExpIterator(value) && !asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)) {
9415
+ if (isSandboxGenerator(value)) {
9416
+ if (hasExplicitSandboxPrototype(value)) return void 0;
9417
+ if (value.async === true === asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)
9418
+ return guestIterator(value, await context.getProperty(value, "next"), asyncProtocol, budget, context, signal);
9419
+ }
9397
9420
  if (!asyncProtocol && Array.isArray(value) && getSandboxPrototype(value, budget) !== null) return void 0;
9398
9421
  if (!asyncProtocol) return getSandboxIterator(value, budget, context);
9399
9422
  if (isSandboxGenerator(value) && value.async)
@@ -9458,7 +9481,7 @@ async function readIteratorResult(iterator, result, property) {
9458
9481
  }
9459
9482
  function getSandboxAsyncIterator(value, budget, context, signal) {
9460
9483
  if (isSandboxGenerator(value) && value.async) {
9461
- return { ...generatorIterator(value, budget, context), asyncProtocol: true };
9484
+ return hasExplicitSandboxPrototype(value) ? void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
9462
9485
  }
9463
9486
  if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
9464
9487
  const method = value[Symbol.asyncIterator];
@@ -9608,7 +9631,7 @@ function getSandboxIterator(value, budget, context) {
9608
9631
  return syncIterator(Float32Array.prototype.values.call(value));
9609
9632
  }
9610
9633
  if (isSandboxGenerator(value)) {
9611
- return value.async ? void 0 : generatorIterator(value);
9634
+ return value.async || hasExplicitSandboxPrototype(value) ? void 0 : generatorObjectIterator(value, budget, context);
9612
9635
  }
9613
9636
  if (typeof value === "string") {
9614
9637
  const iterator2 = value[Symbol.iterator]();
@@ -9685,6 +9708,26 @@ function collectionIterator(collection, value) {
9685
9708
  return adapter;
9686
9709
  }
9687
9710
  var asyncGeneratorRequests = /* @__PURE__ */ new WeakMap();
9711
+ function generatorObjectIterator(generator, budget, context) {
9712
+ const iterator = generatorIterator(generator, budget, context);
9713
+ if (context?.getProperty === void 0) return iterator;
9714
+ return {
9715
+ ...iterator,
9716
+ getOperation: async (method) => {
9717
+ if (method === "next" || !hasExplicitSandboxPrototype(generator) && getSandboxPropertyDescriptor(generator, method, budget) === void 0) return iterator[method];
9718
+ const operation = await context.getProperty(generator, method);
9719
+ if (operation === void 0 || operation === null) return void 0;
9720
+ if (!isSandboxClosure(operation)) throw new TypeError("Iterator operation must be callable.");
9721
+ return async (...args) => {
9722
+ const result = await invokeBuiltinClosure(operation, args, budget ?? new Budget(), context, generator);
9723
+ return generator.async ? await awaitSandboxValue(result, void 0, budget, context) : result;
9724
+ };
9725
+ },
9726
+ readResultProperty: async (result, property) => ({
9727
+ value: await context.getProperty(result, property)
9728
+ })
9729
+ };
9730
+ }
9688
9731
  function generatorIterator(generator, budget, context) {
9689
9732
  const invoke = async (method, value) => {
9690
9733
  const leaveRunning = enterRunningState(generator);
@@ -13006,14 +13049,14 @@ function createObjectArrayGlobals(options) {
13006
13049
  call: ([value]) => {
13007
13050
  if (isGuestHostObject(value))
13008
13051
  throw new TypeError("Live host objects cannot be made non-extensible.");
13009
- Object.preventExtensions(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13052
+ Object.preventExtensions(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13010
13053
  return value;
13011
13054
  },
13012
13055
  name: "preventExtensions"
13013
13056
  }),
13014
13057
  isExtensible: createSandboxClosure({
13015
13058
  sandbox: true,
13016
- call: ([value]) => Object.isExtensible(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13059
+ call: ([value]) => Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13017
13060
  name: "isExtensible"
13018
13061
  }),
13019
13062
  seal: createSandboxClosure({
@@ -13021,14 +13064,14 @@ function createObjectArrayGlobals(options) {
13021
13064
  call: ([value]) => {
13022
13065
  if (isGuestHostObject(value))
13023
13066
  throw new TypeError("Live host objects cannot be sealed.");
13024
- Object.seal(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13067
+ Object.seal(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13025
13068
  return value;
13026
13069
  },
13027
13070
  name: "seal"
13028
13071
  }),
13029
13072
  isSealed: createSandboxClosure({
13030
13073
  sandbox: true,
13031
- call: ([value]) => Object.isSealed(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13074
+ call: ([value]) => Object.isSealed(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13032
13075
  name: "isSealed"
13033
13076
  }),
13034
13077
  freeze: createSandboxClosure({
@@ -13037,7 +13080,7 @@ function createObjectArrayGlobals(options) {
13037
13080
  if (isGuestHostObject(value))
13038
13081
  throw new TypeError("Live host objects cannot be frozen.");
13039
13082
  if (typeof value === "object" && value !== null) {
13040
- Object.freeze(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13083
+ Object.freeze(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
13041
13084
  }
13042
13085
  return value;
13043
13086
  },
@@ -13045,7 +13088,7 @@ function createObjectArrayGlobals(options) {
13045
13088
  }),
13046
13089
  isFrozen: createSandboxClosure({
13047
13090
  sandbox: true,
13048
- call: ([value]) => Object.isFrozen(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13091
+ call: ([value]) => Object.isFrozen(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
13049
13092
  name: "isFrozen"
13050
13093
  }),
13051
13094
  assign: createSandboxClosure({
@@ -13388,6 +13431,7 @@ function reflectionProperties(value) {
13388
13431
  return objectProperties(value);
13389
13432
  }
13390
13433
  function objectProperties(value, mutable = false) {
13434
+ if (isSandboxGenerator(value)) return getGeneratorProperties(value);
13391
13435
  if (isSandboxPromise(value)) return getPromiseProperties(value);
13392
13436
  if (isSandboxMap(value) || isSandboxSet(value)) return getCollectionProperties(value);
13393
13437
  if (isSandboxRegex(value)) return getRegexProperties(value);
@@ -16192,7 +16236,7 @@ function forInKeys(object, budget) {
16192
16236
  for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
16193
16237
  if (depth > 0) budget.visitNode();
16194
16238
  assertSandboxDataDepth(depth++);
16195
- const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
16239
+ const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
16196
16240
  for (const key of Object.getOwnPropertyNames(properties)) {
16197
16241
  if (seen.has(key)) continue;
16198
16242
  seen.add(key);
@@ -16208,7 +16252,7 @@ function hasForInProperty(object, key, budget) {
16208
16252
  for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
16209
16253
  if (depth > 0) budget.visitNode();
16210
16254
  assertSandboxDataDepth(depth++);
16211
- const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
16255
+ const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
16212
16256
  if (Object.hasOwn(properties, key)) return true;
16213
16257
  }
16214
16258
  return false;
@@ -16764,7 +16808,7 @@ function getPropertyValue(target, property, context, receiver = target) {
16764
16808
  if (isSandboxSet(target)) return getSandboxPrototype(target, context.budget) === null ? getSetMember(target, property, createSetMethodOptions(context)) : void 0;
16765
16809
  if (isSandboxCollectionIterator(target))
16766
16810
  return getCollectionIteratorMember(target, property, context.budget);
16767
- if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
16811
+ if (isSandboxGenerator(target)) return hasExplicitSandboxPrototype(target) ? void 0 : getGeneratorMember(target, property, context.budget);
16768
16812
  if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
16769
16813
  if (isSandboxPromise(target)) return hasExplicitSandboxPrototype(target) ? void 0 : getPromiseMember(property, context.budget);
16770
16814
  if (isSandboxRegex(target)) return hasExplicitSandboxPrototype(target) || getSandboxPrototype(target, context.budget) !== null ? void 0 : getRegexMember(target, property, context.budget, createCoercionContext(context));
@@ -17080,7 +17124,7 @@ async function evaluateMemberCallExpression(node, context) {
17080
17124
  );
17081
17125
  }
17082
17126
  if (isSandboxGenerator(member.object)) {
17083
- const memberValue = getGeneratorMember(member.object, member.property, context.budget);
17127
+ const memberValue = await getPropertyValue(member.object, member.property, context);
17084
17128
  if (memberValue === void 0) {
17085
17129
  throw new TypeError(`Generator#${String(member.property)} is not a supported method.`);
17086
17130
  }
@@ -17384,7 +17428,7 @@ function hasSandboxProperty(value, key, context) {
17384
17428
  while (typeof current === "object" && current !== null) {
17385
17429
  if (isGuestHostObject(current)) return typeof key === "symbol" ? false : hasHostObjectMember(current, String(key));
17386
17430
  if (hasOwnSandboxProperty(current, key, false)) return true;
17387
- if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
17431
+ if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || isSandboxGenerator(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
17388
17432
  return getPropertyValue(current, key, context) !== void 0;
17389
17433
  }
17390
17434
  current = getSandboxPrototype(current, context.budget);
@@ -17630,6 +17674,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
17630
17674
  }
17631
17675
  if (isGuestClosure(target)) target = materializeFunctionProperties(target);
17632
17676
  if (isSandboxPromise(target)) target = getPromiseProperties(target);
17677
+ if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
17633
17678
  if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
17634
17679
  if (isFloat32Array(target)) {
17635
17680
  if (typeof property === "symbol") throw new TypeError("Typed array symbol properties are not yet supported.");
@@ -17663,7 +17708,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
17663
17708
  for (let prototype = getSandboxPrototype(prototypeOwner, budget); prototype !== null; prototype = getSandboxPrototype(prototype, budget)) {
17664
17709
  budget.visitNode();
17665
17710
  assertSandboxDataDepth(depth++);
17666
- const properties = isSandboxClosure(prototype) ? prototype.properties : prototype;
17711
+ const properties = isSandboxGenerator(prototype) ? getGeneratorProperties(prototype) : isSandboxClosure(prototype) ? prototype.properties : prototype;
17667
17712
  const inherited = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
17668
17713
  if (inherited === void 0) continue;
17669
17714
  if (inherited.writable !== true)
@@ -17682,7 +17727,7 @@ function setSuperProperty(base, receiver, key, value, context) {
17682
17727
  for (let current = base; current !== null; current = getSandboxPrototype(current, budget)) {
17683
17728
  budget.visitNode();
17684
17729
  assertSandboxDataDepth(depth++);
17685
- const properties = isSandboxClosure(current) ? current.properties : current;
17730
+ const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxClosure(current) ? current.properties : current;
17686
17731
  const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
17687
17732
  if (descriptor === void 0) continue;
17688
17733
  if (!("value" in descriptor))
@@ -17700,6 +17745,7 @@ function deleteSandboxProperty(target, property) {
17700
17745
  if (isGuestClosure(target)) target = materializeFunctionProperties(target);
17701
17746
  if (isSandboxRegex(target)) target = getRegexProperties(target);
17702
17747
  if (isSandboxPromise(target)) target = getPromiseProperties(target);
17748
+ if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
17703
17749
  if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
17704
17750
  if (Array.isArray(target)) {
17705
17751
  assertCollectionMutable(target);
@@ -18270,7 +18316,7 @@ function conversionHook(value, name, budget, context) {
18270
18316
  let current = value;
18271
18317
  let depth = 0;
18272
18318
  while (current !== null) {
18273
- const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
18319
+ const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
18274
18320
  const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
18275
18321
  if (descriptor !== void 0) {
18276
18322
  return readPropertyDescriptor(descriptor, value, context);
@@ -18483,8 +18529,7 @@ function hasOwnSandboxProperty(value, key, enumerable) {
18483
18529
  properties = value.properties ?? /* @__PURE__ */ Object.create(null);
18484
18530
  } else if (isSandboxMap(value) || isSandboxSet(value)) properties = getCollectionProperties(value);
18485
18531
  else if (isSandboxPromise(value)) properties = getPromiseProperties(value);
18486
- else if (isSandboxGenerator(value))
18487
- return false;
18532
+ else if (isSandboxGenerator(value)) properties = getGeneratorProperties(value);
18488
18533
  else if (isSandboxRegex(value)) properties = getRegexProperties(value);
18489
18534
  else properties = Object(value);
18490
18535
  const descriptor = Object.getOwnPropertyDescriptor(properties, key);
@@ -20153,6 +20198,7 @@ function captureGuestHeapNode(value, encode) {
20153
20198
  state: value.state,
20154
20199
  astNodeId: origin2.node.nodeId,
20155
20200
  async: value.async === true,
20201
+ objectState: captureObjectState(value, encode),
20156
20202
  scope: encode(origin2.scope),
20157
20203
  closureScope: encode(origin2.closureScope),
20158
20204
  ...value.state !== "suspended" || origin2.suspendedScope === void 0 ? {} : { suspendedScope: encode(origin2.suspendedScope) },
@@ -20268,6 +20314,7 @@ function captureGuestHeapNode(value, encode) {
20268
20314
  }
20269
20315
  function captureObjectState(value, encode) {
20270
20316
  let properties = value;
20317
+ if (isSandboxGenerator(value)) properties = getGeneratorProperties(value);
20271
20318
  if (isSandboxClosure(value)) {
20272
20319
  properties = value.properties;
20273
20320
  if (isGuestClosure(value)) properties = materializeFunctionProperties(value);
@@ -24254,7 +24301,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
24254
24301
  }
24255
24302
  state(node.state);
24256
24303
  } else if (node.kind === "guest-generator") {
24257
- fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates"]);
24304
+ fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates", "objectState"]);
24305
+ if (Object.hasOwn(node, "objectState")) state(node.objectState);
24258
24306
  if (!["start", "running", "suspended", "done"].includes(String(node.state)) || typeof node.async !== "boolean" || integer(node.astNodeId) < 1)
24259
24307
  throw new TypeError("Invalid generator state.");
24260
24308
  reference(node.scope, ["scope-frame"]);
@@ -25767,6 +25815,7 @@ function ownEnumerableSandboxEntries(value, excludedKeys) {
25767
25815
  if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
25768
25816
  else if (isSandboxRegex(value)) entries = Object.entries(getRegexProperties(value));
25769
25817
  else if (isSandboxPromise(value)) entries = Object.entries(getPromiseProperties(value));
25818
+ else if (isSandboxGenerator(value)) entries = Object.entries(getGeneratorProperties(value));
25770
25819
  else if (isSandboxMap(value) || isSandboxSet(value)) entries = Object.entries(getCollectionProperties(value));
25771
25820
  else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
25772
25821
  else entries = Object.entries(Object(value));
@@ -25778,19 +25827,20 @@ function ownSandboxSymbolKeys(value) {
25778
25827
  if (isSandboxClosure(value)) value = value.properties ?? {};
25779
25828
  else if (isSandboxRegex(value)) value = getRegexProperties(value);
25780
25829
  else if (isSandboxPromise(value)) value = getPromiseProperties(value);
25830
+ else if (isSandboxGenerator(value)) value = getGeneratorProperties(value);
25781
25831
  else if (isSandboxMap(value) || isSandboxSet(value)) value = getCollectionProperties(value);
25782
- else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
25783
25832
  return Object.getOwnPropertySymbols(Object(value)).filter((key) => !internalSymbols.has(key));
25784
25833
  }
25785
25834
  function ownEnumerableSandboxKeys(value, includeSymbols = false) {
25786
25835
  if (includeSymbols) {
25787
- const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
25836
+ const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
25788
25837
  return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter((key) => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
25789
25838
  }
25790
25839
  if (isGuestHostObject(value)) return getHostObjectKeys(value);
25791
25840
  if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
25792
25841
  if (isGuestClosure(value)) return Object.keys(value.properties ?? {});
25793
25842
  if (isSandboxPromise(value)) return Object.keys(getPromiseProperties(value));
25843
+ if (isSandboxGenerator(value)) return Object.keys(getGeneratorProperties(value));
25794
25844
  if (isSandboxRegex(value)) return Object.keys(getRegexProperties(value));
25795
25845
  if (isSandboxMap(value) || isSandboxSet(value)) return Object.keys(getCollectionProperties(value));
25796
25846
  if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
@@ -25842,6 +25892,7 @@ function createSandboxGenerator(channel, metadata = void 0) {
25842
25892
  enumerable: false,
25843
25893
  value: true
25844
25894
  });
25895
+ getGeneratorProperties(generator);
25845
25896
  return generator;
25846
25897
  }
25847
25898
  function createSandboxMap(entries = []) {
@@ -26096,6 +26147,14 @@ function measureSandboxData(values, options = {}) {
26096
26147
  return;
26097
26148
  }
26098
26149
  if (isSandboxGenerator(value)) {
26150
+ const descriptors3 = Object.getOwnPropertyDescriptors(getGeneratorProperties(value));
26151
+ for (const key of Reflect.ownKeys(descriptors3)) {
26152
+ const descriptor = descriptors3[key];
26153
+ usage += typeof key === "string" ? key.length + 1 : 1;
26154
+ if (typeof key === "symbol") visit(key, depth + 1);
26155
+ if ("value" in descriptor) visit(descriptor.value, depth + 1);
26156
+ else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
26157
+ }
26099
26158
  const snapshot = value.channel.snapshot();
26100
26159
  usage += snapshot.sent.length;
26101
26160
  for (const completion of snapshot.sent) visit(completion.value, depth + 1);
@@ -40922,4 +40981,4 @@ export {
40922
40981
  FileSnapshotBackend,
40923
40982
  run
40924
40983
  };
40925
- //# sourceMappingURL=chunk-BGSPSHLP.js.map
40984
+ //# sourceMappingURL=chunk-3QW2X67U.js.map