@formatjs/intl-locale 4.2.12 → 5.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 (39) hide show
  1. package/calendars.generated.js +1 -4
  2. package/character-orders.generated.js +1 -4
  3. package/get_internal_slots.js +1 -4
  4. package/hour-cycles.generated.js +1 -4
  5. package/index.js +105 -108
  6. package/numbering-systems.generated.js +1 -4
  7. package/package.json +11 -5
  8. package/polyfill-force.js +2 -4
  9. package/polyfill.iife.js +8281 -20618
  10. package/polyfill.js +4 -6
  11. package/preference-data.d.ts +1 -1
  12. package/preference-data.js +18 -24
  13. package/should-polyfill.js +2 -5
  14. package/timezones.generated.js +1 -4
  15. package/week-data.generated.js +1 -4
  16. package/lib/calendars.generated.d.ts +0 -55
  17. package/lib/calendars.generated.js +0 -292
  18. package/lib/character-orders.generated.d.ts +0 -729
  19. package/lib/character-orders.generated.js +0 -729
  20. package/lib/get_internal_slots.d.ts +0 -2
  21. package/lib/get_internal_slots.js +0 -19
  22. package/lib/hour-cycles.generated.d.ts +0 -277
  23. package/lib/hour-cycles.generated.js +0 -1041
  24. package/lib/index.d.ts +0 -103
  25. package/lib/index.js +0 -582
  26. package/lib/numbering-systems.generated.d.ts +0 -728
  27. package/lib/numbering-systems.generated.js +0 -2299
  28. package/lib/polyfill-force.d.ts +0 -1
  29. package/lib/polyfill-force.js +0 -7
  30. package/lib/polyfill.d.ts +0 -1
  31. package/lib/polyfill.js +0 -10
  32. package/lib/preference-data.d.ts +0 -6
  33. package/lib/preference-data.js +0 -46
  34. package/lib/should-polyfill.d.ts +0 -1
  35. package/lib/should-polyfill.js +0 -14
  36. package/lib/timezones.generated.d.ts +0 -250
  37. package/lib/timezones.generated.js +0 -966
  38. package/lib/week-data.generated.d.ts +0 -1299
  39. package/lib/week-data.generated.js +0 -2073
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calendars = void 0;
4
1
  /* @generated */
5
2
  // prettier-ignore
