gt-react-native 10.19.16 → 10.19.18

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 (170) hide show
  1. package/dist/commonjs/NativeGtReactNative.js +9 -7
  2. package/dist/commonjs/NativeGtReactNative.js.map +1 -1
  3. package/dist/commonjs/_virtual/_rolldown/runtime.js +23 -0
  4. package/dist/commonjs/errors-dir/constants.js +5 -6
  5. package/dist/commonjs/errors-dir/constants.js.map +1 -1
  6. package/dist/commonjs/errors-dir/errors.js +12 -7
  7. package/dist/commonjs/errors-dir/errors.js.map +1 -1
  8. package/dist/commonjs/errors-dir/warnings.js +34 -15
  9. package/dist/commonjs/errors-dir/warnings.js.map +1 -1
  10. package/dist/commonjs/index.js +35 -194
  11. package/dist/commonjs/internal.js +3 -13
  12. package/dist/commonjs/plugin-dir/index.js +35 -51
  13. package/dist/commonjs/plugin-dir/index.js.map +1 -1
  14. package/dist/commonjs/plugin-dir/types.js +24 -9
  15. package/dist/commonjs/plugin-dir/types.js.map +1 -1
  16. package/dist/commonjs/plugin-dir/utils/resolveLocales.js +52 -69
  17. package/dist/commonjs/plugin-dir/utils/resolveLocales.js.map +1 -1
  18. package/dist/commonjs/plugin.js +5 -13
  19. package/dist/commonjs/provider/GTProvider.js +22 -20
  20. package/dist/commonjs/provider/GTProvider.js.map +1 -1
  21. package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js +96 -160
  22. package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js.map +1 -1
  23. package/dist/commonjs/provider/hooks/useRegionState.js +32 -44
  24. package/dist/commonjs/provider/hooks/useRegionState.js.map +1 -1
  25. package/dist/commonjs/tools/testLocalePolyfill.js +125 -146
  26. package/dist/commonjs/tools/testLocalePolyfill.js.map +1 -1
  27. package/dist/commonjs/types/config.js +1 -6
  28. package/dist/commonjs/utils/getNativeLocales.js +36 -54
  29. package/dist/commonjs/utils/getNativeLocales.js.map +1 -1
  30. package/dist/commonjs/utils/nativeStore.js +37 -42
  31. package/dist/commonjs/utils/nativeStore.js.map +1 -1
  32. package/dist/commonjs/utils/utils.js +10 -14
  33. package/dist/commonjs/utils/utils.js.map +1 -1
  34. package/dist/module/NativeGtReactNative.d.ts.map +1 -0
  35. package/dist/module/NativeGtReactNative.js +5 -3
  36. package/dist/module/NativeGtReactNative.js.map +1 -1
  37. package/dist/module/errors-dir/constants.d.ts.map +1 -0
  38. package/dist/module/errors-dir/constants.js +4 -2
  39. package/dist/module/errors-dir/constants.js.map +1 -1
  40. package/dist/module/errors-dir/errors.d.ts.map +1 -0
  41. package/dist/module/errors-dir/errors.js +11 -3
  42. package/dist/module/errors-dir/errors.js.map +1 -1
  43. package/dist/{typescript/commonjs/src → module}/errors-dir/warnings.d.ts +1 -1
  44. package/dist/module/errors-dir/warnings.d.ts.map +1 -0
  45. package/dist/module/errors-dir/warnings.js +31 -11
  46. package/dist/module/errors-dir/warnings.js.map +1 -1
  47. package/dist/module/index.d.ts.map +1 -0
  48. package/dist/module/index.js +2 -5
  49. package/dist/module/internal.d.ts.map +1 -0
  50. package/dist/module/internal.js +2 -4
  51. package/dist/module/plugin-dir/index.d.ts.map +1 -0
  52. package/dist/module/plugin-dir/index.js +28 -45
  53. package/dist/module/plugin-dir/index.js.map +1 -1
  54. package/dist/module/plugin-dir/types.d.ts.map +1 -0
  55. package/dist/module/plugin-dir/types.js +22 -5
  56. package/dist/module/plugin-dir/types.js.map +1 -1
  57. package/dist/module/plugin-dir/utils/resolveLocales.d.ts.map +1 -0
  58. package/dist/module/plugin-dir/utils/resolveLocales.js +46 -62
  59. package/dist/module/plugin-dir/utils/resolveLocales.js.map +1 -1
  60. package/dist/module/plugin.d.ts.map +1 -0
  61. package/dist/module/plugin.js +2 -4
  62. package/dist/module/provider/GTProvider.d.ts.map +1 -0
  63. package/dist/module/provider/GTProvider.js +15 -14
  64. package/dist/module/provider/GTProvider.js.map +1 -1
  65. package/dist/module/provider/hooks/locale/useDetermineLocale.d.ts.map +1 -0
  66. package/dist/module/provider/hooks/locale/useDetermineLocale.js +91 -153
  67. package/dist/module/provider/hooks/locale/useDetermineLocale.js.map +1 -1
  68. package/dist/module/provider/hooks/useRegionState.d.ts.map +1 -0
  69. package/dist/module/provider/hooks/useRegionState.js +29 -39
  70. package/dist/module/provider/hooks/useRegionState.js.map +1 -1
  71. package/dist/module/tools/testLocalePolyfill.d.ts.map +1 -0
  72. package/dist/module/tools/testLocalePolyfill.js +124 -143
  73. package/dist/module/tools/testLocalePolyfill.js.map +1 -1
  74. package/dist/module/types/config.d.ts.map +1 -0
  75. package/dist/module/types/config.js +0 -3
  76. package/dist/module/utils/getNativeLocales.d.ts.map +1 -0
  77. package/dist/module/utils/getNativeLocales.js +35 -51
  78. package/dist/module/utils/getNativeLocales.js.map +1 -1
  79. package/dist/module/utils/nativeStore.d.ts.map +1 -0
  80. package/dist/module/utils/nativeStore.js +35 -38
  81. package/dist/module/utils/nativeStore.js.map +1 -1
  82. package/dist/module/utils/utils.d.ts.map +1 -0
  83. package/dist/module/utils/utils.js +10 -11
  84. package/dist/module/utils/utils.js.map +1 -1
  85. package/package.json +15 -37
  86. package/src/errors-dir/errors.ts +8 -1
  87. package/src/errors-dir/warnings.ts +30 -9
  88. package/dist/commonjs/index.js.map +0 -1
  89. package/dist/commonjs/internal.js.map +0 -1
  90. package/dist/commonjs/package.json +0 -1
  91. package/dist/commonjs/plugin.js.map +0 -1
  92. package/dist/commonjs/types/config.js.map +0 -1
  93. package/dist/module/index.js.map +0 -1
  94. package/dist/module/internal.js.map +0 -1
  95. package/dist/module/package.json +0 -1
  96. package/dist/module/plugin.js.map +0 -1
  97. package/dist/module/types/config.js.map +0 -1
  98. package/dist/typescript/commonjs/package.json +0 -1
  99. package/dist/typescript/commonjs/src/NativeGtReactNative.d.ts.map +0 -1
  100. package/dist/typescript/commonjs/src/errors-dir/constants.d.ts.map +0 -1
  101. package/dist/typescript/commonjs/src/errors-dir/errors.d.ts.map +0 -1
  102. package/dist/typescript/commonjs/src/errors-dir/warnings.d.ts.map +0 -1
  103. package/dist/typescript/commonjs/src/index.d.ts.map +0 -1
  104. package/dist/typescript/commonjs/src/internal.d.ts.map +0 -1
  105. package/dist/typescript/commonjs/src/plugin-dir/index.d.ts.map +0 -1
  106. package/dist/typescript/commonjs/src/plugin-dir/types.d.ts.map +0 -1
  107. package/dist/typescript/commonjs/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
  108. package/dist/typescript/commonjs/src/plugin.d.ts.map +0 -1
  109. package/dist/typescript/commonjs/src/provider/GTProvider.d.ts.map +0 -1
  110. package/dist/typescript/commonjs/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
  111. package/dist/typescript/commonjs/src/provider/hooks/useRegionState.d.ts.map +0 -1
  112. package/dist/typescript/commonjs/src/tools/testLocalePolyfill.d.ts.map +0 -1
  113. package/dist/typescript/commonjs/src/types/config.d.ts.map +0 -1
  114. package/dist/typescript/commonjs/src/utils/getNativeLocales.d.ts.map +0 -1
  115. package/dist/typescript/commonjs/src/utils/nativeStore.d.ts.map +0 -1
  116. package/dist/typescript/commonjs/src/utils/utils.d.ts.map +0 -1
  117. package/dist/typescript/module/package.json +0 -1
  118. package/dist/typescript/module/src/NativeGtReactNative.d.ts +0 -10
  119. package/dist/typescript/module/src/NativeGtReactNative.d.ts.map +0 -1
  120. package/dist/typescript/module/src/errors-dir/constants.d.ts +0 -2
  121. package/dist/typescript/module/src/errors-dir/constants.d.ts.map +0 -1
  122. package/dist/typescript/module/src/errors-dir/errors.d.ts +0 -2
  123. package/dist/typescript/module/src/errors-dir/errors.d.ts.map +0 -1
  124. package/dist/typescript/module/src/errors-dir/warnings.d.ts +0 -5
  125. package/dist/typescript/module/src/errors-dir/warnings.d.ts.map +0 -1
  126. package/dist/typescript/module/src/index.d.ts +0 -5
  127. package/dist/typescript/module/src/index.d.ts.map +0 -1
  128. package/dist/typescript/module/src/internal.d.ts +0 -2
  129. package/dist/typescript/module/src/internal.d.ts.map +0 -1
  130. package/dist/typescript/module/src/plugin-dir/index.d.ts +0 -6
  131. package/dist/typescript/module/src/plugin-dir/index.d.ts.map +0 -1
  132. package/dist/typescript/module/src/plugin-dir/types.d.ts +0 -13
  133. package/dist/typescript/module/src/plugin-dir/types.d.ts.map +0 -1
  134. package/dist/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts +0 -13
  135. package/dist/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
  136. package/dist/typescript/module/src/plugin.d.ts +0 -2
  137. package/dist/typescript/module/src/plugin.d.ts.map +0 -1
  138. package/dist/typescript/module/src/provider/GTProvider.d.ts +0 -4
  139. package/dist/typescript/module/src/provider/GTProvider.d.ts.map +0 -1
  140. package/dist/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts +0 -4
  141. package/dist/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
  142. package/dist/typescript/module/src/provider/hooks/useRegionState.d.ts +0 -3
  143. package/dist/typescript/module/src/provider/hooks/useRegionState.d.ts.map +0 -1
  144. package/dist/typescript/module/src/tools/testLocalePolyfill.d.ts +0 -8
  145. package/dist/typescript/module/src/tools/testLocalePolyfill.d.ts.map +0 -1
  146. package/dist/typescript/module/src/types/config.d.ts +0 -30
  147. package/dist/typescript/module/src/types/config.d.ts.map +0 -1
  148. package/dist/typescript/module/src/utils/getNativeLocales.d.ts +0 -10
  149. package/dist/typescript/module/src/utils/getNativeLocales.d.ts.map +0 -1
  150. package/dist/typescript/module/src/utils/nativeStore.d.ts +0 -16
  151. package/dist/typescript/module/src/utils/nativeStore.d.ts.map +0 -1
  152. package/dist/typescript/module/src/utils/utils.d.ts +0 -3
  153. package/dist/typescript/module/src/utils/utils.d.ts.map +0 -1
  154. /package/dist/{typescript/commonjs/src → module}/NativeGtReactNative.d.ts +0 -0
  155. /package/dist/{typescript/commonjs/src → module}/errors-dir/constants.d.ts +0 -0
  156. /package/dist/{typescript/commonjs/src → module}/errors-dir/errors.d.ts +0 -0
  157. /package/dist/{typescript/commonjs/src → module}/index.d.ts +0 -0
  158. /package/dist/{typescript/commonjs/src → module}/internal.d.ts +0 -0
  159. /package/dist/{typescript/commonjs/src → module}/plugin-dir/index.d.ts +0 -0
  160. /package/dist/{typescript/commonjs/src → module}/plugin-dir/types.d.ts +0 -0
  161. /package/dist/{typescript/commonjs/src → module}/plugin-dir/utils/resolveLocales.d.ts +0 -0
  162. /package/dist/{typescript/commonjs/src → module}/plugin.d.ts +0 -0
  163. /package/dist/{typescript/commonjs/src → module}/provider/GTProvider.d.ts +0 -0
  164. /package/dist/{typescript/commonjs/src → module}/provider/hooks/locale/useDetermineLocale.d.ts +0 -0
  165. /package/dist/{typescript/commonjs/src → module}/provider/hooks/useRegionState.d.ts +0 -0
  166. /package/dist/{typescript/commonjs/src → module}/tools/testLocalePolyfill.d.ts +0 -0
  167. /package/dist/{typescript/commonjs/src → module}/types/config.d.ts +0 -0
  168. /package/dist/{typescript/commonjs/src → module}/utils/getNativeLocales.d.ts +0 -0
  169. /package/dist/{typescript/commonjs/src → module}/utils/nativeStore.d.ts +0 -0
  170. /package/dist/{typescript/commonjs/src → module}/utils/utils.d.ts +0 -0
