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,47 +1,35 @@
1
- "use strict";
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;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../_virtual/_rolldown/runtime.js");
3
+ const require_utils_nativeStore = require("../../utils/nativeStore.js");
4
+ let react = require("react");
5
+ //#region src/provider/hooks/useRegionState.ts
6
+ function getNewRegion({ _region, regionCookieName }) {
7
+ const cookieRegion = require_utils_nativeStore.nativeStoreGet(regionCookieName) || void 0;
8
+ const newRegion = _region || cookieRegion;
9
+ if (cookieRegion && cookieRegion !== newRegion) require_utils_nativeStore.nativeStoreSet(regionCookieName, newRegion || "");
10
+ return newRegion;
22
11
  }
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
- };
12
+ function useRegionState({ _region, ssr, regionCookieName }) {
13
+ const [region, _setRegion] = (0, react.useState)(ssr ? void 0 : getNewRegion({
14
+ _region,
15
+ regionCookieName
16
+ }));
17
+ const setRegion = (newRegion) => {
18
+ _setRegion(newRegion);
19
+ require_utils_nativeStore.nativeStoreSet(regionCookieName, newRegion || "");
20
+ };
21
+ (0, react.useEffect)(() => {
22
+ _setRegion(getNewRegion({
23
+ _region,
24
+ regionCookieName
25
+ }));
26
+ }, [_region, regionCookieName]);
27
+ return {
28
+ region,
29
+ setRegion
30
+ };
46
31
  }
32
+ //#endregion
33
+ exports.useRegionState = useRegionState;
34
+
47
35
  //# sourceMappingURL=useRegionState.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"useRegionState.js","names":["nativeStoreGet"],"sources":["../../../../src/provider/hooks/useRegionState.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type {\n UseRegionStateParams,\n UseRegionStateReturn,\n} from '@generaltranslation/react-core/types';\nimport { nativeStoreGet, nativeStoreSet } from '../../utils/nativeStore';\n\nfunction getNewRegion({\n _region,\n regionCookieName,\n}: {\n _region: string | undefined;\n regionCookieName: string;\n}) {\n // Check for region in native store\n const cookieRegion = nativeStoreGet(regionCookieName) || undefined;\n const newRegion = _region || cookieRegion;\n\n // if state not valid, change it to newRegion\n if (cookieRegion && cookieRegion !== newRegion) {\n nativeStoreSet(regionCookieName, newRegion || '');\n }\n\n return newRegion;\n}\n\nexport function useRegionState({\n _region,\n ssr,\n regionCookieName,\n}: UseRegionStateParams): UseRegionStateReturn {\n const [region, _setRegion] = useState<string | undefined>(\n ssr\n ? undefined\n : getNewRegion({\n _region,\n regionCookieName,\n })\n );\n const setRegion = (newRegion: string | undefined) => {\n _setRegion(newRegion);\n nativeStoreSet(regionCookieName, newRegion || '');\n };\n useEffect(() => {\n _setRegion(getNewRegion({ _region, regionCookieName }));\n }, [_region, regionCookieName]);\n return {\n region,\n setRegion,\n };\n}\n"],"mappings":";;;;;AAOA,SAAS,aAAa,EACpB,SACA,oBAIC;CAED,MAAM,eAAeA,0BAAAA,eAAe,iBAAiB,IAAI,KAAA;CACzD,MAAM,YAAY,WAAW;AAG7B,KAAI,gBAAgB,iBAAiB,UACnC,2BAAA,eAAe,kBAAkB,aAAa,GAAG;AAGnD,QAAO;;AAGT,SAAgB,eAAe,EAC7B,SACA,KACA,oBAC6C;CAC7C,MAAM,CAAC,QAAQ,eAAA,GAAA,MAAA,UACb,MACI,KAAA,IACA,aAAa;EACX;EACA;EACD,CAAC,CACP;CACD,MAAM,aAAa,cAAkC;AACnD,aAAW,UAAU;AACrB,4BAAA,eAAe,kBAAkB,aAAa,GAAG;;AAEnD,EAAA,GAAA,MAAA,iBAAgB;AACd,aAAW,aAAa;GAAE;GAAS;GAAkB,CAAC,CAAC;IACtD,CAAC,SAAS,iBAAiB,CAAC;AAC/B,QAAO;EACL;EACA;EACD"}