6
- exports.calendars = {
3
+ export var calendars = {
7
4
  "001": [
8
5
  "gregorian"
9
6
  ],
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.characterOrders = void 0;
4
1
  /* @generated */
5
2
  // prettier-ignore
6
- exports.characterOrders = {
3
+ export var characterOrders = {
7
4
  "aa": "left-to-right",
8
5
  "aa-DJ": "left-to-right",
9
6
  "aa-ER": "left-to-right",
@@ -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, internalSlotsList) {
4
+ export default function getInternalSlots(x, internalSlotsList) {
8
5
  if (internalSlotsList === void 0) { internalSlotsList = []; }
9
6
  var internalSlots = internalSlotMap.get(x);
10
7
  if (!internalSlots) {
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hourCycles = void 0;
4
1
  /* @generated */
5
2
  // prettier-ignore
6
- exports.hourCycles = {
3
+ export var hourCycles = {
7
4
  "001": [
8
5
  "h23",
9
6
  "h12"
package/index.js CHANGED
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Locale = void 0;
4
- var tslib_1 = require("tslib");
5
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
- var intl_enumerator_1 = require("@formatjs/intl-enumerator");
7
- var intl_getcanonicallocales_1 = require("@formatjs/intl-getcanonicallocales");
8
- var character_orders_generated_1 = require("./character-orders.generated");
9
- var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
10
- var numbering_systems_generated_1 = require("./numbering-systems.generated");
11
- var preference_data_1 = require("./preference-data");
1
+ import { __assign, __spreadArray } from "tslib";
2
+ import { CoerceOptionsToObject, GetOption, HasOwnProperty, SameValue, createDataProperty, invariant, } from '@formatjs/ecma402-abstract';
3
+ import { supportedValuesOf } from '@formatjs/intl-enumerator';
4
+ import { emitUnicodeLanguageId, emitUnicodeLocaleId, isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, likelySubtags, parseUnicodeLanguageId, parseUnicodeLocaleId, } from '@formatjs/intl-getcanonicallocales';
5
+ import { characterOrders } from './character-orders.generated.js';
6
+ import getInternalSlots from './get_internal_slots.js';
7
+ import { numberingSystems } from './numbering-systems.generated.js';
8
+ import { getCalendarPreferenceDataForRegion, getHourCyclesPreferenceDataForLocaleOrRegion, getTimeZonePreferenceForRegion, getWeekDataForRegion, } from './preference-data.js';
12
9
  var ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
13
10
  var RELEVANT_EXTENSION_KEYS = [
14
11
  'ca',
@@ -21,21 +18,21 @@ var RELEVANT_EXTENSION_KEYS = [
21
18
  ];
22
19
  var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
23
20
  function applyOptionsToTag(tag, options) {
24
- (0, ecma402_abstract_1.invariant)(typeof tag === 'string', 'language tag must be a string');
25
- (0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isStructurallyValidLanguageTag)(tag), 'malformed language tag', RangeError);
26
- var language = (0, ecma402_abstract_1.GetOption)(options, 'language', 'string', undefined, undefined);
21
+ invariant(typeof tag === 'string', 'language tag must be a string');
22
+ invariant(isStructurallyValidLanguageTag(tag), 'malformed language tag', RangeError);
23
+ var language = GetOption(options, 'language', 'string', undefined, undefined);
27
24
  if (language !== undefined) {
28
- (0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeLanguageSubtag)(language), 'Malformed unicode_language_subtag', RangeError);
25
+ invariant(isUnicodeLanguageSubtag(language), 'Malformed unicode_language_subtag', RangeError);
29
26
  }
30
- var script = (0, ecma402_abstract_1.GetOption)(options, 'script', 'string', undefined, undefined);
27
+ var script = GetOption(options, 'script', 'string', undefined, undefined);
31
28
  if (script !== undefined) {
32
- (0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeScriptSubtag)(script), 'Malformed unicode_script_subtag', RangeError);
29
+ invariant(isUnicodeScriptSubtag(script), 'Malformed unicode_script_subtag', RangeError);
33
30
  }
34
- var region = (0, ecma402_abstract_1.GetOption)(options, 'region', 'string', undefined, undefined);
31
+ var region = GetOption(options, 'region', 'string', undefined, undefined);
35
32
  if (region !== undefined) {
36
- (0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeRegionSubtag)(region), 'Malformed unicode_region_subtag', RangeError);
33
+ invariant(isUnicodeRegionSubtag(region), 'Malformed unicode_region_subtag', RangeError);
37
34
  }
38
- var languageId = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(tag);
35
+ var languageId = parseUnicodeLanguageId(tag);
39
36
  if (language !== undefined) {
40
37
  languageId.lang = language;
41
38
  }
@@ -45,12 +42,12 @@ function applyOptionsToTag(tag, options) {
45
42
  if (region !== undefined) {
46
43
  languageId.region = region;
47
44
  }
48
- return Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag)), { lang: languageId })))[0];
45
+ return Intl.getCanonicalLocales(emitUnicodeLocaleId(__assign(__assign({}, parseUnicodeLocaleId(tag)), { lang: languageId })))[0];
49
46
  }
50
47
  function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
51
48
  var unicodeExtension;
52
49
  var keywords = [];
53
- var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
50
+ var ast = parseUnicodeLocaleId(tag);
54
51
  for (var _i = 0, _a = ast.extensions; _i < _a.length; _i++) {
55
52
  var ext = _a[_i];
56
53
  if (ext.type === 'u') {
@@ -70,10 +67,10 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
70
67
  value = entry[1];
71
68
  }
72
69
  }
73
- (0, ecma402_abstract_1.invariant)(key in options, "".concat(key, " must be in options"));
70
+ invariant(key in options, "".concat(key, " must be in options"));
74
71
  var optionsValue = options[key];
75
72
  if (optionsValue !== undefined) {
76
- (0, ecma402_abstract_1.invariant)(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
73
+ invariant(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
77
74
  value = optionsValue;
78
75
  if (entry) {
79
76
  entry[1] = value;
@@ -96,7 +93,7 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
96
93
  else {
97
94
  unicodeExtension.keywords = keywords;
98
95
  }
99
- result.locale = Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast))[0];
96
+ result.locale = Intl.getCanonicalLocales(emitUnicodeLocaleId(ast))[0];
100
97
  return result;
101
98
  }
102
99
  function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
@@ -113,45 +110,45 @@ function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
113
110
  lang: !lang || lang === 'und' ? replacement.lang : lang,
114
111
  script: script || replacement.script,
115
112
  region: region || replacement.region,
116
- variants: tslib_1.__spreadArray(tslib_1.__spreadArray([], variants, true), replacement.variants, true),
113
+ variants: __spreadArray(__spreadArray([], variants, true), replacement.variants, true),
117
114
  };
118
115
  }
119
116
  function addLikelySubtags(tag) {
120
- var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
117
+ var ast = parseUnicodeLocaleId(tag);
121
118
  var unicodeLangId = ast.lang;
122
119
  var lang = unicodeLangId.lang, script = unicodeLangId.script, region = unicodeLangId.region, variants = unicodeLangId.variants;
123
120
  if (script && region) {
124
- var match_1 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, region: region, variants: [] })];
121
+ var match_1 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, region: region, variants: [] })];
125
122
  if (match_1) {
126
- var parts_1 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_1);
123
+ var parts_1 = parseUnicodeLanguageId(match_1);
127
124
  ast.lang = mergeUnicodeLanguageId(undefined, undefined, undefined, variants, parts_1);