@@ -1,9 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
5
4
  });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('GtReactNative');
5
+ require("./_virtual/_rolldown/runtime.js");
6
+ //#region src/NativeGtReactNative.ts
7
+ var NativeGtReactNative_default = require("react-native").TurboModuleRegistry.getEnforcing("GtReactNative");
8
+ //#endregion
9
+ exports.default = NativeGtReactNative_default;
10
+
9
11
  //# sourceMappingURL=NativeGtReactNative.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeGtReactNative.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAQpCC,gCAAmB,CAACC,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"NativeGtReactNative.js","names":["TurboModuleRegistry"],"sources":["../../src/NativeGtReactNative.ts"],"sourcesContent":["import type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\nexport interface Spec extends TurboModule {\n multiply(a: number, b: number): number;\n getNativeLocales(): string[];\n nativeStoreGet(key: string): string | null;\n nativeStoreSet(key: string, value: string): void;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>('GtReactNative');\n"],"mappings":";;;;;;AASA,IAAA,qDAAeA,CAAAA,oBAAoB,aAAmB,gBAAgB"}
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
@@ -1,8 +1,7 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/errors-dir/constants.ts
3
+ const PACKAGE_NAME = "gt-react-native";
4
+ //#endregion
5
+ exports.PACKAGE_NAME = PACKAGE_NAME;
2
6
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PACKAGE_NAME = void 0;
7
- const PACKAGE_NAME = exports.PACKAGE_NAME = 'gt-react-native';
8
7
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PACKAGE_NAME","exports"],"sourceRoot":"../../../src","sources":["errors-dir/constants.ts"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../src/errors-dir/constants.ts"],"sourcesContent":["export const PACKAGE_NAME = 'gt-react-native';\n"],"mappings":";;AAAA,MAAa,eAAe"}
@@ -1,10 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_errors_dir_constants = require("./constants.js");
4
+ let generaltranslation_internal = require("generaltranslation/internal");
5
+ //#region src/errors-dir/errors.ts
6
+ const failedToReadConfigFileError = (filePath) => (0, generaltranslation_internal.createDiagnosticMessage)({
7
+ source: require_errors_dir_constants.PACKAGE_NAME,
8
+ severity: "Error",
9
+ whatHappened: `GT Config at ${filePath} could not be read`,
10
+ fix: "Check that the file exists and contains valid JSON"
5
11
  });
