@formatjs/intl-segmenter 11.7.11 → 12.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.
- package/package.json +9 -5
- package/polyfill-force.js +2 -4
- package/polyfill.iife.js +38 -40
- package/polyfill.js +4 -6
- package/should-polyfill.js +1 -4
- package/src/cldr-segmentation-rules.generated.js +1 -4
- package/src/segmentation-utils.js +2 -7
- package/src/segmenter.js +25 -28
- package/test262-main.d.ts +1 -1
- package/test262-main.js +1 -3
- package/lib/polyfill-force.d.ts +0 -1
- package/lib/polyfill-force.js +0 -7
- package/lib/polyfill.d.ts +0 -1
- package/lib/polyfill.js +0 -10
- package/lib/should-polyfill.d.ts +0 -1
- package/lib/should-polyfill.js +0 -3
- package/lib/src/cldr-segmentation-rules.generated.d.ts +0 -384
- package/lib/src/cldr-segmentation-rules.generated.js +0 -1266
- package/lib/src/segmentation-utils.d.ts +0 -2
- package/lib/src/segmentation-utils.js +0 -32
- package/lib/src/segmenter.d.ts +0 -55
- package/lib/src/segmenter.js +0 -270
- package/lib/test262-main.d.ts +0 -1
- package/lib/test262-main.js +0 -3
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-segmenter",
|
|
3
3
|
"description": "Polyfill for Intl.Segmenter",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "12.0.0",
|
|
5
5
|
"author": "Matija Gaspar <matijagaspar@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@formatjs/ecma402-abstract": "
|
|
9
|
-
"@formatjs/intl-localematcher": "0.
|
|
8
|
+
"@formatjs/ecma402-abstract": "3.0.0",
|
|
9
|
+
"@formatjs/intl-localematcher": "0.7.0",
|
|
10
10
|
"tslib": "^2.8.0"
|
|
11
11
|
},
|
|
12
|
+
"exports": {
|
|
13
|
+
"./polyfill.js": "./polyfill.js",
|
|
14
|
+
"./polyfill-force.js": "./polyfill-force.js",
|
|
15
|
+
"./should-polyfill.js": "./should-polyfill.js"
|
|
16
|
+
},
|
|
12
17
|
"homepage": "https://github.com/formatjs/formatjs",
|
|
13
18
|
"keywords": [
|
|
14
19
|
"ecma402",
|
|
@@ -19,7 +24,6 @@
|
|
|
19
24
|
"unicode"
|
|
20
25
|
],
|
|
21
26
|
"license": "MIT",
|
|
22
|
-
"main": "index.js",
|
|
23
27
|
"repository": "git@github.com:formatjs/formatjs.git",
|
|
24
|
-
"
|
|
28
|
+
"type": "module"
|
|
25
29
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var segmenter_1 = require("./src/segmenter");
|
|
1
|
+
import { Segmenter } from './src/segmenter.js';
|
|
4
2
|
Object.defineProperty(Intl, 'Segmenter', {
|
|
5
|
-
value:
|
|
3
|
+
value: Segmenter,
|
|
6
4
|
enumerable: false,
|
|
7
5
|
writable: true,
|
|
8
6
|
configurable: true,
|
package/polyfill.iife.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
return value;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
23
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js
|
|
24
24
|
function CanonicalizeLocaleList(locales) {
|
|
25
25
|
return Intl.getCanonicalLocales(locales);
|
|
26
26
|
}
|
|
@@ -2385,12 +2385,11 @@
|
|
|
2385
2385
|
var Decimal = P.constructor = clone(DEFAULTS);
|
|
2386
2386
|
LN10 = new Decimal(LN10);
|
|
2387
2387
|
PI = new Decimal(PI);
|
|
2388
|
-
var decimal_default = Decimal;
|
|
2389
2388
|
|
|
2390
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2391
|
-
var TEN = new
|
|
2392
|
-
var ZERO = new
|
|
2393
|
-
var NEGATIVE_ZERO = new
|
|
2389
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
|
|
2390
|
+
var TEN = new Decimal(10);
|
|
2391
|
+
var ZERO = new Decimal(0);
|
|
2392
|
+
var NEGATIVE_ZERO = new Decimal(-0);
|
|
2394
2393
|
|
|
2395
2394
|
// node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
2396
2395
|
var extendStatics = function(d, b) {
|
|
@@ -2424,7 +2423,7 @@
|
|
|
2424
2423
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2425
2424
|
}
|
|
2426
2425
|
|
|
2427
|
-
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/
|
|
2426
|
+
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
2428
2427
|
function memoize(fn, options) {
|
|
2429
2428
|
var cache = options && options.cache ? options.cache : cacheDefault;
|
|
2430
2429
|
var serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -2497,7 +2496,7 @@
|
|
|
2497
2496
|
monadic: strategyMonadic
|
|
2498
2497
|
};
|
|
2499
2498
|
|
|
2500
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2499
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js
|
|
2501
2500
|
function setInternalSlot(map, pl, field, value) {
|
|
2502
2501
|
if (!map.get(pl)) {
|
|
2503
2502
|
map.set(pl, /* @__PURE__ */ Object.create(null));
|
|
@@ -2573,7 +2572,7 @@
|
|
|
2573
2572
|
strategy: strategies.variadic
|
|
2574
2573
|
});
|
|
2575
2574
|
|
|
2576
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2575
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js
|
|
2577
2576
|
function ToString(o) {
|
|
2578
2577
|
if (typeof o === "symbol") {
|
|
2579
2578
|
throw TypeError("Cannot convert a Symbol value to a string");
|
|
@@ -2592,7 +2591,7 @@
|
|
|
2592
2591
|
var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
|
|
2593
2592
|
var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
|
|
2594
2593
|
|
|
2595
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2594
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js
|
|
2596
2595
|
function GetOption(opts, prop, type, values, fallback) {
|
|
2597
2596
|
if (typeof opts !== "object") {
|
|
2598
2597
|
throw new TypeError("Options must be an object");
|
|
@@ -2618,7 +2617,7 @@
|
|
|
2618
2617
|
return fallback;
|
|
2619
2618
|
}
|
|
2620
2619
|
|
|
2621
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2620
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOptionsObject.js
|
|
2622
2621
|
function GetOptionsObject(options) {
|
|
2623
2622
|
if (typeof options === "undefined") {
|
|
2624
2623
|
return /* @__PURE__ */ Object.create(null);
|
|
@@ -2629,7 +2628,7 @@
|
|
|
2629
2628
|
throw new TypeError("Options must be an object");
|
|
2630
2629
|
}
|
|
2631
2630
|
|
|
2632
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2631
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js
|
|
2633
2632
|
var SANCTIONED_UNITS = [
|
|
2634
2633
|
"angle-degree",
|
|
2635
2634
|
"area-acre",
|
|
@@ -2680,24 +2679,24 @@
|
|
|
2680
2679
|
}
|
|
2681
2680
|
var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
2682
2681
|
|
|
2683
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2684
|
-
|
|
2682
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
2683
|
+
Decimal.set({
|
|
2685
2684
|
toExpPos: 100
|
|
2686
2685
|
});
|
|
2687
2686
|
|
|
2688
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2689
|
-
|
|
2687
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
2688
|
+
Decimal.set({
|
|
2690
2689
|
toExpPos: 100
|
|
2691
2690
|
});
|
|
2692
2691
|
|
|
2693
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2692
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
|
|
2694
2693
|
var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
|
2695
2694
|
|
|
2696
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2695
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js
|
|
2697
2696
|
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
2698
2697
|
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
2699
2698
|
|
|
2700
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
2699
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js
|
|
2701
2700
|
var data = {
|
|
2702
2701
|
supplemental: {
|
|
2703
2702
|
languageMatching: {
|
|
@@ -5319,7 +5318,7 @@
|
|
|
5319
5318
|
}
|
|
5320
5319
|
};
|
|
5321
5320
|
|
|
5322
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
5321
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
|
|
5323
5322
|
var regions = {
|
|
5324
5323
|
"001": [
|
|
5325
5324
|
"001",
|
|
@@ -6654,7 +6653,7 @@
|
|
|
6654
6653
|
]
|
|
6655
6654
|
};
|
|
6656
6655
|
|
|
6657
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6656
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
|
|
6658
6657
|
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
6659
6658
|
function invariant2(condition, message, Err) {
|
|
6660
6659
|
if (Err === void 0) {
|
|
@@ -6808,7 +6807,7 @@
|
|
|
6808
6807
|
return result;
|
|
6809
6808
|
}
|
|
6810
6809
|
|
|
6811
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6810
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
|
|
6812
6811
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
6813
6812
|
var foundLocale;
|
|
6814
6813
|
var extension;
|
|
@@ -6833,7 +6832,7 @@
|
|
|
6833
6832
|
};
|
|
6834
6833
|
}
|
|
6835
6834
|
|
|
6836
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6835
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
|
|
6837
6836
|
function CanonicalizeUValue(ukey, uvalue) {
|
|
6838
6837
|
var lowerValue = uvalue.toLowerCase();
|
|
6839
6838
|
invariant2(ukey !== void 0, "ukey must be defined");
|
|
@@ -6841,12 +6840,12 @@
|
|
|
6841
6840
|
return canonicalized;
|
|
6842
6841
|
}
|
|
6843
6842
|
|
|
6844
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6843
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
|
|
6845
6844
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
6846
6845
|
return Intl.getCanonicalLocales(locale)[0];
|
|
6847
6846
|
}
|
|
6848
6847
|
|
|
6849
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6848
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
|
|
6850
6849
|
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
6851
6850
|
invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
|
|
6852
6851
|
var extension = "-u";
|
|
@@ -6877,7 +6876,7 @@
|
|
|
6877
6876
|
return CanonicalizeUnicodeLocaleId(newLocale);
|
|
6878
6877
|
}
|
|
6879
6878
|
|
|
6880
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6879
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
|
|
6881
6880
|
function BestAvailableLocale(availableLocales, locale) {
|
|
6882
6881
|
var candidate = locale;
|
|
6883
6882
|
while (true) {
|
|
@@ -6895,7 +6894,7 @@
|
|
|
6895
6894
|
}
|
|
6896
6895
|
}
|
|
6897
6896
|
|
|
6898
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6897
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
|
|
6899
6898
|
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
6900
6899
|
var result = { locale: "" };
|
|
6901
6900
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -6914,7 +6913,7 @@
|
|
|
6914
6913
|
return result;
|
|
6915
6914
|
}
|
|
6916
6915
|
|
|
6917
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6916
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
|
|
6918
6917
|
function UnicodeExtensionComponents(extension) {
|
|
6919
6918
|
invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
6920
6919
|
invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
@@ -6955,7 +6954,7 @@
|
|
|
6955
6954
|
return { attributes, keywords };
|
|
6956
6955
|
}
|
|
6957
6956
|
|
|
6958
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6957
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
|
|
6959
6958
|
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
6960
6959
|
var _a;
|
|
6961
6960
|
var matcher = options.localeMatcher;
|
|
@@ -7041,7 +7040,7 @@
|
|
|
7041
7040
|
return result;
|
|
7042
7041
|
}
|
|
7043
7042
|
|
|
7044
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7043
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupSupportedLocales.js
|
|
7045
7044
|
function LookupSupportedLocales(availableLocales, requestedLocales) {
|
|
7046
7045
|
var subset = [];
|
|
7047
7046
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -7055,7 +7054,7 @@
|
|
|
7055
7054
|
return subset;
|
|
7056
7055
|
}
|
|
7057
7056
|
|
|
7058
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7057
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/SupportedLocales.js
|
|
7059
7058
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
7060
7059
|
var matcher = "best fit";
|
|
7061
7060
|
if (options !== void 0) {
|
|
@@ -7068,7 +7067,7 @@
|
|
|
7068
7067
|
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
7069
7068
|
}
|
|
7070
7069
|
|
|
7071
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7070
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/data.js
|
|
7072
7071
|
var MissingLocaleDataError = (
|
|
7073
7072
|
/** @class */
|
|
7074
7073
|
function(_super) {
|
|
@@ -7082,7 +7081,7 @@
|
|
|
7082
7081
|
}(Error)
|
|
7083
7082
|
);
|
|
7084
7083
|
|
|
7085
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7084
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/types/date-time.js
|
|
7086
7085
|
var RangePatternType;
|
|
7087
7086
|
(function(RangePatternType2) {
|
|
7088
7087
|
RangePatternType2["startRange"] = "startRange";
|
|
@@ -8646,13 +8645,12 @@
|
|
|
8646
8645
|
configurable: true
|
|
8647
8646
|
});
|
|
8648
8647
|
}
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
});
|
|
8648
|
+
Object.defineProperty(Segmenter.prototype.constructor, "length", {
|
|
8649
|
+
value: 0,
|
|
8650
|
+
writable: false,
|
|
8651
|
+
enumerable: false,
|
|
8652
|
+
configurable: true
|
|
8653
|
+
});
|
|
8656
8654
|
Object.defineProperty(Segmenter.supportedLocalesOf, "length", {
|
|
8657
8655
|
value: 1,
|
|
8658
8656
|
writable: false,
|
package/polyfill.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var should_polyfill_1 = require("./should-polyfill");
|
|
5
|
-
if ((0, should_polyfill_1.shouldPolyfill)()) {
|
|
1
|
+
import { Segmenter } from './src/segmenter.js';
|
|
2
|
+
import { shouldPolyfill } from './should-polyfill.js';
|
|
3
|
+
if (shouldPolyfill()) {
|
|
6
4
|
Object.defineProperty(Intl, 'Segmenter', {
|
|
7
|
-
value:
|
|
5
|
+
value: Segmenter,
|
|
8
6
|
enumerable: false,
|
|
9
7
|
writable: true,
|
|
10
8
|
configurable: true,
|
package/should-polyfill.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SegmentationRules = void 0;
|
|
4
1
|
/* @generated */
|
|
5
2
|
// prettier-ignore
|
|
6
|
-
|
|
3
|
+
export var SegmentationRules = {
|
|
7
4
|
"de": {
|
|
8
5
|
"sentence": {
|
|
9
6
|
"segmentRules": {},
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSurrogate = exports.replaceVariables = void 0;
|
|
4
|
-
var replaceVariables = function (variables, input) {
|
|
1
|
+
export var replaceVariables = function (variables, input) {
|
|
5
2
|
var findVarRegex = /\$[A-Za-z0-9_]+/gm;
|
|
6
3
|
return input.replaceAll(findVarRegex, function (match) {
|
|
7
4
|
if (!(match in variables)) {
|
|
@@ -10,14 +7,12 @@ var replaceVariables = function (variables, input) {
|
|
|
10
7
|
return variables[match];
|
|
11
8
|
});
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
var isSurrogate = function (str, pos) {
|
|
10
|
+
export var isSurrogate = function (str, pos) {
|
|
15
11
|
return (0xd800 <= str.charCodeAt(pos - 1) &&
|
|
16
12
|
str.charCodeAt(pos - 1) <= 0xdbff &&
|
|
17
13
|
0xdc00 <= str.charCodeAt(pos) &&
|
|
18
14
|
str.charCodeAt(pos) <= 0xdfff);
|
|
19
15
|
};
|
|
20
|
-
exports.isSurrogate = isSurrogate;
|
|
21
16
|
// alternative surrogate check mimicking the java implementation
|
|
22
17
|
// const TRAIL_SURROGATE_BITMASK = 0xfffffc00
|
|
23
18
|
// const TRAIL_SURROGATE_BITS = 0xdc00
|
package/src/segmenter.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
7
|
-
var cldr_segmentation_rules_generated_1 = require("./cldr-segmentation-rules.generated");
|
|
8
|
-
var segmentation_utils_1 = require("./segmentation-utils");
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { CanonicalizeLocaleList, GetOption, GetOptionsObject, SupportedLocales, getInternalSlot, getMultiInternalSlots, setInternalSlot, } from '@formatjs/ecma402-abstract';
|
|
3
|
+
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
4
|
+
import { SegmentationRules } from './cldr-segmentation-rules.generated.js';
|
|
5
|
+
import { isSurrogate, replaceVariables } from './segmentation-utils.js';
|
|
9
6
|
/**
|
|
10
7
|
* Adds $ to before rules and ^ to after rules for strictness
|
|
11
8
|
* Replaces variables
|
|
@@ -17,7 +14,7 @@ var segmentation_utils_1 = require("./segmentation-utils");
|
|
|
17
14
|
* @returns
|
|
18
15
|
*/
|
|
19
16
|
var generateRuleRegex = function (rule, variables, after) {
|
|
20
|
-
return new RegExp("".concat(after ? '^' : '').concat(
|
|
17
|
+
return new RegExp("".concat(after ? '^' : '').concat(replaceVariables(variables, rule)).concat(after ? '' : '$'));
|
|
21
18
|
};
|
|
22
19
|
var prepareLocaleSegmentationRules = function (segmentationTypeValue) {
|
|
23
20
|
var preparedRules = {};
|
|
@@ -47,29 +44,29 @@ var Segmenter = /** @class */ (function () {
|
|
|
47
44
|
if (_newTarget === undefined) {
|
|
48
45
|
throw TypeError("Constructor Intl.Segmenter requires 'new'");
|
|
49
46
|
}
|
|
50
|
-
var requestedLocales =
|
|
51
|
-
options =
|
|
47
|
+
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
48
|
+
options = GetOptionsObject(options);
|
|
52
49
|
var opt = Object.create(null);
|
|
53
|
-
var matcher =
|
|
50
|
+
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
54
51
|
opt.localeMatcher = matcher;
|
|
55
|
-
var granularity =
|
|
52
|
+
var granularity = GetOption(options, 'granularity', 'string', ['word', 'sentence', 'grapheme'], 'grapheme');
|
|
56
53
|
setSlot(this, 'granularity', granularity);
|
|
57
54
|
//TODO: figure out correct availible locales
|
|
58
|
-
var r =
|
|
55
|
+
var r = ResolveLocale(Segmenter.availableLocales, //availible locales
|
|
59
56
|
requestedLocales, opt, [], // there is no relevantExtensionKeys
|
|
60
57
|
{}, function () { return ''; } //use only root rules
|
|
61
58
|
);
|
|
62
59
|
setSlot(this, 'locale', r.locale);
|
|
63
60
|
//root rules based on granularity
|
|
64
|
-
this.mergedSegmentationTypeValue =
|
|
61
|
+
this.mergedSegmentationTypeValue = SegmentationRules.root[granularity];
|
|
65
62
|
//merge root rules with locale ones if locale is specified
|
|
66
63
|
if (r.locale.length) {
|
|
67
|
-
var localeOverrides =
|
|
64
|
+
var localeOverrides = SegmentationRules[r.locale];
|
|
68
65
|
if (granularity in localeOverrides) {
|
|
69
66
|
var localeSegmentationTypeValue = localeOverrides[granularity];
|
|
70
|
-
this.mergedSegmentationTypeValue.variables =
|
|
71
|
-
this.mergedSegmentationTypeValue.segmentRules =
|
|
72
|
-
this.mergedSegmentationTypeValue.suppressions =
|
|
67
|
+
this.mergedSegmentationTypeValue.variables = __assign(__assign({}, this.mergedSegmentationTypeValue.variables), localeSegmentationTypeValue.variables);
|
|
68
|
+
this.mergedSegmentationTypeValue.segmentRules = __assign(__assign({}, this.mergedSegmentationTypeValue.segmentRules), localeSegmentationTypeValue.segmentRules);
|
|
69
|
+
this.mergedSegmentationTypeValue.suppressions = __spreadArray(__spreadArray([], this.mergedSegmentationTypeValue.suppressions, true), localeSegmentationTypeValue.suppressions, true);
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
//prepare rules
|
|
@@ -91,7 +88,7 @@ var Segmenter = /** @class */ (function () {
|
|
|
91
88
|
}
|
|
92
89
|
//artificial rule 0.1: js specific, due to es5 regex not being unicode aware
|
|
93
90
|
//number 0.1 chosen to mimic java implementation, but needs to execute after 0.2 and 0.3 to be inside the string bounds
|
|
94
|
-
if (
|
|
91
|
+
if (isSurrogate(input, position)) {
|
|
95
92
|
return breaksAtResult(false, '0.1');
|
|
96
93
|
}
|
|
97
94
|
var stringBeforeBreak = input.substring(0, position);
|
|
@@ -136,16 +133,16 @@ var Segmenter = /** @class */ (function () {
|
|
|
136
133
|
};
|
|
137
134
|
Segmenter.prototype.resolvedOptions = function () {
|
|
138
135
|
checkReceiver(this, 'resolvedOptions');
|
|
139
|
-
return
|
|
136
|
+
return __assign({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'granularity'));
|
|
140
137
|
};
|
|
141
138
|
Segmenter.supportedLocalesOf = function (locales, options) {
|
|
142
|
-
return
|
|
139
|
+
return SupportedLocales(Segmenter.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
143
140
|
};
|
|
144
|
-
Segmenter.availableLocales = new Set(Object.keys(
|
|
141
|
+
Segmenter.availableLocales = new Set(Object.keys(SegmentationRules).filter(function (key) { return key !== 'root'; }));
|
|
145
142
|
Segmenter.polyfilled = true;
|
|
146
143
|
return Segmenter;
|
|
147
144
|
}());
|
|
148
|
-
|
|
145
|
+
export { Segmenter };
|
|
149
146
|
var createSegmentDataObject = function (segmenter, segment, index, input, matchingRule) {
|
|
150
147
|
var returnValue = {
|
|
151
148
|
segment: segment,
|
|
@@ -233,10 +230,10 @@ var SegmentIterator = /** @class */ (function () {
|
|
|
233
230
|
}());
|
|
234
231
|
var __INTERNAL_SLOT_MAP__ = new WeakMap();
|
|
235
232
|
function getSlot(instance, key) {
|
|
236
|
-
return
|
|
233
|
+
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
|
|
237
234
|
}
|
|
238
235
|
function setSlot(instance, key, value) {
|
|
239
|
-
|
|
236
|
+
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
|
|
240
237
|
}
|
|
241
238
|
function checkReceiver(receiver, methodName) {
|
|
242
239
|
if (!(receiver instanceof Segmenter)) {
|
|
@@ -254,7 +251,7 @@ try {
|
|
|
254
251
|
});
|
|
255
252
|
}
|
|
256
253
|
//github.com/tc39/test262/blob/main/test/intl402/Segmenter/constructor/length.js
|
|
257
|
-
|
|
254
|
+
Object.defineProperty(Segmenter.prototype.constructor, 'length', {
|
|
258
255
|
value: 0,
|
|
259
256
|
writable: false,
|
|
260
257
|
enumerable: false,
|
|
@@ -268,6 +265,6 @@ try {
|
|
|
268
265
|
configurable: true,
|
|
269
266
|
});
|
|
270
267
|
}
|
|
271
|
-
catch (
|
|
268
|
+
catch (_a) {
|
|
272
269
|
// Meta fix so we're test262-compliant, not important
|
|
273
270
|
}
|
package/test262-main.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import './polyfill-force';
|
|
1
|
+
import './polyfill-force.js';
|
package/test262-main.js
CHANGED
package/lib/polyfill-force.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill-force.js
DELETED
package/lib/polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Segmenter } from './src/segmenter';
|
|
2
|
-
import { shouldPolyfill } from './should-polyfill';
|
|
3
|
-
if (shouldPolyfill()) {
|
|
4
|
-
Object.defineProperty(Intl, 'Segmenter', {
|
|
5
|
-
value: Segmenter,
|
|
6
|
-
enumerable: false,
|
|
7
|
-
writable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
});
|
|
10
|
-
}
|
package/lib/should-polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function shouldPolyfill(): boolean;
|
package/lib/should-polyfill.js
DELETED