@@ -1,149 +1,128 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ let generaltranslation_internal = require("generaltranslation/internal");
4
+ //#region src/tools/testLocalePolyfill.ts
5
+ function testLocalePolyfill(locale = generaltranslation_internal.libraryDefaultLocale) {
6
+ const problems = [];
7
+ if (!global.Intl) problems.push("Intl missing entirely");
8
+ [
9
+ "Locale",
10
+ "NumberFormat",
11
+ "DateTimeFormat",
12
+ "PluralRules",
13
+ "RelativeTimeFormat",
14
+ "ListFormat",
15
+ "DisplayNames"
16
+ ].forEach((a) => {
17
+ if (!Intl[a]) problems.push(`Intl.${a} missing`);
18
+ });
19
+ const checks = [
20
+ ["DateTimeFormat", Intl.DateTimeFormat],
21
+ ["NumberFormat", Intl.NumberFormat],
22
+ ["PluralRules", Intl.PluralRules],
23
+ ["RelativeTimeFormat", Intl.RelativeTimeFormat],
24
+ ["ListFormat", Intl.ListFormat],
25
+ ["DisplayNames", Intl.DisplayNames]
26
+ ];
27
+ for (const [name, api] of checks) try {
28
+ if (api.supportedLocalesOf([locale]).length === 0) problems.push(`${locale} not supported by ${name}`);
29
+ } catch (e) {
30
+ problems.push(`${name}.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
31
+ }
32
+ let group, decimal;
33
+ try {
34
+ const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);
35
+ group = parts.find((p) => p.type === "group")?.value;
36
+ decimal = parts.find((p) => p.type === "decimal")?.value;
37
+ if (!group || !decimal) problems.push("formatToParts missing group/decimal separators");
38
+ } catch (e) {
39
+ problems.push(`NumberFormat threw: ${e instanceof Error ? e.message : String(e)}`);
40
+ }
41
+ try {
42
+ if (!new Intl.PluralRules(locale).select(5)) problems.push("PluralRules returned undefined");
43
+ } catch (e) {
44
+ problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
45
+ }
46
+ try {
47
+ if (!new Intl.RelativeTimeFormat(locale).format(-1, "day")) problems.push("RelativeTimeFormat returned undefined");
48
+ } catch (e) {
49
+ problems.push(`RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`);
50
+ }
51
+ try {
52
+ if (!new Intl.ListFormat(locale).format([
53
+ "apple",
54
+ "orange",
55
+ "banana"
56
+ ])) problems.push("ListFormat returned undefined");
57
+ } catch (e) {
58
+ problems.push(`ListFormat threw: ${e instanceof Error ? e.message : String(e)}`);
59
+ }
60
+ try {
61
+ if (!new Intl.DisplayNames(locale, { type: "language" }).of("en")) problems.push("DisplayNames returned undefined");
62
+ } catch (e) {
63
+ problems.push(`DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`);
64
+ }
65
+ try {
66
+ if (!new Intl.Locale(locale).language) problems.push("Locale missing language property");
67
+ } catch (e) {
68
+ problems.push(`Locale threw: ${e instanceof Error ? e.message : String(e)}`);
69
+ }
70
+ const example = {};
71
+ try {
72
+ example.number = new Intl.NumberFormat(locale).format(1234.5);
73
+ } catch {
74
+ example.number = "ERROR";
75
+ }
76
+ try {
77
+ example.date = new Intl.DateTimeFormat(locale, { dateStyle: "long" }).format(/* @__PURE__ */ new Date("2020-01-02"));
78
+ } catch {
79
+ example.date = "ERROR";
80
+ }
81
+ try {
82
+ example.weekday = new Intl.DateTimeFormat(locale, { weekday: "long" }).format(/* @__PURE__ */ new Date("2020-01-02"));
83
+ } catch {
84
+ example.weekday = "ERROR";
85
+ }
86
+ try {
87
+ example.pluralRule = new Intl.PluralRules(locale).select(5);
88
+ } catch {
89
+ example.pluralRule = "ERROR";
90
+ }
91
+ try {
92
+ example.relativeTime = new Intl.RelativeTimeFormat(locale).format(-1, "day");
93
+ } catch {
94
+ example.relativeTime = "ERROR";
95
+ }
96
+ try {
97
+ example.list = new Intl.ListFormat(locale).format([
98
+ "apple",
99
+ "orange",
100
+ "banana"
101
+ ]);
102
+ } catch {
103
+ example.list = "ERROR";
104
+ }
105
+ try {
106
+ example.displayName = new Intl.DisplayNames(locale, { type: "language" }).of("en") || "UNDEFINED";
107
+ } catch {
108
+ example.displayName = "ERROR";
109
+ }
110
+ try {
111
+ example.locale = new Intl.Locale(locale).language;
112
+ } catch {
113
+ example.locale = "ERROR";
114
+ }
115
+ const result = {
116
+ ok: problems.length === 0,
117
+ problems,
118
+ group,
119
+ decimal,
120
+ example
121
+ };
122
+ if (!result.ok) console.warn(`❌ Locale polyfill check failed for ${locale}:`, problems, example);
123
+ return result;
124
+ }
125
+ //#endregion
6
126
  exports.testLocalePolyfill = testLocalePolyfill;
7
- var _internal = require("generaltranslation/internal");
8
- function testLocalePolyfill(locale = _internal.libraryDefaultLocale) {
9
- const problems = [];
10
-
11
- // 1. basic presence
12
- if (!global.Intl) problems.push('Intl missing entirely');
13
- const apis = ['Locale', 'NumberFormat', 'DateTimeFormat', 'PluralRules', 'RelativeTimeFormat', 'ListFormat', 'DisplayNames'];
14
- apis.forEach(a => {
15
- // @ts-ignore
16
- if (!Intl[a]) problems.push(`Intl.${a} missing`);
17
- });
18
-
19
- // 2. locale actually supported (no silent fallback)
20
- const checks = [['DateTimeFormat', Intl.DateTimeFormat], ['NumberFormat', Intl.NumberFormat], ['PluralRules', Intl.PluralRules], ['RelativeTimeFormat', Intl.RelativeTimeFormat], ['ListFormat', Intl.ListFormat], ['DisplayNames', Intl.DisplayNames]];
21
- for (const [name, api] of checks) {
22
- try {
23
- const supported = api.supportedLocalesOf([locale]);
24
- if (supported.length === 0) {
25
- problems.push(`${locale} not supported by ${name}`);
26
- }
27
- } catch (e) {
28
- problems.push(`${name}.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`);
29
- }
30
- }
31
-
32
- // 3. numeric separators sanity
33
- let group, decimal;
34
- try {
35
- const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);
36
- group = parts.find(p => p.type === 'group')?.value;
37
- decimal = parts.find(p => p.type === 'decimal')?.value;
38
- if (!group || !decimal) problems.push('formatToParts missing group/decimal separators');
39
- } catch (e) {
40
- problems.push(`NumberFormat threw: ${e instanceof Error ? e.message : String(e)}`);
41
- }
42
-
43
- // 4. plural rules sanity
44
- try {
45
- const pr = new Intl.PluralRules(locale);
46
- const sample = pr.select(5);
47
- if (!sample) problems.push('PluralRules returned undefined');
48
- } catch (e) {
49
- problems.push(`PluralRules threw: ${e instanceof Error ? e.message : String(e)}`);
50
- }
51
127
 
52
- // 5. relative time format sanity
53
- try {
54
- const rtf = new Intl.RelativeTimeFormat(locale);
55
- const sample = rtf.format(-1, 'day');
56
- if (!sample) problems.push('RelativeTimeFormat returned undefined');
57
- } catch (e) {
58
- problems.push(`RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`);
59
- }
60
-
61
- // 6. list format sanity
62
- try {
63
- const lf = new Intl.ListFormat(locale);
64
- const sample = lf.format(['apple', 'orange', 'banana']);
65
- if (!sample) problems.push('ListFormat returned undefined');
66
- } catch (e) {
67
- problems.push(`ListFormat threw: ${e instanceof Error ? e.message : String(e)}`);
68
- }
69
-
70
- // 7. display names sanity
71
- try {
72
- const dn = new Intl.DisplayNames(locale, {
73
- type: 'language'
74
- });
75
- const sample = dn.of('en');
76
- if (!sample) problems.push('DisplayNames returned undefined');
77
- } catch (e) {
78
- problems.push(`DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`);
79
- }
80
-
81
- // 8. locale sanity
82
- try {
83
- const loc = new Intl.Locale(locale);
84
- if (!loc.language) problems.push('Locale missing language property');
85
- } catch (e) {
86
- problems.push(`Locale threw: ${e instanceof Error ? e.message : String(e)}`);
87
- }
88
-
89
- // 9. show example formatted values
90
- const example = {};
91
- try {
92
- example.number = new Intl.NumberFormat(locale).format(1234.5);
93
- } catch {
94
- example.number = 'ERROR';
95
- }
96
- try {
97
- example.date = new Intl.DateTimeFormat(locale, {
98
- dateStyle: 'long'
99
- }).format(new Date('2020-01-02'));
100
- } catch {
101
- example.date = 'ERROR';
102
- }
103
- try {
104
- example.weekday = new Intl.DateTimeFormat(locale, {
105
- weekday: 'long'
106
- }).format(new Date('2020-01-02'));
107
- } catch {
108
- example.weekday = 'ERROR';
109
- }
110
- try {
111
- example.pluralRule = new Intl.PluralRules(locale).select(5);
112
- } catch {
113
- example.pluralRule = 'ERROR';
114
- }
115
- try {
116
- example.relativeTime = new Intl.RelativeTimeFormat(locale).format(-1, 'day');
117
- } catch {
118
- example.relativeTime = 'ERROR';
119
- }
120
- try {
121
- example.list = new Intl.ListFormat(locale).format(['apple', 'orange', 'banana']);
122
- } catch {
123
- example.list = 'ERROR';
124
- }
125
- try {
126
- example.displayName = new Intl.DisplayNames(locale, {
127
- type: 'language'
128
- }).of('en') || 'UNDEFINED';
129
- } catch {
130
- example.displayName = 'ERROR';
131
- }
132
- try {
133
- example.locale = new Intl.Locale(locale).language;
134
- } catch {
135
- example.locale = 'ERROR';
136
- }
137
- const result = {
138
- ok: problems.length === 0,
139
- problems,
140
- group,
141
- decimal,
142
- example
143
- };
144
- if (!result.ok) {
145
- console.warn(`❌ Locale polyfill check failed for ${locale}:`, problems, example);
146
- }
147
- return result;
148
- }
149
128
  //# sourceMappingURL=testLocalePolyfill.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_internal","require","testLocalePolyfill","locale","libraryDefaultLocale","problems","global","Intl","push","apis","forEach","a","checks","DateTimeFormat","NumberFormat","PluralRules","RelativeTimeFormat","ListFormat","DisplayNames","name","api","supported","supportedLocalesOf","length","e","Error","message","String","group","decimal","parts","formatToParts","find","p","type","value","pr","sample","select","rtf","format","lf","dn","of","loc","Locale","language","example","number","date","dateStyle","Date","weekday","pluralRule","relativeTime","list","displayName","result","ok","console","warn"],"sourceRoot":"../../../src","sources":["tools/testLocalePolyfill.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAACC,MAAM,GAAGC,8BAAoB,EAAE;EAChE,MAAMC,QAAQ,GAAG,EAAE;;EAEnB;EACA,IAAI,CAACC,MAAM,CAACC,IAAI,EAAEF,QAAQ,CAACG,IAAI,CAAC,uBAAuB,CAAC;EACxD,MAAMC,IAAI,GAAG,CACX,QAAQ,EACR,cAAc,EACd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CAAC,CAACqC,MAAM,CAAC,CAChD,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAC;EACJ,CAAC,CAAC,MAAM;IACNO,OAAO,CAACQ,IAAI,GAAG,OAAO;EACxB;EAEA,IAAI;IACFR,OAAO,CAACS,WAAW,GACjB,IAAIjD,IAAI,CAACW,YAAY,CAACf,MAAM,EAAE;MAAE+B,IAAI,EAAE;IAAW,CAAC,CAAC,CAACS,EAAE,CAAC,IAAI,CAAC,IAC5D,WAAW;EACf,CAAC,CAAC,MAAM;IACNI,OAAO,CAACS,WAAW,GAAG,OAAO;EAC/B;EAEA,IAAI;IACFT,OAAO,CAAC5C,MAAM,GAAG,IAAII,IAAI,CAACsC,MAAM,CAAC1C,MAAM,CAAC,CAAC2C,QAAQ;EACnD,CAAC,CAAC,MAAM;IACNC,OAAO,CAAC5C,MAAM,GAAG,OAAO;EAC1B;EAEA,MAAMsD,MAAM,GAAG;IACbC,EAAE,EAAErD,QAAQ,CAACkB,MAAM,KAAK,CAAC;IACzBlB,QAAQ;IACRuB,KAAK;IACLC,OAAO;IACPkB;EACF,CAAC;EAED,IAAI,CAACU,MAAM,CAACC,EAAE,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,sCAAsCzD,MAAM,GAAG,EAC/CE,QAAQ,EACR0C,OACF,CAAC;EACH;EACA,OAAOU,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"testLocalePolyfill.js","names":["libraryDefaultLocale"],"sources":["../../../src/tools/testLocalePolyfill.ts"],"sourcesContent":["import { libraryDefaultLocale } from 'generaltranslation/internal';\n\nexport function testLocalePolyfill(locale = libraryDefaultLocale) {\n const problems = [];\n\n // 1. basic presence\n if (!global.Intl) problems.push('Intl missing entirely');\n const apis = [\n 'Locale',\n 'NumberFormat',\n 'DateTimeFormat',\n 'PluralRules',\n 'RelativeTimeFormat',\n 'ListFormat',\n 'DisplayNames',\n ];\n apis.forEach((a) => {\n // @ts-ignore\n if (!Intl[a]) problems.push(`Intl.${a} missing`);\n });\n\n // 2. locale actually supported (no silent fallback)\n const checks: [\n string,\n { supportedLocalesOf(locales: string[]): string[] },\n ][] = [\n ['DateTimeFormat', Intl.DateTimeFormat],\n ['NumberFormat', Intl.NumberFormat],\n ['PluralRules', Intl.PluralRules],\n ['RelativeTimeFormat', Intl.RelativeTimeFormat],\n ['ListFormat', Intl.ListFormat],\n ['DisplayNames', Intl.DisplayNames],\n ];\n\n for (const [name, api] of checks) {\n try {\n const supported = api.supportedLocalesOf([locale]);\n if (supported.length === 0) {\n problems.push(`${locale} not supported by ${name}`);\n }\n } catch (e) {\n problems.push(\n `${name}.supportedLocalesOf threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n }\n\n // 3. numeric separators sanity\n let group, decimal;\n try {\n const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);\n group = parts.find((p) => p.type === 'group')?.value;\n decimal = parts.find((p) => p.type === 'decimal')?.value;\n if (!group || !decimal)\n problems.push('formatToParts missing group/decimal separators');\n } catch (e) {\n problems.push(\n `NumberFormat threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 4. plural rules sanity\n try {\n const pr = new Intl.PluralRules(locale);\n const sample = pr.select(5);\n if (!sample) problems.push('PluralRules returned undefined');\n } catch (e) {\n problems.push(\n `PluralRules threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 5. relative time format sanity\n try {\n const rtf = new Intl.RelativeTimeFormat(locale);\n const sample = rtf.format(-1, 'day');\n if (!sample) problems.push('RelativeTimeFormat returned undefined');\n } catch (e) {\n problems.push(\n `RelativeTimeFormat threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 6. list format sanity\n try {\n const lf = new Intl.ListFormat(locale);\n const sample = lf.format(['apple', 'orange', 'banana']);\n if (!sample) problems.push('ListFormat returned undefined');\n } catch (e) {\n problems.push(\n `ListFormat threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 7. display names sanity\n try {\n const dn = new Intl.DisplayNames(locale, { type: 'language' });\n const sample = dn.of('en');\n if (!sample) problems.push('DisplayNames returned undefined');\n } catch (e) {\n problems.push(\n `DisplayNames threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 8. locale sanity\n try {\n const loc = new Intl.Locale(locale);\n if (!loc.language) problems.push('Locale missing language property');\n } catch (e) {\n problems.push(\n `Locale threw: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n\n // 9. show example formatted values\n const example: Record<string, string> = {};\n\n try {\n example.number = new Intl.NumberFormat(locale).format(1234.5);\n } catch {\n example.number = 'ERROR';\n }\n\n try {\n example.date = new Intl.DateTimeFormat(locale, {\n dateStyle: 'long',\n }).format(new Date('2020-01-02'));\n } catch {\n example.date = 'ERROR';\n }\n\n try {\n example.weekday = new Intl.DateTimeFormat(locale, {\n weekday: 'long',\n }).format(new Date('2020-01-02'));\n } catch {\n example.weekday = 'ERROR';\n }\n\n try {\n example.pluralRule = new Intl.PluralRules(locale).select(5);\n } catch {\n example.pluralRule = 'ERROR';\n }\n\n try {\n example.relativeTime = new Intl.RelativeTimeFormat(locale).format(\n -1,\n 'day'\n );\n } catch {\n example.relativeTime = 'ERROR';\n }\n\n try {\n example.list = new Intl.ListFormat(locale).format([\n 'apple',\n 'orange',\n 'banana',\n ]);\n } catch {\n example.list = 'ERROR';\n }\n\n try {\n example.displayName =\n new Intl.DisplayNames(locale, { type: 'language' }).of('en') ||\n 'UNDEFINED';\n } catch {\n example.displayName = 'ERROR';\n }\n\n try {\n example.locale = new Intl.Locale(locale).language;\n } catch {\n example.locale = 'ERROR';\n }\n\n const result = {\n ok: problems.length === 0,\n problems,\n group,\n decimal,\n example,\n };\n\n if (!result.ok) {\n console.warn(\n `❌ Locale polyfill check failed for ${locale}:`,\n problems,\n example\n );\n }\n return result;\n}\n"],"mappings":";;;;AAEA,SAAgB,mBAAmB,SAASA,4BAAAA,sBAAsB;CAChE,MAAM,WAAW,EAAE;AAGnB,KAAI,CAAC,OAAO,KAAM,UAAS,KAAK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;SACK;AACN,UAAQ,eAAe;;AAGzB,KAAI;AACF,UAAQ,OAAO,IAAI,KAAK,WAAW,OAAO,CAAC,OAAO;GAChD;GACA;GACA;GACD,CAAC;SACI;AACN,UAAQ,OAAO;;AAGjB,KAAI;AACF,UAAQ,cACN,IAAI,KAAK,aAAa,QAAQ,EAAE,MAAM,YAAY,CAAC,CAAC,GAAG,KAAK,IAC5D;SACI;AACN,UAAQ,cAAc;;AAGxB,KAAI;AACF,UAAQ,SAAS,IAAI,KAAK,OAAO,OAAO,CAAC;SACnC;AACN,UAAQ,SAAS;;CAGnB,MAAM,SAAS;EACb,IAAI,SAAS,WAAW;EACxB;EACA;EACA;EACA;EACD;AAED,KAAI,CAAC,OAAO,GACV,SAAQ,KACN,sCAAsC,OAAO,IAC7C,UACA,QACD;AAEH,QAAO"}
@@ -1,6 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=config.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,61 +1,43 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNativeLocales = getNativeLocales;
7
- var _reactNative = require("react-native");
8
- var _NativeGtReactNative = _interopRequireDefault(require("../NativeGtReactNative"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_NativeGtReactNative = require("../NativeGtReactNative.js");
4
+ let react_native = require("react-native");
5
+ //#region src/utils/getNativeLocales.ts
10
6
  /**
11
- * Get native device locales in preference order
12
- * Returns an empty array if detection fails or is not supported
13
- *
14
- * iOS: Returns current locale first, followed by preferred languages
15
- * Android: Returns user's preferred language list (LocaleList on API 24+, single locale on older versions)
16
- * Web: Returns browser language preferences from navigator
17
- */
7
+ * Get native device locales in preference order
8
+ * Returns an empty array if detection fails or is not supported
9
+ *
10
+ * iOS: Returns current locale first, followed by preferred languages
11
+ * Android: Returns user's preferred language list (LocaleList on API 24+, single locale on older versions)
12
+ * Web: Returns browser language preferences from navigator
13
+ */
18
14
  function getNativeLocales() {
19
- try {
20
- // Web platform - use browser locale detection
21
- if (_reactNative.Platform.OS === 'web') {
22
- return getWebLocales();
23
- }
24
-
25
- // Try to get locales from native module
26
- return _NativeGtReactNative.default.getNativeLocales() || [];
27
- } catch {
28
- // Return empty array on any error (native module not available, etc.)
29
- return [];
30
- }
15
+ try {
16
+ if (react_native.Platform.OS === "web") return getWebLocales();
17
+ return require_NativeGtReactNative.default.getNativeLocales() || [];
18
+ } catch {
19
+ return [];
20
+ }
31
21
  }
32
-
33
22
  /**
34
- * Get browser locales for web platform
35
- */
23
+ * Get browser locales for web platform
24
+ */
36
25
  function getWebLocales() {
37
- try {
38
- if (typeof navigator === 'undefined') {
39
- return [];
40
- }
41
- const locales = [];
42
-
43
- // Use navigator.languages if available (most browsers)
44
- if (navigator.languages && Array.isArray(navigator.languages)) {
45
- locales.push(...navigator.languages);
46
- } else if (navigator.language) {
47
- // Fallback to single language
48
- locales.push(navigator.language);
49
- } else {
50
- // IE fallback
51
- const legacyNavigator = navigator;
52
- if (legacyNavigator.userLanguage) {
53
- locales.push(legacyNavigator.userLanguage);
54
- }
55
- }
56
- return locales;
57
- } catch {
58
- return [];
59
- }
26
+ try {
27
+ if (typeof navigator === "undefined") return [];
28
+ const locales = [];
29
+ if (navigator.languages && Array.isArray(navigator.languages)) locales.push(...navigator.languages);
30
+ else if (navigator.language) locales.push(navigator.language);
31
+ else {
32
+ const legacyNavigator = navigator;
33
+ if (legacyNavigator.userLanguage) locales.push(legacyNavigator.userLanguage);
34
+ }
35
+ return locales;
36
+ } catch {
37
+ return [];
38
+ }
60
39
  }
40
+ //#endregion
41
+ exports.getNativeLocales = getNativeLocales;
42
+
61
43
  //# sourceMappingURL=getNativeLocales.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_NativeGtReactNative","_interopRequireDefault","e","__esModule","default","getNativeLocales","Platform","OS","getWebLocales","GtReactNative","navigator","locales","languages","Array","isArray","push","language","legacyNavigator","userLanguage"],"sourceRoot":"../../../src","sources":["utils/getNativeLocales.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gBAAgBA,CAAA,EAAa;EAC3C,IAAI;IACF;IACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzB,OAAOC,aAAa,CAAC,CAAC;IACxB;;IAEA;IACA,OAAOC,4BAAa,CAACJ,gBAAgB,CAAC,CAAC,IAAI,EAAE;EAC/C,CAAC,CAAC,MAAM;IACN;IACA,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA;AACA,SAASG,aAAaA,CAAA,EAAa;EACjC,IAAI;IACF,IAAI,OAAOE,SAAS,KAAK,WAAW,EAAE;MACpC,OAAO,EAAE;IACX;IAEA,MAAMC,OAAiB,GAAG,EAAE;;IAE5B;IACA,IAAID,SAAS,CAACE,SAAS,IAAIC,KAAK,CAACC,OAAO,CAACJ,SAAS,CAACE,SAAS,CAAC,EAAE;MAC7DD,OAAO,CAACI,IAAI,CAAC,GAAGL,SAAS,CAACE,SAAS,CAAC;IACtC,CAAC,MAAM,IAAIF,SAAS,CAACM,QAAQ,EAAE;MAC7B;MACAL,OAAO,CAACI,IAAI,CAACL,SAAS,CAACM,QAAQ,CAAC;IAClC,CAAC,MAAM;MACL;MACA,MAAMC,eAAe,GAAGP,SAEvB;MACD,IAAIO,eAAe,CAACC,YAAY,EAAE;QAChCP,OAAO,CAACI,IAAI,CAACE,eAAe,CAACC,YAAY,CAAC;MAC5C;IACF;IAEA,OAAOP,OAAO;EAChB,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF","ignoreList":[]}
1
+ {"version":3,"file":"getNativeLocales.js","names":["Platform","GtReactNative"],"sources":["../../../src/utils/getNativeLocales.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport GtReactNative from '../NativeGtReactNative';\n\n/**\n * Get native device locales in preference order\n * Returns an empty array if detection fails or is not supported\n *\n * iOS: Returns current locale first, followed by preferred languages\n * Android: Returns user's preferred language list (LocaleList on API 24+, single locale on older versions)\n * Web: Returns browser language preferences from navigator\n */\nexport function getNativeLocales(): string[] {\n try {\n // Web platform - use browser locale detection\n if (Platform.OS === 'web') {\n return getWebLocales();\n }\n\n // Try to get locales from native module\n return GtReactNative.getNativeLocales() || [];\n } catch {\n // Return empty array on any error (native module not available, etc.)\n return [];\n }\n}\n\n/**\n * Get browser locales for web platform\n */\nfunction getWebLocales(): string[] {\n try {\n if (typeof navigator === 'undefined') {\n return [];\n }\n\n const locales: string[] = [];\n\n // Use navigator.languages if available (most browsers)\n if (navigator.languages && Array.isArray(navigator.languages)) {\n locales.push(...navigator.languages);\n } else if (navigator.language) {\n // Fallback to single language\n locales.push(navigator.language);\n } else {\n // IE fallback\n const legacyNavigator = navigator as Navigator & {\n userLanguage?: string;\n };\n if (legacyNavigator.userLanguage) {\n locales.push(legacyNavigator.userLanguage);\n }\n }\n\n return locales;\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,mBAA6B;AAC3C,KAAI;AAEF,MAAIA,aAAAA,SAAS,OAAO,MAClB,QAAO,eAAe;AAIxB,SAAOC,4BAAAA,QAAc,kBAAkB,IAAI,EAAE;SACvC;AAEN,SAAO,EAAE;;;;;;AAOb,SAAS,gBAA0B;AACjC,KAAI;AACF,MAAI,OAAO,cAAc,YACvB,QAAO,EAAE;EAGX,MAAM,UAAoB,EAAE;AAG5B,MAAI,UAAU,aAAa,MAAM,QAAQ,UAAU,UAAU,CAC3D,SAAQ,KAAK,GAAG,UAAU,UAAU;WAC3B,UAAU,SAEnB,SAAQ,KAAK,UAAU,SAAS;OAC3B;GAEL,MAAM,kBAAkB;AAGxB,OAAI,gBAAgB,aAClB,SAAQ,KAAK,gBAAgB,aAAa;;AAI9C,SAAO;SACD;AACN,SAAO,EAAE"}
@@ -1,50 +1,45 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.nativeStoreGet = nativeStoreGet;
7
- exports.nativeStoreSet = nativeStoreSet;
8
- var _reactNative = require("react-native");
9
- var _NativeGtReactNative = _interopRequireDefault(require("../NativeGtReactNative"));
10
- var _warnings = require("../errors-dir/warnings");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_NativeGtReactNative = require("../NativeGtReactNative.js");
4
+ const require_errors_dir_warnings = require("../errors-dir/warnings.js");
5
+ let react_native = require("react-native");
6
+ //#region src/utils/nativeStore.ts
12
7
  /**
13
- * Native store interface, used to replace cookie behavior from gt-react
14
- */
15
-
8
+ * Native store interface, used to replace cookie behavior from gt-react
9
+ */
16
10
  /**
17
- * Get a value from the native store
18
- * @param key - The key to get the value for
19
- * @returns The value for the key
20
- */
11
+ * Get a value from the native store
12
+ * @param key - The key to get the value for
13
+ * @returns The value for the key
14
+ */
21
15
  function nativeStoreGet(key) {
22
- if (_reactNative.Platform.OS === 'web') {
23
- if (typeof localStorage === 'undefined') {
24
- // eslint-disable-next-line no-console
25
- console.warn(_warnings.ssrUnsupportedWarning);
26
- return null;
27
- }
28
- return localStorage.getItem(key);
29
- }
30
- return _NativeGtReactNative.default.nativeStoreGet(key);
16
+ if (react_native.Platform.OS === "web") {
17
+ if (typeof localStorage === "undefined") {
18
+ console.warn(require_errors_dir_warnings.ssrUnsupportedWarning);
19
+ return null;
20
+ }
21
+ return localStorage.getItem(key);
22
+ }
23
+ return require_NativeGtReactNative.default.nativeStoreGet(key);
31
24
  }
32
-
33
25
  /**
34
- * Set a value in the native store
35
- * @param key - The key to set the value for
36
- * @param value - The value to set
37
- */
26
+ * Set a value in the native store
27
+ * @param key - The key to set the value for
28
+ * @param value - The value to set
29
+ */
38
30
  function nativeStoreSet(key, value) {
39
- if (_reactNative.Platform.OS === 'web') {
40
- if (typeof localStorage === 'undefined') {
41
- // eslint-disable-next-line no-console
42
- console.warn(_warnings.ssrUnsupportedWarning);
43
- return;
44
- }
45
- localStorage.setItem(key, value);
46
- return;
47
- }
48
- _NativeGtReactNative.default.nativeStoreSet(key, value);
31
+ if (react_native.Platform.OS === "web") {
32
+ if (typeof localStorage === "undefined") {
33
+ console.warn(require_errors_dir_warnings.ssrUnsupportedWarning);
34
+ return;
35
+ }
36
+ localStorage.setItem(key, value);
37
+ return;
38
+ }
39
+ require_NativeGtReactNative.default.nativeStoreSet(key, value);
49
40
  }
41
+ //#endregion
42
+ exports.nativeStoreGet = nativeStoreGet;
43
+ exports.nativeStoreSet = nativeStoreSet;
44
+
50
45
  //# sourceMappingURL=nativeStore.js.map