128
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
125
+ return emitUnicodeLocaleId(ast);
129
126
  }
130
127
  }
131
128
  if (script) {
132
- var match_2 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] })];
129
+ var match_2 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, variants: [] })];
133
130
  if (match_2) {
134
- var parts_2 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_2);
131
+ var parts_2 = parseUnicodeLanguageId(match_2);
135
132
  ast.lang = mergeUnicodeLanguageId(undefined, undefined, region, variants, parts_2);
136
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
133
+ return emitUnicodeLocaleId(ast);
137
134
  }
138
135
  }
139
136
  if (region) {
140
- var match_3 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] })];
137
+ var match_3 = likelySubtags[emitUnicodeLanguageId({ lang: lang, region: region, variants: [] })];
141
138
  if (match_3) {
142
- var parts_3 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_3);
139
+ var parts_3 = parseUnicodeLanguageId(match_3);
143
140
  ast.lang = mergeUnicodeLanguageId(undefined, script, undefined, variants, parts_3);
144
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
141
+ return emitUnicodeLocaleId(ast);
145
142
  }
146
143
  }
147
- var match = intl_getcanonicallocales_1.likelySubtags[lang] ||
148
- intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: 'und', script: script, variants: [] })];
144
+ var match = likelySubtags[lang] ||
145
+ likelySubtags[emitUnicodeLanguageId({ lang: 'und', script: script, variants: [] })];
149
146
  if (!match) {
150
147
  throw new Error("No match for addLikelySubtags");
151
148
  }
152
- var parts = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match);
149
+ var parts = parseUnicodeLanguageId(match);
153
150
  ast.lang = mergeUnicodeLanguageId(undefined, script, region, variants, parts);
154
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
151
+ return emitUnicodeLocaleId(ast);
155
152
  }
