@formatjs/intl-pluralrules 5.3.4 → 5.3.5

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.
@@ -47,4 +47,3 @@ function GetOperands(s) {
47
47
  FractionDigitsWithoutTrailing: t,
48
48
  };
49
49
  }
50
- //# sourceMappingURL=GetOperands.js.map
@@ -18,4 +18,3 @@ function InitializePluralRules(pl, locales, options, _a) {
18
18
  internalSlots.locale = r.locale;
19
19
  return pl;
20
20
  }
21
- //# sourceMappingURL=InitializePluralRules.js.map
@@ -24,4 +24,3 @@ function ResolvePlural(pl, n, _a) {
24
24
  var operands = (0, GetOperands_1.GetOperands)(s);
25
25
  return PluralRuleSelect(locale, type, n, operands);
26
26
  }
27
- //# sourceMappingURL=ResolvePlural.js.map
@@ -10,4 +10,3 @@ function getInternalSlots(x) {
10
10
  }
11
11
  return internalSlots;
12
12
  }
13
- //# sourceMappingURL=get_internal_slots.js.map
package/index.js CHANGED
@@ -145,4 +145,3 @@ try {
145
145
  catch (ex) {
146
146
  // Meta fixes for test262
147
147
  }
148
- //# sourceMappingURL=index.js.map
@@ -44,4 +44,3 @@ export function GetOperands(s) {
44
44
  FractionDigitsWithoutTrailing: t,
45
45
  };
46
46
  }
47
- //# sourceMappingURL=GetOperands.js.map
@@ -15,4 +15,3 @@ export function InitializePluralRules(pl, locales, options, _a) {
15
15
  internalSlots.locale = r.locale;
16
16
  return pl;
17
17
  }
18
- //# sourceMappingURL=InitializePluralRules.js.map
@@ -21,4 +21,3 @@ export function ResolvePlural(pl, n, _a) {
21
21
  var operands = GetOperands(s);
22
22
  return PluralRuleSelect(locale, type, n, operands);
23
23
  }
24
- //# sourceMappingURL=ResolvePlural.js.map
@@ -7,4 +7,3 @@ export default function getInternalSlots(x) {
7
7
  }
8
8
  return internalSlots;
9
9
  }
10
- //# sourceMappingURL=get_internal_slots.js.map
package/lib/index.js CHANGED
@@ -142,4 +142,3 @@ try {
142
142
  catch (ex) {
143
143
  // Meta fixes for test262
144
144
  }
145
- //# sourceMappingURL=index.js.map
@@ -5,4 +5,3 @@ Object.defineProperty(Intl, 'PluralRules', {
5
5
  enumerable: false,
6
6
  configurable: true,
7
7
  });
8
- //# sourceMappingURL=polyfill-force.js.map
package/lib/polyfill.js CHANGED
@@ -8,4 +8,3 @@ if (shouldPolyfill()) {
8
8
  configurable: true,
9
9
  });
10
10
  }
11
- //# sourceMappingURL=polyfill.js.map
@@ -16,4 +16,3 @@ export function shouldPolyfill(locale) {
16
16
  return locale ? match([locale], supportedLocales, 'en') : undefined;
17
17
  }
18
18
  }
19
- //# sourceMappingURL=should-polyfill.js.map
@@ -1,2 +1 @@
1
1
  export var supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
2
- //# sourceMappingURL=supported-locales.generated.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-pluralrules",
3
- "version": "5.3.4",
3
+ "version": "5.3.5",
4
4
  "description": "Polyfill for Intl.PluralRules",
5
5
  "keywords": [
6
6
  "polyfill",
@@ -21,12 +21,12 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "tslib": "2",
24
- "@formatjs/intl-localematcher": "0.5.7",
25
- "@formatjs/ecma402-abstract": "2.2.3"
24
+ "@formatjs/ecma402-abstract": "2.2.4",
25
+ "@formatjs/intl-localematcher": "0.5.8"
26
26
  },
