@formatjs/intl-displaynames 6.6.0 → 6.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +4 -4
  3. package/lib/abstract/CanonicalCodeForDisplayNames.js +11 -7
  4. package/lib/abstract/IsValidDateTimeFieldCode.js +5 -1
  5. package/lib/index.d.ts +1 -1
  6. package/lib/index.js +33 -30
  7. package/lib/polyfill-force.js +4 -2
  8. package/lib/polyfill.js +6 -4
  9. package/lib/should-polyfill.js +10 -5
  10. package/lib/supported-locales.generated.js +4 -1
  11. package/locale-data/af-NA.js +1548 -0
  12. package/locale-data/af.js +1548 -0
  13. package/locale-data/am.js +1687 -0
  14. package/locale-data/as.js +1527 -0
  15. package/locale-data/be-tarask.js +1580 -0
  16. package/locale-data/be.js +1580 -0
  17. package/locale-data/bg.js +1912 -0
  18. package/locale-data/br.js +1970 -0
  19. package/locale-data/bs-Latn.js +2043 -0
  20. package/locale-data/bs.js +2043 -0
  21. package/locale-data/ca-AD.js +2119 -0
  22. package/locale-data/ca-ES-valencia.js +2119 -0
  23. package/locale-data/ca-FR.js +2119 -0
  24. package/locale-data/ca-IT.js +2119 -0
  25. package/locale-data/ca.js +2119 -0
  26. package/locale-data/ccp-IN.js +1856 -0
  27. package/locale-data/ccp.js +1856 -0
  28. package/locale-data/ce.js +1409 -0
  29. package/locale-data/ceb.js +659 -0
  30. package/locale-data/chr.js +1528 -0
  31. package/locale-data/cs.js +2204 -0
  32. package/locale-data/cy.js +1916 -0
  33. package/locale-data/doi.js +290 -0
  34. package/locale-data/dsb.js +1568 -0
  35. package/locale-data/dz.js +851 -0
  36. package/locale-data/ee-TG.js +1093 -0
  37. package/locale-data/ee.js +1093 -0
  38. package/locale-data/ff-Adlm-BF.js +1671 -0
  39. package/locale-data/ff-Adlm-CM.js +1671 -0
  40. package/locale-data/ff-Adlm-GH.js +1671 -0
  41. package/locale-data/ff-Adlm-GM.js +1671 -0
  42. package/locale-data/ff-Adlm-GW.js +1671 -0
  43. package/locale-data/ff-Adlm-LR.js +1671 -0
  44. package/locale-data/ff-Adlm-MR.js +1671 -0
  45. package/locale-data/ff-Adlm-NE.js +1671 -0
  46. package/locale-data/ff-Adlm-NG.js +1671 -0
  47. package/locale-data/ff-Adlm-SL.js +1672 -0
  48. package/locale-data/ff-Adlm-SN.js +1671 -0
  49. package/locale-data/ff-Adlm.js +1671 -0
  50. package/locale-data/fil.js +1553 -0
  51. package/locale-data/fo-DK.js +1455 -0
  52. package/locale-data/fo.js +1455 -0
  53. package/locale-data/fur.js +979 -0
  54. package/locale-data/ga-GB.js +1812 -0
  55. package/locale-data/ga.js +1812 -0
  56. package/locale-data/gsw-FR.js +1677 -0
  57. package/locale-data/gsw-LI.js +1677 -0
  58. package/locale-data/gsw.js +1677 -0
  59. package/locale-data/gu.js +1862 -0
  60. package/locale-data/ha-GH.js +1518 -0
  61. package/locale-data/ha-NE.js +1518 -0
  62. package/locale-data/ha.js +1518 -0
  63. package/locale-data/hi.js +1865 -0
  64. package/locale-data/hr-BA.js +2034 -0
  65. package/locale-data/hr.js +2034 -0
  66. package/locale-data/hsb.js +1568 -0
  67. package/locale-data/hy.js +1686 -0
  68. package/locale-data/ia.js +1495 -0
  69. package/locale-data/ig.js +1502 -0
  70. package/locale-data/ii.js +259 -0
  71. package/locale-data/jgo.js +316 -0
  72. package/locale-data/jv.js +1506 -0
  73. package/locale-data/kea.js +1068 -0
  74. package/locale-data/kk.js +1651 -0
  75. package/locale-data/km.js +1571 -0
  76. package/locale-data/kn.js +1842 -0
  77. package/locale-data/kok.js +1536 -0
  78. package/locale-data/ks-Arab.js +1677 -0
  79. package/locale-data/ks.js +1677 -0
  80. package/locale-data/ksh.js +1333 -0
  81. package/locale-data/ku.js +951 -0
  82. package/locale-data/ky.js +1528 -0
  83. package/locale-data/lrc-IQ.js +748 -0
  84. package/locale-data/lrc.js +748 -0
  85. package/locale-data/mai.js +1441 -0
  86. package/locale-data/mgo.js +224 -0
  87. package/locale-data/mi.js +1320 -0
  88. package/locale-data/mn.js +1660 -0
  89. package/locale-data/mni-Beng.js +321 -0
  90. package/locale-data/mni.js +321 -0
  91. package/locale-data/mr.js +1841 -0
  92. package/locale-data/ms-BN.js +1738 -0
  93. package/locale-data/ms-ID.js +1738 -0
  94. package/locale-data/ms-SG.js +1738 -0
  95. package/locale-data/ms.js +1738 -0
  96. package/locale-data/mt.js +1588 -0
  97. package/locale-data/ne-IN.js +1922 -0
  98. package/locale-data/ne.js +1922 -0
  99. package/locale-data/or.js +1820 -0
  100. package/locale-data/os-RU.js +390 -0
  101. package/locale-data/os.js +390 -0
  102. package/locale-data/pa-Guru.js +1584 -0
  103. package/locale-data/pa.js +1584 -0
  104. package/locale-data/pcm.js +1501 -0
  105. package/locale-data/ps-PK.js +1527 -0
  106. package/locale-data/ps.js +1527 -0
  107. package/locale-data/qu-BO.js +1487 -0
  108. package/locale-data/qu-EC.js +1487 -0
  109. package/locale-data/qu.js +1487 -0
  110. package/locale-data/sa.js +297 -0
  111. package/locale-data/sah.js +371 -0
  112. package/locale-data/sat-Olck.js +325 -0
  113. package/locale-data/sat.js +325 -0
  114. package/locale-data/sd-Arab.js +1529 -0
  115. package/locale-data/sd-Deva.js +289 -0
  116. package/locale-data/sd.js +1529 -0
  117. package/locale-data/se-FI.js +778 -0
  118. package/locale-data/se-SE.js +736 -0
  119. package/locale-data/se.js +736 -0
  120. package/locale-data/si.js +1547 -0
  121. package/locale-data/so-DJ.js +1634 -0
  122. package/locale-data/so-ET.js +1634 -0
  123. package/locale-data/so-KE.js +1634 -0
  124. package/locale-data/so.js +1634 -0
  125. package/locale-data/sq-MK.js +1671 -0
  126. package/locale-data/sq-XK.js +1671 -0
  127. package/locale-data/sq.js +1671 -0
  128. package/locale-data/su-Latn.js +289 -0
  129. package/locale-data/su.js +289 -0
  130. package/locale-data/sw-CD.js +1603 -0
  131. package/locale-data/sw-KE.js +1617 -0
  132. package/locale-data/sw-UG.js +1603 -0
  133. package/locale-data/sw.js +1603 -0
  134. package/locale-data/ta-LK.js +1856 -0
  135. package/locale-data/ta-MY.js +1856 -0
  136. package/locale-data/ta-SG.js +1856 -0
  137. package/locale-data/ta.js +1856 -0
  138. package/locale-data/te.js +1853 -0
  139. package/locale-data/tg.js +809 -0
  140. package/locale-data/tk.js +1509 -0
  141. package/locale-data/to.js +2000 -0
  142. package/locale-data/tt.js +785 -0
  143. package/locale-data/ur-IN.js +1562 -0
  144. package/locale-data/ur.js +1562 -0
  145. package/locale-data/uz-Cyrl.js +1164 -0
  146. package/locale-data/uz-Latn.js +1542 -0
  147. package/locale-data/uz.js +1542 -0
  148. package/locale-data/wae.js +833 -0
  149. package/locale-data/wo.js +803 -0
  150. package/locale-data/xh.js +665 -0
  151. package/locale-data/yi.js +748 -0
  152. package/locale-data/yo-BJ.js +1505 -0
  153. package/locale-data/yo.js +1505 -0
  154. package/locale-data/yue-Hans.js +2172 -0
  155. package/locale-data/yue-Hant.js +2172 -0
  156. package/locale-data/yue.js +2172 -0
  157. package/locale-data/zh-Hant-HK.js +2218 -0
  158. package/locale-data/zh-Hant-MO.js +2218 -0
  159. package/locale-data/zh-Hant.js +2186 -0
  160. package/locale-data/zu.js +1670 -0
  161. package/package.json +4 -4
  162. package/polyfill.iife.js +7947 -695
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DisplayNamesLocaleData, DisplayNamesData } from '@formatjs/ecma402-abstract';
1
+ import { DisplayNamesData, DisplayNamesLocaleData } from '@formatjs/ecma402-abstract';
2
2
  export interface DisplayNamesOptions {
3
3
  localeMatcher?: 'lookup' | 'best fit';
4
4
  style?: 'narrow' | 'short' | 'long';
package/index.js CHANGED
@@ -6,7 +6,7 @@ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
6
  var CanonicalCodeForDisplayNames_1 = require("./abstract/CanonicalCodeForDisplayNames");
7
7
  var IsValidDateTimeFieldCode_1 = require("./abstract/IsValidDateTimeFieldCode");
8
8
  var intl_localematcher_1 = require("@formatjs/intl-localematcher");
9
- var DisplayNames = exports.DisplayNames = /** @class */ (function () {
9
+ var DisplayNames = /** @class */ (function () {
10
10
  function DisplayNames(locales, options) {
11
11
  var _newTarget = this.constructor;
12
12
  if (_newTarget === undefined) {
@@ -18,7 +18,7 @@ var DisplayNames = exports.DisplayNames = /** @class */ (function () {
18
18
  var localeData = DisplayNames.localeData;
19
19
  var matcher = (0, ecma402_abstract_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
20
20
  opt.localeMatcher = matcher;
21
- var r = (0, intl_localematcher_1.ResolveLocale)(DisplayNames.availableLocales, requestedLocales, opt, [], // there is no relevantExtensionKeys
21
+ var r = (0, intl_localematcher_1.ResolveLocale)(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], // there is no relevantExtensionKeys
22
22
  DisplayNames.localeData, DisplayNames.getDefaultLocale);
23
23
  var style = (0, ecma402_abstract_1.GetOption)(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
24
24
  setSlot(this, 'style', style);
@@ -75,14 +75,13 @@ var DisplayNames = exports.DisplayNames = /** @class */ (function () {
75
75
  }
76
76
  };
77
77
  DisplayNames.prototype.of = function (code) {
78
- var _a;
79
78
  checkReceiver(this, 'of');
80
79
  var type = getSlot(this, 'type');
81
80
  var codeAsString = (0, ecma402_abstract_1.ToString)(code);
82
81
  if (!isValidCodeForDisplayNames(type, codeAsString)) {
83
82
  throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
84
83
  }
85
- var localeData = (_a = (0, ecma402_abstract_1.getMultiInternalSlots)(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), _a.localeData), style = _a.style, fallback = _a.fallback;
84
+ var _a = (0, ecma402_abstract_1.getMultiInternalSlots)(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
86
85
  // Canonicalize the case.
87
86
  var canonicalCode = (0, CanonicalCodeForDisplayNames_1.CanonicalCodeForDisplayNames)(type, codeAsString);
88
87
  var name;
@@ -115,6 +114,7 @@ var DisplayNames = exports.DisplayNames = /** @class */ (function () {
115
114
  DisplayNames.polyfilled = true;
116
115
  return DisplayNames;
117
116
  }());
117
+ exports.DisplayNames = DisplayNames;
118
118
  // https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
119
119
  function isValidCodeForDisplayNames(type, code) {
120
120
  switch (type) {
@@ -1,5 +1,8 @@
1
- import { CanonicalizeLocaleList, invariant, IsWellFormedCurrencyCode, } from '@formatjs/ecma402-abstract';
2
- import { IsValidDateTimeFieldCode } from './IsValidDateTimeFieldCode';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanonicalCodeForDisplayNames = void 0;
4
+ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
+ var IsValidDateTimeFieldCode_1 = require("./IsValidDateTimeFieldCode");
3
6
  var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
4
7
  var ALPHA_4 = /^[a-z]{4}$/i;
5
8
  var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
@@ -12,9 +15,9 @@ function isUnicodeScriptSubtag(script) {
12
15
  function isUnicodeLocaleIdentifierType(code) {
13
16
  return UNICODE_TYPE_REGEX.test(code);
14
17
  }
15
- export function CanonicalCodeForDisplayNames(type, code) {
18
+ function CanonicalCodeForDisplayNames(type, code) {
16
19
  if (type === 'language') {
17
- return CanonicalizeLocaleList([code])[0];
20
+ return (0, ecma402_abstract_1.CanonicalizeLocaleList)([code])[0];
18
21
  }
19
22
  if (type === 'region') {
20
23
  if (!isUnicodeRegionSubtag(code)) {
@@ -35,14 +38,15 @@ export function CanonicalCodeForDisplayNames(type, code) {
35
38
  return code.toLowerCase();
36
39
  }
37
40
  if (type === 'dateTimeField') {
38
- if (!IsValidDateTimeFieldCode(code)) {
41
+ if (!(0, IsValidDateTimeFieldCode_1.IsValidDateTimeFieldCode)(code)) {
39
42
  throw RangeError('invalid dateTimeField');
40
43
  }
41
44
  return code;
42
45
  }
43
- invariant(type === 'currency', 'invalid type');
44
- if (!IsWellFormedCurrencyCode(code)) {
46
+ (0, ecma402_abstract_1.invariant)(type === 'currency', 'invalid type');
47
+ if (!(0, ecma402_abstract_1.IsWellFormedCurrencyCode)(code)) {
45
48
  throw RangeError('invalid currency');
46
49
  }
47
50
  return code.toUpperCase();
48
51
  }
52
+ exports.CanonicalCodeForDisplayNames = CanonicalCodeForDisplayNames;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsValidDateTimeFieldCode = void 0;
1
4
  var CODES_FOR_DATE_TIME_FIELD = [
2
5
  'era',
3
6
  'year',
@@ -12,6 +15,7 @@ var CODES_FOR_DATE_TIME_FIELD = [
12
15
  'second',
13
16
  'timeZoneName',
14
17
  ];
15
- export function IsValidDateTimeFieldCode(field) {
18
+ function IsValidDateTimeFieldCode(field) {
16
19
  return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
17
20
  }
21
+ exports.IsValidDateTimeFieldCode = IsValidDateTimeFieldCode;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DisplayNamesLocaleData, DisplayNamesData } from '@formatjs/ecma402-abstract';
1
+ import { DisplayNamesData, DisplayNamesLocaleData } from '@formatjs/ecma402-abstract';
2
2
  export interface DisplayNamesOptions {
3
3
  localeMatcher?: 'lookup' | 'best fit';
4
4
  style?: 'narrow' | 'short' | 'long';
package/lib/index.js CHANGED
@@ -1,57 +1,60 @@
1
- import { __assign } from "tslib";
2
- import { getInternalSlot, setInternalSlot, GetOption, invariant, SupportedLocales, IsWellFormedCurrencyCode, getMultiInternalSlots, ToString, CanonicalizeLocaleList, GetOptionsObject, } from '@formatjs/ecma402-abstract';
3
- import { CanonicalCodeForDisplayNames } from './abstract/CanonicalCodeForDisplayNames';
4
- import { IsValidDateTimeFieldCode } from './abstract/IsValidDateTimeFieldCode';
5
- import { ResolveLocale } from '@formatjs/intl-localematcher';
6
- export var DisplayNames = /** @class */ (function () {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisplayNames = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
+ var CanonicalCodeForDisplayNames_1 = require("./abstract/CanonicalCodeForDisplayNames");
7
+ var IsValidDateTimeFieldCode_1 = require("./abstract/IsValidDateTimeFieldCode");
8
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
9
+ var DisplayNames = /** @class */ (function () {
7
10
  function DisplayNames(locales, options) {
8
11
  var _newTarget = this.constructor;
9
12
  if (_newTarget === undefined) {
10
13
  throw TypeError("Constructor Intl.DisplayNames requires 'new'");
11
14
  }
12
- var requestedLocales = CanonicalizeLocaleList(locales);
13
- options = GetOptionsObject(options);
15
+ var requestedLocales = (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales);
16
+ options = (0, ecma402_abstract_1.GetOptionsObject)(options);
14
17
  var opt = Object.create(null);
15
18
  var localeData = DisplayNames.localeData;
16
- var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
19
+ var matcher = (0, ecma402_abstract_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
17
20
  opt.localeMatcher = matcher;
18
- var r = ResolveLocale(DisplayNames.availableLocales, requestedLocales, opt, [], // there is no relevantExtensionKeys
21
+ var r = (0, intl_localematcher_1.ResolveLocale)(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], // there is no relevantExtensionKeys
19
22
  DisplayNames.localeData, DisplayNames.getDefaultLocale);
20
- var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
23
+ var style = (0, ecma402_abstract_1.GetOption)(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
21
24
  setSlot(this, 'style', style);
22
- var type = GetOption(options, 'type', 'string', ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'], undefined);
25
+ var type = (0, ecma402_abstract_1.GetOption)(options, 'type', 'string', ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'], undefined);
23
26
  if (type === undefined) {
24
27
  throw TypeError("Intl.DisplayNames constructor requires \"type\" option");
25
28
  }
26
29
  setSlot(this, 'type', type);
27
- var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
30
+ var fallback = (0, ecma402_abstract_1.GetOption)(options, 'fallback', 'string', ['code', 'none'], 'code');
28
31
  setSlot(this, 'fallback', fallback);
29
32
  setSlot(this, 'locale', r.locale);
30
33
  var dataLocale = r.dataLocale;
31
34
  var dataLocaleData = localeData[dataLocale];
32
- invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
35
+ (0, ecma402_abstract_1.invariant)(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
33
36
  setSlot(this, 'localeData', dataLocaleData);
34
- invariant(dataLocaleData !== undefined, "locale data for ".concat(r.locale, " does not exist."));
37
+ (0, ecma402_abstract_1.invariant)(dataLocaleData !== undefined, "locale data for ".concat(r.locale, " does not exist."));
35
38
  var types = dataLocaleData.types;
36
- invariant(typeof types === 'object' && types != null, 'invalid types data');
39
+ (0, ecma402_abstract_1.invariant)(typeof types === 'object' && types != null, 'invalid types data');
37
40
  var typeFields = types[type];
38
- invariant(typeof typeFields === 'object' && typeFields != null, 'invalid typeFields data');
39
- var languageDisplay = GetOption(options, 'languageDisplay', 'string', ['dialect', 'standard'], 'dialect');
41
+ (0, ecma402_abstract_1.invariant)(typeof typeFields === 'object' && typeFields != null, 'invalid typeFields data');
42
+ var languageDisplay = (0, ecma402_abstract_1.GetOption)(options, 'languageDisplay', 'string', ['dialect', 'standard'], 'dialect');
40
43
  if (type === 'language') {
41
44
  setSlot(this, 'languageDisplay', languageDisplay);
42
45
  // Using types[type] instead of typeFields because TypeScript cannot infer the correct type
43
46
  var typeFields_1 = types[type][languageDisplay];
44
- invariant(typeof typeFields_1 === 'object' && typeFields_1 != null, 'invalid language typeFields data');
47
+ (0, ecma402_abstract_1.invariant)(typeof typeFields_1 === 'object' && typeFields_1 != null, 'invalid language typeFields data');
45
48
  }
46
49
  // Using types[type] instead of typeFields because TypeScript cannot infer the correct type
47
50
  var styleFields = type === 'language'
48
51
  ? types[type][languageDisplay][style]
49
52
  : types[type][style];
50
- invariant(typeof styleFields === 'object' && styleFields != null, 'invalid styleFields data');
53
+ (0, ecma402_abstract_1.invariant)(typeof styleFields === 'object' && styleFields != null, 'invalid styleFields data');
51
54
  setSlot(this, 'fields', styleFields);
52
55
  }
53
56
  DisplayNames.supportedLocalesOf = function (locales, options) {
54
- return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
57
+ return (0, ecma402_abstract_1.SupportedLocales)(DisplayNames.availableLocales, (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales), options);
55
58
  };
56
59
  DisplayNames.__addLocaleData = function () {
57
60
  var data = [];
@@ -72,16 +75,15 @@ export var DisplayNames = /** @class */ (function () {
72
75
  }
73
76
  };
74
77
  DisplayNames.prototype.of = function (code) {
75
- var _a;
76
78
  checkReceiver(this, 'of');
77
79
  var type = getSlot(this, 'type');
78
- var codeAsString = ToString(code);
80
+ var codeAsString = (0, ecma402_abstract_1.ToString)(code);
79
81
  if (!isValidCodeForDisplayNames(type, codeAsString)) {
80
82
  throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
81
83
  }
82
- var localeData = (_a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), _a.localeData), style = _a.style, fallback = _a.fallback;
84
+ var _a = (0, ecma402_abstract_1.getMultiInternalSlots)(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
83
85
  // Canonicalize the case.
84
- var canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
86
+ var canonicalCode = (0, CanonicalCodeForDisplayNames_1.CanonicalCodeForDisplayNames)(type, codeAsString);
85
87
  var name;
86
88
  if (type === 'language') {
87
89
  var languageDisplay = getSlot(this, 'languageDisplay');
@@ -101,7 +103,7 @@ export var DisplayNames = /** @class */ (function () {
101
103
  };
102
104
  DisplayNames.prototype.resolvedOptions = function () {
103
105
  checkReceiver(this, 'resolvedOptions');
104
- return __assign({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback', 'languageDisplay'));
106
+ return tslib_1.__assign({}, (0, ecma402_abstract_1.getMultiInternalSlots)(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback', 'languageDisplay'));
105
107
  };
106
108
  DisplayNames.getDefaultLocale = function () {
107
109
  return DisplayNames.__defaultLocale;
@@ -112,6 +114,7 @@ export var DisplayNames = /** @class */ (function () {
112
114
  DisplayNames.polyfilled = true;
113
115
  return DisplayNames;
114
116
  }());
117
+ exports.DisplayNames = DisplayNames;
115
118
  // https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
116
119
  function isValidCodeForDisplayNames(type, code) {
117
120
  switch (type) {
@@ -130,12 +133,12 @@ function isValidCodeForDisplayNames(type, code) {
130
133
  // unicode_script_subtag
131
134
  return /^[a-z]{4}$/i.test(code);
132
135
  case 'currency':
133
- return IsWellFormedCurrencyCode(code);
136
+ return (0, ecma402_abstract_1.IsWellFormedCurrencyCode)(code);
134
137
  case 'calendar':
135
138
  // unicode locale identifier type
136
139
  return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
137
140
  case 'dateTimeField':
138
- return IsValidDateTimeFieldCode(code);
141
+ return (0, IsValidDateTimeFieldCode_1.IsValidDateTimeFieldCode)(code);
139
142
  }
140
143
  }
141
144
  try {
@@ -160,10 +163,10 @@ catch (e) {
160
163
  }
161
164
  var __INTERNAL_SLOT_MAP__ = new WeakMap();
162
165
  function getSlot(instance, key) {
163
- return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
166
+ return (0, ecma402_abstract_1.getInternalSlot)(__INTERNAL_SLOT_MAP__, instance, key);
164
167
  }
165
168
  function setSlot(instance, key, value) {
166
- setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
169
+ (0, ecma402_abstract_1.setInternalSlot)(__INTERNAL_SLOT_MAP__, instance, key, value);
167
170
  }
168
171
  function checkReceiver(receiver, methodName) {
169
172
  if (!(receiver instanceof DisplayNames)) {
@@ -1,6 +1,8 @@
1
- import { DisplayNames } from './';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _1 = require("./");
2
4
  Object.defineProperty(Intl, 'DisplayNames', {
3
- value: DisplayNames,
5
+ value: _1.DisplayNames,
4
6
  enumerable: false,
5
7
  writable: true,
6
8
  configurable: true,
package/lib/polyfill.js CHANGED
@@ -1,8 +1,10 @@
1
- import { DisplayNames } from './';
2
- import { shouldPolyfill } from './should-polyfill';
3
- if (shouldPolyfill()) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _1 = require("./");
4
+ var should_polyfill_1 = require("./should-polyfill");
5
+ if ((0, should_polyfill_1.shouldPolyfill)()) {
4
6
  Object.defineProperty(Intl, 'DisplayNames', {
5
- value: DisplayNames,
7
+ value: _1.DisplayNames,
6
8
  enumerable: false,
7
9
  writable: true,
8
10
  configurable: true,
@@ -1,5 +1,8 @@
1
- import { match } from '@formatjs/intl-localematcher';
2
- import { supportedLocales } from './supported-locales.generated';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldPolyfill = exports._shouldPolyfillWithoutLocale = void 0;
4
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
+ var supported_locales_generated_1 = require("./supported-locales.generated");
3
6
  /**
4
7
  * https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
5
8
  */
@@ -32,17 +35,19 @@ function supportedLocalesOf(locale) {
32
35
  return (Intl.DisplayNames.supportedLocalesOf(locales).length ===
33
36
  locales.length);
34
37
  }
35
- export function _shouldPolyfillWithoutLocale() {
38
+ function _shouldPolyfillWithoutLocale() {
36
39
  return !Intl.DisplayNames || hasMissingICUBug() || hasScriptBug();
37
40
  }
38
- export function shouldPolyfill(locale) {
41
+ exports._shouldPolyfillWithoutLocale = _shouldPolyfillWithoutLocale;
42
+ function shouldPolyfill(locale) {
39
43
  if (locale === void 0) { locale = 'en'; }
40
44
  try {
41
45
  if (_shouldPolyfillWithoutLocale() || !supportedLocalesOf(locale)) {
42
- return match([locale], supportedLocales, 'en');
46
+ return (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en');
43
47
  }
44
48
  }
45
49
  catch (e) {
46
50
  return true;
47
51
  }
48
52
  }
53
+ exports.shouldPolyfill = shouldPolyfill;
@@ -1 +1,4 @@
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
+ "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"];