@poe-platform/safe-js 0.1.730 → 0.1.732

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 (100) hide show
  1. package/README.md +5 -5
  2. package/dist/safe-js/chunks/{chunk-SJZWSPWD.js → chunk-2GVBG23M.js} +1 -1
  3. package/dist/safe-js/chunks/{chunk-SJZWSPWD.js.map → chunk-2GVBG23M.js.map} +1 -1
  4. package/dist/safe-js/chunks/{chunk-MW2QLYVN.js → chunk-3ITVV2R6.js} +77 -66
  5. package/dist/safe-js/chunks/chunk-3ITVV2R6.js.map +7 -0
  6. package/dist/safe-js/chunks/{chunk-VIMROAQA.js → chunk-E4XLBT7R.js} +2 -2
  7. package/dist/safe-js/chunks/chunk-F6CV74HU.js +114 -0
  8. package/dist/safe-js/chunks/chunk-F6CV74HU.js.map +7 -0
  9. package/dist/safe-js/chunks/{chunk-OZLTLIHX.js → chunk-G6WTEIJJ.js} +2 -2
  10. package/dist/safe-js/chunks/{chunk-XX57YCGZ.js → chunk-GNEORAQI.js} +55 -50
  11. package/dist/safe-js/chunks/chunk-GNEORAQI.js.map +7 -0
  12. package/dist/safe-js/chunks/chunk-GVKXZW53.js +76 -0
  13. package/dist/safe-js/chunks/chunk-GVKXZW53.js.map +7 -0
  14. package/dist/safe-js/chunks/{chunk-MRULOD5J.js → chunk-K4T4EBED.js} +59 -38
  15. package/dist/safe-js/chunks/chunk-K4T4EBED.js.map +7 -0
  16. package/dist/safe-js/chunks/{chunk-MFCEBCGV.js → chunk-KETIFEA7.js} +17 -8
  17. package/dist/safe-js/chunks/chunk-KETIFEA7.js.map +7 -0
  18. package/dist/safe-js/chunks/{chunk-S5YDMMM3.js → chunk-MDIWQFYU.js} +95 -169
  19. package/dist/safe-js/chunks/{chunk-S5YDMMM3.js.map → chunk-MDIWQFYU.js.map} +4 -4
  20. package/dist/safe-js/chunks/{chunk-EN724VH3.js → chunk-O4IDRXW7.js} +4 -4
  21. package/dist/safe-js/chunks/{chunk-3LSNBW5N.js → chunk-P64CQIUA.js} +4 -4
  22. package/dist/safe-js/chunks/{chunk-EA7AHM2X.js → chunk-PSVV3IG2.js} +3 -3
  23. package/dist/safe-js/chunks/{chunk-Y5EZYHU6.js → chunk-QKO4FATZ.js} +33 -5
  24. package/dist/safe-js/chunks/chunk-QKO4FATZ.js.map +7 -0
  25. package/dist/safe-js/chunks/{chunk-EG3QWREA.js → chunk-RULU2F5J.js} +2 -2
  26. package/dist/safe-js/chunks/chunk-UQPYTZOZ.js +72 -0
  27. package/dist/safe-js/chunks/chunk-UQPYTZOZ.js.map +7 -0
  28. package/dist/safe-js/chunks/{chunk-LRSWTDIV.js → chunk-W4SWUHCQ.js} +58 -23
  29. package/dist/safe-js/chunks/chunk-W4SWUHCQ.js.map +7 -0
  30. package/dist/safe-js/chunks/{chunk-W3IY6FKO.js → chunk-WS2FJBH6.js} +2 -2
  31. package/dist/safe-js/chunks/{chunk-MVLDRXWS.js → chunk-X3CKAZQ4.js} +3 -3
  32. package/dist/safe-js/chunks/chunk-YUQFFRUF.js +26 -0
  33. package/dist/safe-js/chunks/chunk-YUQFFRUF.js.map +7 -0
  34. package/dist/safe-js/chunks/{cli-runtime-WSVW5DNT.js → cli-runtime-ZSOTNIVC.js} +51 -30
  35. package/dist/safe-js/chunks/cli-runtime-ZSOTNIVC.js.map +7 -0
  36. package/dist/safe-js/chunks/{dump-UNYK24YS.js → dump-RGRC3CG3.js} +5 -4
  37. package/dist/safe-js/chunks/harness-UMOMFXDT.js +11 -0
  38. package/dist/safe-js/chunks/mcp-2Z4XWHKW.js +12 -0
  39. package/dist/safe-js/chunks/migration-file-KRXQYI3Q.js +15 -0
  40. package/dist/safe-js/chunks/restore-GEO7VN2R.js +14 -0
  41. package/dist/safe-js/chunks/run-ZSFX66RN.js +20 -0
  42. package/dist/safe-js/chunks/runtime-modules-A3U2DKFL.js +11 -0
  43. package/dist/safe-js/chunks/source-files-L3SGK63Z.js +10 -0
  44. package/dist/safe-js/cli-runtime.d.ts +2 -0
  45. package/dist/safe-js/cli.js +4 -4
  46. package/dist/safe-js/core.d.ts +1 -0
  47. package/dist/safe-js/core.js +15 -8
  48. package/dist/safe-js/error/shape.js +170 -0
  49. package/dist/safe-js/index.js +42 -33
  50. package/dist/safe-js/index.js.map +2 -2
  51. package/dist/safe-js/interp/budget.js +600 -0
  52. package/dist/safe-js/interp/internal-symbols.js +1 -0
  53. package/dist/safe-js/interp/promise-replay.d.ts +1 -1
  54. package/dist/safe-js/interp/template-cache.js +7 -0
  55. package/dist/safe-js/migration-file.d.ts +2 -0
  56. package/dist/safe-js/modules/fs-config.d.ts +3 -1
  57. package/dist/safe-js/modules/fs.d.ts +8 -4
  58. package/dist/safe-js/modules/fs.js +16 -0
  59. package/dist/safe-js/modules/source-files.d.ts +3 -2
  60. package/dist/safe-js/platform/context.js +58 -0
  61. package/dist/safe-js/platform/node.js +64 -0
  62. package/dist/safe-js/platform/types.js +63 -0
  63. package/dist/safe-js/platform/workerd.js +39 -0
  64. package/dist/safe-js/runner/run-harness.d.ts +2 -0
  65. package/dist/safe-js/snapshot/backend.d.ts +2 -0
  66. package/package.json +9 -2
  67. package/dist/safe-js/chunks/chunk-FCCA27RC.js +0 -69
  68. package/dist/safe-js/chunks/chunk-FCCA27RC.js.map +0 -7
  69. package/dist/safe-js/chunks/chunk-LRSWTDIV.js.map +0 -7
  70. package/dist/safe-js/chunks/chunk-MFCEBCGV.js.map +0 -7
  71. package/dist/safe-js/chunks/chunk-MRULOD5J.js.map +0 -7
  72. package/dist/safe-js/chunks/chunk-MW2QLYVN.js.map +0 -7
  73. package/dist/safe-js/chunks/chunk-XX57YCGZ.js.map +0 -7
  74. package/dist/safe-js/chunks/chunk-Y5EZYHU6.js.map +0 -7
  75. package/dist/safe-js/chunks/cli-runtime-WSVW5DNT.js.map +0 -7
  76. package/dist/safe-js/chunks/fs-AOV77RQC.js +0 -13
  77. package/dist/safe-js/chunks/harness-ZIEO7NAV.js +0 -10
  78. package/dist/safe-js/chunks/mcp-E2AJXEQM.js +0 -11
  79. package/dist/safe-js/chunks/migration-file-3SWGNDS2.js +0 -12
  80. package/dist/safe-js/chunks/restore-FCTWPLU3.js +0 -13
  81. package/dist/safe-js/chunks/run-ESJHEXCE.js +0 -17
  82. package/dist/safe-js/chunks/runtime-modules-7V6BWCRK.js +0 -10
  83. package/dist/safe-js/chunks/source-files-73OHLNGH.js +0 -8
  84. /package/dist/safe-js/chunks/{chunk-VIMROAQA.js.map → chunk-E4XLBT7R.js.map} +0 -0
  85. /package/dist/safe-js/chunks/{chunk-OZLTLIHX.js.map → chunk-G6WTEIJJ.js.map} +0 -0
  86. /package/dist/safe-js/chunks/{chunk-EN724VH3.js.map → chunk-O4IDRXW7.js.map} +0 -0
  87. /package/dist/safe-js/chunks/{chunk-3LSNBW5N.js.map → chunk-P64CQIUA.js.map} +0 -0
  88. /package/dist/safe-js/chunks/{chunk-EA7AHM2X.js.map → chunk-PSVV3IG2.js.map} +0 -0
  89. /package/dist/safe-js/chunks/{chunk-EG3QWREA.js.map → chunk-RULU2F5J.js.map} +0 -0
  90. /package/dist/safe-js/chunks/{chunk-W3IY6FKO.js.map → chunk-WS2FJBH6.js.map} +0 -0
  91. /package/dist/safe-js/chunks/{chunk-MVLDRXWS.js.map → chunk-X3CKAZQ4.js.map} +0 -0
  92. /package/dist/safe-js/chunks/{dump-UNYK24YS.js.map → dump-RGRC3CG3.js.map} +0 -0
  93. /package/dist/safe-js/chunks/{fs-AOV77RQC.js.map → harness-UMOMFXDT.js.map} +0 -0
  94. /package/dist/safe-js/chunks/{harness-ZIEO7NAV.js.map → mcp-2Z4XWHKW.js.map} +0 -0
  95. /package/dist/safe-js/chunks/{mcp-E2AJXEQM.js.map → migration-file-KRXQYI3Q.js.map} +0 -0
  96. /package/dist/safe-js/chunks/{migration-file-3SWGNDS2.js.map → restore-GEO7VN2R.js.map} +0 -0
  97. /package/dist/safe-js/chunks/{restore-FCTWPLU3.js.map → run-ZSFX66RN.js.map} +0 -0
  98. /package/dist/safe-js/chunks/{run-ESJHEXCE.js.map → runtime-modules-A3U2DKFL.js.map} +0 -0
  99. /package/dist/safe-js/chunks/{runtime-modules-7V6BWCRK.js.map → source-files-L3SGK63Z.js.map} +0 -0
  100. /package/dist/safe-js/{chunks/source-files-73OHLNGH.js.map → modules/fs.js.map} +0 -0
