@formatjs/intl-relativetimeformat 9.1.7 → 9.2.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"InitializeRelativeTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/abstract/InitializeRelativeTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAMjB,MAAM,4BAA4B,CAAA;AAInC,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,EACnD,EACE,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;IAC1E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;IACxD,gBAAgB,IAAI,MAAM,CAAA;CAC3B,2BA4DF"}
1
+ {"version":3,"file":"InitializeRelativeTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/abstract/InitializeRelativeTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAKjB,MAAM,4BAA4B,CAAA;AAKnC,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,EACnD,EACE,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;IAC1E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;IACxD,gBAAgB,IAAI,MAAM,CAAA;CAC3B,2BA4DF"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InitializeRelativeTimeFormat = void 0;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
6
  var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
6
7
  function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
7
8
  var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
@@ -21,7 +22,7 @@ function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
21
22
  }
22
23
  }
23
24
  opt.nu = numberingSystem;
24
- var r = ecma402_abstract_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
25
+ var r = intl_localematcher_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
25
26
  var locale = r.locale, nu = r.nu;
26
27
  internalSlots.locale = locale;
27
28
  internalSlots.style = ecma402_abstract_1.GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
@@ -1 +1 @@
1
- {"version":3,"file":"InitializeRelativeTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-relativetimeformat/abstract/InitializeRelativeTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAMjB,MAAM,4BAA4B,CAAA;AAInC,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,EACnD,EACE,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;IAC1E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;IACxD,gBAAgB,IAAI,MAAM,CAAA;CAC3B,2BA4DF"}
1
+ {"version":3,"file":"InitializeRelativeTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-relativetimeformat/abstract/InitializeRelativeTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAKjB,MAAM,4BAA4B,CAAA;AAKnC,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,EACnD,EACE,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;IAC1E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;IACxD,gBAAgB,IAAI,MAAM,CAAA;CAC3B,2BA4DF"}
@@ -1,4 +1,5 @@
1
- import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, ResolveLocale, invariant, } from '@formatjs/ecma402-abstract';
1
+ import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, invariant, } from '@formatjs/ecma402-abstract';
2
+ import { ResolveLocale } from '@formatjs/intl-localematcher';
2
3
  var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
3
4
  export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
4
5
  var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
@@ -1,2 +1,2 @@
1
- export declare function shouldPolyfill(): boolean;
1
+ export declare function shouldPolyfill(locale?: string | string[]): boolean;
2
2
  //# sourceMappingURL=should-polyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,YAE7B"}
