@formatjs/intl-segmenter 11.7.2 → 11.7.4
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.
- package/lib/polyfill-force.js +0 -1
- package/lib/polyfill.js +0 -1
- package/lib/should-polyfill.js +0 -1
- package/lib/src/cldr-segmentation-rules.generated.js +0 -1
- package/lib/src/segmentation-utils.js +0 -1
- package/lib/src/segmenter.js +0 -1
- package/lib/test262-main.js +0 -1
- package/package.json +3 -3
- package/polyfill-force.js +0 -1
- package/polyfill.iife.js +142 -74
- package/polyfill.js +0 -1
- package/should-polyfill.js +0 -1
- package/src/cldr-segmentation-rules.generated.js +0 -1
- package/src/segmentation-utils.js +0 -1
- package/src/segmenter.js +0 -1
- package/test262-main.js +0 -1
package/lib/polyfill-force.js
CHANGED
package/lib/polyfill.js
CHANGED
package/lib/should-polyfill.js
CHANGED
package/lib/src/segmenter.js
CHANGED
package/lib/test262-main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-segmenter",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.4",
|
|
4
4
|
"description": "Polyfill for Intl.Segmenter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"tslib": "2",
|
|
23
|
-
"@formatjs/intl-localematcher": "0.5.
|
|
24
|
-
"@formatjs/ecma402-abstract": "2.2.
|
|
23
|
+
"@formatjs/intl-localematcher": "0.5.8",
|
|
24
|
+
"@formatjs/ecma402-abstract": "2.2.4"
|
|
25
25
|
},
|
|
26
26
|
"main": "index.js",
|
|
27
27
|
"types": "index.d.ts",
|
package/polyfill-force.js
CHANGED
package/polyfill.iife.js
CHANGED
|
@@ -4450,6 +4450,50 @@
|
|
|
4450
4450
|
};
|
|
4451
4451
|
}
|
|
4452
4452
|
|
|
4453
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUValue.js
|
|
4454
|
+
function CanonicalizeUValue(ukey, uvalue) {
|
|
4455
|
+
var lowerValue = uvalue.toLowerCase();
|
|
4456
|
+
invariant(ukey !== void 0, "ukey must be defined");
|
|
4457
|
+
var canonicalized = lowerValue;
|
|
4458
|
+
return canonicalized;
|
|
4459
|
+
}
|
|
4460
|
+
|
|
4461
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUnicodeLocaleId.js
|
|
4462
|
+
function CanonicalizeUnicodeLocaleId(locale) {
|
|
4463
|
+
return Intl.getCanonicalLocales(locale)[0];
|
|
4464
|
+
}
|
|
4465
|
+
|
|
4466
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/InsertUnicodeExtensionAndCanonicalize.js
|
|
4467
|
+
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
4468
|
+
invariant(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
|
|
4469
|
+
var extension = "-u";
|
|
4470
|
+
for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {
|
|
4471
|
+
var attr = attributes_1[_i];
|
|
4472
|
+
extension += "-".concat(attr);
|
|
4473
|
+
}
|
|
4474
|
+
for (var _a = 0, keywords_1 = keywords; _a < keywords_1.length; _a++) {
|
|
4475
|
+
var kw = keywords_1[_a];
|
|
4476
|
+
var key = kw.key, value = kw.value;
|
|
4477
|
+
extension += "-".concat(key);
|
|
4478
|
+
if (value !== "") {
|
|
4479
|
+
extension += "-".concat(value);
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
if (extension === "-u") {
|
|
4483
|
+
return CanonicalizeUnicodeLocaleId(locale);
|
|
4484
|
+
}
|
|
4485
|
+
var privateIndex = locale.indexOf("-x-");
|
|
4486
|
+
var newLocale;
|
|
4487
|
+
if (privateIndex === -1) {
|
|
4488
|
+
newLocale = locale + extension;
|
|
4489
|
+
} else {
|
|
4490
|
+
var preExtension = locale.slice(0, privateIndex);
|
|
4491
|
+
var postExtension = locale.slice(privateIndex);
|
|
4492
|
+
newLocale = preExtension + extension + postExtension;
|
|
4493
|
+
}
|
|
4494
|
+
return CanonicalizeUnicodeLocaleId(newLocale);
|
|
4495
|
+
}
|
|
4496
|
+
|
|
4453
4497
|
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestAvailableLocale.js
|
|
4454
4498
|
function BestAvailableLocale(availableLocales, locale) {
|
|
4455
4499
|
var candidate = locale;
|
|
@@ -4487,47 +4531,50 @@
|
|
|
4487
4531
|
return result;
|
|
4488
4532
|
}
|
|
4489
4533
|
|
|
4490
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/
|
|
4491
|
-
function
|
|
4492
|
-
invariant(
|
|
4534
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/UnicodeExtensionComponents.js
|
|
4535
|
+
function UnicodeExtensionComponents(extension) {
|
|
4536
|
+
invariant(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
4537
|
+
invariant(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
4538
|
+
var attributes = [];
|
|
4539
|
+
var keywords = [];
|
|
4540
|
+
var keyword;
|
|
4493
4541
|
var size = extension.length;
|
|
4494
|
-
var
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
var
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4542
|
+
var k = 3;
|
|
4543
|
+
while (k < size) {
|
|
4544
|
+
var e = extension.indexOf("-", k);
|
|
4545
|
+
var len = void 0;
|
|
4546
|
+
if (e === -1) {
|
|
4547
|
+
len = size - k;
|
|
4548
|
+
} else {
|
|
4549
|
+
len = e - k;
|
|
4550
|
+
}
|
|
4551
|
+
var subtag = extension.slice(k, k + len);
|
|
4552
|
+
invariant(len >= 2, "Expected a subtag to have at least 2 characters");
|
|
4553
|
+
if (keyword === void 0 && len != 2) {
|
|
4554
|
+
if (attributes.indexOf(subtag) === -1) {
|
|
4555
|
+
attributes.push(subtag);
|
|
4508
4556
|
}
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
end = e;
|
|
4516
|
-
k = e + 1;
|
|
4557
|
+
} else if (len === 2) {
|
|
4558
|
+
keyword = { key: subtag, value: "" };
|
|
4559
|
+
if (keywords.find(function(k2) {
|
|
4560
|
+
return k2.key === (keyword === null || keyword === void 0 ? void 0 : keyword.key);
|
|
4561
|
+
}) === void 0) {
|
|
4562
|
+
keywords.push(keyword);
|
|
4517
4563
|
}
|
|
4564
|
+
} else if ((keyword === null || keyword === void 0 ? void 0 : keyword.value) === "") {
|
|
4565
|
+
keyword.value = subtag;
|
|
4566
|
+
} else {
|
|
4567
|
+
invariant(keyword !== void 0, "Expected keyword to be defined");
|
|
4568
|
+
keyword.value += "-" + subtag;
|
|
4518
4569
|
}
|
|
4519
|
-
|
|
4570
|
+
k += len + 1;
|
|
4520
4571
|
}
|
|
4521
|
-
|
|
4522
|
-
pos = extension.indexOf(searchValue);
|
|
4523
|
-
if (pos !== -1 && pos + 3 === size) {
|
|
4524
|
-
return "";
|
|
4525
|
-
}
|
|
4526
|
-
return void 0;
|
|
4572
|
+
return { attributes, keywords };
|
|
4527
4573
|
}
|
|
4528
4574
|
|
|
4529
4575
|
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/ResolveLocale.js
|
|
4530
4576
|
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
4577
|
+
var _a;
|
|
4531
4578
|
var matcher = options.localeMatcher;
|
|
4532
4579
|
var r;
|
|
4533
4580
|
if (matcher === "lookup") {
|
|
@@ -4535,56 +4582,77 @@
|
|
|
4535
4582
|
} else {
|
|
4536
4583
|
r = BestFitMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
|
|
4537
4584
|
}
|
|
4585
|
+
if (r == null) {
|
|
4586
|
+
r = {
|
|
4587
|
+
locale: getDefaultLocale(),
|
|
4588
|
+
extension: ""
|
|
4589
|
+
};
|
|
4590
|
+
}
|
|
4538
4591
|
var foundLocale = r.locale;
|
|
4539
|
-
var
|
|
4540
|
-
var
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4592
|
+
var foundLocaleData = localeData[foundLocale];
|
|
4593
|
+
var result = { locale: "en", dataLocale: foundLocale };
|
|
4594
|
+
var components;
|
|
4595
|
+
var keywords;
|
|
4596
|
+
if (r.extension) {
|
|
4597
|
+
components = UnicodeExtensionComponents(r.extension);
|
|
4598
|
+
keywords = components.keywords;
|
|
4599
|
+
} else {
|
|
4600
|
+
keywords = [];
|
|
4601
|
+
}
|
|
4602
|
+
var supportedKeywords = [];
|
|
4603
|
+
var _loop_1 = function(key2) {
|
|
4604
|
+
var keyLocaleData = (_a = foundLocaleData === null || foundLocaleData === void 0 ? void 0 : foundLocaleData[key2]) !== null && _a !== void 0 ? _a : [];
|
|
4605
|
+
invariant(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key2, " must be an array"));
|
|
4548
4606
|
var value = keyLocaleData[0];
|
|
4549
|
-
invariant(
|
|
4550
|
-
var
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4607
|
+
invariant(value === void 0 || typeof value === "string", "value must be a string or undefined");
|
|
4608
|
+
var supportedKeyword = void 0;
|
|
4609
|
+
var entry = keywords.find(function(k) {
|
|
4610
|
+
return k.key === key2;
|
|
4611
|
+
});
|
|
4612
|
+
if (entry) {
|
|
4613
|
+
var requestedValue = entry.value;
|
|
4614
|
+
if (requestedValue !== "") {
|
|
4615
|
+
if (keyLocaleData.indexOf(requestedValue) > -1) {
|
|
4616
|
+
value = requestedValue;
|
|
4617
|
+
supportedKeyword = {
|
|
4618
|
+
key: key2,
|
|
4619
|
+
value
|
|
4620
|
+
};
|
|
4562
4621
|
}
|
|
4622
|
+
} else if (keyLocaleData.indexOf("true") > -1) {
|
|
4623
|
+
value = "true";
|
|
4624
|
+
supportedKeyword = {
|
|
4625
|
+
key: key2,
|
|
4626
|
+
value
|
|
4627
|
+
};
|
|
4563
4628
|
}
|
|
4564
4629
|
}
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
}
|
|
4630
|
+
var optionsValue = options[key2];
|
|
4631
|
+
invariant(optionsValue == null || typeof optionsValue === "string", "optionsValue must be a string or undefined");
|
|
4632
|
+
if (typeof optionsValue === "string") {
|
|
4633
|
+
var ukey = key2.toLowerCase();
|
|
4634
|
+
optionsValue = CanonicalizeUValue(ukey, optionsValue);
|
|
4635
|
+
if (optionsValue === "") {
|
|
4636
|
+
optionsValue = "true";
|
|
4573
4637
|
}
|
|
4574
4638
|
}
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
foundLocale = foundLocale + supportedExtension;
|
|
4582
|
-
} else {
|
|
4583
|
-
var preExtension = foundLocale.slice(0, privateIndex);
|
|
4584
|
-
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
4585
|
-
foundLocale = preExtension + supportedExtension + postExtension;
|
|
4639
|
+
if (optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
|
|
4640
|
+
value = optionsValue;
|
|
4641
|
+
supportedKeyword = void 0;
|
|
4642
|
+
}
|
|
4643
|
+
if (supportedKeyword) {
|
|
4644
|
+
supportedKeywords.push(supportedKeyword);
|
|
4586
4645
|
}
|
|
4587
|
-
|
|
4646
|
+
result[key2] = value;
|
|
4647
|
+
};
|
|
4648
|
+
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
4649
|
+
var key = relevantExtensionKeys_1[_i];
|
|
4650
|
+
_loop_1(key);
|
|
4651
|
+
}
|
|
4652
|
+
var supportedAttributes = [];
|
|
4653
|
+
if (supportedKeywords.length > 0) {
|
|
4654
|
+
supportedAttributes = [];
|
|
4655
|
+
foundLocale = InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords);
|
|
4588
4656
|
}
|
|
4589
4657
|
result.locale = foundLocale;
|
|
4590
4658
|
return result;
|
package/polyfill.js
CHANGED
package/should-polyfill.js
CHANGED
package/src/segmenter.js
CHANGED
package/test262-main.js
CHANGED