@poe-platform/safe-js 0.1.412 → 0.1.414

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.
@@ -8987,7 +8987,7 @@ function restoreRegexProperties(value, data, decode) {
8987
8987
  }
8988
8988
 
8989
8989
  // packages/safe-js/src/snapshot/validation.ts
8990
- import { types as types8 } from "node:util";
8990
+ import { types as types10 } from "node:util";
8991
8991
 
8992
8992
  // packages/safe-js/src/interp/builtin-call.ts
8993
8993
  async function invokeBuiltinClosure(closure, args, budget, context, thisValue, construct = false) {
@@ -16480,6 +16480,7 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
16480
16480
  }
16481
16481
 
16482
16482
  // packages/safe-js/src/interp/globals/error.ts
16483
+ import { types as types8 } from "node:util";
16483
16484
  var errorConstructorNames = /* @__PURE__ */ new WeakMap();
16484
16485
  var errorNames = [
16485
16486
  "Error",
@@ -16553,7 +16554,20 @@ function createErrorPrototypes(budget, constructors2) {
16553
16554
  }
16554
16555
  })
16555
16556
  });
16557
+ const isError = createSandboxClosure({
16558
+ guest: true,
16559
+ sandbox: true,
16560
+ name: "isError",
16561
+ length: 1,
16562
+ call: ([value]) => typeof value === "object" && value !== null && (sandboxErrorTypes.has(value) || types8.isNativeError(value))
16563
+ });
16564
+ Object.defineProperty(materializeFunctionProperties(constructors2.Error), "isError", {
16565
+ value: isError,
16566
+ writable: true,
16567
+ configurable: true
16568
+ });
16556
16569
  registerBuiltinIdentities(budget, Object.fromEntries(errorNames.map((name) => [name, constructors2[name]])));
16570
+ registerIntrinsicFunction(budget, isError);
16557
16571
  for (const name of errorNames) {
16558
16572
  registerIntrinsicFunction(budget, constructors2[name]);
16559
16573
  registerIntrinsicObject(budget, prototypes2.get(name));
@@ -23684,6 +23698,9 @@ async function formatDateLocale(name, time, args, budget, context) {
23684
23698
  }
23685
23699
  }
23686
23700
 
23701
+ // packages/safe-js/src/interp/host-bridge.ts
23702
+ import { types as types9 } from "node:util";
23703
+
23687
23704
  // packages/safe-js/src/snapshot/replay-data.ts
23688
23705
  var MissingReplayCapabilityError = class extends TypeError {
23689
23706
  };
@@ -24633,11 +24650,12 @@ function copyHostResultToSandbox(result, stackFrames, options) {
24633
24650
  return value;
24634
24651
  }
