@poe-platform/safe-js 0.1.244 → 0.1.245

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-LQ57UIVW.js";
30
+ } from "./chunk-NOQSV7MP.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-IBQE6MEC.js.map
8252
+ //# sourceMappingURL=chunk-ITCCCKXY.js.map
@@ -8096,11 +8096,19 @@ function isIntrinsicFunction(value) {
8096
8096
  function registerIntrinsicPrototype(budget, prototype, constructor) {
8097
8097
  if (constructor.name === void 0) throw new TypeError("Intrinsic constructors require an installation name.");
8098
8098
  registerBuiltinIdentities(budget, { [constructor.name]: constructor });
8099
+ const methods = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).map((key) => Object.getOwnPropertyDescriptor(owner, key)?.value)).filter(isGuestClosure);
8100
+ trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...methods]);
8101
+ }
8102
+ function registerIntrinsicFunction(budget, closure) {
8103
+ if (closure.name === void 0) throw new TypeError("Intrinsic functions require an installation name.");
8104
+ registerBuiltinIdentities(budget, { [closure.name]: closure });
8105
+ trackIntrinsicState(budget, closure, closure, [closure]);
8106
+ }
8107
+ function trackIntrinsicState(budget, root, owner, targets) {
8099
8108
  let roots = intrinsicPrototypeRoots.get(budget);
8100
8109
  if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
8101
- roots.add(prototype);
8102
- const methods = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).map((key) => Object.getOwnPropertyDescriptor(owner, key)?.value)).filter(isGuestClosure);
8103
- const records = [.../* @__PURE__ */ new Set([prototype, constructor, ...methods])].map((target) => ({
8110
+ roots.add(root);
8111
+ const records = [...new Set(targets)].map((target) => ({
8104
8112
  target,
8105
8113
  value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
8106
8114
  prototype: getSandboxPrototype(target),
@@ -8114,14 +8122,14 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
8114
8122
  if (isGuestClosure(target)) intrinsicFunctions.add(target);
8115
8123
  const unchanged = (before, after) => before !== void 0 && after !== void 0 && Object.is(before.value, after.value) && before.get === after.get && before.set === after.set && before.writable === after.writable && before.configurable === after.configurable && before.enumerable === after.enumerable;
8116
8124
  intrinsicConstructors.set(
8117
- constructor,
8125
+ owner,
8118
8126
  () => records.every(({ target, value, descriptors: descriptors2, prototype: parent, explicit, extensible }) => {
8119
8127
  const current = Object.getOwnPropertyDescriptors(value);
8120
8128
  return getSandboxPrototype(target) === parent && Object.isExtensible(value) === extensible && hasExplicitSandboxPrototype(target) === explicit && Reflect.ownKeys(current).length === descriptors2.size && Reflect.ownKeys(value).every((key) => unchanged(descriptors2.get(key), Object.getOwnPropertyDescriptor(value, key)));
8121
8129
  })
8122
8130
  );
8123
8131
  budget.setRetainedValues(
8124
- prototype,
8132
+ root,
8125
8133
  () => records.flatMap(({ target, value, descriptors: descriptors2, prototype: parent }) => [
8126
8134
  ...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
8127
8135
  ...Reflect.ownKeys(value).flatMap((key) => {
@@ -22401,6 +22409,29 @@ function assertStructuredCloneable(value, seen) {
22401
22409
  }
22402
22410
  }
22403
22411
 
22412
+ // packages/safe-js/src/interp/globals/uri.ts
22413
+ var conversions = { encodeURI, encodeURIComponent, decodeURI, decodeURIComponent };
22414
+ function createUriGlobals(budget) {
22415
+ return Object.fromEntries(Object.entries(conversions).map(([name, conversion]) => {
22416
+ const closure = createSandboxClosure({
22417
+ sandbox: true,
22418
+ guest: true,
22419
+ name,
22420
+ length: 1,
22421
+ call: ([value], context) => {
22422
+ const convert = (text2) => {
22423
+ budget.visitNode(text2.length);
22424
+ return budget.allocateString(conversion(text2));
22425
+ };
22426
+ const text = sandboxString(value, budget, context);
22427
+ return typeof text === "string" ? convert(text) : text.then(convert);
22428
+ }
22429
+ });
22430
+ registerIntrinsicFunction(budget, closure);
22431
+ return [name, closure];
22432
+ }));
22433
+ }
22434
+
22404
22435
  // packages/safe-js/src/interp/globals/symbol.ts
22405
22436
  var registries = /* @__PURE__ */ new WeakMap();
22406
22437
  function createSymbolGlobal(budget) {
@@ -22616,6 +22647,7 @@ function createBuiltinBindings(options) {
22616
22647
  ...createMathGlobals({ random: options.random }),
22617
22648
  ...createObjectArrayGlobals(options),
22618
22649
  ...createMiscGlobals(options),
22650
+ ...createUriGlobals(options.budget),
22619
22651
  ...createPromiseGlobals(options),
22620
22652
  ...createRegexGlobals(options)
22621
22653
  };
@@ -26807,6 +26839,10 @@ var KNOWN_RUNTIME_GLOBALS = [
26807
26839
  "Boolean",
26808
26840
  "BigInt",
26809
26841
  "Date",
26842
+ "decodeURI",
26843
+ "decodeURIComponent",
26844
+ "encodeURI",
26845
+ "encodeURIComponent",
26810
26846
  "Error",
26811
26847
  "EvalError",
26812
26848
  "Infinity",
@@ -39311,4 +39347,4 @@ export {
39311
39347
  FileSnapshotBackend,
39312
39348
  run
39313
39349
  };
39314
- //# sourceMappingURL=chunk-LQ57UIVW.js.map
39350
+ //# sourceMappingURL=chunk-NOQSV7MP.js.map