@@ -10,6 +10,7 @@ import {
10
10
  boundIdentifiers,
11
11
  compactDynamicNodes,
12
12
  containsParameterExpression,
13
+ createTrackedProxy,
13
14
  describeThrownValue,
14
15
  dynamicNodeSources,
15
16
  dynamicSourceRecords,
@@ -39,10 +40,15 @@ import {
39
40
  sandboxErrorTypes,
40
41
  syntaxDiagnostics,
41
42
  templateRealms
42
- } from "./chunk-Y5EZYHU6.js";
43
+ } from "./chunk-QKO4FATZ.js";
44
+ import {
45
+ AsyncLocalStorage,
46
+ cloneSharedBufferWrapper,
47
+ setImmediate,
48
+ types
49
+ } from "./chunk-UQPYTZOZ.js";
43
50
 
44
51
  // packages/safe-js/src/interp/native-promise-properties.ts
45
- import { types } from "node:util";
46
52
  var admittedSymbols = /* @__PURE__ */ new WeakMap();
47
53
  function admitNativePromiseProperties(value, keys) {
48
54
  if (!types.isPromise(value)) throw new TypeError("Property admission requires a native Promise.");
@@ -75,7 +81,6 @@ function nativePromiseDataProperties(value) {
75
81
  }
76
82
 
77
83
  // packages/safe-js/src/interp/resources.ts
78
- import { AsyncLocalStorage } from "node:async_hooks";
79
84
  var runResources = new AsyncLocalStorage();
80
85
  function retainValues(budget, values) {
81
86
  const retained = {};
@@ -132,10 +137,9 @@ async function withRunResources(signal, execute) {
132
137
  }
133
138
 
134
139
  // packages/safe-js/src/extensions.ts
135
- import { types as types2 } from "node:util";
136
140
  var definitions = /* @__PURE__ */ new WeakMap();
137
141
  function readDataRecord(value, label) {
138
- if (typeof value !== "object" || value === null || types2.isProxy(value)) {
142
+ if (typeof value !== "object" || value === null || types.isProxy(value)) {
139
143
  throw new TypeError(`${label} must be a plain data record.`);
140
144
  }
141
145
  const prototype = Object.getPrototypeOf(value);
@@ -155,7 +159,7 @@ function readDataRecord(value, label) {
155
159
  return result;
156
160
  }
157
161
  function readStringList(value, label) {
158
- if (!Array.isArray(value) || types2.isProxy(value) || value.length > 4096) {
162
+ if (!Array.isArray(value) || types.isProxy(value) || value.length > 4096) {
159
163
  throw new TypeError(`${label} must be a bounded string array.`);
160
164
  }
161
165
  const result = [];
@@ -177,7 +181,7 @@ function defineExtension(definition) {
177
181
  if (Object.keys(input).some((key) => key !== "manifest" && key !== "setup"))
178
182
  throw new TypeError("Unknown extension definition field.");
179
183
  if (typeof input.setup !== "function") throw new TypeError("Extension setup must be a function.");
180
- if (types2.isAsyncFunction(input.setup))
184
+ if (types.isAsyncFunction(input.setup))
181
185
  throw new TypeError("Extension setup must be synchronous.");
182
186
  const manifest = readDataRecord(input.manifest, "Extension manifest");
183
187
  if (Object.keys(manifest).some(
@@ -212,54 +216,6 @@ function getExtensionSetup(extension) {
212
216
  return setup;
213
217
  }
214
218
 
215
- // packages/safe-js/src/platform/node.ts
216
- import * as nodeUtil from "node:util";
217
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
218
- import { MessageChannel, MessagePort, receiveMessageOnPort } from "node:worker_threads";
219
- var nativeClone = structuredClone;
220
- var sharedByteLength = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
221
- var postMessage = MessagePort.prototype.postMessage;
222
- var closePort = MessagePort.prototype.close;
223
- var probe = new SharedArrayBuffer(1);
224
- var nativeSharesStorage = false;
225
- try {
226
- const copy = nativeClone(probe);
227
- Reflect.apply(sharedByteLength, copy, []);
228
- new Uint8Array(copy)[0] = 1;
229
- nativeSharesStorage = copy !== probe && new Uint8Array(probe)[0] === 1;
230
- } catch {
231
- }
232
- var cloneSharedBufferWrapper = nativeSharesStorage ? nativeClone : (value) => {
233
- Reflect.apply(sharedByteLength, value, []);
234
- const { port1, port2 } = new MessageChannel();
235
- try {
236
- Reflect.apply(postMessage, port1, [value]);
237
- const copy = receiveMessageOnPort(port2)?.message;
238
- Reflect.apply(sharedByteLength, copy, []);
239
- if (copy === value) throw new TypeError("Shared storage requires a distinct wrapper.");
240
- return copy;
241
- } finally {
242
- Reflect.apply(closePort, port1, []);
243
- Reflect.apply(closePort, port2, []);
244
- }
245
- };
246
- function createHostCallbackContext() {
247
- return new AsyncLocalStorage2();
248
- }
249
- var accessDeniedSystemError = readSystemError("EACCES");
250
- function readSystemError(code) {
251
- const fallback = /* @__PURE__ */ new Map([
252
- [process.platform === "win32" ? -4092 : -13, ["EACCES", "permission denied"]]
253
- ]);
254
- const systemErrors = nodeUtil.getSystemErrorMap?.() ?? fallback;
255
- for (const [errno, [name, message]] of systemErrors) {
256
- if (name === code) {
257
- return [errno, message];
258
- }
259
- }
260
- throw new Error(`node does not define the ${code} system error.`);
261
- }
262
-
263
219
  // packages/safe-js/src/interp/arguments.ts
264
220
  var sandboxArgumentsBrand = /* @__PURE__ */ Symbol("SandboxArguments");
265
221
  internalSymbols.add(sandboxArgumentsBrand);
@@ -279,7 +235,7 @@ function createMappedSandboxArguments(values, names, scope, callee) {
279
235
  if (!binding.found) throw new ReferenceError(`Missing mapped argument binding '${name}'.`);
280
236
  return binding.value;
281
237
  };
282
- const result = new Proxy(target, {
238
+ const result = createTrackedProxy(target, {
283
239
  get(object, key, receiver) {
284
240
  const name = typeof key === "string" ? parameters.get(key) : void 0;
285
241
  return name === void 0 ? Reflect.get(object, key, receiver) : parameterValue(name);
@@ -491,7 +447,6 @@ function isSandboxSet(value) {
491
447
  }
492
448
 
493
449
  // packages/safe-js/src/interp/boxed.ts
494
- import { types as types3 } from "node:util";
495
450
  var boxes = /* @__PURE__ */ new WeakSet();
496
451
  var numberValue = Number.prototype.valueOf;
497
452
  var stringValue = String.prototype.valueOf;
@@ -499,11 +454,11 @@ var booleanValue = Boolean.prototype.valueOf;
499
454
  var symbolValue = Symbol.prototype.valueOf;
500
455
  var bigintValue = BigInt.prototype.valueOf;
501
456
  function nativeBoxedValue(value) {
502
- if (types3.isNumberObject(value)) return Reflect.apply(numberValue, value, []);
503
- if (types3.isStringObject(value)) return Reflect.apply(stringValue, value, []);
504
- if (types3.isBooleanObject(value)) return Reflect.apply(booleanValue, value, []);
505
- if (types3.isSymbolObject(value)) return Reflect.apply(symbolValue, value, []);
506
- if (types3.isBigIntObject(value)) return Reflect.apply(bigintValue, value, []);
457
+ if (types.isNumberObject(value)) return Reflect.apply(numberValue, value, []);
458
+ if (types.isStringObject(value)) return Reflect.apply(stringValue, value, []);
459
+ if (types.isBooleanObject(value)) return Reflect.apply(booleanValue, value, []);
460
+ if (types.isSymbolObject(value)) return Reflect.apply(symbolValue, value, []);
461
+ if (types.isBigIntObject(value)) return Reflect.apply(bigintValue, value, []);
507
462
  return void 0;
508
463
  }
509
464
  function createSandboxBox(value) {
@@ -712,13 +667,12 @@ function readNativeSet(value, allowSubclass = false) {
712
667
  }
713
668
 
714
669
  // packages/safe-js/src/interp/native-constructor-name.ts
715
- import { types as types4 } from "node:util";
716
670
  function nativeConstructorName(value) {
717
- if (types4.isProxy(value)) return void 0;
671
+ if (types.isProxy(value)) return void 0;
718
672
  const prototype = Object.getPrototypeOf(value);
719
- const descriptor = Object.getOwnPropertyDescriptor(value, "constructor") ?? (prototype !== null && !types4.isProxy(prototype) ? Object.getOwnPropertyDescriptor(prototype, "constructor") : void 0);
673
+ const descriptor = Object.getOwnPropertyDescriptor(value, "constructor") ?? (prototype !== null && !types.isProxy(prototype) ? Object.getOwnPropertyDescriptor(prototype, "constructor") : void 0);
720
674
  const constructor = descriptor?.value;
721
- if (typeof constructor !== "function" || types4.isProxy(constructor)) return void 0;
675
+ if (typeof constructor !== "function" || types.isProxy(constructor)) return void 0;
722
676
  const name = Object.getOwnPropertyDescriptor(constructor, "name")?.value;
723
677
  return typeof name === "string" ? name : void 0;
724
678
  }
@@ -1191,7 +1145,7 @@ function isSandboxModuleNamespace(value) {
1191
1145
  }
1192
1146
  function createModuleNamespace(bindings, read, retained) {
1193
1147
  const target = /* @__PURE__ */ Object.create(null);
1194
- const namespace = new Proxy(target, {
1148
+ const namespace = createTrackedProxy(target, {
1195
1149
  ownKeys: (owner) => [...Object.getOwnPropertyNames(owner).sort(), ...Object.getOwnPropertySymbols(owner)],
1196
1150
  set: () => false,
1197
1151
  get(owner, key) {
@@ -1220,14 +1174,12 @@ function createModuleNamespace(bindings, read, retained) {
1220
1174
  return namespace;
1221
1175
  }
1222
1176
 
1223
- // packages/safe-js/src/interp/array-buffer.ts
1224
- import { types as types5 } from "node:util";
1225
-
1226
1177
  // packages/safe-js/src/interp/shared-array-buffer.ts
1178
+ var sharedPrototype = globalThis.SharedArrayBuffer?.prototype ?? /* @__PURE__ */ Object.create(null);
1227
1179
  var sharedArrayBufferPrototypes = /* @__PURE__ */ new WeakMap();
1228
- var readByteLength = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
1229
- var readMaxByteLength = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "maxByteLength")?.get;
1230
- var readGrowable = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "growable")?.get;
1180
+ var readByteLength = Object.getOwnPropertyDescriptor(sharedPrototype, "byteLength")?.get;
1181
+ var readMaxByteLength = Object.getOwnPropertyDescriptor(sharedPrototype, "maxByteLength")?.get;
1182
+ var readGrowable = Object.getOwnPropertyDescriptor(sharedPrototype, "growable")?.get;
1231
1183
  var sharedBlocks = /* @__PURE__ */ new WeakMap();
1232
1184
  function isSandboxSharedArrayBuffer(value) {
1233
1185
  return typeof value === "object" && value !== null && sharedBlocks.has(value);
@@ -1237,6 +1189,7 @@ function createSharedArrayBufferStorage(length, maxByteLength, budget) {
1237
1189
  throw new RangeError("Invalid SharedArrayBuffer capacity.");
1238
1190
  if (maxByteLength !== void 0 && readGrowable === void 0)
1239
1191
  throw new TypeError("Growable SharedArrayBuffer requires host runtime support.");
1192
+ requireSharedByteLength();
1240
1193
  budget.allocateArrayLength(maxByteLength ?? length);
1241
1194
  budget.provisionDataUsage(length + 1)();
1242
1195
  const buffer = Reflect.construct(SharedArrayBuffer, [
@@ -1249,7 +1202,7 @@ function createSharedArrayBufferStorage(length, maxByteLength, budget) {
1249
1202
  function sharedArrayBufferStorage(value) {
1250
1203
  const block = sharedBlocks.get(value);
1251
1204
  if (block === void 0) throw new TypeError("Shared storage is not owned by the sandbox.");
1252
- const byteLength = Reflect.apply(readByteLength, value, []);
1205
+ const byteLength = Reflect.apply(requireSharedByteLength(), value, []);
1253
1206
  const growable = readGrowable !== void 0 && Reflect.apply(readGrowable, value, []);
1254
1207
  return {
1255
1208
  block,
@@ -1274,6 +1227,10 @@ function snapshotSharedArrayBufferStorage(value, copies) {
1274
1227
  copies.set(storage.block, copy);
1275
1228
  return copy;
1276
1229
  }
1230
+ function requireSharedByteLength() {
1231
+ if (readByteLength === void 0) throw new TypeError("SharedArrayBuffer requires host runtime support.");
1232
+ return readByteLength;
1233
+ }
1277
1234
 
1278
1235
  // packages/safe-js/src/interp/array-buffer.ts
1279
1236
  var readLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
@@ -1282,7 +1239,7 @@ var readMaxLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "maxB
1282
1239
  var readDetached = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "detached")?.get;
1283
1240
  var arrayBufferPrototypes = /* @__PURE__ */ new WeakMap();
1284
1241
  function isSandboxArrayBuffer(value) {
1285
- return types5.isArrayBuffer(value) && Object.getPrototypeOf(value) === ArrayBuffer.prototype;
1242
+ return types.isArrayBuffer(value) && Object.getPrototypeOf(value) === ArrayBuffer.prototype;
1286
1243
  }
1287
1244
  function arrayBufferLength(value) {
1288
1245
  if (isSandboxSharedArrayBuffer(value)) return sharedArrayBufferStorage(value).byteLength;
@@ -1325,13 +1282,12 @@ function arrayBufferDataProperties(value) {
1325
1282
  }
1326
1283
 
1327
1284
  // packages/safe-js/src/interp/data-view.ts
1328
- import { types as types6 } from "node:util";
1329
1285
  var dataViewPrototypes = /* @__PURE__ */ new WeakMap();
1330
1286
  var dataViewLayouts = /* @__PURE__ */ new WeakMap();
1331
1287
  var dataViewGetters = Object.fromEntries(["buffer", "byteOffset", "byteLength"].map((key) => [key, Object.getOwnPropertyDescriptor(DataView.prototype, key).get]));
1332
1288
  var resize = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize")?.value;
1333
1289
  function isSandboxDataView(value) {
1334
- return types6.isDataView(value) && Object.getPrototypeOf(value) === DataView.prototype;
1290
+ return types.isDataView(value) && Object.getPrototypeOf(value) === DataView.prototype;
1335
1291
  }
1336
1292
  function dataViewBuffer(value) {
1337
1293
  const buffer = Reflect.apply(dataViewGetters.buffer, value, []);
@@ -1571,14 +1527,9 @@ async function invokeBuiltinClosure(closure, args, budget, context, thisValue, c
1571
1527
  import { sha256 } from "@noble/hashes/sha2.js";
1572
1528
  import { bytesToHex } from "@noble/hashes/utils.js";
1573
1529
 
1574
- // packages/safe-js/src/interp/promise-tracker.ts
1575
- import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
1576
-
1577
1530
  // packages/safe-js/src/interp/jobs.ts
1578
- import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
1579
- import { setImmediate as yieldToHost } from "node:timers/promises";
1580
- var activeJob = new AsyncLocalStorage3();
1581
- var activeAttribution = new AsyncLocalStorage3();
1531
+ var activeJob = new AsyncLocalStorage();
1532
+ var activeAttribution = new AsyncLocalStorage();
1582
1533
  function currentJobAttribution() {
1583
1534
  const job = activeJob.getStore();
1584
1535
  const scoped = activeAttribution.getStore();
@@ -1688,7 +1639,7 @@ var SandboxJobQueue = class {
1688
1639
  }
1689
1640
  if (--queue.nodesUntilHostTurn > 0 && Date.now() - queue.lastHostTurn < 16) return;
1690
1641
  queue.nodesUntilHostTurn = 4096;
1691
- return yieldToHost().then(() => {
1642
+ return setImmediate().then(() => {
1692
1643
  queue.lastHostTurn = Date.now();
1693
1644
  if (queue.pauseRequest === void 0) return;
1694
1645
  queue.pauseRequest.acknowledged = true;
@@ -1794,7 +1745,7 @@ function runPromiseJob(task) {
1794
1745
  }
1795
1746
  function captureJobScheduler() {
1796
1747
  const queue = activeJob.getStore()?.queue ?? new SandboxJobQueue();
1797
- const context = AsyncLocalStorage3.snapshot();
1748
+ const context = AsyncLocalStorage.snapshot();
1798
1749
  const attribution = captureJobAttribution();
1799
1750
  return (task) => context(() => attribution(() => queue.run(task)));
1800
1751
  }
@@ -1950,8 +1901,8 @@ var SandboxPromiseRejectionTracker = class {
1950
1901
  return void 0;
1951
1902
  }
1952
1903
  };
1953
- var activePromiseTracker = new AsyncLocalStorage4();
1954
- var fatalRejectionCleanup = new AsyncLocalStorage4();
1904
+ var activePromiseTracker = new AsyncLocalStorage();
1905
+ var fatalRejectionCleanup = new AsyncLocalStorage();
1955
1906
  function assertPromiseExecutionAllowed() {
1956
1907
  const failure = activePromiseTracker.getStore()?.failure;
1957
1908
  if (failure !== void 0 && fatalRejectionCleanup.getStore() !== true) throw failure;
@@ -1986,9 +1937,6 @@ async function flushPromiseJobs() {
1986
1937
  }
1987
1938
  }
1988
1939
 
1989
- // packages/safe-js/src/interp/promise-replay.ts
1990
- import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
1991
-
1992
1940
  // packages/safe-js/src/snapshot/bigint.ts
1993
1941
  function validateBigIntData(value) {
1994
1942
  if (typeof value !== "string" || value.length === 0) throw new TypeError("Invalid BigInt snapshot value.");
@@ -2091,9 +2039,6 @@ function restoreRegexProperties(value, data, decode) {
2091
2039
  if (data.extensible === false) Object.preventExtensions(properties);
2092
2040
  }
2093
2041
 
2094
- // packages/safe-js/src/snapshot/validation.ts
2095
- import { types as types20 } from "node:util";
2096
-
2097
2042
  // packages/safe-js/src/parse/dynamic-source.ts
2098
2043
  function createModuleSource(body, owner) {
2099
2044
  const limit = owner?.budget.limits.stringLength;
@@ -2257,7 +2202,7 @@ function createOwnedTypedArray(Native, args) {
2257
2202
  const view = Reflect.construct(Native, args);
2258
2203
  const keys = /* @__PURE__ */ new Set();
2259
2204
  const methods4 = /* @__PURE__ */ new WeakMap();
2260
- const owned = new Proxy(view, {
2205
+ const owned = createTrackedProxy(view, {
2261
2206
  get(target, key, receiver) {
2262
2207
  const intrinsic = Object.getOwnPropertyDescriptor(
2263
2208
  typedArrayPrototype,
@@ -2622,7 +2567,6 @@ function serializedDateTime(value) {
2622
2567
  }
2623
2568
 
2624
2569
  // packages/safe-js/src/interp/host-capabilities.ts
2625
- import { types as types7 } from "node:util";
2626
2570
  var MAX_INDEXED_LENGTH = 65536;
2627
2571
  var MAX_NAMED_KEYS = 65536;
2628
2572
  var MAX_NAMED_KEY_CODE_UNITS = 1048576;
@@ -2686,7 +2630,7 @@ function createLiveHostObject(definition, controller) {
2686
2630
  if (typeof data[key] !== "number" || !Number.isInteger(data[key]) || data[key] < 1 || data[key] > maximum)
2687
2631
  throw new RangeError(`Guest expando ${key} must be an integer from 1 to ${maximum}.`);
2688
2632
  }
2689
- if (data.assertActive !== void 0 && (typeof data.assertActive !== "function" || types7.isProxy(data.assertActive) || types7.isAsyncFunction(data.assertActive) || types7.isGeneratorFunction(data.assertActive)))
2633
+ if (data.assertActive !== void 0 && (typeof data.assertActive !== "function" || types.isProxy(data.assertActive) || types.isAsyncFunction(data.assertActive) || types.isGeneratorFunction(data.assertActive)))
2690
2634
  throw new TypeError("Guest expando assertActive must be a synchronous function, not a proxy.");
2691
2635
  expandos = {
2692
2636
  // Owned writes invalidate descriptor projections; descendants stay live.
@@ -2721,7 +2665,7 @@ function createLiveHostObject(definition, controller) {
2721
2665
  for (const name of ["keys", "get", "set", "delete"]) {
2722
2666
  const operation = data[name];
2723
2667
  if (operation === void 0 && (name === "set" || name === "delete")) continue;
2724
- if (typeof operation !== "function" || types7.isProxy(operation) || types7.isAsyncFunction(operation) || types7.isGeneratorFunction(operation))
2668
+ if (typeof operation !== "function" || types.isProxy(operation) || types.isAsyncFunction(operation) || types.isGeneratorFunction(operation))
2725
2669
  throw new TypeError(`Named ${name} must be a synchronous non-generator function, not a proxy.`);
2726
2670
  }
2727
2671
  if (typeof data.maxKeys !== "number" || !Number.isInteger(data.maxKeys) || data.maxKeys < 1 || data.maxKeys > MAX_NAMED_KEYS)
@@ -3020,7 +2964,7 @@ function namedMutationKeys(state, key, create3) {
3020
2964
  function namedKeys(state) {
3021
2965
  const named = state.named;
3022
2966
  return state.controller.read(named.keys, (value) => {
3023
- if (!Array.isArray(value) || types7.isProxy(value))
2967
+ if (!Array.isArray(value) || types.isProxy(value))
3024
2968
  throw new TypeError("Named keys must be a dense own-data array of strings, not a proxy.");
3025
2969
  const length = Object.getOwnPropertyDescriptor(value, "length").value;
3026
2970
  if (length > named.maxKeys) throw new RangeError("Named keys exceed maxKeys.");
@@ -3057,7 +3001,7 @@ function expandoKeyUnits(key) {
3057
3001
  }
3058
3002
  function assertExpandoActive(state) {
3059
3003
  const result = state.expandos?.assertActive?.();
3060
- if (types7.isPromise(result)) void Promise.resolve(result).catch(() => void 0);
3004
+ if (types.isPromise(result)) void Promise.resolve(result).catch(() => void 0);
3061
3005
  if (result !== void 0) throw new TypeError("Guest expando assertActive must return undefined.");
3062
3006
  }
3063
3007
  function validateExpandoKey(state, key, create3 = true) {
@@ -4430,8 +4374,7 @@ function getRegExpIteratorMember(property, budget) {
4430
4374
  }
4431
4375
 
4432
4376
  // packages/safe-js/src/interp/cancel.ts
4433
- import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
4434
- var activeCancellation = new AsyncLocalStorage5();
4377
+ var activeCancellation = new AsyncLocalStorage();
4435
4378
  var sandboxPromises = /* @__PURE__ */ new WeakSet();
4436
4379
  var cancelableOutcomes = /* @__PURE__ */ new WeakMap();
4437
4380
  function withCancellationSignal(signal, task) {
@@ -7636,7 +7579,7 @@ async function arrayLikeView(receiver, options) {
7636
7579
  const rawLength = options.context?.getProperty !== void 0 ? await options.context.getProperty(receiver, "length") : getSandboxDataProperty(receiver, "length", options.budget);
7637
7580
  const number = await sandboxNumber(rawLength, options.budget, options.context);
7638
7581
  const length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
7639
- const view = new Proxy(
7582
+ const view = createTrackedProxy(
7640
7583
  /* @__PURE__ */ Object.create(null),
7641
7584
  {
7642
7585
  get: (_target, key) => {
@@ -17767,9 +17710,6 @@ async function sandboxSetProperty(target, key, value, receiver, budget, context)
17767
17710
  }
17768
17711
  }
17769
17712
 
17770
- // packages/safe-js/src/interp/methods/string.ts
17771
- import { types as types9 } from "node:util";
17772
-
17773
17713
  // packages/safe-js/src/interp/intl-collator.ts
17774
17714
  var NativeCollator = Intl.Collator;
17775
17715
  var nativeResolvedOptions2 = NativeCollator.prototype.resolvedOptions;
@@ -17892,13 +17832,12 @@ async function createStringHtml(value, [tag, attribute], argument, budget, conte
17892
17832
  }
17893
17833
 
17894
17834
  // packages/safe-js/src/interp/methods/string-search.ts
17895
- import { types as types8 } from "node:util";
17896
17835
  async function callStringSearch(value, method, args, budget, context) {
17897
17836
  const search = args[0];
17898
17837
  let text;
17899
17838
  const release = retainValues(budget, () => [value, ...args, text]);
17900
17839
  try {
17901
- if (types8.isRegExp(search)) throw new TypeError("String search does not accept unbranded host RegExp values.");
17840
+ if (types.isRegExp(search)) throw new TypeError("String search does not accept unbranded host RegExp values.");
17902
17841
  if (method !== "indexOf" && method !== "lastIndexOf" && search !== null && typeof search === "object") {
17903
17842
  const match = context?.getProperty !== void 0 ? await context.getProperty(search, Symbol.match) : await sandboxGetProperty(search, Symbol.match, search, budget, context);
17904
17843
  if (match === void 0 ? isSandboxRegex(search) : Boolean(match))
@@ -18052,7 +17991,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
18052
17991
  };
18053
17992
  const symbol = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "matchAll" ? Symbol.matchAll : methodName === "replace" || methodName === "replaceAll" ? Symbol.replace : methodName === "split" ? Symbol.split : void 0;
18054
17993
  const pattern = args[0];
18055
- if (symbol !== void 0 && types9.isRegExp(pattern))
17994
+ if (symbol !== void 0 && types.isRegExp(pattern))
18056
17995
  throw new TypeError(`String#${methodName} does not accept unbranded host RegExp values.`);
18057
17996
  if (symbol === void 0 || pattern === null || pattern === void 0) return fallback();
18058
17997
  const readProperty = (key) => context?.getProperty !== void 0 ? context.getProperty(pattern, key) : key === "flags" && isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, key, budget) === void 0 ? getRegexMember(pattern, key, budget, context) : getSandboxDataProperty(pattern, key, budget);
@@ -19010,9 +18949,6 @@ function formatNumber(value, methodName, argument, budget) {
19010
18949
  return budget.allocateString(result);
19011
18950
  }
19012
18951
 
19013
- // packages/safe-js/src/interp/host-bridge.ts
19014
- import { types as types18 } from "node:util";
19015
-
19016
18952
  // packages/safe-js/src/interp/promise-state.ts
19017
18953
  var promiseStates = /* @__PURE__ */ new WeakMap();
19018
18954
  var importedPromises = /* @__PURE__ */ new WeakSet();
@@ -19023,7 +18959,6 @@ var importedPromiseSnapshots = /* @__PURE__ */ new WeakMap();
19023
18959
  var moduleFunctionOrigins = /* @__PURE__ */ new WeakMap();
19024
18960
 
19025
18961
  // packages/safe-js/src/interp/temporal-instant.ts
19026
- import { types as types10 } from "node:util";
19027
18962
  import { Temporal as TemporalBackend } from "temporal-polyfill/full/implementation";
19028
18963
  var nativeTemporal = Object.getOwnPropertyDescriptor(globalThis, "Temporal")?.value;
19029
18964
  var NativeInstant = nativeTemporal !== null && typeof nativeTemporal === "object" ? Object.getOwnPropertyDescriptor(nativeTemporal, "Instant")?.value : void 0;
@@ -19040,7 +18975,7 @@ function createHostTemporalInstant(epoch) {
19040
18975
  return value;
19041
18976
  }
19042
18977
  function hostTemporalInstantEpoch(value) {
19043
- if (typeof value !== "object" || value === null || types10.isProxy(value)) return void 0;
18978
+ if (typeof value !== "object" || value === null || types.isProxy(value)) return void 0;
19044
18979
  const prototype = Object.getPrototypeOf(value);
19045
18980
  const readEpoch = hostEpochReaders.get(prototype);
19046
18981
  if (readEpoch !== void 0) return Reflect.apply(readEpoch, value, []);
@@ -19068,7 +19003,6 @@ function temporalInstantEpoch(value) {
19068
19003
 
19069
19004
  // packages/safe-js/src/interp/temporal-duration.ts
19070
19005
  import { Temporal as TemporalBackend2 } from "temporal-polyfill/full/implementation";
19071
- import { types as types11 } from "node:util";
19072
19006
  var nativeTemporal2 = Object.getOwnPropertyDescriptor(globalThis, "Temporal")?.value;
19073
19007
  var NativeDuration = nativeTemporal2 !== null && typeof nativeTemporal2 === "object" ? Object.getOwnPropertyDescriptor(nativeTemporal2, "Duration")?.value : void 0;
19074
19008
  var HostDuration = NativeDuration ?? TemporalBackend2.Duration;
@@ -19095,7 +19029,7 @@ function createHostTemporalDuration(fields2) {
19095
19029
  return value;
19096
19030
  }
19097
19031
  function hostTemporalDurationFields(value) {
19098
- if (typeof value !== "object" || value === null || types11.isProxy(value)) return void 0;
19032
+ if (typeof value !== "object" || value === null || types.isProxy(value)) return void 0;
19099
19033
  const prototype = Object.getPrototypeOf(value);
19100
19034
  let readers = hostFieldReaders.get(prototype);
19101
19035
  if (readers === void 0) {
@@ -19107,7 +19041,7 @@ function hostTemporalDurationFields(value) {
19107
19041
  }
19108
19042
  var durations = /* @__PURE__ */ new WeakMap();
19109
19043
  function createSandboxTemporalDuration(input = {}) {
19110
- if (input === null || typeof input !== "object" || types11.isProxy(input))
19044
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19111
19045
  throw new TypeError("Duration fields must be an ordinary data record.");
19112
19046
  const fields2 = /* @__PURE__ */ Object.create(null);
19113
19047
  let sign = 0;
@@ -19147,7 +19081,6 @@ function temporalDurationFields(value) {
19147
19081
  }
19148
19082
 
19149
19083
  // packages/safe-js/src/interp/temporal-plain-time.ts
19150
- import { types as types12 } from "node:util";
19151
19084
  import { Temporal as TemporalBackend3 } from "temporal-polyfill/full/implementation";
19152
19085
  var timeFieldLimits = { hour: 24, minute: 60, second: 60, millisecond: 1e3, microsecond: 1e3, nanosecond: 1e3 };
19153
19086
  var temporalPlainTimeFieldNames = Object.freeze(Object.keys(timeFieldLimits));
@@ -19165,7 +19098,7 @@ function createHostTemporalPlainTime(fields2) {
19165
19098
  return value;
19166
19099
  }
19167
19100
  function hostTemporalPlainTimeFields(value) {
19168
- if (typeof value !== "object" || value === null || types12.isProxy(value)) return void 0;
19101
+ if (typeof value !== "object" || value === null || types.isProxy(value)) return void 0;
19169
19102
  const prototype = Object.getPrototypeOf(value);
19170
19103
  let readers = hostFieldReaders2.get(prototype);
19171
19104
  if (readers === void 0) {
@@ -19177,7 +19110,7 @@ function hostTemporalPlainTimeFields(value) {
19177
19110
  }
19178
19111
  var times = /* @__PURE__ */ new WeakMap();
19179
19112
  function createSandboxTemporalPlainTime(input = {}) {
19180
- if (input === null || typeof input !== "object" || types12.isProxy(input))
19113
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19181
19114
  throw new TypeError("PlainTime fields must be an ordinary data record.");
19182
19115
  const fields2 = /* @__PURE__ */ Object.create(null);
19183
19116
  for (const name of temporalPlainTimeFieldNames) {
@@ -19203,7 +19136,6 @@ function temporalPlainTimeFields(value) {
19203
19136
  }
19204
19137
 
19205
19138
  // packages/safe-js/src/interp/temporal-plain-date-time.ts
19206
- import { types as types13 } from "node:util";
19207
19139
  import { Temporal as Backend } from "temporal-polyfill/full/implementation";
19208
19140
  var temporalPlainDateTimeNumericFields = Object.freeze([
19209
19141
  "isoYear",
@@ -19235,7 +19167,7 @@ function createHostTemporalPlainDateTime(fields2) {
19235
19167
  return value;
19236
19168
  }
19237
19169
  function hostTemporalPlainDateTimeFields(value) {
19238
- if (value === null || typeof value !== "object" || types13.isProxy(value)) return void 0;
19170
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return void 0;
19239
19171
  const prototype = Object.getPrototypeOf(value);
19240
19172
  let readers = hostReaders.get(prototype);
19241
19173
  if (readers === void 0) {
@@ -19250,7 +19182,7 @@ function hostTemporalPlainDateTimeFields(value) {
19250
19182
  });
19251
19183
  }
19252
19184
  function createSandboxTemporalPlainDateTime(input) {
19253
- if (input === null || typeof input !== "object" || types13.isProxy(input))
19185
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19254
19186
  throw new TypeError("PlainDateTime fields must be an ordinary data record.");
19255
19187
  const fields2 = /* @__PURE__ */ Object.create(null);
19256
19188
  for (const [index, name] of temporalPlainDateTimeNumericFields.entries()) {
@@ -19291,7 +19223,6 @@ function temporalPlainDateTimeFields(value) {
19291
19223
  }
19292
19224
 
19293
19225
  // packages/safe-js/src/interp/temporal-plain-date.ts
19294
- import { types as types14 } from "node:util";
19295
19226
  import { Temporal as Backend2 } from "temporal-polyfill/full/implementation";
19296
19227
  var temporalPlainDateNumericFields = Object.freeze(["isoYear", "isoMonth", "isoDay"]);
19297
19228
  var dates2 = /* @__PURE__ */ new WeakMap();
@@ -19310,7 +19241,7 @@ function createHostTemporalPlainDate(fields2) {
19310
19241
  return value;
19311
19242
  }
19312
19243
  function hostTemporalPlainDateFields(value) {
19313
- if (value === null || typeof value !== "object" || types14.isProxy(value)) return void 0;
19244
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return void 0;
19314
19245
  const prototype = Object.getPrototypeOf(value);
19315
19246
  let readers = hostReaders2.get(prototype);
19316
19247
  if (readers === void 0) {
@@ -19325,7 +19256,7 @@ function hostTemporalPlainDateFields(value) {
19325
19256
  });
19326
19257
  }
19327
19258
  function createSandboxTemporalPlainDate(input) {
19328
- if (input === null || typeof input !== "object" || types14.isProxy(input))
19259
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19329
19260
  throw new TypeError("PlainDate fields must be an ordinary data record.");
19330
19261
  const fields2 = /* @__PURE__ */ Object.create(null);
19331
19262
  for (const name of temporalPlainDateNumericFields) {
@@ -19359,7 +19290,6 @@ function temporalPlainDateFields(value) {
19359
19290
  }
19360
19291
 
19361
19292
  // packages/safe-js/src/interp/temporal-plain-month-day.ts
19362
- import { types as types15 } from "node:util";
19363
19293
  import { Temporal as Backend3 } from "temporal-polyfill/full/implementation";
19364
19294
  var monthDays = /* @__PURE__ */ new WeakMap();
19365
19295
  var nativeTemporal6 = Object.getOwnPropertyDescriptor(globalThis, "Temporal")?.value;
@@ -19374,7 +19304,7 @@ function createHostTemporalPlainMonthDay(fields2) {
19374
19304
  return value;
19375
19305
  }
19376
19306
  function hostTemporalPlainMonthDayFields(value) {
19377
- if (value === null || typeof value !== "object" || types15.isProxy(value)) return void 0;
19307
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return void 0;
19378
19308
  const prototype = Object.getPrototypeOf(value);
19379
19309
  let format5 = hostFormatters.get(prototype);
19380
19310
  if (format5 === void 0) {
@@ -19386,7 +19316,7 @@ function hostTemporalPlainMonthDayFields(value) {
19386
19316
  return hostTemporalPlainDateFields(Reflect.apply(dateFrom, Backend3.PlainDate, [text]));
19387
19317
  }
19388
19318
  function createSandboxTemporalPlainMonthDay(input) {
19389
- if (input === null || typeof input !== "object" || types15.isProxy(input))
19319
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19390
19320
  throw new TypeError("PlainMonthDay fields must be an ordinary data record.");
19391
19321
  const fields2 = /* @__PURE__ */ Object.create(null);
19392
19322
  for (const name of temporalPlainDateNumericFields) {
@@ -19420,7 +19350,6 @@ function temporalPlainMonthDayFields(value) {
19420
19350
  }
19421
19351
 
19422
19352
  // packages/safe-js/src/interp/temporal-plain-year-month.ts
19423
- import { types as types16 } from "node:util";
19424
19353
  import { Temporal as Backend4 } from "temporal-polyfill/full/implementation";
19425
19354
  var yearMonths = /* @__PURE__ */ new WeakMap();
19426
19355
  var nativeTemporal7 = Object.getOwnPropertyDescriptor(globalThis, "Temporal")?.value;
@@ -19437,7 +19366,7 @@ function createHostTemporalPlainYearMonth(fields2) {
19437
19366
  return value;
19438
19367
  }
19439
19368
  function hostTemporalPlainYearMonthFields(value) {
19440
- if (value === null || typeof value !== "object" || types16.isProxy(value)) return void 0;
19369
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return void 0;
19441
19370
  const prototype = Object.getPrototypeOf(value);
19442
19371
  let readers = hostReaders3.get(prototype);
19443
19372
  if (readers === void 0) {
@@ -19455,7 +19384,7 @@ function hostTemporalPlainYearMonthFields(value) {
19455
19384
  };
19456
19385
  }
19457
19386
  function createSandboxTemporalPlainYearMonth(input) {
19458
- if (input === null || typeof input !== "object" || types16.isProxy(input))
19387
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19459
19388
  throw new TypeError("PlainYearMonth fields must be an ordinary data record.");
19460
19389
  const fields2 = /* @__PURE__ */ Object.create(null);
19461
19390
  for (const name of temporalPlainDateNumericFields) {
@@ -19489,7 +19418,6 @@ function temporalPlainYearMonthFields(value) {
19489
19418
  }
19490
19419
 
19491
19420
  // packages/safe-js/src/interp/temporal-zoned-date-time.ts
19492
- import { types as types17 } from "node:util";
19493
19421
  import { Temporal as Backend5 } from "temporal-polyfill/full/implementation";
19494
19422
  var dates3 = /* @__PURE__ */ new WeakMap();
19495
19423
  var nativeTemporal8 = Object.getOwnPropertyDescriptor(globalThis, "Temporal")?.value;
@@ -19507,7 +19435,7 @@ function createHostTemporalZonedDateTime(fields2) {
19507
19435
  return value;
19508
19436
  }
19509
19437
  function hostTemporalZonedDateTimeFields(value) {
19510
- if (value === null || typeof value !== "object" || types17.isProxy(value)) return void 0;
19438
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return void 0;
19511
19439
  const prototype = Object.getPrototypeOf(value);
19512
19440
  let readers = hostReaders4.get(prototype);
19513
19441
  if (readers === void 0) {
@@ -19522,7 +19450,7 @@ function hostTemporalZonedDateTimeFields(value) {
19522
19450
  }));
19523
19451
  }
19524
19452
  function createSandboxTemporalZonedDateTime(input) {
19525
- if (input === null || typeof input !== "object" || types17.isProxy(input))
19453
+ if (input === null || typeof input !== "object" || types.isProxy(input))
19526
19454
  throw new TypeError("ZonedDateTime fields must be an ordinary data record.");
19527
19455
  const epoch = Object.getOwnPropertyDescriptor(input, "epochNanoseconds");
19528
19456
  const zone = Object.getOwnPropertyDescriptor(input, "timeZone");
@@ -22324,7 +22252,7 @@ function executeHostCall(record4, restored, invoke, stackFrames, options, span,
22324
22252
  try {
22325
22253
  result = invoke();
22326
22254
  } catch (error) {
22327
- if (!types18.isProxy(error) && error instanceof HostCallResumabilityError) {
22255
+ if (!types.isProxy(error) && error instanceof HostCallResumabilityError) {
22328
22256
  throw error;
22329
22257
  }
22330
22258
  const reason = createHostErrorValue(error, stackFrames, options.budget, span);
@@ -22424,8 +22352,8 @@ function copyHostResultToSandbox(result, stackFrames, options) {
22424
22352
  return value;
22425
22353
  }
22426
22354
  function createHostErrorValue(reason, stackFrames, budget, span, state = { seen: /* @__PURE__ */ new WeakMap() }, chargeBudget = false) {
22427
- const proxy = types18.isProxy(reason);
22428
- const nativeError = !proxy && (types18.isNativeError(reason) || reason instanceof Error);
22355
+ const proxy = types.isProxy(reason);
22356
+ const nativeError = !proxy && (types.isNativeError(reason) || reason instanceof Error);
22429
22357
  if (nativeError) {
22430
22358
  const existing = state.seen.get(reason);
22431
22359
  if (existing !== void 0) return existing;
@@ -22465,7 +22393,7 @@ function createHostErrorValue(reason, stackFrames, budget, span, state = { seen:
22465
22393
  }
22466
22394
  function readHostErrorDiagnostic(error, key, fallback) {
22467
22395
  let current = error;
22468
- while (current !== null && !types18.isProxy(current)) {
22396
+ while (current !== null && !types.isProxy(current)) {
22469
22397
  const descriptor = Object.getOwnPropertyDescriptor(current, key);
22470
22398
  if (descriptor !== void 0) {
22471
22399
  if (descriptor.get !== void 0 && descriptor.get === domExceptionDiagnostics[key]) {
@@ -22648,7 +22576,7 @@ function isPromiseLike2(value) {
22648
22576
  return typeof value === "object" && value !== null && "then" in value;
22649
22577
  }
22650
22578
  function isFatalBridgeError(error) {
22651
- return !types18.isProxy(error) && (error instanceof HostCallResumabilityError || error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry"));
22579
+ return !types.isProxy(error) && (error instanceof HostCallResumabilityError || error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry"));
22652
22580
  }
22653
22581
  function wrapHostPromiseWithSignal(promise, signal) {
22654
22582
  if (signal === void 0) {
@@ -22704,7 +22632,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
22704
22632
  if (value.description !== void 0) budget.allocateString(value.description);
22705
22633
  return value;
22706
22634
  }
22707
- if (types18.isNativeError(value) || value instanceof Error) {
22635
+ if (types.isNativeError(value) || value instanceof Error) {
22708
22636
  return createHostErrorValue(value, stackFrames, budget, void 0, state, true);
22709
22637
  }
22710
22638
  if (options.errorData && (typeof value === "function" || isSandboxClosure(value) || isSandboxPromise(value) || value instanceof Promise)) {
@@ -22740,7 +22668,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
22740
22668
  }
22741
22669
  return deepCopyToSandbox(value);
22742
22670
  }
22743
- if (isSandboxRegex(value) || types18.isRegExp(value)) {
22671
+ if (isSandboxRegex(value) || types.isRegExp(value)) {
22744
22672
  const existing = state.seen.get(value);
22745
22673
  if (existing !== void 0) return existing;
22746
22674
  const sandbox = isSandboxRegex(value);
@@ -22961,8 +22889,8 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
22961
22889
  const promiseIdentities = state.promiseIdentities ??= /* @__PURE__ */ new WeakMap();
22962
22890
  const existing = state.seen.get(value) ?? promiseIdentities.get(value);
22963
22891
  if (existing !== void 0) return existing;
22964
- const descriptors2 = types18.isPromise(value) ? nativePromiseDataProperties(value) : [];
22965
- const observed = types18.isPromise(value) ? Reflect.apply(Promise.prototype.then, value, [(settled) => settled]) : Promise.resolve(value);
22892
+ const descriptors2 = types.isPromise(value) ? nativePromiseDataProperties(value) : [];
22893
+ const observed = types.isPromise(value) ? Reflect.apply(Promise.prototype.then, value, [(settled) => settled]) : Promise.resolve(value);
22966
22894
  const promise = wrapHostPromiseWithSignal(observed, options.signal).then(
22967
22895
  (resolved) => {
22968
22896
  try {
@@ -22994,7 +22922,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
22994
22922
  importedPromises.add(sandboxPromise);
22995
22923
  state.seen.set(value, sandboxPromise);
22996
22924
  promiseIdentities.set(value, sandboxPromise);
22997
- if (types18.isPromise(value)) {
22925
+ if (types.isPromise(value)) {
22998
22926
  const properties = getPromiseProperties(sandboxPromise);
22999
22927
  const hasSymbols = descriptors2.some(([key]) => typeof key === "symbol");
23000
22928
  for (const [index, [key, descriptor]] of descriptors2.entries()) {
@@ -23219,7 +23147,7 @@ function describeThrownReason(reason) {
23219
23147
  return "Host operation failed.";
23220
23148
  }
23221
23149
  function readStringProperty(value, key) {
23222
- if (types18.isProxy(value)) return void 0;
23150
+ if (types.isProxy(value)) return void 0;
23223
23151
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
23224
23152
  return descriptor !== void 0 && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
23225
23153
  }
@@ -23563,7 +23491,6 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
23563
23491
  }
23564
23492
 
23565
23493
  // packages/safe-js/src/interp/globals/error.ts
23566
- import { types as types19 } from "node:util";
23567
23494
  var errorConstructorNames = /* @__PURE__ */ new WeakMap();
23568
23495
  var errorNames = [
23569
23496
  "Error",
@@ -23643,7 +23570,7 @@ function createErrorPrototypes(budget, constructors2) {
23643
23570
  sandbox: true,
23644
23571
  name: "isError",
23645
23572
  length: 1,
23646
- call: ([value]) => typeof value === "object" && value !== null && (sandboxErrorTypes.has(value) || types19.isNativeError(value))
23573
+ call: ([value]) => typeof value === "object" && value !== null && (sandboxErrorTypes.has(value) || types.isNativeError(value))
23647
23574
  });
23648
23575
  Object.defineProperty(materializeFunctionProperties(constructors2.Error), "isError", {
23649
23576
  value: isError,
@@ -39426,7 +39353,7 @@ function createReflectGlobal(budget) {
39426
39353
  return reflect;
39427
39354
  }
39428
39355
 
39429
- // packages/safe-js/src/interp/atomic-wait.ts
39356
+ // packages/safe-js/src/platform/atomic-wait-node.ts
39430
39357
  import { Worker } from "node:worker_threads";
39431
39358
  var nativeWait = Reflect.get(Atomics, "waitAsync");
39432
39359
  var workers = /* @__PURE__ */ new WeakMap();
@@ -39694,7 +39621,8 @@ function createAtomicsGlobal(budget) {
39694
39621
  }
39695
39622
 
39696
39623
  // packages/safe-js/src/interp/globals/shared-array-buffer.ts
39697
- var growStorage = Reflect.get(SharedArrayBuffer.prototype, "grow");
39624
+ var sharedPrototype2 = globalThis.SharedArrayBuffer?.prototype ?? /* @__PURE__ */ Object.create(null);
39625
+ var growStorage = Reflect.get(sharedPrototype2, "grow");
39698
39626
  function createSharedArrayBufferGlobal(budget) {
39699
39627
  const prototype = createIntrinsicObject();
39700
39628
  const constructor = createSandboxClosure({
@@ -43085,7 +43013,7 @@ function validateDumpEnvelope(snapshot, options = {}) {
43085
43013
  dataPrototypes: /* @__PURE__ */ new WeakSet()
43086
43014
  };
43087
43015
  if (canPreflightRunSnapshotScalars(root)) validateRunSnapshotScalars(root);
43088
- if (types20.isProxy(root)) fail("invalidType", "$", "proxy objects are not snapshot data");
43016
+ if (types.isProxy(root)) fail("invalidType", "$", "proxy objects are not snapshot data");
43089
43017
  snapshotDataEntries(root, "$", state.dataPrototypes);
43090
43018
  if (root.version !== 1 && root.version !== DUMP_FORMAT_VERSION) {
43091
43019
  fail("unsupportedVersion", "$.version", `expected ${DUMP_FORMAT_VERSION}`);
@@ -43263,7 +43191,7 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
43263
43191
  }
43264
43192
  }
43265
43193
  function hasPlainDataFields(value, keys) {
43266
- if (value === null || typeof value !== "object" || types20.isProxy(value)) return false;
43194
+ if (value === null || typeof value !== "object" || types.isProxy(value)) return false;
43267
43195
  const prototype = Object.getPrototypeOf(value);
43268
43196
  if (prototype !== null && prototype !== Object.prototype) return false;
43269
43197
  return keys.every((key) => {
@@ -43650,7 +43578,7 @@ function validateArgumentsProperties(record4, path) {
43650
43578
  }
43651
43579
  }
43652
43580
  function validateSnapshotProxy(value, path, dataPropertiesOnly = false) {
43653
- if (!types20.isProxy(value)) return;
43581
+ if (!types.isProxy(value)) return;
43654
43582
  if (!dataPropertiesOnly && isTrackedIntrinsicObject(value)) {
43655
43583
  const prototype = Object.getPrototypeOf(value);
43656
43584
  if (prototype !== null && prototype !== (Array.isArray(value) ? Array.prototype : Object.prototype))
@@ -44171,7 +44099,7 @@ var PromiseReplay = class {
44171
44099
  this.liveWaiters.clear();
44172
44100
  }
44173
44101
  };
44174
- var promiseReplayContext = new AsyncLocalStorage6();
44102
+ var promiseReplayContext = new AsyncLocalStorage();
44175
44103
  function validateReplay(value) {
44176
44104
  validateSnapshotData(value);
44177
44105
  if (value === null || typeof value !== "object" || !("version" in value) || value.version !== 1 || !("steps" in value) || !isCounter(value.steps) || !("promises" in value) || !isCounter(value.promises) || !("settlements" in value) || !Array.isArray(value.settlements)) {
@@ -44256,7 +44184,8 @@ function isCounter(value) {
44256
44184
  }
44257
44185
 
44258
44186
  // packages/safe-js/src/interp/shared-host-storage.ts
44259
- var grow = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "grow")?.value;
44187
+ var sharedPrototype3 = globalThis.SharedArrayBuffer?.prototype ?? /* @__PURE__ */ Object.create(null);
44188
+ var grow = Object.getOwnPropertyDescriptor(sharedPrototype3, "grow")?.value;
44260
44189
  function restoreSharedHostValue(value, bindings, budget) {
44261
44190
  const replacements = /* @__PURE__ */ new WeakMap();
44262
44191
  const targets = /* @__PURE__ */ new Set();
@@ -46025,7 +45954,6 @@ function recordCleanupFailure(cleanup, value, budget, context) {
46025
45954
  }
46026
45955
 
46027
45956
  // packages/safe-js/src/interp/values.ts
46028
- import { types as nodeTypes } from "node:util";
46029
45957
  var frozenClosureData = /* @__PURE__ */ new WeakMap();
46030
45958
  var readFrozenClosureData = WeakMap.prototype.get.bind(frozenClosureData);
46031
45959
  var writeFrozenClosureData = WeakMap.prototype.set.bind(frozenClosureData);
@@ -46058,14 +45986,14 @@ for (const marker of [sandboxClosureBrand, sandboxGeneratorBrand, sandboxPromise
46058
45986
  var copiedPlainObjects = /* @__PURE__ */ new WeakSet();
46059
45987
  function assertNativeProxyCopyable(value) {
46060
45988
  if ((typeof value !== "object" || value === null) && typeof value !== "function") return;
46061
- if (nodeTypes.isProxy(value)) {
45989
+ if (types.isProxy(value)) {
46062
45990
  if (isNumericTypedArray(value) || isTrackedIntrinsicObject(value) || mappedArgumentStates.has(value) || isSandboxModuleNamespace(value)) return;
46063
45991
  throw new TypeError("Unsupported proxy sandbox value.");
46064
45992
  }
46065
45993
  let prototype = Object.getPrototypeOf(value);
46066
45994
  for (let depth = 1; prototype !== null; depth++) {
46067
45995
  assertSandboxDataDepth(depth);
46068
- if (nodeTypes.isProxy(prototype)) throw new TypeError("Unsupported proxy sandbox value.");
45996
+ if (types.isProxy(prototype)) throw new TypeError("Unsupported proxy sandbox value.");
46069
45997
  prototype = Object.getPrototypeOf(prototype);
46070
45998
  }
46071
45999
  }
@@ -46324,7 +46252,7 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
46324
46252
  const descriptor = Object.getOwnPropertyDescriptor(regex, "lastIndex");
46325
46253
  Object.defineProperty(storage, "lastIndex", { value: descriptor.value, writable: descriptor.writable });
46326
46254
  };
46327
- const properties = new Proxy(storage, {
46255
+ const properties = createTrackedProxy(storage, {
46328
46256
  get: (target, key, receiver) => key === "lastIndex" ? regex.lastIndex : Reflect.get(target, key, receiver),
46329
46257
  set: (target, key, value, receiver) => key === "lastIndex" ? Reflect.set(regex, key, value) : Reflect.set(target, key, value, receiver),
46330
46258
  getOwnPropertyDescriptor(target, key) {
@@ -46850,7 +46778,7 @@ function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
46850
46778
  if (arrayDescriptors !== void 0) nativeDataArrayAppend(arrayDescriptors, [key, descriptor]);
46851
46779
  else if ("value" in descriptor && typeof descriptor.value !== "number") arrayElements = appendCapture(arrayElements, descriptor.value);
46852
46780
  }
46853
- } else if (!managedArray && nodeTypes.isProxy(value)) {
46781
+ } else if (!managedArray && types.isProxy(value)) {
46854
46782
  for (let index = 0; index < arrayLength; index += 1) {
46855
46783
  const descriptor = Object.getOwnPropertyDescriptor(value, index);
46856
46784
  if (descriptor !== void 0 && "value" in descriptor) arrayElements = appendCapture(arrayElements, descriptor.value);
@@ -47257,7 +47185,7 @@ function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
47257
47185
  break entry;
47258
47186
  }
47259
47187
  const tracked = trackedPropertySymbols(value) !== void 0;
47260
- const proxyKeys = !tracked && nodeTypes.isProxy(value) ? Object.getOwnPropertyNames(value) : void 0;
47188
+ const proxyKeys = !tracked && types.isProxy(value) ? Object.getOwnPropertyNames(value) : void 0;
47261
47189
  const proxyDescriptors = proxyKeys === void 0 ? void 0 : nativeDataArraySetPrototype([], null);
47262
47190
  if (proxyKeys !== void 0) {
47263
47191
  const length = proxyKeys.length;
@@ -47471,7 +47399,7 @@ function deepCopyFromSandbox(value, options = {}) {
47471
47399
  function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections = false, depth = 0) {
47472
47400
  assertSandboxDataDepth(depth);
47473
47401
  assertNativeProxyCopyable(value);
47474
- if (state.structuredClone && (isSandboxPromise(value) || nodeTypes.isPromise(value)))
47402
+ if (state.structuredClone && (isSandboxPromise(value) || types.isPromise(value)))
47475
47403
  throw new DOMException("Promises cannot be structured cloned.", "DataCloneError");
47476
47404
  if (state.structuredClone && typeof value === "symbol")
47477
47405
  throw new DOMException("Symbols cannot be structured cloned.", "DataCloneError");
@@ -47492,7 +47420,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
47492
47420
  throw new DOMException("Proxies cannot be structured cloned.", "DataCloneError");
47493
47421
  if (state.structuredClone && (isSandboxTemporalInstant(value) || isSandboxTemporalDuration(value) || isSandboxTemporalPlainTime(value) || isSandboxTemporalPlainDateTime(value) || isSandboxTemporalPlainDate(value) || isSandboxTemporalPlainMonthDay(value) || isSandboxTemporalPlainYearMonth(value) || isSandboxTemporalZonedDateTime(value)))
47494
47422
  throw new DOMException("Temporal values cannot be structured cloned.", "DataCloneError");
47495
- if (state.structuredClone && nodeTypes.isSymbolObject(value))
47423
+ if (state.structuredClone && types.isSymbolObject(value))
47496
47424
  throw new DOMException("Cannot clone a boxed symbol.", "DataCloneError");
47497
47425
  if (state.structuredClone && isSandboxModuleNamespace(value))
47498
47426
  throw new DOMException("Cannot clone a module namespace.", "DataCloneError");
@@ -47507,7 +47435,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
47507
47435
  state.seen.set(value, copy);
47508
47436
  return copy;
47509
47437
  }
47510
- if (isSandboxRegex(value) || nodeTypes.isRegExp(value)) {
47438
+ if (isSandboxRegex(value) || types.isRegExp(value)) {
47511
47439
  const sandbox = isSandboxRegex(value);
47512
47440
  if (sandbox && !cloneSandboxCollections) return value;
47513
47441
  const existing = state.seen.get(value);
@@ -47719,7 +47647,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
47719
47647
  }
47720
47648
  return copy;
47721
47649
  }
47722
- if (nodeTypes.isPromise(value)) {
47650
+ if (types.isPromise(value)) {
47723
47651
  const nativePromises = state.nativePromises ??= /* @__PURE__ */ new WeakMap();
47724
47652
  const existing = state.seen.get(value) ?? nativePromises.get(value);
47725
47653
  if (existing !== void 0) return existing;
@@ -47763,7 +47691,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
47763
47691
  if (!Object.isExtensible(value)) Object.preventExtensions(copy);
47764
47692
  return copy;
47765
47693
  }
47766
- if (nodeTypes.isDate(value)) {
47694
+ if (types.isDate(value)) {
47767
47695
  const existing = state.seen.get(value);
47768
47696
  if (existing !== void 0) return existing;
47769
47697
  const copy = copyNativeDate(value);
@@ -49239,8 +49167,6 @@ export {
49239
49167
  revokeGuestCallback,
49240
49168
  revokeHostObject,
49241
49169
  hostObjectGuestRoot,
49242
- createHostCallbackContext,
49243
- accessDeniedSystemError,
49244
49170
  isSandboxArrayBuffer,
49245
49171
  arrayBufferLength,
49246
49172
  arrayBufferDetached,
@@ -49386,4 +49312,4 @@ authorization of the copyright holder.
49386
49312
  SPDX-License-Identifier: Unicode-3.0
49387
49313
 
49388
49314
  */
49389
- //# sourceMappingURL=chunk-S5YDMMM3.js.map
49315
+ //# sourceMappingURL=chunk-MDIWQFYU.js.map