poe-code 14.0.82 → 14.0.84

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 (50) hide show
  1. package/dist/index.js +1105 -223
  2. package/dist/index.js.map +4 -4
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-7LGBDF56.js → chunk-2EZQJQ2C.js} +2 -2
  6. package/packages/safe-js/dist/chunks/{chunk-V6LQP64H.js → chunk-CYVI4ZUK.js} +978 -161
  7. package/packages/safe-js/dist/chunks/chunk-CYVI4ZUK.js.map +7 -0
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.js +1 -1
  10. package/packages/safe-js/dist/index.js +2 -2
  11. package/packages/safe-js/dist/interp/array-buffer.d.ts +12 -0
  12. package/packages/safe-js/dist/interp/array-buffer.js +33 -0
  13. package/packages/safe-js/dist/interp/float32-prototypes.d.ts +3 -0
  14. package/packages/safe-js/dist/interp/float32-prototypes.js +1 -0
  15. package/packages/safe-js/dist/interp/float32.d.ts +7 -1
  16. package/packages/safe-js/dist/interp/float32.js +50 -14
  17. package/packages/safe-js/dist/interp/globals/array-buffer.d.ts +3 -0
  18. package/packages/safe-js/dist/interp/globals/array-buffer.js +112 -0
  19. package/packages/safe-js/dist/interp/globals/float32array.d.ts +4 -3
  20. package/packages/safe-js/dist/interp/globals/float32array.js +463 -68
  21. package/packages/safe-js/dist/interp/globals/object-array.js +3 -3
  22. package/packages/safe-js/dist/interp/globals.d.ts +2 -0
  23. package/packages/safe-js/dist/interp/globals.js +6 -2
  24. package/packages/safe-js/dist/interp/host-bridge.d.ts +1 -0
  25. package/packages/safe-js/dist/interp/host-bridge.js +21 -0
  26. package/packages/safe-js/dist/interp/host-call.js +26 -2
  27. package/packages/safe-js/dist/interp/instanceof.js +1 -1
  28. package/packages/safe-js/dist/interp/interpreter.js +2 -4
  29. package/packages/safe-js/dist/interp/iteration.js +15 -6
  30. package/packages/safe-js/dist/interp/methods/array-iterator.js +1 -1
  31. package/packages/safe-js/dist/interp/object-model.js +22 -1
  32. package/packages/safe-js/dist/interp/values.d.ts +1 -1
  33. package/packages/safe-js/dist/interp/values.js +59 -9
  34. package/packages/safe-js/dist/lint/rules/known-globals.d.ts +1 -1
  35. package/packages/safe-js/dist/lint/rules/known-globals.js +1 -0
  36. package/packages/safe-js/dist/parse/parser.js +8 -3
  37. package/packages/safe-js/dist/parse/tokenizer.js +45 -3
  38. package/packages/safe-js/dist/snapshot/array-buffer.d.ts +13 -0
  39. package/packages/safe-js/dist/snapshot/array-buffer.js +40 -0
  40. package/packages/safe-js/dist/snapshot/dump-format.js +25 -9
  41. package/packages/safe-js/dist/snapshot/float32array.d.ts +11 -1
  42. package/packages/safe-js/dist/snapshot/float32array.js +42 -5
  43. package/packages/safe-js/dist/snapshot/replay-data.d.ts +5 -0
  44. package/packages/safe-js/dist/snapshot/replay-data.js +35 -10
  45. package/packages/safe-js/dist/snapshot/restore.js +30 -3
  46. package/packages/safe-js/dist/snapshot/serialize.d.ts +7 -3
  47. package/packages/safe-js/dist/snapshot/serialize.js +24 -14
  48. package/packages/safe-js/dist/snapshot/validation.js +21 -1
  49. package/packages/safe-js/dist/chunks/chunk-V6LQP64H.js.map +0 -7
  50. /package/packages/safe-js/dist/chunks/{chunk-7LGBDF56.js.map → chunk-2EZQJQ2C.js.map} +0 -0
package/dist/index.js CHANGED
@@ -50271,8 +50271,8 @@ function assertNonNegativeInteger3(value, keyword) {
50271
50271
  }
