@formatjs/intl-datetimeformat 6.18.2 → 7.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.
Files changed (98) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -4
  3. package/package.json +19 -11
  4. package/polyfill-force.js +13 -15
  5. package/polyfill.iife.js +44 -44
  6. package/polyfill.js +15 -17
  7. package/should-polyfill.js +7 -10
  8. package/src/abstract/BasicFormatMatcher.js +26 -29
  9. package/src/abstract/BestFitFormatMatcher.js +19 -23
  10. package/src/abstract/DateTimeStyleFormat.js +5 -8
  11. package/src/abstract/FormatDateTime.d.ts +1 -1
  12. package/src/abstract/FormatDateTime.js +3 -6
  13. package/src/abstract/FormatDateTimePattern.d.ts +1 -1
  14. package/src/abstract/FormatDateTimePattern.js +12 -16
  15. package/src/abstract/FormatDateTimeRange.d.ts +2 -2
  16. package/src/abstract/FormatDateTimeRange.js +3 -6
  17. package/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -2
  18. package/src/abstract/FormatDateTimeRangeToParts.js +4 -7
  19. package/src/abstract/FormatDateTimeToParts.d.ts +1 -1
  20. package/src/abstract/FormatDateTimeToParts.js +5 -8
  21. package/src/abstract/InitializeDateTimeFormat.js +37 -40
  22. package/src/abstract/PartitionDateTimePattern.d.ts +2 -2
  23. package/src/abstract/PartitionDateTimePattern.js +6 -9
  24. package/src/abstract/PartitionDateTimeRangePattern.d.ts +2 -2
  25. package/src/abstract/PartitionDateTimeRangePattern.js +16 -19
  26. package/src/abstract/ToDateTimeOptions.js +3 -6
  27. package/src/abstract/ToLocalTime.js +11 -14
  28. package/src/abstract/skeleton.js +14 -20
  29. package/src/abstract/utils.js +9 -12
  30. package/src/core.d.ts +1 -1
  31. package/src/core.js +115 -116
  32. package/src/data/all-tz.js +1 -3
  33. package/src/data/links.js +1 -3
  34. package/src/get_internal_slots.js +1 -4
  35. package/src/packer.d.ts +1 -1
  36. package/src/packer.js +5 -9
  37. package/src/to_locale_string.js +8 -13
  38. package/src/types.d.ts +1 -1
  39. package/src/types.js +1 -2
  40. package/supported-locales.generated.js +1 -4
  41. package/test262-main.d.ts +1 -1
  42. package/test262-main.js +3 -6
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.js +0 -1
  45. package/lib/polyfill-force.d.ts +0 -1
  46. package/lib/polyfill-force.js +0 -44
  47. package/lib/polyfill.d.ts +0 -1
  48. package/lib/polyfill.js +0 -47
  49. package/lib/should-polyfill.d.ts +0 -1
  50. package/lib/should-polyfill.js +0 -61
  51. package/lib/src/abstract/BasicFormatMatcher.d.ts +0 -7
  52. package/lib/src/abstract/BasicFormatMatcher.js +0 -106
  53. package/lib/src/abstract/BestFitFormatMatcher.d.ts +0 -16
  54. package/lib/src/abstract/BestFitFormatMatcher.js +0 -116
  55. package/lib/src/abstract/DateTimeStyleFormat.d.ts +0 -2
  56. package/lib/src/abstract/DateTimeStyleFormat.js +0 -50
  57. package/lib/src/abstract/FormatDateTime.d.ts +0 -9
  58. package/lib/src/abstract/FormatDateTime.js +0 -15
  59. package/lib/src/abstract/FormatDateTimePattern.d.ts +0 -14
  60. package/lib/src/abstract/FormatDateTimePattern.js +0 -191
  61. package/lib/src/abstract/FormatDateTimeRange.d.ts +0 -4
  62. package/lib/src/abstract/FormatDateTimeRange.js +0 -10
  63. package/lib/src/abstract/FormatDateTimeRangeToParts.d.ts +0 -5
  64. package/lib/src/abstract/FormatDateTimeRangeToParts.js +0 -14
  65. package/lib/src/abstract/FormatDateTimeToParts.d.ts +0 -11
  66. package/lib/src/abstract/FormatDateTimeToParts.js +0 -21
  67. package/lib/src/abstract/InitializeDateTimeFormat.d.ts +0 -17
  68. package/lib/src/abstract/InitializeDateTimeFormat.js +0 -190
  69. package/lib/src/abstract/PartitionDateTimePattern.d.ts +0 -10
  70. package/lib/src/abstract/PartitionDateTimePattern.js +0 -17
  71. package/lib/src/abstract/PartitionDateTimeRangePattern.d.ts +0 -5
  72. package/lib/src/abstract/PartitionDateTimeRangePattern.js +0 -119
  73. package/lib/src/abstract/ToDateTimeOptions.d.ts +0 -7
  74. package/lib/src/abstract/ToDateTimeOptions.js +0 -63
  75. package/lib/src/abstract/ToLocalTime.d.ts +0 -26
  76. package/lib/src/abstract/ToLocalTime.js +0 -49
  77. package/lib/src/abstract/skeleton.d.ts +0 -13
  78. package/lib/src/abstract/skeleton.js +0 -294
  79. package/lib/src/abstract/utils.d.ts +0 -10
  80. package/lib/src/abstract/utils.js +0 -21
  81. package/lib/src/core.d.ts +0 -20
  82. package/lib/src/core.js +0 -300
  83. package/lib/src/data/all-tz.d.ts +0 -6
  84. package/lib/src/data/all-tz.js +0 -461
  85. package/lib/src/data/links.d.ts +0 -259
  86. package/lib/src/data/links.js +0 -260
  87. package/lib/src/get_internal_slots.d.ts +0 -2
  88. package/lib/src/get_internal_slots.js +0 -11
  89. package/lib/src/packer.d.ts +0 -4
  90. package/lib/src/packer.js +0 -39
  91. package/lib/src/to_locale_string.d.ts +0 -7
  92. package/lib/src/to_locale_string.js +0 -19
  93. package/lib/src/types.d.ts +0 -47
  94. package/lib/src/types.js +0 -1
  95. package/lib/supported-locales.generated.d.ts +0 -1
  96. package/lib/supported-locales.generated.js +0 -1
  97. package/lib/test262-main.d.ts +0 -1
  98. package/lib/test262-main.js +0 -23786
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './src/core';
1
+ export * from './src/core.js';
package/index.js CHANGED
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./src/core"), exports);
1
+ export * from './src/core.js';
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "@formatjs/intl-datetimeformat",
3
3
  "description": "Intl.DateTimeFormat polyfill",
