@formatjs/intl-durationformat 0.13.0 → 0.13.2
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.
- package/index.d.ts +4 -1
- package/index.js +493 -198
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/polyfill-force.js +509 -204
- package/polyfill-force.js.map +1 -1
- package/polyfill.js +510 -205
- package/polyfill.js.map +1 -1
- package/should-polyfill.js +1 -1
- package/should-polyfill.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BigDecimal
|
|
1
|
+
import { FilterLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
|
+
import { BigDecimal } from "@formatjs/bigdecimal";
|
|
3
3
|
// node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
|
|
4
4
|
const numberingSystemNames = [
|
|
5
5
|
"adlm",
|
|
@@ -101,79 +101,111 @@ const numberingSystemNames = [
|
|
|
101
101
|
"wcho"
|
|
102
102
|
];
|
|
103
103
|
// packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
|
|
104
|
+
const typeApply = Reflect.apply;
|
|
105
|
+
const charCodeAt = String.prototype.charCodeAt;
|
|
104
106
|
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
|
|
105
107
|
function IsUnicodeLocaleIdentifierType(value) {
|
|
106
|
-
|
|
108
|
+
let length = 0;
|
|
109
|
+
for (let index = 0; index < value.length; index++) {
|
|
110
|
+
const code = typeApply(charCodeAt, value, [index]);
|
|
111
|
+
if (code === 45) {
|
|
112
|
+
if (length < 3) return false;
|
|
113
|
+
length = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const letter = code | 32;
|
|
117
|
+
if (!(letter >= 97 && letter <= 122) && !(code >= 48 && code <= 57)) return false;
|
|
118
|
+
if (++length > 8) return false;
|
|
119
|
+
}
|
|
120
|
+
return length >= 3;
|
|
107
121
|
}
|
|
108
|
-
// packages/ecma262-abstract/
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
// packages/ecma262-abstract/intrinsics.js
|
|
123
|
+
const floor = Math.floor;
|
|
124
|
+
const numberFrom = Number;
|
|
125
|
+
const bigIntFrom = BigInt;
|
|
126
|
+
const objectFrom = Object;
|
|
127
|
+
const objectCreate = Object.create;
|
|
128
|
+
function createFromConstructor(newTarget, defaultPrototype) {
|
|
129
|
+
const prototype = newTarget.prototype;
|
|
130
|
+
return objectCreate(objectFrom(prototype) === prototype ? prototype : defaultPrototype);
|
|
111
131
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
const mathAbs = Math.abs;
|
|
133
|
+
const numberIsInteger = Number.isInteger;
|
|
134
|
+
const numberIsFinite = Number.isFinite;
|
|
135
|
+
Number.isSafeInteger;
|
|
136
|
+
const ErrorConstructor = Error;
|
|
137
|
+
const TypeErrorConstructor$1 = TypeError;
|
|
138
|
+
const RangeErrorConstructor = RangeError;
|
|
139
|
+
const arrayApply = Reflect.apply;
|
|
140
|
+
Array.prototype.every;
|
|
141
|
+
const some = Array.prototype.some;
|
|
142
|
+
function arraySome(values, predicate) {
|
|
143
|
+
return arrayApply(some, values, [predicate]);
|
|
122
144
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
Array.prototype.includes;
|
|
146
|
+
Array.prototype.indexOf;
|
|
147
|
+
const defineProperty$1 = Object.defineProperty;
|
|
148
|
+
function setDataProperty(target, key, value) {
|
|
149
|
+
defineProperty$1(target, key, {
|
|
150
|
+
__proto__: null,
|
|
151
|
+
value,
|
|
152
|
+
writable: true,
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
130
156
|
}
|
|
131
157
|
// packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
158
|
+
let canonicalIntl = globalThis.Intl;
|
|
159
|
+
const canonicalDescriptor = Object.getOwnPropertyDescriptor;
|
|
160
|
+
const canonicalApply = Reflect.apply;
|
|
161
|
+
const providerKey = Symbol.for("@formatjs/intlCanonicalizeLocaleList");
|
|
162
|
+
function ownCanonicalProvider() {
|
|
163
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
|
|
164
|
+
return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
|
|
165
|
+
}
|
|
166
|
+
let canonicalProvider = ownCanonicalProvider();
|
|
167
|
+
function registeredCanonicalProvider() {
|
|
168
|
+
try {
|
|
169
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, providerKey);
|
|
170
|
+
return descriptor && canonicalDescriptor(descriptor, "value")?.value;
|
|
171
|
+
} catch {}
|
|
172
|
+
}
|
|
136
173
|
function CanonicalizeLocaleList(locales) {
|
|
137
|
-
|
|
174
|
+
if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
|
|
175
|
+
const registered = registeredCanonicalProvider();
|
|
176
|
+
if (typeof registered === "function") return canonicalApply(registered, canonicalIntl, [locales]);
|
|
177
|
+
if (typeof canonicalProvider !== "function") canonicalProvider = ownCanonicalProvider();
|
|
178
|
+
return canonicalApply(canonicalProvider, canonicalIntl, [locales]);
|
|
138
179
|
}
|
|
139
180
|
// packages/ecma402-abstract/DefaultNumberOption.js
|
|
140
|
-
/**
|
|
141
|
-
* ECMA-402 §9.2.13 DefaultNumberOption, step 2.
|
|
142
|
-
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
143
|
-
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
|
|
144
|
-
* @param val
|
|
145
|
-
* @param min
|
|
146
|
-
* @param max
|
|
147
|
-
* @param fallback
|
|
148
|
-
*/
|
|
149
181
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
150
182
|
if (inputVal === void 0) return fallback;
|
|
151
183
|
const val = +inputVal;
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
184
|
+
if (!numberIsFinite(val) || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
|
|
185
|
+
return val === 0 ? 0 : floor(val);
|
|
154
186
|
}
|
|
155
187
|
// packages/ecma402-abstract/GetNumberOption.js
|
|
156
|
-
/**
|
|
157
|
-
* https://tc39.es/ecma402/#sec-getnumberoption
|
|
158
|
-
* @param options
|
|
159
|
-
* @param property
|
|
160
|
-
* @param min
|
|
161
|
-
* @param max
|
|
162
|
-
* @param fallback
|
|
163
|
-
*/
|
|
164
188
|
function GetNumberOption(options, property, minimum, maximum, fallback) {
|
|
165
189
|
const val = options[property];
|
|
166
190
|
return DefaultNumberOption(val, minimum, maximum, fallback);
|
|
167
191
|
}
|
|
192
|
+
// packages/ecma262-abstract/IsObject.js
|
|
193
|
+
function IsObject(value) {
|
|
194
|
+
return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
|
|
195
|
+
}
|
|
168
196
|
// packages/ecma262-abstract/ToString.js
|
|
197
|
+
const StringConstructor = String;
|
|
198
|
+
const TypeErrorConstructor = TypeError;
|
|
169
199
|
/**
|
|
170
200
|
* https://tc39.es/ecma262/#sec-tostring
|
|
171
201
|
*/
|
|
172
202
|
function ToString(o) {
|
|
173
|
-
if (typeof o === "symbol") throw
|
|
174
|
-
return
|
|
203
|
+
if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
|
|
204
|
+
return StringConstructor(o);
|
|
175
205
|
}
|
|
176
206
|
// packages/ecma402-abstract/GetOption.js
|
|
207
|
+
const optionApply = Reflect.apply;
|
|
208
|
+
const optionJoin = Array.prototype.join;
|
|
177
209
|
/**
|
|
178
210
|
* https://tc39.es/ecma402/#sec-getoption
|
|
179
211
|
* @param opts
|
|
@@ -183,34 +215,62 @@ function ToString(o) {
|
|
|
183
215
|
* @param fallback
|
|
184
216
|
*/
|
|
185
217
|
function GetOption(opts, prop, type, values, fallback) {
|
|
186
|
-
if (opts
|
|
218
|
+
if (!IsObject(opts)) throw new TypeErrorConstructor$1("Options must be an object");
|
|
187
219
|
let value = opts[prop];
|
|
188
220
|
if (value !== void 0) {
|
|
189
|
-
if (type !== "boolean" && type !== "string") throw new
|
|
190
|
-
if (type === "boolean") value =
|
|
221
|
+
if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$1("invalid type");
|
|
222
|
+
if (type === "boolean") value = !!value;
|
|
191
223
|
if (type === "string") value = ToString(value);
|
|
192
|
-
if (values
|
|
224
|
+
if (values?.length && !arraySome(values, (val) => val === value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
|
|
193
225
|
return value;
|
|
194
226
|
}
|
|
195
227
|
return fallback;
|
|
196
228
|
}
|
|
197
|
-
// packages/ecma402-abstract/
|
|
229
|
+
// packages/ecma402-abstract/GetOptionsObject.js
|
|
230
|
+
const createObject$2 = Object.create;
|
|
198
231
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* @param requestedLocales
|
|
232
|
+
* ECMA-262 §7.3.36 GetOptionsObject, steps 1–3.
|
|
233
|
+
* https://tc39.es/ecma262/#sec-getoptionsobject
|
|
202
234
|
* @param options
|
|
235
|
+
* @returns
|
|
203
236
|
*/
|
|
237
|
+
function GetOptionsObject(options) {
|
|
238
|
+
if (options === void 0) return createObject$2(null);
|
|
239
|
+
if (IsObject(options)) return options;
|
|
240
|
+
throw new TypeErrorConstructor$1("Options must be an object");
|
|
241
|
+
}
|
|
242
|
+
// packages/ecma262-abstract/ToObject.js
|
|
243
|
+
/**
|
|
244
|
+
* https://tc39.es/ecma262/#sec-toobject
|
|
245
|
+
*/
|
|
246
|
+
function ToObject(arg) {
|
|
247
|
+
if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
|
|
248
|
+
return objectFrom(arg);
|
|
249
|
+
}
|
|
250
|
+
// packages/ecma402-abstract/CoerceOptionsToObject.js
|
|
251
|
+
const createObject$1 = Object.create;
|
|
252
|
+
/**
|
|
253
|
+
* https://tc39.es/ecma402/#sec-coerceoptionstoobject
|
|
254
|
+
* @param options
|
|
255
|
+
* @returns
|
|
256
|
+
*/
|
|
257
|
+
function CoerceOptionsToObject(options) {
|
|
258
|
+
if (options === void 0) return createObject$1(null);
|
|
259
|
+
return ToObject(options);
|
|
260
|
+
}
|
|
261
|
+
// packages/ecma402-abstract/SupportedLocales.js
|
|
204
262
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
options = ToObject(options);
|
|
208
|
-
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
209
|
-
}
|
|
210
|
-
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
211
|
-
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
263
|
+
const matcher = GetOption(CoerceOptionsToObject(options), "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
264
|
+
return FilterLocales(availableLocales, requestedLocales, matcher, true);
|
|
212
265
|
}
|
|
213
266
|
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
267
|
+
const apply$2 = Reflect.apply;
|
|
268
|
+
const bind = Function.prototype.bind;
|
|
269
|
+
const slice = Array.prototype.slice;
|
|
270
|
+
const stringify = JSON.stringify;
|
|
271
|
+
const create = Object.create;
|
|
272
|
+
const defineProperty = Object.defineProperty;
|
|
273
|
+
const setPrototypeOf = Object.setPrototypeOf;
|
|
214
274
|
function memoize(fn, options) {
|
|
215
275
|
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
216
276
|
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -226,23 +286,29 @@ function monadic(fn, cache, serializer, arg) {
|
|
|
226
286
|
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
227
287
|
let computedValue = cache.get(cacheKey);
|
|
228
288
|
if (typeof computedValue === "undefined") {
|
|
229
|
-
computedValue = fn
|
|
289
|
+
computedValue = apply$2(fn, this, [arg]);
|
|
230
290
|
cache.set(cacheKey, computedValue);
|
|
231
291
|
}
|
|
232
292
|
return computedValue;
|
|
233
293
|
}
|
|
234
294
|
function variadic(fn, cache, serializer) {
|
|
235
|
-
const args =
|
|
295
|
+
const args = apply$2(slice, arguments, [3]);
|
|
296
|
+
if (serializer === serializerDefault) setPrototypeOf(args, null);
|
|
236
297
|
const cacheKey = serializer(args);
|
|
237
298
|
let computedValue = cache.get(cacheKey);
|
|
238
299
|
if (typeof computedValue === "undefined") {
|
|
239
|
-
computedValue =
|
|
300
|
+
computedValue = apply$2(fn, this, args);
|
|
240
301
|
cache.set(cacheKey, computedValue);
|
|
241
302
|
}
|
|
242
303
|
return computedValue;
|
|
243
304
|
}
|
|
244
305
|
function assemble(fn, context, strategy, cache, serialize) {
|
|
245
|
-
return
|
|
306
|
+
return apply$2(bind, strategy, [
|
|
307
|
+
context,
|
|
308
|
+
fn,
|
|
309
|
+
cache,
|
|
310
|
+
serialize
|
|
311
|
+
]);
|
|
246
312
|
}
|
|
247
313
|
function strategyDefault(fn, options) {
|
|
248
314
|
const strategy = fn.length === 1 ? monadic : variadic;
|
|
@@ -255,11 +321,18 @@ function strategyMonadic(fn, options) {
|
|
|
255
321
|
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
|
256
322
|
}
|
|
257
323
|
const serializerDefault = function() {
|
|
258
|
-
|
|
324
|
+
setPrototypeOf(arguments, null);
|
|
325
|
+
return stringify(arguments);
|
|
259
326
|
};
|
|
260
327
|
var ObjectWithoutPrototypeCache = class {
|
|
261
328
|
constructor() {
|
|
262
|
-
this
|
|
329
|
+
defineProperty(this, "cache", {
|
|
330
|
+
__proto__: null,
|
|
331
|
+
value: create(null),
|
|
332
|
+
writable: true,
|
|
333
|
+
enumerable: true,
|
|
334
|
+
configurable: true
|
|
335
|
+
});
|
|
263
336
|
}
|
|
264
337
|
get(key) {
|
|
265
338
|
return this.cache[key];
|
|
@@ -275,16 +348,115 @@ const strategies = {
|
|
|
275
348
|
variadic: strategyVariadic,
|
|
276
349
|
monadic: strategyMonadic
|
|
277
350
|
};
|
|
278
|
-
|
|
279
|
-
|
|
351
|
+
String.prototype.repeat;
|
|
352
|
+
Array.from;
|
|
353
|
+
Array.prototype.join;
|
|
354
|
+
function invariant(condition, message, Err = ErrorConstructor) {
|
|
280
355
|
if (!condition) throw new Err(message);
|
|
281
356
|
}
|
|
282
|
-
|
|
283
|
-
memoize((...args) => new Intl.
|
|
284
|
-
const
|
|
357
|
+
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
358
|
+
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
359
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
360
|
+
const formatterMemoizeOptions = {
|
|
361
|
+
__proto__: null,
|
|
362
|
+
strategy: strategies.variadic
|
|
363
|
+
};
|
|
364
|
+
let providerIntl = globalThis.Intl;
|
|
365
|
+
function ownIntlProvider(name) {
|
|
366
|
+
const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
|
|
367
|
+
return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
|
|
368
|
+
}
|
|
369
|
+
let numberFormatIntrinsic = ownIntlProvider("NumberFormat");
|
|
370
|
+
let listFormatIntrinsic = ownIntlProvider("ListFormat");
|
|
371
|
+
let pluralRulesProvider = ownIntlProvider("PluralRules");
|
|
372
|
+
const formatterIntrinsicKeys = {
|
|
373
|
+
NumberFormat: Symbol.for("@formatjs/intlNumberFormat"),
|
|
374
|
+
ListFormat: Symbol.for("@formatjs/intlListFormat"),
|
|
375
|
+
PluralRules: Symbol.for("@formatjs/intlPluralRules")
|
|
376
|
+
};
|
|
377
|
+
function getNumberFormatIntrinsic() {
|
|
378
|
+
if (providerIntl === void 0) providerIntl = globalThis.Intl;
|
|
379
|
+
const registered = ownIntlProvider(formatterIntrinsicKeys.NumberFormat);
|
|
380
|
+
if (typeof registered === "function") return registered;
|
|
381
|
+
if (typeof numberFormatIntrinsic !== "function") numberFormatIntrinsic = ownIntlProvider("NumberFormat");
|
|
382
|
+
return numberFormatIntrinsic;
|
|
383
|
+
}
|
|
384
|
+
function getListFormatIntrinsic() {
|
|
385
|
+
if (providerIntl === void 0) providerIntl = globalThis.Intl;
|
|
386
|
+
const registered = ownIntlProvider(formatterIntrinsicKeys.ListFormat);
|
|
387
|
+
if (typeof registered === "function") return registered;
|
|
388
|
+
if (typeof listFormatIntrinsic !== "function") listFormatIntrinsic = ownIntlProvider("ListFormat");
|
|
389
|
+
return listFormatIntrinsic;
|
|
390
|
+
}
|
|
391
|
+
const getFormatterPrototype = Object.getPrototypeOf;
|
|
392
|
+
function formatterMethodLookup(name) {
|
|
393
|
+
const methods = /* @__PURE__ */ new WeakMap();
|
|
394
|
+
const owners = /* @__PURE__ */ new WeakMap();
|
|
395
|
+
const getMethod = methods.get.bind(methods);
|
|
396
|
+
const setMethod = methods.set.bind(methods);
|
|
397
|
+
const getOwner = owners.get.bind(owners);
|
|
398
|
+
const setOwner = owners.set.bind(owners);
|
|
399
|
+
return (Constructor) => {
|
|
400
|
+
const cached = getMethod(Constructor);
|
|
401
|
+
if (cached) return cached;
|
|
402
|
+
let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
|
|
403
|
+
while (prototype != null) {
|
|
404
|
+
const inherited = getOwner(prototype);
|
|
405
|
+
if (inherited) {
|
|
406
|
+
setMethod(Constructor, inherited);
|
|
407
|
+
return inherited;
|
|
408
|
+
}
|
|
409
|
+
const descriptor = getOwnPropertyDescriptor(prototype, name);
|
|
410
|
+
const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
|
|
411
|
+
if (value && typeof value.value === "function") {
|
|
412
|
+
const method = value.value;
|
|
413
|
+
setMethod(Constructor, method);
|
|
414
|
+
setOwner(prototype, method);
|
|
415
|
+
return method;
|
|
416
|
+
}
|
|
417
|
+
prototype = getFormatterPrototype(prototype);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
const findFormatterPartsMethod = formatterMethodLookup("formatToParts");
|
|
422
|
+
const findPluralRulesSelectMethod = formatterMethodLookup("select");
|
|
423
|
+
function getFormatterPartsMethod(Constructor) {
|
|
424
|
+
const method = findFormatterPartsMethod(Constructor);
|
|
425
|
+
if (!method) throw new TypeErrorConstructor$1("Missing supplied formatter parts method");
|
|
426
|
+
return method;
|
|
427
|
+
}
|
|
428
|
+
if (typeof numberFormatIntrinsic === "function") findFormatterPartsMethod(numberFormatIntrinsic);
|
|
429
|
+
if (typeof listFormatIntrinsic === "function") findFormatterPartsMethod(listFormatIntrinsic);
|
|
430
|
+
if (typeof pluralRulesProvider === "function") findPluralRulesSelectMethod(pluralRulesProvider);
|
|
431
|
+
const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
432
|
+
const getNumberFormatMemoizer = numberFormatMemoizers.get.bind(numberFormatMemoizers);
|
|
433
|
+
const setNumberFormatMemoizer = numberFormatMemoizers.set.bind(numberFormatMemoizers);
|
|
434
|
+
const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
435
|
+
const getListFormatMemoizer = listFormatMemoizers.get.bind(listFormatMemoizers);
|
|
436
|
+
const setListFormatMemoizer = listFormatMemoizers.set.bind(listFormatMemoizers);
|
|
437
|
+
const pluralRulesMemoizers = /* @__PURE__ */ new WeakMap();
|
|
438
|
+
pluralRulesMemoizers.get.bind(pluralRulesMemoizers);
|
|
439
|
+
pluralRulesMemoizers.set.bind(pluralRulesMemoizers);
|
|
440
|
+
function createMemoizedNumberFormatForConstructor(Constructor) {
|
|
441
|
+
let factory = getNumberFormatMemoizer(Constructor);
|
|
442
|
+
if (!factory) {
|
|
443
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
444
|
+
setNumberFormatMemoizer(Constructor, factory);
|
|
445
|
+
}
|
|
446
|
+
return factory;
|
|
447
|
+
}
|
|
448
|
+
function createMemoizedListFormatForConstructor(Constructor) {
|
|
449
|
+
let factory = getListFormatMemoizer(Constructor);
|
|
450
|
+
if (!factory) {
|
|
451
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
452
|
+
setListFormatMemoizer(Constructor, factory);
|
|
453
|
+
}
|
|
454
|
+
return factory;
|
|
455
|
+
}
|
|
285
456
|
// packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
|
|
286
457
|
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
|
|
287
|
-
|
|
458
|
+
const unitOptions = options;
|
|
459
|
+
let style = GetOption(unitOptions, unit, "string", stylesList, void 0);
|
|
288
460
|
let displayDefault = "always";
|
|
289
461
|
if (style === void 0) {
|
|
290
462
|
if (baseStyle === "digital") {
|
|
@@ -302,10 +474,10 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
|
|
|
302
474
|
style = "fractional";
|
|
303
475
|
displayDefault = "auto";
|
|
304
476
|
}
|
|
305
|
-
const display = GetOption(
|
|
306
|
-
if (display === "always" && style === "fractional") throw new
|
|
307
|
-
if (prevStyle === "fractional" && style !== "fractional") throw new
|
|
308
|
-
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new
|
|
477
|
+
const display = GetOption(unitOptions, `${unit}Display`, "string", ["always", "auto"], displayDefault);
|
|
478
|
+
if (display === "always" && style === "fractional") throw new RangeErrorConstructor("Fractional units cannot use always display");
|
|
479
|
+
if (prevStyle === "fractional" && style !== "fractional") throw new RangeErrorConstructor("Fractional units must be followed by fractional units");
|
|
480
|
+
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeErrorConstructor("Can't mix numeric and non-numeric styles");
|
|
309
481
|
if (twoDigitHours && unit === "hours") style = "2-digit";
|
|
310
482
|
if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
|
|
311
483
|
return {
|
|
@@ -388,43 +560,63 @@ const TABLE_2 = [
|
|
|
388
560
|
];
|
|
389
561
|
// packages/intl-durationformat/get_internal_slots.ts
|
|
390
562
|
const internalSlotMap = /* @__PURE__ */ new WeakMap();
|
|
563
|
+
const getSlots = internalSlotMap.get.bind(internalSlotMap);
|
|
564
|
+
const setSlots = internalSlotMap.set.bind(internalSlotMap);
|
|
565
|
+
const createSlots = Object.create;
|
|
566
|
+
function requireInternalSlots(x) {
|
|
567
|
+
const slots = getSlots(x);
|
|
568
|
+
if (!slots?.initializedDurationFormat) throw new TypeErrorConstructor$1("Incompatible Intl.DurationFormat receiver");
|
|
569
|
+
return slots;
|
|
570
|
+
}
|
|
391
571
|
function getInternalSlots(x) {
|
|
392
|
-
let internalSlots =
|
|
572
|
+
let internalSlots = getSlots(x);
|
|
393
573
|
if (!internalSlots) {
|
|
394
|
-
internalSlots =
|
|
395
|
-
|
|
574
|
+
internalSlots = createSlots(null);
|
|
575
|
+
setSlots(x, internalSlots);
|
|
396
576
|
}
|
|
397
577
|
return internalSlots;
|
|
398
578
|
}
|
|
399
579
|
// packages/intl-durationformat/abstract/PartitionDurationFormatPattern.ts
|
|
580
|
+
const apply$1 = Reflect.apply;
|
|
581
|
+
const stringListIterator = Array.prototype[Symbol.iterator];
|
|
582
|
+
const stringListIteratorNext = Object.getPrototypeOf(apply$1(stringListIterator, [], [])).next;
|
|
583
|
+
const formatterProviders = /* @__PURE__ */ new WeakMap();
|
|
584
|
+
const getFormatterProviders = formatterProviders.get.bind(formatterProviders);
|
|
585
|
+
const setFormatterProviders = formatterProviders.set.bind(formatterProviders);
|
|
586
|
+
function initializeDurationFormatProviders(df) {
|
|
587
|
+
const NumberFormat = getNumberFormatIntrinsic();
|
|
588
|
+
const ListFormat = getListFormatIntrinsic();
|
|
589
|
+
setFormatterProviders(df, {
|
|
590
|
+
numberFormat: createMemoizedNumberFormatForConstructor(NumberFormat),
|
|
591
|
+
listFormat: createMemoizedListFormatForConstructor(ListFormat),
|
|
592
|
+
numberFormatToParts: getFormatterPartsMethod(NumberFormat),
|
|
593
|
+
listFormatToParts: getFormatterPartsMethod(ListFormat)
|
|
594
|
+
});
|
|
595
|
+
}
|
|
400
596
|
function PartitionDurationFormatPattern(df, duration) {
|
|
401
597
|
const result = [];
|
|
402
598
|
let done = false;
|
|
403
599
|
let separated = false;
|
|
404
600
|
let signDisplayed = true;
|
|
405
|
-
const negative = TABLE_2
|
|
601
|
+
const negative = arraySome(TABLE_2, (row) => duration[row.valueField] < 0);
|
|
406
602
|
const internalSlots = getInternalSlots(df);
|
|
407
|
-
|
|
408
|
-
const dataLocaleData = DurationFormat.localeData[dataLocale];
|
|
409
|
-
if (!dataLocaleData) throw new TypeError("Invalid locale");
|
|
410
|
-
const numberingSystem = internalSlots.numberingSystem;
|
|
411
|
-
const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
|
|
603
|
+
const providers = getFormatterProviders(df);
|
|
412
604
|
for (let i = 0; i < TABLE_2.length && !done; i++) {
|
|
413
605
|
const row = TABLE_2[i];
|
|
414
|
-
let value = new BigDecimal(
|
|
606
|
+
let value = new BigDecimal(bigIntFrom(duration[row.valueField]));
|
|
415
607
|
const style = internalSlots[row.styleSlot];
|
|
416
608
|
const display = internalSlots[row.displaySlot];
|
|
417
609
|
const { unit, numberFormatUnit } = row;
|
|
418
|
-
const nfOpts =
|
|
610
|
+
const nfOpts = { __proto__: null };
|
|
419
611
|
if (unit === "seconds" || unit === "milliseconds" || unit === "microseconds") {
|
|
420
612
|
let nextStyle;
|
|
421
613
|
if (unit === "seconds") nextStyle = internalSlots.milliseconds;
|
|
422
614
|
else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
|
|
423
615
|
else nextStyle = internalSlots.nanoseconds;
|
|
424
|
-
if (nextStyle === "
|
|
425
|
-
if (unit === "seconds") value = value.plus(new BigDecimal(
|
|
426
|
-
else if (unit === "milliseconds") value = value.plus(new BigDecimal(
|
|
427
|
-
else value = value.plus(new BigDecimal(
|
|
616
|
+
if (nextStyle === "fractional") {
|
|
617
|
+
if (unit === "seconds") value = value.plus(new BigDecimal(bigIntFrom(duration.milliseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e6))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e9)));
|
|
618
|
+
else if (unit === "milliseconds") value = value.plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e6)));
|
|
619
|
+
else value = value.plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e3)));
|
|
428
620
|
if (internalSlots.fractionalDigits === void 0) {
|
|
429
621
|
nfOpts.maximumFractionDigits = 9;
|
|
430
622
|
nfOpts.minimumFractionDigits = 0;
|
|
@@ -450,56 +642,73 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
450
642
|
nfOpts.unit = numberFormatUnit;
|
|
451
643
|
nfOpts.unitDisplay = style;
|
|
452
644
|
}
|
|
453
|
-
const nf =
|
|
645
|
+
const nf = providers.numberFormat(internalSlots.locale, nfOpts);
|
|
454
646
|
let list;
|
|
455
647
|
if (!separated) list = [];
|
|
456
648
|
else {
|
|
457
649
|
list = result[result.length - 1];
|
|
458
|
-
list.
|
|
650
|
+
setDataProperty(list, `${list.length}`, {
|
|
459
651
|
type: "literal",
|
|
460
|
-
value:
|
|
652
|
+
value: unit === "minutes" ? internalSlots.hourMinuteSeparator : internalSlots.minuteSecondSeparator,
|
|
653
|
+
unit: void 0
|
|
461
654
|
});
|
|
462
655
|
}
|
|
463
|
-
nf
|
|
464
|
-
|
|
656
|
+
let parts = apply$1(providers.numberFormatToParts, nf, [value.isZero() && value.isNegative() ? -0 : value]);
|
|
657
|
+
for (let index = 0; index < parts.length; index++) {
|
|
658
|
+
const { type, value } = parts[index];
|
|
659
|
+
setDataProperty(list, `${list.length}`, {
|
|
465
660
|
type,
|
|
466
661
|
value,
|
|
467
662
|
unit: numberFormatUnit
|
|
468
663
|
});
|
|
469
|
-
}
|
|
664
|
+
}
|
|
470
665
|
if (!separated) {
|
|
471
666
|
if (style === "2-digit" || style === "numeric") separated = true;
|
|
472
|
-
result.
|
|
667
|
+
setDataProperty(result, `${result.length}`, list);
|
|
473
668
|
}
|
|
474
669
|
} else separated = false;
|
|
475
670
|
}
|
|
476
|
-
const lfOpts =
|
|
671
|
+
const lfOpts = { __proto__: null };
|
|
477
672
|
lfOpts.type = "unit";
|
|
478
673
|
let listStyle = internalSlots.style;
|
|
479
674
|
if (listStyle === "digital") listStyle = "short";
|
|
480
675
|
lfOpts.style = listStyle;
|
|
481
|
-
const lf =
|
|
676
|
+
const lf = providers.listFormat(internalSlots.locale, lfOpts);
|
|
482
677
|
const strings = [];
|
|
483
|
-
for (
|
|
678
|
+
for (let index = 0; index < result.length; index++) {
|
|
679
|
+
const parts = result[index];
|
|
484
680
|
let string = "";
|
|
485
|
-
for (
|
|
486
|
-
strings.
|
|
681
|
+
for (let partIndex = 0; partIndex < parts.length; partIndex++) string += parts[partIndex].value;
|
|
682
|
+
setDataProperty(strings, `${strings.length}`, string);
|
|
487
683
|
}
|
|
488
|
-
|
|
684
|
+
setDataProperty(strings, Symbol.iterator, () => {
|
|
685
|
+
const iterator = apply$1(stringListIterator, strings, []);
|
|
686
|
+
return {
|
|
687
|
+
__proto__: null,
|
|
688
|
+
next() {
|
|
689
|
+
return apply$1(stringListIteratorNext, iterator, []);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
});
|
|
693
|
+
let formatted = apply$1(providers.listFormatToParts, lf, [strings]);
|
|
489
694
|
let resultIndex = 0;
|
|
490
695
|
let resultLength = result.length;
|
|
491
|
-
|
|
492
|
-
for (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
type
|
|
501
|
-
|
|
502
|
-
|
|
696
|
+
const flattened = [];
|
|
697
|
+
for (let index = 0; index < formatted.length; index++) {
|
|
698
|
+
const { type, value } = formatted[index];
|
|
699
|
+
if (type === "element") {
|
|
700
|
+
invariant(resultIndex < resultLength, "Index out of bounds");
|
|
701
|
+
let parts = result[resultIndex];
|
|
702
|
+
for (let index = 0; index < parts.length; index++) setDataProperty(flattened, `${flattened.length}`, parts[index]);
|
|
703
|
+
resultIndex++;
|
|
704
|
+
} else {
|
|
705
|
+
invariant(type === "literal", "Type must be literal");
|
|
706
|
+
setDataProperty(flattened, `${flattened.length}`, {
|
|
707
|
+
type: "literal",
|
|
708
|
+
value,
|
|
709
|
+
unit: void 0
|
|
710
|
+
});
|
|
711
|
+
}
|
|
503
712
|
}
|
|
504
713
|
return flattened;
|
|
505
714
|
}
|
|
@@ -518,7 +727,8 @@ const TABLE_1 = [
|
|
|
518
727
|
];
|
|
519
728
|
// packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
|
|
520
729
|
function DurationRecordSign(record) {
|
|
521
|
-
for (
|
|
730
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
731
|
+
const key = TABLE_1[index];
|
|
522
732
|
if (record[key] < 0) return -1;
|
|
523
733
|
if (record[key] > 0) return 1;
|
|
524
734
|
}
|
|
@@ -527,42 +737,49 @@ function DurationRecordSign(record) {
|
|
|
527
737
|
// packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
|
|
528
738
|
function IsValidDurationRecord(record) {
|
|
529
739
|
const sign = DurationRecordSign(record);
|
|
530
|
-
for (
|
|
531
|
-
const v = record[
|
|
532
|
-
if (!
|
|
740
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
741
|
+
const v = record[TABLE_1[index]];
|
|
742
|
+
if (!numberIsFinite(v)) return false;
|
|
533
743
|
if (v < 0 && sign > 0) return false;
|
|
534
744
|
if (v > 0 && sign < 0) return false;
|
|
535
745
|
}
|
|
536
|
-
if ([
|
|
746
|
+
if (arraySome([
|
|
537
747
|
"years",
|
|
538
748
|
"months",
|
|
539
749
|
"weeks"
|
|
540
|
-
]
|
|
541
|
-
const billion =
|
|
542
|
-
const normalizedNanoseconds =
|
|
543
|
-
const limit =
|
|
750
|
+
], (unit) => mathAbs(record[unit]) >= 2 ** 32)) return false;
|
|
751
|
+
const billion = bigIntFrom(1e9);
|
|
752
|
+
const normalizedNanoseconds = bigIntFrom(record.days) * bigIntFrom(86400) * billion + bigIntFrom(record.hours) * bigIntFrom(3600) * billion + bigIntFrom(record.minutes) * bigIntFrom(60) * billion + bigIntFrom(record.seconds) * billion + bigIntFrom(record.milliseconds) * bigIntFrom(1e6) + bigIntFrom(record.microseconds) * bigIntFrom(1e3) + bigIntFrom(record.nanoseconds);
|
|
753
|
+
const limit = bigIntFrom(2 ** 53) * billion;
|
|
544
754
|
return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
|
|
545
755
|
}
|
|
546
756
|
// packages/ecma262-abstract/ToNumber.js
|
|
547
|
-
/**
|
|
548
|
-
* ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
|
|
549
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
550
|
-
* https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
|
|
551
|
-
*/
|
|
552
757
|
function ToNumber(arg) {
|
|
553
|
-
return
|
|
758
|
+
return +arg;
|
|
554
759
|
}
|
|
555
760
|
// packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
|
|
556
761
|
function ToIntegerIfIntegral(arg) {
|
|
557
762
|
const number = ToNumber(arg);
|
|
558
|
-
|
|
559
|
-
return number
|
|
763
|
+
if (!numberIsInteger(number)) throw new RangeErrorConstructor("Duration field is not an integer");
|
|
764
|
+
return number === 0 ? 0 : number;
|
|
560
765
|
}
|
|
561
766
|
// packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
|
|
767
|
+
const durationPropertyNames = [
|
|
768
|
+
"days",
|
|
769
|
+
"hours",
|
|
770
|
+
"microseconds",
|
|
771
|
+
"milliseconds",
|
|
772
|
+
"minutes",
|
|
773
|
+
"months",
|
|
774
|
+
"nanoseconds",
|
|
775
|
+
"seconds",
|
|
776
|
+
"weeks",
|
|
777
|
+
"years"
|
|
778
|
+
];
|
|
562
779
|
function ToDurationRecord(input) {
|
|
563
|
-
if ((
|
|
564
|
-
if (typeof input === "string") throw new
|
|
565
|
-
throw new
|
|
780
|
+
if (!IsObject(input)) {
|
|
781
|
+
if (typeof input === "string") throw new RangeErrorConstructor("Invalid duration format");
|
|
782
|
+
throw new TypeErrorConstructor$1("Invalid duration");
|
|
566
783
|
}
|
|
567
784
|
const result = {
|
|
568
785
|
years: 0,
|
|
@@ -577,26 +794,16 @@ function ToDurationRecord(input) {
|
|
|
577
794
|
nanoseconds: 0
|
|
578
795
|
};
|
|
579
796
|
let anyDefined = false;
|
|
580
|
-
for (
|
|
581
|
-
|
|
582
|
-
"hours",
|
|
583
|
-
"microseconds",
|
|
584
|
-
"milliseconds",
|
|
585
|
-
"minutes",
|
|
586
|
-
"months",
|
|
587
|
-
"nanoseconds",
|
|
588
|
-
"seconds",
|
|
589
|
-
"weeks",
|
|
590
|
-
"years"
|
|
591
|
-
]) {
|
|
797
|
+
for (let index = 0; index < durationPropertyNames.length; index++) {
|
|
798
|
+
const field = durationPropertyNames[index];
|
|
592
799
|
const value = input[field];
|
|
593
800
|
if (value !== void 0) {
|
|
594
801
|
anyDefined = true;
|
|
595
802
|
result[field] = ToIntegerIfIntegral(value);
|
|
596
803
|
}
|
|
597
804
|
}
|
|
598
|
-
if (!anyDefined) throw new
|
|
599
|
-
if (!IsValidDurationRecord(result)) throw new
|
|
805
|
+
if (!anyDefined) throw new TypeErrorConstructor$1("Invalid duration format");
|
|
806
|
+
if (!IsValidDurationRecord(result)) throw new RangeErrorConstructor("Invalid duration format");
|
|
600
807
|
return result;
|
|
601
808
|
}
|
|
602
809
|
// packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
|
|
@@ -616,11 +823,11 @@ const apply = Reflect.apply;
|
|
|
616
823
|
const readers = [];
|
|
617
824
|
function registerTemporalDurationNamespace(namespace) {
|
|
618
825
|
const constructor = namespace?.Duration;
|
|
619
|
-
if (!constructor || readers
|
|
826
|
+
if (!constructor || arraySome(readers, (reader) => reader.constructor === constructor)) return;
|
|
620
827
|
const from = constructor.from, prototype = constructor.prototype;
|
|
621
828
|
if (typeof from !== "function" || prototype === null || typeof prototype !== "object" && typeof prototype !== "function") return;
|
|
622
829
|
const getters = fields.map((field) => Object.getOwnPropertyDescriptor(prototype, field)?.get);
|
|
623
|
-
if (getters
|
|
830
|
+
if (arraySome(getters, (getter) => typeof getter !== "function")) return;
|
|
624
831
|
readers.push({
|
|
625
832
|
constructor,
|
|
626
833
|
from,
|
|
@@ -634,14 +841,15 @@ function ToTemporalDurationRecord(input) {
|
|
|
634
841
|
const reader = readers[readers.length - 1];
|
|
635
842
|
input = apply(reader.from, reader.constructor, [input]);
|
|
636
843
|
}
|
|
637
|
-
if (input !== null && (typeof input === "object" || typeof input === "function")) for (
|
|
844
|
+
if (input !== null && (typeof input === "object" || typeof input === "function")) for (let index = 0; index < readers.length; index++) {
|
|
845
|
+
const reader = readers[index];
|
|
638
846
|
let years;
|
|
639
847
|
try {
|
|
640
848
|
years = apply(reader.getters[0], input, []);
|
|
641
849
|
} catch {
|
|
642
850
|
continue;
|
|
643
851
|
}
|
|
644
|
-
const record =
|
|
852
|
+
const record = { __proto__: null };
|
|
645
853
|
record.years = years;
|
|
646
854
|
for (let index = 1; index < fields.length; index++) record[fields[index]] = apply(reader.getters[index], input, []);
|
|
647
855
|
return record;
|
|
@@ -695,6 +903,7 @@ const TIME_SEPARATORS = {
|
|
|
695
903
|
"az-Cyrl": { "nu": ["latn"] },
|
|
696
904
|
"az-Latn": { "nu": ["latn"] },
|
|
697
905
|
"ba": { "nu": ["latn"] },
|
|
906
|
+
"bal": { "nu": ["latn"] },
|
|
698
907
|
"bal-Latn": { "nu": ["latn"] },
|
|
699
908
|
"bas": { "nu": ["latn"] },
|
|
700
909
|
"be": { "nu": ["latn"] },
|
|
@@ -718,6 +927,7 @@ const TIME_SEPARATORS = {
|
|
|
718
927
|
"bua": { "nu": ["latn"] },
|
|
719
928
|
"ca": { "nu": ["latn"] },
|
|
720
929
|
"ca-AD": { "nu": ["latn"] },
|
|
930
|
+
"ca-ES": { "nu": ["latn"] },
|
|
721
931
|
"ca-ES-valencia": { "nu": ["latn"] },
|
|
722
932
|
"ca-FR": { "nu": ["latn"] },
|
|
723
933
|
"ca-IT": { "nu": ["latn"] },
|
|
@@ -939,6 +1149,13 @@ const TIME_SEPARATORS = {
|
|
|
939
1149
|
"ff-Adlm-NG": { "nu": ["adlm"] },
|
|
940
1150
|
"ff-Adlm-SL": { "nu": ["adlm"] },
|
|
941
1151
|
"ff-Adlm-SN": { "nu": ["adlm"] },
|
|
1152
|
+
"ff-BF": { "nu": ["latn"] },
|
|
1153
|
+
"ff-CM": { "nu": ["latn"] },
|
|
1154
|
+
"ff-GH": { "nu": ["latn"] },
|
|
1155
|
+
"ff-GM": { "nu": ["latn"] },
|
|
1156
|
+
"ff-GN": { "nu": ["latn"] },
|
|
1157
|
+
"ff-GW": { "nu": ["latn"] },
|
|
1158
|
+
"ff-LR": { "nu": ["latn"] },
|
|
942
1159
|
"ff-Latn": { "nu": ["latn"] },
|
|
943
1160
|
"ff-Latn-BF": { "nu": ["latn"] },
|
|
944
1161
|
"ff-Latn-CM": { "nu": ["latn"] },
|
|
@@ -951,6 +1168,11 @@ const TIME_SEPARATORS = {
|
|
|
951
1168
|
"ff-Latn-NE": { "nu": ["latn"] },
|
|
952
1169
|
"ff-Latn-NG": { "nu": ["latn"] },
|
|
953
1170
|
"ff-Latn-SL": { "nu": ["latn"] },
|
|
1171
|
+
"ff-MR": { "nu": ["latn"] },
|
|
1172
|
+
"ff-NE": { "nu": ["latn"] },
|
|
1173
|
+
"ff-NG": { "nu": ["latn"] },
|
|
1174
|
+
"ff-SL": { "nu": ["latn"] },
|
|
1175
|
+
"ff-SN": { "nu": ["adlm"] },
|
|
954
1176
|
"fi": {
|
|
955
1177
|
"nu": ["latn"],
|
|
956
1178
|
"separator": { "latn": "." }
|
|
@@ -1079,9 +1301,11 @@ const TIME_SEPARATORS = {
|
|
|
1079
1301
|
"ksf": { "nu": ["latn"] },
|
|
1080
1302
|
"ksh": { "nu": ["latn"] },
|
|
1081
1303
|
"ku": { "nu": ["latn"] },
|
|
1304
|
+
"ku-IQ": { "nu": ["latn"] },
|
|
1082
1305
|
"ku-Latn": { "nu": ["latn"] },
|
|
1083
1306
|
"ku-Latn-IQ": { "nu": ["latn"] },
|
|
1084
1307
|
"ku-Latn-SY": { "nu": ["latn"] },
|
|
1308
|
+
"ku-SY": { "nu": ["latn"] },
|
|
1085
1309
|
"ku-TR": { "nu": ["latn"] },
|
|
1086
1310
|
"kw": { "nu": ["latn"] },
|
|
1087
1311
|
"kxv": { "nu": ["latn"] },
|
|
@@ -1242,6 +1466,7 @@ const TIME_SEPARATORS = {
|
|
|
1242
1466
|
"sq-MK": { "nu": ["latn"] },
|
|
1243
1467
|
"sq-XK": { "nu": ["latn"] },
|
|
1244
1468
|
"sr": { "nu": ["latn"] },
|
|
1469
|
+
"sr-BA": { "nu": ["latn"] },
|
|
1245
1470
|
"sr-Cyrl": { "nu": ["latn"] },
|
|
1246
1471
|
"sr-Cyrl-BA": { "nu": ["latn"] },
|
|
1247
1472
|
"sr-Cyrl-ME": { "nu": ["latn"] },
|
|
@@ -1250,6 +1475,8 @@ const TIME_SEPARATORS = {
|
|
|
1250
1475
|
"sr-Latn-BA": { "nu": ["latn"] },
|
|
1251
1476
|
"sr-Latn-ME": { "nu": ["latn"] },
|
|
1252
1477
|
"sr-Latn-XK": { "nu": ["latn"] },
|
|
1478
|
+
"sr-ME": { "nu": ["latn"] },
|
|
1479
|
+
"sr-XK": { "nu": ["latn"] },
|
|
1253
1480
|
"st": { "nu": ["latn"] },
|
|
1254
1481
|
"st-LS": { "nu": ["latn"] },
|
|
1255
1482
|
"su": {
|
|
@@ -1260,6 +1487,7 @@ const TIME_SEPARATORS = {
|
|
|
1260
1487
|
"nu": ["latn"],
|
|
1261
1488
|
"separator": { "latn": "." }
|
|
1262
1489
|
},
|
|
1490
|
+
"suz": { "nu": ["latn"] },
|
|
1263
1491
|
"suz-Sunu": { "nu": ["latn"] },
|
|
1264
1492
|
"sv": { "nu": ["latn"] },
|
|
1265
1493
|
"sv-AX": { "nu": ["latn"] },
|
|
@@ -1334,13 +1562,16 @@ const TIME_SEPARATORS = {
|
|
|
1334
1562
|
"yrl-CO": { "nu": ["latn"] },
|
|
1335
1563
|
"yrl-VE": { "nu": ["latn"] },
|
|
1336
1564
|
"yue": { "nu": ["latn"] },
|
|
1565
|
+
"yue-CN": { "nu": ["latn"] },
|
|
1337
1566
|
"yue-Hans": { "nu": ["latn"] },
|
|
1338
1567
|
"yue-Hant": { "nu": ["latn"] },
|
|
1339
1568
|
"yue-Hant-CN": { "nu": ["latn"] },
|
|
1340
1569
|
"yue-Hant-MO": { "nu": ["latn"] },
|
|
1570
|
+
"yue-MO": { "nu": ["latn"] },
|
|
1341
1571
|
"za": { "nu": ["latn"] },
|
|
1342
1572
|
"zgh": { "nu": ["latn"] },
|
|
1343
1573
|
"zh": { "nu": ["latn"] },
|
|
1574
|
+
"zh-HK": { "nu": ["latn"] },
|
|
1344
1575
|
"zh-Hans": { "nu": ["latn"] },
|
|
1345
1576
|
"zh-Hans-HK": { "nu": ["latn"] },
|
|
1346
1577
|
"zh-Hans-MO": { "nu": ["latn"] },
|
|
@@ -1350,25 +1581,76 @@ const TIME_SEPARATORS = {
|
|
|
1350
1581
|
"zh-Hant-HK": { "nu": ["latn"] },
|
|
1351
1582
|
"zh-Hant-MO": { "nu": ["latn"] },
|
|
1352
1583
|
"zh-Hant-MY": { "nu": ["latn"] },
|
|
1584
|
+
"zh-MO": { "nu": ["latn"] },
|
|
1585
|
+
"zh-MY": { "nu": ["latn"] },
|
|
1586
|
+
"zh-SG": { "nu": ["latn"] },
|
|
1353
1587
|
"zu": { "nu": ["latn"] }
|
|
1354
1588
|
}
|
|
1355
1589
|
};
|
|
1356
1590
|
// packages/intl-durationformat/core.ts
|
|
1591
|
+
let defaultLocale = "en";
|
|
1592
|
+
function getDefaultLocale() {
|
|
1593
|
+
return defaultLocale;
|
|
1594
|
+
}
|
|
1357
1595
|
const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
|
|
1596
|
+
const getNumberingSystems = numberingSystemsByConstructor.get.bind(numberingSystemsByConstructor);
|
|
1597
|
+
const setNumberingSystems = numberingSystemsByConstructor.set.bind(numberingSystemsByConstructor);
|
|
1598
|
+
const createObject = Object.create;
|
|
1599
|
+
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
|
1600
|
+
const providerApply = Reflect.apply;
|
|
1601
|
+
const providerDescriptor = Object.getOwnPropertyDescriptor;
|
|
1602
|
+
const providerPrototype = Object.getPrototypeOf;
|
|
1603
|
+
const resolvedMethods = /* @__PURE__ */ new WeakMap();
|
|
1604
|
+
const getResolvedMethod = resolvedMethods.get.bind(resolvedMethods);
|
|
1605
|
+
const setResolvedMethod = resolvedMethods.set.bind(resolvedMethods);
|
|
1606
|
+
function numberFormatResolvedOptions(Constructor) {
|
|
1607
|
+
let prototype = Constructor.prototype;
|
|
1608
|
+
while (prototype !== null) {
|
|
1609
|
+
const cached = getResolvedMethod(prototype);
|
|
1610
|
+
if (cached) return cached;
|
|
1611
|
+
const descriptor = providerDescriptor(prototype, "resolvedOptions");
|
|
1612
|
+
const value = descriptor && providerDescriptor(descriptor, "value");
|
|
1613
|
+
if (typeof value?.value === "function") {
|
|
1614
|
+
const method = value.value;
|
|
1615
|
+
setResolvedMethod(prototype, method);
|
|
1616
|
+
return method;
|
|
1617
|
+
}
|
|
1618
|
+
prototype = providerPrototype(prototype);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
const initialNumberFormat = getNumberFormatIntrinsic();
|
|
1622
|
+
if (typeof initialNumberFormat === "function") numberFormatResolvedOptions(initialNumberFormat);
|
|
1623
|
+
const NumberingSet = Set;
|
|
1624
|
+
const numberingAdd = Set.prototype.add;
|
|
1625
|
+
const numberingValues = Set.prototype.values;
|
|
1626
|
+
const numberingNext = providerPrototype(new NumberingSet().values()).next;
|
|
1627
|
+
function numberingUnion(first, second) {
|
|
1628
|
+
const unique = new NumberingSet();
|
|
1629
|
+
for (let index = 0; index < first.length; index++) providerApply(numberingAdd, unique, [first[index]]);
|
|
1630
|
+
for (let index = 0; index < second.length; index++) providerApply(numberingAdd, unique, [second[index]]);
|
|
1631
|
+
const iterator = providerApply(numberingValues, unique, []);
|
|
1632
|
+
const result = [];
|
|
1633
|
+
for (;;) {
|
|
1634
|
+
const next = providerApply(numberingNext, iterator, []);
|
|
1635
|
+
if (next.done) return result;
|
|
1636
|
+
setDataProperty(result, `${result.length}`, next.value);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1358
1639
|
function supportedNumberingSystems() {
|
|
1359
|
-
const NumberFormat =
|
|
1360
|
-
let systems =
|
|
1640
|
+
const NumberFormat = getNumberFormatIntrinsic();
|
|
1641
|
+
let systems = getNumberingSystems(NumberFormat);
|
|
1361
1642
|
if (!systems) {
|
|
1362
|
-
systems =
|
|
1363
|
-
|
|
1643
|
+
systems = [];
|
|
1644
|
+
const resolvedOptions = numberFormatResolvedOptions(NumberFormat);
|
|
1645
|
+
for (let index = 0; index < numberingSystemNames.length; index++) {
|
|
1646
|
+
const numberingSystem = numberingSystemNames[index];
|
|
1647
|
+
const options = createObject(null);
|
|
1364
1648
|
options.numberingSystem = numberingSystem;
|
|
1365
1649
|
try {
|
|
1366
|
-
|
|
1367
|
-
} catch {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
});
|
|
1371
|
-
if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
|
|
1650
|
+
if (resolvedOptions && providerApply(resolvedOptions, new NumberFormat("en", options), []).numberingSystem === numberingSystem) setDataProperty(systems, `${systems.length}`, numberingSystem);
|
|
1651
|
+
} catch {}
|
|
1652
|
+
}
|
|
1653
|
+
if (systems.length) setNumberingSystems(NumberFormat, systems);
|
|
1372
1654
|
}
|
|
1373
1655
|
return systems;
|
|
1374
1656
|
}
|
|
@@ -1523,27 +1805,33 @@ const TABLE_3 = [
|
|
|
1523
1805
|
* DurationFormat provides locale-sensitive duration formatting
|
|
1524
1806
|
* Implements the Intl.DurationFormat API from the TC39 proposal
|
|
1525
1807
|
*/
|
|
1526
|
-
var DurationFormat = class DurationFormat {
|
|
1808
|
+
var DurationFormat = class DurationFormat extends null {
|
|
1527
1809
|
static __addTemporalNamespace(namespace) {
|
|
1528
1810
|
registerTemporalDurationNamespace(namespace);
|
|
1529
1811
|
}
|
|
1530
1812
|
constructor(locales, options) {
|
|
1531
|
-
|
|
1813
|
+
const receiver = createFromConstructor(new.target, DurationFormat.prototype);
|
|
1532
1814
|
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
1533
|
-
const opt =
|
|
1534
|
-
const opts =
|
|
1815
|
+
const opt = createObject(null);
|
|
1816
|
+
const opts = GetOptionsObject(options);
|
|
1535
1817
|
const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
1536
1818
|
const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
|
|
1537
|
-
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw
|
|
1819
|
+
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeErrorConstructor(`Invalid numberingSystems: ${numberingSystem}`);
|
|
1538
1820
|
opt.nu = numberingSystem;
|
|
1539
1821
|
opt.localeMatcher = matcher;
|
|
1540
1822
|
const { localeData, availableLocales } = DurationFormat;
|
|
1541
|
-
const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData,
|
|
1823
|
+
const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData, getDefaultLocale, "hostDefaultWithLocaleData");
|
|
1542
1824
|
const locale = r.locale;
|
|
1543
|
-
const internalSlots = getInternalSlots(
|
|
1825
|
+
const internalSlots = getInternalSlots(receiver);
|
|
1544
1826
|
internalSlots.initializedDurationFormat = true;
|
|
1545
1827
|
internalSlots.locale = locale;
|
|
1546
1828
|
internalSlots.numberingSystem = r.nu;
|
|
1829
|
+
internalSlots.dataLocale = r.dataLocale;
|
|
1830
|
+
const digitalFormat = r.localeData?.digitalFormat;
|
|
1831
|
+
invariant(!!digitalFormat, `Invalid locale ${r.dataLocale}`);
|
|
1832
|
+
const separator = hasOwn(digitalFormat, r.nu) ? digitalFormat[r.nu] : digitalFormat.default;
|
|
1833
|
+
internalSlots.hourMinuteSeparator = separator;
|
|
1834
|
+
internalSlots.minuteSecondSeparator = separator;
|
|
1547
1835
|
const style = GetOption(opts, "style", "string", [
|
|
1548
1836
|
"long",
|
|
1549
1837
|
"short",
|
|
@@ -1551,61 +1839,61 @@ var DurationFormat = class DurationFormat {
|
|
|
1551
1839
|
"digital"
|
|
1552
1840
|
], "short");
|
|
1553
1841
|
internalSlots.style = style;
|
|
1554
|
-
internalSlots.dataLocale = r.dataLocale;
|
|
1555
1842
|
let prevStyle = "";
|
|
1556
|
-
|
|
1557
|
-
|
|
1843
|
+
const unitStyles = internalSlots;
|
|
1844
|
+
for (let index = 0; index < TABLE_3.length; index++) {
|
|
1845
|
+
const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = TABLE_3[index];
|
|
1558
1846
|
const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
|
|
1559
|
-
|
|
1847
|
+
unitStyles[styleSlot] = unitOptions.style;
|
|
1560
1848
|
internalSlots[displaySlot] = unitOptions.display;
|
|
1561
1849
|
if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") prevStyle = unitOptions.style;
|
|
1562
|
-
}
|
|
1850
|
+
}
|
|
1563
1851
|
internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, void 0);
|
|
1852
|
+
initializeDurationFormatProviders(receiver);
|
|
1853
|
+
return receiver;
|
|
1564
1854
|
}
|
|
1565
1855
|
resolvedOptions() {
|
|
1566
|
-
|
|
1567
|
-
const internalSlots = getInternalSlots(this);
|
|
1856
|
+
const internalSlots = requireInternalSlots(this);
|
|
1568
1857
|
const ro = {};
|
|
1569
|
-
for (
|
|
1858
|
+
for (let index = 0; index < RESOLVED_OPTIONS_KEYS.length; index++) {
|
|
1859
|
+
const key = RESOLVED_OPTIONS_KEYS[index];
|
|
1570
1860
|
let v = internalSlots[key];
|
|
1571
1861
|
if (key === "fractionalDigits") {
|
|
1572
1862
|
if (v === void 0) continue;
|
|
1573
|
-
v =
|
|
1863
|
+
v = numberFrom(v);
|
|
1574
1864
|
} else if (v === "fractional") v = "numeric";
|
|
1575
1865
|
else invariant(v !== void 0, `Missing internal slot ${key}`);
|
|
1576
|
-
ro
|
|
1866
|
+
setDataProperty(ro, key, v);
|
|
1577
1867
|
}
|
|
1578
1868
|
return ro;
|
|
1579
1869
|
}
|
|
1580
1870
|
formatToParts(duration) {
|
|
1581
|
-
|
|
1871
|
+
requireInternalSlots(this);
|
|
1582
1872
|
const record = ToTemporalDurationRecord(duration);
|
|
1583
1873
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1584
1874
|
const result = [];
|
|
1585
|
-
for (
|
|
1875
|
+
for (let index = 0; index < parts.length; index++) {
|
|
1876
|
+
const { type, unit, value } = parts[index];
|
|
1586
1877
|
const obj = {
|
|
1587
1878
|
type,
|
|
1588
1879
|
value
|
|
1589
1880
|
};
|
|
1590
|
-
if (unit) obj
|
|
1591
|
-
result.
|
|
1881
|
+
if (unit) setDataProperty(obj, "unit", unit);
|
|
1882
|
+
setDataProperty(result, `${result.length}`, obj);
|
|
1592
1883
|
}
|
|
1593
1884
|
return result;
|
|
1594
1885
|
}
|
|
1595
1886
|
format(duration) {
|
|
1596
|
-
|
|
1887
|
+
requireInternalSlots(this);
|
|
1597
1888
|
const record = ToTemporalDurationRecord(duration);
|
|
1598
1889
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1599
1890
|
let result = "";
|
|
1600
|
-
for (
|
|
1891
|
+
for (let index = 0; index < parts.length; index++) result += parts[index].value;
|
|
1601
1892
|
return result;
|
|
1602
1893
|
}
|
|
1603
1894
|
static supportedLocalesOf(locales, options) {
|
|
1604
1895
|
return SupportedLocales(DurationFormat.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
1605
1896
|
}
|
|
1606
|
-
static {
|
|
1607
|
-
this.__defaultLocale = "en";
|
|
1608
|
-
}
|
|
1609
1897
|
static {
|
|
1610
1898
|
this.availableLocales = /* @__PURE__ */ new Set();
|
|
1611
1899
|
}
|
|
@@ -1615,7 +1903,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1615
1903
|
all[locale] = {
|
|
1616
1904
|
get nu() {
|
|
1617
1905
|
const defaults = TIME_SEPARATORS.localeData[locale].nu;
|
|
1618
|
-
return
|
|
1906
|
+
return numberingUnion(defaults, supportedNumberingSystems());
|
|
1619
1907
|
},
|
|
1620
1908
|
digitalFormat: {
|
|
1621
1909
|
default: TIME_SEPARATORS.default,
|
|
@@ -1626,14 +1914,20 @@ var DurationFormat = class DurationFormat {
|
|
|
1626
1914
|
}, {});
|
|
1627
1915
|
}
|
|
1628
1916
|
static {
|
|
1629
|
-
this.getDefaultLocale =
|
|
1630
|
-
return DurationFormat.__defaultLocale;
|
|
1631
|
-
};
|
|
1917
|
+
this.getDefaultLocale = getDefaultLocale;
|
|
1632
1918
|
}
|
|
1633
1919
|
static {
|
|
1634
1920
|
this.polyfilled = true;
|
|
1635
1921
|
}
|
|
1636
1922
|
};
|
|
1923
|
+
Object.defineProperty(DurationFormat, "__defaultLocale", {
|
|
1924
|
+
configurable: true,
|
|
1925
|
+
enumerable: true,
|
|
1926
|
+
get: getDefaultLocale,
|
|
1927
|
+
set(locale) {
|
|
1928
|
+
defaultLocale = locale;
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1637
1931
|
Object.defineProperty(DurationFormat, "length", {
|
|
1638
1932
|
value: 0,
|
|
1639
1933
|
configurable: true
|
|
@@ -1642,6 +1936,7 @@ Object.defineProperty(DurationFormat.supportedLocalesOf, "length", {
|
|
|
1642
1936
|
value: 1,
|
|
1643
1937
|
configurable: true
|
|
1644
1938
|
});
|
|
1939
|
+
Object.setPrototypeOf(DurationFormat.prototype, Object.prototype);
|
|
1645
1940
|
Object.defineProperty(DurationFormat.prototype, Symbol.toStringTag, {
|
|
1646
1941
|
value: "Intl.DurationFormat",
|
|
1647
1942
|
configurable: true
|