50272
50272
  function validateSchemaObject(schema, dialect) {
50273
50273
  if (schema.type !== void 0) {
50274
- const types8 = Array.isArray(schema.type) ? schema.type : [schema.type];
50275
- if (types8.length === 0 || !types8.every((type) => typeof type === "string" && draftTypeSet.has(type)) || new Set(types8).size !== types8.length) {
50274
+ const types9 = Array.isArray(schema.type) ? schema.type : [schema.type];
50275
+ if (types9.length === 0 || !types9.every((type) => typeof type === "string" && draftTypeSet.has(type)) || new Set(types9).size !== types9.length) {
50276
50276
  throw new Error("type must be a JSON Schema type or a unique array of JSON Schema types.");
50277
50277
  }
50278
50278
  }
@@ -50991,9 +50991,9 @@ function evaluateValidationKeywords(node, schema, value, path193) {
50991
50991
  if (schema.nullable === true && value === null) {
50992
50992
  return results;
50993
50993
  }
50994
- const types8 = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
50995
- if (types8.length > 0 && !types8.some((type) => typeof type === "string" && typeMatches(type, value))) {
50996
- results.push(invalidResult(issue(path193, types8.join(","), value, `must be ${types8.join(",")}`)));
50994
+ const types9 = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
50995
+ if (types9.length > 0 && !types9.some((type) => typeof type === "string" && typeMatches(type, value))) {
50996
+ results.push(invalidResult(issue(path193, types9.join(","), value, `must be ${types9.join(",")}`)));
50997
50997
  return results;
50998
50998
  }
50999
50999
  if (schema.const !== void 0 && !deepEqual(schema.const, value)) {
@@ -120507,7 +120507,7 @@ function matchPunctuator(source, index) {
120507
120507
  (punctuator) => source.startsWith(punctuator, index) && (punctuator !== "?." || !isDecimalDigit(source[index + 2] ?? ""))
120508
120508
  );
120509
120509
  }
120510
- function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis) {
120510
+ function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis, tokens) {
120511
120511
  if (previousToken === void 0) {
120512
120512
  return true;
120513
120513
  }
@@ -120515,6 +120515,7 @@ function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis) {
120515
120515
  return false;
120516
120516
  }
120517
120517
  if (previousToken.type === "keyword") {
120518
+ if (previousToken.value === "of") return endsWithForOfSeparator(tokens);
120518
120519
  return !EXPRESSION_ENDING_KEYWORDS.has(previousToken.value);
120519
120520
  }
120520
120521
  if (previousToken.value === ")") {
@@ -120522,6 +120523,35 @@ function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis) {
120522
120523
  }
120523
120524
  return !isExpressionEndingPunctuator(previousToken.value);
120524
120525
  }
120526
+ function endsWithForOfSeparator(tokens) {
120527
+ let depth = 0;
120528
+ let start = -1;
120529
+ for (let index = tokens.length - 2; index >= 0; index--) {
120530
+ const token = tokens[index];
120531
+ if (token.type !== "punctuator") continue;
120532
+ if ([")", "]", "}"].includes(token.value)) depth++;
120533
+ else if (["(", "[", "{"].includes(token.value)) {
120534
+ if (depth > 0) {
120535
+ depth--;
120536
+ continue;
120537
+ }
120538
+ if (token.value === "(" && (tokens[index - 1]?.value === "for" || tokens[index - 1]?.value === "await" && tokens[index - 2]?.value === "for")) start = index + 1;
120539
+ break;
120540
+ } else if (depth === 0 && token.value === ";") break;
120541
+ }
120542
+ if (start < 0) return false;
120543
+ depth = 0;
120544
+ for (let index = start; index < tokens.length; index++) {
120545
+ const token = tokens[index];
120546
+ if (token.type === "punctuator") {
120547
+ if (["(", "[", "{"].includes(token.value)) depth++;
120548
+ else if ([")", "]", "}"].includes(token.value)) depth--;
120549
+ }
120550
+ if (depth === 0 && token.type === "keyword" && token.value === "of" && index !== start && tokens[index - 1]?.value !== "." && tokens[index - 1]?.value !== "?." && !(index === start + 1 && ["const", "let", "var"].includes(tokens[start].value)))
120551
+ return index === tokens.length - 1;
120552
+ }
120553
+ return false;
120554
+ }
120525
120555
  function updateGroupingState(groupingStack, previousToken, punctuator) {
120526
120556
  if (punctuator === "(") {
120527
120557
  groupingStack.push({
@@ -120905,7 +120935,7 @@ var init_tokenizer2 = __esm({
120905
120935
  lastClosedControlParenthesis = false;
120906
120936
  continue;
120907
120937
  }
120908
- if (char === "/" && this.peekChar(1) !== "=" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedControlParenthesis)) {
120938
+ if (char === "/" && this.peekChar(1) !== "=" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedControlParenthesis, tokens)) {
120909
120939
  if (!this.options.allowRegexLiterals) {
120910
120940
  this.syntaxError("Regular expression literals are not supported", this.position());
120911
120941
  }
@@ -121174,7 +121204,7 @@ var init_tokenizer2 = __esm({
121174
121204
  }
121175
121205
  }
121176
121206
  readSlashOrPunctuator(start) {
121177
- if (this.currentChar() === "/" && this.peekChar(1) !== "=" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedControlParenthesis)) {
121207
+ if (this.currentChar() === "/" && this.peekChar(1) !== "=" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedControlParenthesis, this.tokens)) {
121178
121208
  if (!this.options.allowRegexLiterals) {
121179
121209
  this.syntaxError("Regular expression literals are not supported", start);
121180
121210
  }
@@ -123372,7 +123402,7 @@ function isLiteralPropertyKey(token) {
123372
123402
  return token.type === "numeric" || token.type === "string";
123373
123403
  }
123374
123404
  function isIdentifierLikeToken(token) {
123375
- return token.type === "identifier" || token.type === "keyword" && token.value === "async";
123405
+ return token.type === "identifier" || token.type === "keyword" && (token.value === "async" || token.value === "of");
123376
123406
  }
123377
123407
  function isNewToken(token) {
123378
123408
  return token.value === "new";
@@ -126051,6 +126081,7 @@ var init_parser3 = __esm({
126051
126081
  return void 0;
126052
126082
  }
126053
126083
  findTopLevelForIterationOperator(startIndex) {
126084
+ let operator;
126054
126085
  let depth = 0;
126055
126086
  let previousToken;
126056
126087
  for (let index = startIndex; index < this.tokens.length; index += 1) {
@@ -126060,15 +126091,15 @@ var init_parser3 = __esm({
126060
126091
  depth += 1;
126061
126092
  } else if (token.value === ")" || token.value === "]" || token.value === "}") {
126062
126093
  if (depth === 0 && token.value === ")") {
126063
- return void 0;
126094
+ return operator;
126064
126095
  }
126065
126096
  depth -= 1;
126066
126097
  } else if (depth === 0 && token.value === ";") {
126067
126098
  return void 0;
126068
126099
  }
126069
126100
  }
126070
- if (depth === 0 && token.type === "keyword" && (token.value === "of" || token.value === "in") && previousToken?.value !== "." && previousToken?.value !== "?.") {
126071
- return token;
126101
+ if (depth === 0 && token.type === "keyword" && (token.value === "of" || token.value === "in") && index !== startIndex && !(token.value === "of" && index === startIndex + 1 && ["const", "let", "var"].includes(previousToken?.value ?? "")) && previousToken?.value !== "." && previousToken?.value !== "?.") {
126102
+ operator ??= token;
126072
126103
  }
126073
126104
  previousToken = token;
126074
126105
  }
@@ -126503,6 +126534,45 @@ var init_otel2 = __esm({
126503
126534
  }
126504
126535
  });
126505
126536
 
126537
+ // packages/safe-js/src/interp/array-buffer.ts
126538
+ import { types } from "node:util";
126539
+ function isSandboxArrayBuffer(value) {
126540
+ return types.isArrayBuffer(value) && Object.getPrototypeOf(value) === ArrayBuffer.prototype;
126541
+ }
126542
+ function arrayBufferLength(value) {
126543
+ return Reflect.apply(readLength, value, []);
126544
+ }
126545
+ function arrayBufferOptions(value) {
126546
+ return readResizable !== void 0 && Reflect.apply(readResizable, value, []) ? { maxByteLength: Reflect.apply(readMaxLength, value, []) } : void 0;
126547
+ }
126548
+ function copyArrayBufferStorage(value, state) {
126549
+ state.float32Buffers ??= /* @__PURE__ */ new WeakMap();
126550
+ let copy = state.float32Buffers.get(value);
126551
+ if (copy === void 0) {
126552
+ copy = Reflect.construct(ArrayBuffer, [arrayBufferLength(value), arrayBufferOptions(value)]);
126553
+ new Uint8Array(copy).set(new Uint8Array(value));
126554
+ state.float32Buffers.set(value, copy);
126555
+ }
126556
+ return copy;
126557
+ }
126558
+ function arrayBufferDataProperties(value) {
126559
+ return Reflect.ownKeys(value).map((key3) => {
126560
+ const descriptor = Object.getOwnPropertyDescriptor(value, key3);
126561
+ if (!("value" in descriptor)) throw new TypeError("ArrayBuffer accessors cannot be copied as data.");
126562
+ return [key3, descriptor];
126563
+ });
126564
+ }
126565
+ var readLength, readResizable, readMaxLength, arrayBufferPrototypes;
126566
+ var init_array_buffer = __esm({
126567
+ "packages/safe-js/src/interp/array-buffer.ts"() {
126568
+ "use strict";
126569
+ readLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
126570
+ readResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
126571
+ readMaxLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "maxByteLength")?.get;
126572
+ arrayBufferPrototypes = /* @__PURE__ */ new WeakMap();
126573
+ }
126574
+ });
126575
+
126506
126576
  // packages/safe-js/src/interp/internal-symbols.ts
126507
126577
  var internalSymbols;
126508
126578
  var init_internal_symbols = __esm({
@@ -126846,7 +126916,7 @@ var init_regexp_iterator = __esm({
126846
126916
  });
126847
126917
 
126848
126918
  // packages/safe-js/src/interp/date.ts
126849
- import { types } from "node:util";
126919
+ import { types as types2 } from "node:util";
126850
126920
  function isSandboxDate(value) {
126851
126921
  return typeof value === "object" && value !== null && dates.has(value);
126852
126922
  }
@@ -126859,7 +126929,7 @@ function dateTime(value) {
126859
126929
  return Reflect.apply(readTime, value, []);
126860
126930
  }
126861
126931
  function copyNativeDate(value) {
126862
- if (!types.isDate(value)) return void 0;
126932
+ if (!types2.isDate(value)) return void 0;
126863
126933
  if (Object.getPrototypeOf(value) !== NativeDate.prototype)
126864
126934
  throw new TypeError("Date subclasses are not supported.");
126865
126935
  return createSandboxDate(dateTime(value));
@@ -127040,13 +127110,13 @@ var init_arguments = __esm({
127040
127110
  });
127041
127111
 
127042
127112
  // packages/safe-js/src/interp/boxed.ts
127043
- import { types as types2 } from "node:util";
127113
+ import { types as types3 } from "node:util";
127044
127114
  function nativeBoxedValue(value) {
127045
- if (types2.isNumberObject(value)) return Reflect.apply(numberValue2, value, []);
127046
- if (types2.isStringObject(value)) return Reflect.apply(stringValue2, value, []);
127047
- if (types2.isBooleanObject(value)) return Reflect.apply(booleanValue, value, []);
127048
- if (types2.isSymbolObject(value)) return Reflect.apply(symbolValue, value, []);
127049
- if (types2.isBigIntObject(value)) return Reflect.apply(bigintValue, value, []);
127115
+ if (types3.isNumberObject(value)) return Reflect.apply(numberValue2, value, []);
127116
+ if (types3.isStringObject(value)) return Reflect.apply(stringValue2, value, []);
127117
+ if (types3.isBooleanObject(value)) return Reflect.apply(booleanValue, value, []);
127118
+ if (types3.isSymbolObject(value)) return Reflect.apply(symbolValue, value, []);
127119
+ if (types3.isBigIntObject(value)) return Reflect.apply(bigintValue, value, []);
127050
127120
  return void 0;
127051
127121
  }
127052
127122
  function createSandboxBox(value) {
@@ -127265,9 +127335,9 @@ var init_resources = __esm({
127265
127335
  });
127266
127336
 
127267
127337
  // packages/safe-js/src/extensions.ts
127268
- import { types as types3 } from "node:util";
127338
+ import { types as types4 } from "node:util";
127269
127339
  function readDataRecord(value, label) {
127270
- if (typeof value !== "object" || value === null || types3.isProxy(value)) {
127340
+ if (typeof value !== "object" || value === null || types4.isProxy(value)) {
127271
127341
  throw new TypeError(`${label} must be a plain data record.`);
127272
127342
  }
127273
127343
  const prototype = Object.getPrototypeOf(value);
@@ -127287,7 +127357,7 @@ function readDataRecord(value, label) {
127287
127357
  return result;
127288
127358
  }
127289
127359
  function readStringList(value, label) {
127290
- if (!Array.isArray(value) || types3.isProxy(value) || value.length > 4096) {
127360
+ if (!Array.isArray(value) || types4.isProxy(value) || value.length > 4096) {
127291
127361
  throw new TypeError(`${label} must be a bounded string array.`);
127292
127362
  }
127293
127363
  const result = [];
@@ -127318,7 +127388,7 @@ var init_extensions = __esm({
127318
127388
  });
127319
127389
 
127320
127390
  // packages/safe-js/src/interp/host-capabilities.ts
127321
- import { types as types4 } from "node:util";
127391
+ import { types as types5 } from "node:util";
127322
127392
  function createGuestReference(root, owner, assertActive) {
127323
127393
  const reference = Object.freeze(/* @__PURE__ */ Object.create(null));
127324
127394
  guestReferences.set(reference, { root, owner, assertActive });
@@ -127366,7 +127436,7 @@ function createLiveHostObject(definition, controller) {
127366
127436
  for (const name of ["keys", "get", "set", "delete"]) {
127367
127437
  const operation = data[name];
127368
127438
  if (operation === void 0 && (name === "set" || name === "delete")) continue;
127369
- if (typeof operation !== "function" || types4.isProxy(operation) || types4.isAsyncFunction(operation) || types4.isGeneratorFunction(operation))
127439
+ if (typeof operation !== "function" || types5.isProxy(operation) || types5.isAsyncFunction(operation) || types5.isGeneratorFunction(operation))
127370
127440
  throw new TypeError(`Named ${name} must be a synchronous non-generator function, not a proxy.`);
127371
127441
  }
127372
127442
  if (typeof data.maxKeys !== "number" || !Number.isInteger(data.maxKeys) || data.maxKeys < 1 || data.maxKeys > MAX_NAMED_KEYS)
@@ -127621,7 +127691,7 @@ function namedMutationKeys(state, key3, create) {
127621
127691
  function namedKeys2(state) {
127622
127692
  const named = state.named;
127623
127693
  return state.controller.read(named.keys, (value) => {
127624
- if (!Array.isArray(value) || types4.isProxy(value))
127694
+ if (!Array.isArray(value) || types5.isProxy(value))
127625
127695
  throw new TypeError("Named keys must be a dense own-data array of strings, not a proxy.");
127626
127696
  const length = Object.getOwnPropertyDescriptor(value, "length").value;
127627
127697
  if (length > named.maxKeys) throw new RangeError("Named keys exceed maxKeys.");
@@ -127677,6 +127747,115 @@ var init_error_prototypes = __esm({
127677
127747
  }
127678
127748
  });
127679
127749
 
127750
+ // packages/safe-js/src/interp/float32.ts
127751
+ function restoreFloat32View(buffer, byteOffset2, length, budget) {
127752
+ const originalLength = arrayBufferLength(buffer);
127753
+ const required = byteOffset2 + (length ?? 0) * 4;
127754
+ const options = arrayBufferOptions(buffer);
127755
+ const grow = required > originalLength;
127756
+ if (grow) {
127757
+ if (options === void 0 || required > options.maxByteLength)
127758
+ throw new RangeError("Float32Array layout exceeds backing capacity.");
127759
+ budget?.allocateArrayLength(Math.ceil(required / 4));
127760
+ budget?.provisionDataUsage(required - originalLength)();
127761
+ Reflect.apply(resizeBuffer, buffer, [required]);
127762
+ }
127763
+ try {
127764
+ const view = new Float32Array(buffer, byteOffset2, length);
127765
+ if (options !== void 0) float32ViewLayouts.set(view, { byteOffset: byteOffset2, ...length === void 0 ? {} : { length } });
127766
+ return view;
127767
+ } finally {
127768
+ if (grow) Reflect.apply(resizeBuffer, buffer, [originalLength]);
127769
+ }
127770
+ }
127771
+ function isFloat32Array(value) {
127772
+ return ArrayBuffer.isView(value) && Object.getPrototypeOf(value) === Float32Array.prototype && Reflect.apply(readTag, value, []) === "Float32Array";
127773
+ }
127774
+ function float32Storage(value, requireInBounds = false) {
127775
+ if (requireInBounds) Reflect.apply(createValuesIterator, value, []);
127776
+ const buffer = Reflect.apply(readBuffer, value, []);
127777
+ if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype) {
127778
+ throw new TypeError("Float32Array requires a non-shared ArrayBuffer.");
127779
+ }
127780
+ return {
127781
+ buffer,
127782
+ byteOffset: Reflect.apply(readOffset, value, []),
127783
+ length: Reflect.apply(readLength2, value, []),
127784
+ byteLength: Reflect.apply(bufferLength, buffer, [])
127785
+ };
127786
+ }
127787
+ function float32Properties(value) {
127788
+ const properties = [];
127789
+ for (const key3 of Reflect.ownKeys(value)) {
127790
+ if (typeof key3 === "string" && isFloat32Index(key3)) continue;
127791
+ properties.push([key3, Object.getOwnPropertyDescriptor(value, key3)]);
127792
+ }
127793
+ return properties;
127794
+ }
127795
+ function float32DataProperties(value) {
127796
+ if (Object.getOwnPropertySymbols(value).length > 0)
127797
+ throw new TypeError("Float32Array symbol properties are not supported.");
127798
+ const properties = [];
127799
+ for (const [key3, descriptor] of float32Properties(value)) {
127800
+ if (typeof key3 !== "string") throw new TypeError("Float32Array symbol properties are not supported.");
127801
+ if (!("value" in descriptor))
127802
+ throw new TypeError(`Float32Array accessor property '${key3}' is not supported.`);
127803
+ properties.push([key3, descriptor]);
127804
+ }
127805
+ return properties;
127806
+ }
127807
+ function isFloat32Index(key3) {
127808
+ return key3 === "-0" || String(Number(key3)) === key3;
127809
+ }
127810
+ function float32Number(value) {
127811
+ if (value !== null && typeof value === "object" || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
127812
+ throw new TypeError(
127813
+ "Float32Array numeric arguments must be primitive numeric-coercible values."
127814
+ );
127815
+ }
127816
+ return Number(value);
127817
+ }
127818
+ function checkFloat32Allocation(length, budget) {
127819
+ budget.allocateArrayLength(length);
127820
+ budget.provisionDataUsage(length * Float32Array.BYTES_PER_ELEMENT + 1)();
127821
+ }
127822
+ function copyFloat32Storage(value, state) {
127823
+ const storage2 = float32Storage(value);
127824
+ const buffer = copyArrayBufferStorage(storage2.buffer, state);
127825
+ if (bufferResizable !== void 0 && Reflect.apply(bufferResizable, storage2.buffer, [])) {
127826
+ const layout = float32ViewLayouts.get(value);
127827
+ if (layout === void 0) throw new TypeError("Resizable Float32Array copies require known view layout.");
127828
+ return restoreFloat32View(buffer, layout.byteOffset, layout.length);
127829
+ }
127830
+ return new Float32Array(buffer, storage2.byteOffset, storage2.length);
127831
+ }
127832
+ var typedArrayPrototype, readLength2, readOffset, readBuffer, readTag, createValuesIterator, bufferLength, bufferResizable, float32ViewLayouts, resizeBuffer;
127833
+ var init_float32 = __esm({
127834
+ "packages/safe-js/src/interp/float32.ts"() {
127835
+ "use strict";
127836
+ init_array_buffer();
127837
+ typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
127838
+ readLength2 = Object.getOwnPropertyDescriptor(typedArrayPrototype, "length").get;
127839
+ readOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
127840
+ readBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
127841
+ readTag = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
127842
+ createValuesIterator = Object.getOwnPropertyDescriptor(typedArrayPrototype, "values").value;
127843
+ bufferLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
127844
+ bufferResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
127845
+ float32ViewLayouts = /* @__PURE__ */ new WeakMap();
127846
+ resizeBuffer = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize").value;
127847
+ }
127848
+ });
127849
+
127850
+ // packages/safe-js/src/interp/float32-prototypes.ts
127851
+ var float32Prototypes;
127852
+ var init_float32_prototypes = __esm({
127853
+ "packages/safe-js/src/interp/float32-prototypes.ts"() {
127854
+ "use strict";
127855
+ float32Prototypes = /* @__PURE__ */ new WeakMap();
127856
+ }
127857
+ });
127858
+
127680
127859
  // packages/safe-js/src/interp/object-model.ts
127681
127860
  function registerGuestClosure(closure) {
127682
127861
  guestClosures.add(closure);
@@ -127883,11 +128062,15 @@ function releaseObjectPrototype(budget) {
127883
128062
  functionPrototypes.delete(budget);
127884
128063
  generatorPrototypes.delete(budget);
127885
128064
  errorPrototypes.delete(budget);
128065
+ float32Prototypes.delete(budget);
128066
+ arrayBufferPrototypes.delete(budget);
127886
128067
  initialRegexDescriptors.delete(budget);
127887
128068
  intrinsicPrototypes.delete(budget);
127888
128069
  }
127889
128070
  function getSandboxPrototype(value, budget) {
127890
128071
  if (prototypes.has(value)) return prototypes.get(value) ?? null;
128072
+ if (isSandboxArrayBuffer(value)) return budget === void 0 ? null : arrayBufferPrototypes.get(budget) ?? null;
128073
+ if (isFloat32Array(value)) return budget === void 0 ? null : float32Prototypes.get(budget) ?? null;
127891
128074
  const errorType = sandboxErrorTypes.get(value);
127892
128075
  if (budget !== void 0 && errorType !== void 0) {
127893
128076
  const prototype = errorPrototypes.get(budget)?.get(errorType);
@@ -127920,6 +128103,8 @@ function getSandboxPropertyDescriptor(value, key3, budget) {
127920
128103
  let current = value;
127921
128104
  let depth = 0;
127922
128105
  while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxGenerator(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
128106
+ if (isFloat32Array(current) && typeof key3 !== "symbol" && isFloat32Index(String(key3)))
128107
+ return Object.getOwnPropertyDescriptor(current, key3);
127923
128108
  const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? key3 === "prototype" && current.construct !== void 0 && current.boundTarget === void 0 ? materializeFunctionProperties(current) : getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
127924
128109
  if (properties === void 0 && isGuestClosure(current) && (key3 === "name" || key3 === "length"))
127925
128110
  return {
@@ -127942,6 +128127,8 @@ function getSandboxDataProperty(value, key3, budget) {
127942
128127
  let current = value;
127943
128128
  let depth = 0;
127944
128129
  while (typeof current === "object" && current !== null) {
128130
+ if (isFloat32Array(current) && typeof key3 !== "symbol" && isFloat32Index(String(key3)))
128131
+ return Object.getOwnPropertyDescriptor(current, key3)?.value;
127945
128132
  if (isGuestHostObject(current)) return typeof key3 === "symbol" ? void 0 : getHostObjectMember(current, String(key3));
127946
128133
  if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key3)?.value;
127947
128134
  if (isSandboxPromise(current)) return Object.getOwnPropertyDescriptor(getPromiseProperties(current), key3)?.value;
@@ -127993,6 +128180,8 @@ function setSandboxPrototype(value, prototype, budget) {
127993
128180
  prototypes.set(value, prototype);
127994
128181
  }
127995
128182
  function isPrototypeRecord(value) {
128183
+ if (isSandboxArrayBuffer(value)) return true;
128184
+ if (isFloat32Array(value)) return true;
127996
128185
  if (isGuestClosure(value)) return true;
127997
128186
  if (isGuestHostObject(value)) return false;
127998
128187
  if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxSet(value))
@@ -128012,7 +128201,7 @@ function hasGuestObjectState(value) {
128012
128201
  if (isLiveCapability(value)) return true;
128013
128202
  if (functionProperties.has(value) || prototypes.has(value) && !hasNullObjectPrototype(value)) return true;
128014
128203
  if (isSandboxBox(value) || isSandboxDate(value)) return false;
128015
- return descriptorObjects.has(value) && Object.values(Object.getOwnPropertyDescriptors(value)).some(
128204
+ return descriptorObjects.has(value) && (isFloat32Array(value) ? float32Properties(value).map(([, descriptor]) => descriptor) : Object.values(Object.getOwnPropertyDescriptors(value))).some(
128016
128205
  (descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
128017
128206
  );
128018
128207
  }
@@ -128030,6 +128219,9 @@ var init_object_model = __esm({
128030
128219
  init_accessors();
128031
128220
  init_host_capabilities();
128032
128221
  init_error_prototypes();
128222
+ init_float32();
128223
+ init_float32_prototypes();
128224
+ init_array_buffer();
128033
128225
  init_shape();
128034
128226
  init_boxed();
128035
128227
  init_values();
@@ -128079,75 +128271,6 @@ var init_raw_json = __esm({
128079
128271
  }
128080
128272
  });
128081
128273
 
128082
- // packages/safe-js/src/interp/float32.ts
128083
- function isFloat32Array(value) {
128084
- return ArrayBuffer.isView(value) && Object.getPrototypeOf(value) === Float32Array.prototype && Reflect.apply(readTag, value, []) === "Float32Array";
128085
- }
128086
- function float32Storage(value) {
128087
- const buffer = Reflect.apply(readBuffer, value, []);
128088
- if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype || bufferResizable !== void 0 && Reflect.apply(bufferResizable, buffer, [])) {
128089
- throw new TypeError("Float32Array requires a fixed, non-shared ArrayBuffer.");
128090
- }
128091
- return {
128092
- buffer,
128093
- byteOffset: Reflect.apply(readOffset, value, []),
128094
- length: Reflect.apply(readLength, value, []),
128095
- byteLength: Reflect.apply(bufferLength, buffer, [])
128096
- };
128097
- }
128098
- function float32DataProperties(value) {
128099
- if (Object.getOwnPropertySymbols(value).length > 0)
128100
- throw new TypeError("Float32Array symbol properties are not supported.");
128101
- const properties = [];
128102
- for (const key3 of Object.getOwnPropertyNames(value)) {
128103
- if (isFloat32Index(key3)) continue;
128104
- const descriptor = Object.getOwnPropertyDescriptor(value, key3);
128105
- if (!("value" in descriptor))
128106
- throw new TypeError(`Float32Array accessor property '${key3}' is not supported.`);
128107
- properties.push([key3, descriptor]);
128108
- }
128109
- return properties;
128110
- }
128111
- function isFloat32Index(key3) {
128112
- return key3 === "-0" || String(Number(key3)) === key3;
128113
- }
128114
- function float32Number(value) {
128115
- if (value !== null && typeof value === "object" || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
128116
- throw new TypeError(
128117
- "Float32Array numeric arguments must be primitive numeric-coercible values."
128118
- );
128119
- }
128120
- return Number(value);
128121
- }
128122
- function checkFloat32Allocation(length, budget) {
128123
- budget.allocateArrayLength(length);
128124
- budget.provisionDataUsage(length * Float32Array.BYTES_PER_ELEMENT + 1)();
128125
- }
128126
- function copyFloat32Storage(value, state) {
128127
- const storage2 = float32Storage(value);
128128
- state.float32Buffers ??= /* @__PURE__ */ new WeakMap();
128129
- let buffer = state.float32Buffers.get(storage2.buffer);
128130
- if (buffer === void 0) {
128131
- buffer = new ArrayBuffer(storage2.byteLength);
128132
- new Uint8Array(buffer).set(new Uint8Array(storage2.buffer));
128133
- state.float32Buffers.set(storage2.buffer, buffer);
128134
- }
128135
- return new Float32Array(buffer, storage2.byteOffset, storage2.length);
128136
- }
128137
- var typedArrayPrototype, readLength, readOffset, readBuffer, readTag, bufferLength, bufferResizable;
128138
- var init_float32 = __esm({
128139
- "packages/safe-js/src/interp/float32.ts"() {
128140
- "use strict";
128141
- typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
128142
- readLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "length").get;
128143
- readOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
128144
- readBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
128145
- readTag = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
128146
- bufferLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
128147
- bufferResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
128148
- }
128149
- });
128150
-
128151
128274
  // packages/safe-js/src/interp/promise-tracker.ts
128152
128275
  import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
128153
128276
  function assertPromiseExecutionAllowed() {
@@ -128779,18 +128902,20 @@ var init_symbols3 = __esm({
128779
128902
  });
128780
128903
 
128781
128904
  // packages/safe-js/src/snapshot/float32array.ts
128782
- function encodeFloat32Storage(value, id, buffers, reference) {
128905
+ function encodeFloat32Layout(value) {
128783
128906
  const storage2 = float32Storage(value);
128784
- const existing = buffers.get(storage2.buffer);
128785
- if (existing === void 0) buffers.set(storage2.buffer, id);
128907
+ if (arrayBufferOptions(storage2.buffer) === void 0) return { byteOffset: storage2.byteOffset, length: storage2.length };
128908
+ const layout = float32ViewLayouts.get(value);
128909
+ if (layout === void 0) throw new TypeError("Resizable Float32Array snapshots require known view layout.");
128786
128910
  return {
128787
- kind: "float32array",
128788
- byteOffset: storage2.byteOffset,
128789
- length: storage2.length,
128790
- ...existing === void 0 ? { bytes: Array.from(new Uint8Array(storage2.buffer)) } : { buffer: reference(existing) }
128911
+ byteOffset: layout.byteOffset,
128912
+ length: layout.length ?? 0,
128913
+ ...layout.length === void 0 ? { lengthTracking: true } : {}
128791
128914
  };
128792
128915
  }
128793
128916
  function validateFloat32Storage(value) {
128917
+ if (Object.hasOwn(value, "lengthTracking") && (value.lengthTracking !== true || value.length !== 0 || Object.hasOwn(value, "bytes")))
128918
+ throw new TypeError("Invalid Float32Array length-tracking layout.");
128794
128919
  if (!Number.isSafeInteger(value.length) || Number(value.length) < 0 || !Number.isSafeInteger(value.byteOffset) || Number(value.byteOffset) < 0 || Number(value.byteOffset) % 4 !== 0)
128795
128920
  throw new TypeError("Invalid Float32Array view dimensions.");
128796
128921
  if (Object.hasOwn(value, "bytes") === Object.hasOwn(value, "buffer"))
@@ -128800,7 +128925,7 @@ function validateFloat32Storage(value) {
128800
128925
  throw new TypeError("Invalid Float32Array backing bytes.");
128801
128926
  }
128802
128927
  }
128803
- function decodeFloat32Storage(value, resolve16) {
128928
+ function decodeFloat32Storage(value, resolve16, budget) {
128804
128929
  validateFloat32Storage(value);
128805
128930
  let buffer;
128806
128931
  if (Array.isArray(value.bytes)) {
@@ -128808,15 +128933,67 @@ function decodeFloat32Storage(value, resolve16) {
128808
128933
  new Uint8Array(buffer).set(value.bytes);
128809
128934
  } else {
128810
128935
  const referenced = resolve16(value.buffer);
128811
- if (!isFloat32Array(referenced)) throw new TypeError("Invalid Float32Array backing reference.");
128812
- buffer = float32Storage(referenced).buffer;
128936
+ if (isSandboxArrayBuffer(referenced)) buffer = referenced;
128937
+ else if (isFloat32Array(referenced)) buffer = float32Storage(referenced).buffer;
128938
+ else throw new TypeError("Invalid Float32Array backing reference.");
128813
128939
  }
128814
- return new Float32Array(buffer, Number(value.byteOffset), Number(value.length));
128940
+ if (value.lengthTracking === true && arrayBufferOptions(buffer) === void 0)
128941
+ throw new TypeError("Length-tracking layout requires resizable backing storage.");
128942
+ return restoreFloat32View(buffer, Number(value.byteOffset), value.lengthTracking === true ? void 0 : Number(value.length), budget);
128815
128943
  }
128816
128944
  var init_float32array = __esm({
128817
128945
  "packages/safe-js/src/snapshot/float32array.ts"() {
128818
128946
  "use strict";
128819
128947
  init_float32();
128948
+ init_object_model();
128949
+ init_property_descriptors();
128950
+ init_array_buffer();
128951
+ }
128952
+ });
128953
+
128954
+ // packages/safe-js/src/snapshot/array-buffer.ts
128955
+ function captureArrayBufferState(value, encode) {
128956
+ return {
128957
+ properties: serializePropertyDescriptors(value, encode),
128958
+ ...hasExplicitSandboxPrototype(value) ? { prototype: encode(getSandboxPrototype(value)) } : {}
128959
+ };
128960
+ }
128961
+ function encodeArrayBufferStorage(value, id, buffers, reference) {
128962
+ arrayBufferLength(value);
128963
+ const existing = buffers.get(value);
128964
+ if (existing === void 0) buffers.set(value, id);
128965
+ return { kind: "arraybuffer", ...existing === void 0 ? { bytes: Array.from(new Uint8Array(value)), ...arrayBufferOptions(value) } : { buffer: reference(existing) } };
128966
+ }
128967
+ function validateArrayBufferStorage(value) {
128968
+ if (Object.hasOwn(value, "bytes") === Object.hasOwn(value, "buffer"))
128969
+ throw new TypeError("ArrayBuffer requires one backing storage description.");
128970
+ if (Object.hasOwn(value, "bytes") && (!Array.isArray(value.bytes) || value.bytes.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255)))
128971
+ throw new TypeError("Invalid ArrayBuffer bytes.");
128972
+ if (Object.hasOwn(value, "maxByteLength") && (!Array.isArray(value.bytes) || !Number.isSafeInteger(value.maxByteLength) || Number(value.maxByteLength) < value.bytes.length))
128973
+ throw new TypeError("Invalid ArrayBuffer maximum length.");
128974
+ }
128975
+ function decodeArrayBufferStorage(value, resolve16) {
128976
+ validateArrayBufferStorage(value);
128977
+ if (Array.isArray(value.bytes)) {
128978
+ const buffer = Reflect.construct(ArrayBuffer, [
128979
+ value.bytes.length,
128980
+ Object.hasOwn(value, "maxByteLength") ? { maxByteLength: value.maxByteLength } : void 0
128981
+ ]);
128982
+ new Uint8Array(buffer).set(value.bytes);
128983
+ return buffer;
128984
+ }
128985
+ const referenced = resolve16(value.buffer);
128986
+ if (isSandboxArrayBuffer(referenced)) return referenced;
128987
+ if (isFloat32Array(referenced)) return float32Storage(referenced).buffer;
128988
+ throw new TypeError("Invalid ArrayBuffer backing reference.");
128989
+ }
128990
+ var init_array_buffer2 = __esm({
128991
+ "packages/safe-js/src/snapshot/array-buffer.ts"() {
128992
+ "use strict";
128993
+ init_array_buffer();
128994
+ init_float32();
128995
+ init_object_model();
128996
+ init_property_descriptors();
128820
128997
  }
128821
128998
  });
128822
128999
 
@@ -128981,11 +129158,24 @@ function encodeReplayData(value, options = {}) {
128981
129158
  ...symbolProperties.length === 0 ? {} : { symbolProperties },
128982
129159
  ...Object.isExtensible(entry) ? {} : { extensible: false }
128983
129160
  };
129161
+ } else if (isSandboxArrayBuffer(entry)) {
129162
+ const storage2 = encodeArrayBufferStorage(entry, id, float32Buffers, (id2) => ({ tag: "ref", id: id2 }));
129163
+ const properties = /* @__PURE__ */ Object.create(null);
129164
+ for (const [key3, descriptor] of arrayBufferDataProperties(entry)) {
129165
+ if (typeof key3 === "symbol") continue;
129166
+ properties[key3] = {
129167
+ value: child(descriptor.value, key3),
129168
+ configurable: descriptor.configurable === true,
129169
+ enumerable: descriptor.enumerable === true,
129170
+ writable: descriptor.writable === true
129171
+ };
129172
+ }
129173
+ let symbolIndex = 0;
129174
+ const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path193, { symbol: Math.floor(symbolIndex++ / 2) }]));
129175
+ nodes[id] = { ...storage2, properties, extensible: Object.isExtensible(entry), symbolEntries };
128984
129176
  } else if (isFloat32Array(entry)) {
128985
- const storage2 = encodeFloat32Storage(entry, id, float32Buffers, (id2) => ({
128986
- tag: "ref",
128987
- id: id2
128988
- }));
129177
+ const backing = float32Storage(entry);
129178
+ const storage2 = { kind: "float32array", ...encodeFloat32Layout(entry), buffer: child(backing.buffer, "<buffer>") };
128989
129179
  const properties = /* @__PURE__ */ Object.create(null);
128990
129180
  for (const [key3, descriptor] of float32DataProperties(entry)) {
128991
129181
  properties[key3] = {
@@ -129088,7 +129278,7 @@ function decodeReplayData(input, options = {}, parent) {
129088
129278
  const graph = record2(input);
129089
129279
  const nodes = list(own(graph, "nodes"));
129090
129280
  const restored = /* @__PURE__ */ new Map();
129091
- const initializeIterators = [];
129281
+ const initializeValues = [];
129092
129282
  const decode = (entry, depth = 0) => {
129093
129283
  if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
129094
129284
  if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
@@ -129213,10 +129403,20 @@ function decodeReplayData(input, options = {}, parent) {
129213
129403
  if (node.extensible === false) Object.preventExtensions(result3);
129214
129404
  return result3;
129215
129405
  }
129406
+ if (kind === "arraybuffer") {
129407
+ if (typeof node.extensible !== "boolean") throw new TypeError("Invalid ArrayBuffer extensibility.");
129408
+ const result3 = decodeArrayBufferStorage(node, child);
129409
+ restored.set(id, result3);
129410
+ initializeValues.push(() => {
129411
+ defineProperties(result3, record2(own(node, "properties")), child, node.symbolEntries);
129412
+ if (!node.extensible) Object.preventExtensions(result3);
129413
+ });
129414
+ return result3;
129415
+ }
129216
129416
  if (kind === "float32array") {
129217
129417
  if (typeof node.extensible !== "boolean")
129218
129418
  throw new TypeError("Invalid Float32Array extensibility.");
129219
- const result3 = decodeFloat32Storage(node, child);
129419
+ const result3 = decodeFloat32Storage(node, child, compilation.owner?.budget);
129220
129420
  restored.set(id, result3);
129221
129421
  defineProperties(result3, record2(own(node, "properties")), child);
129222
129422
  if (!node.extensible) Object.preventExtensions(result3);
@@ -129252,7 +129452,7 @@ function decodeReplayData(input, options = {}, parent) {
129252
129452
  restored.set(id, result3);
129253
129453
  const collection = child(own(node, "collection"));
129254
129454
  if (collection !== void 0 && !isSandboxMap(collection) && !isSandboxSet(collection)) throw new TypeError("Invalid replay collection iterator source.");
129255
- initializeIterators.push(() => {
129455
+ initializeValues.push(() => {
129256
129456
  restoreSandboxCollectionIterator({ collection, collectionKind, method, index, exhausted }, result3);
129257
129457
  });
129258
129458
  defineProperties(result3, record2(own(node, "properties")), child);
@@ -129323,7 +129523,7 @@ function decodeReplayData(input, options = {}, parent) {
129323
129523
  return result2;
129324
129524
  };
129325
129525
  const result = decode(own(graph, "root"));
129326
- for (const initialize of initializeIterators) initialize();
129526
+ for (const initialize of initializeValues) initialize();
129327
129527
  if (parent !== void 0) compilation.forward(compilation.tickets, parent);
129328
129528
  return result;
129329
129529
  } finally {
@@ -129404,6 +129604,8 @@ var init_replay_data = __esm({
129404
129604
  init_compile_guard();
129405
129605
  init_float32();
129406
129606
  init_float32array();
129607
+ init_array_buffer();
129608
+ init_array_buffer2();
129407
129609
  init_date();
129408
129610
  init_raw_json();
129409
129611
  init_boxed();
@@ -129639,8 +129841,29 @@ function normalize2(value, seen) {
129639
129841
  try {
129640
129842
  const date = copyNativeDate(value);
129641
129843
  if (date !== void 0) return Object.assign(/* @__PURE__ */ Object.create(null), { $type: "date", time: serializedDateTime(date) });
129844
+ if (isSandboxArrayBuffer(value)) {
129845
+ arrayBufferLength(value);
129846
+ const properties = /* @__PURE__ */ Object.create(null);
129847
+ const entries = [];
129848
+ for (const [key3, descriptor] of arrayBufferDataProperties(value)) {
129849
+ if (typeof key3 === "symbol") throw new TypeError("ArrayBuffer symbol properties require an explicit host-call identity.");
129850
+ entries.push([key3, descriptor]);
129851
+ }
129852
+ for (const [key3, descriptor] of entries.sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0))
129853
+ defineOwnDataProperty(properties, key3, normalize2(descriptor.value, seen));
129854
+ return Object.assign(/* @__PURE__ */ Object.create(null), {
129855
+ $type: "arraybuffer",
129856
+ bytes: normalize2(Array.from(new Uint8Array(value)), seen),
129857
+ ...arrayBufferOptions(value),
129858
+ properties
129859
+ });
129860
+ }
129642
129861
  if (isFloat32Array(value)) {
129643
129862
  const storage2 = float32Storage(value);
129863
+ const resizable = arrayBufferOptions(storage2.buffer) !== void 0;
129864
+ const layout = resizable ? float32ViewLayouts.get(value) : void 0;
129865
+ if (resizable && layout === void 0)
129866
+ throw new TypeError("Resizable Float32Array host-call identity requires known view layout.");
129644
129867
  const properties = /* @__PURE__ */ Object.create(null);
129645
129868
  for (const [key3, descriptor] of float32DataProperties(value).sort(
129646
129869
  ([left], [right]) => left < right ? -1 : left > right ? 1 : 0
@@ -129652,7 +129875,12 @@ function normalize2(value, seen) {
129652
129875
  bytes: normalize2(Array.from(new Uint8Array(storage2.buffer)), seen),
129653
129876
  byteOffset: storage2.byteOffset,
129654
129877
  length: storage2.length,
129655
- properties
129878
+ properties,
129879
+ ...resizable || Reflect.ownKeys(storage2.buffer).length > 0 ? { buffer: normalize2(storage2.buffer, seen) } : {},
129880
+ ...layout === void 0 ? {} : { viewLayout: {
129881
+ byteOffset: layout.byteOffset,
129882
+ length: layout.length ?? null
129883
+ } }
129656
129884
  });
129657
129885
  }
129658
129886
  if (Array.isArray(value)) {
@@ -129687,6 +129915,7 @@ var init_host_call = __esm({
129687
129915
  "packages/safe-js/src/interp/host-call.ts"() {
129688
129916
  "use strict";
129689
129917
  init_float32();
129918
+ init_array_buffer();
129690
129919
  init_date();
129691
129920
  init_values();
129692
129921
  init_compile_guard();
@@ -131008,6 +131237,8 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
131008
131237
  const iterator = await invokeBuiltinClosure(factory, [], budget, context, value);
131009
131238
  if (typeof iterator !== "object" && typeof iterator !== "function" || iterator === null)
131010
131239
  throw new TypeError("Iterator must be an object.");
131240
+ if (!asyncProtocol && isSandboxGenerator(iterator) && !iterator.async && !hasExplicitSandboxPrototype(iterator) && getSandboxPropertyDescriptor(iterator, "next", budget) === void 0)
131241
+ return getSandboxIterator(iterator, budget, context);
131011
131242
  const next = await context.getProperty(iterator, "next");
131012
131243
  return guestIterator(iterator, next, asyncProtocol, budget, context, signal);
131013
131244
  }
@@ -131040,7 +131271,7 @@ async function readIteratorResult(iterator, result, property) {
131040
131271
  }
131041
131272
  function getSandboxAsyncIterator(value, budget, context, signal) {
131042
131273
  if (isSandboxGenerator(value) && value.async) {
131043
- return hasExplicitSandboxPrototype(value) ? context?.getProperty === void 0 ? generatorProtocolAdapter(value, budget, context, true, signal) : void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
131274
+ return hasExplicitSandboxPrototype(value) ? context?.getProperty === void 0 ? guestProtocolAdapter(value, budget, context, true, signal) : void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
131044
131275
  }
131045
131276
  if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
131046
131277
  const method = value[Symbol.asyncIterator];
@@ -131187,11 +131418,15 @@ function getSandboxIterator(value, budget, context) {
131187
131418
  }
131188
131419
  if (isGuestHostObject(value)) return getHostObjectIterator(value);
131189
131420
  if (isFloat32Array(value)) {
131421
+ if (hasExplicitSandboxPrototype(value) || budget !== void 0 && float32Prototypes.has(budget)) {
131422
+ if (getSandboxPropertyDescriptor(value, Symbol.iterator, budget) === void 0) return void 0;
131423
+ return guestProtocolAdapter(value, budget ?? new Budget(), context, false);
131424
+ }
131190
131425
  return syncIterator(Float32Array.prototype.values.call(value));
131191
131426
  }
131192
131427
  if (isSandboxGenerator(value)) {
131193
131428
  if (value.async) return void 0;
131194
- if (hasExplicitSandboxPrototype(value)) return context?.getProperty === void 0 ? generatorProtocolAdapter(value, budget ?? new Budget(), context, false) : void 0;
131429
+ if (hasExplicitSandboxPrototype(value)) return context?.getProperty === void 0 ? guestProtocolAdapter(value, budget ?? new Budget(), context, false) : void 0;
131195
131430
  return generatorObjectIterator(value, budget, context);
131196
131431
  }
131197
131432
  if (typeof value === "string") {
@@ -131268,7 +131503,7 @@ function collectionIterator(collection, value) {
131268
131503
  adapter.snapshot = () => ({ kind: "builtin", value, index: adapter.snapshotIndex() });
131269
131504
  return adapter;
131270
131505
  }
131271
- function generatorProtocolAdapter(value, budget, context, asyncProtocol, signal) {
131506
+ function guestProtocolAdapter(value, budget, context, asyncProtocol, signal) {
131272
131507
  const bridge = {
131273
131508
  ...context,
131274
131509
  stack: context?.stack ?? [],
@@ -131282,7 +131517,7 @@ function generatorProtocolAdapter(value, budget, context, asyncProtocol, signal)
131282
131517
  let resolved;
131283
131518
  let pending;
131284
131519
  const initialize = () => pending ??= acquireSandboxIterator(value, budget, bridge, asyncProtocol, signal).then((iterator) => {
131285
- if (iterator === void 0) throw new TypeError("Generator does not provide an iterator protocol.");
131520
+ if (iterator === void 0) throw new TypeError("Value does not provide an iterator protocol.");
131286
131521
  return resolved = iterator;
131287
131522
  });
131288
131523
  return {
@@ -131391,6 +131626,7 @@ var init_iteration = __esm({
131391
131626
  init_values();
131392
131627
  init_running_state();
131393
131628
  init_float32();
131629
+ init_float32_prototypes();
131394
131630
  init_boxed();
131395
131631
  init_host_capabilities();
131396
131632
  init_collection_iterator();
@@ -132183,7 +132419,7 @@ async function nextArrayIterator(value, budget, context) {
132183
132419
  const read = (key3) => context?.getProperty !== void 0 ? context.getProperty(source, key3) : readPropertyDescriptor((isFloat32Array(source) ? Object.getOwnPropertyDescriptor(source, key3) : void 0) ?? getSandboxPropertyDescriptor(source, key3, budget) ?? { value: void 0 }, source, context);
132184
132420
  try {
132185
132421
  budget.visitNode();
132186
- const number = isFloat32Array(source) ? float32Storage(source).length : await sandboxNumber(await read("length"), budget, context);
132422
+ const number = isFloat32Array(source) ? float32Storage(source, true).length : await sandboxNumber(await read("length"), budget, context);
132187
132423
  const length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
132188
132424
  if (index >= length) {
132189
132425
  state.source = void 0;
@@ -132552,7 +132788,7 @@ var init_string_locale = __esm({
132552
132788
  });
132553
132789
 
132554
132790
  // packages/safe-js/src/interp/methods/string.ts
132555
- import { types as types5 } from "node:util";
132791
+ import { types as types6 } from "node:util";
132556
132792
  function getStringMember(value, property, budget) {
132557
132793
  const index = getStringIndex(property);
132558
132794
  if (index !== void 0) {
@@ -132622,7 +132858,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
132622
132858
  };
132623
132859
  const symbol2 = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "matchAll" ? Symbol.matchAll : methodName === "replace" || methodName === "replaceAll" ? Symbol.replace : methodName === "split" ? Symbol.split : void 0;
132624
132860
  const pattern = args[0];
132625
- if (symbol2 !== void 0 && types5.isRegExp(pattern))
132861
+ if (symbol2 !== void 0 && types6.isRegExp(pattern))
132626
132862
  throw new TypeError(`String#${methodName} does not accept unbranded host RegExp values.`);
132627
132863
  if (symbol2 === void 0 || pattern === null || pattern === void 0) return fallback();
132628
132864
  const readProperty = (key3) => context?.getProperty !== void 0 ? context.getProperty(pattern, key3) : key3 === "flags" && isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, key3, budget) === void 0 ? getRegexMember(pattern, key3, budget, context) : getSandboxDataProperty(pattern, key3, budget);
@@ -135330,8 +135566,8 @@ async function definePropertiesFromObject(target, descriptors2, budget, context)
135330
135566
  }
135331
135567
  function defineDataProperty8(target, key3, descriptor, budget) {
135332
135568
  budget.visitNode();
135333
- if (isFloat32Array(target))
135334
- throw new TypeError("Typed array property descriptors are not supported.");
135569
+ if (isFloat32Array(target) && typeof key3 !== "symbol" && isFloat32Index(String(key3)) && "value" in descriptor)
135570
+ descriptor = { ...descriptor, value: float32Number(descriptor.value) };
135335
135571
  const properties = objectProperties(target, true);
135336
135572
  if (Array.isArray(properties)) {
135337
135573
  if (key3 === "length" && "value" in descriptor)
@@ -136285,8 +136521,9 @@ var init_set = __esm({
136285
136521
  });
136286
136522
 
136287
136523
  // packages/safe-js/src/interp/globals/float32array.ts
136288
- function createFloat32ArrayGlobal(budget) {
136524
+ function createFloat32ArrayGlobal(budget, nativePrototype = false) {
136289
136525
  const constructor = createSandboxClosure({
136526
+ guest: nativePrototype,
136290
136527
  sandbox: true,
136291
136528
  name: "Float32Array",
136292
136529
  length: 3,
@@ -136294,42 +136531,357 @@ function createFloat32ArrayGlobal(budget) {
136294
136531
  call: () => {
136295
136532
  throw new TypeError("Constructor Float32Array requires 'new'.");
136296
136533
  },
136297
- construct: ([source]) => {
136298
- if (Array.isArray(source) || isFloat32Array(source)) {
136299
- const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
136300
- checkFloat32Allocation(length2, budget);
136301
- if (isFloat32Array(source)) return new Float32Array(source);
136302
- const result = new Float32Array(length2);
136303
- for (let index = 0; index < length2; index += 1) {
136304
- budget.visitNode();
136305
- const descriptor = Object.getOwnPropertyDescriptor(source, index);
136306
- if (descriptor !== void 0 && !("value" in descriptor))
136307
- throw new TypeError("Float32Array input accessors are not supported.");
136308
- result[index] = float32Number(descriptor?.value);
136534
+ construct: (args, context) => {
136535
+ if (!nativePrototype) return allocateFloat32Array(args[0], budget);
136536
+ return (async () => {
136537
+ const newTarget = context?.newTarget ?? constructor;
136538
+ const candidate = context?.getProperty === void 0 ? getSandboxDataProperty(newTarget, "prototype", budget) : await context.getProperty(newTarget, "prototype");
136539
+ const prototype = candidate !== null && typeof candidate === "object" ? candidate : float32Prototypes.get(budget);
136540
+ const release2 = retainValues(budget, () => [prototype, ...args]);
136541
+ try {
136542
+ if (isSandboxArrayBuffer(args[0])) {
136543
+ const buffer = args[0];
136544
+ const number = await sandboxNumber(args[1], budget, context);
136545
+ const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
136546
+ if (!Number.isSafeInteger(offset) || offset < 0 || offset % 4 !== 0)
136547
+ throw new RangeError("Invalid Float32Array buffer offset.");
136548
+ const bytes = arrayBufferLength(buffer);
136549
+ let length;
136550
+ if (args[2] === void 0) {
136551
+ if (arrayBufferOptions(buffer) === void 0 && bytes % 4 !== 0 || offset > bytes)
136552
+ throw new RangeError("Invalid Float32Array buffer length.");
136553
+ length = Math.floor((bytes - offset) / 4);
136554
+ } else {
136555
+ const size = await sandboxNumber(args[2], budget, context);
136556
+ length = Number.isNaN(size) ? 0 : Math.trunc(size);
136557
+ if (!Number.isSafeInteger(length) || length < 0 || offset + length * 4 > arrayBufferLength(buffer))
136558
+ throw new RangeError("Invalid Float32Array view length.");
136559
+ }
136560
+ budget.allocateArrayLength(length);
136561
+ const result2 = new Float32Array(buffer, offset, args[2] === void 0 ? void 0 : length);
136562
+ if (arrayBufferOptions(buffer) !== void 0)
136563
+ float32ViewLayouts.set(result2, { byteOffset: offset, ...args[2] === void 0 ? {} : { length } });
136564
+ setSandboxPrototype(result2, prototype, budget);
136565
+ return result2;
136566
+ }
136567
+ const result = args[0] !== null && typeof args[0] === "object" && !isFloat32Array(args[0]) ? await allocateFloat32Input(args[0], budget, context) : allocateFloat32Array(args[0], budget);
136568
+ setSandboxPrototype(result, prototype, budget);
136569
+ return result;
136570
+ } finally {
136571
+ release2();
136309
136572
  }
136310
- return result;
136311
- }
136312
- const number = float32Number(source);
136313
- const length = Number.isNaN(number) ? 0 : Math.trunc(number);
136314
- if (length < 0 || !Number.isSafeInteger(length))
136315
- throw new RangeError("Invalid typed array length.");
136316
- checkFloat32Allocation(length, budget);
136317
- return new Float32Array(length);
136573
+ })();
136318
136574
  }
136319
136575
  });
136320
136576
  constructors.add(constructor);
136321
136577
  return constructor;
136322
136578
  }
136579
+ async function allocateFloat32Input(source, budget, context) {
136580
+ const callerContext = context;
136581
+ const bridge = {
136582
+ ...callerContext,
136583
+ stack: callerContext?.stack ?? [],
136584
+ thisValue: void 0,
136585
+ getProperty: callerContext?.getProperty ?? ((value, key3) => {
136586
+ const descriptor = getSandboxPropertyDescriptor(value, key3, budget);
136587
+ return descriptor === void 0 ? getSandboxDataProperty(value, key3, budget) : readPropertyDescriptor(descriptor, value, bridge);
136588
+ }),
136589
+ invokeClosure: callerContext?.invokeClosure ?? ((callee, values2, receiver, construct) => invokeBuiltinClosure(callee, values2, budget, callerContext, receiver, construct))
136590
+ };
136591
+ const values = [];
136592
+ let iterator;
136593
+ let current;
136594
+ let result;
136595
+ const release2 = retainValues(budget, () => [source, values, iterator?.retainedValue, current, result]);
136596
+ const checkData = createDataCheckpoint(budget, bridge);
136597
+ try {
136598
+ iterator = await acquireSandboxIterator(source, budget, bridge);
136599
+ let length;
136600
+ if (iterator !== void 0) {
136601
+ while (true) {
136602
+ budget.visitNode();
136603
+ const next = await iterator.next();
136604
+ if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
136605
+ if ((await readIteratorResult(iterator, next, "done")).value) break;
136606
+ current = (await readIteratorResult(iterator, next, "value")).value;
136607
+ budget.allocateArrayLength(values.length + 1);
136608
+ values.push(current);
136609
+ checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
136610
+ }
136611
+ length = values.length;
136612
+ } else {
136613
+ current = await bridge.getProperty(source, "length");
136614
+ const number = await sandboxNumber(current, budget, bridge);
136615
+ length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
136616
+ }
136617
+ checkFloat32Allocation(length, budget);
136618
+ result = new Float32Array(length);
136619
+ checkData(result, 0, true);
136620
+ for (let index = 0; index < length; index++) {
136621
+ budget.visitNode();
136622
+ current = iterator === void 0 ? await bridge.getProperty(source, String(index)) : values[index];
136623
+ result[index] = await sandboxNumber(current, budget, bridge);
136624
+ }
136625
+ return result;
136626
+ } finally {
136627
+ release2();
136628
+ }
136629
+ }
136630
+ function allocateFloat32Array(source, budget) {
136631
+ if (Array.isArray(source) || isFloat32Array(source)) {
136632
+ const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
136633
+ checkFloat32Allocation(length2, budget);
136634
+ if (isFloat32Array(source)) return new Float32Array(source);
136635
+ const result = new Float32Array(length2);
136636
+ for (let index = 0; index < length2; index += 1) {
136637
+ budget.visitNode();
136638
+ const descriptor = Object.getOwnPropertyDescriptor(source, index);
136639
+ if (descriptor !== void 0 && !("value" in descriptor))
136640
+ throw new TypeError("Float32Array input accessors are not supported.");
136641
+ result[index] = float32Number(descriptor?.value);
136642
+ }
136643
+ return result;
136644
+ }
136645
+ const number = float32Number(source);
136646
+ const length = Number.isNaN(number) ? 0 : Math.trunc(number);
136647
+ if (length < 0 || !Number.isSafeInteger(length))
136648
+ throw new RangeError("Invalid typed array length.");
136649
+ checkFloat32Allocation(length, budget);
136650
+ return new Float32Array(length);
136651
+ }
136652
+ function createFloat32ArrayPrototypes(budget, constructor) {
136653
+ const prototype = /* @__PURE__ */ Object.create(null);
136654
+ const shared = /* @__PURE__ */ Object.create(null);
136655
+ const abstractCall = () => {
136656
+ throw new TypeError("Abstract TypedArray constructor cannot be called.");
136657
+ };
136658
+ const typedArray = createSandboxClosure({
136659
+ guest: true,
136660
+ sandbox: true,
136661
+ name: "TypedArray",
136662
+ length: 0,
136663
+ call: abstractCall,
136664
+ construct: abstractCall
136665
+ });
136666
+ Object.defineProperty(materializeFunctionProperties(typedArray), "prototype", { value: shared, writable: false });
136667
+ Object.defineProperty(materializeFunctionProperties(typedArray), "from", {
136668
+ writable: true,
136669
+ configurable: true,
136670
+ value: createSandboxClosure({
136671
+ guest: true,
136672
+ sandbox: true,
136673
+ name: "from",
136674
+ length: 1,
136675
+ call: async (args, context) => {
136676
+ const target = context?.thisValue;
136677
+ const [source, mapper, receiver] = args;
136678
+ if (!isSandboxClosure(target) || target.construct === void 0)
136679
+ throw new TypeError("TypedArray.from requires a constructor receiver.");
136680
+ if (mapper !== void 0 && !isSandboxClosure(mapper))
136681
+ throw new TypeError("TypedArray.from mapper must be callable.");
136682
+ if (source === null || source === void 0)
136683
+ throw new TypeError("TypedArray.from requires a non-null source.");
136684
+ const callerContext = context;
136685
+ context = {
136686
+ ...callerContext,
136687
+ stack: callerContext?.stack ?? [],
136688
+ thisValue: target,
136689
+ getProperty: callerContext?.getProperty ?? ((value, key3) => {
136690
+ const descriptor = getSandboxPropertyDescriptor(value, key3, budget);
136691
+ return descriptor === void 0 ? getSandboxDataProperty(value, key3, budget) : readPropertyDescriptor(descriptor, value, context);
136692
+ }),
136693
+ invokeClosure: callerContext?.invokeClosure ?? ((callee, values2, thisValue, construct) => invokeBuiltinClosure(callee, values2, budget, callerContext, thisValue, construct))
136694
+ };
136695
+ let result;
136696
+ let current;
136697
+ let iterator;
136698
+ const values = [];
136699
+ const release2 = retainValues(budget, () => [target, result, current, iterator?.retainedValue, values, ...args]);
136700
+ const checkData = createDataCheckpoint(budget, context);
136701
+ const read = (key3) => context?.getProperty === void 0 ? getSandboxDataProperty(source, key3, budget) : context.getProperty(source, key3);
136702
+ try {
136703
+ iterator = await acquireSandboxIterator(source, budget, context);
136704
+ let length;
136705
+ if (iterator !== void 0) {
136706
+ while (true) {
136707
+ budget.visitNode();
136708
+ const next = await iterator.next();
136709
+ if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
136710
+ if ((await readIteratorResult(iterator, next, "done")).value) break;
136711
+ current = (await readIteratorResult(iterator, next, "value")).value;
136712
+ budget.allocateArrayLength(values.length + 1);
136713
+ values.push(current);
136714
+ checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
136715
+ }
136716
+ length = values.length;
136717
+ } else {
136718
+ const number = await sandboxNumber(await read("length"), budget, context);
136719
+ length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
136720
+ }
136721
+ result = await invokeBuiltinClosure(target, [length], budget, context, void 0, true);
136722
+ if (!isFloat32Array(result) || float32Storage(result).length < length)
136723
+ throw new TypeError("TypedArray.from constructor must return sufficient typed storage.");
136724
+ checkData(result, 0, true);
136725
+ for (let index = 0; index < length; index++) {
136726
+ budget.visitNode();
136727
+ current = iterator === void 0 ? await read(String(index)) : values[index];
136728
+ if (mapper !== void 0)
136729
+ current = await invokeBuiltinClosure(mapper, [current, index], budget, context, receiver);
136730
+ result[index] = await sandboxNumber(current, budget, context);
136731
+ }
136732
+ return result;
136733
+ } finally {
136734
+ release2();
136735
+ }
136736
+ }
136737
+ })
136738
+ });
136739
+ Object.defineProperty(materializeFunctionProperties(typedArray), "of", {
136740
+ writable: true,
136741
+ configurable: true,
136742
+ value: createSandboxClosure({
136743
+ guest: true,
136744
+ sandbox: true,
136745
+ name: "of",
136746
+ length: 0,
136747
+ call: async (args, context) => {
136748
+ const target = context?.thisValue;
136749
+ if (!isSandboxClosure(target) || target.construct === void 0)
136750
+ throw new TypeError("TypedArray.of requires a constructor receiver.");
136751
+ let result;
136752
+ const release2 = retainValues(budget, () => [target, result, ...args]);
136753
+ try {
136754
+ result = await invokeBuiltinClosure(target, [args.length], budget, context, void 0, true);
136755
+ if (!isFloat32Array(result) || float32Storage(result).length < args.length)
136756
+ throw new TypeError("TypedArray.of constructor must return sufficient typed storage.");
136757
+ for (let index = 0; index < args.length; index++) {
136758
+ budget.visitNode();
136759
+ result[index] = await sandboxNumber(args[index], budget, context);
136760
+ }
136761
+ return result;
136762
+ } finally {
136763
+ release2();
136764
+ }
136765
+ }
136766
+ })
136767
+ });
136768
+ Object.defineProperties(materializeFunctionProperties(constructor), {
136769
+ prototype: { value: prototype, writable: false },
136770
+ BYTES_PER_ELEMENT: { value: 4, writable: false, enumerable: false, configurable: false }
136771
+ });
136772
+ Object.defineProperties(prototype, {
136773
+ constructor: { value: constructor, writable: true, configurable: true },
136774
+ BYTES_PER_ELEMENT: { value: 4 }
136775
+ });
136776
+ Object.defineProperty(shared, "constructor", { value: typedArray, writable: true, configurable: true });
136777
+ setSandboxPrototype(constructor, typedArray);
136778
+ setSandboxPrototype(prototype, shared);
136779
+ setSandboxPrototype(shared, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
136780
+ const getters = [];
136781
+ const species = createSandboxClosure({
136782
+ guest: true,
136783
+ sandbox: true,
136784
+ name: "get [Symbol.species]",
136785
+ length: 0,
136786
+ call: (_args, context) => context?.thisValue
136787
+ });
136788
+ getters.push(species);
136789
+ Object.defineProperty(materializeFunctionProperties(typedArray), Symbol.species, {
136790
+ get: accessorAdapter(species, "get"),
136791
+ configurable: true
136792
+ });
136793
+ for (const key3 of ["length", "byteLength", "byteOffset", "buffer"]) {
136794
+ const getter = createSandboxClosure({
136795
+ guest: true,
136796
+ sandbox: true,
136797
+ name: `get ${key3}`,
136798
+ length: 0,
136799
+ call: (_args, context) => {
136800
+ if (!isFloat32Array(context?.thisValue)) throw new TypeError(`TypedArray ${key3} requires a typed array receiver.`);
136801
+ const storage2 = float32Storage(context.thisValue);
136802
+ return key3 === "byteLength" ? storage2.length * 4 : storage2[key3];
136803
+ }
136804
+ });
136805
+ getters.push(getter);
136806
+ Object.defineProperty(shared, key3, { get: accessorAdapter(getter, "get"), configurable: true });
136807
+ }
136808
+ for (const key3 of ["set", "slice", "subarray"])
136809
+ Object.defineProperty(shared, key3, { value: getFloat32Member(new Float32Array(0), key3, budget, constructor), writable: true, configurable: true });
136810
+ const arrayPrototype = resolveIntrinsicIdentity(budget, '["Array","prototype"]');
136811
+ Object.defineProperty(shared, "toString", { value: getSandboxDataProperty(arrayPrototype, "toString", budget), writable: true, configurable: true });
136812
+ Object.defineProperty(shared, "join", {
136813
+ writable: true,
136814
+ configurable: true,
136815
+ value: createSandboxClosure({
136816
+ guest: true,
136817
+ sandbox: true,
136818
+ name: "join",
136819
+ length: 1,
136820
+ call: async (args, context) => {
136821
+ if (!isFloat32Array(context?.thisValue)) throw new TypeError("TypedArray join requires a typed array receiver.");
136822
+ const receiver = context.thisValue;
136823
+ const length = float32Storage(receiver, true).length;
136824
+ let separator = ",";
136825
+ let text5 = "";
136826
+ const release2 = retainValues(budget, () => [receiver, separator, text5, ...args]);
136827
+ try {
136828
+ if (args[0] !== void 0) separator = await sandboxString(args[0], budget, context);
136829
+ for (let index = 0; index < length; index++) {
136830
+ budget.visitNode();
136831
+ const value = receiver[index];
136832
+ text5 = budget.allocateString(text5 + (index === 0 ? "" : separator) + (value === void 0 ? "" : String(value)));
136833
+ }
136834
+ return text5;
136835
+ } finally {
136836
+ release2();
136837
+ }
136838
+ }
136839
+ })
136840
+ });
136841
+ const tagGetter = createSandboxClosure({
136842
+ guest: true,
136843
+ sandbox: true,
136844
+ name: "get [Symbol.toStringTag]",
136845
+ length: 0,
136846
+ call: (_args, context) => isFloat32Array(context?.thisValue) ? "Float32Array" : void 0
136847
+ });
136848
+ getters.push(tagGetter);
136849
+ Object.defineProperty(shared, Symbol.toStringTag, { get: accessorAdapter(tagGetter, "get"), configurable: true });
136850
+ for (const key3 of ["values", "keys", "entries"]) {
136851
+ const method = getSandboxDataProperty(arrayPrototype, key3, budget);
136852
+ const closure = createSandboxClosure({
136853
+ guest: true,
136854
+ sandbox: true,
136855
+ name: key3,
136856
+ length: 0,
136857
+ call: (args, context) => {
136858
+ if (!isFloat32Array(context?.thisValue)) throw new TypeError(`TypedArray ${key3} requires a typed array receiver.`);
136859
+ float32Storage(context.thisValue, true);
136860
+ return invokeBuiltinClosure(method, args, budget, context, context.thisValue);
136861
+ }
136862
+ });
136863
+ Object.defineProperty(shared, key3, { value: closure, writable: true, configurable: true });
136864
+ if (key3 === "values") Object.defineProperty(shared, Symbol.iterator, { value: closure, writable: true, configurable: true });
136865
+ }
136866
+ float32Prototypes.set(budget, prototype);
136867
+ registerBuiltinIdentities(budget, { Float32Array: constructor, "%TypedArray%": typedArray });
136868
+ registerIntrinsicFunction(budget, constructor);
136869
+ registerIntrinsicFunction(budget, typedArray);
136870
+ registerIntrinsicObject(budget, prototype);
136871
+ registerIntrinsicObject(budget, shared);
136872
+ for (const getter of getters) registerIntrinsicFunction(budget, getter);
136873
+ }
136323
136874
  function isFloat32ArrayConstructor(value) {
136324
136875
  return typeof value === "object" && value !== null && constructors.has(value);
136325
136876
  }
136326
- function getFloat32Member(value, property, budget) {
136877
+ function getFloat32Member(value, property, budget, defaultConstructor) {
136327
136878
  const key3 = String(property);
136328
136879
  const descriptor = Object.getOwnPropertyDescriptor(value, key3);
136329
136880
  if (descriptor !== void 0) {
136330
136881
  if (!("value" in descriptor)) throw new TypeError("Float32Array accessors are not supported.");
136331
136882
  return descriptor.value;
136332
136883
  }
136884
+ if (float32Prototypes.has(budget)) return void 0;
136333
136885
  const storage2 = float32Storage(value);
136334
136886
  if (key3 === "length") return storage2.length;
136335
136887
  if (key3 === "byteLength") return storage2.length * 4;
@@ -136337,6 +136889,7 @@ function getFloat32Member(value, property, budget) {
136337
136889
  if (key3 === "BYTES_PER_ELEMENT") return 4;
136338
136890
  if (!["set", "slice", "subarray"].includes(key3)) return void 0;
136339
136891
  return createSandboxClosure({
136892
+ guest: true,
136340
136893
  sandbox: true,
136341
136894
  name: key3,
136342
136895
  length: key3 === "set" ? 1 : 2,
@@ -136344,66 +136897,134 @@ function getFloat32Member(value, property, budget) {
136344
136897
  const receiver = context?.thisValue;
136345
136898
  if (!isFloat32Array(receiver))
136346
136899
  throw new TypeError(`Float32Array#${key3} requires a Float32Array receiver.`);
136347
- const storage3 = float32Storage(receiver);
136900
+ const storage3 = float32Storage(receiver, key3 === "slice");
136901
+ const bridge = {
136902
+ ...context,
136903
+ stack: context?.stack ?? [],
136904
+ thisValue: receiver,
136905
+ getProperty: context?.getProperty ?? ((value2, property2) => {
136906
+ const descriptor2 = getSandboxPropertyDescriptor(value2, property2, budget);
136907
+ return descriptor2 === void 0 ? getSandboxDataProperty(value2, property2, budget) : readPropertyDescriptor(descriptor2, value2, bridge);
136908
+ }),
136909
+ invokeClosure: context?.invokeClosure ?? ((callee, values, thisValue, construct) => invokeBuiltinClosure(callee, values, budget, context, thisValue, construct))
136910
+ };
136348
136911
  if (key3 === "set") {
136349
- const [source, offsetValue = 0] = args;
136350
- if (!Array.isArray(source) && !isFloat32Array(source))
136351
- throw new TypeError("Float32Array#set requires an array or Float32Array.");
136352
- const number = float32Number(offsetValue);
136353
- const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
136354
- const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
136355
- if (offset < 0 || !Number.isSafeInteger(offset) || offset + length2 > storage3.length)
136356
- throw new RangeError("Float32Array#set source is out of bounds.");
136357
- if (isFloat32Array(source)) {
136358
- Float32Array.prototype.set.call(receiver, source, offset);
136359
- return void 0;
136360
- }
136361
- checkFloat32Allocation(length2, budget);
136362
- const copied = new Float32Array(length2);
136363
- for (let index = 0; index < length2; index += 1) {
136364
- budget.visitNode();
136365
- const entry = Object.getOwnPropertyDescriptor(source, index);
136366
- if (entry !== void 0 && !("value" in entry))
136367
- throw new TypeError("Float32Array input accessors are not supported.");
136368
- copied[index] = float32Number(entry?.value);
136369
- }
136370
- Float32Array.prototype.set.call(receiver, copied, offset);
136371
- return void 0;
136912
+ return (async () => {
136913
+ const [source, offsetValue = 0] = args;
136914
+ let current;
136915
+ let sourceObject;
136916
+ const release2 = retainValues(budget, () => [receiver, sourceObject, current, ...args]);
136917
+ try {
136918
+ const number = await sandboxNumber(offsetValue, budget, bridge);
136919
+ const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
136920
+ if (offset < 0) throw new RangeError("Float32Array#set offset is out of bounds.");
136921
+ const targetStorage = float32Storage(receiver, true);
136922
+ if (source === null || source === void 0) throw new TypeError("Float32Array#set requires a non-null source.");
136923
+ let length;
136924
+ if (isFloat32Array(source)) length = float32Storage(source, true).length;
136925
+ else {
136926
+ sourceObject = typeof source === "object" ? source : createSandboxBox(source);
136927
+ current = await bridge.getProperty(sourceObject, "length");
136928
+ const size = await sandboxNumber(current, budget, bridge);
136929
+ length = Number.isNaN(size) || size <= 0 ? 0 : Math.min(Math.trunc(size), Number.MAX_SAFE_INTEGER);
136930
+ }
136931
+ if (offset + length > targetStorage.length) throw new RangeError("Float32Array#set source is out of bounds.");
136932
+ if (isFloat32Array(source)) Float32Array.prototype.set.call(receiver, source, offset);
136933
+ else for (let index = 0; index < length; index++) {
136934
+ budget.visitNode();
136935
+ current = await bridge.getProperty(sourceObject, String(index));
136936
+ receiver[offset + index] = await sandboxNumber(current, budget, bridge);
136937
+ }
136938
+ return void 0;
136939
+ } finally {
136940
+ release2();
136941
+ }
136942
+ })();
136372
136943
  }
136373
- const start = relativeIndex(args[0], storage3.length, 0);
136374
- const end = relativeIndex(args[1], storage3.length, storage3.length);
136375
- const length = Math.max(end - start, 0);
136376
- if (key3 === "subarray")
136377
- return new Float32Array(storage3.buffer, storage3.byteOffset + start * 4, length);
136378
- checkFloat32Allocation(length, budget);
136379
- const result = new Float32Array(length);
136380
- new Uint8Array(result.buffer).set(
136381
- new Uint8Array(storage3.buffer, storage3.byteOffset + start * 4, length * 4)
136382
- );
136383
- return result;
136944
+ return (async () => {
136945
+ let candidate;
136946
+ let result;
136947
+ const release2 = retainValues(budget, () => [receiver, candidate, result, ...args]);
136948
+ try {
136949
+ const start = relativeIndex(await sandboxNumber(args[0], budget, bridge), storage3.length);
136950
+ const end = args[1] === void 0 ? storage3.length : relativeIndex(await sandboxNumber(args[1], budget, bridge), storage3.length);
136951
+ const length = Math.max(end - start, 0);
136952
+ const layout = float32ViewLayouts.get(receiver);
136953
+ const offset = (layout?.byteOffset ?? storage3.byteOffset) + start * 4;
136954
+ const tracking = layout !== void 0 && layout.length === void 0 && args[1] === void 0;
136955
+ if (defaultConstructor !== void 0) {
136956
+ candidate = await bridge.getProperty(receiver, "constructor");
136957
+ if (candidate !== void 0) {
136958
+ if (candidate === null || typeof candidate !== "object")
136959
+ throw new TypeError("TypedArray constructor must be an object.");
136960
+ candidate = await bridge.getProperty(candidate, Symbol.species);
136961
+ if (candidate !== void 0 && candidate !== null && (!isSandboxClosure(candidate) || candidate.construct === void 0))
136962
+ throw new TypeError("TypedArray species must be a constructor.");
136963
+ }
136964
+ }
136965
+ if (candidate !== void 0 && candidate !== null && candidate !== defaultConstructor) {
136966
+ const values = key3 === "slice" ? [length] : [storage3.buffer, offset, tracking ? void 0 : length];
136967
+ result = await invokeBuiltinClosure(candidate, values, budget, bridge, void 0, true);
136968
+ if (!isFloat32Array(result)) throw new TypeError("TypedArray species must return typed storage.");
136969
+ const target = float32Storage(result, key3 === "slice");
136970
+ if (key3 === "slice" && target.length < length)
136971
+ throw new TypeError("TypedArray species returned insufficient storage.");
136972
+ }
136973
+ if (key3 === "subarray") {
136974
+ if (result === void 0) {
136975
+ result = new Float32Array(storage3.buffer, offset, tracking ? void 0 : length);
136976
+ if (arrayBufferOptions(storage3.buffer) !== void 0)
136977
+ float32ViewLayouts.set(result, { byteOffset: offset, ...tracking ? {} : { length } });
136978
+ }
136979
+ return result;
136980
+ }
136981
+ if (result === void 0) {
136982
+ checkFloat32Allocation(length, budget);
136983
+ result = new Float32Array(length);
136984
+ }
136985
+ if (!isFloat32Array(result)) throw new TypeError("TypedArray species must return typed storage.");
136986
+ if (length > 0) {
136987
+ const current = float32Storage(receiver, true);
136988
+ const target = float32Storage(result, true);
136989
+ const count = Math.min(length, Math.max(current.length - start, 0));
136990
+ if (count > 0) {
136991
+ const sourceBytes = new Uint8Array(current.buffer, current.byteOffset + start * 4, count * 4);
136992
+ const targetBytes = new Uint8Array(target.buffer, target.byteOffset, count * 4);
136993
+ if (current.buffer === target.buffer && targetBytes.byteOffset > sourceBytes.byteOffset && targetBytes.byteOffset < sourceBytes.byteOffset + sourceBytes.length) {
136994
+ for (let index = 0; index < sourceBytes.length; index++) {
136995
+ budget.visitNode();
136996
+ targetBytes[index] = sourceBytes[index];
136997
+ }
136998
+ } else targetBytes.set(sourceBytes);
136999
+ }
137000
+ }
137001
+ return result;
137002
+ } finally {
137003
+ release2();
137004
+ }
137005
+ })();
136384
137006
  }
136385
137007
  });
136386
137008
  }
136387
- function setFloat32Member(value, property, entry) {
136388
- const key3 = String(property);
136389
- if (isFloat32Index(key3)) {
137009
+ function setFloat32Member(value, property, entry, budget) {
137010
+ const key3 = typeof property === "symbol" ? property : String(property);
137011
+ if (typeof key3 !== "symbol" && isFloat32Index(key3)) {
136390
137012
  Reflect.set(value, key3, float32Number(entry));
136391
137013
  return;
136392
137014
  }
136393
137015
  const descriptor = Object.getOwnPropertyDescriptor(value, key3);
136394
- if (descriptor === void 0 && ["length", "byteLength", "byteOffset", "buffer", "BYTES_PER_ELEMENT"].includes(key3))
136395
- throw new TypeError(`Cannot assign to read only property '${key3}'.`);
136396
- if (descriptor !== void 0 && (!("value" in descriptor) || !descriptor.writable))
136397
- throw new TypeError(`Cannot assign to read only property '${key3}'.`);
137016
+ const inherited = descriptor ?? (budget === void 0 ? void 0 : getSandboxPropertyDescriptor(value, key3, budget));
137017
+ if (descriptor === void 0 && typeof key3 === "string" && (budget === void 0 || !float32Prototypes.has(budget)) && ["length", "byteLength", "byteOffset", "buffer", "BYTES_PER_ELEMENT"].includes(key3))
137018
+ throw new TypeError(`Cannot assign to read only property '${String(key3)}'.`);
137019
+ if (inherited !== void 0 && (!("value" in inherited) || !inherited.writable))
137020
+ throw new TypeError(`Cannot assign to read only property '${String(key3)}'.`);
136398
137021
  Object.defineProperty(
136399
137022
  value,
136400
137023
  key3,
136401
137024
  descriptor === void 0 ? { value: entry, configurable: true, enumerable: true, writable: true } : { value: entry }
136402
137025
  );
136403
137026
  }
136404
- function relativeIndex(value, length, fallback) {
136405
- if (value === void 0) return fallback;
136406
- const numeric = float32Number(value);
137027
+ function relativeIndex(numeric, length) {
136407
137028
  const integer3 = Number.isNaN(numeric) ? 0 : Math.trunc(numeric);
136408
137029
  return integer3 < 0 ? Math.max(length + integer3, 0) : Math.min(integer3, length);
136409
137030
  }
@@ -136413,6 +137034,17 @@ var init_float32array2 = __esm({
136413
137034
  "use strict";
136414
137035
  init_float32();
136415
137036
  init_values();
137037
+ init_accessors();
137038
+ init_float32_prototypes();
137039
+ init_object_model();
137040
+ init_intrinsics();
137041
+ init_builtin_call();
137042
+ init_resources();
137043
+ init_string_coercion();
137044
+ init_iteration();
137045
+ init_data_checkpoint();
137046
+ init_boxed();
137047
+ init_array_buffer();
136416
137048
  constructors = /* @__PURE__ */ new WeakSet();
136417
137049
  }
136418
137050
  });
@@ -136590,7 +137222,7 @@ async function ordinaryHasInstance(value, constructor, budget, context) {
136590
137222
  budget.visitNode();
136591
137223
  return evaluateInstanceof(value, constructor.boundTarget, budget, context);
136592
137224
  }
136593
- if (isFloat32ArrayConstructor(constructor)) return isFloat32Array(value);
137225
+ if (isFloat32ArrayConstructor(constructor) && !isGuestClosure(constructor)) return isFloat32Array(value);
136594
137226
  if ((!isGuestClosure(constructor) || value !== null && typeof value === "object" && !hasExplicitSandboxPrototype(value)) && isSandboxErrorConstructorInstance2(value, constructor)) return true;
136595
137227
  if (!isGuestClosure(constructor) || typeof value !== "object" || value === null) return false;
136596
137228
  const prototype = await readInstanceProperty(constructor, "prototype", budget, context);
@@ -139190,7 +139822,7 @@ async function evaluateMemberCallExpression(node, context) {
139190
139822
  if (isFloat32Array(member.object)) {
139191
139823
  return evaluateResolvedCallExpression(
139192
139824
  node,
139193
- getFloat32Member(member.object, member.property, context.budget),
139825
+ await getPropertyValue(member.object, member.property, context),
139194
139826
  context,
139195
139827
  member.object
139196
139828
  );
@@ -139727,8 +140359,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
139727
140359
  if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
139728
140360
  if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
139729
140361
  if (isFloat32Array(target)) {
139730
- if (typeof property === "symbol") throw new TypeError("Typed array symbol properties are not yet supported.");
139731
- setFloat32Member(target, property, value);
140362
+ setFloat32Member(target, property, value, budget);
139732
140363
  return;
139733
140364
  }
139734
140365
  if (isSandboxRegex(target)) {
@@ -142849,15 +143480,16 @@ function measureSandboxData(values, options = {}) {
142849
143480
  }
142850
143481
  const prototype = getSandboxPrototype(value);
142851
143482
  if (prototype !== null) visit(prototype, depth + 1);
143483
+ if (isSandboxArrayBuffer(value)) usage += arrayBufferLength(value);
142852
143484
  if (isFloat32Array(value)) {
142853
143485
  const storage2 = float32Storage(value);
142854
- if (!seen.has(storage2.buffer)) {
142855
- seen.add(storage2.buffer);
142856
- usage += storage2.byteLength;
142857
- }
142858
- for (const [key3, descriptor] of float32DataProperties(value)) {
142859
- usage += key3.length + 1;
142860
- visit(descriptor.value, depth + 1);
143486
+ visit(storage2.buffer, depth + 1);
143487
+ for (const [key3, descriptor] of float32Properties(value)) {
143488
+ usage += 1;
143489
+ if (typeof key3 === "string") usage += key3.length;
143490
+ else visit(key3, depth + 1);
143491
+ if ("value" in descriptor) visit(descriptor.value, depth + 1);
143492
+ else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
142861
143493
  }
142862
143494
  return;
142863
143495
  }
@@ -142990,7 +143622,7 @@ function measureSandboxData(values, options = {}) {
142990
143622
  const descriptor = Object.getOwnPropertyDescriptor(value, key3);
142991
143623
  if (descriptor !== void 0) descriptors2.push([key3, descriptor]);
142992
143624
  }
142993
- const includeNonEnumerable = isSandboxDate(value) || sandboxErrorTypes.has(value) || hasManagedDescriptors(value);
143625
+ const includeNonEnumerable = isSandboxDate(value) || isSandboxArrayBuffer(value) || sandboxErrorTypes.has(value) || hasManagedDescriptors(value);
142994
143626
  for (const [key3, descriptor] of descriptors2) {
142995
143627
  if (!descriptor.enumerable && !includeNonEnumerable) continue;
142996
143628
  usage += 1 + key3.length;
@@ -143186,6 +143818,20 @@ function copyToSandbox(value, state, path193 = "<root>", cloneSandboxCollections
143186
143818
  }
143187
143819
  return sandboxPromise;
143188
143820
  }
143821
+ if (isSandboxArrayBuffer(value)) {
143822
+ const existing = state.seen.get(value);
143823
+ if (existing !== void 0) return existing;
143824
+ const copy = copyArrayBufferStorage(value, state);
143825
+ state.seen.set(value, copy);
143826
+ for (const [key3, descriptor] of arrayBufferDataProperties(value)) {
143827
+ Object.defineProperty(copy, key3, {
143828
+ ...descriptor,
143829
+ value: copyToSandbox(descriptor.value, state, joinPath(path193, key3), cloneSandboxCollections, depth + 1)
143830
+ });
143831
+ }
143832
+ if (!Object.isExtensible(value)) Object.preventExtensions(copy);
143833
+ return copy;
143834
+ }
143189
143835
  if (nodeTypes.isDate(value)) {
143190
143836
  const existing = state.seen.get(value);
143191
143837
  if (existing !== void 0) return existing;
@@ -143204,6 +143850,7 @@ function copyToSandbox(value, state, path193 = "<root>", cloneSandboxCollections
143204
143850
  if (existing !== void 0) return existing;
143205
143851
  const copy = copyFloat32Storage(value, state);
143206
143852
  state.seen.set(value, copy);
143853
+ copyToSandbox(float32Storage(value).buffer, state, `${path193}.buffer`, cloneSandboxCollections, depth + 1);
143207
143854
  for (const [key3, descriptor] of float32DataProperties(value)) {
143208
143855
  Object.defineProperty(copy, key3, {
143209
143856
  ...descriptor,
@@ -143425,6 +144072,7 @@ function copyFromSandbox(value, state, path193 = "<root>", options, depth = 0) {
143425
144072
  if (existing !== void 0) return existing;
143426
144073
  const copy = copyFloat32Storage(value, state);
143427
144074
  state.seen.set(value, copy);
144075
+ copyFromSandbox(float32Storage(value).buffer, state, `${path193}.buffer`, options, depth + 1);
143428
144076
  for (const [key3, descriptor] of float32DataProperties(value)) {
143429
144077
  Object.defineProperty(copy, key3, {
143430
144078
  ...descriptor,
@@ -143434,6 +144082,20 @@ function copyFromSandbox(value, state, path193 = "<root>", options, depth = 0) {
143434
144082
  if (!Object.isExtensible(value)) Object.preventExtensions(copy);
143435
144083
  return copy;
143436
144084
  }
144085
+ if (isSandboxArrayBuffer(value)) {
144086
+ const existing = state.seen.get(value);
144087
+ if (existing !== void 0) return existing;
144088
+ const copy = copyArrayBufferStorage(value, state);
144089
+ state.seen.set(value, copy);
144090
+ for (const [key3, descriptor] of arrayBufferDataProperties(value)) {
144091
+ Object.defineProperty(copy, key3, {
144092
+ ...descriptor,
144093
+ value: copyFromSandbox(descriptor.value, state, joinPath(path193, key3), options, depth + 1)
144094
+ });
144095
+ }
144096
+ if (!Object.isExtensible(value)) Object.preventExtensions(copy);
144097
+ return copy;
144098
+ }
143437
144099
  if (isSandboxDate(value)) {
143438
144100
  const existing = state.seen.get(value);
143439
144101
  if (existing !== void 0) return existing;
@@ -143595,6 +144257,16 @@ function allocateSandboxValue2(value, budget, seen) {
143595
144257
  budget.allocateString(value);
143596
144258
  return;
143597
144259
  }
144260
+ if (isSandboxArrayBuffer(value)) {
144261
+ if (seen.has(value)) return;
144262
+ seen.add(value);
144263
+ budget.allocateArrayLength(arrayBufferLength(value));
144264
+ for (const [key3, descriptor] of arrayBufferDataProperties(value)) {
144265
+ if (typeof key3 === "string") budget.allocateString(key3);
144266
+ allocateSandboxValue2(descriptor.value, budget, seen);
144267
+ }
144268
+ return;
144269
+ }
143598
144270
  if (isSandboxBox(value)) {
143599
144271
  if (seen.has(value)) return;
143600
144272
  seen.add(value);
@@ -143755,6 +144427,7 @@ var init_values = __esm({
143755
144427
  "packages/safe-js/src/interp/values.ts"() {
143756
144428
  "use strict";
143757
144429
  init_otel2();
144430
+ init_array_buffer();
143758
144431
  init_internal_symbols();
143759
144432
  init_intrinsics();
143760
144433
  init_generator_properties();
@@ -144223,7 +144896,7 @@ function serializeDumpValue(value, path193, state) {
144223
144896
  if (hasGuestObjectState(value) && !(state.trustedRunReplay && (isSandboxDate(value) || isSandboxPromise(value) || isPromiseResolvingFunction(value)))) {
144224
144897
  throw new TypeError("Guest function properties and prototype links cannot be serialized.");
144225
144898
  }
144226
- if (isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path193, state);
144899
+ if (isSandboxArrayBuffer(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path193, state);
144227
144900
  if (Array.isArray(value)) {
144228
144901
  const reference2 = serializeHeapReference(value, path193, state);
144229
144902
  if (reference2 !== void 0) {
@@ -144295,11 +144968,21 @@ function serializeHeapReference(value, path193, state) {
144295
144968
  const serialized = serializeDumpValue(entry, `${path193}.<date-property>`, state);
144296
144969
  return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
144297
144970
  });
144971
+ } else if (isSandboxArrayBuffer(value)) {
144972
+ state.heap[String(id)] = {
144973
+ ...encodeArrayBufferStorage(value, id, state.float32Buffers, (id2) => ({ kind: "ref", id: id2 })),
144974
+ state: captureArrayBufferState(value, (entry) => {
144975
+ const serialized = serializeDumpValue(entry, `${path193}.<buffer>`, state);
144976
+ return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
144977
+ })
144978
+ };
144298
144979
  } else if (isFloat32Array(value)) {
144299
- const storage2 = encodeFloat32Storage(value, id, state.float32Buffers, (id2) => ({
144300
- kind: "ref",
144301
- id: id2
144302
- }));
144980
+ const backing = float32Storage(value);
144981
+ const storage2 = {
144982
+ kind: "float32array",
144983
+ ...encodeFloat32Layout(value),
144984
+ buffer: serializeHeapReference(backing.buffer, `${path193}.buffer`, state)
144985
+ };
144303
144986
  const entries = /* @__PURE__ */ Object.create(null);
144304
144987
  state.heap[String(id)] = { ...storage2, entries };
144305
144988
  for (const [key3, descriptor] of float32DataProperties(value)) {
@@ -144365,7 +145048,7 @@ function indexHeapContainers(snapshot2) {
144365
145048
  const heapIds = /* @__PURE__ */ new Map();
144366
145049
  let nextId = 1;
144367
145050
  for (const [value, stat35] of stats2.entries()) {
144368
- if (stat35.count > 1 || stat35.forceHeap === true || guestValues.has(value) || stat35.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
145051
+ if (stat35.count > 1 || stat35.forceHeap === true || guestValues.has(value) || stat35.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || isSandboxArrayBuffer(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
144369
145052
  heapIds.set(value, nextId);
144370
145053
  nextId += 1;
144371
145054
  }
@@ -144397,12 +145080,16 @@ function collectContainerStats(value, stats2, ancestors, guestValues, depth = 0)
144397
145080
  stat35.expanded = true;
144398
145081
  ancestors.add(value);
144399
145082
  const guestEntries = [];
144400
- const guest = captureGuestHeapNode(value, (entry) => {
145083
+ if (isFloat32Array(value)) guestEntries.push(float32Storage(value).buffer);
145084
+ const guest = isSandboxArrayBuffer(value) ? { kind: "arraybuffer", state: captureArrayBufferState(value, (entry) => {
145085
+ guestEntries.push(entry);
145086
+ return null;
145087
+ }) } : captureGuestHeapNode(value, (entry) => {
144401
145088
  guestEntries.push(entry);
144402
145089
  return null;
144403
145090
  });
144404
145091
  if (guest !== void 0) {
144405
- guestValues.add(value);
145092
+ if (!isSandboxArrayBuffer(value)) guestValues.add(value);
144406
145093
  for (const entry of guestEntries) {
144407
145094
  collectContainerStats(entry, stats2, ancestors, guestValues, depth + 1);
144408
145095
  if (entry !== null && typeof entry === "object") stats2.get(entry).forceHeap = true;
@@ -144410,6 +145097,7 @@ function collectContainerStats(value, stats2, ancestors, guestValues, depth = 0)
144410
145097
  ancestors.delete(value);
144411
145098
  return;
144412
145099
  }
145100
+ for (const entry of guestEntries) collectContainerStats(entry, stats2, ancestors, guestValues, depth + 1);
144413
145101
  if (!Array.isArray(value) && !isPlainObject10(value) && !isFloat32Array(value) && !isSandboxDate(value)) {
144414
145102
  ancestors.delete(value);
144415
145103
  return;
@@ -144476,6 +145164,8 @@ var init_dump_format = __esm({
144476
145164
  init_arrays();
144477
145165
  init_float32();
144478
145166
  init_float32array();
145167
+ init_array_buffer();
145168
+ init_array_buffer2();
144479
145169
  init_date();
144480
145170
  init_date_properties();
144481
145171
  init_boxed();
@@ -145392,12 +146082,43 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path193) {
145392
146082
  state.seen.set(value, date);
145393
146083
  return date;
145394
146084
  }
146085
+ if (isSandboxArrayBuffer(value)) {
146086
+ const existing = state.seen.get(value);
146087
+ if (existing !== void 0) return existing;
146088
+ const length = arrayBufferLength(value);
146089
+ budget.allocateArrayLength(length);
146090
+ budget.provisionDataUsage(length + 1)();
146091
+ const copy = copyArrayBufferStorage(value, state);
146092
+ state.seen.set(value, copy);
146093
+ for (const [key3, descriptor] of arrayBufferDataProperties(value)) {
146094
+ if (typeof key3 === "symbol") throw new TypeError("Host ArrayBuffer symbol properties require an explicit capability path.");
146095
+ Object.defineProperty(copy, key3, {
146096
+ ...descriptor,
146097
+ value: copyHostValueToSandbox(
146098
+ descriptor.value,
146099
+ stackFrames,
146100
+ { ...options, capabilityPath: [...options.capabilityPath ?? [], key3] },
146101
+ state,
146102
+ joinPath2(path193, key3)
146103
+ )
146104
+ });
146105
+ }
146106
+ if (!Object.isExtensible(value)) Object.preventExtensions(copy);
146107
+ return copy;
146108
+ }
145395
146109
  if (isFloat32Array(value)) {
145396
146110
  const existing = state.seen.get(value);
145397
146111
  if (existing !== void 0) return existing;
145398
146112
  checkFloat32Allocation(Math.ceil(float32Storage(value).byteLength / 4), budget);
145399
146113
  const copy = copyFloat32Storage(value, state);
145400
146114
  state.seen.set(value, copy);
146115
+ copyHostValueToSandbox(
146116
+ float32Storage(value).buffer,
146117
+ stackFrames,
146118
+ { ...options, capabilityPath: [...options.capabilityPath ?? [], "buffer"] },
146119
+ state,
146120
+ `${path193}.buffer`
146121
+ );
145401
146122
  for (const [key3, descriptor] of float32DataProperties(value)) {
145402
146123
  Object.defineProperty(copy, key3, {
145403
146124
  ...descriptor,
@@ -145679,6 +146400,7 @@ var init_host_bridge = __esm({
145679
146400
  init_shape();
145680
146401
  init_budget2();
145681
146402
  init_compile_guard();
146403
+ init_array_buffer();
145682
146404
  init_float32();
145683
146405
  init_exceptions();
145684
146406
  init_otel2();
@@ -147632,24 +148354,162 @@ var init_bigint2 = __esm({
147632
148354
  }
147633
148355
  });
147634
148356
 
148357
+ // packages/safe-js/src/interp/globals/array-buffer.ts
148358
+ function createArrayBufferGlobal(budget) {
148359
+ const prototype = /* @__PURE__ */ Object.create(null);
148360
+ const constructor = createSandboxClosure({
148361
+ guest: true,
148362
+ sandbox: true,
148363
+ name: "ArrayBuffer",
148364
+ length: 1,
148365
+ call: () => {
148366
+ throw new TypeError("ArrayBuffer requires new.");
148367
+ },
148368
+ construct: async (args, context) => {
148369
+ let selected;
148370
+ let current;
148371
+ const bridge = {
148372
+ ...context,
148373
+ stack: context?.stack ?? [],
148374
+ thisValue: void 0,
148375
+ getProperty: context?.getProperty ?? ((value, key3) => {
148376
+ const descriptor = getSandboxPropertyDescriptor(value, key3, budget);
148377
+ return descriptor === void 0 ? getSandboxDataProperty(value, key3, budget) : readPropertyDescriptor(descriptor, value, bridge);
148378
+ }),
148379
+ invokeClosure: context?.invokeClosure ?? ((callee, values, receiver, construct) => invokeBuiltinClosure(callee, values, budget, context, receiver, construct))
148380
+ };
148381
+ const release2 = retainValues(budget, () => [selected, current, ...args]);
148382
+ try {
148383
+ const number = await sandboxNumber(args[0], budget, bridge);
148384
+ const length = Number.isNaN(number) ? 0 : Math.trunc(number);
148385
+ if (length < 0 || !Number.isSafeInteger(length)) throw new RangeError("Invalid ArrayBuffer length.");
148386
+ let maxByteLength;
148387
+ if (args[1] !== null && typeof args[1] === "object") {
148388
+ current = await bridge.getProperty(args[1], "maxByteLength");
148389
+ if (current !== void 0) {
148390
+ const maximum = await sandboxNumber(current, budget, bridge);
148391
+ maxByteLength = Number.isNaN(maximum) ? 0 : Math.trunc(maximum);
148392
+ if (!Number.isSafeInteger(maxByteLength) || maxByteLength < length)
148393
+ throw new RangeError("Invalid ArrayBuffer maximum length.");
148394
+ }
148395
+ }
148396
+ const target = context?.newTarget ?? constructor;
148397
+ selected = await bridge.getProperty(target, "prototype");
148398
+ budget.allocateArrayLength(maxByteLength ?? length);
148399
+ budget.provisionDataUsage(length + 1)();
148400
+ const result = Reflect.construct(ArrayBuffer, [length, maxByteLength === void 0 ? void 0 : { maxByteLength }]);
148401
+ setSandboxPrototype(result, selected !== null && typeof selected === "object" ? selected : prototype, budget);
148402
+ return result;
148403
+ } finally {
148404
+ release2();
148405
+ }
148406
+ }
148407
+ });
148408
+ Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
148409
+ Object.defineProperty(materializeFunctionProperties(constructor), "isView", {
148410
+ writable: true,
148411
+ configurable: true,
148412
+ value: createSandboxClosure({
148413
+ guest: true,
148414
+ sandbox: true,
148415
+ name: "isView",
148416
+ length: 1,
148417
+ call: (args) => ArrayBuffer.isView(args[0])
148418
+ })
148419
+ });
148420
+ Object.defineProperties(prototype, {
148421
+ constructor: { value: constructor, writable: true, configurable: true },
148422
+ [Symbol.toStringTag]: { value: "ArrayBuffer", configurable: true }
148423
+ });
148424
+ const getters = [];
148425
+ Object.defineProperty(prototype, "resize", {
148426
+ writable: true,
148427
+ configurable: true,
148428
+ value: createSandboxClosure({
148429
+ guest: true,
148430
+ sandbox: true,
148431
+ name: "resize",
148432
+ length: 1,
148433
+ call: async (args, context) => {
148434
+ const receiver = context?.thisValue;
148435
+ if (!isSandboxArrayBuffer(receiver) || arrayBufferOptions(receiver) === void 0)
148436
+ throw new TypeError("ArrayBuffer resize requires a resizable buffer receiver.");
148437
+ const release2 = retainValues(budget, () => [receiver, ...args]);
148438
+ try {
148439
+ const number = await sandboxNumber(args[0], budget, context);
148440
+ const length = Number.isNaN(number) ? 0 : Math.trunc(number);
148441
+ if (!Number.isSafeInteger(length) || length < 0 || length > arrayBufferOptions(receiver).maxByteLength)
148442
+ throw new RangeError("Invalid ArrayBuffer resize length.");
148443
+ budget.allocateArrayLength(length);
148444
+ budget.provisionDataUsage(Math.max(length - arrayBufferLength(receiver), 0))();
148445
+ Reflect.apply(resizeBuffer2, receiver, [length]);
148446
+ return void 0;
148447
+ } finally {
148448
+ release2();
148449
+ }
148450
+ }
148451
+ })
148452
+ });
148453
+ for (const key3 of ["byteLength", "maxByteLength", "resizable"]) {
148454
+ const getter = createSandboxClosure({
148455
+ guest: true,
148456
+ sandbox: true,
148457
+ name: `get ${key3}`,
148458
+ length: 0,
148459
+ call: (_args, context) => {
148460
+ if (!isSandboxArrayBuffer(context?.thisValue)) throw new TypeError(`ArrayBuffer ${key3} requires a buffer receiver.`);
148461
+ if (key3 === "byteLength") return arrayBufferLength(context.thisValue);
148462
+ const options = arrayBufferOptions(context.thisValue);
148463
+ return key3 === "resizable" ? options !== void 0 : options?.maxByteLength ?? arrayBufferLength(context.thisValue);
148464
+ }
148465
+ });
148466
+ Object.defineProperty(prototype, key3, { get: accessorAdapter(getter, "get"), configurable: true });
148467
+ getters.push(getter);
148468
+ }
148469
+ setSandboxPrototype(prototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
148470
+ arrayBufferPrototypes.set(budget, prototype);
148471
+ registerBuiltinIdentities(budget, { ArrayBuffer: constructor });
148472
+ registerIntrinsicFunction(budget, constructor);
148473
+ for (const getter of getters) registerIntrinsicFunction(budget, getter);
148474
+ registerIntrinsicObject(budget, prototype);
148475
+ return constructor;
148476
+ }
148477
+ var resizeBuffer2;
148478
+ var init_array_buffer3 = __esm({
148479
+ "packages/safe-js/src/interp/globals/array-buffer.ts"() {
148480
+ "use strict";
148481
+ init_array_buffer();
148482
+ init_accessors();
148483
+ init_values();
148484
+ init_object_model();
148485
+ init_builtin_call();
148486
+ init_intrinsics();
148487
+ init_string_coercion();
148488
+ init_resources();
148489
+ resizeBuffer2 = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize").value;
148490
+ }
148491
+ });
148492
+
147635
148493
  // packages/safe-js/src/interp/globals.ts
147636
148494
  function createBuiltinBindings(options) {
147637
148495
  const bindings = {
147638
148496
  ...createConsoleJsonGlobals(options),
147639
148497
  ...createCollectionGlobals(options),
147640
- Float32Array: createFloat32ArrayGlobal(options.budget),
148498
+ Float32Array: createFloat32ArrayGlobal(options.budget, options.float32Prototypes !== false),
147641
148499
  Date: createDateGlobal(options),
147642
148500
  Symbol: createSymbolGlobal(options.budget),
147643
148501
  BigInt: createBigIntGlobal(options.budget),
147644
148502
  ...createErrorGlobals({ ...options, errorPrototypes: options.errorPrototypes !== false }),
147645
148503
  ...createMathGlobals({ random: options.random, budget: options.budget }),
147646
148504
  ...createObjectArrayGlobals(options),
148505
+ ArrayBuffer: createArrayBufferGlobal(options.budget),
147647
148506
  ...createMiscGlobals(options),
147648
148507
  ...createUriGlobals(options.budget),
147649
148508
  ...createPromiseGlobals(options),
147650
148509
  ...createRegexGlobals(options)
147651
148510
  };
147652
148511
  createFunctionPrototype(options.budget, options.functionHasInstance);
148512
+ if (options.float32Prototypes !== false) createFloat32ArrayPrototypes(options.budget, bindings.Float32Array);
147653
148513
  if (options.errorPrototypes !== false) createErrorPrototypes(options.budget, bindings);
147654
148514
  createGeneratorPrototypes(options.budget);
147655
148515
  registerBuiltinIdentities(options.budget, bindings);
@@ -147673,6 +148533,7 @@ var init_globals = __esm({
147673
148533
  init_date2();
147674
148534
  init_symbol();
147675
148535
  init_bigint2();
148536
+ init_array_buffer3();
147676
148537
  init_intrinsics();
147677
148538
  }
147678
148539
  });
@@ -148322,7 +149183,7 @@ var init_template_validation = __esm({
148322
149183
  });
148323
149184
 
148324
149185
  // packages/safe-js/src/snapshot/validation.ts
148325
- import { types as types6 } from "node:util";
149186
+ import { types as types7 } from "node:util";
148326
149187
  function validateSnapshotData(value) {
148327
149188
  validateGenericValue(value, "$", 0, {
148328
149189
  allowFunctions: false,
@@ -148394,9 +149255,18 @@ function validateDumpHeap(root, state) {
148394
149255
  validateDateRecord(entry, path193);
148395
149256
  continue;
148396
149257
  }
149258
+ if (entry.kind === "arraybuffer") {
149259
+ validateArrayBufferStorage(entry);
149260
+ validateGuestHeapNode({ kind: "guest-object", state: entry.state }, heap, state.limits.maxEntries);
149261
+ continue;
149262
+ }
148397
149263
  if (entry.kind === "float32array") {
148398
149264
  validateFloat32Storage(entry);
148399
149265
  requireRecord3(entry.entries, `${path193}.entries`);
149266
+ if (Object.hasOwn(entry, "state")) {
149267
+ if (Object.keys(entry.entries).length !== 0) fail2("invalidValue", path193, "ambiguous Float32Array property state");
149268
+ validateGuestHeapNode({ kind: "guest-object", state: entry.state }, heap, state.limits.maxEntries);
149269
+ }
148400
149270
  continue;
148401
149271
  }
148402
149272
  if (entry.kind === "arguments") {
@@ -148613,7 +149483,7 @@ function validateHeapValue(value, path193, state, heap) {
148613
149483
  fail2("invalidValue", path193, String(error3));
148614
149484
  }
148615
149485
  validateErrorType(record4, path193);
148616
- if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record4.kind)))
149486
+ if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "arraybuffer", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record4.kind)))
148617
149487
  fail2("unknownTag", `${path193}.kind`, "unknown heap tag");
148618
149488
  validateValue(record4, path193, 1, state);
148619
149489
  if (record4.kind === "symbol") validateSymbolRecord(record4, path193, state);
@@ -148622,9 +149492,17 @@ function validateHeapValue(value, path193, state, heap) {
148622
149492
  if (record4.kind === "object") requireRecord3(record4.entries, `${path193}.entries`);
148623
149493
  if (record4.kind === "boxed") validateBoxedRecord(record4, path193, heap);
148624
149494
  if (record4.kind === "date") validateDateRecord(record4, path193);
149495
+ if (record4.kind === "arraybuffer") {
149496
+ validateArrayBufferStorage(record4);
149497
+ validateGuestHeapNode({ kind: "guest-object", state: record4.state }, heap, state.limits.maxEntries);
149498
+ }
148625
149499
  if (record4.kind === "float32array") {
148626
149500
  validateFloat32Storage(record4);
148627
149501
  requireRecord3(record4.entries, `${path193}.entries`);
149502
+ if (Object.hasOwn(record4, "state")) {
149503
+ if (Object.keys(record4.entries).length !== 0) fail2("invalidValue", path193, "ambiguous Float32Array property state");
149504
+ validateGuestHeapNode({ kind: "guest-object", state: record4.state }, heap, state.limits.maxEntries);
149505
+ }
148628
149506
  }
148629
149507
  if (record4.kind === "map") {
148630
149508
  const entries = requireArray(record4.entries, `${path193}.entries`, state);
@@ -148814,7 +149692,7 @@ function validateGenericValue(value, path193, depth, state) {
148814
149692
  if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
148815
149693
  fail2("invalidState", path193, "guest function properties, prototype links and custom descriptors cannot be restored");
148816
149694
  }
148817
- if (state.dataPropertiesOnly && types6.isProxy(value)) {
149695
+ if (state.dataPropertiesOnly && types7.isProxy(value)) {
148818
149696
  fail2("invalidType", path193, "proxy objects are not snapshot data");
148819
149697
  }
148820
149698
  if (depth > state.limits.maxDepth)
@@ -148951,6 +149829,7 @@ var init_validation = __esm({
148951
149829
  init_dump_format();
148952
149830
  init_graph_depth();
148953
149831
  init_float32array();
149832
+ init_array_buffer2();
148954
149833
  init_date();
148955
149834
  init_boxed2();
148956
149835
  init_object_model();
@@ -149861,6 +150740,7 @@ var init_known_globals = __esm({
149861
150740
  KNOWN_RUNTIME_GLOBALS = [
149862
150741
  "AggregateError",
149863
150742
  "Array",
150743
+ "ArrayBuffer",
149864
150744
  "Boolean",
149865
150745
  "BigInt",
149866
150746
  "Date",
@@ -160620,10 +161500,10 @@ var init_random = __esm({
160620
161500
 
160621
161501
  // packages/safe-js/src/realm.ts
160622
161502
  import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
160623
- import { types as types7 } from "node:util";
161503
+ import { types as types8 } from "node:util";
160624
161504
  function readModules(input) {
160625
161505
  const entries = (value, label) => {
160626
- if (types7.isMap(value) && !types7.isProxy(value)) {
161506
+ if (types8.isMap(value) && !types8.isProxy(value)) {
160627
161507
  const result = [...Map.prototype.entries.call(value)];
160628
161508
  if (result.length > 4096 || result.some(([key3]) => typeof key3 !== "string" || key3.length === 0))
160629
161509
  throw new TypeError(`${label} requires bounded string keys.`);
@@ -160737,7 +161617,7 @@ var init_realm = __esm({
160737
161617
  throw new TypeError("Realm limits must be positive safe integers with supported names.");
160738
161618
  this.limits[name] = Number(value);
160739
161619
  }
160740
- if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types7.isProxy(options.extensions)))
161620
+ if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types8.isProxy(options.extensions)))
160741
161621
  throw new TypeError("Extensions must be a registration array.");
160742
161622
  const registrations = options.extensions ?? [];
160743
161623
  const extensions = [];
@@ -160972,7 +161852,7 @@ var init_realm = __esm({
160972
161852
  return this.phase.run(phase, () => {
160973
161853
  try {
160974
161854
  const result = call();
160975
- if (types7.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
161855
+ if (types8.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
160976
161856
  return Promise.resolve(result).then(
160977
161857
  async (value) => {
160978
161858
  await Promise.allSettled(phase.pending);
@@ -161041,7 +161921,7 @@ var init_realm = __esm({
161041
161921
  },
161042
161922
  read: (operation, validate2) => {
161043
161923
  const value = this.invokeHost(operation, operation);
161044
- if (types7.isPromise(value)) {
161924
+ if (types8.isPromise(value)) {
161045
161925
  void Promise.resolve(value).catch(() => void 0);
161046
161926
  throw new TypeError("Live property operations must be synchronous.");
161047
161927
  }
@@ -161049,7 +161929,7 @@ var init_realm = __esm({
161049
161929
  },
161050
161930
  write: (operation, value) => {
161051
161931
  const result = this.invokeHost(operation, () => operation(this.exportValue(value)));
161052
- if (types7.isPromise(result)) {
161932
+ if (types8.isPromise(result)) {
161053
161933
  void Promise.resolve(result).catch(() => void 0);
161054
161934
  throw new TypeError("Live property setters must be synchronous.");
161055
161935
  }
@@ -161258,7 +162138,7 @@ var init_realm = __esm({
161258
162138
  }
161259
162139
  });
161260
162140
  const output = getExtensionSetup(extension)(context);
161261
- if (types7.isPromise(output)) {
162141
+ if (types8.isPromise(output)) {
161262
162142
  void Promise.resolve(output).catch(() => void 0);
161263
162143
  throw new TypeError("Extension setup must be synchronous.");
161264
162144
  }
@@ -161892,6 +162772,8 @@ var init_serialize = __esm({
161892
162772
  init_arrays();
161893
162773
  init_float32();
161894
162774
  init_float32array();
162775
+ init_array_buffer();
162776
+ init_array_buffer2();
161895
162777
  init_date();
161896
162778
  init_date_properties();
161897
162779
  init_boxed();