4
- "version": "6.18.2",
5
- "license": "MIT",
4
+ "version": "7.0.0",
6
5
  "author": "Long Ho <holevietlong@gmail.com>",
7
- "types": "index.d.ts",
6
+ "bugs": "https://github.com/formatjs/formatjs/issues",
8
7
  "dependencies": {
8
+ "@formatjs/ecma402-abstract": "3.0.0",
9
+ "@formatjs/intl-localematcher": "0.7.0",
9
10
  "decimal.js": "^10.4.3",
10
- "tslib": "^2.8.0",
11
- "@formatjs/ecma402-abstract": "2.3.6",
12
- "@formatjs/intl-localematcher": "0.6.2"
11
+ "tslib": "^2.8.0"
13
12
  },
14
13
  "devDependencies": {
15
- "@formatjs/intl-locale": "4.2.13",
16
- "@formatjs/intl-getcanonicallocales": "2.5.6"
14
+ "@formatjs/intl-getcanonicallocales": "3.0.0",
15
+ "@formatjs/intl-locale": "5.0.0"
16
+ },
17
+ "exports": {
18
+ ".": "./index.js",
19
+ "./polyfill.js": "./polyfill.js",
20
+ "./polyfill-force.js": "./polyfill-force.js",
21
+ "./should-polyfill.js": "./should-polyfill.js",
22
+ "./add-all-tz.js": "./add-all-tz.js",
23
+ "./locale-data/*": "./locale-data/*"
17
24
  },
