@poe-platform/safe-js 0.1.399 → 0.1.401

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.
@@ -8817,12 +8817,18 @@ var promiseAdoptionBridges = /* @__PURE__ */ new WeakMap();
8817
8817
  var promiseAdoptionResolvers = /* @__PURE__ */ new WeakMap();
8818
8818
  var promiseContinuations = /* @__PURE__ */ new WeakMap();
8819
8819
  var promiseReactionResults = /* @__PURE__ */ new WeakMap();
8820
+ var promiseProducers = /* @__PURE__ */ new WeakMap();
8820
8821
  function trackPromiseContinuation(promise, continuation) {
8821
8822
  promiseContinuations.set(promise, continuation);
8822
8823
  if (continuation.kind === "reaction") {
8823
8824
  let results = promiseReactionResults.get(continuation.source);
8824
8825
  if (results === void 0) promiseReactionResults.set(continuation.source, results = /* @__PURE__ */ new Set());
8825
8826
  results.add(promise);
8827
+ if (continuation.capability !== void 0) {
8828
+ let producers = promiseProducers.get(continuation.capability.promise);
8829
+ if (producers === void 0) promiseProducers.set(continuation.capability.promise, producers = /* @__PURE__ */ new Set());
8830
+ producers.add(promise);
8831
+ }
8826
8832
  }
8827
8833
  const release = () => {
8828
8834
  promiseContinuations.delete(promise);
@@ -8831,6 +8837,11 @@ function trackPromiseContinuation(promise, continuation) {
8831
8837
  const results = promiseReactionResults.get(continuation.source);
8832
8838
  results?.delete(promise);
8833
8839
  if (results?.size === 0) promiseReactionResults.delete(continuation.source);
8840
+ if (continuation.capability !== void 0) {
8841
+ const producers = promiseProducers.get(continuation.capability.promise);
8842
+ producers?.delete(promise);
8843
+ if (producers?.size === 0) promiseProducers.delete(continuation.capability.promise);
8844
+ }
8834
8845
  }
8835
8846
  };
8836
8847
  promise.promise.then(release, release);
@@ -21549,18 +21560,28 @@ function getPromisePrototype(budget) {
21549
21560
  const finish = (constructor2) => {
21550
21561
  if (!isSandboxPromiseConstructor(constructor2)) {
21551
21562
  return createPromiseCapability(constructor2, budget, context).then((capability) => {
21552
- if (isSandboxPromise(capability.promise)) unrepresentedPromiseContinuations.add(capability.promise);
21553
- observeSandboxPromise(target);
21554
- createSandboxPromise(target.promise.then(
21563
+ observeSandboxPromise(target, isSandboxPromise(capability.promise));
21564
+ const continuation2 = isSandboxPromise(capability.promise) ? {
21565
+ kind: "reaction",
21566
+ phase: "waiting",
21567
+ source: target,
21568
+ onFulfilled,
21569
+ onRejected,
21570
+ capability: { ...capability, promise: capability.promise }
21571
+ } : void 0;
21572
+ const completion = createSandboxPromise(target.promise.then(
21555
21573
  (value) => {
21574
+ if (continuation2 !== void 0) continuation2.phase = "running";
21556
21575
  consumeSettledHostCall(target);
21557
21576
  return runCapabilityReaction(onFulfilled, value, "fulfilled", capability, budget, context);
21558
21577
  },
21559
21578
  (reason) => {
21579
+ if (continuation2 !== void 0) continuation2.phase = "running";
21560
21580
  consumeSettledHostCall(target);
21561
21581
  return runCapabilityReaction(onRejected, reason, "rejected", capability, budget, context);
21562
21582
  }
21563
21583
  ));
21584
+ if (continuation2 !== void 0) trackPromiseContinuation(completion, continuation2);
21564
21585
  return capability.promise;
21565
21586
  });
21566
21587
  }
@@ -22339,12 +22360,14 @@ function captureGuestHeapNode(value, encode) {
22339
22360
  return { kind: "promise-resolver", promise: encode(resolver.promise), state: captureObjectState(value, encode) };
22340
22361
  }
22341
22362
  if (isSandboxPromise(value)) {
22363
+ const producerState = promiseProducers.has(value) ? { producers: [...promiseProducers.get(value)].map(encode) } : {};
22342
22364
  const settlement = promiseStates.get(value);
22343
22365
  if (settlement !== void 0 && settlement.status !== "pending")
22344
22366
  return {
22345
22367
  kind: "guest-promise",
22346
22368
  status: settlement.status,
22347
22369
  value: encode(settlement.value),
22370
+ ...producerState,
22348
22371
  ...promiseReactionResults.has(value) ? { reactions: [...promiseReactionResults.get(value)].map(encode) } : {},
22349
22372
  state: captureObjectState(value, encode)
22350
22373
  };
@@ -22358,6 +22381,7 @@ function captureGuestHeapNode(value, encode) {
22358
22381
  return {
22359
22382
  kind: "pending-promise",
22360
22383
  ...continuation.state.settled ? { adoption: encode(adoption) } : {},
22384
+ ...producerState,
22361
22385
  reactions: [...promiseReactionResults.get(value) ?? []].map(encode),
22362
22386
  state: captureObjectState(value, encode)
22363
22387
  };
@@ -22366,6 +22390,12 @@ function captureGuestHeapNode(value, encode) {
22366
22390
  return {
22367
22391
  kind: "promise-reaction",
22368
22392
  source: encode(continuation.source),
22393
+ ...producerState,
22394
+ ...continuation.capability === void 0 ? {} : { capability: {
22395
+ promise: encode(continuation.capability.promise),
22396
+ resolve: encode(continuation.capability.resolve),
22397
+ reject: encode(continuation.capability.reject)
22398
+ } },
22369
22399
  onFulfilled: encode(continuation.onFulfilled),
22370
22400
  onRejected: encode(continuation.onRejected),
22371
22401
  reactions: [...promiseReactionResults.get(value) ?? []].map(encode),
@@ -23202,6 +23232,8 @@ function collectContainerStats(value, stats, ancestors, guestValues, trustedRunR
23202
23232
  stat2.expanded = true;
23203
23233
  ancestors.add(value);
23204
23234
  const guestEntries = [];
23235
+ const replayPromise = isSandboxPromise(value) ? value : isPromiseResolvingFunction(value) ? promiseResolvingFunctions.get(value)?.promise : void 0;
23236
+ const replayMetadata = trustedRunReplay && replayPromise !== void 0 && promiseStates.get(replayPromise)?.status === "pending" && unrepresentedPromiseContinuations.has(replayPromise);
23205
23237
  if (isSandboxDataView(value)) guestEntries.push(dataViewBuffer(value));
23206
23238
  if (isNumericTypedArray(value)) guestEntries.push(typedArrayStorage(value).buffer);
23207
23239
  const guest = isSandboxDataView(value) ? { kind: "dataview", state: captureDataViewState(value, (entry) => {
@@ -23213,7 +23245,7 @@ function collectContainerStats(value, stats, ancestors, guestValues, trustedRunR
23213
23245
  }) } : isSandboxArrayBuffer(value) ? { kind: "arraybuffer", state: captureArrayBufferState(value, (entry) => {
23214
23246
  guestEntries.push(entry);
23215
23247
  return null;
23216
- }) } : trustedRunReplay && isSandboxPromise(value) && unrepresentedPromiseContinuations.has(value) ? void 0 : captureGuestHeapNode(value, (entry) => {
23248
+ }) } : replayMetadata ? void 0 : captureGuestHeapNode(value, (entry) => {
23217
23249
  guestEntries.push(entry);
23218
23250
  return null;
23219
23251
  });
@@ -27898,6 +27930,15 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
27898
27930
  if (typeof descriptor.enumerable !== "boolean" || typeof descriptor.configurable !== "boolean") throw new TypeError("Invalid guest descriptor flags.");
27899
27931
  }
27900
27932
  };
27933
+ if (Object.hasOwn(node, "producers")) {
27934
+ const producers = /* @__PURE__ */ new Set();
27935
+ for (const entry of array(node.producers)) {
27936
+ const producer = reference(entry, ["promise-reaction"]);
27937
+ if (producers.has(producer) || reference(record3(producer.capability).promise) !== node)
27938
+ throw new TypeError("Invalid promise producer ownership.");
27939
+ producers.add(producer);
27940
+ }
27941
+ }
27901
27942
  if (node.kind === "map" || node.kind === "set") {
27902
27943
  fields(node, ["kind", node.kind === "map" ? "entries" : "values"], ["propertyState", "prototype", "privateElements"]);
27903
27944
  if (node.privateElements !== void 0) privateState(node.privateElements);
@@ -27939,12 +27980,23 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
27939
27980
  throw new TypeError("Invalid promise resolver action.");
27940
27981
  state(node.state);
27941
27982
  } else if (node.kind === "pending-promise" || node.kind === "promise-reaction") {
27942
- fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption"] : []);
27983
+ fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption", "producers"] : ["capability", "producers"]);
27943
27984
  if (node.kind === "pending-promise" && Object.hasOwn(node, "adoption")) {
27944
27985
  const bridge = reference(node.adoption, ["promise-adoption"]);
27945
27986
  if (reference(bridge.owner, ["pending-promise"]) !== node) throw new TypeError("Invalid promise adoption owner.");
27946
27987
  }
27947
27988
  if (node.kind === "promise-reaction") {
27989
+ if (Object.hasOwn(node, "capability")) {
27990
+ const capability = record3(node.capability);
27991
+ fields(capability, ["promise", "resolve", "reject"]);
27992
+ const result = reference(capability.promise, ["pending-promise", "guest-promise", "promise-reaction"]);
27993
+ if (result === node) throw new TypeError("Invalid promise producer ownership.");
27994
+ if (!Array.isArray(result.producers) || !result.producers.some((entry) => reference(entry, ["promise-reaction"]) === node))
27995
+ throw new TypeError("Unlisted promise producer.");
27996
+ if (absent(capability.resolve) || absent(capability.reject)) throw new TypeError("Missing promise producer resolver.");
27997
+ callable(capability.resolve);
27998
+ callable(capability.reject);
27999
+ }
27948
28000
  const source = reference(node.source, ["pending-promise", "promise-reaction", "guest-promise"]);
27949
28001
  if (!Array.isArray(source.reactions) || !source.reactions.some((entry) => reference(entry, ["promise-reaction"]) === node))
27950
28002
  throw new TypeError("Unlisted promise reaction.");
@@ -27959,7 +28011,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
27959
28011
  }
27960
28012
  state(node.state);
27961
28013
  } else if (node.kind === "guest-promise") {
27962
- fields(node, ["kind", "status", "value", "state"], ["reactions"]);
28014
+ fields(node, ["kind", "status", "value", "state"], ["reactions", "producers"]);
27963
28015
  if (Object.hasOwn(node, "reactions")) {
27964
28016
  if (!Array.isArray(node.reactions)) throw new TypeError("Invalid promise reactions.");
27965
28017
  const reactions = /* @__PURE__ */ new Set();
@@ -30198,8 +30250,14 @@ function measureSandboxData(values, options = {}) {
30198
30250
  visit(continuation.source, depth + 1);
30199
30251
  visit(continuation.onFulfilled, depth + 1);
30200
30252
  visit(continuation.onRejected, depth + 1);
30253
+ if (continuation.capability !== void 0) {
30254
+ visit(continuation.capability.promise, depth + 1);
30255
+ visit(continuation.capability.resolve, depth + 1);
30256
+ visit(continuation.capability.reject, depth + 1);
30257
+ }
30201
30258
  }
30202
30259
  for (const reaction of promiseReactionResults.get(value) ?? []) visit(reaction, depth + 1);
30260
+ for (const producer of promiseProducers.get(value) ?? []) visit(producer, depth + 1);
30203
30261
  for (const key of Reflect.ownKeys(getPromiseProperties(value))) {
30204
30262
  const descriptor = Object.getOwnPropertyDescriptor(getPromiseProperties(value), key);
30205
30263
  usage += typeof key === "string" ? key.length + 1 : 1;
@@ -45215,4 +45273,4 @@ export {
45215
45273
  FileSnapshotBackend,
45216
45274
  run
45217
45275
  };
45218
- //# sourceMappingURL=chunk-L4AQGNFP.js.map
45276
+ //# sourceMappingURL=chunk-HDEGJ4AI.js.map