156
153
  /**
157
154
  * From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
@@ -162,23 +159,23 @@ function removeLikelySubtags(tag) {
162
159
  if (!maxLocale) {
163
160
  return tag;
164
161
  }
165
- maxLocale = (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)(tslib_1.__assign(tslib_1.__assign({}, (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(maxLocale)), { variants: [] }));
166
- var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
162
+ maxLocale = emitUnicodeLanguageId(__assign(__assign({}, parseUnicodeLanguageId(maxLocale)), { variants: [] }));
163
+ var ast = parseUnicodeLocaleId(tag);
167
164
  var _a = ast.lang, lang = _a.lang, script = _a.script, region = _a.region, variants = _a.variants;
168
- var trial = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, variants: [] }));
165
+ var trial = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, variants: [] }));
169
166
  if (trial === maxLocale) {
170
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
167
+ return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
171
168
  }
172
169
  if (region) {
173
- var trial_1 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] }));
170
+ var trial_1 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, region: region, variants: [] }));
174
171
  if (trial_1 === maxLocale) {
175
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
172
+ return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
176
173
  }
177
174
  }
178
175
  if (script) {
179
- var trial_2 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] }));
176
+ var trial_2 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, script: script, variants: [] }));
180
177
  if (trial_2 === maxLocale) {
181
- return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
178
+ return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
182
179
  }
183
180
  }
184
181
  return tag;
@@ -191,55 +188,55 @@ function createArrayFromListOrRestricted(list, restricted) {
191
188
  return Array.from(result);
192
189
  }
193
190
  function calendarsOfLocale(loc) {
194
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
191
+ var locInternalSlots = getInternalSlots(loc);
195
192
  var restricted = locInternalSlots.calendar;
196
193
  var locale = locInternalSlots.locale;
197
194
  var region;
198
195
  if (locale !== 'root') {
199
196
  region = loc.maximize().region;
200
197
  }
201
- var preferredCalendars = (0, preference_data_1.getCalendarPreferenceDataForRegion)(region);
198
+ var preferredCalendars = getCalendarPreferenceDataForRegion(region);
202
199
  return createArrayFromListOrRestricted(preferredCalendars, restricted);
203
200
  }
204
201
  function collationsOfLocale(loc) {
205
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
202
+ var locInternalSlots = getInternalSlots(loc);
206
203
  var restricted = locInternalSlots.collation;
207
204
  var locale = locInternalSlots.locale;
208
- var supportedCollations = (0, intl_enumerator_1.supportedValuesOf)('collation', locale).filter(function (co) { return co !== 'standard' && co !== 'search'; });
205
+ var supportedCollations = supportedValuesOf('collation', locale).filter(function (co) { return co !== 'standard' && co !== 'search'; });
209
206
  supportedCollations.sort();
210
207
  return createArrayFromListOrRestricted(supportedCollations, restricted);
211
208
  }
212
209
  function hourCyclesOfLocale(loc) {
213
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
210
+ var locInternalSlots = getInternalSlots(loc);
214
211
  var restricted = locInternalSlots.hourCycle;
215
212
  var locale = locInternalSlots.locale;
216
213
  var region;
217
214
  if (locale !== 'root') {
218
215
  region = loc.maximize().region;
219
216
  }
220
- var preferredHourCycles = (0, preference_data_1.getHourCyclesPreferenceDataForLocaleOrRegion)(locale, region);
217
+ var preferredHourCycles = getHourCyclesPreferenceDataForLocaleOrRegion(locale, region);
221
218
  return createArrayFromListOrRestricted(preferredHourCycles, restricted);
222
219
  }
223
220
  function numberingSystemsOfLocale(loc) {
224
221
  var _a;
225
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
222
+ var locInternalSlots = getInternalSlots(loc);
226
223
  var restricted = locInternalSlots.numberingSystem;
227
224
  var locale = locInternalSlots.locale;
228
225
  var language = loc.language;
229
- var localeNumberingSystems = (_a = numbering_systems_generated_1.numberingSystems[locale]) !== null && _a !== void 0 ? _a : numbering_systems_generated_1.numberingSystems[language];
226
+ var localeNumberingSystems = (_a = numberingSystems[locale]) !== null && _a !== void 0 ? _a : numberingSystems[language];
230
227
  if (localeNumberingSystems) {
231
- return createArrayFromListOrRestricted(tslib_1.__spreadArray([], localeNumberingSystems, true), restricted);
228
+ return createArrayFromListOrRestricted(__spreadArray([], localeNumberingSystems, true), restricted);
232
229
  }
233
230
  return createArrayFromListOrRestricted([], restricted);
234
231
  }
235
232
  function timeZonesOfLocale(loc) {
236
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
233
+ var locInternalSlots = getInternalSlots(loc);
237
234
  var locale = locInternalSlots.locale;
238
- var region = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).region;
235
+ var region = parseUnicodeLanguageId(locale).region;
239
236
  if (!region) {
240
237
  return undefined;
241
238
  }
242
- var preferredTimeZones = (0, preference_data_1.getTimeZonePreferenceForRegion)(region);
239
+ var preferredTimeZones = getTimeZonePreferenceForRegion(region);
243
240
  preferredTimeZones.sort();
244
241
  return Array.from(preferredTimeZones);
245
242
  }
@@ -251,16 +248,16 @@ function translateCharacterOrder(order) {
251
248
  }
252
249
  function characterDirectionOfLocale(loc) {
253
250
  var locale = loc.minimize().toString();
254
- return translateCharacterOrder(character_orders_generated_1.characterOrders[locale]);
251
+ return translateCharacterOrder(characterOrders[locale]);
255
252
  }
256
253
  function weekInfoOfLocale(loc) {
257
- var locInternalSlots = (0, get_internal_slots_1.default)(loc);
254
+ var locInternalSlots = getInternalSlots(loc);
258
255
  var locale = locInternalSlots.locale;
259
256
  var region;
260
257
  if (locale !== 'root') {
261
258
  region = loc.maximize().region;
262
259
  }
263
- return (0, preference_data_1.getWeekDataForRegion)(region);
260
+ return getWeekDataForRegion(region);
264
261
  }
265
262
  var TABLE_1 = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
266
263
  function weekdayToString(fw) {
@@ -297,32 +294,32 @@ var Locale = /** @class */ (function () {
297
294
  }
298
295
  var tagInternalSlots;
299
296
  if (typeof tag === 'object' &&
300
- (tagInternalSlots = (0, get_internal_slots_1.default)(tag)) &&
301
- (0, ecma402_abstract_1.HasOwnProperty)(tagInternalSlots, 'initializedLocale')) {
297
+ (tagInternalSlots = getInternalSlots(tag)) &&
298
+ HasOwnProperty(tagInternalSlots, 'initializedLocale')) {
302
299
  tag = tagInternalSlots.locale;
303
300
  }
304
301
  else {
305
302
  tag = tag.toString();
306
303
  }
307
- var internalSlots = (0, get_internal_slots_1.default)(this, internalSlotsList);
308
- var options = (0, ecma402_abstract_1.CoerceOptionsToObject)(opts);
304
+ var internalSlots = getInternalSlots(this, internalSlotsList);
305
+ var options = CoerceOptionsToObject(opts);
309
306
  tag = applyOptionsToTag(tag, options);
310
307
  var opt = Object.create(null);
311
- var calendar = (0, ecma402_abstract_1.GetOption)(options, 'calendar', 'string', undefined, undefined);
308
+ var calendar = GetOption(options, 'calendar', 'string', undefined, undefined);
312
309
  if (calendar !== undefined) {
313
310
  if (!UNICODE_TYPE_REGEX.test(calendar)) {
314
311
  throw new RangeError('invalid calendar');
315
312
  }
316
313
  }
317
314
  opt.ca = calendar;
318
- var collation = (0, ecma402_abstract_1.GetOption)(options, 'collation', 'string', undefined, undefined);
315
+ var collation = GetOption(options, 'collation', 'string', undefined, undefined);
319
316
  if (collation !== undefined) {
320
317
  if (!UNICODE_TYPE_REGEX.test(collation)) {
321
318
  throw new RangeError('invalid collation');
322
319
  }
323
320
  }
324
321
  opt.co = collation;
325
- var fw = (0, ecma402_abstract_1.GetOption)(options, 'firstDayOfWeek', 'string', undefined, undefined);
322
+ var fw = GetOption(options, 'firstDayOfWeek', 'string', undefined, undefined);
326
323
  if (fw !== undefined) {
327
324
  fw = weekdayToString(fw);
328
325
  if (!ALPHANUM_3_8.test(fw)) {
@@ -330,17 +327,17 @@ var Locale = /** @class */ (function () {
330
327
  }
331
328
  }
332
329
  opt.fw = fw;
333
- var hc = (0, ecma402_abstract_1.GetOption)(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
330
+ var hc = GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
334
331
  opt.hc = hc;
335
- var kf = (0, ecma402_abstract_1.GetOption)(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
332
+ var kf = GetOption(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
336
333
  opt.kf = kf;
337
- var _kn = (0, ecma402_abstract_1.GetOption)(options, 'numeric', 'boolean', undefined, undefined);
334
+ var _kn = GetOption(options, 'numeric', 'boolean', undefined, undefined);
338
335
  var kn;
339
336
  if (_kn !== undefined) {
340
337
  kn = String(_kn);
341
338
  }
342
339
  opt.kn = kn;
343
- var numberingSystem = (0, ecma402_abstract_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
340
+ var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
344
341
  if (numberingSystem !== undefined) {
345
342
  if (!UNICODE_TYPE_REGEX.test(numberingSystem)) {
346
343
  throw new RangeError('Invalid numberingSystem');
@@ -357,7 +354,7 @@ var Locale = /** @class */ (function () {
357
354
  internalSlots.caseFirst = r.kf;
358
355
  }
359
356
  if (relevantExtensionKeys.indexOf('kn') > -1) {
360
- internalSlots.numeric = (0, ecma402_abstract_1.SameValue)(r.kn, 'true');
357
+ internalSlots.numeric = SameValue(r.kn, 'true');
361
358
  }
362
359
  internalSlots.numberingSystem = r.nu;
363
360
  }
@@ -365,12 +362,12 @@ var Locale = /** @class */ (function () {
365
362
  * https://www.unicode.org/reports/tr35/#Likely_Subtags
366
363
  */
367
364
  Locale.prototype.maximize = function () {
368
- var locale = (0, get_internal_slots_1.default)(this).locale;
365
+ var locale = getInternalSlots(this).locale;
369
366
  try {
370
367
  var maximizedLocale = addLikelySubtags(locale);
371
368
  return new Locale(maximizedLocale);
372
369
  }
373
- catch (e) {
370
+ catch (_a) {
374
371
  return new Locale(locale);
375
372
  }
376
373
  };
@@ -378,57 +375,57 @@ var Locale = /** @class */ (function () {
378
375
  * https://www.unicode.org/reports/tr35/#Likely_Subtags
379
376
  */
380
377
  Locale.prototype.minimize = function () {
381
- var locale = (0, get_internal_slots_1.default)(this).locale;
378
+ var locale = getInternalSlots(this).locale;
382
379
  try {
383
380
  var minimizedLocale = removeLikelySubtags(locale);
384
381
  return new Locale(minimizedLocale);
385
382
  }
386
- catch (e) {
383
+ catch (_a) {
387
384
  return new Locale(locale);
388
385
  }
389
386
  };
390
387
  Locale.prototype.toString = function () {
391
- return (0, get_internal_slots_1.default)(this).locale;
388
+ return getInternalSlots(this).locale;
392
389
  };
393
390
  Object.defineProperty(Locale.prototype, "baseName", {
394
391
  get: function () {
395
- var locale = (0, get_internal_slots_1.default)(this).locale;
396
- return (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)((0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale));
392
+ var locale = getInternalSlots(this).locale;
393
+ return emitUnicodeLanguageId(parseUnicodeLanguageId(locale));
397
394
  },
398
395
  enumerable: false,
399
396
  configurable: true
400
397
  });
401
398
  Object.defineProperty(Locale.prototype, "calendar", {
402
399
  get: function () {
403
- return (0, get_internal_slots_1.default)(this).calendar;
400
+ return getInternalSlots(this).calendar;
404
401
  },
405
402
  enumerable: false,
406
403
  configurable: true
407
404
  });
408
405
  Object.defineProperty(Locale.prototype, "collation", {
409
406
  get: function () {
410
- return (0, get_internal_slots_1.default)(this).collation;
407
+ return getInternalSlots(this).collation;
411
408
  },
412
409
  enumerable: false,
413
410
  configurable: true
414
411
  });
415
412
  Object.defineProperty(Locale.prototype, "caseFirst", {
416
413
  get: function () {
417
- return (0, get_internal_slots_1.default)(this).caseFirst;
414
+ return getInternalSlots(this).caseFirst;
418
415
  },
419
416
  enumerable: false,
420
417
  configurable: true
421
418
  });
422
419
  Object.defineProperty(Locale.prototype, "numeric", {
423
420
  get: function () {
424
- return (0, get_internal_slots_1.default)(this).numeric;
421
+ return getInternalSlots(this).numeric;
425
422
  },
426
423
  enumerable: false,
427
424
  configurable: true
428
425
  });
429
426
  Object.defineProperty(Locale.prototype, "numberingSystem", {
430
427
  get: function () {
431
- return (0, get_internal_slots_1.default)(this).numberingSystem;
428
+ return getInternalSlots(this).numberingSystem;
432
429
  },
433
430
  enumerable: false,
434
431
  configurable: true
@@ -438,8 +435,8 @@ var Locale = /** @class */ (function () {
438
435
  * https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.language
439
436
  */
440
437
  get: function () {
441
- var locale = (0, get_internal_slots_1.default)(this).locale;
442
- return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).lang;
438
+ var locale = getInternalSlots(this).locale;
439
+ return parseUnicodeLanguageId(locale).lang;
443
440
  },
444
441
  enumerable: false,
445
442
  configurable: true
@@ -449,8 +446,8 @@ var Locale = /** @class */ (function () {
449
446
  * https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.script
450
447
  */
451
448
  get: function () {
452
- var locale = (0, get_internal_slots_1.default)(this).locale;
453
- return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).script;
449
+ var locale = getInternalSlots(this).locale;
450
+ return parseUnicodeLanguageId(locale).script;
454
451
  },
455
452
  enumerable: false,
456
453
  configurable: true
@@ -460,16 +457,16 @@ var Locale = /** @class */ (function () {
460
457
  * https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
461
458
  */
462
459
  get: function () {
463
- var locale = (0, get_internal_slots_1.default)(this).locale;
464
- return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).region;
460
+ var locale = getInternalSlots(this).locale;
461
+ return parseUnicodeLanguageId(locale).region;
465
462
  },
466
463
  enumerable: false,
467
464
  configurable: true
468
465
  });
469
466
  Object.defineProperty(Locale.prototype, "firstDayOfWeek", {
470
467
  get: function () {
471
- var internalSlots = (0, get_internal_slots_1.default)(this);
472
- if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
468
+ var internalSlots = getInternalSlots(this);
469
+ if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
473
470
  throw new TypeError('Error uninitialized locale');
474
471
  }
475
472
  return internalSlots.firstDayOfWeek;
@@ -479,8 +476,8 @@ var Locale = /** @class */ (function () {
479
476
  });
480
477
  Object.defineProperty(Locale.prototype, "hourCycle", {
481
478
  get: function () {
482
- var internalSlots = (0, get_internal_slots_1.default)(this);
483
- if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
479
+ var internalSlots = getInternalSlots(this);
480
+ if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
484
481
  throw new TypeError('Error uninitialized locale');
485
482
  }
486
483
  return internalSlots.hourCycle;
@@ -507,8 +504,8 @@ var Locale = /** @class */ (function () {
507
504
  * https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
508
505
  */
509
506
  Locale.prototype.getHourCycles = function () {
510
- var internalSlots = (0, get_internal_slots_1.default)(this);
511
- if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
507
+ var internalSlots = getInternalSlots(this);
508
+ if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
512
509
  throw new TypeError('Error uninitialized locale');
513
510
  }
514
511
  return hourCyclesOfLocale(this);
@@ -534,7 +531,7 @@ var Locale = /** @class */ (function () {
534
531
  Locale.prototype.getTextInfo = function () {
535
532
  var info = Object.create(Object.prototype);
536
533
  var dir = characterDirectionOfLocale(this);
537
- (0, ecma402_abstract_1.createDataProperty)(info, 'direction', dir);
534
+ createDataProperty(info, 'direction', dir);
538
535
  return info;
539
536
  };
540
537
  /**
@@ -543,15 +540,15 @@ var Locale = /** @class */ (function () {
543
540
  */
544
541
  Locale.prototype.getWeekInfo = function () {
545
542
  var info = Object.create(Object.prototype);
546
- var internalSlots = (0, get_internal_slots_1.default)(this);
547
- if (!(0, ecma402_abstract_1.HasOwnProperty)(internalSlots, 'initializedLocale')) {
543
+ var internalSlots = getInternalSlots(this);
544
+ if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
548
545
  throw new TypeError('Error uninitialized locale');
549
546
  }
550
547
  var wi = weekInfoOfLocale(this);
551
548
  var we = wi.weekend;
552
- (0, ecma402_abstract_1.createDataProperty)(info, 'firstDay', wi.firstDay);
553
- (0, ecma402_abstract_1.createDataProperty)(info, 'weekend', we);
554
- (0, ecma402_abstract_1.createDataProperty)(info, 'minimalDays', wi.minimalDays);
549
+ createDataProperty(info, 'firstDay', wi.firstDay);
550
+ createDataProperty(info, 'weekend', we);
551
+ createDataProperty(info, 'minimalDays', wi.minimalDays);
555
552
  var fw = internalSlots.firstDayOfWeek;
556
553
  if (fw !== undefined) {
557
554
  info.firstDay = fw;
@@ -562,7 +559,7 @@ var Locale = /** @class */ (function () {
562
559
  Locale.polyfilled = true;
563
560
  return Locale;
564
561
  }());
565
- exports.Locale = Locale;
562
+ export { Locale };
566
563
  try {
567
564
  if (typeof Symbol !== 'undefined') {
568
565
  Object.defineProperty(Locale.prototype, Symbol.toStringTag, {
@@ -579,7 +576,7 @@ try {
579
576
  configurable: true,
580
577
  });
581
578
  }
582
- catch (e) {
579
+ catch (_a) {
583
580
  // Meta fix so we're test262-compliant, not important
584
581
  }
585
- exports.default = Locale;
582
+ export default Locale;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.numberingSystems = void 0;
4
1
  /* @generated */
5
2
  // prettier-ignore
6
- exports.numberingSystems = {
3
+ export var numberingSystems = {
7
4
  "aa": [
8
5
  "latn"
9
6
  ],
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@formatjs/intl-locale",
3
3
  "description": "Intl.Locale polyfill",
4
- "version": "4.2.12",
4
+ "version": "5.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-enumerator": "1.8.11",
10
- "@formatjs/intl-getcanonicallocales": "2.5.6",
8
+ "@formatjs/ecma402-abstract": "3.0.0",
9
+ "@formatjs/intl-enumerator": "2.0.0",
10
+ "@formatjs/intl-getcanonicallocales": "3.0.0",
11
11
  "tslib": "^2.8.0"
12
12
  },
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./polyfill.js": "./polyfill.js",
16
+ "./polyfill-force.js": "./polyfill-force.js",
17
+ "./should-polyfill.js": "./should-polyfill.js"
18
+ },
13
19
  "homepage": "https://github.com/formatjs/formatjs#readme",
14
20
  "keywords": [
15
21
  "ecma402",
@@ -21,7 +27,7 @@
21
27
  "tc39"
22
28
  ],
23
29
  "license": "MIT",
24
- "main": "index.js",
25
30
  "repository": "formatjs/formatjs.git",
31
+ "type": "module",
26
32
  "types": "index.d.ts"
27
33
  }
package/polyfill-force.js CHANGED
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var _1 = require("./");
1
+ import { Locale } from './index.js';
4
2
  Object.defineProperty(Intl, 'Locale', {
5
- value: _1.Locale,
3
+ value: Locale,
6
4
  writable: true,
7
5
  enumerable: false,
8
6
  configurable: true,