@poe-platform/safe-js 0.1.451 → 0.1.452

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-7OZYVM5K.js";
30
+ } from "./chunk-GJPSM3AB.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-YIPIBBVN.js.map
8252
+ //# sourceMappingURL=chunk-6WDZNRKU.js.map
@@ -28545,7 +28545,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28545
28545
  }
28546
28546
  const updated = Object.values(base).filter((value) => value !== void 0).join("-") + canonical.slice(native.baseName.length);
28547
28547
  const extension = unicodeKeywords(updated);
28548
- const optionTypes2 = [
28548
+ const optionTypes3 = [
28549
28549
  ["calendar", "ca", "unicodeType"],
28550
28550
  ["collation", "co", "unicodeType"],
28551
28551
  ["firstDayOfWeek", "fw", "unicodeType"],
@@ -28554,7 +28554,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28554
28554
  ["numeric", "kn", "boolean"],
28555
28555
  ["numberingSystem", "nu", "unicodeType"]
28556
28556
  ];
28557
- for (const [key, extensionKey, type] of optionTypes2) {
28557
+ for (const [key, extensionKey, type] of optionTypes3) {
28558
28558
  let value = await readIntlProperty(options, key, budget, context);
28559
28559
  if (value === void 0) continue;
28560
28560
  if (key === "firstDayOfWeek") {
@@ -28574,20 +28574,43 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28574
28574
  return budget.allocateString(Reflect.apply(nativeToString, result, []));
28575
28575
  }
28576
28576
 
28577
- // packages/safe-js/src/interp/intl-numberformat.ts
28577
+ // packages/safe-js/src/interp/intl-listformat.ts
28578
+ var NativeListFormat = Intl.ListFormat;
28579
+ var resolvedOptions2 = NativeListFormat.prototype.resolvedOptions;
28580
+ var format = NativeListFormat.prototype.format;
28581
+ var formatToParts2 = NativeListFormat.prototype.formatToParts;
28578
28582
  var states6 = /* @__PURE__ */ new WeakMap();
28583
+ function createSandboxListFormat(locales2, options) {
28584
+ const native = new NativeListFormat(locales2, options);
28585
+ const value = /* @__PURE__ */ Object.create(null);
28586
+ states6.set(value, { native, options: Reflect.apply(resolvedOptions2, native, []) });
28587
+ return value;
28588
+ }
28589
+ function isSandboxListFormat(value) {
28590
+ return typeof value === "object" && value !== null && states6.has(value);
28591
+ }
28592
+ function listFormatState(value) {
28593
+ if (!isSandboxListFormat(value)) throw new TypeError("Intl.ListFormat requires a ListFormat receiver.");
28594
+ return states6.get(value);
28595
+ }
28596
+ function formatList(value, strings, parts) {
28597
+ return Reflect.apply(parts ? formatToParts2 : format, listFormatState(value).native, [strings]);
28598
+ }
28599
+
28600
+ // packages/safe-js/src/interp/intl-numberformat.ts
28601
+ var states7 = /* @__PURE__ */ new WeakMap();
28579
28602
  function createSandboxNumberFormat(locales2, options) {
28580
28603
  const native = createNumberFormatter(locales2, options);
28581
28604
  const value = /* @__PURE__ */ Object.create(null);
28582
- states6.set(value, { native, options: numberFormatterOptions2(native) });
28605
+ states7.set(value, { native, options: numberFormatterOptions2(native) });
28583
28606
  return value;
28584
28607
  }
28585
28608
  function isSandboxNumberFormat(value) {
28586
- return typeof value === "object" && value !== null && states6.has(value);
28609
+ return typeof value === "object" && value !== null && states7.has(value);
28587
28610
  }
28588
28611
  function numberFormatState(value) {
28589
28612
  if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
28590
- return states6.get(value);
28613
+ return states7.get(value);
28591
28614
  }
28592
28615
  async function numberFormatValue(value, budget, context) {
28593
28616
  const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
@@ -28941,9 +28964,10 @@ function captureGuestHeapNode(value, encode) {
28941
28964
  return void 0;
28942
28965
  }
28943
28966
  if (isSandboxLocale(value)) return { kind: "guest-locale", tag: localeTag(value), state: captureObjectState(value, encode) };
28967
+ if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
28944
28968
  if (isSandboxNumberFormat(value)) {
28945
- const { options, format } = numberFormatState(value);
28946
- return { kind: "guest-numberformat", options: { ...options }, ...format === void 0 ? {} : { format: encode(format) }, state: captureObjectState(value, encode) };
28969
+ const { options, format: format2 } = numberFormatState(value);
28970
+ return { kind: "guest-numberformat", options: { ...options }, ...format2 === void 0 ? {} : { format: encode(format2) }, state: captureObjectState(value, encode) };
28947
28971
  }
28948
28972
  if (isSandboxCollator(value)) {
28949
28973
  const { options, compare } = collatorState(value);
@@ -33374,6 +33398,117 @@ function createNumberFormatConstructor(budget) {
33374
33398
  return constructor;
33375
33399
  }
33376
33400
 
33401
+ // packages/safe-js/src/interp/globals/intl-listformat.ts
33402
+ var supportedLocalesOf4 = Intl.ListFormat.supportedLocalesOf;
33403
+ var optionTypes2 = [
33404
+ ["localeMatcher", ["lookup", "best fit"]],
33405
+ ["type", ["conjunction", "disjunction", "unit"]],
33406
+ ["style", ["long", "short", "narrow"]]
33407
+ ];
33408
+ function createListFormatConstructor(budget) {
33409
+ const prototype = createIntrinsicObject();
33410
+ const constructor = createSandboxClosure({
33411
+ guest: true,
33412
+ sandbox: true,
33413
+ name: "ListFormat",
33414
+ length: 0,
33415
+ call: () => {
33416
+ throw new TypeError("Constructor ListFormat requires 'new'.");
33417
+ },
33418
+ construct: async ([input, options], context) => {
33419
+ const target = context?.newTarget;
33420
+ 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);
33421
+ let locales2 = [];
33422
+ const converted = /* @__PURE__ */ Object.create(null);
33423
+ const release = retainValues(budget, () => [selected, locales2, converted]);
33424
+ try {
33425
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
33426
+ const source = intlOptionsObject(options, budget);
33427
+ for (const [key, type] of optionTypes2) {
33428
+ const raw = await readIntlProperty(source, key, budget, context);
33429
+ if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
33430
+ }
33431
+ const value = createSandboxListFormat(locales2, converted);
33432
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
33433
+ return allocateProducedSandboxValue(value, budget);
33434
+ } finally {
33435
+ release();
33436
+ }
33437
+ }
33438
+ });
33439
+ const properties = materializeFunctionProperties(constructor);
33440
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
33441
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
33442
+ guest: true,
33443
+ sandbox: true,
33444
+ name: "supportedLocalesOf",
33445
+ length: 1,
33446
+ call: async ([input, options], context) => {
33447
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
33448
+ const release = retainValues(budget, () => [locales2]);
33449
+ try {
33450
+ const source = intlOptionsObject(options, budget);
33451
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
33452
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
33453
+ return allocateProducedSandboxValue(supportedLocalesOf4(locales2, { localeMatcher: matcher }), budget);
33454
+ } finally {
33455
+ release();
33456
+ }
33457
+ }
33458
+ }), writable: true, configurable: true });
33459
+ Object.defineProperties(prototype, {
33460
+ constructor: { value: constructor, writable: true, configurable: true },
33461
+ [Symbol.toStringTag]: { value: "Intl.ListFormat", configurable: true },
33462
+ resolvedOptions: { value: createSandboxClosure({
33463
+ guest: true,
33464
+ sandbox: true,
33465
+ name: "resolvedOptions",
33466
+ length: 0,
33467
+ call: (_args, context) => allocateProducedSandboxValue({ ...listFormatState(context?.thisValue).options }, budget)
33468
+ }), writable: true, configurable: true }
33469
+ });
33470
+ for (const method of ["format", "formatToParts"]) {
33471
+ Object.defineProperty(prototype, method, { value: createSandboxClosure({
33472
+ guest: true,
33473
+ sandbox: true,
33474
+ name: method,
33475
+ length: 1,
33476
+ call: async ([input], context) => {
33477
+ const receiver = context?.thisValue;
33478
+ listFormatState(receiver);
33479
+ const strings = [];
33480
+ let iterator;
33481
+ const release = retainValues(budget, () => [receiver, strings, iterator?.retainedValue]);
33482
+ const checkpoint = createDataCheckpoint(budget, context);
33483
+ try {
33484
+ if (input !== void 0) {
33485
+ iterator = context === void 0 ? getSandboxIterator(input, budget) : await acquireSandboxIterator(input, budget, context);
33486
+ if (iterator === void 0) throw new TypeError("ListFormat requires an iterable.");
33487
+ while (true) {
33488
+ budget.visitNode();
33489
+ const result = await iterator.next();
33490
+ if ((await readIteratorResult(iterator, result, "done")).value) break;
33491
+ const value = (await readIteratorResult(iterator, result, "value")).value;
33492
+ if (typeof value !== "string") {
33493
+ await closeIterator(iterator, true);
33494
+ throw new TypeError("ListFormat requires string elements.");
33495
+ }
33496
+ budget.visitNode(value.length);
33497
+ budget.allocateArrayLength(strings.length + 1);
33498
+ strings.push(value);
33499
+ checkpoint(strings, value.length + 1);
33500
+ }
33501
+ }
33502
+ return allocateProducedSandboxValue(formatList(receiver, strings, method === "formatToParts"), budget);
33503
+ } finally {
33504
+ release();
33505
+ }
33506
+ }
33507
+ }), writable: true, configurable: true });
33508
+ }
33509
+ return constructor;
33510
+ }
33511
+
33377
33512
  // packages/safe-js/src/interp/globals/intl.ts