18
- "bugs": "https://github.com/formatjs/formatjs/issues",
19
25
  "homepage": "https://github.com/formatjs/formatjs#readme",
20
26
  "keywords": [
21
27
  "datetimeformat",
@@ -24,6 +30,8 @@
24
30
  "intl",
25
31
  "polyfill"
26
32
  ],
27
- "main": "index.js",
28
- "repository": "formatjs/formatjs.git"
33
+ "license": "MIT",
34
+ "repository": "formatjs/formatjs.git",
35
+ "type": "module",
36
+ "types": "index.d.ts"
29
37
  }
package/polyfill-force.js CHANGED
@@ -1,45 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
4
- var _1 = require("./");
5
- var to_locale_string_1 = require("./src/to_locale_string");
6
- (0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
7
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
1
+ import { defineProperty } from '@formatjs/ecma402-abstract';
2
+ import { DateTimeFormat } from './index.js';
3
+ import { toLocaleDateString as _toLocaleDateString, toLocaleString as _toLocaleString, toLocaleTimeString as _toLocaleTimeString, } from './src/to_locale_string.js';
4
+ defineProperty(Intl, 'DateTimeFormat', { value: DateTimeFormat });
5
+ defineProperty(Date.prototype, 'toLocaleString', {
8
6
  value: function toLocaleString(locales, options) {
9
7
  if (options === void 0) { options = {
10
8
  dateStyle: 'short',
11
9
  timeStyle: 'medium',
12
10
  }; }
13
11
  try {
14
- return (0, to_locale_string_1.toLocaleString)(this, locales, options);
12
+ return _toLocaleString(this, locales, options);
15
13
  }
16
- catch (error) {
14
+ catch (_a) {
17
15
  return 'Invalid Date';
18
16
  }
19
17
  },
20
18
  });
21
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
19
+ defineProperty(Date.prototype, 'toLocaleDateString', {
22
20
  value: function toLocaleDateString(locales, options) {
23
21
  if (options === void 0) { options = {
24
22
  dateStyle: 'short',
25
23
  }; }
26
24
  try {
27
- return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
25
+ return _toLocaleDateString(this, locales, options);
28
26
  }
29
- catch (error) {
27
+ catch (_a) {
30
28
  return 'Invalid Date';
31
29
  }
32
30
  },
33
31
  });
34
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
32
+ defineProperty(Date.prototype, 'toLocaleTimeString', {
35
33
  value: function toLocaleTimeString(locales, options) {
36
34
  if (options === void 0) { options = {
37
35
  timeStyle: 'medium',
38
36
  }; }
39
37
  try {
40
- return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
38
+ return _toLocaleTimeString(this, locales, options);
41
39
  }
42
- catch (error) {
40
+ catch (_a) {
43
41
  return 'Invalid Date';
44
42
  }
45
43
  },
package/polyfill.iife.js CHANGED
@@ -32,12 +32,12 @@
32
32
  return target;
33
33
  };
34
34
 
35
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/CanonicalizeLocaleList.js
35
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js
36
36
  function CanonicalizeLocaleList(locales) {
37
37
  return Intl.getCanonicalLocales(locales);
38
38
  }
39
39
 
40
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/CanonicalizeTimeZoneName.js
40
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeTimeZoneName.js
41
41
  function CanonicalizeTimeZoneName(tz, _a) {
42
42
  var zoneNames = _a.zoneNames, uppercaseLinks = _a.uppercaseLinks;
43
43
  var uppercasedTz = tz.toUpperCase();
@@ -2414,10 +2414,10 @@
2414
2414
  PI = new Decimal(PI);
2415
2415
  var decimal_default = Decimal;
2416
2416
 
2417
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/constants.js
2418
- var TEN = new decimal_default(10);
2419
- var ZERO = new decimal_default(0);
2420
- var NEGATIVE_ZERO = new decimal_default(-0);
2417
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
2418
+ var TEN = new Decimal(10);
2419
+ var ZERO = new Decimal(0);
2420
+ var NEGATIVE_ZERO = new Decimal(-0);
2421
2421
 
2422
2422
  // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2423
2423
  var extendStatics = function(d, b) {
@@ -2451,7 +2451,7 @@
2451
2451
  return to.concat(ar || Array.prototype.slice.call(from));
2452
2452
  }
2453
2453
 
2454
- // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2454
+ // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
2455
2455
  function memoize(fn, options) {
2456
2456
  var cache = options && options.cache ? options.cache : cacheDefault;
2457
2457
  var serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -2524,7 +2524,7 @@
2524
2524
  monadic: strategyMonadic
2525
2525
  };
2526
2526
 
2527
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2527
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js
2528
2528
  function defineProperty(target, name, _a) {
2529
2529
  var value = _a.value;
2530
2530
  Object.defineProperty(target, name, {
@@ -2593,7 +2593,7 @@
2593
2593
  strategy: strategies.variadic
2594
2594
  });
2595
2595
 
2596
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
2596
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js
2597
2597
  function ToString(o) {
2598
2598
  if (typeof o === "symbol") {
2599
2599
  throw TypeError("Cannot convert a Symbol value to a string");
@@ -2617,7 +2617,7 @@
2617
2617
  if (typeof arg === "string") {
2618
2618
  try {
2619
2619
  return new Decimal(arg);
2620
- } catch (e) {
2620
+ } catch (_a) {
2621
2621
  return new Decimal(NaN);
2622
2622
  }
2623
2623
  }
@@ -2665,7 +2665,7 @@
2665
2665
  return x !== x && y !== y;
2666
2666
  }
2667
2667
  function ArrayCreate(len) {
2668
- return new Array(len);
2668
+ return Array.from({ length: len });
2669
2669
  }
2670
2670
  var MS_PER_DAY = 864e5;
2671
2671
  function mod2(x, y) {
@@ -2874,7 +2874,7 @@
2874
2874
  return input;
2875
2875
  }
2876
2876
 
2877
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/DefaultNumberOption.js
2877
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/DefaultNumberOption.js
2878
2878
  function DefaultNumberOption(inputVal, min2, max2, fallback) {
2879
2879
  if (inputVal === void 0) {
2880
2880
  return fallback;
@@ -2886,13 +2886,13 @@
2886
2886
  return Math.floor(val);
2887
2887
  }
2888
2888
 
2889
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/GetNumberOption.js
2889
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetNumberOption.js
2890
2890
  function GetNumberOption(options, property, minimum, maximum, fallback) {
2891
2891
  var val = options[property];
2892
2892
  return DefaultNumberOption(val, minimum, maximum, fallback);
2893
2893
  }
2894
2894
 
2895
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/GetOption.js
2895
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js
2896
2896
  function GetOption(opts, prop, type, values, fallback) {
2897
2897
  if (typeof opts !== "object") {
2898
2898
  throw new TypeError("Options must be an object");
@@ -2918,7 +2918,7 @@
2918
2918
  return fallback;
2919
2919
  }
2920
2920
 
2921
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/IsSanctionedSimpleUnitIdentifier.js
2921
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js
2922
2922
  var SANCTIONED_UNITS = [
2923
2923
  "angle-degree",
2924
2924
  "area-acre",
@@ -2969,7 +2969,7 @@
2969
2969
  }
2970
2970
  var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
2971
2971
 
2972
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/IsValidTimeZoneName.js
2972
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsValidTimeZoneName.js
2973
2973
  function IsValidTimeZoneName(tz, _a) {
2974
2974
  var zoneNamesFromData = _a.zoneNamesFromData, uppercaseLinks = _a.uppercaseLinks;
2975
2975
  var uppercasedTz = tz.toUpperCase();
@@ -2987,29 +2987,29 @@
2987
2987
  return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
2988
2988
  }
2989
2989
 
2990
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponentForMagnitude.js
2991
- decimal_default.set({
2990
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
2991
+ Decimal.set({
2992
2992
  toExpPos: 100
2993
2993
  });
2994
2994
 
2995
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawFixed.js
2996
- decimal_default.set({
2995
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
2996
+ Decimal.set({
2997
2997
  toExpPos: 100
2998
2998
  });
2999
2999
 
3000
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
3000
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
3001
3001
  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]/;
3002
3002
 
3003
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/format_to_parts.js
3003
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js
3004
3004
  var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
3005
3005
  var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
3006
3006
 
3007
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeLocaleList.js
3007
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeLocaleList.js
3008
3008
  function CanonicalizeLocaleList2(locales) {
3009
3009
  return Intl.getCanonicalLocales(locales);
3010
3010
  }
3011
3011
 
3012
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/languageMatching.js
3012
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js
3013
3013
  var data = {
3014
3014
  supplemental: {
3015
3015
  languageMatching: {
@@ -5631,7 +5631,7 @@
5631
5631
  }
5632
5632
  };
5633
5633
 
5634
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/regions.generated.js
5634
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
5635
5635
  var regions = {
5636
5636
  "001": [
5637
5637
  "001",
@@ -6966,7 +6966,7 @@
6966
6966
  ]
6967
6967
  };
6968
6968
 
6969
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/utils.js
6969
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
6970
6970
  var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
6971
6971
  function invariant2(condition, message, Err) {
6972
6972
  if (Err === void 0) {
@@ -7120,7 +7120,7 @@
7120
7120
  return result;
7121
7121
  }
7122
7122
 
7123
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestFitMatcher.js
7123
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
7124
7124
  function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
7125
7125
  var foundLocale;
7126
7126
  var extension;
@@ -7145,7 +7145,7 @@
7145
7145
  };
7146
7146
  }
7147
7147
 
7148
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUValue.js
7148
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
7149
7149
  function CanonicalizeUValue(ukey, uvalue) {
7150
7150
  var lowerValue = uvalue.toLowerCase();
7151
7151
  invariant2(ukey !== void 0, "ukey must be defined");
@@ -7153,12 +7153,12 @@
7153
7153
  return canonicalized;
7154
7154
  }
7155
7155
 
7156
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/CanonicalizeUnicodeLocaleId.js
7156
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
7157
7157
  function CanonicalizeUnicodeLocaleId(locale) {
7158
7158
  return Intl.getCanonicalLocales(locale)[0];
7159
7159
  }
7160
7160
 
7161
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/InsertUnicodeExtensionAndCanonicalize.js
7161
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
7162
7162
  function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
7163
7163
  invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
7164
7164
  var extension = "-u";
@@ -7189,7 +7189,7 @@
7189
7189
  return CanonicalizeUnicodeLocaleId(newLocale);
7190
7190
  }
7191
7191
 
7192
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/BestAvailableLocale.js
7192
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
7193
7193
  function BestAvailableLocale(availableLocales, locale) {
7194
7194
  var candidate = locale;
7195
7195
  while (true) {
@@ -7207,7 +7207,7 @@
7207
7207
  }
7208
7208
  }
7209
7209
 
7210
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/LookupMatcher.js
7210
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
7211
7211
  function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
7212
7212
  var result = { locale: "" };
7213
7213
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
@@ -7226,7 +7226,7 @@
7226
7226
  return result;
7227
7227
  }
7228
7228
 
7229
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/UnicodeExtensionComponents.js
7229
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
7230
7230
  function UnicodeExtensionComponents(extension) {
7231
7231
  invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
7232
7232
  invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
@@ -7267,7 +7267,7 @@
7267
7267
  return { attributes, keywords };
7268
7268
  }
7269
7269
 
7270
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/ResolveLocale.js
7270
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
7271
7271
  function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
7272
7272
  var _a;
7273
7273
  var matcher = options.localeMatcher;
@@ -7353,7 +7353,7 @@
7353
7353
  return result;
7354
7354
  }
7355
7355
 
7356
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/abstract/LookupSupportedLocales.js
7356
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupSupportedLocales.js
7357
7357
  function LookupSupportedLocales(availableLocales, requestedLocales) {
7358
7358
  var subset = [];
7359
7359
  for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
@@ -7367,7 +7367,7 @@
7367
7367
  return subset;
7368
7368
  }
7369
7369
 
7370
- // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/lib/index.js
7370
+ // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
7371
7371
  function match(requestedLocales, availableLocales, defaultLocale, opts) {
7372
7372
  return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), {
7373
7373
  localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
@@ -7376,7 +7376,7 @@
7376
7376
  }).locale;
7377
7377
  }
7378
7378
 
7379
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/PartitionPattern.js
7379
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/PartitionPattern.js
7380
7380
  function PartitionPattern(pattern) {
7381
7381
  var result = [];
7382
7382
  var beginIndex = pattern.indexOf("{");
@@ -7408,7 +7408,7 @@
7408
7408
  return result;
7409
7409
  }
7410
7410
 
7411
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/SupportedLocales.js
7411
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/SupportedLocales.js
7412
7412
  function SupportedLocales(availableLocales, requestedLocales, options) {
7413
7413
  var matcher = "best fit";
7414
7414
  if (options !== void 0) {
@@ -7421,7 +7421,7 @@
7421
7421
  return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
7422
7422
  }
7423
7423
 
7424
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/data.js
7424
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/data.js
7425
7425
  var MissingLocaleDataError = (
7426
7426
  /** @class */
7427
7427
  function(_super) {
@@ -7435,7 +7435,7 @@
7435
7435
  }(Error)
7436
7436
  );
7437
7437
 
7438
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/types/date-time.js
7438
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/types/date-time.js
7439
7439
  var RangePatternType;
7440
7440
  (function(RangePatternType2) {
7441
7441
  RangePatternType2["startRange"] = "startRange";
@@ -7838,7 +7838,7 @@
7838
7838
  // packages/intl-datetimeformat/src/abstract/FormatDateTimeRangeToParts.ts
7839
7839
  function FormatDateTimeRangeToParts(dtf, x, y, implDetails) {
7840
7840
  const parts = PartitionDateTimeRangePattern(dtf, x, y, implDetails);
7841
- const result = new Array(0);
7841
+ const result = [];
7842
7842
  for (const part of parts) {
7843
7843
  result.push({
7844
7844
  type: part.type,
@@ -9328,7 +9328,7 @@
9328
9328
  }) {
9329
9329
  try {
9330
9330
  return toLocaleString(this, locales, options);
9331
- } catch (error) {
9331
+ } catch (e) {
9332
9332
  return "Invalid Date";
9333
9333
  }
9334
9334
  }
@@ -9339,7 +9339,7 @@
9339
9339
  }) {
9340
9340
  try {
9341
9341
  return toLocaleDateString(this, locales, options);
9342
- } catch (error) {
9342
+ } catch (e) {
9343
9343
  return "Invalid Date";
9344
9344
  }
9345
9345
  }
@@ -9350,7 +9350,7 @@
9350
9350
  }) {
9351
9351
  try {
9352
9352
  return toLocaleTimeString(this, locales, options);
9353
- } catch (error) {
9353
+ } catch (e) {
9354
9354
  return "Invalid Date";
9355
9355
  }
9356
9356
  }
package/polyfill.js CHANGED
@@ -1,47 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var _1 = require("./");
4
- var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
- var should_polyfill_1 = require("./should-polyfill");
6
- var to_locale_string_1 = require("./src/to_locale_string");
7
- if ((0, should_polyfill_1.shouldPolyfill)()) {
8
- (0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
9
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
1
+ import { DateTimeFormat } from './index.js';
2
+ import { defineProperty } from '@formatjs/ecma402-abstract';
3
+ import { shouldPolyfill } from './should-polyfill.js';
4
+ import { toLocaleString as _toLocaleString, toLocaleDateString as _toLocaleDateString, toLocaleTimeString as _toLocaleTimeString, } from './src/to_locale_string.js';
5
+ if (shouldPolyfill()) {
6
+ defineProperty(Intl, 'DateTimeFormat', { value: DateTimeFormat });
7
+ defineProperty(Date.prototype, 'toLocaleString', {
10
8
  value: function toLocaleString(locales, options) {
11
9
  if (options === void 0) { options = {
12
10
  dateStyle: 'short',
13
11
  timeStyle: 'medium',
14
12
  }; }
15
13
  try {
16
- return (0, to_locale_string_1.toLocaleString)(this, locales, options);
14
+ return _toLocaleString(this, locales, options);
17
15
  }
18
- catch (error) {
16
+ catch (_a) {
19
17
  return 'Invalid Date';
20
18
  }
21
19
  },
22
20
  });
23
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
21
+ defineProperty(Date.prototype, 'toLocaleDateString', {
24
22
  value: function toLocaleDateString(locales, options) {
25
23
  if (options === void 0) { options = {
26
24
  dateStyle: 'short',
27
25
  }; }
28
26
  try {
29
- return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
27
+ return _toLocaleDateString(this, locales, options);
30
28
  }
31
- catch (error) {
29
+ catch (_a) {
32
30
  return 'Invalid Date';
33
31
  }
34
32
  },
35
33
  });
36
- (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
34
+ defineProperty(Date.prototype, 'toLocaleTimeString', {
37
35
  value: function toLocaleTimeString(locales, options) {
38
36
  if (options === void 0) { options = {
39
37
  timeStyle: 'medium',
40
38
  }; }
41
39
  try {
42
- return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
40
+ return _toLocaleTimeString(this, locales, options);
43
41
  }
44
- catch (error) {
42
+ catch (_a) {
45
43
  return 'Invalid Date';
46
44
  }
47
45
  },
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldPolyfill = shouldPolyfill;
4
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
5
- var supported_locales_generated_1 = require("./supported-locales.generated");
1
+ import { match } from '@formatjs/intl-localematcher';
2
+ import { supportedLocales } from './supported-locales.generated.js';
6
3
  function supportsDateStyle() {
7
4
  try {
8
5
  return !!new Intl.DateTimeFormat(undefined, {
9
6
  dateStyle: 'short',
10
7
  }).resolvedOptions().dateStyle;
11
8
  }
12
- catch (e) {
9
+ catch (_a) {
13
10
  return false;
14
11
  }
15
12
  }
@@ -23,7 +20,7 @@ function hasChromeLt71Bug() {
23
20
  hour: 'numeric',
24
21
  }).formatToParts(0)[2].type !== 'dayPeriod');
25
22
  }
26
- catch (e) {
23
+ catch (_a) {
27
24
  return false;
28
25
  }
29
26
  }
@@ -39,7 +36,7 @@ function hasUnthrownDateTimeStyleBug() {
39
36
  hour: 'numeric',
40
37
  }).format(new Date(0));
41
38
  }
42
- catch (e) {
39
+ catch (_a) {
43
40
  return false;
44
41
  }
45
42
  }
@@ -50,7 +47,7 @@ function supportedLocalesOf(locale) {
50
47
  var locales = Array.isArray(locale) ? locale : [locale];
51
48
  return (Intl.DateTimeFormat.supportedLocalesOf(locales).length === locales.length);
52
49
  }
53
- function shouldPolyfill(locale) {
50
+ export function shouldPolyfill(locale) {
54
51
  if (locale === void 0) { locale = 'en'; }
55
52
  if (!('DateTimeFormat' in Intl) ||
56
53
  !('formatToParts' in Intl.DateTimeFormat.prototype) ||
@@ -59,6 +56,6 @@ function shouldPolyfill(locale) {
59
56
  hasUnthrownDateTimeStyleBug() ||
60
57
  !supportsDateStyle() ||
61
58
  !supportedLocalesOf(locale)) {
62
- return locale ? (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en') : undefined;
59
+ return locale ? match([locale], supportedLocales, 'en') : undefined;
63
60
  }
64
61
  }