@poe-platform/safe-js 0.1.454 → 0.1.456

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-GYKATDHU.js";
30
+ } from "./chunk-NC5GGOCN.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-IOBAVJXI.js.map
8252
+ //# sourceMappingURL=chunk-ENQTGOQ6.js.map
@@ -28619,7 +28619,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28619
28619
  }
28620
28620
  const updated = Object.values(base).filter((value) => value !== void 0).join("-") + canonical.slice(native.baseName.length);
28621
28621
  const extension = unicodeKeywords(updated);
28622
- const optionTypes4 = [
28622
+ const optionTypes5 = [
28623
28623
  ["calendar", "ca", "unicodeType"],
28624
28624
  ["collation", "co", "unicodeType"],
28625
28625
  ["firstDayOfWeek", "fw", "unicodeType"],
@@ -28628,7 +28628,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28628
28628
  ["numeric", "kn", "boolean"],
28629
28629
  ["numberingSystem", "nu", "unicodeType"]
28630
28630
  ];
28631
- for (const [key, extensionKey, type] of optionTypes4) {
28631
+ for (const [key, extensionKey, type] of optionTypes5) {
28632
28632
  let value = await readIntlProperty(options, key, budget, context);
28633
28633
  if (value === void 0) continue;
28634
28634
  if (key === "firstDayOfWeek") {
@@ -28694,20 +28694,42 @@ function formatRelativeTime(value, amount, unit, parts) {
28694
28694
  return Reflect.apply(parts ? formatToParts3 : format2, relativeTimeFormatState(value).native, [amount, unit]);
28695
28695
  }
28696
28696
 
28697
- // packages/safe-js/src/interp/intl-numberformat.ts
28697
+ // packages/safe-js/src/interp/intl-displaynames.ts
28698
+ var NativeDisplayNames = Intl.DisplayNames;
28699
+ var resolvedOptions4 = NativeDisplayNames.prototype.resolvedOptions;
28700
+ var of = NativeDisplayNames.prototype.of;
28698
28701
  var states8 = /* @__PURE__ */ new WeakMap();
28702
+ function createSandboxDisplayNames(locales2, options) {
28703
+ const native = new NativeDisplayNames(locales2, options);
28704
+ const value = /* @__PURE__ */ Object.create(null);
28705
+ states8.set(value, { native, options: Reflect.apply(resolvedOptions4, native, []) });
28706
+ return value;
28707
+ }
28708
+ function isSandboxDisplayNames(value) {
28709
+ return typeof value === "object" && value !== null && states8.has(value);
28710
+ }
28711
+ function displayNamesState(value) {
28712
+ if (!isSandboxDisplayNames(value)) throw new TypeError("Intl.DisplayNames requires a DisplayNames receiver.");
28713
+ return states8.get(value);
28714
+ }
28715
+ function displayName(value, code) {
28716
+ return Reflect.apply(of, displayNamesState(value).native, [code]);
28717
+ }
28718
+
28719
+ // packages/safe-js/src/interp/intl-numberformat.ts
28720
+ var states9 = /* @__PURE__ */ new WeakMap();
28699
28721
  function createSandboxNumberFormat(locales2, options) {
28700
28722
  const native = createNumberFormatter(locales2, options);
28701
28723
  const value = /* @__PURE__ */ Object.create(null);
28702
- states8.set(value, { native, options: numberFormatterOptions2(native) });
28724
+ states9.set(value, { native, options: numberFormatterOptions2(native) });
28703
28725
  return value;
28704
28726
  }
28705
28727
  function isSandboxNumberFormat(value) {
28706
- return typeof value === "object" && value !== null && states8.has(value);
28728
+ return typeof value === "object" && value !== null && states9.has(value);
28707
28729
  }
28708
28730
  function numberFormatState(value) {
28709
28731
  if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
28710
- return states8.get(value);
28732
+ return states9.get(value);
28711
28733
  }
28712
28734
  async function numberFormatValue(value, budget, context) {
28713
28735
  const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
@@ -29063,6 +29085,7 @@ function captureGuestHeapNode(value, encode) {
29063
29085
  if (isSandboxLocale(value)) return { kind: "guest-locale", tag: localeTag(value), state: captureObjectState(value, encode) };
29064
29086
  if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
29065
29087
  if (isSandboxRelativeTimeFormat(value)) return { kind: "guest-relativetimeformat", options: { ...relativeTimeFormatState(value).options }, state: captureObjectState(value, encode) };
29088
+ if (isSandboxDisplayNames(value)) return { kind: "guest-displaynames", options: { ...displayNamesState(value).options }, state: captureObjectState(value, encode) };
29066
29089
  if (isSandboxNumberFormat(value)) {
29067
29090
  const { options, format: format3 } = numberFormatState(value);
29068
29091
  return { kind: "guest-numberformat", options: { ...options }, ...format3 === void 0 ? {} : { format: encode(format3) }, state: captureObjectState(value, encode) };
@@ -30729,6 +30752,91 @@ function defineDataProperty2(target, key, value) {
30729
30752
  });
30730
30753
  }
30731
30754
 
30755
+ // packages/safe-js/src/interp/globals/set-operations.ts
30756
+ var setOperationNames = ["union", "intersection", "difference", "symmetricDifference", "isSubsetOf", "isSupersetOf", "isDisjointFrom"];
30757
+ function createSetOperation(name, budget) {
30758
+ return createSandboxClosure({
30759
+ guest: true,
30760
+ sandbox: true,
30761
+ name,
30762
+ length: 1,
30763
+ call: async ([other], context) => {
30764
+ const receiver = context?.thisValue;
30765
+ if (!isSandboxSet(receiver)) throw new TypeError(`Set.prototype.${name} requires a Set receiver.`);
30766
+ if (typeof other !== "object" || other === null) throw new TypeError("Expected a set-like object.");
30767
+ const read = async (object, key) => context?.getProperty !== void 0 ? context.getProperty(object, key) : readPropertyDescriptor(getSandboxPropertyDescriptor(object, key, budget) ?? { value: void 0 }, object, context);
30768
+ const iterationContext = { ...context, thisValue: receiver, stack: context?.stack ?? [], getProperty: read };
30769
+ const result = createSandboxSet([]);
30770
+ let iterator;
30771
+ let current;
30772
+ let has;
30773
+ let keys;
30774
+ const release = retainValues(budget, () => [receiver, other, result, current, has, keys, iterator?.retainedValue]);
30775
+ const checkpoint = createDataCheckpoint(budget, context);
30776
+ const add = (value) => {
30777
+ budget.visitNode();
30778
+ if (result.values.has(value)) return;
30779
+ budget.allocateCollectionEntries(result.values.size + 1);
30780
+ result.values.add(value);
30781
+ checkpoint(result, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value])));
30782
+ };
30783
+ try {
30784
+ const numericSize = await sandboxNumber(await read(other, "size"), budget, context);
30785
+ if (Number.isNaN(numericSize)) throw new TypeError("Invalid set-like size.");
30786
+ const size = Math.trunc(numericSize);
30787
+ if (size < 0) throw new RangeError("Negative set-like size.");
30788
+ has = await read(other, "has");
30789
+ if (!isSandboxClosure(has)) throw new TypeError("Set-like has must be callable.");
30790
+ keys = await read(other, "keys");
30791
+ if (!isSandboxClosure(keys)) throw new TypeError("Set-like keys must be callable.");
30792
+ if (name === "isSubsetOf" && receiver.values.size > size || name === "isSupersetOf" && receiver.values.size < size) return false;
30793
+ const visitReceiver = name === "isSubsetOf" || (name === "intersection" || name === "difference" || name === "isDisjointFrom") && receiver.values.size <= size;
30794
+ if (name === "union" || name === "symmetricDifference")
30795
+ iterator = await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
30796
+ if (name === "union" || name === "symmetricDifference" || name === "difference")
30797
+ for (const value of receiver.values) add(value);
30798
+ if (visitReceiver) {
30799
+ const target = name === "difference" ? result : receiver;
30800
+ const cursor = enterKeyedCollectionCallback(target, target.values, budget);
30801
+ try {
30802
+ for (let next = cursor.next(); !next.done; next = cursor.next()) {
30803
+ current = next.value;
30804
+ const found = Boolean(await invokeBuiltinClosure(has, [current], budget, context, other));
30805
+ if (name === "isSubsetOf" && !found || name === "isDisjointFrom" && found) return false;
30806
+ if (name === "intersection" && found) add(current);
30807
+ if (name === "difference" && found) result.values.delete(current);
30808
+ current = void 0;
30809
+ }
30810
+ } finally {
30811
+ cursor.leave();
30812
+ }
30813
+ } else {
30814
+ iterator ??= await getSandboxIteratorFromMethod(other, keys, budget, iterationContext);
30815
+ while (true) {
30816
+ budget.visitNode();
30817
+ const next = await iterator.next();
30818
+ if ((await readIteratorResult(iterator, next, "done")).value) break;
30819
+ current = (await readIteratorResult(iterator, next, "value")).value;
30820
+ const found = receiver.values.has(current);
30821
+ if (name === "isSupersetOf" && !found || name === "isDisjointFrom" && found) {
30822
+ await closeIterator(iterator);
30823
+ return false;
30824
+ }
30825
+ if (name === "union" || name === "intersection" && found || name === "symmetricDifference" && !found) add(current);
30826
+ else if (name === "difference" || name === "symmetricDifference" && found) result.values.delete(current);
30827
+ current = void 0;
30828
+ }
30829
+ }
30830
+ if (name === "isSubsetOf" || name === "isSupersetOf" || name === "isDisjointFrom") return true;
30831
+ checkpoint(result, 0, true);
30832
+ return allocateProducedSandboxValue(result, budget);
30833
+ } finally {
30834
+ release();
30835
+ }
30836
+ }
30837
+ });
30838
+ }
30839
+
30732
30840
  // packages/safe-js/src/interp/globals/collection-prototypes.ts
30733
30841
  function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
30734
30842
  const mapMethods = Object.fromEntries([...mapMethodNames].map((name) => [name, createSandboxClosure({
@@ -30760,6 +30868,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
30760
30868
  }
30761
30869
  })]));
30762
30870
  setMethods.keys = setMethods.values;
30871
+ for (const name of setOperationNames) setMethods[name] = createSetOperation(name, budget);
30763
30872
  const mapSize = createSandboxClosure({
30764
30873
  guest: true,
30765
30874
  sandbox: true,
@@ -33706,6 +33815,100 @@ function createRelativeTimeFormatConstructor(budget) {
33706
33815
  return constructor;
33707
33816
  }
33708
33817
 
33818
+ // packages/safe-js/src/interp/globals/intl-displaynames.ts
33819
+ var supportedLocalesOf6 = Intl.DisplayNames.supportedLocalesOf;
33820
+ var optionTypes4 = [
33821
+ ["localeMatcher", ["lookup", "best fit"]],
33822
+ ["style", ["long", "short", "narrow"]],
33823
+ ["type", ["language", "region", "script", "currency", "calendar", "dateTimeField"]],
33824
+ ["fallback", ["code", "none"]],
33825
+ ["languageDisplay", ["dialect", "standard"]]
33826
+ ];
33827
+ function createDisplayNamesConstructor(budget) {
33828
+ const prototype = createIntrinsicObject();
33829
+ const constructor = createSandboxClosure({
33830
+ guest: true,
33831
+ sandbox: true,
33832
+ name: "DisplayNames",
33833
+ length: 2,
33834
+ call: () => {
33835
+ throw new TypeError("Constructor DisplayNames requires 'new'.");
33836
+ },
33837
+ construct: async ([input, options], context) => {
33838
+ const target = context?.newTarget;
33839
+ const selected = target === void 0 || target === constructor ? prototype : context?.getProperty !== void 0 ? await context.getProperty(target, "prototype") : await readPropertyDescriptor(getSandboxPropertyDescriptor(target, "prototype", budget) ?? { value: void 0 }, target, context);
33840
+ let locales2 = [];
33841
+ const converted = /* @__PURE__ */ Object.create(null);
33842
+ const release = retainValues(budget, () => [selected, locales2, converted]);
33843
+ try {
33844
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
33845
+ if (options === void 0) throw new TypeError("DisplayNames requires options.");
33846
+ const source = intlOptionsObject(options, budget);
33847
+ for (const [key, type] of optionTypes4) {
33848
+ const raw = await readIntlProperty(source, key, budget, context);
33849
+ if (key === "type" && raw === void 0) throw new TypeError("DisplayNames requires a type.");
33850
+ if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
33851
+ }
33852
+ const value = createSandboxDisplayNames(locales2, converted);
33853
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
33854
+ return allocateProducedSandboxValue(value, budget);
33855
+ } finally {
33856
+ release();
33857
+ }
33858
+ }
33859
+ });
33860
+ const properties = materializeFunctionProperties(constructor);
33861
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
33862
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
33863
+ guest: true,
33864
+ sandbox: true,
33865
+ name: "supportedLocalesOf",
33866
+ length: 1,
33867
+ call: async ([input, options], context) => {
33868
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
33869
+ const release = retainValues(budget, () => [locales2]);
33870
+ try {
33871
+ const source = intlOptionsObject(options, budget);
33872
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
33873
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
33874
+ return allocateProducedSandboxValue(supportedLocalesOf6(locales2, { localeMatcher: matcher }), budget);
33875
+ } finally {
33876
+ release();
33877
+ }
33878
+ }
33879
+ }), writable: true, configurable: true });
33880
+ Object.defineProperties(prototype, {
33881
+ constructor: { value: constructor, writable: true, configurable: true },
33882
+ [Symbol.toStringTag]: { value: "Intl.DisplayNames", configurable: true },
33883
+ resolvedOptions: { value: createSandboxClosure({
33884
+ guest: true,
33885
+ sandbox: true,
33886
+ name: "resolvedOptions",
33887
+ length: 0,
33888
+ call: (_args, context) => allocateProducedSandboxValue({ ...displayNamesState(context?.thisValue).options }, budget)
33889
+ }), writable: true, configurable: true }
33890
+ });
33891
+ Object.defineProperty(prototype, "of", { value: createSandboxClosure({
33892
+ guest: true,
33893
+ sandbox: true,
33894
+ name: "of",
33895
+ length: 1,
33896
+ call: async ([input], context) => {
33897
+ const receiver = context?.thisValue;
33898
+ displayNamesState(receiver);
33899
+ const release = retainValues(budget, () => [receiver, input]);
33900
+ try {
33901
+ const code = await sandboxString(input, budget, context);
33902
+ budget.visitNode(code.length);
33903
+ return allocateProducedSandboxValue(displayName(receiver, code), budget);
33904
+ } finally {
33905
+ release();
33906
+ }
33907
+ }
33908
+ }), writable: true, configurable: true });
33909
+ return constructor;
33910
+ }
33911
+
33709
33912
  // packages/safe-js/src/interp/globals/intl.ts
