@poe-platform/safe-js 0.1.457 → 0.1.458

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.
@@ -8258,13 +8258,13 @@ function createLiveHostObject(definition, controller) {
8258
8258
  controller.chargeWork(properties.size + Object.keys(operations).length + 1);
8259
8259
  const host = Object.freeze(/* @__PURE__ */ Object.create(null));
8260
8260
  const guest = Object.freeze(/* @__PURE__ */ Object.create(null));
8261
- const methods2 = new Map(
8261
+ const methods3 = new Map(
8262
8262
  Object.entries(operations).map(([name, operation]) => [
8263
8263
  name,
8264
8264
  controller.method(operation)
8265
8265
  ])
8266
8266
  );
8267
- const state = { host, guest, controller, properties, methods: methods2, indexed, named };
8267
+ const state = { host, guest, controller, properties, methods: methods3, indexed, named };
8268
8268
  hostObjects.set(host, state);
8269
8269
  guestObjects.set(guest, state);
8270
8270
  return host;
@@ -8691,11 +8691,11 @@ function isIntrinsicFunction(value) {
8691
8691
  function registerIntrinsicPrototype(budget, prototype, constructor) {
8692
8692
  if (constructor.name === void 0) throw new TypeError("Intrinsic constructors require an installation name.");
8693
8693
  registerBuiltinIdentities(budget, { [constructor.name]: constructor });
8694
- const methods2 = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).flatMap((key) => {
8694
+ const methods3 = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).flatMap((key) => {
8695
8695
  const descriptor = Object.getOwnPropertyDescriptor(owner, key);
8696
8696
  return [descriptor.value, ...retainedAccessorClosures(descriptor)];
8697
8697
  })).filter(isGuestClosure);
8698
- trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...methods2]);
8698
+ trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...methods3]);
8699
8699
  }