33378
33513
  var supportedValuesOf = Intl.supportedValuesOf;
33379
33514
  function createIntlGlobal(budget) {
@@ -33389,16 +33524,18 @@ function createIntlGlobal(budget) {
33389
33524
  const locale = createLocaleConstructor(budget);
33390
33525
  const collator = createCollatorConstructor(budget);
33391
33526
  const numberFormat = createNumberFormatConstructor(budget);
33527
+ const listFormat = createListFormatConstructor(budget);
33392
33528
  Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
33393
33529
  Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
33394
33530
  Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
33531
+ Object.defineProperty(intl, "ListFormat", { value: listFormat, writable: true, configurable: true });
33395
33532
  for (const [name, call] of Object.entries(methods2)) {
33396
33533
  const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
33397
33534
  Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
33398
33535
  }
33399
33536
  Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
33400
33537
  registerBuiltinIdentities(budget, { Intl: intl });
33401
- for (const constructor of [locale, collator, numberFormat]) {
33538
+ for (const constructor of [locale, collator, numberFormat, listFormat]) {
33402
33539
  const prototype = constructor.properties.prototype;
33403
33540
  for (const owner of [prototype, constructor.properties])
33404
33541
  for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
@@ -33515,7 +33652,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
33515
33652
  createRawJson(node.text);
33516
33653
  return true;
33517
33654
  }
33518
- 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-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;
33655
+ 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-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;
33519
33656
  const reference = (value, kinds) => {
33520
33657
  const ref = record2(value);
33521
33658
  fields(ref, ["kind", "id"]);
@@ -33794,11 +33931,20 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
33794
33931
  if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
33795
33932
  throw new TypeError("Invalid resolved NumberFormat options.");
33796
33933
  if (node.format !== void 0) {
33797
- const format = reference(node.format, ["bound-function"]);
33798
- if (reference(format.thisValue) !== node || array(format.args).length !== 0 || format.name !== "" || format.length !== 1 || reference(format.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
33934
+ const format2 = reference(node.format, ["bound-function"]);
33935
+ if (reference(format2.thisValue) !== node || array(format2.args).length !== 0 || format2.name !== "" || format2.length !== 1 || reference(format2.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
33799
33936
  throw new TypeError("Invalid cached NumberFormat function.");
33800
33937
  }
33801
33938
  state(node.state);
33939
+ } else if (node.kind === "guest-listformat") {
33940
+ fields(node, ["kind", "options", "state"]);
33941
+ const options = record2(node.options);
33942
+ const names = ["locale", "type", "style"];
33943
+ fields(options, [...names]);
33944
+ if (names.some((key) => typeof options[key] !== "string")) throw new TypeError("Invalid ListFormat option type.");
33945
+ const restored = listFormatState(createSandboxListFormat(options.locale, options)).options;
33946
+ if (names.some((key) => options[key] !== restored[key])) throw new TypeError("Invalid resolved ListFormat options.");
33947
+ state(node.state);
33802
33948
  } else if (node.kind === "guest-collator") {
33803
33949
  fields(node, ["kind", "options", "state"], ["compare"]);
33804
33950
  const options = record2(node.options);
@@ -37554,6 +37700,7 @@ function measureSandboxData(values, options = {}) {
37554
37700
  }
37555
37701
  if (isSandboxDate(value)) usage += 8;
37556
37702
  if (isSandboxLocale(value)) usage += localeTag(value).length;
37703
+ if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
37557
37704
  if (isSandboxNumberFormat(value)) {
37558
37705
  const state = numberFormatState(value);
37559
37706
  visit(state.options, depth + 1);
@@ -55539,4 +55686,4 @@ The above copyright notice and this permission notice shall be included in all c
55539
55686
  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.
55540
55687
 
55541
55688
  */
55542
- //# sourceMappingURL=chunk-7OZYVM5K.js.map
55689
+ //# sourceMappingURL=chunk-GJPSM3AB.js.map