33710
33913
  var supportedValuesOf = Intl.supportedValuesOf;
33711
33914
  function createIntlGlobal(budget) {
@@ -33723,11 +33926,13 @@ function createIntlGlobal(budget) {
33723
33926
  const numberFormat = createNumberFormatConstructor(budget);
33724
33927
  const listFormat = createListFormatConstructor(budget);
33725
33928
  const relativeTimeFormat = createRelativeTimeFormatConstructor(budget);
33929
+ const displayNames = createDisplayNamesConstructor(budget);
33726
33930
  Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
33727
33931
  Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
33728
33932
  Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
33729
33933
  Object.defineProperty(intl, "ListFormat", { value: listFormat, writable: true, configurable: true });
33730
33934
  Object.defineProperty(intl, "RelativeTimeFormat", { value: relativeTimeFormat, writable: true, configurable: true });
33935
+ Object.defineProperty(intl, "DisplayNames", { value: displayNames, writable: true, configurable: true });
33731
33936
  for (const [name, call] of Object.entries(methods2)) {
33732
33937
  const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
33733
33938
  Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
@@ -33851,7 +34056,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
33851
34056
  createRawJson(node.text);
33852
34057
  return true;
33853
34058
  }
33854
- if (!["module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-relativetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
34059
+ if (!["module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-displaynames", "guest-relativetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
33855
34060
  const reference = (value, kinds) => {
33856
34061
  const ref = record2(value);
33857
34062
  fields(ref, ["kind", "id"]);
@@ -34144,6 +34349,15 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34144
34349
  const restored = listFormatState(createSandboxListFormat(options.locale, options)).options;
34145
34350
  if (names.some((key) => options[key] !== restored[key])) throw new TypeError("Invalid resolved ListFormat options.");
34146
34351
  state(node.state);
34352
+ } else if (node.kind === "guest-displaynames") {
34353
+ fields(node, ["kind", "options", "state"]);
34354
+ const options = record2(node.options);
34355
+ fields(options, ["locale", "style", "type", "fallback"], ["languageDisplay"]);
34356
+ if (Object.values(options).some((value) => typeof value !== "string")) throw new TypeError("Invalid DisplayNames option type.");
34357
+ const restored = displayNamesState(createSandboxDisplayNames(options.locale, options)).options;
34358
+ if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
34359
+ throw new TypeError("Invalid resolved DisplayNames options.");
34360
+ state(node.state);
34147
34361
  } else if (node.kind === "guest-relativetimeformat") {
34148
34362
  fields(node, ["kind", "options", "state"]);
34149
34363
  const options = record2(node.options);
@@ -37910,6 +38124,7 @@ function measureSandboxData(values, options = {}) {
37910
38124
  if (isSandboxLocale(value)) usage += localeTag(value).length;
37911
38125
  if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
37912
38126
  if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
38127
+ if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
37913
38128
  if (isSandboxNumberFormat(value)) {
37914
38129
  const state = numberFormatState(value);
37915
38130
  visit(state.options, depth + 1);
@@ -55895,4 +56110,4 @@ The above copyright notice and this permission notice shall be included in all c
55895
56110
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55896
56111
 
55897
56112
  */
55898
- //# sourceMappingURL=chunk-GYKATDHU.js.map
56113
+ //# sourceMappingURL=chunk-NC5GGOCN.js.map