gt-react-native 0.0.2-alpha.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeGtReactNativeSpec.java +51 -0
  2. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +28 -0
  3. package/android/app/build/generated/source/codegen/jni/GtReactNativeSpec-generated.cpp +50 -0
  4. package/android/app/build/generated/source/codegen/jni/GtReactNativeSpec.h +31 -0
  5. package/android/app/build/generated/source/codegen/jni/react/renderer/components/GtReactNativeSpec/GtReactNativeSpecJSI-generated.cpp +51 -0
  6. package/android/app/build/generated/source/codegen/jni/react/renderer/components/GtReactNativeSpec/GtReactNativeSpecJSI.h +98 -0
  7. package/lib/typescript/src/NativeGtReactNative.d.ts.map +1 -0
  8. package/lib/typescript/src/errors-dir/constants.d.ts.map +1 -0
  9. package/lib/typescript/src/errors-dir/errors.d.ts.map +1 -0
  10. package/lib/typescript/src/errors-dir/warnings.d.ts.map +1 -0
  11. package/lib/typescript/src/index.d.ts.map +1 -0
  12. package/lib/typescript/src/internal.d.ts.map +1 -0
  13. package/lib/typescript/src/plugin-dir/index.d.ts.map +1 -0
  14. package/lib/typescript/src/plugin-dir/types.d.ts.map +1 -0
  15. package/lib/typescript/src/plugin-dir/utils/resolveLocales.d.ts.map +1 -0
  16. package/lib/typescript/src/plugin.d.ts.map +1 -0
  17. package/lib/typescript/src/provider/GTProvider.d.ts.map +1 -0
  18. package/lib/typescript/src/provider/hooks/locale/useDetermineLocale.d.ts.map +1 -0
  19. package/lib/typescript/src/provider/hooks/useRegionState.d.ts.map +1 -0
  20. package/lib/typescript/src/tools/testLocalePolyfill.d.ts.map +1 -0
  21. package/lib/typescript/src/types/config.d.ts.map +1 -0
  22. package/lib/typescript/src/utils/getNativeLocales.d.ts.map +1 -0
  23. package/lib/typescript/src/utils/nativeStore.d.ts.map +1 -0
  24. package/lib/typescript/src/utils/utils.d.ts.map +1 -0
  25. package/lib/typescript/vitest.config.d.ts.map +1 -0
  26. package/package.json +12 -36
  27. package/lib/commonjs/NativeGtReactNative.js +0 -9
  28. package/lib/commonjs/NativeGtReactNative.js.map +0 -1
  29. package/lib/commonjs/errors-dir/constants.js +0 -8
  30. package/lib/commonjs/errors-dir/constants.js.map +0 -1
  31. package/lib/commonjs/errors-dir/errors.js +0 -10
  32. package/lib/commonjs/errors-dir/errors.js.map +0 -1
  33. package/lib/commonjs/errors-dir/warnings.js +0 -18
  34. package/lib/commonjs/errors-dir/warnings.js.map +0 -1
  35. package/lib/commonjs/index.js +0 -158
  36. package/lib/commonjs/index.js.map +0 -1
  37. package/lib/commonjs/internal.js +0 -13
  38. package/lib/commonjs/internal.js.map +0 -1
  39. package/lib/commonjs/package.json +0 -1
  40. package/lib/commonjs/plugin-dir/index.js +0 -54
  41. package/lib/commonjs/plugin-dir/index.js.map +0 -1
  42. package/lib/commonjs/plugin-dir/types.js +0 -2
  43. package/lib/commonjs/plugin-dir/types.js.map +0 -1
  44. package/lib/commonjs/plugin-dir/utils/resolveLocales.js +0 -74
  45. package/lib/commonjs/plugin-dir/utils/resolveLocales.js.map +0 -1
  46. package/lib/commonjs/plugin.js +0 -14
  47. package/lib/commonjs/plugin.js.map +0 -1
  48. package/lib/commonjs/provider/GTProvider.js +0 -24
  49. package/lib/commonjs/provider/GTProvider.js.map +0 -1
  50. package/lib/commonjs/provider/hooks/locale/useDetermineLocale.js +0 -146
  51. package/lib/commonjs/provider/hooks/locale/useDetermineLocale.js.map +0 -1
  52. package/lib/commonjs/provider/hooks/useRegionState.js +0 -47
  53. package/lib/commonjs/provider/hooks/useRegionState.js.map +0 -1
  54. package/lib/commonjs/tools/testLocalePolyfill.js +0 -68
  55. package/lib/commonjs/tools/testLocalePolyfill.js.map +0 -1
  56. package/lib/commonjs/types/config.js +0 -6
  57. package/lib/commonjs/types/config.js.map +0 -1
  58. package/lib/commonjs/utils/getNativeLocales.js +0 -58
  59. package/lib/commonjs/utils/getNativeLocales.js.map +0 -1
  60. package/lib/commonjs/utils/nativeStore.js +0 -39
  61. package/lib/commonjs/utils/nativeStore.js.map +0 -1
  62. package/lib/commonjs/utils/utils.js +0 -17
  63. package/lib/commonjs/utils/utils.js.map +0 -1
  64. package/lib/typescript/commonjs/package.json +0 -1
  65. package/lib/typescript/commonjs/src/NativeGtReactNative.d.ts.map +0 -1
  66. package/lib/typescript/commonjs/src/errors-dir/constants.d.ts.map +0 -1
  67. package/lib/typescript/commonjs/src/errors-dir/errors.d.ts.map +0 -1
  68. package/lib/typescript/commonjs/src/errors-dir/warnings.d.ts.map +0 -1
  69. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  70. package/lib/typescript/commonjs/src/internal.d.ts.map +0 -1
  71. package/lib/typescript/commonjs/src/plugin-dir/index.d.ts.map +0 -1
  72. package/lib/typescript/commonjs/src/plugin-dir/types.d.ts.map +0 -1
  73. package/lib/typescript/commonjs/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
  74. package/lib/typescript/commonjs/src/plugin.d.ts.map +0 -1
  75. package/lib/typescript/commonjs/src/provider/GTProvider.d.ts.map +0 -1
  76. package/lib/typescript/commonjs/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
  77. package/lib/typescript/commonjs/src/provider/hooks/useRegionState.d.ts.map +0 -1
  78. package/lib/typescript/commonjs/src/tools/testLocalePolyfill.d.ts.map +0 -1
  79. package/lib/typescript/commonjs/src/types/config.d.ts.map +0 -1
  80. package/lib/typescript/commonjs/src/utils/getNativeLocales.d.ts.map +0 -1
  81. package/lib/typescript/commonjs/src/utils/nativeStore.d.ts.map +0 -1
  82. package/lib/typescript/commonjs/src/utils/utils.d.ts.map +0 -1
  83. package/lib/typescript/commonjs/vitest.config.d.ts.map +0 -1
  84. package/lib/typescript/module/src/NativeGtReactNative.d.ts +0 -10
  85. package/lib/typescript/module/src/NativeGtReactNative.d.ts.map +0 -1
  86. package/lib/typescript/module/src/errors-dir/constants.d.ts +0 -2
  87. package/lib/typescript/module/src/errors-dir/constants.d.ts.map +0 -1
  88. package/lib/typescript/module/src/errors-dir/errors.d.ts +0 -2
  89. package/lib/typescript/module/src/errors-dir/errors.d.ts.map +0 -1
  90. package/lib/typescript/module/src/errors-dir/warnings.d.ts +0 -4
  91. package/lib/typescript/module/src/errors-dir/warnings.d.ts.map +0 -1
  92. package/lib/typescript/module/src/index.d.ts +0 -6
  93. package/lib/typescript/module/src/index.d.ts.map +0 -1
  94. package/lib/typescript/module/src/internal.d.ts +0 -2
  95. package/lib/typescript/module/src/internal.d.ts.map +0 -1
  96. package/lib/typescript/module/src/plugin-dir/index.d.ts +0 -6
  97. package/lib/typescript/module/src/plugin-dir/index.d.ts.map +0 -1
  98. package/lib/typescript/module/src/plugin-dir/types.d.ts +0 -10
  99. package/lib/typescript/module/src/plugin-dir/types.d.ts.map +0 -1
  100. package/lib/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts +0 -13
  101. package/lib/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
  102. package/lib/typescript/module/src/plugin.d.ts +0 -2
  103. package/lib/typescript/module/src/plugin.d.ts.map +0 -1
  104. package/lib/typescript/module/src/provider/GTProvider.d.ts +0 -4
  105. package/lib/typescript/module/src/provider/GTProvider.d.ts.map +0 -1
  106. package/lib/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts +0 -4
  107. package/lib/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
  108. package/lib/typescript/module/src/provider/hooks/useRegionState.d.ts +0 -3
  109. package/lib/typescript/module/src/provider/hooks/useRegionState.d.ts.map +0 -1
  110. package/lib/typescript/module/src/tools/testLocalePolyfill.d.ts +0 -12
  111. package/lib/typescript/module/src/tools/testLocalePolyfill.d.ts.map +0 -1
  112. package/lib/typescript/module/src/types/config.d.ts +0 -30
  113. package/lib/typescript/module/src/types/config.d.ts.map +0 -1
  114. package/lib/typescript/module/src/utils/getNativeLocales.d.ts +0 -10
  115. package/lib/typescript/module/src/utils/getNativeLocales.d.ts.map +0 -1
  116. package/lib/typescript/module/src/utils/nativeStore.d.ts +0 -16
  117. package/lib/typescript/module/src/utils/nativeStore.d.ts.map +0 -1
  118. package/lib/typescript/module/src/utils/utils.d.ts +0 -3
  119. package/lib/typescript/module/src/utils/utils.d.ts.map +0 -1
  120. package/lib/typescript/module/vitest.config.d.ts +0 -3
  121. package/lib/typescript/module/vitest.config.d.ts.map +0 -1
  122. /package/lib/typescript/{module/package.json → package.json} +0 -0
  123. /package/lib/typescript/{commonjs/src → src}/NativeGtReactNative.d.ts +0 -0
  124. /package/lib/typescript/{commonjs/src → src}/errors-dir/constants.d.ts +0 -0
  125. /package/lib/typescript/{commonjs/src → src}/errors-dir/errors.d.ts +0 -0
  126. /package/lib/typescript/{commonjs/src → src}/errors-dir/warnings.d.ts +0 -0
  127. /package/lib/typescript/{commonjs/src → src}/index.d.ts +0 -0
  128. /package/lib/typescript/{commonjs/src → src}/internal.d.ts +0 -0
  129. /package/lib/typescript/{commonjs/src → src}/plugin-dir/index.d.ts +0 -0
  130. /package/lib/typescript/{commonjs/src → src}/plugin-dir/types.d.ts +0 -0
  131. /package/lib/typescript/{commonjs/src → src}/plugin-dir/utils/resolveLocales.d.ts +0 -0
  132. /package/lib/typescript/{commonjs/src → src}/plugin.d.ts +0 -0
  133. /package/lib/typescript/{commonjs/src → src}/provider/GTProvider.d.ts +0 -0
  134. /package/lib/typescript/{commonjs/src → src}/provider/hooks/locale/useDetermineLocale.d.ts +0 -0
  135. /package/lib/typescript/{commonjs/src → src}/provider/hooks/useRegionState.d.ts +0 -0
  136. /package/lib/typescript/{commonjs/src → src}/tools/testLocalePolyfill.d.ts +0 -0
  137. /package/lib/typescript/{commonjs/src → src}/types/config.d.ts +0 -0
  138. /package/lib/typescript/{commonjs/src → src}/utils/getNativeLocales.d.ts +0 -0
  139. /package/lib/typescript/{commonjs/src → src}/utils/nativeStore.d.ts +0 -0
  140. /package/lib/typescript/{commonjs/src → src}/utils/utils.d.ts +0 -0
  141. /package/lib/typescript/{commonjs/vitest.config.d.ts → vitest.config.d.ts} +0 -0