1
+ {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAWA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAExD"}
@@ -1,3 +1,11 @@
1
- export function shouldPolyfill() {
2
- return !('RelativeTimeFormat' in Intl);
1
+ function supportedLocalesOf(locale) {
2
+ if (!locale) {
3
+ return true;
4
+ }
5
+ var locales = Array.isArray(locale) ? locale : [locale];
6
+ return (Intl.RelativeTimeFormat.supportedLocalesOf(locales).length ===
7
+ locales.length);
8
+ }
9
+ export function shouldPolyfill(locale) {
10
+ return !('RelativeTimeFormat' in Intl) || !supportedLocalesOf(locale);
3
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-relativetimeformat",
3
- "version": "9.1.7",
3
+ "version": "9.2.3",
4
4
  "description": "Formats JavaScript dates to relative time strings.",
5
5
  "keywords": [
6
6
  "intl",
@@ -20,7 +20,8 @@
20
20
  "url": "git@github.com:formatjs/formatjs.git"
21
21
  },
22
22
  "dependencies": {
23
- "@formatjs/ecma402-abstract": "1.9.4",
23
+ "@formatjs/ecma402-abstract": "1.9.8",
24
+ "@formatjs/intl-localematcher": "0.2.20",
24
25
  "tslib": "^2.1.0"
25
26
  },
26
27
  "main": "index.js",
package/polyfill.iife.js CHANGED
@@ -1,4 +1,338 @@
1
1
  (function() {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __markAsModule = function(target) {
9
+ return __defProp(target, "__esModule", {value: true});
10
+ };
11
+ var __commonJS = function(cb, mod) {
12
+ return function __require() {
13
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = {exports: {}}).exports, mod), mod.exports;
14
+ };
15
+ };
16
+ var __reExport = function(target, module, desc) {
17
+ if (module && typeof module === "object" || typeof module === "function")
18
+ for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(target, key) && key !== "default")
21
+ __defProp(target, key, {get: function(k) {
22
+ return module[k];
23
+ }.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
24
+ }
25
+ return target;
26
+ };
27
+ var __toModule = function(module) {
28
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: function() {
29
+ return module.default;
30
+ }, enumerable: true} : {value: module, enumerable: true})), module);
31
+ };
32
+
33
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
34
+ var require_utils = __commonJS({
35
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
36
+ "use strict";
37
+ Object.defineProperty(exports, "__esModule", {value: true});
38
+ exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
39
+ exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
40
+ function invariant2(condition, message, Err) {
41
+ if (Err === void 0) {
42
+ Err = Error;
43
+ }
44
+ if (!condition) {
45
+ throw new Err(message);
46
+ }
47
+ }
48
+ exports.invariant = invariant2;
49
+ }
50
+ });
51
+
52
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js
53
+ var require_BestAvailableLocale = __commonJS({
54
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js": function(exports) {
55
+ "use strict";
56
+ Object.defineProperty(exports, "__esModule", {value: true});
57
+ exports.BestAvailableLocale = void 0;
58
+ function BestAvailableLocale(availableLocales, locale) {
59
+ var candidate = locale;
60
+ while (true) {
61
+ if (availableLocales.has(candidate)) {
62
+ return candidate;
63
+ }
64
+ var pos = candidate.lastIndexOf("-");
65
+ if (!~pos) {
66
+ return void 0;
67
+ }
68
+ if (pos >= 2 && candidate[pos - 2] === "-") {
69
+ pos -= 2;
70
+ }
71
+ candidate = candidate.slice(0, pos);
72
+ }
73
+ }
74
+ exports.BestAvailableLocale = BestAvailableLocale;
75
+ }
76
+ });
77
+
78
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js
79
+ var require_LookupMatcher = __commonJS({
80
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js": function(exports) {
81
+ "use strict";
82
+ Object.defineProperty(exports, "__esModule", {value: true});
83
+ exports.LookupMatcher = void 0;
84
+ var utils_1 = require_utils();
85
+ var BestAvailableLocale_1 = require_BestAvailableLocale();
86
+ function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
87
+ var result = {locale: ""};
88
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
89
+ var locale = requestedLocales_1[_i];
90
+ var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
91
+ var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
92
+ if (availableLocale) {
93
+ result.locale = availableLocale;
94
+ if (locale !== noExtensionLocale) {
95
+ result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
96
+ }
97
+ return result;
98
+ }
99
+ }
100
+ result.locale = getDefaultLocale();
101
+ return result;
102
+ }
103
+ exports.LookupMatcher = LookupMatcher;
104
+ }
105
+ });
106
+
107
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js
108
+ var require_BestFitMatcher = __commonJS({
109
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js": function(exports) {
110
+ "use strict";
111
+ Object.defineProperty(exports, "__esModule", {value: true});
112
+ exports.BestFitMatcher = void 0;
113
+ var BestAvailableLocale_1 = require_BestAvailableLocale();
114
+ var utils_1 = require_utils();
115
+ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
116
+ var minimizedAvailableLocaleMap = Array.from(availableLocales).reduce(function(all, l2) {
117
+ all[l2] = l2;
118
+ return all;
119
+ }, {});
120
+ var minimizedAvailableLocales = new Set();
121
+ availableLocales.forEach(function(locale2) {
122
+ var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
123
+ minimizedAvailableLocaleMap[minimizedLocale] = locale2;
124
+ minimizedAvailableLocales.add(minimizedLocale);
125
+ });
126
+ var foundLocale;
127
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
128
+ var l = requestedLocales_1[_i];
129
+ if (foundLocale) {
130
+ break;
131
+ }
132
+ var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
133
+ if (availableLocales.has(noExtensionLocale)) {
134
+ foundLocale = noExtensionLocale;
135
+ break;
136
+ }
137
+ if (minimizedAvailableLocales.has(noExtensionLocale)) {
138
+ foundLocale = noExtensionLocale;
139
+ break;
140
+ }
141
+ var locale = new Intl.Locale(noExtensionLocale);
142
+ var maximizedRequestedLocale = locale.maximize().toString();
143
+ var minimizedRequestedLocale = locale.minimize().toString();
144
+ if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
145
+ foundLocale = minimizedRequestedLocale;
146
+ break;
147
+ }
148
+ foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
149
+ }
150
+ return {
151
+ locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
152
+ };
153
+ }
154
+ exports.BestFitMatcher = BestFitMatcher;
155
+ }
156
+ });
157
+
158
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js
159
+ var require_UnicodeExtensionValue = __commonJS({
160
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js": function(exports) {
161
+ "use strict";
162
+ Object.defineProperty(exports, "__esModule", {value: true});
163
+ exports.UnicodeExtensionValue = void 0;
164
+ var utils_1 = require_utils();
165
+ function UnicodeExtensionValue(extension, key) {
166
+ utils_1.invariant(key.length === 2, "key must have 2 elements");
167
+ var size = extension.length;
168
+ var searchValue = "-" + key + "-";
169
+ var pos = extension.indexOf(searchValue);
170
+ if (pos !== -1) {
171
+ var start = pos + 4;
172
+ var end = start;
173
+ var k = start;
174
+ var done = false;
175
+ while (!done) {
176
+ var e = extension.indexOf("-", k);
177
+ var len = void 0;
178
+ if (e === -1) {
179
+ len = size - k;
180
+ } else {
181
+ len = e - k;
182
+ }
183
+ if (len === 2) {
184
+ done = true;
185
+ } else if (e === -1) {
186
+ end = size;
187
+ done = true;
188
+ } else {
189
+ end = e;
190
+ k = e + 1;
191
+ }
192
+ }
193
+ return extension.slice(start, end);
194
+ }
195
+ searchValue = "-" + key;
196
+ pos = extension.indexOf(searchValue);
197
+ if (pos !== -1 && pos + 3 === size) {
198
+ return "";
199
+ }
200
+ return void 0;
201
+ }
202
+ exports.UnicodeExtensionValue = UnicodeExtensionValue;
203
+ }
204
+ });
205
+
206
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js
207
+ var require_ResolveLocale = __commonJS({
208
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js": function(exports) {
209
+ "use strict";
210
+ Object.defineProperty(exports, "__esModule", {value: true});
211
+ exports.ResolveLocale = void 0;
212
+ var LookupMatcher_1 = require_LookupMatcher();
213
+ var BestFitMatcher_1 = require_BestFitMatcher();
214
+ var utils_1 = require_utils();
215
+ var UnicodeExtensionValue_1 = require_UnicodeExtensionValue();
216
+ function ResolveLocale3(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
217
+ var matcher = options.localeMatcher;
218
+ var r;
219
+ if (matcher === "lookup") {
220
+ r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
221
+ } else {
222
+ r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
223
+ }
224
+ var foundLocale = r.locale;
225
+ var result = {locale: "", dataLocale: foundLocale};
226
+ var supportedExtension = "-u";
227
+ for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
228
+ var key = relevantExtensionKeys_1[_i];
229
+ utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
230
+ var foundLocaleData = localeData[foundLocale];
231
+ utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
232
+ var keyLocaleData = foundLocaleData[key];
233
+ utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
234
+ var value = keyLocaleData[0];
235
+ utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
236
+ var supportedExtensionAddition = "";
237
+ if (r.extension) {
238
+ var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
239
+ if (requestedValue !== void 0) {
240
+ if (requestedValue !== "") {
241
+ if (~keyLocaleData.indexOf(requestedValue)) {
242
+ value = requestedValue;
243
+ supportedExtensionAddition = "-" + key + "-" + value;
244
+ }
245
+ } else if (~requestedValue.indexOf("true")) {
246
+ value = "true";
247
+ supportedExtensionAddition = "-" + key;
248
+ }
249
+ }
250
+ }
251
+ if (key in options) {
252
+ var optionsValue = options[key];
253
+ utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
254
+ if (~keyLocaleData.indexOf(optionsValue)) {
255
+ if (optionsValue !== value) {
256
+ value = optionsValue;
257
+ supportedExtensionAddition = "";
258
+ }
259
+ }
260
+ }
261
+ result[key] = value;
262
+ supportedExtension += supportedExtensionAddition;
263
+ }
264
+ if (supportedExtension.length > 2) {
265
+ var privateIndex = foundLocale.indexOf("-x-");
266
+ if (privateIndex === -1) {
267
+ foundLocale = foundLocale + supportedExtension;
268
+ } else {
269
+ var preExtension = foundLocale.slice(0, privateIndex);
270
+ var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
271
+ foundLocale = preExtension + supportedExtension + postExtension;
272
+ }
273
+ foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
274
+ }
275
+ result.locale = foundLocale;
276
+ return result;
277
+ }
278
+ exports.ResolveLocale = ResolveLocale3;
279
+ }
280
+ });
281
+
282
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js
283
+ var require_LookupSupportedLocales = __commonJS({
284
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js": function(exports) {
285
+ "use strict";
286
+ Object.defineProperty(exports, "__esModule", {value: true});
287
+ exports.LookupSupportedLocales = void 0;
288
+ var utils_1 = require_utils();
289
+ var BestAvailableLocale_1 = require_BestAvailableLocale();
290
+ function LookupSupportedLocales2(availableLocales, requestedLocales) {
291
+ var subset = [];
292
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
293
+ var locale = requestedLocales_1[_i];
294
+ var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
295
+ var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
296
+ if (availableLocale) {
297
+ subset.push(availableLocale);
298
+ }
299
+ }
300
+ return subset;
301
+ }
302
+ exports.LookupSupportedLocales = LookupSupportedLocales2;
303
+ }
304
+ });
305
+
306
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js
307
+ var require_intl_localematcher = __commonJS({
308
+ "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js": function(exports) {
309
+ "use strict";
310
+ Object.defineProperty(exports, "__esModule", {value: true});
311
+ exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
312
+ var ResolveLocale_1 = require_ResolveLocale();
313
+ function match(requestedLocales, availableLocales, defaultLocale, opts) {
314
+ var locales = availableLocales.reduce(function(all, l) {
315
+ all.add(l);
316
+ return all;
317
+ }, new Set());
318
+ return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
319
+ localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
320
+ }, [], {}, function() {
321
+ return defaultLocale;
322
+ }).locale;
323
+ }
324
+ exports.match = match;
325
+ var LookupSupportedLocales_1 = require_LookupSupportedLocales();
326
+ Object.defineProperty(exports, "LookupSupportedLocales", {enumerable: true, get: function() {
327
+ return LookupSupportedLocales_1.LookupSupportedLocales;
328
+ }});
329
+ var ResolveLocale_2 = require_ResolveLocale();
330
+ Object.defineProperty(exports, "ResolveLocale", {enumerable: true, get: function() {
331
+ return ResolveLocale_2.ResolveLocale;
332
+ }});
333
+ }
334
+ });
335
+
2
336
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/CanonicalizeLocaleList.js
3
337
  function CanonicalizeLocaleList(locales) {
4
338
  return Intl.getCanonicalLocales(locales);
@@ -144,7 +478,6 @@
144
478
  var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
145
479
 
146
480
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/utils.js
147
- var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
148
481
  function invariant(condition, message, Err) {
149
482
  if (Err === void 0) {
150
483
  Err = Error;
@@ -161,183 +494,8 @@
161
494
  var CARET_S_UNICODE_REGEX = new RegExp("^" + S_UNICODE_REGEX.source);
162
495
  var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source + "$");
163
496
 
164
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/BestAvailableLocale.js
165
- function BestAvailableLocale(availableLocales, locale) {
166
- var candidate = locale;
167
- while (true) {
168
- if (availableLocales.has(candidate)) {
169
- return candidate;
170
- }
171
- var pos = candidate.lastIndexOf("-");
172
- if (!~pos) {
173
- return void 0;
174
- }
175
- if (pos >= 2 && candidate[pos - 2] === "-") {
176
- pos -= 2;
177
- }
178
- candidate = candidate.slice(0, pos);
179
- }
180
- }
181
-
182
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/LookupMatcher.js
183
- function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
184
- var result = {locale: ""};
185
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
186
- var locale = requestedLocales_1[_i];
187
- var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
188
- var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
189
- if (availableLocale) {
190
- result.locale = availableLocale;
191
- if (locale !== noExtensionLocale) {
192
- result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
193
- }
194
- return result;
195
- }
196
- }
197
- result.locale = getDefaultLocale();
198
- return result;
199
- }
200
-
201
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/BestFitMatcher.js
202
- function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
203
- var minimizedAvailableLocaleMap = {};
204
- var minimizedAvailableLocales = new Set();
205
- availableLocales.forEach(function(locale2) {
206
- var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
207
- minimizedAvailableLocaleMap[minimizedLocale] = locale2;
208
- minimizedAvailableLocales.add(minimizedLocale);
209
- });
210
- var foundLocale;
211
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
212
- var l = requestedLocales_1[_i];
213
- if (foundLocale) {
214
- break;
215
- }
216
- var noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
217
- if (availableLocales.has(noExtensionLocale)) {
218
- foundLocale = noExtensionLocale;
219
- break;
220
- }
221
- if (minimizedAvailableLocales.has(noExtensionLocale)) {
222
- foundLocale = minimizedAvailableLocaleMap[noExtensionLocale];
223
- break;
224
- }
225
- var locale = new Intl.Locale(noExtensionLocale);
226
- var maximizedRequestedLocale = locale.maximize().toString();
227
- var minimizedRequestedLocale = locale.minimize().toString();
228
- if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
229
- foundLocale = minimizedAvailableLocaleMap[minimizedRequestedLocale];
230
- break;
231
- }
232
- foundLocale = BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
233
- }
234
- return {
235
- locale: foundLocale || getDefaultLocale()
236
- };
237
- }
238
-
239
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/UnicodeExtensionValue.js
240
- function UnicodeExtensionValue(extension, key) {
241
- invariant(key.length === 2, "key must have 2 elements");
242
- var size = extension.length;
243
- var searchValue = "-" + key + "-";
244
- var pos = extension.indexOf(searchValue);
245
- if (pos !== -1) {
246
- var start = pos + 4;
247
- var end = start;
248
- var k = start;
249
- var done = false;
250
- while (!done) {
251
- var e = extension.indexOf("-", k);
252
- var len = void 0;
253
- if (e === -1) {
254
- len = size - k;
255
- } else {
256
- len = e - k;
257
- }
258
- if (len === 2) {
259
- done = true;
260
- } else if (e === -1) {
261
- end = size;
262
- done = true;
263
- } else {
264
- end = e;
265
- k = e + 1;
266
- }
267
- }
268
- return extension.slice(start, end);
269
- }
270
- searchValue = "-" + key;
271
- pos = extension.indexOf(searchValue);
272
- if (pos !== -1 && pos + 3 === size) {
273
- return "";
274
- }
275
- return void 0;
276
- }
277
-
278
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/ResolveLocale.js
279
- function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
280
- var matcher = options.localeMatcher;
281
- var r;
282
- if (matcher === "lookup") {
283
- r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
284
- } else {
285
- r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
286
- }
287
- var foundLocale = r.locale;
288
- var result = {locale: "", dataLocale: foundLocale};
289
- var supportedExtension = "-u";
290
- for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
291
- var key = relevantExtensionKeys_1[_i];
292
- invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
293
- var foundLocaleData = localeData[foundLocale];
294
- invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
295
- var keyLocaleData = foundLocaleData[key];
296
- invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
297
- var value = keyLocaleData[0];
298
- invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
299
- var supportedExtensionAddition = "";
300
- if (r.extension) {
301
- var requestedValue = UnicodeExtensionValue(r.extension, key);
302
- if (requestedValue !== void 0) {
303
- if (requestedValue !== "") {
304
- if (~keyLocaleData.indexOf(requestedValue)) {
305
- value = requestedValue;
306
- supportedExtensionAddition = "-" + key + "-" + value;
307
- }
308
- } else if (~requestedValue.indexOf("true")) {
309
- value = "true";
310
- supportedExtensionAddition = "-" + key;
311
- }
312
- }
313
- }
314
- if (key in options) {
315
- var optionsValue = options[key];
316
- invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
317
- if (~keyLocaleData.indexOf(optionsValue)) {
318
- if (optionsValue !== value) {
319
- value = optionsValue;
320
- supportedExtensionAddition = "";
321
- }
322
- }
323
- }
324
- result[key] = value;
325
- supportedExtension += supportedExtensionAddition;
326
- }
327
- if (supportedExtension.length > 2) {
328
- var privateIndex = foundLocale.indexOf("-x-");
329
- if (privateIndex === -1) {
330
- foundLocale = foundLocale + supportedExtension;
331
- } else {
332
- var preExtension = foundLocale.slice(0, privateIndex);
333
- var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
334
- foundLocale = preExtension + supportedExtension + postExtension;
335
- }
336
- foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
337
- }
338
- result.locale = foundLocale;
339
- return result;
340
- }
497
+ // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/InitializeNumberFormat.js
498
+ var import_intl_localematcher = __toModule(require_intl_localematcher());
341
499
 