24635
24652
  function createHostErrorValue(reason, stackFrames, budget, span, state = { seen: /* @__PURE__ */ new WeakMap() }, chargeBudget = false) {
24636
- if (reason instanceof Error) {
24653
+ const nativeError = types9.isNativeError(reason) || reason instanceof Error;
24654
+ if (nativeError) {
24637
24655
  const existing = state.seen.get(reason);
24638
24656
  if (existing !== void 0) return existing;
24639
24657
  }
24640
- const error = reason instanceof Error ? createSubsetErrorValue(reason.name, reason.message, stackFrames, budget, {
24658
+ const error = nativeError ? createSubsetErrorValue(reason.name, reason.message, stackFrames, budget, {
24641
24659
  cause: reason,
24642
24660
  chargeBudget,
24643
24661
  transport: true
@@ -24645,7 +24663,7 @@ function createHostErrorValue(reason, stackFrames, budget, span, state = { seen:
24645
24663
  chargeBudget: false,
24646
24664
  transport: true
24647
24665
  });
24648
- if (reason instanceof Error) {
24666
+ if (nativeError) {
24649
24667
  state.seen.set(reason, error);
24650
24668
  copyHostErrorMetadata(error, reason, budget, chargeBudget);
24651
24669
  const errors = reason instanceof AggregateError ? Object.getOwnPropertyDescriptor(reason, "errors") : void 0;
@@ -24867,7 +24885,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
24867
24885
  if (typeof value === "string") {
24868
24886
  return options.budget.allocateString(value);
24869
24887
  }
24870
- if (value instanceof Error) {
24888
+ if (types9.isNativeError(value) || value instanceof Error) {
24871
24889
  return createHostErrorValue(value, stackFrames, budget, void 0, state, true);
24872
24890
  }
24873
24891
  if (options.errorData && (typeof value === "function" || isSandboxClosure(value) || isSandboxPromise(value) || value instanceof Promise)) {
@@ -29512,7 +29530,7 @@ function validateGenericValue(value, path, depth, state) {
29512
29530
  if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
29513
29531
  fail("invalidState", path, "guest function properties, prototype links and custom descriptors cannot be restored");
29514
29532
  }
29515
- if (state.dataPropertiesOnly && types8.isProxy(value)) {
29533
+ if (state.dataPropertiesOnly && types10.isProxy(value)) {
29516
29534
  fail("invalidType", path, "proxy objects are not snapshot data");
29517
29535
  }
29518
29536
  if (depth > state.limits.maxDepth)
@@ -43467,7 +43485,7 @@ function createReplayableRandom(options = {}) {
43467
43485
 
43468
43486
  // packages/safe-js/src/realm.ts
43469
43487
  import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
43470
- import { types as types9 } from "node:util";
43488
+ import { types as types11 } from "node:util";
43471
43489
 
43472
43490
  // packages/safe-js/src/modules/registry.ts
43473
43491
  function createUnknownModuleMessage2(moduleName, moduleNames) {
@@ -43606,7 +43624,7 @@ var RealmState = class {
43606
43624
  throw new TypeError("Realm limits must be positive safe integers with supported names.");
43607
43625
  this.limits[name] = Number(value);
43608
43626
  }
43609
- if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types9.isProxy(options.extensions)))
43627
+ if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types11.isProxy(options.extensions)))
43610
43628
  throw new TypeError("Extensions must be a registration array.");
43611
43629
  const registrations = options.extensions ?? [];
43612
43630
  const extensions = [];
@@ -43841,7 +43859,7 @@ var RealmState = class {
43841
43859
  return this.phase.run(phase, () => {
43842
43860
  try {
43843
43861
  const result = call();
43844
- if (types9.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
43862
+ if (types11.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
43845
43863
  return Promise.resolve(result).then(
43846
43864
  async (value) => {
43847
43865
  await Promise.allSettled(phase.pending);
@@ -43910,7 +43928,7 @@ var RealmState = class {
43910
43928
  },
43911
43929
  read: (operation, validate) => {
43912
43930
  const value = this.invokeHost(operation, operation);
43913
- if (types9.isPromise(value)) {
43931
+ if (types11.isPromise(value)) {
43914
43932
  void Promise.resolve(value).catch(() => void 0);
43915
43933
  throw new TypeError("Live property operations must be synchronous.");
43916
43934
  }
@@ -43918,7 +43936,7 @@ var RealmState = class {
43918
43936
  },
43919
43937
  write: (operation, value) => {
43920
43938
  const result = this.invokeHost(operation, () => operation(this.exportValue(value)));
43921
- if (types9.isPromise(result)) {
43939
+ if (types11.isPromise(result)) {
43922
43940
  void Promise.resolve(result).catch(() => void 0);
43923
43941
  throw new TypeError("Live property setters must be synchronous.");
43924
43942
  }
@@ -44127,7 +44145,7 @@ var RealmState = class {
44127
44145
  }
44128
44146
  });
44129
44147
  const output = getExtensionSetup(extension)(context);
44130
- if (types9.isPromise(output)) {
44148
+ if (types11.isPromise(output)) {
44131
44149
  void Promise.resolve(output).catch(() => void 0);
44132
44150
  throw new TypeError("Extension setup must be synchronous.");
44133
44151
  }
@@ -44319,7 +44337,7 @@ var RealmState = class {
44319
44337
  };
44320
44338
  function readModules(input) {
44321
44339
  const entries = (value, label) => {
44322
- if (types9.isMap(value) && !types9.isProxy(value)) {
44340
+ if (types11.isMap(value) && !types11.isProxy(value)) {
44323
44341
  const result = [...Map.prototype.entries.call(value)];
44324
44342
  if (result.length > 4096 || result.some(([key]) => typeof key !== "string" || key.length === 0))
44325
44343
  throw new TypeError(`${label} requires bounded string keys.`);
@@ -45589,4 +45607,4 @@ export {
45589
45607
  FileSnapshotBackend,
45590
45608
  run
45591
45609
  };
45592
- //# sourceMappingURL=chunk-7Y4M6UQR.js.map
45610
+ //# sourceMappingURL=chunk-OGZMY5KV.js.map