@poe-platform/safe-js 0.1.395 → 0.1.396

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.
@@ -22159,6 +22159,9 @@ function isPromiseLike2(value) {
22159
22159
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function" && !isSandboxClosure(value) && !isSandboxPromise(value);
22160
22160
  }
22161
22161
 
22162
+ // packages/safe-js/src/interp/symbol-registry.ts
22163
+ var symbolRegistryOrigins = /* @__PURE__ */ new WeakMap();
22164
+
22162
22165
  // packages/safe-js/src/snapshot/property-descriptors.ts
22163
22166
  function serializePropertyDescriptors(target, encode) {
22164
22167
  return {
@@ -22326,7 +22329,13 @@ function captureGuestHeapNode(value, encode) {
22326
22329
  const intrinsic = getIntrinsicIdentity(value);
22327
22330
  if (intrinsic !== void 0) {
22328
22331
  const state2 = captureObjectState(value, encode);
22329
- return { kind: "intrinsic", id: intrinsic, ...state2 === void 0 ? {} : { state: state2 } };
22332
+ const registry = isSandboxClosure(value) ? symbolRegistryOrigins.get(value) : void 0;
22333
+ return {
22334
+ kind: "intrinsic",
22335
+ id: intrinsic,
22336
+ ...state2 === void 0 ? {} : { state: state2 },
22337
+ ...registry === void 0 ? {} : { symbolRegistry: [...registry].map(([key, symbol]) => [key, encode(symbol)]) }
22338
+ };
22330
22339
  }
22331
22340
  const bound = boundFunctionStates.get(value);
22332
22341
  if (bound !== void 0 && isSandboxClosure(value)) {
@@ -27107,8 +27116,10 @@ function createSymbolGlobal(budget) {
27107
27116
  })
27108
27117
  };
27109
27118
  for (const [name, method] of Object.entries(methods2)) {
27119
+ symbolRegistryOrigins.set(method, entries);
27110
27120
  Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
27111
27121
  }
27122
+ symbolRegistryOrigins.set(constructor, entries);
27112
27123
  for (const [name, value] of Object.entries(wellKnownSymbols)) {
27113
27124
  Object.defineProperty(properties, name, { value });
27114
27125
  }
@@ -27846,8 +27857,23 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
27846
27857
  if (iterator.kind === "symbol" || iterator.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
27847
27858
  state(node.state);
27848
27859
  } else if (node.kind === "intrinsic") {
27849
- fields(node, ["kind", "id"], ["state"]);
27860
+ fields(node, ["kind", "id"], ["state", "symbolRegistry"]);
27850
27861
  if (typeof node.id !== "string" || !intrinsicCatalogue().has(node.id)) throw new TypeError("Unknown intrinsic identity.");
27862
+ if (Object.hasOwn(node, "symbolRegistry")) {
27863
+ if (![JSON.stringify(["Symbol"]), JSON.stringify(["Symbol", "for"]), JSON.stringify(["Symbol", "keyFor"])].includes(node.id) || !Array.isArray(node.symbolRegistry))
27864
+ throw new TypeError("Invalid symbol registry owner.");
27865
+ const keys = /* @__PURE__ */ new Set();
27866
+ const symbols = /* @__PURE__ */ new Set();
27867
+ for (const entry of node.symbolRegistry) {
27868
+ if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string" || keys.has(entry[0]))
27869
+ throw new TypeError("Invalid symbol registry entry.");
27870
+ const symbol = reference(entry[1], ["symbol"]);
27871
+ if (symbol.wellKnown !== void 0 || symbol.description !== entry[0] || symbols.has(symbol))
27872
+ throw new TypeError("Invalid registered symbol identity.");
27873
+ keys.add(entry[0]);
27874
+ symbols.add(symbol);
27875
+ }
27876
+ }
27851
27877
  if (Object.hasOwn(node, "state")) state(node.state);
27852
27878
  } else if (node.kind === "guest-regexp-iterator") {
27853
27879
  fields(node, ["kind", "matcher", "input", "exhausted", "state"], ["global", "unicode"]);
@@ -45015,4 +45041,4 @@ export {
45015
45041
  FileSnapshotBackend,
45016
45042
  run
45017
45043
  };
45018
- //# sourceMappingURL=chunk-7V4MG4KI.js.map
45044
+ //# sourceMappingURL=chunk-BVKIA2LQ.js.map