342
500
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/PartitionPattern.js
343
501
  function PartitionPattern(pattern) {
@@ -371,21 +529,8 @@
371
529
  return result;
372
530
  }
373
531
 
374
- // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/LookupSupportedLocales.js
375
- function LookupSupportedLocales(availableLocales, requestedLocales) {
376
- var subset = [];
377
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
378
- var locale = requestedLocales_1[_i];
379
- var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
380
- var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
381
- if (availableLocale) {
382
- subset.push(availableLocale);
383
- }
384
- }
385
- return subset;
386
- }
387
-
388
532
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/SupportedLocales.js
533
+ var import_intl_localematcher2 = __toModule(require_intl_localematcher());
389
534
  function SupportedLocales(availableLocales, requestedLocales, options) {
390
535
  var matcher = "best fit";
391
536
  if (options !== void 0) {
@@ -393,9 +538,9 @@
393
538
  matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
394
539
  }
395
540
  if (matcher === "best fit") {
396
- return LookupSupportedLocales(availableLocales, requestedLocales);
541
+ return (0, import_intl_localematcher2.LookupSupportedLocales)(availableLocales, requestedLocales);
397
542
  }
398
- return LookupSupportedLocales(availableLocales, requestedLocales);
543
+ return (0, import_intl_localematcher2.LookupSupportedLocales)(availableLocales, requestedLocales);
399
544
  }