6
- exports.failedToReadConfigFileError = void 0;
7
- var _constants = require("./constants");
8
- const failedToReadConfigFileError = filePath => `${_constants.PACKAGE_NAME} Error: Failed to read GT Config at ${filePath}.`;
12
+ //#endregion
9
13
  exports.failedToReadConfigFileError = failedToReadConfigFileError;
14
+
10
15
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","failedToReadConfigFileError","filePath","PACKAGE_NAME","exports"],"sourceRoot":"../../../src","sources":["errors-dir/errors.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACO,MAAMC,2BAA2B,GAAIC,QAAgB,IAC1D,GAAGC,uBAAY,uCAAuCD,QAAQ,GAAG;AAACE,OAAA,CAAAH,2BAAA,GAAAA,2BAAA","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["PACKAGE_NAME"],"sources":["../../../src/errors-dir/errors.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { PACKAGE_NAME } from './constants';\n\nexport const failedToReadConfigFileError = (filePath: string) =>\n createDiagnosticMessage({\n source: PACKAGE_NAME,\n severity: 'Error',\n whatHappened: `GT Config at ${filePath} could not be read`,\n fix: 'Check that the file exists and contains valid JSON',\n });\n"],"mappings":";;;;;AAGA,MAAa,+BAA+B,cAAA,GAAA,4BAAA,yBAClB;CACtB,QAAQA,6BAAAA;CACR,UAAU;CACV,cAAc,gBAAgB,SAAS;CACvC,KAAK;CACN,CAAC"}
@@ -1,19 +1,38 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_errors_dir_constants = require("./constants.js");
4
+ let generaltranslation_internal = require("generaltranslation/internal");
5
+ //#region src/errors-dir/warnings.ts
6
+ const resolveLocalesFailedWarning = (0, generaltranslation_internal.createDiagnosticMessage)({
7
+ source: require_errors_dir_constants.PACKAGE_NAME,
8
+ severity: "Warning",
9
+ whatHappened: "Locales for the polyfill could not be resolved",
10
+ fix: "Provide locales directly, pass your GT Config to the plugin, or provide the path to your GT Config file",
11
+ wayOut: `The library will fall back to ${generaltranslation_internal.libraryDefaultLocale}`
12
+ });
13
+ const couldNotLocateConfigWarning = (filePath) => (0, generaltranslation_internal.createDiagnosticMessage)({
14
+ source: require_errors_dir_constants.PACKAGE_NAME,
15
+ severity: "Warning",
16
+ whatHappened: `GT Config could not be found at ${filePath}`,
17
+ fix: "Check the path or pass locales directly to the plugin"
18
+ });
19
+ const invalidLocalesWarning = (invalidLocales) => (0, generaltranslation_internal.createDiagnosticMessage)({
20
+ source: require_errors_dir_constants.PACKAGE_NAME,
21
+ severity: "Warning",
22
+ whatHappened: "GT Config contains invalid locales",
23
+ fix: "Use valid BCP 47 locale codes or add custom mappings",
24
+ details: invalidLocales
5
25
  });
