@formatjs/intl-relativetimeformat 9.2.2 → 9.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/should-polyfill.d.ts.map +1 -1
- package/lib/should-polyfill.js +14 -1
- package/package.json +3 -3
- package/polyfill.iife.js +36 -24
- package/should-polyfill.d.ts.map +1 -1
- package/should-polyfill.js +14 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAwBA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAMxD"}
|
package/lib/should-polyfill.js
CHANGED
|
@@ -6,6 +6,19 @@ function supportedLocalesOf(locale) {
|
|
|
6
6
|
return (Intl.RelativeTimeFormat.supportedLocalesOf(locales).length ===
|
|
7
7
|
locales.length);
|
|
8
8
|
}
|
|
9
|
+
function hasResolvedOptionsNumberingSystem(locale) {
|
|
10
|
+
try {
|
|
11
|
+
return ('numberingSystem' in
|
|
12
|
+
new Intl.RelativeTimeFormat(locale || 'en', {
|
|
13
|
+
numeric: 'auto',
|
|
14
|
+
}).resolvedOptions());
|
|
15
|
+
}
|
|
16
|
+
catch (_) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
export function shouldPolyfill(locale) {
|
|
10
|
-
return !('RelativeTimeFormat' in Intl) ||
|
|
21
|
+
return (!('RelativeTimeFormat' in Intl) ||
|
|
22
|
+
!supportedLocalesOf(locale) ||
|
|
23
|
+
!hasResolvedOptionsNumberingSystem(locale));
|
|
11
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-relativetimeformat",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.2",
|
|
4
4
|
"description": "Formats JavaScript dates to relative time strings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"url": "git@github.com:formatjs/formatjs.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@formatjs/ecma402-abstract": "1.
|
|
24
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
23
|
+
"@formatjs/ecma402-abstract": "1.10.0",
|
|
24
|
+
"@formatjs/intl-localematcher": "0.2.21",
|
|
25
25
|
"tslib": "^2.1.0"
|
|
26
26
|
},
|
|
27
27
|
"main": "index.js",
|
package/polyfill.iife.js
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __markAsModule = function(target) {
|
|
9
|
-
return __defProp(target, "__esModule", {value: true});
|
|
9
|
+
return __defProp(target, "__esModule", { value: true });
|
|
10
|
+
};
|
|
11
|
+
var __require = typeof require !== "undefined" ? require : function(x) {
|
|
12
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
10
13
|
};
|
|
11
14
|
var __commonJS = function(cb, mod) {
|
|
12
|
-
return function
|
|
13
|
-
return mod || (0, cb[Object.keys(cb)[0]])((mod = {exports: {}}).exports, mod), mod.exports;
|
|
15
|
+
return function __require2() {
|
|
16
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
19
|
var __reExport = function(target, module, desc) {
|
|
@@ -18,23 +21,23 @@
|
|
|
18
21
|
for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
22
|
key = keys[i];
|
|
20
23
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
21
|
-
__defProp(target, key, {get: function(k) {
|
|
24
|
+
__defProp(target, key, { get: function(k) {
|
|
22
25
|
return module[k];
|
|
23
|
-
}.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
|
|
26
|
+
}.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
24
27
|
}
|
|
25
28
|
return target;
|
|
26
29
|
};
|
|
27
30
|
var __toModule = function(module) {
|
|
28
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: function() {
|
|
31
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: function() {
|
|
29
32
|
return module.default;
|
|
30
|
-
}, enumerable: true} : {value: module, enumerable: true})), module);
|
|
33
|
+
}, enumerable: true } : { value: module, enumerable: true })), module);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
|
|
34
37
|
var require_utils = __commonJS({
|
|
35
38
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
|
|
36
39
|
"use strict";
|
|
37
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
41
|
exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
|
|
39
42
|
exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
40
43
|
function invariant2(condition, message, Err) {
|
|
@@ -53,7 +56,7 @@
|
|
|
53
56
|
var require_BestAvailableLocale = __commonJS({
|
|
54
57
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js": function(exports) {
|
|
55
58
|
"use strict";
|
|
56
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
60
|
exports.BestAvailableLocale = void 0;
|
|
58
61
|
function BestAvailableLocale(availableLocales, locale) {
|
|
59
62
|
var candidate = locale;
|
|
@@ -79,12 +82,12 @@
|
|
|
79
82
|
var require_LookupMatcher = __commonJS({
|
|
80
83
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js": function(exports) {
|
|
81
84
|
"use strict";
|
|
82
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
85
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
86
|
exports.LookupMatcher = void 0;
|
|
84
87
|
var utils_1 = require_utils();
|
|
85
88
|
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
86
89
|
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
87
|
-
var result = {locale: ""};
|
|
90
|
+
var result = { locale: "" };
|
|
88
91
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
89
92
|
var locale = requestedLocales_1[_i];
|
|
90
93
|
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
@@ -108,7 +111,7 @@
|
|
|
108
111
|
var require_BestFitMatcher = __commonJS({
|
|
109
112
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js": function(exports) {
|
|
110
113
|
"use strict";
|
|
111
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
114
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
115
|
exports.BestFitMatcher = void 0;
|
|
113
116
|
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
114
117
|
var utils_1 = require_utils();
|
|
@@ -159,7 +162,7 @@
|
|
|
159
162
|
var require_UnicodeExtensionValue = __commonJS({
|
|
160
163
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js": function(exports) {
|
|
161
164
|
"use strict";
|
|
162
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
165
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
163
166
|
exports.UnicodeExtensionValue = void 0;
|
|
164
167
|
var utils_1 = require_utils();
|
|
165
168
|
function UnicodeExtensionValue(extension, key) {
|
|
@@ -207,7 +210,7 @@
|
|
|
207
210
|
var require_ResolveLocale = __commonJS({
|
|
208
211
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js": function(exports) {
|
|
209
212
|
"use strict";
|
|
210
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
213
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
211
214
|
exports.ResolveLocale = void 0;
|
|
212
215
|
var LookupMatcher_1 = require_LookupMatcher();
|
|
213
216
|
var BestFitMatcher_1 = require_BestFitMatcher();
|
|
@@ -222,7 +225,7 @@
|
|
|
222
225
|
r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
223
226
|
}
|
|
224
227
|
var foundLocale = r.locale;
|
|
225
|
-
var result = {locale: "", dataLocale: foundLocale};
|
|
228
|
+
var result = { locale: "", dataLocale: foundLocale };
|
|
226
229
|
var supportedExtension = "-u";
|
|
227
230
|
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
228
231
|
var key = relevantExtensionKeys_1[_i];
|
|
@@ -283,7 +286,7 @@
|
|
|
283
286
|
var require_LookupSupportedLocales = __commonJS({
|
|
284
287
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js": function(exports) {
|
|
285
288
|
"use strict";
|
|
286
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
289
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
287
290
|
exports.LookupSupportedLocales = void 0;
|
|
288
291
|
var utils_1 = require_utils();
|
|
289
292
|
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
@@ -307,7 +310,7 @@
|
|
|
307
310
|
var require_intl_localematcher = __commonJS({
|
|
308
311
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js": function(exports) {
|
|
309
312
|
"use strict";
|
|
310
|
-
Object.defineProperty(exports, "__esModule", {value: true});
|
|
313
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
311
314
|
exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
|
|
312
315
|
var ResolveLocale_1 = require_ResolveLocale();
|
|
313
316
|
function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
@@ -323,13 +326,13 @@
|
|
|
323
326
|
}
|
|
324
327
|
exports.match = match;
|
|
325
328
|
var LookupSupportedLocales_1 = require_LookupSupportedLocales();
|
|
326
|
-
Object.defineProperty(exports, "LookupSupportedLocales", {enumerable: true, get: function() {
|
|
329
|
+
Object.defineProperty(exports, "LookupSupportedLocales", { enumerable: true, get: function() {
|
|
327
330
|
return LookupSupportedLocales_1.LookupSupportedLocales;
|
|
328
|
-
}});
|
|
331
|
+
} });
|
|
329
332
|
var ResolveLocale_2 = require_ResolveLocale();
|
|
330
|
-
Object.defineProperty(exports, "ResolveLocale", {enumerable: true, get: function() {
|
|
333
|
+
Object.defineProperty(exports, "ResolveLocale", { enumerable: true, get: function() {
|
|
331
334
|
return ResolveLocale_2.ResolveLocale;
|
|
332
|
-
}});
|
|
335
|
+
} });
|
|
333
336
|
}
|
|
334
337
|
});
|
|
335
338
|
|
|
@@ -545,7 +548,7 @@
|
|
|
545
548
|
|
|
546
549
|
// node_modules/tslib/tslib.es6.js
|
|
547
550
|
var extendStatics = function(d, b) {
|
|
548
|
-
extendStatics = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(d2, b2) {
|
|
551
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
549
552
|
d2.__proto__ = b2;
|
|
550
553
|
} || function(d2, b2) {
|
|
551
554
|
for (var p in b2)
|
|
@@ -762,7 +765,7 @@
|
|
|
762
765
|
if (!internalSlots.initializedRelativeTimeFormat) {
|
|
763
766
|
throw new TypeError("formatToParts was called on a invalid context");
|
|
764
767
|
}
|
|
765
|
-
return PartitionRelativeTimePattern(this, Number(value), ToString(unit), {getInternalSlots: getInternalSlots});
|
|
768
|
+
return PartitionRelativeTimePattern(this, Number(value), ToString(unit), { getInternalSlots: getInternalSlots });
|
|
766
769
|
};
|
|
767
770
|
RelativeTimeFormat2.prototype.resolvedOptions = function() {
|
|
768
771
|
if (typeof this !== "object") {
|
|
@@ -841,8 +844,17 @@
|
|
|
841
844
|
var locales = Array.isArray(locale) ? locale : [locale];
|
|
842
845
|
return Intl.RelativeTimeFormat.supportedLocalesOf(locales).length === locales.length;
|
|
843
846
|
}
|
|
847
|
+
function hasResolvedOptionsNumberingSystem(locale) {
|
|
848
|
+
try {
|
|
849
|
+
return "numberingSystem" in new Intl.RelativeTimeFormat(locale || "en", {
|
|
850
|
+
numeric: "auto"
|
|
851
|
+
}).resolvedOptions();
|
|
852
|
+
} catch (_) {
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
844
856
|
function shouldPolyfill(locale) {
|
|
845
|
-
return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale);
|
|
857
|
+
return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale);
|
|
846
858
|
}
|
|
847
859
|
|
|
848
860
|
// bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/polyfill.js
|
package/should-polyfill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAwBA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAMxD"}
|
package/should-polyfill.js
CHANGED
|
@@ -9,7 +9,20 @@ function supportedLocalesOf(locale) {
|
|
|
9
9
|
return (Intl.RelativeTimeFormat.supportedLocalesOf(locales).length ===
|
|
10
10
|
locales.length);
|
|
11
11
|
}
|
|
12
|
+
function hasResolvedOptionsNumberingSystem(locale) {
|
|
13
|
+
try {
|
|
14
|
+
return ('numberingSystem' in
|
|
15
|
+
new Intl.RelativeTimeFormat(locale || 'en', {
|
|
16
|
+
numeric: 'auto',
|
|
17
|
+
}).resolvedOptions());
|
|
18
|
+
}
|
|
19
|
+
catch (_) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
function shouldPolyfill(locale) {
|
|
13
|
-
return !('RelativeTimeFormat' in Intl) ||
|
|
24
|
+
return (!('RelativeTimeFormat' in Intl) ||
|
|
25
|
+
!supportedLocalesOf(locale) ||
|
|
26
|
+
!hasResolvedOptionsNumberingSystem(locale));
|
|
14
27
|
}
|
|
15
28
|
exports.shouldPolyfill = shouldPolyfill;
|