@formatjs/intl-relativetimeformat 9.3.1 → 9.4.1

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FormatRelativeTime = void 0;
4
4
  var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
5
5
  function FormatRelativeTime(rtf, value, unit, implDetails) {
6
- var parts = PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(rtf, value, unit, implDetails);
6
+ var parts = (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(rtf, value, unit, implDetails);
7
7
  var result = '';
8
8
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
9
9
  var part = parts_1[_i];
@@ -4,8 +4,8 @@ exports.FormatRelativeTimeToParts = void 0;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
6
6
  function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
7
- var parts = PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(rtf, value, unit, implDetails);
8
- var result = ecma402_abstract_1.ArrayCreate(0);
7
+ var parts = (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(rtf, value, unit, implDetails);
8
+ var result = (0, ecma402_abstract_1.ArrayCreate)(0);
9
9
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
10
10
  var part = parts_1[_i];
11
11
  var o = {
@@ -8,27 +8,27 @@ function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
8
8
  var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
9
9
  var internalSlots = getInternalSlots(rtf);
10
10
  internalSlots.initializedRelativeTimeFormat = true;
11
- var requestedLocales = ecma402_abstract_1.CanonicalizeLocaleList(locales);
11
+ var requestedLocales = (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales);
12
12
  var opt = Object.create(null);
13
- var opts = ecma402_abstract_1.CoerceOptionsToObject(options);
14
- var matcher = ecma402_abstract_1.GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
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');
15
15
  opt.localeMatcher = matcher;
16
- var numberingSystem = ecma402_abstract_1.GetOption(opts,
16
+ var numberingSystem = (0, ecma402_abstract_1.GetOption)(opts,
17
17
  // @ts-expect-error TS option is wack
18
18
  'numberingSystem', 'string', undefined, undefined);
19
19
  if (numberingSystem !== undefined) {
20
20
  if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
21
- throw new RangeError("Invalid numbering system " + numberingSystem);
21
+ throw new RangeError("Invalid numbering system ".concat(numberingSystem));
22
22
  }
23
23
  }
24
24
  opt.nu = numberingSystem;
25
- var r = intl_localematcher_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
25
+ var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
26
26
  var locale = r.locale, nu = r.nu;
27
27
  internalSlots.locale = locale;
28
- internalSlots.style = ecma402_abstract_1.GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
29
- internalSlots.numeric = ecma402_abstract_1.GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
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');
30
30
  var fields = localeData[r.dataLocale];
31
- ecma402_abstract_1.invariant(!!fields, "Missing locale data for " + r.dataLocale);
31
+ (0, ecma402_abstract_1.invariant)(!!fields, "Missing locale data for ".concat(r.dataLocale));
32
32
  internalSlots.fields = fields;
33
33
  internalSlots.numberFormat = new Intl.NumberFormat(locales);
34
34
  internalSlots.pluralRules = new Intl.PluralRules(locales);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MakePartsList = void 0;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  function MakePartsList(pattern, unit, parts) {
6
- var patternParts = ecma402_abstract_1.PartitionPattern(pattern);
6
+ var patternParts = (0, ecma402_abstract_1.PartitionPattern)(pattern);
7
7
  var result = [];
8
8
  for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
9
9
  var patternPart = patternParts_1[_i];
@@ -14,7 +14,7 @@ function MakePartsList(pattern, unit, parts) {
14
14
  });
15
15
  }
16
16
  else {
17
- ecma402_abstract_1.invariant(patternPart.type === '0', "Malformed pattern " + pattern);
17
+ (0, ecma402_abstract_1.invariant)(patternPart.type === '0', "Malformed pattern ".concat(pattern));
18
18
  for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
19
19
  var part = parts_1[_a];
20
20
  result.push({
@@ -6,36 +6,36 @@ var SingularRelativeTimeUnit_1 = require("./SingularRelativeTimeUnit");
6
6
  var MakePartsList_1 = require("./MakePartsList");
7
7
  function PartitionRelativeTimePattern(rtf, value, unit, _a) {
8
8
  var getInternalSlots = _a.getInternalSlots;
9
- ecma402_abstract_1.invariant(ecma402_abstract_1.Type(value) === 'Number', "value must be number, instead got " + typeof value, TypeError);
10
- ecma402_abstract_1.invariant(ecma402_abstract_1.Type(unit) === 'String', "unit must be number, instead got " + typeof value, TypeError);
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);
11
11
  if (isNaN(value) || !isFinite(value)) {
12
- throw new RangeError("Invalid value " + value);
12
+ throw new RangeError("Invalid value ".concat(value));
13
13
  }
14
- var resolvedUnit = SingularRelativeTimeUnit_1.SingularRelativeTimeUnit(unit);
14
+ var resolvedUnit = (0, SingularRelativeTimeUnit_1.SingularRelativeTimeUnit)(unit);
15
15
  var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
16
16
  var entry = resolvedUnit;
17
17
  if (style === 'short') {
18
- entry = resolvedUnit + "-short";
18
+ entry = "".concat(resolvedUnit, "-short");
19
19
  }
20
20
  else if (style === 'narrow') {
21
- entry = resolvedUnit + "-narrow";
21
+ entry = "".concat(resolvedUnit, "-narrow");
22
22
  }
23
23
  if (!(entry in fields)) {
24
24
  entry = resolvedUnit;
25
25
  }
26
26
  var patterns = fields[entry];
27
27
  if (numeric === 'auto') {
28
- if (ecma402_abstract_1.ToString(value) in patterns) {
28
+ if ((0, ecma402_abstract_1.ToString)(value) in patterns) {
29
29
  return [
30
30
  {
31
31
  type: 'literal',
32
- value: patterns[ecma402_abstract_1.ToString(value)],
32
+ value: patterns[(0, ecma402_abstract_1.ToString)(value)],
33
33
  },
34
34
  ];
35
35
  }
36
36
  }
37
37
  var tl = 'future';
38
- if (ecma402_abstract_1.SameValue(value, -0) || value < 0) {
38
+ if ((0, ecma402_abstract_1.SameValue)(value, -0) || value < 0) {
39
39
  tl = 'past';
40
40
  }
41
41
  var po = patterns[tl];
@@ -52,6 +52,6 @@ function PartitionRelativeTimePattern(rtf, value, unit, _a) {
52
52
  ];
53
53
  var pr = pluralRules.select(value);
54
54
  var pattern = po[pr];
55
- return MakePartsList_1.MakePartsList(pattern, resolvedUnit, fv);
55
+ return (0, MakePartsList_1.MakePartsList)(pattern, resolvedUnit, fv);
56
56
  }
57
57
  exports.PartitionRelativeTimePattern = PartitionRelativeTimePattern;
@@ -7,7 +7,7 @@ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
7
7
  * @param unit
8
8
  */
9
9
  function SingularRelativeTimeUnit(unit) {
10
- ecma402_abstract_1.invariant(ecma402_abstract_1.Type(unit) === 'String', 'unit must be a string');
10
+ (0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(unit) === 'String', 'unit must be a string');
11
11
  if (unit === 'seconds')
12
12
  return 'second';
13
13
  if (unit === 'minutes')
package/index.js CHANGED
@@ -4,7 +4,7 @@ var tslib_1 = require("tslib");
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  var InitializeRelativeTimeFormat_1 = require("./abstract/InitializeRelativeTimeFormat");
6
6
  var PartitionRelativeTimePattern_1 = require("./abstract/PartitionRelativeTimePattern");
7
- var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
7
+ var get_internal_slots_1 = (0, tslib_1.__importDefault)(require("./get_internal_slots"));
8
8
  var RelativeTimeFormat = /** @class */ (function () {
9
9
  function RelativeTimeFormat(locales, options) {
10
10
  // test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
@@ -13,7 +13,7 @@ var RelativeTimeFormat = /** @class */ (function () {
13
13
  if (!newTarget) {
14
14
  throw new TypeError("Intl.RelativeTimeFormat must be called with 'new'");
15
15
  }
16
- return InitializeRelativeTimeFormat_1.InitializeRelativeTimeFormat(this, locales, options, {
16
+ return (0, InitializeRelativeTimeFormat_1.InitializeRelativeTimeFormat)(this, locales, options, {
17
17
  getInternalSlots: get_internal_slots_1.default,
18
18
  availableLocales: RelativeTimeFormat.availableLocales,
19
19
  relevantExtensionKeys: RelativeTimeFormat.relevantExtensionKeys,
@@ -25,11 +25,11 @@ var RelativeTimeFormat = /** @class */ (function () {
25
25
  if (typeof this !== 'object') {
26
26
  throw new TypeError('format was called on a non-object');
27
27
  }
28
- var internalSlots = get_internal_slots_1.default(this);
28
+ var internalSlots = (0, get_internal_slots_1.default)(this);
29
29
  if (!internalSlots.initializedRelativeTimeFormat) {
30
30
  throw new TypeError('format was called on a invalid context');
31
31
  }
32
- return PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(this, Number(value), ecma402_abstract_1.ToString(unit), {
32
+ return (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(this, Number(value), (0, ecma402_abstract_1.ToString)(unit), {
33
33
  getInternalSlots: get_internal_slots_1.default,
34
34
  })
35
35
  .map(function (el) { return el.value; })
@@ -39,17 +39,17 @@ var RelativeTimeFormat = /** @class */ (function () {
39
39
  if (typeof this !== 'object') {
40
40
  throw new TypeError('formatToParts was called on a non-object');
41
41
  }
42
- var internalSlots = get_internal_slots_1.default(this);
42
+ var internalSlots = (0, get_internal_slots_1.default)(this);
43
43
  if (!internalSlots.initializedRelativeTimeFormat) {
44
44
  throw new TypeError('formatToParts was called on a invalid context');
45
45
  }
46
- return PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(this, Number(value), ecma402_abstract_1.ToString(unit), { getInternalSlots: get_internal_slots_1.default });
46
+ return (0, PartitionRelativeTimePattern_1.PartitionRelativeTimePattern)(this, Number(value), (0, ecma402_abstract_1.ToString)(unit), { getInternalSlots: get_internal_slots_1.default });
47
47
  };
48
48
  RelativeTimeFormat.prototype.resolvedOptions = function () {
49
49
  if (typeof this !== 'object') {
50
50
  throw new TypeError('resolvedOptions was called on a non-object');
51
51
  }
52
- var internalSlots = get_internal_slots_1.default(this);
52
+ var internalSlots = (0, get_internal_slots_1.default)(this);
53
53
  if (!internalSlots.initializedRelativeTimeFormat) {
54
54
  throw new TypeError('resolvedOptions was called on a invalid context');
55
55
  }
@@ -62,7 +62,7 @@ var RelativeTimeFormat = /** @class */ (function () {
62
62
  };
63
63
  };
64
64
  RelativeTimeFormat.supportedLocalesOf = function (locales, options) {
65
- return ecma402_abstract_1.SupportedLocales(RelativeTimeFormat.availableLocales, ecma402_abstract_1.CanonicalizeLocaleList(locales), options);
65
+ return (0, ecma402_abstract_1.SupportedLocales)(RelativeTimeFormat.availableLocales, (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales), options);
66
66
  };
67
67
  RelativeTimeFormat.__addLocaleData = function () {
68
68
  var data = [];
@@ -15,7 +15,7 @@ export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
15
15
  'numberingSystem', 'string', undefined, undefined);
16
16
  if (numberingSystem !== undefined) {
17
17
  if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
18
- throw new RangeError("Invalid numbering system " + numberingSystem);
18
+ throw new RangeError("Invalid numbering system ".concat(numberingSystem));
19
19
  }
20
20
  }
21
21
  opt.nu = numberingSystem;
@@ -25,7 +25,7 @@ export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
25
25
  internalSlots.style = GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
26
26
  internalSlots.numeric = GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
27
27
  var fields = localeData[r.dataLocale];
28
- invariant(!!fields, "Missing locale data for " + r.dataLocale);
28
+ invariant(!!fields, "Missing locale data for ".concat(r.dataLocale));
29
29
  internalSlots.fields = fields;
30
30
  internalSlots.numberFormat = new Intl.NumberFormat(locales);
31
31
  internalSlots.pluralRules = new Intl.PluralRules(locales);
@@ -11,7 +11,7 @@ export function MakePartsList(pattern, unit, parts) {
11
11
  });
12
12
  }
13
13
  else {
14
- invariant(patternPart.type === '0', "Malformed pattern " + pattern);
14
+ invariant(patternPart.type === '0', "Malformed pattern ".concat(pattern));
15
15
  for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
16
16
  var part = parts_1[_a];
17
17
  result.push({
@@ -3,19 +3,19 @@ import { SingularRelativeTimeUnit } from './SingularRelativeTimeUnit';
3
3
  import { MakePartsList } from './MakePartsList';
4
4
  export function PartitionRelativeTimePattern(rtf, value, unit, _a) {
5
5
  var getInternalSlots = _a.getInternalSlots;
6
- invariant(Type(value) === 'Number', "value must be number, instead got " + typeof value, TypeError);
7
- invariant(Type(unit) === 'String', "unit must be number, instead got " + 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);
8
8
  if (isNaN(value) || !isFinite(value)) {
9
- throw new RangeError("Invalid value " + value);
9
+ throw new RangeError("Invalid value ".concat(value));
10
10
  }
11
11
  var resolvedUnit = SingularRelativeTimeUnit(unit);
12
12
  var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
13
13
  var entry = resolvedUnit;
14
14
  if (style === 'short') {
15
- entry = resolvedUnit + "-short";
15
+ entry = "".concat(resolvedUnit, "-short");
16
16
  }
17
17
  else if (style === 'narrow') {
18
- entry = resolvedUnit + "-narrow";
18
+ entry = "".concat(resolvedUnit, "-narrow");
19
19
  }
20
20
  if (!(entry in fields)) {
21
21
  entry = resolvedUnit;
@@ -1,2 +1,2 @@
1
- export declare function shouldPolyfill(locale?: string | string[]): boolean;
1
+ export declare function shouldPolyfill(locale?: string): string | undefined;
2
2
  //# sourceMappingURL=should-polyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAwBA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAMxD"}
1
+ {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AA2BA,wBAAgB,cAAc,CAAC,MAAM,SAAO,sBAQ3C"}
@@ -1,3 +1,5 @@
1
+ import { match } from '@formatjs/intl-localematcher';
2
+ import { supportedLocales } from './supported-locales';
1
3
  function supportedLocalesOf(locale) {
2
4
  if (!locale) {
3
5
  return true;
@@ -18,7 +20,10 @@ function hasResolvedOptionsNumberingSystem(locale) {
18
20
  }
19
21
  }
20
22
  export function shouldPolyfill(locale) {
21
- return (!('RelativeTimeFormat' in Intl) ||
23
+ if (locale === void 0) { locale = 'en'; }
24
+ if (!('RelativeTimeFormat' in Intl) ||
22
25
  !supportedLocalesOf(locale) ||
23
- !hasResolvedOptionsNumberingSystem(locale));
26
+ !hasResolvedOptionsNumberingSystem(locale)) {
27
+ return match([locale], supportedLocales, 'en');
28
+ }
24
29
  }
@@ -0,0 +1,2 @@
1
+ export declare const supportedLocales: string[];
2
+ //# sourceMappingURL=supported-locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supported-locales.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/supported-locales.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,EAAE,MAAM,EAA+nI,CAAA"}
@@ -0,0 +1,2 @@
1
+ // This file is generated from supported-locales-gen.ts
2
+ export var supportedLocales = ["af-NA", "af", "agq", "ak", "am", "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", "ar", "as", "asa", "ast", "az-Cyrl", "az-Latn", "az", "bas", "be", "bem", "bez", "bg", "bm", "bn-IN", "bn", "bo-IN", "bo", "br", "brx", "bs-Cyrl", "bs-Latn", "bs", "ca-AD", "ca-ES-VALENCIA", "ca-FR", "ca-IT", "ca", "ccp-IN", "ccp", "ce", "ceb", "cgg", "chr", "ckb-IR", "ckb", "cs", "cy", "da-GL", "da", "dav", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "de", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee-TG", "ee", "el-CY", "el", "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-US-POSIX", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "en", "eo", "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", "es", "et", "eu", "ewo", "fa-AF", "fa", "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-Adlm", "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", "ff-Latn", "ff", "fi", "fil", "fo-DK", "fo", "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", "fr", "fur", "fy", "ga-GB", "ga", "gd", "gl", "gsw-FR", "gsw-LI", "gsw", "gu", "guz", "gv", "ha-GH", "ha-NE", "ha", "haw", "he", "hi", "hr-BA", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it-CH", "it-SM", "it-VA", "it", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko-KP", "ko", "kok", "ks-Arab", "ks", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln-AO", "ln-CF", "ln-CG", "ln", "lo", "lrc-IQ", "lrc", "lt", "lu", "luo", "luy", "lv", "mai", "mas-TZ", "mas", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni-Beng", "mni", "mr", "ms-BN", "ms-ID", "ms-SG", "ms", "mt", "mua", "my", "mzn", "naq", "nb-SJ", "nb", "nd", "nds-NL", "nds", "ne-IN", "ne", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nl", "nmg", "nn", "nnh", "no", "nus", "nyn", "om-KE", "om", "or", "os-RU", "os", "pa-Arab", "pa-Guru", "pa", "pcm", "pl", "ps-PK", "ps", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "pt", "qu-BO", "qu-EC", "qu", "rm", "rn", "ro-MD", "ro", "rof", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "ru", "rw", "rwk", "sa", "sah", "saq", "sat-Olck", "sat", "sbp", "sd-Arab", "sd-Deva", "sd", "se-FI", "se-SE", "se", "seh", "ses", "sg", "shi-Latn", "shi-Tfng", "shi", "si", "sk", "sl", "smn", "sn", "so-DJ", "so-ET", "so-KE", "so", "sq-MK", "sq-XK", "sq", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Cyrl", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "sr-Latn", "sr", "su-Latn", "su", "sv-AX", "sv-FI", "sv", "sw-CD", "sw-KE", "sw-UG", "sw", "ta-LK", "ta-MY", "ta-SG", "ta", "te", "teo-KE", "teo", "tg", "th", "ti-ER", "ti", "tk", "to", "tr-CY", "tr", "tt", "twq", "tzm", "ug", "uk", "ur-IN", "ur", "uz-Arab", "uz-Cyrl", "uz-Latn", "uz", "vai-Latn", "vai-Vaii", "vai", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo-BJ", "yo", "yue-Hans", "yue-Hant", "yue", "zgh", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hans", "zh-Hant-HK", "zh-Hant-MO", "zh-Hant", "zh", "zu"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-relativetimeformat",
3
- "version": "9.3.1",
3
+ "version": "9.4.1",
4
4
  "description": "Formats JavaScript dates to relative time strings.",
5
5
  "keywords": [
6
6
  "intl",
@@ -20,8 +20,8 @@
20
20
  "url": "git@github.com:formatjs/formatjs.git"
21
21
  },
22
22
  "dependencies": {
23
- "@formatjs/ecma402-abstract": "1.9.9",
24
- "@formatjs/intl-localematcher": "0.2.21",
23
+ "@formatjs/ecma402-abstract": "1.11.1",
24
+ "@formatjs/intl-localematcher": "0.2.22",
25
25
  "tslib": "^2.1.0"
26
26
  },
27
27
  "main": "index.js",
package/polyfill-force.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var _1 = tslib_1.__importDefault(require("./"));
4
+ var _1 = (0, tslib_1.__importDefault)(require("./"));
5
5
  Object.defineProperty(Intl, 'RelativeTimeFormat', {
6
6
  value: _1.default,
7
7
  writable: true,
package/polyfill.iife.js CHANGED
@@ -8,11 +8,8 @@
8
8
  var __markAsModule = function(target) {
9
9
  return __defProp(target, "__esModule", { value: true });
10
10
  };
11
- var __require = typeof require !== "undefined" ? require : function(x) {
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
13
- };
14
11
  var __commonJS = function(cb, mod) {
15
- return function __require2() {
12
+ return function __require() {
16
13
  return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
14
  };
18
15
  };
@@ -91,7 +88,7 @@
91
88
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
92
89
  var locale = requestedLocales_1[_i];
93
90
  var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
94
- var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
91
+ var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
95
92
  if (availableLocale) {
96
93
  result.locale = availableLocale;
97
94
  if (locale !== noExtensionLocale) {
@@ -116,10 +113,10 @@
116
113
  var BestAvailableLocale_1 = require_BestAvailableLocale();
117
114
  var utils_1 = require_utils();
118
115
  function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
119
- var minimizedAvailableLocaleMap = Array.from(availableLocales).reduce(function(all, l2) {
120
- all[l2] = l2;
121
- return all;
122
- }, {});
116
+ var minimizedAvailableLocaleMap = {};
117
+ availableLocales.forEach(function(l2) {
118
+ return minimizedAvailableLocaleMap[l2] = l2;
119
+ });
123
120
  var minimizedAvailableLocales = new Set();
124
121
  availableLocales.forEach(function(locale2) {
125
122
  var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
@@ -148,7 +145,7 @@
148
145
  foundLocale = minimizedRequestedLocale;
149
146
  break;
150
147
  }
151
- foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
148
+ foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
152
149
  }
153
150
  return {
154
151
  locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
@@ -166,9 +163,9 @@
166
163
  exports.UnicodeExtensionValue = void 0;
167
164
  var utils_1 = require_utils();
168
165
  function UnicodeExtensionValue(extension, key) {
169
- utils_1.invariant(key.length === 2, "key must have 2 elements");
166
+ (0, utils_1.invariant)(key.length === 2, "key must have 2 elements");
170
167
  var size = extension.length;
171
- var searchValue = "-" + key + "-";
168
+ var searchValue = "-".concat(key, "-");
172
169
  var pos = extension.indexOf(searchValue);
173
170
  if (pos !== -1) {
174
171
  var start = pos + 4;
@@ -195,7 +192,7 @@
195
192
  }
196
193
  return extension.slice(start, end);
197
194
  }
198
- searchValue = "-" + key;
195
+ searchValue = "-".concat(key);
199
196
  pos = extension.indexOf(searchValue);
200
197
  if (pos !== -1 && pos + 3 === size) {
201
198
  return "";
@@ -220,40 +217,40 @@
220
217
  var matcher = options.localeMatcher;
221
218
  var r;
222
219
  if (matcher === "lookup") {
223
- r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
220
+ r = (0, LookupMatcher_1.LookupMatcher)(availableLocales, requestedLocales, getDefaultLocale);
224
221
  } else {
225
- r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
222
+ r = (0, BestFitMatcher_1.BestFitMatcher)(availableLocales, requestedLocales, getDefaultLocale);
226
223
  }
227
224
  var foundLocale = r.locale;
228
225
  var result = { locale: "", dataLocale: foundLocale };
229
226
  var supportedExtension = "-u";
230
227
  for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
231
228
  var key = relevantExtensionKeys_1[_i];
232
- utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
229
+ (0, utils_1.invariant)(foundLocale in localeData, "Missing locale data for ".concat(foundLocale));
233
230
  var foundLocaleData = localeData[foundLocale];
234
- utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
231
+ (0, utils_1.invariant)(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data ".concat(key, " must be an object"));
235
232
  var keyLocaleData = foundLocaleData[key];
236
- utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
233
+ (0, utils_1.invariant)(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key, " must be an array"));
237
234
  var value = keyLocaleData[0];
238
- utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
235
+ (0, utils_1.invariant)(typeof value === "string" || value === null, "value must be string or null but got ".concat(typeof value, " in key ").concat(key));
239
236
  var supportedExtensionAddition = "";
240
237
  if (r.extension) {
241
- var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
238
+ var requestedValue = (0, UnicodeExtensionValue_1.UnicodeExtensionValue)(r.extension, key);
242
239
  if (requestedValue !== void 0) {
243
240
  if (requestedValue !== "") {
244
241
  if (~keyLocaleData.indexOf(requestedValue)) {
245
242
  value = requestedValue;
246
- supportedExtensionAddition = "-" + key + "-" + value;
243
+ supportedExtensionAddition = "-".concat(key, "-").concat(value);
247
244
  }
248
245
  } else if (~requestedValue.indexOf("true")) {
249
246
  value = "true";
250
- supportedExtensionAddition = "-" + key;
247
+ supportedExtensionAddition = "-".concat(key);
251
248
  }
252
249
  }
253
250
  }
254
251
  if (key in options) {
255
252
  var optionsValue = options[key];
256
- utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
253
+ (0, utils_1.invariant)(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
257
254
  if (~keyLocaleData.indexOf(optionsValue)) {
258
255
  if (optionsValue !== value) {
259
256
  value = optionsValue;
@@ -295,7 +292,7 @@
295
292
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
296
293
  var locale = requestedLocales_1[_i];
297
294
  var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
298
- var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
295
+ var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
299
296
  if (availableLocale) {
300
297
  subset.push(availableLocale);
301
298
  }
@@ -313,18 +310,18 @@
313
310
  Object.defineProperty(exports, "__esModule", { value: true });
314
311
  exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
315
312
  var ResolveLocale_1 = require_ResolveLocale();
316
- function match(requestedLocales, availableLocales, defaultLocale, opts) {
313
+ function match2(requestedLocales, availableLocales, defaultLocale, opts) {
317
314
  var locales = availableLocales.reduce(function(all, l) {
318
315
  all.add(l);
319
316
  return all;
320
317
  }, new Set());
321
- return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
318
+ return (0, ResolveLocale_1.ResolveLocale)(locales, requestedLocales, {
322
319
  localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
323
320
  }, [], {}, function() {
324
321
  return defaultLocale;
325
322
  }).locale;
326
323
  }
327
- exports.match = match;
324
+ exports.match = match2;
328
325
  var LookupSupportedLocales_1 = require_LookupSupportedLocales();
329
326
  Object.defineProperty(exports, "LookupSupportedLocales", { enumerable: true, get: function() {
330
327
  return LookupSupportedLocales_1.LookupSupportedLocales;
@@ -422,7 +419,7 @@
422
419
  if (values !== void 0 && !values.filter(function(val) {
423
420
  return val == value;
424
421
  }).length) {
425
- throw new RangeError(value + " is not within " + values.join(", "));
422
+ throw new RangeError("".concat(value, " is not within ").concat(values.join(", ")));
426
423
  }
427
424
  return value;
428
425
  }
@@ -494,8 +491,8 @@
494
491
  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]/;
495
492
 
496
493
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/format_to_parts.js
497
- var CARET_S_UNICODE_REGEX = new RegExp("^" + S_UNICODE_REGEX.source);
498
- var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source + "$");
494
+ var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
495
+ var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
499
496
 
500
497
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/InitializeNumberFormat.js
501
498
  var import_intl_localematcher = __toModule(require_intl_localematcher());
@@ -509,7 +506,7 @@
509
506
  var length = pattern.length;
510
507
  while (beginIndex < pattern.length && beginIndex > -1) {
511
508
  endIndex = pattern.indexOf("}", beginIndex);
512
- invariant(endIndex > beginIndex, "Invalid pattern " + pattern);
509
+ invariant(endIndex > beginIndex, "Invalid pattern ".concat(pattern));
513
510
  if (beginIndex > nextIndex) {
514
511
  result.push({
515
512
  type: "literal",
@@ -601,7 +598,7 @@
601
598
  var numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
602
599
  if (numberingSystem !== void 0) {
603
600
  if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
604
- throw new RangeError("Invalid numbering system " + numberingSystem);
601
+ throw new RangeError("Invalid numbering system ".concat(numberingSystem));
605
602
  }
606
603
  }
607
604
  opt.nu = numberingSystem;
@@ -611,7 +608,7 @@
611
608
  internalSlots.style = GetOption(opts, "style", "string", ["long", "narrow", "short"], "long");
612
609
  internalSlots.numeric = GetOption(opts, "numeric", "string", ["always", "auto"], "always");
613
610
  var fields = localeData[r.dataLocale];
614
- invariant(!!fields, "Missing locale data for " + r.dataLocale);
611
+ invariant(!!fields, "Missing locale data for ".concat(r.dataLocale));
615
612
  internalSlots.fields = fields;
616
613
  internalSlots.numberFormat = new Intl.NumberFormat(locales);
617
614
  internalSlots.pluralRules = new Intl.PluralRules(locales);
@@ -656,7 +653,7 @@
656
653
  value: patternPart.value
657
654
  });
658
655
  } else {
659
- invariant(patternPart.type === "0", "Malformed pattern " + pattern);
656
+ invariant(patternPart.type === "0", "Malformed pattern ".concat(pattern));
660
657
  for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
661
658
  var part = parts_1[_a];
662
659
  result.push({
@@ -673,18 +670,18 @@
673
670
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/abstract/PartitionRelativeTimePattern.js
674
671
  function PartitionRelativeTimePattern(rtf, value, unit, _a) {
675
672
  var getInternalSlots2 = _a.getInternalSlots;
676
- invariant(Type(value) === "Number", "value must be number, instead got " + typeof value, TypeError);
677
- invariant(Type(unit) === "String", "unit must be number, instead got " + typeof value, TypeError);
673
+ invariant(Type(value) === "Number", "value must be number, instead got ".concat(typeof value), TypeError);
674
+ invariant(Type(unit) === "String", "unit must be number, instead got ".concat(typeof value), TypeError);
678
675
  if (isNaN(value) || !isFinite(value)) {
679
- throw new RangeError("Invalid value " + value);
676
+ throw new RangeError("Invalid value ".concat(value));
680
677
  }
681
678
  var resolvedUnit = SingularRelativeTimeUnit(unit);
682
679
  var _b = getInternalSlots2(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
683
680
  var entry = resolvedUnit;
684
681
  if (style === "short") {
685
- entry = resolvedUnit + "-short";
682
+ entry = "".concat(resolvedUnit, "-short");
686
683
  } else if (style === "narrow") {
687
- entry = resolvedUnit + "-narrow";
684
+ entry = "".concat(resolvedUnit, "-narrow");
688
685
  }
689
686
  if (!(entry in fields)) {
690
687
  entry = resolvedUnit;
@@ -836,6 +833,12 @@
836
833
  } catch (e) {
837
834
  }
838
835
 
836
+ // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/should-polyfill.js
837
+ var import_intl_localematcher4 = __toModule(require_intl_localematcher());
838
+
839
+ // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/supported-locales.js
840
+ var supportedLocales = ["af-NA", "af", "agq", "ak", "am", "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", "ar", "as", "asa", "ast", "az-Cyrl", "az-Latn", "az", "bas", "be", "bem", "bez", "bg", "bm", "bn-IN", "bn", "bo-IN", "bo", "br", "brx", "bs-Cyrl", "bs-Latn", "bs", "ca-AD", "ca-ES-VALENCIA", "ca-FR", "ca-IT", "ca", "ccp-IN", "ccp", "ce", "ceb", "cgg", "chr", "ckb-IR", "ckb", "cs", "cy", "da-GL", "da", "dav", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "de", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee-TG", "ee", "el-CY", "el", "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-US-POSIX", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "en", "eo", "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", "es", "et", "eu", "ewo", "fa-AF", "fa", "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-Adlm", "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", "ff-Latn", "ff", "fi", "fil", "fo-DK", "fo", "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", "fr", "fur", "fy", "ga-GB", "ga", "gd", "gl", "gsw-FR", "gsw-LI", "gsw", "gu", "guz", "gv", "ha-GH", "ha-NE", "ha", "haw", "he", "hi", "hr-BA", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it-CH", "it-SM", "it-VA", "it", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko-KP", "ko", "kok", "ks-Arab", "ks", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln-AO", "ln-CF", "ln-CG", "ln", "lo", "lrc-IQ", "lrc", "lt", "lu", "luo", "luy", "lv", "mai", "mas-TZ", "mas", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni-Beng", "mni", "mr", "ms-BN", "ms-ID", "ms-SG", "ms", "mt", "mua", "my", "mzn", "naq", "nb-SJ", "nb", "nd", "nds-NL", "nds", "ne-IN", "ne", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nl", "nmg", "nn", "nnh", "no", "nus", "nyn", "om-KE", "om", "or", "os-RU", "os", "pa-Arab", "pa-Guru", "pa", "pcm", "pl", "ps-PK", "ps", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "pt", "qu-BO", "qu-EC", "qu", "rm", "rn", "ro-MD", "ro", "rof", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "ru", "rw", "rwk", "sa", "sah", "saq", "sat-Olck", "sat", "sbp", "sd-Arab", "sd-Deva", "sd", "se-FI", "se-SE", "se", "seh", "ses", "sg", "shi-Latn", "shi-Tfng", "shi", "si", "sk", "sl", "smn", "sn", "so-DJ", "so-ET", "so-KE", "so", "sq-MK", "sq-XK", "sq", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Cyrl", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "sr-Latn", "sr", "su-Latn", "su", "sv-AX", "sv-FI", "sv", "sw-CD", "sw-KE", "sw-UG", "sw", "ta-LK", "ta-MY", "ta-SG", "ta", "te", "teo-KE", "teo", "tg", "th", "ti-ER", "ti", "tk", "to", "tr-CY", "tr", "tt", "twq", "tzm", "ug", "uk", "ur-IN", "ur", "uz-Arab", "uz-Cyrl", "uz-Latn", "uz", "vai-Latn", "vai-Vaii", "vai", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo-BJ", "yo", "yue-Hans", "yue-Hant", "yue", "zgh", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hans", "zh-Hant-HK", "zh-Hant-MO", "zh-Hant", "zh", "zu"];
841
+
839
842
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/should-polyfill.js
840
843
  function supportedLocalesOf(locale) {
841
844
  if (!locale) {
@@ -854,7 +857,12 @@
854
857
  }
855
858
  }
856
859
  function shouldPolyfill(locale) {
857
- return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale);
860
+ if (locale === void 0) {
861
+ locale = "en";
862
+ }
863
+ if (!("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale)) {
864
+ return (0, import_intl_localematcher4.match)([locale], supportedLocales, "en");
865
+ }
858
866
  }
859
867
 
860
868
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/polyfill.js
package/polyfill.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- var _1 = tslib_1.__importDefault(require("./"));
4
+ var _1 = (0, tslib_1.__importDefault)(require("./"));
5
5
  var should_polyfill_1 = require("./should-polyfill");
6
- if (should_polyfill_1.shouldPolyfill()) {
6
+ if ((0, should_polyfill_1.shouldPolyfill)()) {
7
7
  Object.defineProperty(Intl, 'RelativeTimeFormat', {
8
8
  value: _1.default,
9
9
  writable: true,
@@ -1,2 +1,2 @@
1
- export declare function shouldPolyfill(locale?: string | string[]): boolean;
1
+ export declare function shouldPolyfill(locale?: string): string | undefined;
2
2
  //# sourceMappingURL=should-polyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAwBA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAMxD"}
1
+ {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AA2BA,wBAAgB,cAAc,CAAC,MAAM,SAAO,sBAQ3C"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shouldPolyfill = void 0;
4
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
+ var supported_locales_1 = require("./supported-locales");
4
6
  function supportedLocalesOf(locale) {
5
7
  if (!locale) {
6
8
  return true;
@@ -21,8 +23,11 @@ function hasResolvedOptionsNumberingSystem(locale) {
21
23
  }
22
24
  }
23
25
  function shouldPolyfill(locale) {
24
- return (!('RelativeTimeFormat' in Intl) ||
26
+ if (locale === void 0) { locale = 'en'; }
27
+ if (!('RelativeTimeFormat' in Intl) ||
25
28
  !supportedLocalesOf(locale) ||
26
- !hasResolvedOptionsNumberingSystem(locale));
29
+ !hasResolvedOptionsNumberingSystem(locale)) {
30
+ return (0, intl_localematcher_1.match)([locale], supported_locales_1.supportedLocales, 'en');
31
+ }
27
32
  }
28
33
  exports.shouldPolyfill = shouldPolyfill;
@@ -0,0 +1,2 @@
1
+ export declare const supportedLocales: string[];
2
+ //# sourceMappingURL=supported-locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supported-locales.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/supported-locales.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,EAAE,MAAM,EAA+nI,CAAA"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.supportedLocales = void 0;
4
+ // This file is generated from supported-locales-gen.ts
5
+ exports.supportedLocales = ["af-NA", "af", "agq", "ak", "am", "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", "ar", "as", "asa", "ast", "az-Cyrl", "az-Latn", "az", "bas", "be", "bem", "bez", "bg", "bm", "bn-IN", "bn", "bo-IN", "bo", "br", "brx", "bs-Cyrl", "bs-Latn", "bs", "ca-AD", "ca-ES-VALENCIA", "ca-FR", "ca-IT", "ca", "ccp-IN", "ccp", "ce", "ceb", "cgg", "chr", "ckb-IR", "ckb", "cs", "cy", "da-GL", "da", "dav", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "de", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee-TG", "ee", "el-CY", "el", "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-US-POSIX", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "en", "eo", "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", "es", "et", "eu", "ewo", "fa-AF", "fa", "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-Adlm", "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", "ff-Latn", "ff", "fi", "fil", "fo-DK", "fo", "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", "fr", "fur", "fy", "ga-GB", "ga", "gd", "gl", "gsw-FR", "gsw-LI", "gsw", "gu", "guz", "gv", "ha-GH", "ha-NE", "ha", "haw", "he", "hi", "hr-BA", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it-CH", "it-SM", "it-VA", "it", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko-KP", "ko", "kok", "ks-Arab", "ks", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln-AO", "ln-CF", "ln-CG", "ln", "lo", "lrc-IQ", "lrc", "lt", "lu", "luo", "luy", "lv", "mai", "mas-TZ", "mas", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni-Beng", "mni", "mr", "ms-BN", "ms-ID", "ms-SG", "ms", "mt", "mua", "my", "mzn", "naq", "nb-SJ", "nb", "nd", "nds-NL", "nds", "ne-IN", "ne", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nl", "nmg", "nn", "nnh", "no", "nus", "nyn", "om-KE", "om", "or", "os-RU", "os", "pa-Arab", "pa-Guru", "pa", "pcm", "pl", "ps-PK", "ps", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "pt", "qu-BO", "qu-EC", "qu", "rm", "rn", "ro-MD", "ro", "rof", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "ru", "rw", "rwk", "sa", "sah", "saq", "sat-Olck", "sat", "sbp", "sd-Arab", "sd-Deva", "sd", "se-FI", "se-SE", "se", "seh", "ses", "sg", "shi-Latn", "shi-Tfng", "shi", "si", "sk", "sl", "smn", "sn", "so-DJ", "so-ET", "so-KE", "so", "sq-MK", "sq-XK", "sq", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Cyrl", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "sr-Latn", "sr", "su-Latn", "su", "sv-AX", "sv-FI", "sv", "sw-CD", "sw-KE", "sw-UG", "sw", "ta-LK", "ta-MY", "ta-SG", "ta", "te", "teo-KE", "teo", "tg", "th", "ti-ER", "ti", "tk", "to", "tr-CY", "tr", "tt", "twq", "tzm", "ug", "uk", "ur-IN", "ur", "uz-Arab", "uz-Cyrl", "uz-Latn", "uz", "vai-Latn", "vai-Vaii", "vai", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo-BJ", "yo", "yue-Hans", "yue-Hant", "yue", "zgh", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hans", "zh-Hant-HK", "zh-Hant-MO", "zh-Hant", "zh", "zu"];