6
- exports.ssrUnsupportedWarning = exports.resolveLocalesFailedWarning = exports.invalidLocalesWarning = exports.couldNotLocateConfigWarning = void 0;
7
- var _internal = require("generaltranslation/internal");
8
- var _constants = require("./constants");
9
- const resolveLocalesFailedWarning = exports.resolveLocalesFailedWarning = `${_constants.PACKAGE_NAME}: Failed to resolve locales for polyfill. Falling back to ${_internal.libraryDefaultLocale}.
10
- Specify a list of locales for the gt-react-native babel plugin by:
11
- (1) Providing a list of locales
12
- (2) Providing your GT Config to the plugin
13
- (3) Providing the path to your GT Config file.`;
14
- const couldNotLocateConfigWarning = filePath => `${_constants.PACKAGE_NAME}: Could not locate GT Config at ${filePath}.`;
26
+ const ssrUnsupportedWarning = (0, generaltranslation_internal.createDiagnosticMessage)({
27
+ source: require_errors_dir_constants.PACKAGE_NAME,
28
+ severity: "Warning",
29
+ whatHappened: "Server-side environments are not explicitly supported",
30
+ wayOut: "Some features may not work as expected"
31
+ });
32
+ //#endregion
15
33
  exports.couldNotLocateConfigWarning = couldNotLocateConfigWarning;
16
- const invalidLocalesWarning = invalidLocales => `${_constants.PACKAGE_NAME}: Invalid locales found in GT Config: ${invalidLocales.join(', ')}.`;
17
34
  exports.invalidLocalesWarning = invalidLocalesWarning;
18
- const ssrUnsupportedWarning = exports.ssrUnsupportedWarning = `${_constants.PACKAGE_NAME}: Server-side environments are not explicitly supported. Some features may not work as expected.`;
35
+ exports.resolveLocalesFailedWarning = resolveLocalesFailedWarning;
36
+ exports.ssrUnsupportedWarning = ssrUnsupportedWarning;
37
+
19
38
  //# sourceMappingURL=warnings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_internal","require","_constants","resolveLocalesFailedWarning","exports","PACKAGE_NAME","libraryDefaultLocale","couldNotLocateConfigWarning","filePath","invalidLocalesWarning","invalidLocales","join","ssrUnsupportedWarning"],"sourceRoot":"../../../src","sources":["errors-dir/warnings.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEO,MAAME,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,GAAGE,uBAAY,6DAA6DC,8BAAoB;AAC3I;AACA;AACA;AACA,+CAA+C;AAExC,MAAMC,2BAA2B,GAAIC,QAAgB,IAC1D,GAAGH,uBAAY,mCAAmCG,QAAQ,GAAG;AAACJ,OAAA,CAAAG,2BAAA,GAAAA,2BAAA;AAEzD,MAAME,qBAAqB,GAAIC,cAAwB,IAC5D,GAAGL,uBAAY,yCAAyCK,cAAc,CAACC,IAAI,CAAC,IAAI,CAAC,GAAG;AAACP,OAAA,CAAAK,qBAAA,GAAAA,qBAAA;AAEhF,MAAMG,qBAAqB,GAAAR,OAAA,CAAAQ,qBAAA,GAAG,GAAGP,uBAAY,kGAAkG","ignoreList":[]}
