@poe-platform/safe-js 0.1.361 → 0.1.362

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-UPTA6E3T.js";
30
+ } from "./chunk-QMF5YOGC.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8249,4 +8249,4 @@ export {
8249
8249
  parseMcpConfig,
8250
8250
  makeMcpModule
8251
8251
  };
8252
- //# sourceMappingURL=chunk-MGIF45X7.js.map
8252
+ //# sourceMappingURL=chunk-EF6FLPF6.js.map
@@ -14638,6 +14638,96 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
14638
14638
  }
14639
14639
  }
14640
14640
 
14641
+ // packages/safe-js/src/interp/globals/uint8-hex.ts
14642
+ var hexDigits = "0123456789abcdef";
14643
+ function installUint8Hex(budget, constructor, prototype) {
14644
+ const fromHex = createSandboxClosure({
14645
+ guest: true,
14646
+ sandbox: true,
14647
+ name: "fromHex",
14648
+ length: 1,
14649
+ call: ([text]) => {
14650
+ if (typeof text !== "string") throw new TypeError("Hex input must be a string.");
14651
+ if (text.length % 2 !== 0) throw new SyntaxError("Hex input must have an even length.");
14652
+ checkTypedArrayAllocation(text.length / 2, budget, 1);
14653
+ const value = new Uint8Array(text.length / 2);
14654
+ decodeHexInto(text, value, budget);
14655
+ setSandboxPrototype(value, prototype, budget);
14656
+ return value;
14657
+ }
14658
+ });
14659
+ Object.defineProperty(materializeFunctionProperties(constructor), "fromHex", {
14660
+ value: fromHex,
14661
+ writable: true,
14662
+ configurable: true
14663
+ });
14664
+ registerIntrinsicFunction(budget, fromHex);
14665
+ Object.defineProperties(prototype, {
14666
+ toHex: {
14667
+ writable: true,
14668
+ configurable: true,
14669
+ value: createSandboxClosure({
14670
+ guest: true,
14671
+ sandbox: true,
14672
+ name: "toHex",
14673
+ length: 0,
14674
+ call: (_args, context) => {
14675
+ const value = uint8Receiver(context?.thisValue);
14676
+ const { length } = typedArrayStorage(value, true);
14677
+ budget.provisionDataUsage(length * 2)();
14678
+ let result = "";
14679
+ for (let index = 0; index < length; index++) {
14680
+ budget.visitNode();
14681
+ const byte = value[index];
14682
+ result = budget.allocateString(result + hexDigits[byte >> 4] + hexDigits[byte & 15]);
14683
+ }
14684
+ return result;
14685
+ }
14686
+ })
14687
+ },
14688
+ setFromHex: {
14689
+ writable: true,
14690
+ configurable: true,
14691
+ value: createSandboxClosure({
14692
+ guest: true,
14693
+ sandbox: true,
14694
+ name: "setFromHex",
14695
+ length: 1,
14696
+ call: ([text], context) => {
14697
+ const value = uint8Receiver(context?.thisValue);
14698
+ if (typeof text !== "string") throw new TypeError("Hex input must be a string.");
14699
+ typedArrayStorage(value, true);
14700
+ const written = decodeHexInto(text, value, budget);
14701
+ return { read: written * 2, written };
14702
+ }
14703
+ })
14704
+ }
14705
+ });
14706
+ }
14707
+ function uint8Receiver(value) {
14708
+ if (!isNumericTypedArray(value) || typedArrayStorage(value).Native !== Uint8Array)
14709
+ throw new TypeError("Hex conversion requires a Uint8Array receiver.");
14710
+ return value;
14711
+ }
14712
+ function decodeHexInto(text, value, budget) {
14713
+ if (text.length % 2 !== 0) throw new SyntaxError("Hex input must have an even length.");
14714
+ const length = Math.min(text.length / 2, typedArrayStorage(value).length);
14715
+ for (let index = 0; index < length; index++) {
14716
+ budget.visitNode();
14717
+ const high = hexNibble(text.charCodeAt(index * 2));
14718
+ const low = hexNibble(text.charCodeAt(index * 2 + 1));
14719
+ if (high < 0 || low < 0) throw new SyntaxError("Invalid hexadecimal digit.");
14720
+ value[index] = high * 16 + low;
14721
+ }
14722
+ return length;
14723
+ }
14724
+ function hexNibble(code) {
14725
+ if (code >= 48 && code <= 57) return code - 48;
14726
+ if (code >= 65 && code <= 70) return code - 55;
14727
+ if (code >= 97 && code <= 102) return code - 87;
14728
+ return -1;
14729
+ }
14730
+
14641
14731
  // packages/safe-js/src/interp/globals/numeric-typed-array.ts
14642
14732
  var constructors = /* @__PURE__ */ new WeakMap();
14643
14733
  function createNumericTypedArrayGlobal(budget, nativePrototype = false, Native = Float32Array) {
@@ -14903,8 +14993,11 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
14903
14993
  setSandboxPrototype(constructor, typedArray);
14904
14994
  setSandboxPrototype(prototype, shared);
14905
14995
  prototypes2.set(Native, prototype);
14906
- registerIntrinsicFunction(budget, constructor);
14907
- registerIntrinsicObject(budget, prototype);
14996
+ }
14997
+ installUint8Hex(budget, bindings.Uint8Array, prototypes2.get(Uint8Array));
14998
+ for (const [name, Native] of Object.entries(numericTypedArrayConstructors)) {
14999
+ registerIntrinsicFunction(budget, bindings[name]);
15000
+ registerIntrinsicObject(budget, prototypes2.get(Native));
14908
15001
  }
14909
15002
  Object.defineProperty(shared, "constructor", { value: typedArray, writable: true, configurable: true });
14910
15003
  setSandboxPrototype(shared, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
@@ -42828,4 +42921,4 @@ export {
42828
42921
  FileSnapshotBackend,
42829
42922
  run
42830
42923
  };
42831
- //# sourceMappingURL=chunk-UPTA6E3T.js.map
42924
+ //# sourceMappingURL=chunk-QMF5YOGC.js.map