27
27
  "devDependencies": {
28
- "@formatjs/intl-getcanonicallocales": "2.5.2",
29
- "@formatjs/intl-locale": "4.2.4"
28
+ "@formatjs/intl-locale": "4.2.5",
29
+ "@formatjs/intl-getcanonicallocales": "2.5.3"
30
30
  },
31
31
  "bugs": {
32
32
  "url": "https://github.com/formatjs/formatjs/issues"
package/polyfill-force.js CHANGED
@@ -7,4 +7,3 @@ Object.defineProperty(Intl, 'PluralRules', {
7
7
  enumerable: false,
8
8
  configurable: true,
9
9
  });
10
- //# sourceMappingURL=polyfill-force.js.map
package/polyfill.iife.js CHANGED
@@ -4640,6 +4640,50 @@
4640
4640
  };
4641
4641
  }
4642
4642
 
4643
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUValue.js
4644
+ function CanonicalizeUValue(ukey, uvalue) {
4645
+ var lowerValue = uvalue.toLowerCase();
4646
+ invariant2(ukey !== void 0, "ukey must be defined");
4647
+ var canonicalized = lowerValue;
4648
+ return canonicalized;
4649
+ }
4650
+
4651
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUnicodeLocaleId.js
4652
+ function CanonicalizeUnicodeLocaleId(locale) {
4653
+ return Intl.getCanonicalLocales(locale)[0];
4654
+ }
4655
+
4656
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/InsertUnicodeExtensionAndCanonicalize.js
4657
+ function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
4658
+ invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
4659
+ var extension = "-u";
4660
+ for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {
4661
+ var attr = attributes_1[_i];
4662
+ extension += "-".concat(attr);
4663
+ }
4664
+ for (var _a = 0, keywords_1 = keywords; _a < keywords_1.length; _a++) {
4665
+ var kw = keywords_1[_a];
4666
+ var key = kw.key, value = kw.value;
4667
+ extension += "-".concat(key);
4668
+ if (value !== "") {
4669
+ extension += "-".concat(value);
4670
+ }
4671
+ }
4672
+ if (extension === "-u") {
4673
+ return CanonicalizeUnicodeLocaleId(locale);
4674
+ }
4675
+ var privateIndex = locale.indexOf("-x-");
4676
+ var newLocale;
4677
+ if (privateIndex === -1) {
4678
+ newLocale = locale + extension;
4679
+ } else {
4680
+ var preExtension = locale.slice(0, privateIndex);
4681
+ var postExtension = locale.slice(privateIndex);
4682
+ newLocale = preExtension + extension + postExtension;
4683
+ }
4684
+ return CanonicalizeUnicodeLocaleId(newLocale);
4685
+ }
4686
+
4643
4687
  // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestAvailableLocale.js
4644
4688
  function BestAvailableLocale(availableLocales, locale) {
4645
4689
  var candidate = locale;
@@ -4677,47 +4721,50 @@
4677
4721
  return result;
4678
4722
  }
4679
4723
 