1
+ {"version":3,"file":"warnings.js","names":["PACKAGE_NAME","libraryDefaultLocale"],"sources":["../../../src/errors-dir/warnings.ts"],"sourcesContent":["import {\n createDiagnosticMessage,\n libraryDefaultLocale,\n} from 'generaltranslation/internal';\nimport { PACKAGE_NAME } from './constants';\n\nexport const resolveLocalesFailedWarning = createDiagnosticMessage({\n source: PACKAGE_NAME,\n severity: 'Warning',\n whatHappened: 'Locales for the polyfill could not be resolved',\n fix: 'Provide locales directly, pass your GT Config to the plugin, or provide the path to your GT Config file',\n wayOut: `The library will fall back to ${libraryDefaultLocale}`,\n});\n\nexport const couldNotLocateConfigWarning = (filePath: string) =>\n createDiagnosticMessage({\n source: PACKAGE_NAME,\n severity: 'Warning',\n whatHappened: `GT Config could not be found at ${filePath}`,\n fix: 'Check the path or pass locales directly to the plugin',\n });\n\nexport const invalidLocalesWarning = (invalidLocales: string[]) =>\n createDiagnosticMessage({\n source: PACKAGE_NAME,\n severity: 'Warning',\n whatHappened: 'GT Config contains invalid locales',\n fix: 'Use valid BCP 47 locale codes or add custom mappings',\n details: invalidLocales,\n });\n\nexport const ssrUnsupportedWarning = createDiagnosticMessage({\n source: PACKAGE_NAME,\n severity: 'Warning',\n whatHappened: 'Server-side environments are not explicitly supported',\n wayOut: 'Some features may not work as expected',\n});\n"],"mappings":";;;;;AAMA,MAAa,+BAAA,GAAA,4BAAA,yBAAsD;CACjE,QAAQA,6BAAAA;CACR,UAAU;CACV,cAAc;CACd,KAAK;CACL,QAAQ,iCAAiCC,4BAAAA;CAC1C,CAAC;AAEF,MAAa,+BAA+B,cAAA,GAAA,4BAAA,yBAClB;CACtB,QAAQD,6BAAAA;CACR,UAAU;CACV,cAAc,mCAAmC;CACjD,KAAK;CACN,CAAC;AAEJ,MAAa,yBAAyB,oBAAA,GAAA,4BAAA,yBACZ;CACtB,QAAQA,6BAAAA;CACR,UAAU;CACV,cAAc;CACd,KAAK;CACL,SAAS;CACV,CAAC;AAEJ,MAAa,yBAAA,GAAA,4BAAA,yBAAgD;CAC3D,QAAQA,6BAAAA;CACR,UAAU;CACV,cAAc;CACd,QAAQ;CACT,CAAC"}
@@ -1,194 +1,35 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Branch", {
7
- enumerable: true,
8
- get: function () {
9
- return _reactCore.Branch;
10
- }
11
- });
12
- Object.defineProperty(exports, "Currency", {
13
- enumerable: true,
14
- get: function () {
15
- return _reactCore.Currency;
16
- }
17
- });
18
- Object.defineProperty(exports, "DateTime", {
19
- enumerable: true,
20
- get: function () {
21
- return _reactCore.DateTime;
22
- }
23
- });
24
- Object.defineProperty(exports, "GTProvider", {
25
- enumerable: true,
26
- get: function () {
27
- return _GTProvider.GTProvider;
28
- }
29
- });
30
- Object.defineProperty(exports, "Num", {
31
- enumerable: true,
32
- get: function () {
33
- return _reactCore.Num;
34
- }
35
- });
36
- Object.defineProperty(exports, "Plural", {
37
- enumerable: true,
38
- get: function () {
39
- return _reactCore.Plural;
40
- }
41
- });
42
- Object.defineProperty(exports, "Static", {
43
- enumerable: true,
44
- get: function () {
45
- return _reactCore.Static;
46
- }
47
- });
48
- Object.defineProperty(exports, "T", {
49
- enumerable: true,
50
- get: function () {
51
- return _reactCore.T;
52
- }
53
- });
54
- Object.defineProperty(exports, "Var", {
55
- enumerable: true,
56
- get: function () {
57
- return _reactCore.Var;
58
- }
59
- });
60
- Object.defineProperty(exports, "declareStatic", {
61
- enumerable: true,
62
- get: function () {
63
- return _reactCore.declareStatic;
64
- }
65
- });
66
- Object.defineProperty(exports, "declareVar", {
67
- enumerable: true,
68
- get: function () {
69
- return _reactCore.declareVar;
70
- }
71
- });
72
- Object.defineProperty(exports, "decodeMsg", {
73
- enumerable: true,
74
- get: function () {
75
- return _reactCore.decodeMsg;
76
- }
77
- });
78
- Object.defineProperty(exports, "decodeOptions", {
79
- enumerable: true,
80
- get: function () {
81
- return _reactCore.decodeOptions;
82
- }
83
- });
84
- Object.defineProperty(exports, "decodeVars", {
85
- enumerable: true,
86
- get: function () {
87
- return _reactCore.decodeVars;
88
- }
89
- });
90
- Object.defineProperty(exports, "gtFallback", {
91
- enumerable: true,
92
- get: function () {
93
- return _reactCore.gtFallback;
94
- }
95
- });
96
- Object.defineProperty(exports, "mFallback", {
97
- enumerable: true,
98
- get: function () {
99
- return _reactCore.mFallback;
100
- }
101
- });
102
- Object.defineProperty(exports, "msg", {
103
- enumerable: true,
104
- get: function () {
105
- return _reactCore.msg;
106
- }
107
- });
108
- Object.defineProperty(exports, "useDefaultLocale", {
109
- enumerable: true,
110
- get: function () {
111
- return _reactCore.useDefaultLocale;
112
- }
113
- });
114
- Object.defineProperty(exports, "useGT", {
115
- enumerable: true,
116
- get: function () {
117
- return _reactCore.useGT;
118
- }
119
- });
120
- Object.defineProperty(exports, "useGTClass", {
121
- enumerable: true,
122
- get: function () {
123
- return _reactCore.useGTClass;
124
- }
125
- });
126
- Object.defineProperty(exports, "useLocale", {
127
- enumerable: true,
128
- get: function () {
129
- return _reactCore.useLocale;
130
- }
131
- });
132
- Object.defineProperty(exports, "useLocaleDirection", {
133
- enumerable: true,
134
- get: function () {
135
- return _reactCore.useLocaleDirection;
136
- }
137
- });
138
- Object.defineProperty(exports, "useLocaleProperties", {
139
- enumerable: true,
140
- get: function () {
141
- return _reactCore.useLocaleProperties;
142
- }
143
- });
144
- Object.defineProperty(exports, "useLocaleSelector", {
145
- enumerable: true,
146
- get: function () {
147
- return _reactCore.useLocaleSelector;
148
- }
149
- });
150
- Object.defineProperty(exports, "useLocales", {
151
- enumerable: true,
152
- get: function () {
153
- return _reactCore.useLocales;
154
- }
155
- });
156
- Object.defineProperty(exports, "useMessages", {
157
- enumerable: true,
158
- get: function () {
159
- return _reactCore.useMessages;
160
- }
161
- });
162
- Object.defineProperty(exports, "useRegion", {
163
- enumerable: true,
164
- get: function () {
165
- return _reactCore.useRegion;
166
- }
167
- });
168
- Object.defineProperty(exports, "useRegionSelector", {
169
- enumerable: true,
170
- get: function () {
171
- return _reactCore.useRegionSelector;
172
- }
173
- });
174
- Object.defineProperty(exports, "useSetLocale", {
175
- enumerable: true,
176
- get: function () {
177
- return _reactCore.useSetLocale;
178
- }
179
- });
180
- Object.defineProperty(exports, "useTranslations", {
181
- enumerable: true,
182
- get: function () {
183
- return _reactCore.useTranslations;
184
- }
185
- });
186
- Object.defineProperty(exports, "useVersionId", {
187
- enumerable: true,
188
- get: function () {
189
- return _reactCore.useVersionId;
190
- }
191
- });
192
- var _GTProvider = require("./provider/GTProvider");
193
- var _reactCore = require("@generaltranslation/react-core");
194
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./_virtual/_rolldown/runtime.js");
3
+ const require_provider_GTProvider = require("./provider/GTProvider.js");
4
+ let _generaltranslation_react_core = require("@generaltranslation/react-core");
5
+ exports.Branch = _generaltranslation_react_core.Branch;
6
+ exports.Currency = _generaltranslation_react_core.Currency;
7
+ exports.DateTime = _generaltranslation_react_core.DateTime;
8
+ exports.GTProvider = require_provider_GTProvider.GTProvider;
9
+ exports.Num = _generaltranslation_react_core.Num;
10
+ exports.Plural = _generaltranslation_react_core.Plural;
11
+ exports.Static = _generaltranslation_react_core.Static;
12
+ exports.T = _generaltranslation_react_core.T;
13
+ exports.Var = _generaltranslation_react_core.Var;
14
+ exports.declareStatic = _generaltranslation_react_core.declareStatic;
15
+ exports.declareVar = _generaltranslation_react_core.declareVar;
16
+ exports.decodeMsg = _generaltranslation_react_core.decodeMsg;
17
+ exports.decodeOptions = _generaltranslation_react_core.decodeOptions;
18
+ exports.decodeVars = _generaltranslation_react_core.decodeVars;
19
+ exports.gtFallback = _generaltranslation_react_core.gtFallback;
20
+ exports.mFallback = _generaltranslation_react_core.mFallback;
21
+ exports.msg = _generaltranslation_react_core.msg;
22
+ exports.useDefaultLocale = _generaltranslation_react_core.useDefaultLocale;
23
+ exports.useGT = _generaltranslation_react_core.useGT;
24
+ exports.useGTClass = _generaltranslation_react_core.useGTClass;
25
+ exports.useLocale = _generaltranslation_react_core.useLocale;
26
+ exports.useLocaleDirection = _generaltranslation_react_core.useLocaleDirection;
27
+ exports.useLocaleProperties = _generaltranslation_react_core.useLocaleProperties;
28
+ exports.useLocaleSelector = _generaltranslation_react_core.useLocaleSelector;
29
+ exports.useLocales = _generaltranslation_react_core.useLocales;
30
+ exports.useMessages = _generaltranslation_react_core.useMessages;
31
+ exports.useRegion = _generaltranslation_react_core.useRegion;
32
+ exports.useRegionSelector = _generaltranslation_react_core.useRegionSelector;
33
+ exports.useSetLocale = _generaltranslation_react_core.useSetLocale;
34
+ exports.useTranslations = _generaltranslation_react_core.useTranslations;
35
+ exports.useVersionId = _generaltranslation_react_core.useVersionId;
@@ -1,13 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "testLocalePolyfill", {
7
- enumerable: true,
8
- get: function () {
9
- return _testLocalePolyfill.testLocalePolyfill;
10
- }
11
- });
12
- var _testLocalePolyfill = require("./tools/testLocalePolyfill");
13
- //# sourceMappingURL=internal.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_tools_testLocalePolyfill = require("./tools/testLocalePolyfill.js");
3
+ exports.testLocalePolyfill = require_tools_testLocalePolyfill.testLocalePolyfill;
@@ -1,54 +1,38 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
5
4
  });