8700
8700
  function registerIntrinsicFunction(budget, closure) {
8701
8701
  if (closure.name === void 0) throw new TypeError("Intrinsic functions require an installation name.");
@@ -8704,8 +8704,8 @@ function registerIntrinsicFunction(budget, closure) {
8704
8704
  trackIntrinsicState(budget, closure, closure, [closure]);
8705
8705
  }
8706
8706
  function registerIntrinsicObject(budget, value, trackMethods = true) {
8707
- const methods2 = trackMethods ? Object.values(Object.getOwnPropertyDescriptors(value)).map((descriptor) => descriptor.value).filter(isGuestClosure) : [];
8708
- trackIntrinsicState(budget, value, value, [value, ...methods2]);
8707
+ const methods3 = trackMethods ? Object.values(Object.getOwnPropertyDescriptors(value)).map((descriptor) => descriptor.value).filter(isGuestClosure) : [];
8708
+ trackIntrinsicState(budget, value, value, [value, ...methods3]);
8709
8709
  }
8710
8710
  function completeIntrinsicObjectInitialization(budget, value) {
8711
8711
  for (const records of intrinsicRetentionGroups.get(budget)?.values() ?? []) {
@@ -10199,7 +10199,7 @@ async function nextArrayIterator(value, budget, context) {
10199
10199
  }
10200
10200
 
10201
10201
  // packages/safe-js/src/interp/globals/object.ts
10202
- function createObjectGlobal(methods2, budget) {
10202
+ function createObjectGlobal(methods3, budget) {
10203
10203
  const construct = ([value]) => {
10204
10204
  if (value === null || value === void 0) {
10205
10205
  budget.chargeDataUsage(1);
@@ -10235,7 +10235,7 @@ function createObjectGlobal(methods2, budget) {
10235
10235
  const prototype = createIntrinsicObject(properties.prototype);
10236
10236
  properties.prototype = prototype;
10237
10237
  Object.defineProperty(properties, "prototype", { writable: false });
10238
- for (const [name, method] of Object.entries(methods2)) {
10238
+ for (const [name, method] of Object.entries(methods3)) {
10239
10239
  Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
10240
10240
  }
10241
10241
  const prototypeMethods = {
@@ -20723,7 +20723,7 @@ function createPrimitiveConstructor(options, budget) {
20723
20723
  writable: isSandboxClosure(value),
20724
20724
  configurable: isSandboxClosure(value)
20725
20725
  });
20726
- const methods2 = /* @__PURE__ */ new Map([
20726
+ const methods3 = /* @__PURE__ */ new Map([
20727
20727
  [
20728
20728
  "valueOf",
20729
20729
  createSandboxClosure({
@@ -20735,9 +20735,9 @@ function createPrimitiveConstructor(options, budget) {
20735
20735
  ]
20736
20736
  ]);
20737
20737
  if (kind === "number") {
20738
- for (const name of numberMethodNames) methods2.set(name, getNumberMember(name, budget));
20738
+ for (const name of numberMethodNames) methods3.set(name, getNumberMember(name, budget));
20739
20739
  } else {
20740
- methods2.set(
20740
+ methods3.set(
20741
20741
  "toString",
20742
20742
  createSandboxClosure({
20743
20743
  sandbox: true,
@@ -20747,9 +20747,9 @@ function createPrimitiveConstructor(options, budget) {
20747
20747
  })
20748
20748
  );
20749
20749
  if (kind === "string")
20750
- for (const name of stringMethodNames) methods2.set(name, getStringMember("", name, budget));
20750
+ for (const name of stringMethodNames) methods3.set(name, getStringMember("", name, budget));
20751
20751
  }
20752
- for (const [name, value] of methods2)
20752
+ for (const [name, value] of methods3)
20753
20753
  Object.defineProperty(prototype, name, { value, writable: true, configurable: true });
20754
20754
  if (kind === "string") {
20755
20755
  const iteratorPrototype = createIntrinsicObject();
@@ -28744,6 +28744,36 @@ function formatNumberValue(receiver, method, values) {
28744
28744
  return numberFormatterResult2(native, method, values);
28745
28745
  }
28746
28746
 
28747
+ // packages/safe-js/src/interp/intl-datetimeformat.ts
28748
+ var NativeDateTimeFormat = Intl.DateTimeFormat;
28749
+ var resolvedOptions5 = NativeDateTimeFormat.prototype.resolvedOptions;
28750
+ var format3 = Object.getOwnPropertyDescriptor(NativeDateTimeFormat.prototype, "format").get;
28751
+ var methods = {
28752
+ formatToParts: NativeDateTimeFormat.prototype.formatToParts,
28753
+ formatRange: NativeDateTimeFormat.prototype.formatRange,
28754
+ formatRangeToParts: NativeDateTimeFormat.prototype.formatRangeToParts
28755
+ };
28756
+ var states10 = /* @__PURE__ */ new WeakMap();
28757
+ function createSandboxDateTimeFormat(locales2, options, restoring = false) {
28758
+ const input = { ...options };
28759
+ if (restoring) delete input.hour12;
28760
+ const native = new NativeDateTimeFormat(locales2, input);
28761
+ const value = /* @__PURE__ */ Object.create(null);
28762
+ states10.set(value, { native, options: { ...Reflect.apply(resolvedOptions5, native, []) } });
28763
+ return value;
28764
+ }
28765
+ function isSandboxDateTimeFormat(value) {
28766
+ return typeof value === "object" && value !== null && states10.has(value);
28767
+ }
28768
+ function dateTimeFormatState(value) {
28769
+ if (!isSandboxDateTimeFormat(value)) throw new TypeError("Intl.DateTimeFormat requires a DateTimeFormat receiver.");
28770
+ return states10.get(value);
28771
+ }
28772
+ function formatDateTimeValue(receiver, method, values) {
28773
+ const { native } = dateTimeFormatState(receiver);
28774
+ return method === "format" ? Reflect.apply(format3, native, [])(values[0]) : Reflect.apply(methods[method], native, values);
28775
+ }
28776
+
28747
28777
  // packages/safe-js/src/interp/iterator-helper.ts
28748
28778
  var iteratorHelperStates = /* @__PURE__ */ new WeakMap();
28749
28779
 
@@ -29086,9 +29116,13 @@ function captureGuestHeapNode(value, encode) {
29086
29116
  if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
29087
29117
  if (isSandboxRelativeTimeFormat(value)) return { kind: "guest-relativetimeformat", options: { ...relativeTimeFormatState(value).options }, state: captureObjectState(value, encode) };
29088
29118
  if (isSandboxDisplayNames(value)) return { kind: "guest-displaynames", options: { ...displayNamesState(value).options }, state: captureObjectState(value, encode) };
29119
+ if (isSandboxDateTimeFormat(value)) {
29120
+ const { options, format: format4 } = dateTimeFormatState(value);
29121
+ return { kind: "guest-datetimeformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
29122
+ }
29089
29123
  if (isSandboxNumberFormat(value)) {
29090
- const { options, format: format3 } = numberFormatState(value);
29091
- return { kind: "guest-numberformat", options: { ...options }, ...format3 === void 0 ? {} : { format: encode(format3) }, state: captureObjectState(value, encode) };
29124
+ const { options, format: format4 } = numberFormatState(value);
29125
+ return { kind: "guest-numberformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
29092
29126
  }
29093
29127
  if (isSandboxCollator(value)) {
29094
29128
  const { options, compare } = collatorState(value);
@@ -30166,7 +30200,7 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
30166
30200
  }
30167
30201
 
30168
30202
  // packages/safe-js/src/interp/date-locale.ts
30169
- var NativeDateTimeFormat = Intl.DateTimeFormat;
30203
+ var NativeDateTimeFormat2 = Intl.DateTimeFormat;
30170
30204
  var dateTimeOptions = [
30171
30205
  ["localeMatcher", ["lookup", "best fit"]],
30172
30206
  ["calendar", "unicodeType"],
@@ -30189,14 +30223,11 @@ var dateTimeOptions = [
30189
30223
  ["dateStyle", ["full", "long", "medium", "short"]],
30190
30224
  ["timeStyle", ["full", "long", "medium", "short"]]
30191
30225
  ];
30192
- async function formatDateLocale(name, time, args, budget, context) {
30193
- if (Number.isNaN(time)) return budget.allocateString("Invalid Date");
30194
- let locales2 = [];
30226
+ async function readDateTimeFormatOptions(input, budget, context) {
30195
30227
  const options = /* @__PURE__ */ Object.create(null);
30196
- const release = retainValues(budget, () => [locales2, options]);
30228
+ const release = retainValues(budget, () => [input, options]);
30197
30229
  try {
30198
- locales2 = await canonicalizeGuestLocales(args[0], budget, context);
30199
- const inputOptions = intlOptionsObject(args[1], budget);
30230
+ const inputOptions = intlOptionsObject(input, budget);
30200
30231
  for (const [key, type] of dateTimeOptions) {
30201
30232
  const value = await readIntlProperty(inputOptions, key, budget, context);
30202
30233
  if (value === void 0) continue;
@@ -30208,10 +30239,23 @@ async function formatDateLocale(name, time, args, budget, context) {
30208
30239
  } else if (type === "zone") {
30209
30240
  const text = await sandboxString(value, budget, context);
30210
30241
  budget.visitNode(text.length);
30211
- new NativeDateTimeFormat("en", { timeZone: text });
30242
+ new NativeDateTimeFormat2("en", { timeZone: text });
30212
30243
  options[key] = text;
30213
30244
  } else options[key] = await convertIntlOption(value, key, type, budget, context);
30214
30245
  }
30246
+ return options;
30247
+ } finally {
30248
+ release();
30249
+ }
30250
+ }
30251
+ async function formatDateLocale(name, time, args, budget, context) {
30252
+ if (Number.isNaN(time)) return budget.allocateString("Invalid Date");
30253
+ let locales2 = [];
30254
+ let options = /* @__PURE__ */ Object.create(null);
30255
+ const release = retainValues(budget, () => [locales2, options]);
30256
+ try {
30257
+ locales2 = await canonicalizeGuestLocales(args[0], budget, context);
30258
+ options = await readDateTimeFormatOptions(args[1], budget, context);
30215
30259
  const date = name !== "toLocaleTimeString";
30216
30260
  const clock = name !== "toLocaleDateString";
30217
30261
  if (options.dateStyle !== void 0 || options.timeStyle !== void 0) {
@@ -30225,7 +30269,7 @@ async function formatDateLocale(name, time, args, budget, context) {
30225
30269
  if (clock) for (const key of ["hour", "minute", "second"]) options[key] = "numeric";
30226
30270
  }
30227
30271
  }
30228
- const formatter = new NativeDateTimeFormat(locales2, options);
30272
+ const formatter = new NativeDateTimeFormat2(locales2, options);
30229
30273
  return budget.allocateString(formatter.format(time));
30230
30274
  } finally {
30231
30275
  release();
@@ -30310,9 +30354,9 @@ function createDateGlobal(options) {
30310
30354
  call: (args, context) => coerceDateParts(args, true, options.budget, context)
30311
30355
  })
30312
30356
  };
30313
- const methods2 = /* @__PURE__ */ new Map();
30357
+ const methods3 = /* @__PURE__ */ new Map();
30314
30358
  for (const [name, method] of dateMethods)
30315
- methods2.set(
30359
+ methods3.set(
30316
30360
  name,
30317
30361
  createSandboxClosure({
30318
30362
  guest: true,
@@ -30332,8 +30376,8 @@ function createDateGlobal(options) {
30332
30376
  }
30333
30377
  })
30334
30378
  );
30335
- methods2.set("toGMTString", methods2.get("toUTCString"));
30336
- methods2.set(Symbol.toPrimitive, createSandboxClosure({
30379
+ methods3.set("toGMTString", methods3.get("toUTCString"));
30380
+ methods3.set(Symbol.toPrimitive, createSandboxClosure({
30337
30381
  guest: true,
30338
30382
  sandbox: true,
30339
30383
  name: "[Symbol.toPrimitive]",
@@ -30349,7 +30393,7 @@ function createDateGlobal(options) {
30349
30393
  for (const [key, value] of Object.entries(staticProperties))
30350
30394
  Object.defineProperty(properties, key, { value, writable: key !== "prototype", configurable: key !== "prototype" });
30351
30395
  Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
30352
- for (const [key, value] of methods2)
30396
+ for (const [key, value] of methods3)
30353
30397
  Object.defineProperty(prototype, key, { value, writable: key !== Symbol.toPrimitive, configurable: true });
30354
30398
  installDatePrototype(options.budget, prototype, constructor);
30355
30399
  return constructor;
@@ -30889,7 +30933,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
30889
30933
  return context.thisValue.values.size;
30890
30934
  }
30891
30935
  });
30892
- for (const { name, constructor, methods: methods2, size, iterator } of [
30936
+ for (const { name, constructor, methods: methods3, size, iterator } of [
30893
30937
  { name: "Map", constructor: mapConstructor, methods: mapMethods, size: mapSize, iterator: mapMethods.entries },
30894
30938
  { name: "Set", constructor: setConstructor, methods: setMethods, size: setSize, iterator: setMethods.values }
30895
30939
  ]) {
@@ -30904,13 +30948,13 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
30904
30948
  Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
30905
30949
  Object.defineProperty(materializeFunctionProperties(constructor), Symbol.species, { get: accessorAdapter(species, "get"), configurable: true });
30906
30950
  Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
30907
- for (const [key, method] of Object.entries(methods2))
30951
+ for (const [key, method] of Object.entries(methods3))
30908
30952
  Object.defineProperty(prototype, key, { value: method, writable: true, configurable: true });
30909
30953
  Object.defineProperty(prototype, "size", { get: accessorAdapter(size, "get"), configurable: true });
30910
30954
  Object.defineProperty(prototype, Symbol.toStringTag, { value: name, configurable: true });
30911
30955
  Object.defineProperty(prototype, Symbol.iterator, { value: iterator, writable: true, configurable: true });
30912
30956
  installCollectionPrototype(budget, name, prototype, constructor);
30913
- for (const method of /* @__PURE__ */ new Set([...Object.values(methods2), size, species])) registerIntrinsicFunction(budget, method);
30957
+ for (const method of /* @__PURE__ */ new Set([...Object.values(methods3), size, species])) registerIntrinsicFunction(budget, method);
30914
30958
  }
30915
30959
  }
30916
30960
  function installCollectionIteratorPrototypes(budget) {
@@ -32793,7 +32837,7 @@ function createSymbolGlobal(budget) {
32793
32837
  });
32794
32838
  const properties = materializeFunctionProperties(constructor);
32795
32839
  Object.defineProperty(properties, "prototype", { value: prototype });
32796
- const methods2 = {
32840
+ const methods3 = {
32797
32841
  for: createSandboxClosure({
32798
32842
  sandbox: true,
32799
32843
  name: "for",
@@ -32821,7 +32865,7 @@ function createSymbolGlobal(budget) {
32821
32865
  }
32822
32866
  })
32823
32867
  };
32824
- for (const [name, method] of Object.entries(methods2)) {
32868
+ for (const [name, method] of Object.entries(methods3)) {
32825
32869
  symbolRegistryOrigins.set(method, entries);
32826
32870
  Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
32827
32871
  }
@@ -33084,17 +33128,17 @@ function createArrayBufferGlobal(budget) {
33084
33128
  }
33085
33129
 
33086
33130
  // packages/safe-js/src/interp/globals/data-view.ts
33087
- var methods = Object.fromEntries(["Int8", "Uint8", "Int16", "Uint16", "Int32", "Uint32", "Float32", "Float64", "BigInt64", "BigUint64"].flatMap((type) => ["get", "set"].map((operation) => [operation + type, Object.getOwnPropertyDescriptor(DataView.prototype, operation + type).value])));
33131
+ var methods2 = Object.fromEntries(["Int8", "Uint8", "Int16", "Uint16", "Int32", "Uint32", "Float32", "Float64", "BigInt64", "BigUint64"].flatMap((type) => ["get", "set"].map((operation) => [operation + type, Object.getOwnPropertyDescriptor(DataView.prototype, operation + type).value])));
33088
33132
  var readUint16 = DataView.prototype.getUint16;
33089
33133
  var writeUint16 = DataView.prototype.setUint16;
33090
- methods.getFloat16 = function(...args) {
33134
+ methods2.getFloat16 = function(...args) {
33091
33135
  const bits = Reflect.apply(readUint16, this, args);
33092
33136
  const sign = bits & 32768 ? -1 : 1;
33093
33137
  const exponent = bits >> 10 & 31, fraction = bits & 1023;
33094
33138
  if (exponent === 31) return fraction === 0 ? sign * Infinity : NaN;
33095
33139
  return sign * (exponent === 0 ? fraction * 2 ** -24 : (1 + fraction / 1024) * 2 ** (exponent - 15));
33096
33140
  };
33097
- methods.setFloat16 = function(...args) {
33141
+ methods2.setFloat16 = function(...args) {
33098
33142
  const rounded = f16round(args[1]);
33099
33143
  const sign = rounded < 0 || Object.is(rounded, -0) ? 32768 : 0;
33100
33144
  const magnitude = Math.abs(rounded);
@@ -33166,7 +33210,7 @@ function createDataViewGlobal(budget) {
33166
33210
  Object.defineProperty(prototype, name, { get: accessorAdapter(closure, "get"), configurable: true });
33167
33211
  getters.push(closure);
33168
33212
  }
33169
- for (const [name, method] of Object.entries(methods)) {
33213
+ for (const [name, method] of Object.entries(methods2)) {
33170
33214
  const setter = name.startsWith("set");
33171
33215
  Object.defineProperty(prototype, name, {
33172
33216
  writable: true,
@@ -33209,7 +33253,7 @@ async function dataViewIndex(value, budget, context) {
33209
33253
  // packages/safe-js/src/interp/globals/reflect.ts
33210
33254
  var nativeReflectPropertyNames = Object.getOwnPropertyNames(Reflect);
33211
33255
  function createReflectGlobal(budget) {
33212
- const methods2 = {
33256
+ const methods3 = {
33213
33257
  ownKeys: { length: 1, call: ([target]) => {
33214
33258
  const properties = objectProperties(target);
33215
33259
  return allocateProducedSandboxValue([...Object.getOwnPropertyNames(properties), ...ownSandboxSymbolKeys(target)], budget);
@@ -33308,7 +33352,7 @@ function createReflectGlobal(budget) {
33308
33352
  };
33309
33353
  const reflect = createIntrinsicObject({});
33310
33354
  for (const name of nativeReflectPropertyNames) {
33311
- const method = methods2[name];
33355
+ const method = methods3[name];
33312
33356
  if (method === void 0) continue;
33313
33357
  const closure = createSandboxClosure({
33314
33358
  guest: true,
@@ -33365,9 +33409,9 @@ function createLocaleConstructor(budget) {
33365
33409
  Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false, configurable: false });
33366
33410
  Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
33367
33411
  Object.defineProperty(prototype, Symbol.toStringTag, { value: "Intl.Locale", configurable: true });
33368
- const methods2 = ["toString", "maximize", "minimize", "getCalendars", "getCollations", "getHourCycles", "getNumberingSystems", "getTimeZones", "getTextInfo", "getWeekInfo"];
33412
+ const methods3 = ["toString", "maximize", "minimize", "getCalendars", "getCollations", "getHourCycles", "getNumberingSystems", "getTimeZones", "getTextInfo", "getWeekInfo"];
33369
33413
  const getters = ["baseName", "language", "script", "region", "variants", "calendar", "collation", "firstDayOfWeek", "hourCycle", "caseFirst", "numeric", "numberingSystem"];
33370
- for (const name of [...methods2, ...getters]) {
33414
+ for (const name of [...methods3, ...getters]) {
33371
33415
  const getter = getters.includes(name);
33372
33416
  const closure = createSandboxClosure({
33373
33417
  guest: true,
@@ -33909,10 +33953,132 @@ function createDisplayNamesConstructor(budget) {
33909
33953
  return constructor;
33910
33954
  }
33911
33955
 
33956
+ // packages/safe-js/src/interp/globals/intl-datetimeformat.ts
33957
+ var supportedLocalesOf7 = Intl.DateTimeFormat.supportedLocalesOf;
33958
+ function createDateTimeFormatConstructor(budget, now) {
33959
+ const prototype = createIntrinsicObject();
33960
+ const formatTarget = createSandboxClosure({
33961
+ guest: true,
33962
+ sandbox: true,
33963
+ name: "",
33964
+ length: 1,
33965
+ call: async ([input], context) => {
33966
+ dateTimeFormatState(context?.thisValue);
33967
+ let value = 0;
33968
+ const release = retainValues(budget, () => [context?.thisValue, value]);
33969
+ try {
33970
+ value = input === void 0 ? await now.call([], context) : await sandboxNumber(input, budget, context);
33971
+ return allocateProducedSandboxValue(formatDateTimeValue(context?.thisValue, "format", [value]), budget);
33972
+ } finally {
33973
+ release();
33974
+ }
33975
+ }
33976
+ });
33977
+ registerBuiltinIdentities(budget, { "%DateTimeFormatFormat%": formatTarget });
33978
+ registerIntrinsicFunction(budget, formatTarget);
33979
+ const initialize = async ([input, options], context) => {
33980
+ const target = context?.newTarget;
33981
+ 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);
33982
+ let locales2 = [];
33983
+ const release = retainValues(budget, () => [selected, locales2]);
33984
+ try {
33985
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
33986
+ const converted = await readDateTimeFormatOptions(options, budget, context);
33987
+ const value = createSandboxDateTimeFormat(locales2, converted);
33988
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
33989
+ return allocateProducedSandboxValue(value, budget);
33990
+ } finally {
33991
+ release();
33992
+ }
33993
+ };
33994
+ const constructor = createSandboxClosure({
33995
+ guest: true,
33996
+ sandbox: true,
33997
+ name: "DateTimeFormat",
33998
+ length: 0,
33999
+ construct: initialize,
34000
+ call: (args, context) => initialize(args, { ...context, stack: context?.stack ?? [], thisValue: context?.thisValue, newTarget: void 0 })
34001
+ });
34002
+ const properties = materializeFunctionProperties(constructor);
34003
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
34004
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
34005
+ guest: true,
34006
+ sandbox: true,
34007
+ name: "supportedLocalesOf",
34008
+ length: 1,
34009
+ call: async ([input, options], context) => {
34010
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
34011
+ const release = retainValues(budget, () => [locales2]);
34012
+ try {
34013
+ const source = intlOptionsObject(options, budget);
34014
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
34015
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
34016
+ return allocateProducedSandboxValue(supportedLocalesOf7(locales2, { localeMatcher: matcher }), budget);
34017
+ } finally {
34018
+ release();
34019
+ }
34020
+ }
34021
+ }), writable: true, configurable: true });
34022
+ Object.defineProperties(prototype, {
34023
+ constructor: { value: constructor, writable: true, configurable: true },
34024
+ [Symbol.toStringTag]: { value: "Intl.DateTimeFormat", configurable: true },
34025
+ resolvedOptions: { value: createSandboxClosure({
34026
+ guest: true,
34027
+ sandbox: true,
34028
+ name: "resolvedOptions",
34029
+ length: 0,
34030
+ call: (_args, context) => allocateProducedSandboxValue({ ...dateTimeFormatState(context?.thisValue).options }, budget)
34031
+ }), writable: true, configurable: true },
34032
+ format: { get: accessorAdapter(createSandboxClosure({
34033
+ guest: true,
34034
+ sandbox: true,
34035
+ name: "get format",
34036
+ length: 0,
34037
+ call: (_args, context) => {
34038
+ const receiver = context?.thisValue;
34039
+ const state = dateTimeFormatState(receiver);
34040
+ if (state.format === void 0) {
34041
+ state.format = createBoundFunction(
34042
+ { target: formatTarget, thisValue: receiver, args: [] },
34043
+ "",
34044
+ 1,
34045
+ (target, args, stack, thisValue) => invokeBuiltinClosure(target, args, budget, { stack, thisValue }, thisValue)
34046
+ );
34047
+ allocateProducedSandboxValue(state.format, budget);
34048
+ }
34049
+ return state.format;
34050
+ }
34051
+ }), "get"), configurable: true }
34052
+ });
34053
+ for (const method of ["formatToParts", "formatRange", "formatRangeToParts"]) {
34054
+ const range = method !== "formatToParts";
34055
+ Object.defineProperty(prototype, method, { value: createSandboxClosure({
34056
+ guest: true,
34057
+ sandbox: true,
34058
+ name: method,
34059
+ length: range ? 2 : 1,
34060
+ call: async ([first, second], context) => {
34061
+ dateTimeFormatState(context?.thisValue);
34062
+ if (range && (first === void 0 || second === void 0)) throw new TypeError("DateTimeFormat range requires both values.");
34063
+ const values = [];
34064
+ const release = retainValues(budget, () => [context?.thisValue, values]);
34065
+ try {
34066
+ values.push(!range && first === void 0 ? await now.call([], context) : await sandboxNumber(first, budget, context));
34067
+ if (range) values.push(await sandboxNumber(second, budget, context));
34068
+ return allocateProducedSandboxValue(formatDateTimeValue(context?.thisValue, method, values), budget);
34069
+ } finally {
34070
+ release();
34071
+ }
34072
+ }
34073
+ }), writable: true, configurable: true });
34074
+ }
34075
+ return constructor;
34076
+ }
34077
+
33912
34078
  // packages/safe-js/src/interp/globals/intl.ts
33913
34079
  var supportedValuesOf = Intl.supportedValuesOf;
33914
- function createIntlGlobal(budget) {
33915
- const methods2 = {
34080
+ function createIntlGlobal(budget, now) {
34081
+ const methods3 = {
33916
34082
  getCanonicalLocales: async ([locales2], context) => allocateProducedSandboxValue(await canonicalizeGuestLocales(locales2, budget, context), budget),
33917
34083
  supportedValuesOf: async ([key], context) => {
33918
34084
  const text = await sandboxString(key, budget, context);
@@ -33927,19 +34093,21 @@ function createIntlGlobal(budget) {
33927
34093
  const listFormat = createListFormatConstructor(budget);
33928
34094
  const relativeTimeFormat = createRelativeTimeFormatConstructor(budget);
33929
34095
  const displayNames = createDisplayNamesConstructor(budget);
34096
+ const dateTimeFormat = createDateTimeFormatConstructor(budget, now);
33930
34097
  Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
33931
34098
  Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
33932
34099
  Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
33933
34100
  Object.defineProperty(intl, "ListFormat", { value: listFormat, writable: true, configurable: true });
33934
34101
  Object.defineProperty(intl, "RelativeTimeFormat", { value: relativeTimeFormat, writable: true, configurable: true });
33935
34102
  Object.defineProperty(intl, "DisplayNames", { value: displayNames, writable: true, configurable: true });
33936
- for (const [name, call] of Object.entries(methods2)) {
34103
+ Object.defineProperty(intl, "DateTimeFormat", { value: dateTimeFormat, writable: true, configurable: true });
34104
+ for (const [name, call] of Object.entries(methods3)) {
33937
34105
  const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
33938
34106
  Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
33939
34107
  }
33940
34108
  Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
33941
34109
  registerBuiltinIdentities(budget, { Intl: intl });
33942
- for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames]) {
34110
+ for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat]) {
33943
34111
  const prototype = constructor.properties.prototype;
33944
34112
  for (const owner of [prototype, constructor.properties])
33945
34113
  for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
@@ -33947,18 +34115,19 @@ function createIntlGlobal(budget) {
33947
34115
  if (isSandboxClosure(closure)) registerIntrinsicFunction(budget, closure);
33948
34116
  registerIntrinsicObject(budget, prototype);
33949
34117
  }
33950
- for (const name of Object.keys(methods2)) registerIntrinsicFunction(budget, intl[name]);
34118
+ for (const name of Object.keys(methods3)) registerIntrinsicFunction(budget, intl[name]);
33951
34119
  registerIntrinsicObject(budget, intl);
33952
34120
  return intl;
33953
34121
  }
33954
34122
 
33955
34123
  // packages/safe-js/src/interp/globals.ts
33956
34124
  function createBuiltinBindings(options) {
34125
+ const date = createDateGlobal(options);
33957
34126
  const bindings = {
33958
34127
  ...createConsoleJsonGlobals(options),
33959
34128
  ...createCollectionGlobals(options),
33960
34129
  ...Object.fromEntries(Object.entries(numericTypedArrayConstructors).map(([name, Native]) => [name, createNumericTypedArrayGlobal(options.budget, options.typedArrayPrototypes !== false, Native)])),
33961
- Date: createDateGlobal(options),
34130
+ Date: date,
33962
34131
  Symbol: createSymbolGlobal(options.budget),
33963
34132
  BigInt: createBigIntGlobal(options.budget),
33964
34133
  ...createErrorGlobals({ ...options, errorPrototypes: options.errorPrototypes !== false }),
@@ -33968,7 +34137,7 @@ function createBuiltinBindings(options) {
33968
34137
  DisposableStack: createDisposableStackGlobal(options.budget),
33969
34138
  AsyncDisposableStack: createAsyncDisposableStackGlobal(options.budget),
33970
34139
  Reflect: createReflectGlobal(options.budget),
33971
- Intl: createIntlGlobal(options.budget),
34140
+ Intl: createIntlGlobal(options.budget, date.properties.now),
33972
34141
  ArrayBuffer: createArrayBufferGlobal(options.budget),
33973
34142
  DataView: createDataViewGlobal(options.budget),
33974
34143
  ...createMiscGlobals(options),
@@ -34056,7 +34225,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34056
34225
  createRawJson(node.text);
34057
34226
  return true;
34058
34227
  }
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;
34228
+ 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-datetimeformat", "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;
34060
34229
  const reference = (value, kinds) => {
34061
34230
  const ref = record2(value);
34062
34231
  fields(ref, ["kind", "id"]);
@@ -34325,6 +34494,21 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34325
34494
  fields(node, ["kind", "source", "flags", "state"]);
34326
34495
  if (typeof node.source !== "string" || typeof node.flags !== "string") throw new TypeError("Invalid guest RegExp payload.");
34327
34496
  state(node.state);
34497
+ } else if (node.kind === "guest-datetimeformat") {
34498
+ fields(node, ["kind", "options", "state"], ["format"]);
34499
+ const options = record2(node.options);
34500
+ fields(options, ["locale", "calendar", "numberingSystem", "timeZone"], ["hourCycle", "hour12", "weekday", "era", "year", "month", "day", "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits", "timeZoneName", "dateStyle", "timeStyle"]);
34501
+ if (typeof options.locale !== "string" || Object.values(options).some((value) => !["string", "number", "boolean"].includes(typeof value)))
34502
+ throw new TypeError("Invalid DateTimeFormat option type.");
34503
+ const restored = dateTimeFormatState(createSandboxDateTimeFormat(options.locale, options, true)).options;
34504
+ if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
34505
+ throw new TypeError("Invalid resolved DateTimeFormat options.");
34506
+ if (node.format !== void 0) {
34507
+ const format4 = reference(node.format, ["bound-function"]);
34508
+ if (reference(format4.thisValue) !== node || array(format4.args).length !== 0 || format4.name !== "" || format4.length !== 1 || reference(format4.target, ["intrinsic"]).id !== '["%DateTimeFormatFormat%"]')
34509
+ throw new TypeError("Invalid cached DateTimeFormat function.");
34510
+ }
34511
+ state(node.state);
34328
34512
  } else if (node.kind === "guest-numberformat") {
34329
34513
  fields(node, ["kind", "options", "state"], ["format"]);
34330
34514
  const options = record2(node.options);
@@ -34335,8 +34519,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34335
34519
  if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
34336
34520
  throw new TypeError("Invalid resolved NumberFormat options.");
34337
34521
  if (node.format !== void 0) {
34338
- const format3 = reference(node.format, ["bound-function"]);
34339
- if (reference(format3.thisValue) !== node || array(format3.args).length !== 0 || format3.name !== "" || format3.length !== 1 || reference(format3.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
34522
+ const format4 = reference(node.format, ["bound-function"]);
34523
+ if (reference(format4.thisValue) !== node || array(format4.args).length !== 0 || format4.name !== "" || format4.length !== 1 || reference(format4.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
34340
34524
  throw new TypeError("Invalid cached NumberFormat function.");
34341
34525
  }
34342
34526
  state(node.state);
@@ -38130,6 +38314,11 @@ function measureSandboxData(values, options = {}) {
38130
38314
  visit(state.options, depth + 1);
38131
38315
  visit(state.format, depth + 1);
38132
38316
  }
38317
+ if (isSandboxDateTimeFormat(value)) {
38318
+ const state = dateTimeFormatState(value);
38319
+ visit(state.options, depth + 1);
38320
+ visit(state.format, depth + 1);
38321
+ }
38133
38322
  if (isSandboxCollator(value)) {
38134
38323
  const state = collatorState(value);
38135
38324
  visit(state.options, depth + 1);
@@ -56110,4 +56299,4 @@ The above copyright notice and this permission notice shall be included in all c
56110
56299
  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.
56111
56300
 
56112
56301
  */
56113
- //# sourceMappingURL=chunk-OXTOMAYL.js.map
56302
+ //# sourceMappingURL=chunk-GPAQUL2B.js.map