4680
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/UnicodeExtensionValue.js
4681
- function UnicodeExtensionValue(extension, key) {
4682
- invariant2(key.length === 2, "key must have 2 elements");
4724
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/UnicodeExtensionComponents.js
4725
+ function UnicodeExtensionComponents(extension) {
4726
+ invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
4727
+ invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
4728
+ var attributes = [];
4729
+ var keywords = [];
4730
+ var keyword;
4683
4731
  var size = extension.length;
4684
- var searchValue = "-".concat(key, "-");
4685
- var pos = extension.indexOf(searchValue);
4686
- if (pos !== -1) {
4687
- var start = pos + 4;
4688
- var end = start;
4689
- var k = start;
4690
- var done = false;
4691
- while (!done) {
4692
- var e = extension.indexOf("-", k);
4693
- var len = void 0;
4694
- if (e === -1) {
4695
- len = size - k;
4696
- } else {
4697
- len = e - k;
4732
+ var k = 3;
4733
+ while (k < size) {
4734
+ var e = extension.indexOf("-", k);
4735
+ var len = void 0;
4736
+ if (e === -1) {
4737
+ len = size - k;
4738
+ } else {
4739
+ len = e - k;
4740
+ }
4741
+ var subtag = extension.slice(k, k + len);
4742
+ invariant2(len >= 2, "Expected a subtag to have at least 2 characters");
4743
+ if (keyword === void 0 && len != 2) {
4744
+ if (attributes.indexOf(subtag) === -1) {
4745
+ attributes.push(subtag);
4698
4746
  }
4699
- if (len === 2) {
4700
- done = true;
4701
- } else if (e === -1) {
4702
- end = size;
4703
- done = true;
4704
- } else {
4705
- end = e;
4706
- k = e + 1;
4747
+ } else if (len === 2) {
4748
+ keyword = { key: subtag, value: "" };
4749
+ if (keywords.find(function(k2) {
4750
+ return k2.key === (keyword === null || keyword === void 0 ? void 0 : keyword.key);
4751
+ }) === void 0) {
4752
+ keywords.push(keyword);
4707
4753
  }
4754
+ } else if ((keyword === null || keyword === void 0 ? void 0 : keyword.value) === "") {
4755
+ keyword.value = subtag;
4756
+ } else {
4757
+ invariant2(keyword !== void 0, "Expected keyword to be defined");
4758
+ keyword.value += "-" + subtag;
4708
4759
  }
4709
- return extension.slice(start, end);
4710
- }
4711
- searchValue = "-".concat(key);
4712
- pos = extension.indexOf(searchValue);
4713
- if (pos !== -1 && pos + 3 === size) {
4714
- return "";
4760
+ k += len + 1;
4715
4761
  }
4716
- return void 0;
4762
+ return { attributes, keywords };
4717
4763
  }
4718
4764
 
4719
4765
  // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/ResolveLocale.js
4720
4766
  function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
4767
+ var _a;
4721
4768
  var matcher = options.localeMatcher;
4722
4769
  var r;
4723
4770
  if (matcher === "lookup") {
@@ -4725,56 +4772,77 @@
4725
4772
  } else {
4726
4773
  r = BestFitMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
4727
4774
  }
4775
+ if (r == null) {
4776
+ r = {
4777
+ locale: getDefaultLocale(),
4778
+ extension: ""
4779
+ };
4780
+ }
4728
4781
  var foundLocale = r.locale;
4729
- var result = { locale: "", dataLocale: foundLocale };
4730
- var supportedExtension = "-u";
4731
- for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
4732
- var key = relevantExtensionKeys_1[_i];
4733
- invariant2(foundLocale in localeData, "Missing locale data for ".concat(foundLocale));
4734
- var foundLocaleData = localeData[foundLocale];
4735
- invariant2(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data ".concat(key, " must be an object"));
4736
- var keyLocaleData = foundLocaleData[key];
4737
- invariant2(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key, " must be an array"));
4782
+ var foundLocaleData = localeData[foundLocale];
4783
+ var result = { locale: "en", dataLocale: foundLocale };
4784
+ var components;
4785
+ var keywords;
4786
+ if (r.extension) {
4787
+ components = UnicodeExtensionComponents(r.extension);
4788
+ keywords = components.keywords;
4789
+ } else {
4790
+ keywords = [];
4791
+ }
4792
+ var supportedKeywords = [];
4793
+ var _loop_1 = function(key2) {
4794
+ var keyLocaleData = (_a = foundLocaleData === null || foundLocaleData === void 0 ? void 0 : foundLocaleData[key2]) !== null && _a !== void 0 ? _a : [];
4795
+ invariant2(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key2, " must be an array"));
4738
4796
  var value = keyLocaleData[0];
4739
- invariant2(typeof value === "string" || value === null, "value must be string or null but got ".concat(typeof value, " in key ").concat(key));
4740
- var supportedExtensionAddition = "";
4741
- if (r.extension) {
4742
- var requestedValue = UnicodeExtensionValue(r.extension, key);
4743
- if (requestedValue !== void 0) {
4744
- if (requestedValue !== "") {
4745
- if (~keyLocaleData.indexOf(requestedValue)) {
4746
- value = requestedValue;
4747
- supportedExtensionAddition = "-".concat(key, "-").concat(value);
4748
- }
4749
- } else if (~requestedValue.indexOf("true")) {
4750
- value = "true";
4751
- supportedExtensionAddition = "-".concat(key);
4797
+ invariant2(value === void 0 || typeof value === "string", "value must be a string or undefined");
4798
+ var supportedKeyword = void 0;
4799
+ var entry = keywords.find(function(k) {
4800
+ return k.key === key2;
4801
+ });
4802
+ if (entry) {
4803
+ var requestedValue = entry.value;
4804
+ if (requestedValue !== "") {
4805
+ if (keyLocaleData.indexOf(requestedValue) > -1) {
4806
+ value = requestedValue;
4807
+ supportedKeyword = {
4808
+ key: key2,
4809
+ value
4810
+ };
4752
4811
  }
4812
+ } else if (keyLocaleData.indexOf("true") > -1) {
4813
+ value = "true";
4814
+ supportedKeyword = {
4815
+ key: key2,
4816
+ value
4817
+ };
4753
4818
  }
4754
4819
  }
4755
- if (key in options) {
4756
- var optionsValue = options[key];
4757
- invariant2(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
4758
- if (~keyLocaleData.indexOf(optionsValue)) {
4759
- if (optionsValue !== value) {
4760
- value = optionsValue;
4761
- supportedExtensionAddition = "";
4762
- }
4820
+ var optionsValue = options[key2];
4821
+ invariant2(optionsValue == null || typeof optionsValue === "string", "optionsValue must be a string or undefined");
4822
+ if (typeof optionsValue === "string") {
4823
+ var ukey = key2.toLowerCase();
4824
+ optionsValue = CanonicalizeUValue(ukey, optionsValue);
4825
+ if (optionsValue === "") {
4826
+ optionsValue = "true";
4763
4827
  }
4764
4828
  }
4765
- result[key] = value;
4766
- supportedExtension += supportedExtensionAddition;
4767
- }
4768
- if (supportedExtension.length > 2) {
4769
- var privateIndex = foundLocale.indexOf("-x-");
4770
- if (privateIndex === -1) {
4771
- foundLocale = foundLocale + supportedExtension;
4772
- } else {
4773
- var preExtension = foundLocale.slice(0, privateIndex);
4774
- var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
4775
- foundLocale = preExtension + supportedExtension + postExtension;
4829
+ if (optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
4830
+ value = optionsValue;
4831
+ supportedKeyword = void 0;
4832
+ }
4833
+ if (supportedKeyword) {
4834
+ supportedKeywords.push(supportedKeyword);
4776
4835
  }
4777
- foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
4836
+ result[key2] = value;
4837
+ };
4838
+ for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
4839
+ var key = relevantExtensionKeys_1[_i];
4840
+ _loop_1(key);
4841
+ }
4842
+ var supportedAttributes = [];
4843
+ if (supportedKeywords.length > 0) {
4844
+ supportedAttributes = [];
4845
+ foundLocale = InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords);
4778
4846
  }
4779
4847
  result.locale = foundLocale;
4780
4848
  return result;
package/polyfill.js CHANGED
@@ -10,4 +10,3 @@ if ((0, should_polyfill_1.shouldPolyfill)()) {
10
10
  configurable: true,
11
11
  });
12
12
  }
13
- //# sourceMappingURL=polyfill.js.map
@@ -19,4 +19,3 @@ function shouldPolyfill(locale) {
19
19
  return locale ? (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en') : undefined;
20
20
  }
21
21
  }
22
- //# sourceMappingURL=should-polyfill.js.map
@@ -2,4 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.supportedLocales = void 0;
4
4
  exports.supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
5
- //# sourceMappingURL=supported-locales.generated.js.map