@@ -1,158 +0,0 @@
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, "T", {
43
- enumerable: true,
44
- get: function () {
45
- return _reactCore.T;
46
- }
47
- });
48
- Object.defineProperty(exports, "Var", {
49
- enumerable: true,
50
- get: function () {
51
- return _reactCore.Var;
52
- }
53
- });
54
- Object.defineProperty(exports, "decodeMsg", {
55
- enumerable: true,
56
- get: function () {
57
- return _reactCore.decodeMsg;
58
- }
59
- });
60
- Object.defineProperty(exports, "decodeOptions", {
61
- enumerable: true,
62
- get: function () {
63
- return _reactCore.decodeOptions;
64
- }
65
- });
66
- Object.defineProperty(exports, "msg", {
67
- enumerable: true,
68
- get: function () {
69
- return _reactCore.msg;
70
- }
71
- });
72
- exports.multiply = multiply;
73
- Object.defineProperty(exports, "useDefaultLocale", {
74
- enumerable: true,
75
- get: function () {
76
- return _reactCore.useDefaultLocale;
77
- }
78
- });
79
- Object.defineProperty(exports, "useGT", {
80
- enumerable: true,
81
- get: function () {
82
- return _reactCore.useGT;
83
- }
84
- });
85
- Object.defineProperty(exports, "useGTClass", {
86
- enumerable: true,
87
- get: function () {
88
- return _reactCore.useGTClass;
89
- }
90
- });
91
- Object.defineProperty(exports, "useLocale", {
92
- enumerable: true,
93
- get: function () {
94
- return _reactCore.useLocale;
95
- }
96
- });
97
- Object.defineProperty(exports, "useLocaleDirection", {
98
- enumerable: true,
99
- get: function () {
100
- return _reactCore.useLocaleDirection;
101
- }
102
- });
103
- Object.defineProperty(exports, "useLocaleProperties", {
104
- enumerable: true,
105
- get: function () {
106
- return _reactCore.useLocaleProperties;
107
- }
108
- });
109
- Object.defineProperty(exports, "useLocaleSelector", {
110
- enumerable: true,
111
- get: function () {
112
- return _reactCore.useLocaleSelector;
113
- }
114
- });
115
- Object.defineProperty(exports, "useLocales", {
116
- enumerable: true,
117
- get: function () {
118
- return _reactCore.useLocales;
119
- }
120
- });
121
- Object.defineProperty(exports, "useMessages", {
122
- enumerable: true,
123
- get: function () {
124
- return _reactCore.useMessages;
125
- }
126
- });
127
- Object.defineProperty(exports, "useRegion", {
128
- enumerable: true,
129
- get: function () {
130
- return _reactCore.useRegion;
131
- }
132
- });
133
- Object.defineProperty(exports, "useRegionSelector", {
134
- enumerable: true,
135
- get: function () {
136
- return _reactCore.useRegionSelector;
137
- }
138
- });
139
- Object.defineProperty(exports, "useSetLocale", {
140
- enumerable: true,
141
- get: function () {
142
- return _reactCore.useSetLocale;
143
- }
144
- });
145
- Object.defineProperty(exports, "useTranslations", {
146
- enumerable: true,
147
- get: function () {
148
- return _reactCore.useTranslations;
149
- }
150
- });
151
- var _NativeGtReactNative = _interopRequireDefault(require("./NativeGtReactNative"));
152
- var _GTProvider = require("./provider/GTProvider");
153
- var _reactCore = require("@generaltranslation/react-core");
154
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
155
- function multiply(a, b) {
156
- return _NativeGtReactNative.default.multiply(a, b);
157
- }
158
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_NativeGtReactNative","_interopRequireDefault","require","_GTProvider","_reactCore","e","__esModule","default","multiply","a","b","GtReactNative"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAF,OAAA;AAwBwC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA5BjC,SAASG,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOC,4BAAa,CAACH,QAAQ,CAACC,CAAC,EAAEC,CAAC,CAAC;AACrC","ignoreList":[]}
@@ -1,13 +0,0 @@
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 +0,0 @@
1
- {"version":3,"names":["_testLocalePolyfill","require"],"sourceRoot":"../../src","sources":["internal.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = _default;
7
- var path = _interopRequireWildcard(require("path"));
8
- var _resolveLocales = require("./utils/resolveLocales");
9
- 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); }
10
- function _default(babel, {
11
- locales,
12
- config,
13
- configFilePath,
14
- entryPointFilePath = path.resolve(process.cwd(), 'src', 'App.tsx')
15
- }) {
16
- const {
17
- types: t
18
- } = babel;
19
- return {
20
- name: 'gt-react-native/plugin',
21
- visitor: {
22
- Program(programPath, state) {
23
- const currentFilePath = path.resolve(state.filename || state.file.opts.filename || '');
24
-
25
- // Only apply polyfills to files that import gt-react-native or generaltranslation
26
- if (currentFilePath !== entryPointFilePath) {
27
- return;
28
- }
29
- const resolvedLocales = (0, _resolveLocales.resolveLocales)({
30
- locales,
31
- config,
32
- configFilePath
33
- });
34
-
35
- // TODO: smart imports based on if the polyfill is required, do this as a wrapper around AppRegistry.registerComponent()
36
- const imports = ['@formatjs/intl-getcanonicallocales/polyfill', '@formatjs/intl-locale/polyfill', '@formatjs/intl-displaynames/polyfill', '@formatjs/intl-listformat/polyfill', '@formatjs/intl-pluralrules/polyfill-force',
37
- // https://github.com/formatjs/formatjs/issues/4463
38
- '@formatjs/intl-numberformat/polyfill', '@formatjs/intl-relativetimeformat/polyfill', '@formatjs/intl-datetimeformat/polyfill', '@formatjs/intl-datetimeformat/add-all-tz', ...resolvedLocales.flatMap(locale => [`@formatjs/intl-displaynames/locale-data/${locale}`, `@formatjs/intl-listformat/locale-data/${locale}`, `@formatjs/intl-pluralrules/locale-data/${locale}`, `@formatjs/intl-numberformat/locale-data/${locale}`, `@formatjs/intl-relativetimeformat/locale-data/${locale}`, `@formatjs/intl-datetimeformat/locale-data/${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
- };
53
- }
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["path","_interopRequireWildcard","require","_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","types","name","visitor","Program","programPath","state","currentFilePath","filename","file","opts","resolvedLocales","resolveLocales","imports","flatMap","locale","existingImports","Set","node","body","forEach","isImportDeclaration","source","value","includes","add","importsToAdd","filter","imp","length","newImports","map","importPath","importDeclaration","stringLiteral","unshift"],"sourceRoot":"../../../src","sources":["plugin-dir/index.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AAAwD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,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,S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C9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["plugin-dir/types.ts"],"mappings":"","ignoreList":[]}
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveLocales = resolveLocales;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _warnings = require("../../errors-dir/warnings");
9
- var _internal = require("generaltranslation/internal");
10
- var _errors = require("../../errors-dir/errors");
11
- var _supportedLocales = require("@generaltranslation/supported-locales");
12
- var _path = _interopRequireDefault(require("path"));
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- const DEFAULT_CONFIG_FILE_PATHS = [_path.default.join(process.cwd(), 'gt.config.json'), _path.default.join(process.cwd(), '.locadex', 'gt.config.json')];
15
-
16
- /**
17
- * Given a list of locales or a config object or a path to a config file, return a list of locales to polyfill.
18
- * Preference order: locales > config > configFilePaths > library default locale
19
- */
20
- function resolveLocales({
21
- locales,
22
- config,
23
- configFilePath
24
- }) {
25
- let result = [];
26
-
27
- // Resolve locales from the given options
28
- if (locales) {
29
- result = Array.from(new Set(locales));
30
- } else if (config) {
31
- result = Array.from(new Set([config.defaultLocale, ...config.locales]));
32
- } else {
33
- result = resolveLocalesFromConfig(configFilePath);
34
- }
35
-
36
- // Validate the result
37
- const invalidLocales = result.filter(locale => !(0, _supportedLocales.getSupportedLocale)(locale));
38
- if (invalidLocales.length) {
39
- console.warn((0, _warnings.invalidLocalesWarning)(invalidLocales));
40
- result = result.filter(locale => !invalidLocales.includes(locale));
41
- }
42
-
43
- // Fallback to default locale if no locales were found
44
- if (result.length === 0) {
45
- console.warn(_warnings.resolveLocalesFailedWarning);
46
- result = [_internal.libraryDefaultLocale];
47
- }
48
- return result;
49
- }
50
-
51
- /**
52
- * Resolve locales from a config file
53
- * @param configFilePath - The path to the config file
54
- * @returns A list of locales
55
- */
56
- function resolveLocalesFromConfig(configFilePath) {
57
- const configFilePaths = [...(configFilePath ? [configFilePath] : []), ...DEFAULT_CONFIG_FILE_PATHS];
58
- let result = [];
59
- for (const filePath of configFilePaths) {
60
- try {
61
- if (!_fs.default.existsSync(filePath)) {
62
- console.warn((0, _warnings.couldNotLocateConfigWarning)(filePath));
63
- continue;
64
- }
65
- const resolvedConfig = JSON.parse(_fs.default.readFileSync(filePath, 'utf8'));
66
- result = Array.from(new Set([...(resolvedConfig.defaultLocale ? [resolvedConfig.defaultLocale] : []), ...(resolvedConfig.locales || [])]));
67
- } catch (error) {
68
- console.error((0, _errors.failedToReadConfigFileError)(filePath), error);
69
- break;
70
- }
71
- }
72
- return result;
73
- }
74
- //# sourceMappingURL=resolveLocales.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_fs","_interopRequireDefault","require","_warnings","_internal","_errors","_supportedLocales","_path","e","__esModule","default","DEFAULT_CONFIG_FILE_PATHS","path","join","process","cwd","resolveLocales","locales","config","configFilePath","result","Array","from","Set","defaultLocale","resolveLocalesFromConfig","invalidLocales","filter","locale","getSupportedLocale","length","console","warn","invalidLocalesWarning","includes","resolveLocalesFailedWarning","libraryDefaultLocale","configFilePaths","filePath","fs","existsSync","couldNotLocateConfigWarning","resolvedConfig","JSON","parse","readFileSync","error","failedToReadConfigFileError"],"sourceRoot":"../../../../src","sources":["plugin-dir/utils/resolveLocales.ts"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA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OhB,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASK,wBAAwBA,CAACN,cAAkC,EAAE;EACpE,MAAMkB,eAAe,GAAG,CACtB,IAAIlB,cAAc,GAAG,CAACA,cAAc,CAAC,GAAG,EAAE,CAAC,EAC3C,GAAGR,yBAAyB,CAC7B;EACD,IAAIS,MAAgB,GAAG,EAAE;EAEzB,KAAK,MAAMkB,QAAQ,IAAID,eAAe,EAAE;IACtC,IAAI;MACF,IAAI,CAACE,WAAE,CAACC,UAAU,CAACF,QAAQ,CAAC,EAAE;QAC5BP,OAAO,CAACC,IAAI,CAAC,IAAAS,qCAA2B,EAACH,QAAQ,CAAC,CAAC;QACnD;MACF;MAEA,MAAMI,cAAc,GAAGC,IAAI,CAACC,KAAK,CAACL,WAAE,CAACM,YAAY,CAACP,QAAQ,EAAE,MAAM,CAAC,CAGlE;MAEDlB,MAAM,GAAGC,KAAK,CAACC,IAAI,CACjB,IAAIC,GAAG,CAAC,CACN,IAAImB,cAAc,CAAClB,aAAa,GAC5B,CAACkB,cAAc,CAAClB,aAAa,CAAC,GAC9B,EAAE,CAAC,EACP,IAAIkB,cAAc,CAACzB,OAAO,IAAI,EAAE,CAAC,CAClC,CACH,CAAC;IACH,CAAC,CAAC,OAAO6B,KAAK,EAAE;MACdf,OAAO,CAACe,KAAK,CAAC,IAAAC,mCAA2B,EAACT,QAAQ,CAAC,EAAEQ,KAAK,CAAC;MAC3D;IACF;EACF;EACA,OAAO1B,MAAM;AACf","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _pluginDir.default;
10
- }
11
- });
12
- var _pluginDir = _interopRequireDefault(require("./plugin-dir"));
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- //# sourceMappingURL=plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_pluginDir","_interopRequireDefault","require","e","__esModule","default"],"sourceRoot":"../../src","sources":["plugin.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GTProvider = GTProvider;
7
- exports.default = void 0;
8
- var _useDetermineLocale = require("./hooks/locale/useDetermineLocale");
9
- var _reactCore = require("@generaltranslation/react-core");
10
- var _utils = require("../utils/utils");
11
- var _useRegionState = require("./hooks/useRegionState");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function GTProvider(props) {
14
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactCore.GTProvider, {
15
- ssr: false,
16
- environment: __DEV__ ? 'development' : 'production',
17
- ...props,
18
- readAuthFromEnv: _utils.readAuthFromEnv,
19
- useDetermineLocale: _useDetermineLocale.useDetermineLocale,
20
- useRegionState: _useRegionState.useRegionState
21
- });
22
- }
23
- var _default = exports.default = GTProvider;
24
- //# sourceMappingURL=GTProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_useDetermineLocale","require","_reactCore","_utils","_useRegionState","_jsxRuntime","GTProvider","props","jsx","ssr","environment","__DEV__","readAuthFromEnv","useDetermineLocale","useRegionState","_default","exports","default"],"sourceRoot":"../../../src","sources":["provider/GTProvider.tsx"],"mappings":";;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAAwD,IAAAI,WAAA,GAAAJ,OAAA;AAEjD,SAASK,UAAUA,CAACC,KAAsB,EAAqB;EACpE,oBACE,IAAAF,WAAA,CAAAG,GAAA,EAACN,UAAA,CAAAI,UAAW;IACVG,GAAG,EAAE,KAAM;IACXC,WAAW,EAAEC,OAAO,GAAG,aAAa,GAAG,YAAa;IAAA,GAChDJ,KAAK;IACTK,eAAe,EAAEA,sBAAgB;IACjCC,kBAAkB,EAAEA,sCAAmB;IACvCC,cAAc,EAAEA;EAAe,CAChC,CAAC;AAEN;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcX,UAAU","ignoreList":[]}
@@ -1,146 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDetermineLocale = useDetermineLocale;
7
- var _react = require("react");
8
- var _generaltranslation = require("generaltranslation");
9
- var _internal = require("generaltranslation/internal");
10
- var _getNativeLocales = require("../../../utils/getNativeLocales");
11
- var _nativeStore = require("../../../utils/nativeStore");
12
- function useDetermineLocale({
13
- locale: _locale = '',
14
- defaultLocale = _internal.libraryDefaultLocale,
15
- locales = [],
16
- localeCookieName = 'generaltranslation.locale',
17
- ssr = false,
18
- // not relevant
19
- customMapping
20
- }) {
21
- // resolve alias locale
22
- _locale = (0, _generaltranslation.resolveAliasLocale)(_locale, customMapping);
23
- locales = locales.map(locale => (0, _generaltranslation.resolveAliasLocale)(locale, customMapping));
24
- const initializeLocale = () => {
25
- const result = (0, _generaltranslation.resolveAliasLocale)(ssr ? _locale ? (0, _generaltranslation.determineLocale)(_locale, locales, customMapping) || '' : '' : getNewLocale({
26
- _locale,
27
- locale: _locale,
28
- locales,
29
- defaultLocale,
30
- localeCookieName,
31
- customMapping
32
- }), customMapping);
33
- return result;
34
- };
35
-
36
- // maintaining the state of locale
37
- const [locale, _setLocale] = (0, _react.useState)(initializeLocale());
38
-
39
- // Functions for setting internal locale state
40
- const [setLocale, setLocaleWithoutPersist] = createSetLocale({
41
- locale,
42
- locales,
43
- defaultLocale,
44
- localeCookieName,
45
- _setLocale,
46
- customMapping
47
- });
48
-
49
- // check browser for locales
50
- (0, _react.useEffect)(() => {
51
- const newLocale = getNewLocale({
52
- _locale,
53
- locale,
54
- locales,
55
- defaultLocale,
56
- localeCookieName,
57
- customMapping
58
- });
59
- setLocaleWithoutPersist(newLocale);
60
- }, [_locale, locale, locales, defaultLocale, localeCookieName, customMapping, setLocaleWithoutPersist]);
61
- return [locale, setLocale];
62
- }
63
-
64
- // ----- HELPER FUNCTIONS ---- //
65
-
66
- /**
67
- * Choose a locale to use
68
- * (1) use provided locale
69
- * (2) use cookie locale
70
- * (3) use preferred locale
71
- * (5) fallback to defaultLocale
72
- * Update the cookie locale to be correct
73
- */
74
- function getNewLocale({
75
- _locale,
76
- locale,
77
- locales,
78
- defaultLocale,
79
- localeCookieName,
80
- customMapping
81
- }) {
82
- // No change, return
83
- if (_locale && _locale === locale && (0, _generaltranslation.determineLocale)(_locale, locales, customMapping) === locale) {
84
- return (0, _generaltranslation.resolveAliasLocale)(_locale, customMapping);
85
- }
86
-
87
- // Check for locale in native store
88
- let storedLocale = (0, _nativeStore.nativeStoreGet)(localeCookieName);
89
- if (storedLocale) {
90
- storedLocale = (0, _generaltranslation.resolveAliasLocale)(storedLocale, customMapping);
91
- }
92
-
93
- // check user's configured locales
94
- let preferredLocales = (0, _getNativeLocales.getNativeLocales)();
95
- if (preferredLocales.length === 0) preferredLocales = [defaultLocale];
96
- preferredLocales = preferredLocales.map(l => (0, _generaltranslation.resolveAliasLocale)(l, customMapping));
97
-
98
- // determine locale
99
- let newLocale = (0, _generaltranslation.determineLocale)([...(_locale ? [_locale] : []),
100
- // prefer user passed locale
101
- ...(storedLocale ? [storedLocale] : []),
102
- // then prefer stored locale
103
- ...preferredLocales // then prefer browser locale
104
- ], locales, customMapping) || defaultLocale;
105
- if (newLocale) {
106
- newLocale = (0, _generaltranslation.resolveAliasLocale)(newLocale, customMapping);
107
- }
108
-
109
- // if stored locale not valid, change it back to whatever we use for fallback
110
- if (storedLocale && storedLocale !== newLocale) {
111
- (0, _nativeStore.nativeStoreSet)(localeCookieName, newLocale);
112
- }
113
-
114
- // return new locale
115
- return newLocale;
116
- }
117
- function createSetLocale({
118
- locale,
119
- locales,
120
- defaultLocale,
121
- _setLocale,
122
- localeCookieName,
123
- customMapping
124
- }) {
125
- locale = (0, _generaltranslation.resolveAliasLocale)(locale, customMapping);
126
- // Just update the internal state, don't persist it
127
- const setLocaleWithoutPersist = newLocale => {
128
- // validate locale
129
- const validatedLocale = (0, _generaltranslation.resolveAliasLocale)((0, _generaltranslation.determineLocale)(newLocale, locales, customMapping) || locale || defaultLocale, customMapping);
130
- if (validatedLocale !== newLocale) {
131
- console.warn(`[gt-react-native] Unsupported locale: ${validatedLocale} -> ${newLocale}`);
132
- }
133
- // persist locale
134
- _setLocale(validatedLocale);
135
- return validatedLocale;
136
- };
137
- // update locale and persist it in native store
138
- const setLocale = newLocale => {
139
- newLocale = (0, _generaltranslation.resolveAliasLocale)(newLocale, customMapping);
140
- setLocaleWithoutPersist(newLocale);
141
- const validatedLocale = setLocaleWithoutPersist(newLocale);
142
- (0, _nativeStore.nativeStoreSet)(localeCookieName, validatedLocale);
143
- };
144
- return [setLocale, setLocaleWithoutPersist];
145
- }
146
- //# sourceMappingURL=useDetermineLocale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_generaltranslation","_internal","_getNativeLocales","_nativeStore","useDetermineLocale","locale","_locale","defaultLocale","libraryDefaultLocale","locales","localeCookieName","ssr","customMapping","resolveAliasLocale","map","initializeLocale","result","determineLocale","getNewLocale","_setLocale","useState","setLocale","setLocaleWithoutPersist","createSetLocale","useEffect","newLocale","storedLocale","nativeStoreGet","preferredLocales","getNativeLocales","length","l","nativeStoreSet","validatedLocale","console","warn"],"sourceRoot":"../../../../../src","sources":["provider/hooks/locale/useDetermineLocale.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAA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2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useRegionState = useRegionState;
7
- var _react = require("react");
8
- var _nativeStore = require("../../utils/nativeStore");
9
- function getNewRegion({
10
- _region,
11
- regionCookieName
12
- }) {
13
- // Check for region in native store
14
- const cookieRegion = (0, _nativeStore.nativeStoreGet)(regionCookieName) || undefined;
15
- const newRegion = _region || cookieRegion;
16
-
17
- // if state not valid, change it to newRegion
18
- if (cookieRegion && cookieRegion !== newRegion) {
19
- (0, _nativeStore.nativeStoreSet)(regionCookieName, newRegion || '');
20
- }
21
- return newRegion;
22
- }
23
- function useRegionState({
24
- _region,
25
- ssr,
26
- regionCookieName
27
- }) {
28
- const [region, _setRegion] = (0, _react.useState)(ssr ? undefined : getNewRegion({
29
- _region,
30
- regionCookieName
31
- }));
32
- const setRegion = newRegion => {
33
- _setRegion(newRegion);
34
- (0, _nativeStore.nativeStoreSet)(regionCookieName, newRegion || '');
35
- };
36
- (0, _react.useEffect)(() => {
37
- _setRegion(getNewRegion({
38
- _region,
39
- regionCookieName
40
- }));
41
- }, [_region, regionCookieName]);
42
- return {
43
- region,
44
- setRegion
45
- };
46
- }
47
- //# sourceMappingURL=useRegionState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_nativeStore","getNewRegion","_region","regionCookieName","cookieRegion","nativeStoreGet","undefined","newRegion","nativeStoreSet","useRegionState","ssr","region","_setRegion","useState","setRegion","useEffect"],"sourceRoot":"../../../../src","sources":["provider/hooks/useRegionState.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAEA,SAASE,YAAYA,CAAC;EACpBC,OAAO;EACPC;AAIF,CAAC,EAAE;EACD;EACA,MAAMC,YAAY,GAAG,IAAAC,2BAAc,EAACF,gBAAgB,CAAC,IAAIG,SAAS;EAClE,MAAMC,SAAS,GAAGL,OAAO,IAAIE,YAAY;;EAEzC;EACA,IAAIA,YAAY,IAAIA,YAAY,KAAKG,SAAS,EAAE;IAC9C,IAAAC,2BAAc,EAACL,gBAAgB,EAAEI,SAAS,IAAI,EAAE,CAAC;EACnD;EAEA,OAAOA,SAAS;AAClB;AAEO,SAASE,cAAcA,CAAC;EAC7BP,OAAO;EACPQ,GAAG;EACHP;AACoB,CAAC,EAAwB;EAC7C,MAAM,CAACQ,MAAM,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EACnCH,GAAG,GACCJ,SAAS,GACTL,YAAY,CAAC;IACXC,OAAO;IACPC;EACF,CAAC,CACP,CAAC;EACD,MAAMW,SAAS,GAAIP,SAA6B,IAAK;IACnDK,UAAU,CAACL,SAAS,CAAC;IACrB,IAAAC,2BAAc,EAACL,gBAAgB,EAAEI,SAAS,IAAI,EAAE,CAAC;EACnD,CAAC;EACD,IAAAQ,gBAAS,EAAC,MAAM;IACdH,UAAU,CAACX,YAAY,CAAC;MAAEC,OAAO;MAAEC;IAAiB,CAAC,CAAC,CAAC;EACzD,CAAC,EAAE,CAACD,OAAO,EAAEC,gBAAgB,CAAC,CAAC;EAC/B,OAAO;IACLQ,MAAM;IACNG;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testLocalePolyfill = testLocalePolyfill;
7
- function testLocalePolyfill(locale = 'en-US') {
8
- const problems = [];
9
-
10
- // 1. basic presence
11
- if (!global.Intl) problems.push('Intl missing entirely');
12
- const apis = ['Locale', 'NumberFormat', 'DateTimeFormat', 'PluralRules', 'RelativeTimeFormat', 'ListFormat', 'DisplayNames'];
13
- apis.forEach(a => {
14
- // @ts-ignore
15
- if (!Intl[a]) problems.push(`Intl.${a} missing`);
16
- });
17
-
18
- // 2. locale actually supported (no silent fallback)
19
- const dtfSupported = Intl.DateTimeFormat.supportedLocalesOf([locale])[0] === locale;
20
- const nfSupported = Intl.NumberFormat.supportedLocalesOf([locale])[0] === locale;
21
- if (!dtfSupported) problems.push(`${locale} not supported by DateTimeFormat`);
22
- if (!nfSupported) problems.push(`${locale} not supported by NumberFormat`);
23
-
24
- // 3. numeric separators sanity
25
- let group, decimal;
26
- try {
27
- const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);
28
- group = parts.find(p => p.type === 'group')?.value;
29
- decimal = parts.find(p => p.type === 'decimal')?.value;
30
- if (!group || !decimal) problems.push('formatToParts missing group/decimal separators');
31
- } catch (e) {
32
- problems.push(`NumberFormat threw: ${e instanceof Error ? e.message : String(e)}`);
33
- }
34
-
35
- // 4. plural rules sanity
36
- try {
37
- const pr = new Intl.PluralRules(locale);
38
- const sample = pr.select(5);
39
- if (!sample) problems.push('PluralRules returned undefined');
40
- } catch (e) {
41
- problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
42
- }
43
-
44
- // 5. show example formatted values
45
- const example = {
46
- number: new Intl.NumberFormat(locale).format(1234.5),
47
- date: new Intl.DateTimeFormat(locale, {
48
- dateStyle: 'long'
49
- }).format(new Date('2020-01-02')),
50
- weekday: new Intl.DateTimeFormat(locale, {
51
- weekday: 'long'
52
- }).format(new Date('2020-01-02'))
53
- };
54
- const result = {
55
- ok: problems.length === 0,
56
- problems,
57
- group,
58
- decimal,
59
- example
60
- };
61
- if (result.ok) {
62
- console.log(`✅ Locale polyfill looks OK for ${locale}`, example);
63
- } else {
64
- console.warn(`❌ Locale polyfill check failed for ${locale}:`, problems, example);
65
- }
66
- return result;
67
- }
68
- //# sourceMappingURL=testLocalePolyfill.js.map