400
545
 
401
546
  // node_modules/tslib/tslib.es6.js
@@ -439,6 +584,7 @@
439
584
  })(RangePatternType || (RangePatternType = {}));
440
585
 
441
586
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/abstract/InitializeRelativeTimeFormat.js
587
+ var import_intl_localematcher3 = __toModule(require_intl_localematcher());
442
588
  var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
443
589
  function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
444
590
  var getInternalSlots2 = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
@@ -456,7 +602,7 @@
456
602
  }
457
603
  }
458
604
  opt.nu = numberingSystem;
459
- var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
605
+ var r = (0, import_intl_localematcher3.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
460
606
  var locale = r.locale, nu = r.nu;
461
607
  internalSlots.locale = locale;
462
608
  internalSlots.style = GetOption(opts, "style", "string", ["long", "narrow", "short"], "long");
@@ -688,8 +834,15 @@
688
834
  }
689
835
 
690
836
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/should-polyfill.js
691
- function shouldPolyfill() {
692
- return !("RelativeTimeFormat" in Intl);
837
+ function supportedLocalesOf(locale) {
838
+ if (!locale) {
839
+ return true;
840
+ }
841
+ var locales = Array.isArray(locale) ? locale : [locale];
842
+ return Intl.RelativeTimeFormat.supportedLocalesOf(locales).length === locales.length;
843
+ }
844
+ function shouldPolyfill(locale) {
845
+ return !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale);
693
846
  }
694
847
 
695
848
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/polyfill.js
@@ -1,2 +1,2 @@
1
- export declare function shouldPolyfill(): boolean;
1
+ export declare function shouldPolyfill(locale?: string | string[]): boolean;
2
2
  //# sourceMappingURL=should-polyfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,YAE7B"}
1
+ {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-relativetimeformat/should-polyfill.ts"],"names":[],"mappings":"AAWA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAExD"}
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shouldPolyfill = void 0;
4
- function shouldPolyfill() {
5
- return !('RelativeTimeFormat' in Intl);
4
+ function supportedLocalesOf(locale) {
5
+ if (!locale) {
6
+ return true;
7
+ }
8
+ var locales = Array.isArray(locale) ? locale : [locale];
9
+ return (Intl.RelativeTimeFormat.supportedLocalesOf(locales).length ===
10
+ locales.length);
11
+ }
12
+ function shouldPolyfill(locale) {
13
+ return !('RelativeTimeFormat' in Intl) || !supportedLocalesOf(locale);
6
14
  }
7
15
  exports.shouldPolyfill = shouldPolyfill;