@formatjs/intl-getcanonicallocales 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/index.d.ts +6 -0
  2. package/index.d.ts.map +1 -0
  3. package/index.js +42 -0
  4. package/lib/index.d.ts +6 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +31 -0
  7. package/lib/polyfill.d.ts +2 -0
  8. package/lib/polyfill.d.ts.map +1 -0
  9. package/lib/polyfill.js +24 -0
  10. package/lib/should-polyfill.d.ts +2 -0
  11. package/lib/should-polyfill.d.ts.map +1 -0
  12. package/lib/should-polyfill.js +8 -0
  13. package/lib/src/aliases.generated.d.ts +5 -0
  14. package/lib/src/aliases.generated.d.ts.map +1 -0
  15. package/lib/src/aliases.generated.js +1137 -0
  16. package/lib/src/canonicalizer.d.ts +20 -0
  17. package/lib/src/canonicalizer.d.ts.map +1 -0
  18. package/lib/src/canonicalizer.js +219 -0
  19. package/lib/src/emitter.d.ts +4 -0
  20. package/lib/src/emitter.d.ts.map +1 -0
  21. package/lib/src/emitter.js +28 -0
  22. package/lib/src/likelySubtags.generated.d.ts +2 -0
  23. package/lib/src/likelySubtags.generated.d.ts.map +1 -0
  24. package/lib/src/likelySubtags.generated.js +1870 -0
  25. package/lib/src/parser.d.ts +10 -0
  26. package/lib/src/parser.d.ts.map +1 -0
  27. package/lib/src/parser.js +233 -0
  28. package/lib/src/types.d.ts +33 -0
  29. package/lib/src/types.d.ts.map +1 -0
  30. package/lib/src/types.js +1 -0
  31. package/package.json +1 -1
  32. package/polyfill.d.ts +2 -0
  33. package/polyfill.d.ts.map +1 -0
  34. package/polyfill.iife.js +3512 -0
  35. package/polyfill.js +26 -0
  36. package/should-polyfill.d.ts +2 -0
  37. package/should-polyfill.d.ts.map +1 -0
  38. package/should-polyfill.js +12 -0
  39. package/src/aliases.generated.d.ts +5 -0
  40. package/src/aliases.generated.d.ts.map +1 -0
  41. package/src/aliases.generated.js +1140 -0
  42. package/src/canonicalizer.d.ts +20 -0
  43. package/src/canonicalizer.d.ts.map +1 -0
  44. package/src/canonicalizer.js +224 -0
  45. package/src/emitter.d.ts +4 -0
  46. package/src/emitter.d.ts.map +1 -0
  47. package/src/emitter.js +33 -0
  48. package/src/likelySubtags.generated.d.ts +2 -0
  49. package/src/likelySubtags.generated.d.ts.map +1 -0
  50. package/src/likelySubtags.generated.js +1873 -0
  51. package/src/parser.d.ts +10 -0
  52. package/src/parser.d.ts.map +1 -0
  53. package/src/parser.js +243 -0
  54. package/src/types.d.ts +33 -0
  55. package/src/types.d.ts.map +1 -0
  56. package/src/types.js +2 -0
  57. package/BUILD +0 -116
  58. package/CHANGELOG.md +0 -290
  59. package/index.ts +0 -43
  60. package/polyfill.ts +0 -23
  61. package/scripts/aliases.ts +0 -70
  62. package/scripts/likely-subtags.ts +0 -20
  63. package/should-polyfill.ts +0 -10
  64. package/src/aliases.generated.ts +0 -1137
  65. package/src/canonicalizer.ts +0 -272
  66. package/src/emitter.ts +0 -39
  67. package/src/likelySubtags.generated.ts +0 -1870
  68. package/src/parser.ts +0 -259
  69. package/src/types.ts +0 -63
  70. package/tests/index.test.ts +0 -24
  71. package/tests/parser.test.ts +0 -204
  72. package/tsconfig.json +0 -5
package/polyfill.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _1 = require("./");
4
+ var should_polyfill_1 = require("./should-polyfill");
5
+ if (typeof Intl === 'undefined') {
6
+ if (typeof window !== 'undefined') {
7
+ Object.defineProperty(window, 'Intl', {
8
+ value: {},
9
+ });
10
+ // @ts-ignore we don't include @types/node so global isn't a thing
11
+ }
12
+ else if (typeof global !== 'undefined') {
13
+ // @ts-ignore we don't include @types/node so global isn't a thing
14
+ Object.defineProperty(global, 'Intl', {
15
+ value: {},
16
+ });
17
+ }
18
+ }
19
+ if ((0, should_polyfill_1.shouldPolyfill)()) {
20
+ Object.defineProperty(Intl, 'getCanonicalLocales', {
21
+ value: _1.getCanonicalLocales,
22
+ writable: true,
23
+ enumerable: false,
24
+ configurable: true,
25
+ });
26
+ }
@@ -0,0 +1,2 @@
1
+ export declare function shouldPolyfill(): boolean;
2
+ //# sourceMappingURL=should-polyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["should-polyfill.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,YAS7B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldPolyfill = void 0;
4
+ function shouldPolyfill() {
5
+ return (typeof Intl === 'undefined' ||
6
+ !('getCanonicalLocales' in Intl) ||
7
+ // Native Intl.getCanonicalLocales is just buggy
8
+ // https://bugs.chromium.org/p/v8/issues/detail?id=10682
9
+ Intl.getCanonicalLocales('und-x-private')[0] ===
10
+ 'x-private');
11
+ }
12
+ exports.shouldPolyfill = shouldPolyfill;
@@ -0,0 +1,5 @@
1
+ export declare const languageAlias: Record<string, string>;
2
+ export declare const territoryAlias: Record<string, string>;
3
+ export declare const scriptAlias: Record<string, string>;
4
+ export declare const variantAlias: Record<string, string>;
5
+ //# sourceMappingURL=aliases.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aliases.generated.d.ts","sourceRoot":"","sources":["aliases.generated.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqehD,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAioBjD,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAE9C,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG/C,CAAC"}