@formatjs/intl-relativetimeformat 11.4.12 → 12.0.0

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.
Files changed (38) hide show
  1. package/abstract/FormatRelativeTime.js +3 -6
  2. package/abstract/FormatRelativeTimeToParts.js +3 -6
  3. package/abstract/InitializeRelativeTimeFormat.js +13 -16
  4. package/abstract/MakePartsList.js +4 -7
  5. package/abstract/PartitionRelativeTimePattern.js +11 -14
  6. package/abstract/SingularRelativeTimeUnit.js +3 -6
  7. package/get_internal_slots.js +1 -4
  8. package/index.js +15 -18
  9. package/package.json +13 -7
  10. package/polyfill-force.js +2 -5
  11. package/polyfill.iife.js +36 -37
  12. package/polyfill.js +4 -7
  13. package/should-polyfill.js +5 -8
  14. package/supported-locales.generated.js +1 -4
  15. package/lib/abstract/FormatRelativeTime.d.ts +0 -4
  16. package/lib/abstract/FormatRelativeTime.js +0 -10
  17. package/lib/abstract/FormatRelativeTimeToParts.d.ts +0 -4
  18. package/lib/abstract/FormatRelativeTimeToParts.js +0 -4
  19. package/lib/abstract/InitializeRelativeTimeFormat.d.ts +0 -8
  20. package/lib/abstract/InitializeRelativeTimeFormat.js +0 -34
  21. package/lib/abstract/MakePartsList.d.ts +0 -1
  22. package/lib/abstract/MakePartsList.js +0 -26
  23. package/lib/abstract/PartitionRelativeTimePattern.d.ts +0 -4
  24. package/lib/abstract/PartitionRelativeTimePattern.js +0 -53
  25. package/lib/abstract/SingularRelativeTimeUnit.d.ts +0 -6
  26. package/lib/abstract/SingularRelativeTimeUnit.js +0 -35
  27. package/lib/get_internal_slots.d.ts +0 -2
  28. package/lib/get_internal_slots.js +0 -11
  29. package/lib/index.d.ts +0 -15
  30. package/lib/index.js +0 -120
  31. package/lib/polyfill-force.d.ts +0 -1
  32. package/lib/polyfill-force.js +0 -7
  33. package/lib/polyfill.d.ts +0 -1
  34. package/lib/polyfill.js +0 -10
  35. package/lib/should-polyfill.d.ts +0 -1
  36. package/lib/should-polyfill.js +0 -29
  37. package/lib/supported-locales.generated.d.ts +0 -1
  38. package/lib/supported-locales.generated.js +0 -1
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatRelativeTime = FormatRelativeTime;
4
- var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
5
- function FormatRelativeTime(rtf, value, unit, implDetails) {
6
- var parts = (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(rtf, value, unit, implDetails);
1
+ import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern.js';
2
+ export function FormatRelativeTime(rtf, value, unit, implDetails) {
3
+ var parts = PartitionRelativeTimePattern(rtf, value, unit, implDetails);
7
4
  var result = '';
8
5
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
6
  var part = parts_1[_i];
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatRelativeTimeToParts = FormatRelativeTimeToParts;
4
- var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
5
- function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
6
- return (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(rtf, value, unit, implDetails);
1
+ import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern.js';
2
+ export function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
3
+ return PartitionRelativeTimePattern(rtf, value, unit, implDetails);
7
4
  }
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitializeRelativeTimeFormat = InitializeRelativeTimeFormat;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
1
+ import { CanonicalizeLocaleList, CoerceOptionsToObject, createMemoizedNumberFormat, createMemoizedPluralRules, GetOption, invariant, } from '@formatjs/ecma402-abstract';
2
+ import { ResolveLocale } from '@formatjs/intl-localematcher';
6
3
  var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
7
- function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
4
+ export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
8
5
  var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
9
6
  var internalSlots = getInternalSlots(rtf);
10
7
  internalSlots.initializedRelativeTimeFormat = true;
11
- var requestedLocales = (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales);
8
+ var requestedLocales = CanonicalizeLocaleList(locales);
12
9
  var opt = Object.create(null);
13
- var opts = (0, ecma402_abstract_1.CoerceOptionsToObject)(options);
14
- var matcher = (0, ecma402_abstract_1.GetOption)(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
10
+ var opts = CoerceOptionsToObject(options);
11
+ var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
15
12
  opt.localeMatcher = matcher;
16
- var numberingSystem = (0, ecma402_abstract_1.GetOption)(opts,
13
+ var numberingSystem = GetOption(opts,
17
14
  // @ts-expect-error TS option is wack
18
15
  'numberingSystem', 'string', undefined, undefined);
19
16
  if (numberingSystem !== undefined) {
@@ -22,16 +19,16 @@ function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
22
19
  }
23
20
  }
24
21
  opt.nu = numberingSystem;
25
- var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
22
+ var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
26
23
  var locale = r.locale, nu = r.nu;
27
24
  internalSlots.locale = locale;
28
- internalSlots.style = (0, ecma402_abstract_1.GetOption)(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
29
- internalSlots.numeric = (0, ecma402_abstract_1.GetOption)(opts, 'numeric', 'string', ['always', 'auto'], 'always');
25
+ internalSlots.style = GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
26
+ internalSlots.numeric = GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
30
27
  var fields = localeData[r.dataLocale];
31
- (0, ecma402_abstract_1.invariant)(!!fields, "Missing locale data for ".concat(r.dataLocale));
28
+ invariant(!!fields, "Missing locale data for ".concat(r.dataLocale));
32
29
  internalSlots.fields = fields;
33
- internalSlots.numberFormat = (0, ecma402_abstract_1.createMemoizedNumberFormat)(locales);
34
- internalSlots.pluralRules = (0, ecma402_abstract_1.createMemoizedPluralRules)(locales);
30
+ internalSlots.numberFormat = createMemoizedNumberFormat(locales);
31
+ internalSlots.pluralRules = createMemoizedPluralRules(locales);
35
32
  internalSlots.numberingSystem = nu;
36
33
  return rtf;
37
34
  }
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MakePartsList = MakePartsList;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- function MakePartsList(pattern, unit, parts) {
6
- var patternParts = (0, ecma402_abstract_1.PartitionPattern)(pattern);
1
+ import { invariant, PartitionPattern } from '@formatjs/ecma402-abstract';
2
+ export function MakePartsList(pattern, unit, parts) {
3
+ var patternParts = PartitionPattern(pattern);
7
4
  var result = [];
8
5
  for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
9
6
  var patternPart = patternParts_1[_i];
@@ -14,7 +11,7 @@ function MakePartsList(pattern, unit, parts) {
14
11
  });
15
12
  }
16
13
  else {
17
- (0, ecma402_abstract_1.invariant)(patternPart.type === '0', "Malformed pattern ".concat(pattern));
14
+ invariant(patternPart.type === '0', "Malformed pattern ".concat(pattern));
18
15
  for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
19
16
  var part = parts_1[_a];
20
17
  result.push({
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionRelativeTimePattern = PartitionRelativeTimePattern;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var SingularRelativeTimeUnit_1 = require("./SingularRelativeTimeUnit");
6
- var MakePartsList_1 = require("./MakePartsList");
7
- function PartitionRelativeTimePattern(rtf, value, unit, _a) {
1
+ import { invariant, SameValue, ToString, Type, } from '@formatjs/ecma402-abstract';
2
+ import { SingularRelativeTimeUnit } from './SingularRelativeTimeUnit.js';
3
+ import { MakePartsList } from './MakePartsList.js';
4
+ export function PartitionRelativeTimePattern(rtf, value, unit, _a) {
8
5
  var getInternalSlots = _a.getInternalSlots;
9
- (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(value) === 'Number', "value must be number, instead got ".concat(typeof value), TypeError);
10
- (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(unit) === 'String', "unit must be number, instead got ".concat(typeof value), TypeError);
6
+ invariant(Type(value) === 'Number', "value must be number, instead got ".concat(typeof value), TypeError);
7
+ invariant(Type(unit) === 'String', "unit must be number, instead got ".concat(typeof value), TypeError);
11
8
  if (isNaN(value) || !isFinite(value)) {
12
9
  throw new RangeError("Invalid value ".concat(value));
13
10
  }
14
- var resolvedUnit = (0, SingularRelativeTimeUnit_1.SingularRelativeTimeUnit)(unit);
11
+ var resolvedUnit = SingularRelativeTimeUnit(unit);
15
12
  var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
16
13
  var entry = resolvedUnit;
17
14
  if (style === 'short') {
@@ -25,17 +22,17 @@ function PartitionRelativeTimePattern(rtf, value, unit, _a) {
25
22
  }
26
23
  var patterns = fields[entry];
27
24
  if (numeric === 'auto') {
28
- if ((0, ecma402_abstract_1.ToString)(value) in patterns) {
25
+ if (ToString(value) in patterns) {
29
26
  return [
30
27
  {
31
28
  type: 'literal',
32
- value: patterns[(0, ecma402_abstract_1.ToString)(value)],
29
+ value: patterns[ToString(value)],
33
30
  },
34
31
  ];
35
32
  }
36
33
  }
37
34
  var tl = 'future';
38
- if ((0, ecma402_abstract_1.SameValue)(value, -0) || value < 0) {
35
+ if (SameValue(value, -0) || value < 0) {
39
36
  tl = 'past';
40
37
  }
41
38
  var po = patterns[tl];
@@ -52,5 +49,5 @@ function PartitionRelativeTimePattern(rtf, value, unit, _a) {
52
49
  ];
53
50
  var pr = pluralRules.select(value);
54
51
  var pattern = po[pr];
55
- return (0, MakePartsList_1.MakePartsList)(pattern, resolvedUnit, fv);
52
+ return MakePartsList(pattern, resolvedUnit, fv);
56
53
  }
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SingularRelativeTimeUnit = SingularRelativeTimeUnit;
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
1
+ import { invariant, Type, } from '@formatjs/ecma402-abstract';
5
2
  /**
6
3
  * https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
7
4
  * @param unit
8
5
  */
9
- function SingularRelativeTimeUnit(unit) {
10
- (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(unit) === 'String', 'unit must be a string');
6
+ export function SingularRelativeTimeUnit(unit) {
7
+ invariant(Type(unit) === 'String', 'unit must be a string');
11
8
  if (unit === 'seconds')
12
9
  return 'second';
13
10
  if (unit === 'minutes')
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  // Type-only circular import
3
2
  // eslint-disable-next-line import/no-cycle
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.default = getInternalSlots;
6
3
  var internalSlotMap = new WeakMap();
7
- function getInternalSlots(x) {
4
+ export default function getInternalSlots(x) {
8
5
  var internalSlots = internalSlotMap.get(x);
9
6
  if (!internalSlots) {
10
7
  internalSlots = Object.create(null);
package/index.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var InitializeRelativeTimeFormat_1 = require("./abstract/InitializeRelativeTimeFormat");
6
- var PartitionRelativeTimePattern_1 = require("./abstract/PartitionRelativeTimePattern");
7
- var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
1
+ import { CanonicalizeLocaleList, SupportedLocales, ToString, } from '@formatjs/ecma402-abstract';
2
+ import { InitializeRelativeTimeFormat } from './abstract/InitializeRelativeTimeFormat.js';
3
+ import { PartitionRelativeTimePattern } from './abstract/PartitionRelativeTimePattern.js';
4
+ import getInternalSlots from './get_internal_slots.js';
8
5
  var RelativeTimeFormat = /** @class */ (function () {
9
6
  function RelativeTimeFormat(locales, options) {
10
7
  // test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
@@ -13,8 +10,8 @@ var RelativeTimeFormat = /** @class */ (function () {
13
10
  if (!newTarget) {
14
11
  throw new TypeError("Intl.RelativeTimeFormat must be called with 'new'");
15
12
  }
16
- return (0, InitializeRelativeTimeFormat_1.InitializeRelativeTimeFormat)(this, locales, options, {
17
- getInternalSlots: get_internal_slots_1.default,
13
+ return InitializeRelativeTimeFormat(this, locales, options, {
14
+ getInternalSlots: getInternalSlots,
18
15
  availableLocales: RelativeTimeFormat.availableLocales,
19
16
  relevantExtensionKeys: RelativeTimeFormat.relevantExtensionKeys,
20
17
  localeData: RelativeTimeFormat.localeData,
@@ -25,12 +22,12 @@ var RelativeTimeFormat = /** @class */ (function () {
25
22
  if (typeof this !== 'object') {
26
23
  throw new TypeError('format was called on a non-object');
27
24
  }
28
- var internalSlots = (0, get_internal_slots_1.default)(this);
25
+ var internalSlots = getInternalSlots(this);
29
26
  if (!internalSlots.initializedRelativeTimeFormat) {
30
27
  throw new TypeError('format was called on a invalid context');
31
28
  }
32
- return (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(this, Number(value), (0, ecma402_abstract_1.ToString)(unit), {
33
- getInternalSlots: get_internal_slots_1.default,
29
+ return PartitionRelativeTimePattern(this, Number(value), ToString(unit), {
30
+ getInternalSlots: getInternalSlots,
34
31
  })
35
32
  .map(function (el) { return el.value; })
36
33
  .join('');
@@ -39,17 +36,17 @@ var RelativeTimeFormat = /** @class */ (function () {
39
36
  if (typeof this !== 'object') {
40
37
  throw new TypeError('formatToParts was called on a non-object');
41
38
  }
42
- var internalSlots = (0, get_internal_slots_1.default)(this);
39
+ var internalSlots = getInternalSlots(this);
43
40
  if (!internalSlots.initializedRelativeTimeFormat) {
44
41
  throw new TypeError('formatToParts was called on a invalid context');
45
42
  }
46
- return (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(this, Number(value), (0, ecma402_abstract_1.ToString)(unit), { getInternalSlots: get_internal_slots_1.default });
43
+ return PartitionRelativeTimePattern(this, Number(value), ToString(unit), { getInternalSlots: getInternalSlots });
47
44
  };
48
45
  RelativeTimeFormat.prototype.resolvedOptions = function () {
49
46
  if (typeof this !== 'object') {
50
47
  throw new TypeError('resolvedOptions was called on a non-object');
51
48
  }
52
- var internalSlots = (0, get_internal_slots_1.default)(this);
49
+ var internalSlots = getInternalSlots(this);
53
50
  if (!internalSlots.initializedRelativeTimeFormat) {
54
51
  throw new TypeError('resolvedOptions was called on a invalid context');
55
52
  }
@@ -62,7 +59,7 @@ var RelativeTimeFormat = /** @class */ (function () {
62
59
  };
63
60
  };
64
61
  RelativeTimeFormat.supportedLocalesOf = function (locales, options) {
65
- return (0, ecma402_abstract_1.SupportedLocales)(RelativeTimeFormat.availableLocales, (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales), options);
62
+ return SupportedLocales(RelativeTimeFormat.availableLocales, CanonicalizeLocaleList(locales), options);
66
63
  };
67
64
  RelativeTimeFormat.__addLocaleData = function () {
68
65
  var data = [];
@@ -92,7 +89,7 @@ var RelativeTimeFormat = /** @class */ (function () {
92
89
  RelativeTimeFormat.polyfilled = true;
93
90
  return RelativeTimeFormat;
94
91
  }());
95
- exports.default = RelativeTimeFormat;
92
+ export default RelativeTimeFormat;
96
93
  try {
97
94
  // IE11 does not have Symbol
98
95
  if (typeof Symbol !== 'undefined') {
@@ -118,6 +115,6 @@ try {
118
115
  configurable: true,
119
116
  });
120
117
  }
121
- catch (e) {
118
+ catch (_a) {
122
119
  // Meta fix so we're test262-compliant, not important
123
120
  }
package/package.json CHANGED
@@ -1,18 +1,24 @@
1
1
  {
2
2
  "name": "@formatjs/intl-relativetimeformat",
3
3
  "description": "Formats JavaScript dates to relative time strings.",
4
- "version": "11.4.12",
4
+ "version": "12.0.0",
5
5
  "author": "Long Ho <holevietlong@gmail.com>",
6
6
  "bugs": "https://github.com/formatjs/formatjs/issues",
7
7
  "dependencies": {
8
- "@formatjs/ecma402-abstract": "2.3.5",
9
- "@formatjs/intl-localematcher": "0.6.2",
8
+ "@formatjs/ecma402-abstract": "3.0.0",
9
+ "@formatjs/intl-localematcher": "0.7.0",
10
10
  "tslib": "^2.8.0"
11
11
  },
12
12
  "devDependencies": {
13
- "@formatjs/intl-getcanonicallocales": "2.5.6",
14
- "@formatjs/intl-locale": "4.2.12",
15
- "@formatjs/intl-pluralrules": "5.4.5"
13
+ "@formatjs/intl-getcanonicallocales": "3.0.0",
14
+ "@formatjs/intl-locale": "5.0.0",
15
+ "@formatjs/intl-pluralrules": "6.0.0"
16
+ },
17
+ "exports": {
18
+ ".": "./index.js",
19
+ "./polyfill.js": "./polyfill.js",
20
+ "./polyfill-force.js": "./polyfill-force.js",
21
+ "./should-polyfill.js": "./should-polyfill.js"
16
22
  },
17
23
  "gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c",
18
24
  "homepage": "https://github.com/formatjs/formatjs",
@@ -26,7 +32,7 @@
26
32
  "time"
27
33
  ],
28
34
  "license": "MIT",
29
- "main": "index.js",
30
35
  "repository": "git@github.com:formatjs/formatjs.git",
36
+ "type": "module",
31
37
  "types": "index.d.ts"
32
38
  }
package/polyfill-force.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var _1 = tslib_1.__importDefault(require("./"));
1
+ import RelativeTimeFormat from './index.js';
5
2
  Object.defineProperty(Intl, 'RelativeTimeFormat', {
6
- value: _1.default,
3
+ value: RelativeTimeFormat,
7
4
  writable: true,
8
5
  enumerable: false,
9
6
  configurable: true,
package/polyfill.iife.js CHANGED
@@ -6,7 +6,7 @@
6
6
  return value;
7
7
  };
8
8
 
9
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/CanonicalizeLocaleList.js
9
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js
10
10
  function CanonicalizeLocaleList(locales) {
11
11
  return Intl.getCanonicalLocales(locales);
12
12
  }
@@ -2371,12 +2371,11 @@
2371
2371
  var Decimal = P.constructor = clone(DEFAULTS);
2372
2372
  LN10 = new Decimal(LN10);
2373
2373
  PI = new Decimal(PI);
2374
- var decimal_default = Decimal;
2375
2374
 
2376
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/constants.js
2377
- var TEN = new decimal_default(10);
2378
- var ZERO = new decimal_default(0);
2379
- var NEGATIVE_ZERO = new decimal_default(-0);
2375
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
2376
+ var TEN = new Decimal(10);
2377
+ var ZERO = new Decimal(0);
2378
+ var NEGATIVE_ZERO = new Decimal(-0);
2380
2379
 
2381
2380
  // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2382
2381
  var extendStatics = function(d, b) {
@@ -2410,7 +2409,7 @@
2410
2409
  return to.concat(ar || Array.prototype.slice.call(from));
2411
2410
  }
2412
2411
 
2413
- // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2412
+ // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
2414
2413
  function memoize(fn, options) {
2415
2414
  var cache = options && options.cache ? options.cache : cacheDefault;
2416
2415
  var serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -2483,7 +2482,7 @@
2483
2482
  monadic: strategyMonadic
2484
2483
  };
2485
2484
 
2486
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2485
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js
2487
2486
  function invariant(condition, message, Err) {
2488
2487
  if (Err === void 0) {
2489
2488
  Err = Error;
@@ -2543,7 +2542,7 @@
2543
2542
  strategy: strategies.variadic
2544
2543
  });
2545
2544
 
2546
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
2545
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js
2547
2546
  function ToString(o) {
2548
2547
  if (typeof o === "symbol") {
2549
2548
  throw TypeError("Cannot convert a Symbol value to a string");
@@ -2597,7 +2596,7 @@
2597
2596
  var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
2598
2597
  var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
2599
2598
 
2600
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/CoerceOptionsToObject.js
2599
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CoerceOptionsToObject.js
2601
2600
  function CoerceOptionsToObject(options) {
2602
2601
  if (typeof options === "undefined") {
2603
2602
  return /* @__PURE__ */ Object.create(null);
@@ -2605,7 +2604,7 @@
2605
2604
  return ToObject(options);
2606
2605
  }
2607
2606
 
2608
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/GetOption.js
2607
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js
2609
2608
  function GetOption(opts, prop, type, values, fallback) {
2610
2609
  if (typeof opts !== "object") {
2611
2610
  throw new TypeError("Options must be an object");
@@ -2631,7 +2630,7 @@
2631
2630
  return fallback;
2632
2631
  }
2633
2632
 
2634
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/IsSanctionedSimpleUnitIdentifier.js
2633
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js
2635
2634
  var SANCTIONED_UNITS = [
2636
2635
  "angle-degree",
2637
2636
  "area-acre",
@@ -2682,29 +2681,29 @@
2682
2681
  }
2683
2682
  var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
2684
2683
 
2685
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponentForMagnitude.js
2686
- decimal_default.set({
2684
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
2685
+ Decimal.set({
2687
2686
  toExpPos: 100
2688
2687
  });
2689
2688
 
2690
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawFixed.js
2691
- decimal_default.set({
2689
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
2690
+ Decimal.set({
2692
2691
  toExpPos: 100
2693
2692
  });
2694
2693
 
2695
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
2694
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
2696
2695
  var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
2697
2696
 
2698
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/format_to_parts.js
2697
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js
2699
2698
  var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
2700
2699
  var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
2701
2700
 
2702
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeLocaleList.js
2701
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeLocaleList.js
2703
2702
  function CanonicalizeLocaleList2(locales) {
2704
2703
  return Intl.getCanonicalLocales(locales);
2705
2704
  }
2706
2705
 
2707
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/languageMatching.js
2706
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js
2708
2707
  var data = {
2709
2708
  supplemental: {
2710
2709
  languageMatching: {
@@ -5326,7 +5325,7 @@
5326
5325
  }
5327
5326
  };
5328
5327
 
5329
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/regions.generated.js
5328
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
5330
5329
  var regions = {
5331
5330
  "001": [
5332
5331
  "001",
@@ -6661,7 +6660,7 @@
6661
6660
  ]
6662
6661
  };
6663
6662
 
6664
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/utils.js
6663
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
6665
6664
  var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
6666
6665
  function invariant2(condition, message, Err) {
6667
6666
  if (Err === void 0) {
@@ -6815,7 +6814,7 @@
6815
6814
  return result;
6816
6815
  }
6817
6816
 
6818
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestFitMatcher.js
6817
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
6819
6818
  function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
6820
6819
  var foundLocale;
6821
6820
  var extension;
@@ -6840,7 +6839,7 @@
6840
6839
  };
6841
6840
  }
6842
6841
 
6843
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUValue.js
6842
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
6844
6843
  function CanonicalizeUValue(ukey, uvalue) {
6845
6844
  var lowerValue = uvalue.toLowerCase();
6846
6845
  invariant2(ukey !== void 0, "ukey must be defined");
@@ -6848,12 +6847,12 @@
6848
6847
  return canonicalized;
6849
6848
  }
6850
6849
 
6851
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUnicodeLocaleId.js
6850
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
6852
6851
  function CanonicalizeUnicodeLocaleId(locale) {
6853
6852
  return Intl.getCanonicalLocales(locale)[0];
6854
6853
  }
6855
6854
 
6856
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/InsertUnicodeExtensionAndCanonicalize.js
6855
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
6857
6856
  function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
6858
6857
  invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
6859
6858
  var extension = "-u";
@@ -6884,7 +6883,7 @@
6884
6883
  return CanonicalizeUnicodeLocaleId(newLocale);
6885
6884
  }
6886
6885
 
6887
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestAvailableLocale.js
6886
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
6888
6887
  function BestAvailableLocale(availableLocales, locale) {
6889
6888
  var candidate = locale;
6890
6889
  while (true) {
@@ -6902,7 +6901,7 @@
6902
6901
  }
6903
6902
  }
6904
6903
 
6905
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/LookupMatcher.js
6904
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
6906
6905
  function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
6907
6906
  var result = { locale: "" };
6908
6907
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
@@ -6921,7 +6920,7 @@
6921
6920
  return result;
6922
6921
  }
6923
6922
 
6924
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/UnicodeExtensionComponents.js
6923
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
6925
6924
  function UnicodeExtensionComponents(extension) {
6926
6925
  invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
6927
6926
  invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
@@ -6962,7 +6961,7 @@
6962
6961
  return { attributes, keywords };
6963
6962
  }
6964
6963
 
6965
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/ResolveLocale.js
6964
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
6966
6965
  function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
6967
6966
  var _a;
6968
6967
  var matcher = options.localeMatcher;
@@ -7048,7 +7047,7 @@
7048
7047
  return result;
7049
7048
  }
7050
7049
 
7051
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/LookupSupportedLocales.js
7050
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupSupportedLocales.js
7052
7051
  function LookupSupportedLocales(availableLocales, requestedLocales) {
7053
7052
  var subset = [];
7054
7053
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
@@ -7062,7 +7061,7 @@
7062
7061
  return subset;
7063
7062
  }
7064
7063
 
7065
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/index.js
7064
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
7066
7065
  function match(requestedLocales, availableLocales, defaultLocale, opts) {
7067
7066
  return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), {
7068
7067
  localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
@@ -7071,7 +7070,7 @@
7071
7070
  }).locale;
7072
7071
  }
7073
7072
 
7074
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/PartitionPattern.js
7073
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/PartitionPattern.js
7075
7074
  function PartitionPattern(pattern) {
7076
7075
  var result = [];
7077
7076
  var beginIndex = pattern.indexOf("{");
@@ -7103,7 +7102,7 @@
7103
7102
  return result;
7104
7103
  }
7105
7104
 
7106
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/SupportedLocales.js
7105
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/SupportedLocales.js
7107
7106
  function SupportedLocales(availableLocales, requestedLocales, options) {
7108
7107
  var matcher = "best fit";
7109
7108
  if (options !== void 0) {
@@ -7116,7 +7115,7 @@
7116
7115
  return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
7117
7116
  }
7118
7117
 
7119
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/data.js
7118
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/data.js
7120
7119
  var MissingLocaleDataError = (
7121
7120
  /** @class */
7122
7121
  function(_super) {
@@ -7130,7 +7129,7 @@
7130
7129
  }(Error)
7131
7130
  );
7132
7131
 
7133
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/types/date-time.js
7132
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/types/date-time.js
7134
7133
  var RangePatternType;
7135
7134
  (function(RangePatternType2) {
7136
7135
  RangePatternType2["startRange"] = "startRange";
@@ -7457,7 +7456,7 @@
7457
7456
  return "numberingSystem" in new Intl.RelativeTimeFormat(locale || "en", {
7458
7457
  numeric: "auto"
7459
7458
  }).resolvedOptions();
7460
- } catch (_) {
7459
+ } catch (e) {
7461
7460
  return false;
7462
7461
  }
7463
7462
  }
package/polyfill.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var _1 = tslib_1.__importDefault(require("./"));
5
- var should_polyfill_1 = require("./should-polyfill");
6
- if ((0, should_polyfill_1.shouldPolyfill)()) {
1
+ import RelativeTimeFormat from './index.js';
2
+ import { shouldPolyfill } from './should-polyfill.js';
3
+ if (shouldPolyfill()) {
7
4
  Object.defineProperty(Intl, 'RelativeTimeFormat', {
8
- value: _1.default,
5
+ value: RelativeTimeFormat,
9
6
  writable: true,
10
7
  enumerable: false,
11
8
  configurable: true,
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldPolyfill = shouldPolyfill;
4
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
- var supported_locales_generated_1 = require("./supported-locales.generated");
1
+ import { match } from '@formatjs/intl-localematcher';
2
+ import { supportedLocales } from './supported-locales.generated.js';
6
3
  function supportedLocalesOf(locale) {
7
4
  if (!locale) {
8
5
  return true;
@@ -18,15 +15,15 @@ function hasResolvedOptionsNumberingSystem(locale) {
18
15
  numeric: 'auto',
19
16
  }).resolvedOptions());
20
17
  }
21
- catch (_) {
18
+ catch (_a) {
22
19
  return false;
23
20
  }
24
21
  }
25
- function shouldPolyfill(locale) {
22
+ export function shouldPolyfill(locale) {
26
23
  if (locale === void 0) { locale = 'en'; }
27
24
  if (!('RelativeTimeFormat' in Intl) ||
28
25
  !supportedLocalesOf(locale) ||
29
26
  !hasResolvedOptionsNumberingSystem(locale)) {
30
- return (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en');
27
+ return match([locale], supportedLocales, 'en');
31
28
  }
32
29
  }
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.supportedLocales = void 0;
4
- exports.supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];
1
+ export var supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];
@@ -1,4 +0,0 @@
1
- import { RelativeTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
- export declare function FormatRelativeTime(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, implDetails: {
3
- getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
4
- }): string;
@@ -1,10 +0,0 @@
1
- import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern';
2
- export function FormatRelativeTime(rtf, value, unit, implDetails) {
3
- var parts = PartitionRelativeTimePattern(rtf, value, unit, implDetails);
4
- var result = '';
5
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
6
- var part = parts_1[_i];
7
- result += part.value;
8
- }
9
- return result;
10
- }
@@ -1,4 +0,0 @@
1
- import { RelativeTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
- export declare function FormatRelativeTimeToParts(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, implDetails: {
3
- getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
4
- }): Intl.RelativeTimeFormatPart[];
@@ -1,4 +0,0 @@
1
- import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern';
2
- export function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
3
- return PartitionRelativeTimePattern(rtf, value, unit, implDetails);
4
- }
@@ -1,8 +0,0 @@
1
- import { LocaleFieldsData, RelativeTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
- export declare function InitializeRelativeTimeFormat(rtf: Intl.RelativeTimeFormat, locales: string | string[] | undefined, options: Intl.RelativeTimeFormatOptions | undefined, { getInternalSlots, availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, }: {
3
- getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
4
- availableLocales: Set<string>;
5
- relevantExtensionKeys: string[];
6
- localeData: Record<string, LocaleFieldsData | undefined>;
7
- getDefaultLocale(): string;
8
- }): Intl.RelativeTimeFormat;
@@ -1,34 +0,0 @@
1
- import { CanonicalizeLocaleList, CoerceOptionsToObject, createMemoizedNumberFormat, createMemoizedPluralRules, GetOption, invariant, } from '@formatjs/ecma402-abstract';
2
- import { ResolveLocale } from '@formatjs/intl-localematcher';
3
- var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
4
- export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
5
- var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
6
- var internalSlots = getInternalSlots(rtf);
7
- internalSlots.initializedRelativeTimeFormat = true;
8
- var requestedLocales = CanonicalizeLocaleList(locales);
9
- var opt = Object.create(null);
10
- var opts = CoerceOptionsToObject(options);
11
- var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
12
- opt.localeMatcher = matcher;
13
- var numberingSystem = GetOption(opts,
14
- // @ts-expect-error TS option is wack
15
- 'numberingSystem', 'string', undefined, undefined);
16
- if (numberingSystem !== undefined) {
17
- if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
18
- throw new RangeError("Invalid numbering system ".concat(numberingSystem));
19
- }
20
- }
21
- opt.nu = numberingSystem;
22
- var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
23
- var locale = r.locale, nu = r.nu;
24
- internalSlots.locale = locale;
25
- internalSlots.style = GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
26
- internalSlots.numeric = GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
27
- var fields = localeData[r.dataLocale];
28
- invariant(!!fields, "Missing locale data for ".concat(r.dataLocale));
29
- internalSlots.fields = fields;
30
- internalSlots.numberFormat = createMemoizedNumberFormat(locales);
31
- internalSlots.pluralRules = createMemoizedPluralRules(locales);
32
- internalSlots.numberingSystem = nu;
33
- return rtf;
34
- }
@@ -1 +0,0 @@
1
- export declare function MakePartsList(pattern: string, unit: Intl.RelativeTimeFormatUnitSingular, parts: Intl.NumberFormatPart[] | Intl.RelativeTimeFormatPart[]): Intl.RelativeTimeFormatPart[];
@@ -1,26 +0,0 @@
1
- import { invariant, PartitionPattern } from '@formatjs/ecma402-abstract';
2
- export function MakePartsList(pattern, unit, parts) {
3
- var patternParts = PartitionPattern(pattern);
4
- var result = [];
5
- for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
6
- var patternPart = patternParts_1[_i];
7
- if (patternPart.type === 'literal') {
8
- result.push({
9
- type: 'literal',
10
- value: patternPart.value,
11
- });
12
- }
13
- else {
14
- invariant(patternPart.type === '0', "Malformed pattern ".concat(pattern));
15
- for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
16
- var part = parts_1[_a];
17
- result.push({
18
- type: part.type,
19
- value: part.value,
20
- unit: unit,
21
- });
22
- }
23
- }
24
- }
25
- return result;
26
- }
@@ -1,4 +0,0 @@
1
- import { RelativeTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
- export declare function PartitionRelativeTimePattern(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, { getInternalSlots, }: {
3
- getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
4
- }): Intl.RelativeTimeFormatPart[];
@@ -1,53 +0,0 @@
1
- import { invariant, SameValue, ToString, Type, } from '@formatjs/ecma402-abstract';
2
- import { SingularRelativeTimeUnit } from './SingularRelativeTimeUnit';
3
- import { MakePartsList } from './MakePartsList';
4
- export function PartitionRelativeTimePattern(rtf, value, unit, _a) {
5
- var getInternalSlots = _a.getInternalSlots;
6
- invariant(Type(value) === 'Number', "value must be number, instead got ".concat(typeof value), TypeError);
7
- invariant(Type(unit) === 'String', "unit must be number, instead got ".concat(typeof value), TypeError);
8
- if (isNaN(value) || !isFinite(value)) {
9
- throw new RangeError("Invalid value ".concat(value));
10
- }
11
- var resolvedUnit = SingularRelativeTimeUnit(unit);
12
- var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
13
- var entry = resolvedUnit;
14
- if (style === 'short') {
15
- entry = "".concat(resolvedUnit, "-short");
16
- }
17
- else if (style === 'narrow') {
18
- entry = "".concat(resolvedUnit, "-narrow");
19
- }
20
- if (!(entry in fields)) {
21
- entry = resolvedUnit;
22
- }
23
- var patterns = fields[entry];
24
- if (numeric === 'auto') {
25
- if (ToString(value) in patterns) {
26
- return [
27
- {
28
- type: 'literal',
29
- value: patterns[ToString(value)],
30
- },
31
- ];
32
- }
33
- }
34
- var tl = 'future';
35
- if (SameValue(value, -0) || value < 0) {
36
- tl = 'past';
37
- }
38
- var po = patterns[tl];
39
- var fv = typeof numberFormat.formatToParts === 'function'
40
- ? numberFormat.formatToParts(Math.abs(value))
41
- : // TODO: If formatToParts is not supported, we assume the whole formatted
42
- // number is a part
43
- [
44
- {
45
- type: 'literal',
46
- value: numberFormat.format(Math.abs(value)),
47
- unit: unit,
48
- },
49
- ];
50
- var pr = pluralRules.select(value);
51
- var pattern = po[pr];
52
- return MakePartsList(pattern, resolvedUnit, fv);
53
- }
@@ -1,6 +0,0 @@
1
- import { RelativeTimeFormatSingularUnit } from '@formatjs/ecma402-abstract';
2
- /**
3
- * https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
4
- * @param unit
5
- */
6
- export declare function SingularRelativeTimeUnit(unit: Intl.RelativeTimeFormatUnit): RelativeTimeFormatSingularUnit;
@@ -1,35 +0,0 @@
1
- import { invariant, Type, } from '@formatjs/ecma402-abstract';
2
- /**
3
- * https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
4
- * @param unit
5
- */
6
- export function SingularRelativeTimeUnit(unit) {
7
- invariant(Type(unit) === 'String', 'unit must be a string');
8
- if (unit === 'seconds')
9
- return 'second';
10
- if (unit === 'minutes')
11
- return 'minute';
12
- if (unit === 'hours')
13
- return 'hour';
14
- if (unit === 'days')
15
- return 'day';
16
- if (unit === 'weeks')
17
- return 'week';
18
- if (unit === 'months')
19
- return 'month';
20
- if (unit === 'quarters')
21
- return 'quarter';
22
- if (unit === 'years')
23
- return 'year';
24
- if (unit !== 'second' &&
25
- unit !== 'minute' &&
26
- unit !== 'hour' &&
27
- unit !== 'day' &&
28
- unit !== 'week' &&
29
- unit !== 'month' &&
30
- unit !== 'quarter' &&
31
- unit !== 'year') {
32
- throw new RangeError('invalid unit');
33
- }
34
- return unit;
35
- }
@@ -1,2 +0,0 @@
1
- import { RelativeTimeFormatInternal } from '@formatjs/ecma402-abstract';
2
- export default function getInternalSlots(x: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
@@ -1,11 +0,0 @@
1
- // Type-only circular import
2
- // eslint-disable-next-line import/no-cycle
3
- var internalSlotMap = new WeakMap();
4
- export default function getInternalSlots(x) {
5
- var internalSlots = internalSlotMap.get(x);
6
- if (!internalSlots) {
7
- internalSlots = Object.create(null);
8
- internalSlotMap.set(x, internalSlots);
9
- }
10
- return internalSlots;
11
- }
package/lib/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { LocaleFieldsData, RelativeTimeLocaleData } from '@formatjs/ecma402-abstract';
2
- export default class RelativeTimeFormat {
3
- constructor(locales?: string | string[], options?: Intl.RelativeTimeFormatOptions);
4
- format(value: number, unit: Intl.RelativeTimeFormatUnit): string;
5
- formatToParts(value: number, unit: Intl.RelativeTimeFormatUnit): Intl.RelativeTimeFormatPart[];
6
- resolvedOptions(): Intl.ResolvedRelativeTimeFormatOptions;
7
- static supportedLocalesOf(locales: string | string[], options?: Pick<Intl.RelativeTimeFormatOptions, 'localeMatcher'>): string[];
8
- static __addLocaleData(...data: RelativeTimeLocaleData[]): void;
9
- static localeData: Record<string, LocaleFieldsData>;
10
- private static availableLocales;
11
- private static __defaultLocale;
12
- private static getDefaultLocale;
13
- private static relevantExtensionKeys;
14
- static polyfilled: boolean;
15
- }
package/lib/index.js DELETED
@@ -1,120 +0,0 @@
1
- import { CanonicalizeLocaleList, SupportedLocales, ToString, } from '@formatjs/ecma402-abstract';
2
- import { InitializeRelativeTimeFormat } from './abstract/InitializeRelativeTimeFormat';
3
- import { PartitionRelativeTimePattern } from './abstract/PartitionRelativeTimePattern';
4
- import getInternalSlots from './get_internal_slots';
5
- var RelativeTimeFormat = /** @class */ (function () {
6
- function RelativeTimeFormat(locales, options) {
7
- // test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
8
- // Cannot use `new.target` bc of IE11 & TS transpiles it to something else
9
- var newTarget = this && this instanceof RelativeTimeFormat ? this.constructor : void 0;
10
- if (!newTarget) {
11
- throw new TypeError("Intl.RelativeTimeFormat must be called with 'new'");
12
- }
13
- return InitializeRelativeTimeFormat(this, locales, options, {
14
- getInternalSlots: getInternalSlots,
15
- availableLocales: RelativeTimeFormat.availableLocales,
16
- relevantExtensionKeys: RelativeTimeFormat.relevantExtensionKeys,
17
- localeData: RelativeTimeFormat.localeData,
18
- getDefaultLocale: RelativeTimeFormat.getDefaultLocale,
19
- });
20
- }
21
- RelativeTimeFormat.prototype.format = function (value, unit) {
22
- if (typeof this !== 'object') {
23
- throw new TypeError('format was called on a non-object');
24
- }
25
- var internalSlots = getInternalSlots(this);
26
- if (!internalSlots.initializedRelativeTimeFormat) {
27
- throw new TypeError('format was called on a invalid context');
28
- }
29
- return PartitionRelativeTimePattern(this, Number(value), ToString(unit), {
30
- getInternalSlots: getInternalSlots,
31
- })
32
- .map(function (el) { return el.value; })
33
- .join('');
34
- };
35
- RelativeTimeFormat.prototype.formatToParts = function (value, unit) {
36
- if (typeof this !== 'object') {
37
- throw new TypeError('formatToParts was called on a non-object');
38
- }
39
- var internalSlots = getInternalSlots(this);
40
- if (!internalSlots.initializedRelativeTimeFormat) {
41
- throw new TypeError('formatToParts was called on a invalid context');
42
- }
43
- return PartitionRelativeTimePattern(this, Number(value), ToString(unit), { getInternalSlots: getInternalSlots });
44
- };
45
- RelativeTimeFormat.prototype.resolvedOptions = function () {
46
- if (typeof this !== 'object') {
47
- throw new TypeError('resolvedOptions was called on a non-object');
48
- }
49
- var internalSlots = getInternalSlots(this);
50
- if (!internalSlots.initializedRelativeTimeFormat) {
51
- throw new TypeError('resolvedOptions was called on a invalid context');
52
- }
53
- // test262/test/intl402/RelativeTimeFormat/prototype/resolvedOptions/type.js
54
- return {
55
- locale: internalSlots.locale,
56
- style: internalSlots.style,
57
- numeric: internalSlots.numeric,
58
- numberingSystem: internalSlots.numberingSystem,
59
- };
60
- };
61
- RelativeTimeFormat.supportedLocalesOf = function (locales, options) {
62
- return SupportedLocales(RelativeTimeFormat.availableLocales, CanonicalizeLocaleList(locales), options);
63
- };
64
- RelativeTimeFormat.__addLocaleData = function () {
65
- var data = [];
66
- for (var _i = 0; _i < arguments.length; _i++) {
67
- data[_i] = arguments[_i];
68
- }
69
- for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
70
- var _b = data_1[_a], d = _b.data, locale = _b.locale;
71
- var minimizedLocale = new Intl.Locale(locale)
72
- .minimize()
73
- .toString();
74
- RelativeTimeFormat.localeData[locale] = RelativeTimeFormat.localeData[minimizedLocale] = d;
75
- RelativeTimeFormat.availableLocales.add(minimizedLocale);
76
- RelativeTimeFormat.availableLocales.add(locale);
77
- if (!RelativeTimeFormat.__defaultLocale) {
78
- RelativeTimeFormat.__defaultLocale = minimizedLocale;
79
- }
80
- }
81
- };
82
- RelativeTimeFormat.getDefaultLocale = function () {
83
- return RelativeTimeFormat.__defaultLocale;
84
- };
85
- RelativeTimeFormat.localeData = {};
86
- RelativeTimeFormat.availableLocales = new Set();
87
- RelativeTimeFormat.__defaultLocale = '';
88
- RelativeTimeFormat.relevantExtensionKeys = ['nu'];
89
- RelativeTimeFormat.polyfilled = true;
90
- return RelativeTimeFormat;
91
- }());
92
- export default RelativeTimeFormat;
93
- try {
94
- // IE11 does not have Symbol
95
- if (typeof Symbol !== 'undefined') {
96
- Object.defineProperty(RelativeTimeFormat.prototype, Symbol.toStringTag, {
97
- value: 'Intl.RelativeTimeFormat',
98
- writable: false,
99
- enumerable: false,
100
- configurable: true,
101
- });
102
- }
103
- // https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/length.js
104
- Object.defineProperty(RelativeTimeFormat.prototype.constructor, 'length', {
105
- value: 0,
106
- writable: false,
107
- enumerable: false,
108
- configurable: true,
109
- });
110
- // https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/length.js
111
- Object.defineProperty(RelativeTimeFormat.supportedLocalesOf, 'length', {
112
- value: 1,
113
- writable: false,
114
- enumerable: false,
115
- configurable: true,
116
- });
117
- }
118
- catch (e) {
119
- // Meta fix so we're test262-compliant, not important
120
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import RelativeTimeFormat from './';
2
- Object.defineProperty(Intl, 'RelativeTimeFormat', {
3
- value: RelativeTimeFormat,
4
- writable: true,
5
- enumerable: false,
6
- configurable: true,
7
- });
package/lib/polyfill.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/polyfill.js DELETED
@@ -1,10 +0,0 @@
1
- import RelativeTimeFormat from './';
2
- import { shouldPolyfill } from './should-polyfill';
3
- if (shouldPolyfill()) {
4
- Object.defineProperty(Intl, 'RelativeTimeFormat', {
5
- value: RelativeTimeFormat,
6
- writable: true,
7
- enumerable: false,
8
- configurable: true,
9
- });
10
- }
@@ -1 +0,0 @@
1
- export declare function shouldPolyfill(locale?: string): string | undefined;
@@ -1,29 +0,0 @@
1
- import { match } from '@formatjs/intl-localematcher';
2
- import { supportedLocales } from './supported-locales.generated';
3
- function supportedLocalesOf(locale) {
4
- if (!locale) {
5
- return true;
6
- }
7
- var locales = Array.isArray(locale) ? locale : [locale];
8
- return (Intl.RelativeTimeFormat.supportedLocalesOf(locales).length ===
9
- locales.length);
10
- }
11
- function hasResolvedOptionsNumberingSystem(locale) {
12
- try {
13
- return ('numberingSystem' in
14
- new Intl.RelativeTimeFormat(locale || 'en', {
15
- numeric: 'auto',
16
- }).resolvedOptions());
17
- }
18
- catch (_) {
19
- return false;
20
- }
21
- }
22
- export function shouldPolyfill(locale) {
23
- if (locale === void 0) { locale = 'en'; }
24
- if (!('RelativeTimeFormat' in Intl) ||
25
- !supportedLocalesOf(locale) ||
26
- !hasResolvedOptionsNumberingSystem(locale)) {
27
- return match([locale], supportedLocales, 'en');
28
- }
29
- }
@@ -1 +0,0 @@
1
- export declare const supportedLocales: string[];
@@ -1 +0,0 @@
1
- export var supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];