6
- exports.default = _default;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _types = require("./types");
9
- var _resolveLocales = require("./utils/resolveLocales");
10
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
- function _default(babel, {
12
- locales,
13
- config,
14
- configFilePath,
15
- entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx'),
16
- excludePolyfills = []
17
- }) {
18
- const {
19
- types: t
20
- } = babel;
21
- return {
22
- name: 'gt-react-native/plugin',
23
- visitor: {
24
- Program(programPath, state) {
25
- const currentFilePath = path.resolve(state.filename || state.file.opts.filename || '');
26
-
27
- // Only apply polyfills to files that import gt-react-native or generaltranslation
28
- if (currentFilePath !== entryPointFilePath) {
29
- return;
30
- }
31
- const resolvedLocales = (0, _resolveLocales.resolveLocales)({
32
- locales,
33
- config,
34
- configFilePath
35
- });
36
-
37
- // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
38
- const imports = [..._types.POLYFILLS.filter(polyfill => !excludePolyfills.includes(polyfill)), ...resolvedLocales.flatMap(locale => _types.LOCALE_POLYFILLS.map(localeData => `${localeData}/${locale}`))];
39
- const existingImports = new Set();
40
- programPath.node.body.forEach(node => {
41
- if (t.isImportDeclaration(node) && typeof node.source.value === 'string' && imports.includes(node.source.value)) {
42
- existingImports.add(node.source.value);
43
- }
44
- });
45
- const importsToAdd = imports.filter(imp => !existingImports.has(imp));
46
- if (importsToAdd.length > 0) {
47
- const newImports = importsToAdd.map(importPath => t.importDeclaration([], t.stringLiteral(importPath)));
48
- programPath.node.body.unshift(...newImports);
49
- }
50
- }
51
- }
52
- };
5
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
6
+ const require_plugin_dir_types = require("./types.js");
7
+ const require_plugin_dir_utils_resolveLocales = require("./utils/resolveLocales.js");
8
+ let path = require("path");
9
+ path = require_runtime.__toESM(path);
10
+ //#region src/plugin-dir/index.ts
11
+ function plugin_dir_default(babel, { locales, config, configFilePath, entryPointFilePath = path.resolve(process.cwd(), "src", "App.tsx"), excludePolyfills = [] }) {
12
+ const { types: t } = babel;
13
+ return {
14
+ name: "gt-react-native/plugin",
15
+ visitor: { Program(programPath, state) {
16
+ if (path.resolve(state.filename || state.file.opts.filename || "") !== entryPointFilePath) return;
17
+ const resolvedLocales = require_plugin_dir_utils_resolveLocales.resolveLocales({
18
+ locales,
19
+ config,
20
+ configFilePath
21
+ });
22
+ const imports = [...require_plugin_dir_types.POLYFILLS.filter((polyfill) => !excludePolyfills.includes(polyfill)), ...resolvedLocales.flatMap((locale) => require_plugin_dir_types.LOCALE_POLYFILLS.map((localeData) => `${localeData}/${locale}`))];
23
+ const existingImports = /* @__PURE__ */ new Set();
24
+ programPath.node.body.forEach((node) => {
25
+ if (t.isImportDeclaration(node) && typeof node.source.value === "string" && imports.includes(node.source.value)) existingImports.add(node.source.value);
26
+ });
27
+ const importsToAdd = imports.filter((imp) => !existingImports.has(imp));
28
+ if (importsToAdd.length > 0) {
29
+ const newImports = importsToAdd.map((importPath) => t.importDeclaration([], t.stringLiteral(importPath)));
30
+ programPath.node.body.unshift(...newImports);
31
+ }
32
+ } }
33
+ };
53
34
  }
35
+ //#endregion
36
+ exports.default = plugin_dir_default;
37
+
54
38
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["path","_interopRequireWildcard","require","_types","_resolveLocales","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","babel","locales","config","configFilePath","entryPointFilePath","resolve","process","cwd","excludePolyfills","types","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","resolveLocales","imports","POLYFILLS","filter","polyfill","includes","flatMap","locale","LOCALE_POLYFILLS","map","localeData","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","add","importsToAdd","imp","length","newImports","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAwD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEzC,SAAAkB,SACbC,KAA8B,EAC9B;EACEC,OAAO;EACPC,MAAM;EACNC,cAAc;EACdC,kBAAkB,GAAG7B,IAAI,CAAC8B,OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC;EAClEC,gBAAgB,GAAG;AACN,CAAC,EACL;EACX,MAAM;IAAEC,KAAK,EAAE5B;EAAE,CAAC,GAAGmB,KAAK;EAE1B,OAAO;IACLU,IAAI,EAAE,wBAAwB;IAC9BC,OAAO,EAAE;MACPC,OAAOA,CAACC,WAAW,EAAEC,KAAK,EAAE;QAC1B,MAAMC,eAAe,GAAGxC,IAAI,CAAC8B,OAAO,CAClCS,KAAK,CAACE,QAAQ,IAAIF,KAAK,CAACG,IAAI,CAACC,IAAI,CAACF,QAAQ,IAAI,EAChD,CAAC;;QAED;QACA,IAAID,eAAe,KAAKX,kBAAkB,EAAE;UAC1C;QACF;QAEA,MAAMe,eAAe,GAAG,IAAAC,8BAAc,EAAC;UACrCnB,OAAO;UACPC,MAAM;UACNC;QACF,CAAC,CAAC;;QAEF;QACA,MAAMkB,OAAO,GAAG,CACd,GAAGC,gBAAS,CAACC,MAAM,CAChBC,QAAQ,IAAK,CAAChB,gBAAgB,CAACiB,QAAQ,CAACD,QAAQ,CACnD,CAAC,EACD,GAAGL,eAAe,CAACO,OAAO,CAAEC,MAAM,IAChCC,uBAAgB,CAACC,GAAG,CAAEC,UAAU,IAAK,GAAGA,UAAU,IAAIH,MAAM,EAAE,CAChE,CAAC,CACF;QAED,MAAMI,eAAe,GAAG,IAAIC,GAAG,CAAS,CAAC;QACzCnB,WAAW,CAACoB,IAAI,CAACC,IAAI,CAACC,OAAO,CAAEF,IAAI,IAAK;UACtC,IACEpD,CAAC,CAACuD,mBAAmB,CAACH,IAAI,CAAC,IAC3B,OAAOA,IAAI,CAACI,MAAM,CAACC,KAAK,KAAK,QAAQ,IACrCjB,OAAO,CAACI,QAAQ,CAACQ,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC,EACnC;YACAP,eAAe,CAACQ,GAAG,CAACN,IAAI,CAACI,MAAM,CAACC,KAAK,CAAC;UACxC;QACF,CAAC,CAAC;QAEF,MAAME,YAAY,GAAGnB,OAAO,CAACE,MAAM,CAAEkB,GAAG,IAAK,CAACV,eAAe,CAACxC,GAAG,CAACkD,GAAG,CAAC,CAAC;QAEvE,IAAID,YAAY,CAACE,MAAM,GAAG,CAAC,EAAE;UAC3B,MAAMC,UAAU,GAAGH,YAAY,CAACX,GAAG,CAAEe,UAAU,IAC7C/D,CAAC,CAACgE,iBAAiB,CAAC,EAAE,EAAEhE,CAAC,CAACiE,aAAa,CAACF,UAAU,CAAC,CACrD,CAAC;UAED/B,WAAW,CAACoB,IAAI,CAACC,IAAI,CAACa,OAAO,CAAC,GAAGJ,UAAU,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["resolveLocales","POLYFILLS","LOCALE_POLYFILLS"],"sources":["../../../src/plugin-dir/index.ts"],"sourcesContent":["import * as path from 'path';\nimport type { PluginObj, types } from '@babel/core';\nimport { LOCALE_POLYFILLS, POLYFILLS, type PluginOptions } from './types';\nimport { resolveLocales } from './utils/resolveLocales';\n\nexport default function (\n babel: { types: typeof types },\n {\n locales,\n config,\n configFilePath,\n entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx'),\n excludePolyfills = [],\n }: PluginOptions\n): PluginObj {\n const { types: t } = babel;\n\n return {\n name: 'gt-react-native/plugin',\n visitor: {\n Program(programPath, state) {\n const currentFilePath = path.resolve(\n state.filename || state.file.opts.filename || ''\n );\n\n // Only apply polyfills to files that import gt-react-native or generaltranslation\n if (currentFilePath !== entryPointFilePath) {\n return;\n }\n\n const resolvedLocales = resolveLocales({\n locales,\n config,\n configFilePath,\n });\n\n // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()\n const imports = [\n ...POLYFILLS.filter(\n (polyfill) => !excludePolyfills.includes(polyfill)\n ),\n ...resolvedLocales.flatMap((locale) =>\n LOCALE_POLYFILLS.map((localeData) => `${localeData}/${locale}`)\n ),\n ];\n\n const existingImports = new Set<string>();\n programPath.node.body.forEach((node) => {\n if (\n t.isImportDeclaration(node) &&\n typeof node.source.value === 'string' &&\n imports.includes(node.source.value)\n ) {\n existingImports.add(node.source.value);\n }\n });\n\n const importsToAdd = imports.filter((imp) => !existingImports.has(imp));\n\n if (importsToAdd.length > 0) {\n const newImports = importsToAdd.map((importPath) =>\n t.importDeclaration([], t.stringLiteral(importPath))\n );\n\n programPath.node.body.unshift(...newImports);\n }\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAKA,SAAA,mBACE,OACA,EACE,SACA,QACA,gBACA,qBAAqB,KAAK,QAAQ,QAAQ,KAAK,EAAE,OAAO,UAAU,EAClE,mBAAmB,EAAE,IAEZ;CACX,MAAM,EAAE,OAAO,MAAM;AAErB,QAAO;EACL,MAAM;EACN,SAAS,EACP,QAAQ,aAAa,OAAO;AAM1B,OALwB,KAAK,QAC3B,MAAM,YAAY,MAAM,KAAK,KAAK,YAAY,GAI7B,KAAK,mBACtB;GAGF,MAAM,kBAAkBA,wCAAAA,eAAe;IACrC;IACA;IACA;IACD,CAAC;GAGF,MAAM,UAAU,CACd,GAAGC,yBAAAA,UAAU,QACV,aAAa,CAAC,iBAAiB,SAAS,SAAS,CACnD,EACD,GAAG,gBAAgB,SAAS,WAC1BC,yBAAAA,iBAAiB,KAAK,eAAe,GAAG,WAAW,GAAG,SAAS,CAChE,CACF;GAED,MAAM,kCAAkB,IAAI,KAAa;AACzC,eAAY,KAAK,KAAK,SAAS,SAAS;AACtC,QACE,EAAE,oBAAoB,KAAK,IAC3B,OAAO,KAAK,OAAO,UAAU,YAC7B,QAAQ,SAAS,KAAK,OAAO,MAAM,CAEnC,iBAAgB,IAAI,KAAK,OAAO,MAAM;KAExC;GAEF,MAAM,eAAe,QAAQ,QAAQ,QAAQ,CAAC,gBAAgB,IAAI,IAAI,CAAC;AAEvE,OAAI,aAAa,SAAS,GAAG;IAC3B,MAAM,aAAa,aAAa,KAAK,eACnC,EAAE,kBAAkB,EAAE,EAAE,EAAE,cAAc,WAAW,CAAC,CACrD;AAED,gBAAY,KAAK,KAAK,QAAQ,GAAG,WAAW;;KAGjD;EACF"}
@@ -1,11 +1,26 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/plugin-dir/types.ts
3
+ const POLYFILLS = [
4
+ "@formatjs/intl-getcanonicallocales/polyfill",
5
+ "@formatjs/intl-locale/polyfill",
6
+ "@formatjs/intl-displaynames/polyfill",
7
+ "@formatjs/intl-listformat/polyfill",
8
+ "@formatjs/intl-pluralrules/polyfill-force",
9
+ "@formatjs/intl-numberformat/polyfill",
10
+ "@formatjs/intl-relativetimeformat/polyfill",
11
+ "@formatjs/intl-datetimeformat/polyfill",
12
+ "@formatjs/intl-datetimeformat/add-all-tz"
13
+ ];
14
+ const LOCALE_POLYFILLS = [
15
+ `@formatjs/intl-displaynames/locale-data`,
16
+ `@formatjs/intl-listformat/locale-data`,
17
+ `@formatjs/intl-pluralrules/locale-data`,
18
+ `@formatjs/intl-numberformat/locale-data`,
19
+ `@formatjs/intl-relativetimeformat/locale-data`,
20
+ `@formatjs/intl-datetimeformat/locale-data`
21
+ ];
22
+ //#endregion
23
+ exports.LOCALE_POLYFILLS = LOCALE_POLYFILLS;
24
+ exports.POLYFILLS = POLYFILLS;
2
25
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.POLYFILLS = exports.LOCALE_POLYFILLS = void 0;
7
- const POLYFILLS = exports.POLYFILLS = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
8
- // https://github.com/formatjs/formatjs/issues/4463
9
- '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz'];
10
- const LOCALE_POLYFILLS = exports.LOCALE_POLYFILLS = [`@formatjs/intl-displaynames/locale-data`, `@formatjs/intl-listformat/locale-data`, `@formatjs/intl-pluralrules/locale-data`, `@formatjs/intl-numberformat/locale-data`, `@formatjs/intl-relativetimeformat/locale-data`, `@formatjs/intl-datetimeformat/locale-data`];
11
26
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["POLYFILLS","exports","LOCALE_POLYFILLS"],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,CACvB,6CAA6C,EAC7C,gCAAgC,EAChC,sCAAsC,EACtC,oCAAoC,EACpC,2CAA2C;AAAE;AAC7C,sCAAsC,EACtC,4CAA4C,EAC5C,wCAAwC,EACxC,0CAA0C,CAClC;AAEH,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAC9B,yCAAyC,EACzC,uCAAuC,EACvC,wCAAwC,EACxC,yCAAyC,EACzC,+CAA+C,EAC/C,2CAA2C,CACnC","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/plugin-dir/types.ts"],"sourcesContent":["export const POLYFILLS = [\n '@formatjs/intl-getcanonicallocales/polyfill',\n '@formatjs/intl-locale/polyfill',\n '@formatjs/intl-displaynames/polyfill',\n '@formatjs/intl-listformat/polyfill',\n '@formatjs/intl-pluralrules/polyfill-force', // https://github.com/formatjs/formatjs/issues/4463\n '@formatjs/intl-numberformat/polyfill',\n '@formatjs/intl-relativetimeformat/polyfill',\n '@formatjs/intl-datetimeformat/polyfill',\n '@formatjs/intl-datetimeformat/add-all-tz',\n] as const;\n\nexport const LOCALE_POLYFILLS = [\n `@formatjs/intl-displaynames/locale-data`,\n `@formatjs/intl-listformat/locale-data`,\n `@formatjs/intl-pluralrules/locale-data`,\n `@formatjs/intl-numberformat/locale-data`,\n `@formatjs/intl-relativetimeformat/locale-data`,\n `@formatjs/intl-datetimeformat/locale-data`,\n] as const;\n\nexport interface PluginOptions {\n /* List of locales to polyfill */\n locales?: string[];\n /* Gt config object */\n config?: { defaultLocale: string; locales: string[] } & Record<\n string,\n unknown\n >;\n /* Path to the gt config file */\n configFilePath?: string;\n /* Resolved from package.json */\n entryPointFilePath?: string;\n /* Polyfills to exclude */\n excludePolyfills?: (typeof POLYFILLS)[number][];\n}\n"],"mappings":";;AAAA,MAAa,YAAY;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACA;CACD"}