gt-react-native 11.0.0-odysseus.9 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/commonjs/condition-store/NativeConditionStore.js +19 -27
  2. package/dist/commonjs/condition-store/NativeConditionStore.js.map +1 -1
  3. package/dist/commonjs/hooks/selectors.js.map +1 -1
  4. package/dist/commonjs/index.js +34 -9
  5. package/dist/commonjs/provider/GTProvider.js +32 -21
  6. package/dist/commonjs/provider/GTProvider.js.map +1 -1
  7. package/dist/commonjs/provider/NativeGTProvider.js +0 -3
  8. package/dist/commonjs/provider/NativeGTProvider.js.map +1 -1
  9. package/dist/commonjs/setup/initializeGT.js +6 -11
  10. package/dist/commonjs/utils/getInitialNativeConditions.js +2 -2
  11. package/dist/commonjs/utils/getInitialNativeConditions.js.map +1 -1
  12. package/dist/commonjs/utils/getLocale.js +1 -1
  13. package/dist/commonjs/utils/getLocale.js.map +1 -1
  14. package/dist/commonjs/utils/nativeStore.js +2 -2
  15. package/dist/commonjs/utils/nativeStore.js.map +1 -1
  16. package/dist/commonjs/utils/resolveLocale.js +1 -2
  17. package/dist/commonjs/utils/resolveLocale.js.map +1 -1
  18. package/dist/module/condition-store/NativeConditionStore.d.ts +0 -7
  19. package/dist/module/condition-store/NativeConditionStore.d.ts.map +1 -1
  20. package/dist/module/condition-store/NativeConditionStore.js +20 -28
  21. package/dist/module/condition-store/NativeConditionStore.js.map +1 -1
  22. package/dist/module/hooks/selectors.d.ts +3 -11
  23. package/dist/module/hooks/selectors.d.ts.map +1 -1
  24. package/dist/module/hooks/selectors.js.map +1 -1
  25. package/dist/module/index.d.ts +2 -3
  26. package/dist/module/index.d.ts.map +1 -1
  27. package/dist/module/index.js +3 -4
  28. package/dist/module/provider/GTProvider.d.ts +1 -1
  29. package/dist/module/provider/GTProvider.d.ts.map +1 -1
  30. package/dist/module/provider/GTProvider.js +32 -21
  31. package/dist/module/provider/GTProvider.js.map +1 -1
  32. package/dist/module/provider/NativeGTProvider.d.ts.map +1 -1
  33. package/dist/module/provider/NativeGTProvider.js +0 -3
  34. package/dist/module/provider/NativeGTProvider.js.map +1 -1
  35. package/dist/module/setup/initializeGT.d.ts +3 -4
  36. package/dist/module/setup/initializeGT.d.ts.map +1 -1
  37. package/dist/module/setup/initializeGT.js +1 -11
  38. package/dist/module/utils/getInitialNativeConditions.d.ts.map +1 -1
  39. package/dist/module/utils/getInitialNativeConditions.js +3 -3
  40. package/dist/module/utils/getInitialNativeConditions.js.map +1 -1
  41. package/dist/module/utils/getLocale.d.ts.map +1 -1
  42. package/dist/module/utils/getLocale.js +2 -2
  43. package/dist/module/utils/getLocale.js.map +1 -1
  44. package/dist/module/utils/nativeStore.d.ts +1 -1
  45. package/dist/module/utils/nativeStore.d.ts.map +1 -1
  46. package/dist/module/utils/nativeStore.js +3 -3
  47. package/dist/module/utils/nativeStore.js.map +1 -1
  48. package/dist/module/utils/resolveLocale.d.ts.map +1 -1
  49. package/dist/module/utils/resolveLocale.js +1 -2
  50. package/dist/module/utils/resolveLocale.js.map +1 -1
  51. package/package.json +6 -6
  52. package/src/condition-store/NativeConditionStore.ts +21 -40
  53. package/src/hooks/selectors.ts +17 -3
  54. package/src/index.tsx +5 -2
  55. package/src/provider/GTProvider.tsx +51 -29
  56. package/src/provider/NativeGTProvider.tsx +1 -9
  57. package/src/setup/initializeGT.ts +7 -19
  58. package/src/utils/getInitialNativeConditions.ts +3 -6
  59. package/src/utils/getLocale.ts +2 -2
  60. package/src/utils/nativeStore.ts +3 -3
  61. package/src/utils/resolveLocale.ts +1 -5
  62. package/dist/commonjs/hooks/utils.js +0 -17
  63. package/dist/commonjs/hooks/utils.js.map +0 -1
  64. package/dist/commonjs/setup/initializeGT.js.map +0 -1
  65. package/dist/module/hooks/utils.d.ts +0 -3
  66. package/dist/module/hooks/utils.d.ts.map +0 -1
  67. package/dist/module/hooks/utils.js +0 -14
  68. package/dist/module/hooks/utils.js.map +0 -1
  69. package/dist/module/setup/initializeGT.js.map +0 -1
  70. package/src/hooks/utils.ts +0 -14
@@ -1 +1 @@
1
- {"version":3,"file":"NativeConditionStore.js","names":["defaultLocaleStoreKey","defaultRegionStoreKey","defaultEnableI18nStoreKey"],"sources":["../../../src/condition-store/NativeConditionStore.ts"],"sourcesContent":["import type {\n LocaleCandidates,\n WritableConditionStoreInterface,\n WritableConditionStoreParams,\n} from 'gt-i18n/internal/types';\nimport {\n defaultEnableI18nCookieName as defaultEnableI18nStoreKey,\n defaultLocaleCookieName as defaultLocaleStoreKey,\n defaultRegionCookieName as defaultRegionStoreKey,\n} from '@generaltranslation/react-core/pure';\nimport { getLocale } from '../utils/getLocale';\nimport {\n getInitialEnableI18n,\n getInitialRegion,\n} from '../utils/getInitialNativeConditions';\nimport { nativeStoreGet, nativeStoreSet } from '../utils/nativeStore';\nimport { resolveLocale } from '../utils/resolveLocale';\n\nexport type NativeConditionStoreParams = WritableConditionStoreParams & {\n localeStoreKey?: string;\n regionStoreKey?: string;\n enableI18nStoreKey?: string;\n _reload?: ReloadType;\n};\n\nexport type NativeConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\n\nexport type ReloadType = (state: NativeConditionStoreState) => void;\n\n/**\n * Condition store implementation for React Native.\n */\nexport class NativeConditionStore implements WritableConditionStoreInterface {\n private localeStoreKey: string;\n private regionStoreKey: string;\n private enableI18nStoreKey: string;\n private customReload: ReloadType;\n\n constructor(config: NativeConditionStoreParams) {\n this.customReload = config._reload ?? (() => undefined);\n this.localeStoreKey = config.localeStoreKey ?? defaultLocaleStoreKey;\n this.regionStoreKey = config.regionStoreKey ?? defaultRegionStoreKey;\n this.enableI18nStoreKey =\n config.enableI18nStoreKey ?? defaultEnableI18nStoreKey;\n\n this.updateLocale(\n config.locale ?? getLocale({ localeStoreKey: this.localeStoreKey })\n );\n const region = getInitialRegion({\n region: config.region,\n regionStoreKey: this.regionStoreKey,\n });\n if (region !== undefined) {\n this.updateRegion(region);\n }\n this.updateEnableI18n(\n getInitialEnableI18n({\n enableI18n: config.enableI18n,\n enableI18nStoreKey: this.enableI18nStoreKey,\n })\n );\n }\n\n updateConfig = ({\n localeStoreKey,\n regionStoreKey,\n enableI18nStoreKey,\n }: Pick<\n NativeConditionStoreParams,\n 'localeStoreKey' | 'regionStoreKey' | 'enableI18nStoreKey'\n >): void => {\n this.localeStoreKey = localeStoreKey ?? defaultLocaleStoreKey;\n this.regionStoreKey = regionStoreKey ?? defaultRegionStoreKey;\n this.enableI18nStoreKey = enableI18nStoreKey ?? defaultEnableI18nStoreKey;\n };\n\n getLocale = (): string => {\n return getLocale({ localeStoreKey: this.localeStoreKey });\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n const nextLocale = resolveLocale(locale);\n nativeStoreSet(this.localeStoreKey, nextLocale);\n this.reload({ locale: nextLocale });\n };\n\n getRegion = (): string | undefined => {\n return nativeStoreGet(this.regionStoreKey) || undefined;\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload({ region });\n };\n\n getEnableI18n = (): boolean => {\n return nativeStoreGet(this.enableI18nStoreKey) !== 'false';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload({ enableI18n });\n };\n\n updateLocale = (locale: LocaleCandidates): void => {\n nativeStoreSet(this.localeStoreKey, resolveLocale(locale));\n };\n\n updateRegion = (region: string | undefined): void => {\n nativeStoreSet(this.regionStoreKey, region ?? '');\n };\n\n updateEnableI18n = (enableI18n: boolean): void => {\n nativeStoreSet(this.enableI18nStoreKey, enableI18n ? 'true' : 'false');\n };\n\n reload = (state: Partial<NativeConditionStoreState> = {}): void => {\n this.customReload({\n locale: state.locale ?? this.getLocale(),\n region: 'region' in state ? state.region : this.getRegion(),\n enableI18n: state.enableI18n ?? this.getEnableI18n(),\n });\n };\n}\n"],"mappings":";;;;;;;;;AAoCA,IAAa,uBAAb,MAA6E;CAC3E;CACA;CACA;CACA;CAEA,YAAY,QAAoC;AAC9C,OAAK,eAAe,OAAO,kBAAkB,KAAA;AAC7C,OAAK,iBAAiB,OAAO,kBAAkBA;AAC/C,OAAK,iBAAiB,OAAO,kBAAkBC;AAC/C,OAAK,qBACH,OAAO,sBAAsBC;AAE/B,OAAK,aACH,OAAO,UAAU,UAAU,EAAE,gBAAgB,KAAK,gBAAgB,CAAC,CACpE;EACD,MAAM,SAAS,iBAAiB;GAC9B,QAAQ,OAAO;GACf,gBAAgB,KAAK;GACtB,CAAC;AACF,MAAI,WAAW,KAAA,EACb,MAAK,aAAa,OAAO;AAE3B,OAAK,iBACH,qBAAqB;GACnB,YAAY,OAAO;GACnB,oBAAoB,KAAK;GAC1B,CAAC,CACH;;CAGH,gBAAgB,EACd,gBACA,gBACA,yBAIU;AACV,OAAK,iBAAiB,kBAAkBF;AACxC,OAAK,iBAAiB,kBAAkBC;AACxC,OAAK,qBAAqB,sBAAsBC;;CAGlD,kBAA0B;AACxB,SAAO,UAAU,EAAE,gBAAgB,KAAK,gBAAgB,CAAC;;CAG3D,aAAa,WAAmC;EAC9C,MAAM,aAAa,cAAc,OAAO;AACxC,iBAAe,KAAK,gBAAgB,WAAW;AAC/C,OAAK,OAAO,EAAE,QAAQ,YAAY,CAAC;;CAGrC,kBAAsC;AACpC,SAAO,eAAe,KAAK,eAAe,IAAI,KAAA;;CAGhD,aAAa,WAAqC;AAChD,OAAK,aAAa,OAAO;AACzB,OAAK,OAAO,EAAE,QAAQ,CAAC;;CAGzB,sBAA+B;AAC7B,SAAO,eAAe,KAAK,mBAAmB,KAAK;;CAGrD,iBAAiB,eAA8B;AAC7C,OAAK,iBAAiB,WAAW;AACjC,OAAK,OAAO,EAAE,YAAY,CAAC;;CAG7B,gBAAgB,WAAmC;AACjD,iBAAe,KAAK,gBAAgB,cAAc,OAAO,CAAC;;CAG5D,gBAAgB,WAAqC;AACnD,iBAAe,KAAK,gBAAgB,UAAU,GAAG;;CAGnD,oBAAoB,eAA8B;AAChD,iBAAe,KAAK,oBAAoB,aAAa,SAAS,QAAQ;;CAGxE,UAAU,QAA4C,EAAE,KAAW;AACjE,OAAK,aAAa;GAChB,QAAQ,MAAM,UAAU,KAAK,WAAW;GACxC,QAAQ,YAAY,QAAQ,MAAM,SAAS,KAAK,WAAW;GAC3D,YAAY,MAAM,cAAc,KAAK,eAAe;GACrD,CAAC"}
1
+ {"version":3,"file":"NativeConditionStore.js","names":[],"sources":["../../../src/condition-store/NativeConditionStore.ts"],"sourcesContent":["import type {\n LocaleCandidates,\n WritableConditionStoreInterface,\n WritableConditionStoreParams,\n} from 'gt-i18n/internal/types';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getLocale } from '../utils/getLocale';\nimport {\n getInitialEnableI18n,\n getInitialRegion,\n} from '../utils/getInitialNativeConditions';\nimport { nativeStoreGet, nativeStoreSet } from '../utils/nativeStore';\nimport { resolveLocale } from '../utils/resolveLocale';\n\nexport type NativeConditionStoreParams = WritableConditionStoreParams & {\n _reload?: ReloadType;\n};\n\nexport type NativeConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\n\nexport type ReloadType = (state: NativeConditionStoreState) => void;\n\n/**\n * Condition store implementation for React Native.\n */\nexport class NativeConditionStore implements WritableConditionStoreInterface {\n private customReload: ReloadType;\n\n constructor(config: NativeConditionStoreParams) {\n this.customReload = config._reload ?? (() => undefined);\n\n this.updateLocale(config.locale ?? getLocale());\n const region = getInitialRegion({\n region: config.region,\n });\n if (region !== undefined) {\n this.updateRegion(region);\n }\n this.updateEnableI18n(\n getInitialEnableI18n({\n enableI18n: config.enableI18n,\n })\n );\n }\n\n getLocale = (): string => {\n return getLocale();\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n const nextLocale = resolveLocale(locale);\n nativeStoreSet(getLocaleStoreKey(), nextLocale);\n this.reload({ locale: nextLocale });\n };\n\n getRegion = (): string | undefined => {\n return nativeStoreGet(getRegionStoreKey()) || undefined;\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload({ region });\n };\n\n getEnableI18n = (): boolean => {\n return nativeStoreGet(getEnableI18nStoreKey()) !== 'false';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload({ enableI18n });\n };\n\n updateLocale = (locale: LocaleCandidates): void => {\n nativeStoreSet(getLocaleStoreKey(), resolveLocale(locale));\n };\n\n updateRegion = (region: string | undefined): void => {\n nativeStoreSet(getRegionStoreKey(), region ?? '');\n };\n\n updateEnableI18n = (enableI18n: boolean): void => {\n nativeStoreSet(getEnableI18nStoreKey(), enableI18n ? 'true' : 'false');\n };\n\n reload = (state: Partial<NativeConditionStoreState> = {}): void => {\n this.customReload({\n locale: state.locale ?? this.getLocale(),\n region: 'region' in state ? state.region : this.getRegion(),\n enableI18n: state.enableI18n ?? this.getEnableI18n(),\n });\n };\n}\n\nfunction getLocaleStoreKey(): string {\n return getI18nConfig().getLocaleCookieName();\n}\n\nfunction getRegionStoreKey(): string {\n return getI18nConfig().getRegionCookieName();\n}\n\nfunction getEnableI18nStoreKey(): string {\n return getI18nConfig().getEnableI18nCookieName();\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,uBAAb,MAA6E;CAC3E;CAEA,YAAY,QAAoC;AAC9C,OAAK,eAAe,OAAO,kBAAkB,KAAA;AAE7C,OAAK,aAAa,OAAO,UAAU,WAAW,CAAC;EAC/C,MAAM,SAAS,iBAAiB,EAC9B,QAAQ,OAAO,QAChB,CAAC;AACF,MAAI,WAAW,KAAA,EACb,MAAK,aAAa,OAAO;AAE3B,OAAK,iBACH,qBAAqB,EACnB,YAAY,OAAO,YACpB,CAAC,CACH;;CAGH,kBAA0B;AACxB,SAAO,WAAW;;CAGpB,aAAa,WAAmC;EAC9C,MAAM,aAAa,cAAc,OAAO;AACxC,iBAAe,mBAAmB,EAAE,WAAW;AAC/C,OAAK,OAAO,EAAE,QAAQ,YAAY,CAAC;;CAGrC,kBAAsC;AACpC,SAAO,eAAe,mBAAmB,CAAC,IAAI,KAAA;;CAGhD,aAAa,WAAqC;AAChD,OAAK,aAAa,OAAO;AACzB,OAAK,OAAO,EAAE,QAAQ,CAAC;;CAGzB,sBAA+B;AAC7B,SAAO,eAAe,uBAAuB,CAAC,KAAK;;CAGrD,iBAAiB,eAA8B;AAC7C,OAAK,iBAAiB,WAAW;AACjC,OAAK,OAAO,EAAE,YAAY,CAAC;;CAG7B,gBAAgB,WAAmC;AACjD,iBAAe,mBAAmB,EAAE,cAAc,OAAO,CAAC;;CAG5D,gBAAgB,WAAqC;AACnD,iBAAe,mBAAmB,EAAE,UAAU,GAAG;;CAGnD,oBAAoB,eAA8B;AAChD,iBAAe,uBAAuB,EAAE,aAAa,SAAS,QAAQ;;CAGxE,UAAU,QAA4C,EAAE,KAAW;AACjE,OAAK,aAAa;GAChB,QAAQ,MAAM,UAAU,KAAK,WAAW;GACxC,QAAQ,YAAY,QAAQ,MAAM,SAAS,KAAK,WAAW;GAC3D,YAAY,MAAM,cAAc,KAAK,eAAe;GACrD,CAAC;;;AAIN,SAAS,oBAA4B;AACnC,QAAO,eAAe,CAAC,qBAAqB;;AAG9C,SAAS,oBAA4B;AACnC,QAAO,eAAe,CAAC,qBAAqB;;AAG9C,SAAS,wBAAgC;AACvC,QAAO,eAAe,CAAC,yBAAyB"}
@@ -1,16 +1,8 @@
1
- import type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';
2
- export declare function useLocaleSelector(locales?: string[]): {
3
- locale: string;
4
- locales: string[];
5
- getLocaleProperties: (locale: string) => import("generaltranslation/internal").LocaleProperties;
1
+ import type { InternalLocaleSelectorResult, InternalRegionSelectorOptions, InternalRegionSelectorResult } from '@generaltranslation/react-core/hooks';
2
+ export declare function useLocaleSelector(locales?: string[]): InternalLocaleSelectorResult & {
6
3
  setLocale: (locale: string) => void;
7
4
  };
8
- export declare function useRegionSelector(options?: InternalRegionSelectorOptions): {
9
- region: string | undefined;
10
- regions: string[];
11
- regionData: Map<string, import("@generaltranslation/react-core/hooks").RegionData>;
12
- locale: string;
13
- localeRegion: string;
5
+ export declare function useRegionSelector(options?: InternalRegionSelectorOptions): InternalRegionSelectorResult & {
14
6
  setLocale: (locale: string) => void;
15
7
  setRegion: (region: string | undefined) => void;
16
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/hooks/selectors.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAE1F,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE;;;;;EAGnD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,6BAA6B;;;;;;;;EAIxE"}
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/hooks/selectors.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,sCAAsC,CAAC;AAK9C,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,4BAA4B,GAAG;IAAE,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAGxE;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,6BAA6B,GACtC,4BAA4B,GAAG;IAChC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACjD,CAIA"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","names":[],"sources":["../../../src/hooks/selectors.ts"],"sourcesContent":["import { useSetLocale, useSetRegion } from './condition-store';\nimport {\n useInternalLocaleSelector,\n useInternalRegionSelector,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setLocale = useSetLocale();\n const setRegion = useSetRegion();\n return { setLocale, setRegion, ...useInternalRegionSelector(options) };\n}\n"],"mappings":";;;AAOA,SAAgB,kBAAkB,SAAoB;AAEpD,QAAO;EAAE,WADS,cACA;EAAE,GAAG,0BAA0B,QAAQ;EAAE;;AAG7D,SAAgB,kBAAkB,SAAyC;AAGzE,QAAO;EAAE,WAFS,cAEA;EAAE,WADF,cACW;EAAE,GAAG,0BAA0B,QAAQ;EAAE"}
1
+ {"version":3,"file":"selectors.js","names":[],"sources":["../../../src/hooks/selectors.ts"],"sourcesContent":["import { useSetLocale, useSetRegion } from './condition-store';\nimport {\n useInternalLocaleSelector,\n useInternalRegionSelector,\n} from '@generaltranslation/react-core/hooks';\nimport type {\n InternalLocaleSelectorResult,\n InternalRegionSelectorOptions,\n InternalRegionSelectorResult,\n} from '@generaltranslation/react-core/hooks';\n\n// Explicit return types are required: project references make TypeScript try to\n// name the inferred selector types, which otherwise reach into\n// generaltranslation's non-portable bundled declarations (TS2742).\nexport function useLocaleSelector(\n locales?: string[]\n): InternalLocaleSelectorResult & { setLocale: (locale: string) => void } {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n\nexport function useRegionSelector(\n options?: InternalRegionSelectorOptions\n): InternalRegionSelectorResult & {\n setLocale: (locale: string) => void;\n setRegion: (region: string | undefined) => void;\n} {\n const setLocale = useSetLocale();\n const setRegion = useSetRegion();\n return { setLocale, setRegion, ...useInternalRegionSelector(options) };\n}\n"],"mappings":";;;AAcA,SAAgB,kBACd,SACwE;AAExE,QAAO;EAAE,WADS,cACA;EAAE,GAAG,0BAA0B,QAAQ;EAAE;;AAG7D,SAAgB,kBACd,SAIA;AAGA,QAAO;EAAE,WAFS,cAEA;EAAE,WADF,cACW;EAAE,GAAG,0BAA0B,QAAQ;EAAE"}
@@ -1,10 +1,9 @@
1
1
  export { Branch, Currency, DateTime, Derive, Num, Plural, RelativeTime, T, Var, } from '@generaltranslation/react-core/components';
2
2
  export { GTProvider } from './provider/GTProvider';
3
- export { useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useLocale, useLocaleProperties, useLocales, useMessages, useRegion, useTranslations, } from '@generaltranslation/react-core/hooks';
3
+ export { useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useTranslations, } from '@generaltranslation/react-core/hooks';
4
4
  export { useSetLocale, useSetRegion, useSetEnableI18n, } from './hooks/condition-store';
5
5
  export { useLocaleSelector, useRegionSelector } from './hooks/selectors';
6
- export { useLocaleDirection, useVersionId } from './hooks/utils';
7
- export { createRenderPipeline, decodeMsg, decodeOptions, decodeVars, declareVar, derive, getFormatLocales, getReactI18nCache, getTranslationsSnapshot, gtFallback, mFallback, msg, setReactI18nCache, } from '@generaltranslation/react-core/pure';
6
+ export { createRenderPipeline, decodeMsg, decodeOptions, decodeVars, declareVar, derive, getDefaultLocale, getFormatLocales, getLocales, resolveCanonicalLocale, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, mFallback, msg, setReactI18nCache, } from '@generaltranslation/react-core/pure';
8
7
  export { getLocaleFromNativeStore } from './utils/nativeStore';
9
8
  export { getLocale } from './utils/getLocale';
10
9
  export { initializeGT } from './setup/initializeGT';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,GAAG,EACH,MAAM,EACN,YAAY,EACZ,CAAC,EACD,GAAG,GACJ,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,SAAS,EACT,GAAG,EACH,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,EACd,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,GAAG,EACH,MAAM,EACN,YAAY,EACZ,CAAC,EACD,GAAG,GACJ,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,GAAG,EACH,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,EACd,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -3,9 +3,8 @@ import { getLocale } from "./utils/getLocale.js";
3
3
  import { GTProvider } from "./provider/GTProvider.js";
4
4
  import { useSetEnableI18n, useSetLocale, useSetRegion } from "./hooks/condition-store.js";
5
5
  import { useLocaleSelector, useRegionSelector } from "./hooks/selectors.js";
6
- import { useLocaleDirection, useVersionId } from "./hooks/utils.js";
7
6
  import { initializeGT } from "./setup/initializeGT.js";
8
7
  import { Branch, Currency, DateTime, Derive, Num, Plural, RelativeTime, T, Var } from "@generaltranslation/react-core/components";
9
- import { createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getFormatLocales, getReactI18nCache, getTranslationsSnapshot, gtFallback, mFallback, msg, setReactI18nCache } from "@generaltranslation/react-core/pure";
10
- import { useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useLocale, useLocaleProperties, useLocales, useMessages, useRegion, useTranslations } from "@generaltranslation/react-core/hooks";
11
- export { Branch, Currency, DateTime, Derive, GTProvider, Num, Plural, RelativeTime, T, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getFormatLocales, getLocale, getLocaleFromNativeStore, getReactI18nCache, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, setReactI18nCache, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations, useVersionId };
8
+ import { createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, mFallback, msg, resolveCanonicalLocale, setReactI18nCache } from "@generaltranslation/react-core/pure";
9
+ import { useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useTranslations } from "@generaltranslation/react-core/hooks";
10
+ export { Branch, Currency, DateTime, Derive, GTProvider, Num, Plural, RelativeTime, T, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocale, getLocaleFromNativeStore, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGT, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
@@ -5,7 +5,7 @@ import type { NativeConditionStoreParams } from '../condition-store/NativeCondit
5
5
  export type GTProviderProps = Omit<InternalGTProviderProps, 'conditionStore' | 'i18nStore' | 'translations'> & Omit<NativeConditionStoreParams, 'locale' | '_reload'> & {
6
6
  children?: ReactNode;
7
7
  locale?: LocaleCandidates;
8
- loadingFallback?: ReactNode;
8
+ fallback?: ReactNode;
9
9
  };
10
10
  export declare function GTProvider(props: GTProviderProps): import("react/jsx-runtime").JSX.Element;
11
11
  //# sourceMappingURL=GTProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAU,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,yCAAyC,CAAC;AAUjD,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,uBAAuB,EACvB,gBAAgB,GAAG,WAAW,GAAG,cAAc,CAChD,GACC,IAAI,CAAC,0BAA0B,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG;IACvD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAKJ,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAQhD"}
1
+ {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAU,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,yCAAyC,CAAC;AAajD,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,uBAAuB,EACvB,gBAAgB,GAAG,WAAW,GAAG,cAAc,CAChD,GACC,IAAI,CAAC,0BAA0B,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG;IACvD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAKJ,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAEhD"}
@@ -8,34 +8,25 @@ import { Suspense, use, useCallback, useMemo, useState } from "react";
8
8
  import { jsx } from "react/jsx-runtime";
9
9
  //#region src/provider/GTProvider.tsx
10
10
  function GTProvider(props) {
11
- const { loadingFallback, ...providerProps } = props;
12
- return /* @__PURE__ */ jsx(Suspense, {
13
- fallback: loadingFallback ?? /* @__PURE__ */ jsx(DefaultLoadingFallback, {}),
14
- children: /* @__PURE__ */ jsx(LoadableGTProvider, { ...providerProps })
15
- });
11
+ return /* @__PURE__ */ jsx(LoadableGTProvider, { ...props });
16
12
  }
17
13
  /**
18
14
  * This wrapper takes the place of a loader that would be present in
19
15
  * SSR style applications.
20
16
  */
21
17
  function LoadableGTProvider(props) {
22
- const { locale, localeStoreKey, region, regionStoreKey, enableI18n, enableI18nStoreKey } = props;
18
+ const { fallback, ...providerProps } = props;
19
+ const renderedFallback = fallback ?? /* @__PURE__ */ jsx(DefaultLoadingFallback, {});
20
+ const { locale, region, enableI18n } = providerProps;
23
21
  const [nativeConditions, setNativeConditions] = useState(() => ({
24
- locale: getLocale({ localeStoreKey }),
25
- region: getInitialRegion({
26
- region,
27
- regionStoreKey
28
- }),
29
- enableI18n: getInitialEnableI18n({
30
- enableI18n,
31
- enableI18nStoreKey
32
- })
22
+ locale: getLocale(),
23
+ region: getInitialRegion({ region }),
24
+ enableI18n: getInitialEnableI18n({ enableI18n })
33
25
  }));
34
26
  const activeLocale = resolveLocale(locale ?? nativeConditions.locale);
35
27
  const activeRegion = region ?? nativeConditions.region;
36
28
  const activeEnableI18n = enableI18n ?? nativeConditions.enableI18n;
37
- const localeTranslations = use(loadTranslations(activeLocale));
38
- const translations = useMemo(() => ({ [activeLocale]: localeTranslations }), [activeLocale, localeTranslations]);
29
+ const fallbackTranslations = useMemo(() => ({ [activeLocale]: {} }), [activeLocale]);
39
30
  const reload = useCallback((state) => {
40
31
  setNativeConditions((previousState) => ({
41
32
  locale: locale === void 0 ? state.locale : previousState.locale,
@@ -47,13 +38,33 @@ function LoadableGTProvider(props) {
47
38
  locale,
48
39
  region
49
40
  ]);
41
+ return /* @__PURE__ */ jsx(Suspense, {
42
+ fallback: /* @__PURE__ */ jsx(NativeGTProvider, {
43
+ ...providerProps,
44
+ locale: activeLocale,
45
+ region: activeRegion,
46
+ enableI18n: activeEnableI18n,
47
+ translations: fallbackTranslations,
48
+ _reload: reload,
49
+ children: renderedFallback
50
+ }),
51
+ children: /* @__PURE__ */ jsx(LoadedGTProvider, {
52
+ ...providerProps,
53
+ locale: activeLocale,
54
+ region: activeRegion,
55
+ enableI18n: activeEnableI18n,
56
+ _reload: reload
57
+ })
58
+ });
59
+ }
60
+ function LoadedGTProvider(props) {
61
+ const activeLocale = resolveLocale(props.locale);
62
+ const localeTranslations = use(loadTranslations(activeLocale));
63
+ const translations = useMemo(() => ({ [activeLocale]: localeTranslations }), [activeLocale, localeTranslations]);
50
64
  return /* @__PURE__ */ jsx(NativeGTProvider, {
51
65
  ...props,
52
66
  locale: activeLocale,
53
- region: activeRegion,
54
- enableI18n: activeEnableI18n,
55
- translations,
56
- _reload: reload
67
+ translations
57
68
  });
58
69
  }
59
70
  function DefaultLoadingFallback() {
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.js","names":[],"sources":["../../../src/provider/GTProvider.tsx"],"sourcesContent":["import type { InternalGTProviderProps } from '@generaltranslation/react-core/components';\nimport { Suspense, use, useCallback, useMemo, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { ActivityIndicator, StyleSheet, View } from 'react-native';\nimport type { LocaleCandidates, Locale } from 'gt-i18n/internal/types';\nimport type {\n NativeConditionStoreParams,\n NativeConditionStoreState,\n} from '../condition-store/NativeConditionStore';\nimport { getLocale } from '../utils/getLocale';\nimport {\n getInitialEnableI18n,\n getInitialRegion,\n} from '../utils/getInitialNativeConditions';\nimport { resolveLocale } from '../utils/resolveLocale';\nimport { loadTranslations, type LocaleTranslations } from './loadTranslations';\nimport { NativeGTProvider } from './NativeGTProvider';\n\nexport type GTProviderProps = Omit<\n InternalGTProviderProps,\n 'conditionStore' | 'i18nStore' | 'translations'\n> &\n Omit<NativeConditionStoreParams, 'locale' | '_reload'> & {\n children?: ReactNode;\n locale?: LocaleCandidates;\n loadingFallback?: ReactNode;\n };\n\ntype LoadableGTProviderProps = Omit<GTProviderProps, 'loadingFallback'>;\ntype TranslationSnapshot = Record<Locale, LocaleTranslations>;\n\nexport function GTProvider(props: GTProviderProps) {\n const { loadingFallback, ...providerProps } = props;\n\n return (\n <Suspense fallback={loadingFallback ?? <DefaultLoadingFallback />}>\n <LoadableGTProvider {...providerProps} />\n </Suspense>\n );\n}\n\n/**\n * This wrapper takes the place of a loader that would be present in\n * SSR style applications.\n */\nfunction LoadableGTProvider(props: LoadableGTProviderProps) {\n const {\n locale,\n localeStoreKey,\n region,\n regionStoreKey,\n enableI18n,\n enableI18nStoreKey,\n } = props;\n // Keep native conditions in React state so condition-store writes trigger rerenders.\n const [nativeConditions, setNativeConditions] =\n useState<NativeConditionStoreState>(() => ({\n locale: getLocale({ localeStoreKey }),\n region: getInitialRegion({ region, regionStoreKey }),\n enableI18n: getInitialEnableI18n({ enableI18n, enableI18nStoreKey }),\n }));\n const activeLocale = resolveLocale(locale ?? nativeConditions.locale);\n const activeRegion = region ?? nativeConditions.region;\n const activeEnableI18n = enableI18n ?? nativeConditions.enableI18n;\n const localeTranslations = use(loadTranslations(activeLocale));\n const translations = useMemo<TranslationSnapshot>(\n () => ({ [activeLocale]: localeTranslations }),\n [activeLocale, localeTranslations]\n );\n const reload = useCallback(\n (state: NativeConditionStoreState) => {\n setNativeConditions((previousState) => ({\n locale: locale === undefined ? state.locale : previousState.locale,\n region: region === undefined ? state.region : previousState.region,\n enableI18n:\n enableI18n === undefined\n ? state.enableI18n\n : previousState.enableI18n,\n }));\n },\n [enableI18n, locale, region]\n );\n\n return (\n <NativeGTProvider\n {...props}\n locale={activeLocale}\n region={activeRegion}\n enableI18n={activeEnableI18n}\n translations={translations}\n _reload={reload}\n />\n );\n}\n\nfunction DefaultLoadingFallback() {\n return (\n <View style={styles.loadingContainer}>\n <ActivityIndicator />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n loadingContainer: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,iBAAiB,GAAG,kBAAkB;AAE9C,QACE,oBAAC,UAAD;EAAU,UAAU,mBAAmB,oBAAC,wBAAD,EAA0B,CAAA;YAC/D,oBAAC,oBAAD,EAAoB,GAAI,eAAiB,CAAA;EAChC,CAAA;;;;;;AAQf,SAAS,mBAAmB,OAAgC;CAC1D,MAAM,EACJ,QACA,gBACA,QACA,gBACA,YACA,uBACE;CAEJ,MAAM,CAAC,kBAAkB,uBACvB,gBAA2C;EACzC,QAAQ,UAAU,EAAE,gBAAgB,CAAC;EACrC,QAAQ,iBAAiB;GAAE;GAAQ;GAAgB,CAAC;EACpD,YAAY,qBAAqB;GAAE;GAAY;GAAoB,CAAC;EACrE,EAAE;CACL,MAAM,eAAe,cAAc,UAAU,iBAAiB,OAAO;CACrE,MAAM,eAAe,UAAU,iBAAiB;CAChD,MAAM,mBAAmB,cAAc,iBAAiB;CACxD,MAAM,qBAAqB,IAAI,iBAAiB,aAAa,CAAC;CAC9D,MAAM,eAAe,eACZ,GAAG,eAAe,oBAAoB,GAC7C,CAAC,cAAc,mBAAmB,CACnC;CACD,MAAM,SAAS,aACZ,UAAqC;AACpC,uBAAqB,mBAAmB;GACtC,QAAQ,WAAW,KAAA,IAAY,MAAM,SAAS,cAAc;GAC5D,QAAQ,WAAW,KAAA,IAAY,MAAM,SAAS,cAAc;GAC5D,YACE,eAAe,KAAA,IACX,MAAM,aACN,cAAc;GACrB,EAAE;IAEL;EAAC;EAAY;EAAQ;EAAO,CAC7B;AAED,QACE,oBAAC,kBAAD;EACE,GAAI;EACJ,QAAQ;EACR,QAAQ;EACR,YAAY;EACE;EACd,SAAS;EACT,CAAA;;AAIN,SAAS,yBAAyB;AAChC,QACE,oBAAC,MAAD;EAAM,OAAO,OAAO;YAClB,oBAAC,mBAAD,EAAqB,CAAA;EAChB,CAAA;;AAIX,MAAM,SAAS,WAAW,OAAO,EAC/B,kBAAkB;CAChB,MAAM;CACN,YAAY;CACZ,gBAAgB;CACjB,EACF,CAAC"}
1
+ {"version":3,"file":"GTProvider.js","names":[],"sources":["../../../src/provider/GTProvider.tsx"],"sourcesContent":["import type { InternalGTProviderProps } from '@generaltranslation/react-core/components';\nimport { Suspense, use, useCallback, useMemo, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { ActivityIndicator, StyleSheet, View } from 'react-native';\nimport type { LocaleCandidates, Locale } from 'gt-i18n/internal/types';\nimport type {\n NativeConditionStoreParams,\n NativeConditionStoreState,\n} from '../condition-store/NativeConditionStore';\nimport { getLocale } from '../utils/getLocale';\nimport {\n getInitialEnableI18n,\n getInitialRegion,\n} from '../utils/getInitialNativeConditions';\nimport { resolveLocale } from '../utils/resolveLocale';\nimport { loadTranslations, type LocaleTranslations } from './loadTranslations';\nimport {\n NativeGTProvider,\n type NativeGTProviderProps,\n} from './NativeGTProvider';\n\nexport type GTProviderProps = Omit<\n InternalGTProviderProps,\n 'conditionStore' | 'i18nStore' | 'translations'\n> &\n Omit<NativeConditionStoreParams, 'locale' | '_reload'> & {\n children?: ReactNode;\n locale?: LocaleCandidates;\n fallback?: ReactNode;\n };\n\ntype LoadedGTProviderProps = Omit<NativeGTProviderProps, 'translations'>;\ntype TranslationSnapshot = Record<Locale, LocaleTranslations>;\n\nexport function GTProvider(props: GTProviderProps) {\n return <LoadableGTProvider {...props} />;\n}\n\n/**\n * This wrapper takes the place of a loader that would be present in\n * SSR style applications.\n */\nfunction LoadableGTProvider(props: GTProviderProps) {\n const { fallback, ...providerProps } = props;\n const renderedFallback = fallback ?? <DefaultLoadingFallback />;\n const { locale, region, enableI18n } = providerProps;\n // Keep native conditions in React state so condition-store writes trigger rerenders.\n const [nativeConditions, setNativeConditions] =\n useState<NativeConditionStoreState>(() => ({\n locale: getLocale(),\n region: getInitialRegion({ region }),\n enableI18n: getInitialEnableI18n({ enableI18n }),\n }));\n const activeLocale = resolveLocale(locale ?? nativeConditions.locale);\n const activeRegion = region ?? nativeConditions.region;\n const activeEnableI18n = enableI18n ?? nativeConditions.enableI18n;\n const fallbackTranslations = useMemo<TranslationSnapshot>(\n () => ({ [activeLocale]: {} }),\n [activeLocale]\n );\n const reload = useCallback(\n (state: NativeConditionStoreState) => {\n setNativeConditions((previousState) => ({\n locale: locale === undefined ? state.locale : previousState.locale,\n region: region === undefined ? state.region : previousState.region,\n enableI18n:\n enableI18n === undefined\n ? state.enableI18n\n : previousState.enableI18n,\n }));\n },\n [enableI18n, locale, region]\n );\n\n return (\n <Suspense\n fallback={\n <NativeGTProvider\n {...providerProps}\n locale={activeLocale}\n region={activeRegion}\n enableI18n={activeEnableI18n}\n translations={fallbackTranslations}\n _reload={reload}\n >\n {renderedFallback}\n </NativeGTProvider>\n }\n >\n <LoadedGTProvider\n {...providerProps}\n locale={activeLocale}\n region={activeRegion}\n enableI18n={activeEnableI18n}\n _reload={reload}\n />\n </Suspense>\n );\n}\n\nfunction LoadedGTProvider(props: LoadedGTProviderProps) {\n const activeLocale = resolveLocale(props.locale);\n const localeTranslations = use(loadTranslations(activeLocale));\n const translations = useMemo<TranslationSnapshot>(\n () => ({ [activeLocale]: localeTranslations }),\n [activeLocale, localeTranslations]\n );\n\n return (\n <NativeGTProvider\n {...props}\n locale={activeLocale}\n translations={translations}\n />\n );\n}\n\nfunction DefaultLoadingFallback() {\n return (\n <View style={styles.loadingContainer}>\n <ActivityIndicator />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n loadingContainer: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,WAAW,OAAwB;AACjD,QAAO,oBAAC,oBAAD,EAAoB,GAAI,OAAS,CAAA;;;;;;AAO1C,SAAS,mBAAmB,OAAwB;CAClD,MAAM,EAAE,UAAU,GAAG,kBAAkB;CACvC,MAAM,mBAAmB,YAAY,oBAAC,wBAAD,EAA0B,CAAA;CAC/D,MAAM,EAAE,QAAQ,QAAQ,eAAe;CAEvC,MAAM,CAAC,kBAAkB,uBACvB,gBAA2C;EACzC,QAAQ,WAAW;EACnB,QAAQ,iBAAiB,EAAE,QAAQ,CAAC;EACpC,YAAY,qBAAqB,EAAE,YAAY,CAAC;EACjD,EAAE;CACL,MAAM,eAAe,cAAc,UAAU,iBAAiB,OAAO;CACrE,MAAM,eAAe,UAAU,iBAAiB;CAChD,MAAM,mBAAmB,cAAc,iBAAiB;CACxD,MAAM,uBAAuB,eACpB,GAAG,eAAe,EAAE,EAAE,GAC7B,CAAC,aAAa,CACf;CACD,MAAM,SAAS,aACZ,UAAqC;AACpC,uBAAqB,mBAAmB;GACtC,QAAQ,WAAW,KAAA,IAAY,MAAM,SAAS,cAAc;GAC5D,QAAQ,WAAW,KAAA,IAAY,MAAM,SAAS,cAAc;GAC5D,YACE,eAAe,KAAA,IACX,MAAM,aACN,cAAc;GACrB,EAAE;IAEL;EAAC;EAAY;EAAQ;EAAO,CAC7B;AAED,QACE,oBAAC,UAAD;EACE,UACE,oBAAC,kBAAD;GACE,GAAI;GACJ,QAAQ;GACR,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,SAAS;aAER;GACgB,CAAA;YAGrB,oBAAC,kBAAD;GACE,GAAI;GACJ,QAAQ;GACR,QAAQ;GACR,YAAY;GACZ,SAAS;GACT,CAAA;EACO,CAAA;;AAIf,SAAS,iBAAiB,OAA8B;CACtD,MAAM,eAAe,cAAc,MAAM,OAAO;CAChD,MAAM,qBAAqB,IAAI,iBAAiB,aAAa,CAAC;CAC9D,MAAM,eAAe,eACZ,GAAG,eAAe,oBAAoB,GAC7C,CAAC,cAAc,mBAAmB,CACnC;AAED,QACE,oBAAC,kBAAD;EACE,GAAI;EACJ,QAAQ;EACM;EACd,CAAA;;AAIN,SAAS,yBAAyB;AAChC,QACE,oBAAC,MAAD;EAAM,OAAO,OAAO;YAClB,oBAAC,mBAAD,EAAqB,CAAA;EAChB,CAAA;;AAIX,MAAM,SAAS,WAAW,OAAO,EAC/B,kBAAkB;CAChB,MAAM;CACN,YAAY;CACZ,gBAAgB;CACjB,EACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"NativeGTProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/NativeGTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAG1F,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,uBAAuB,EACvB,gBAAgB,GAAG,WAAW,CAC/B,GACC,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,GAAG;IAC3C,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,2CAyB5D"}
1
+ {"version":3,"file":"NativeGTProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/NativeGTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAG1F,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,uBAAuB,EACvB,gBAAgB,GAAG,WAAW,CAC/B,GACC,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,GAAG;IAC3C,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,2CAiB5D"}
@@ -10,9 +10,6 @@ function NativeGTProvider(props) {
10
10
  props.locale,
11
11
  props.region,
12
12
  props.enableI18n,
13
- props.localeStoreKey,
14
- props.regionStoreKey,
15
- props.enableI18nStoreKey,
16
13
  props._reload
17
14
  ]);
18
15
  const i18nStoreRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"NativeGTProvider.js","names":[],"sources":["../../../src/provider/NativeGTProvider.tsx"],"sourcesContent":["import {\n I18nStore,\n InternalGTProvider,\n type InternalGTProviderProps,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { LocaleCandidates } from 'gt-i18n/internal/types';\nimport type { NativeConditionStoreParams } from '../condition-store/NativeConditionStore';\nimport { NativeConditionStore } from '../condition-store/NativeConditionStore';\n\nexport type NativeGTProviderProps = Omit<\n InternalGTProviderProps,\n 'conditionStore' | 'i18nStore'\n> &\n Omit<NativeConditionStoreParams, 'locale'> & {\n locale: LocaleCandidates;\n };\n\nexport function NativeGTProvider(props: NativeGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new NativeConditionStore(props);\n }, [\n props.locale,\n props.region,\n props.enableI18n,\n props.localeStoreKey,\n props.regionStoreKey,\n props.enableI18nStoreKey,\n props._reload,\n ]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n"],"mappings":";;;;;AAkBA,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,iBAAiB,cAAc;AACnC,SAAO,IAAI,qBAAqB,MAAM;IACrC;EACD,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACP,CAAC;CAEF,MAAM,eAAe,OAAyB,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAI,WAAW;AAGxC,QACE,oBAAC,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA"}
1
+ {"version":3,"file":"NativeGTProvider.js","names":[],"sources":["../../../src/provider/NativeGTProvider.tsx"],"sourcesContent":["import {\n I18nStore,\n InternalGTProvider,\n type InternalGTProviderProps,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { LocaleCandidates } from 'gt-i18n/internal/types';\nimport type { NativeConditionStoreParams } from '../condition-store/NativeConditionStore';\nimport { NativeConditionStore } from '../condition-store/NativeConditionStore';\n\nexport type NativeGTProviderProps = Omit<\n InternalGTProviderProps,\n 'conditionStore' | 'i18nStore'\n> &\n Omit<NativeConditionStoreParams, 'locale'> & {\n locale: LocaleCandidates;\n };\n\nexport function NativeGTProvider(props: NativeGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new NativeConditionStore(props);\n }, [props.locale, props.region, props.enableI18n, props._reload]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n"],"mappings":";;;;;AAkBA,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,iBAAiB,cAAc;AACnC,SAAO,IAAI,qBAAqB,MAAM;IACrC;EAAC,MAAM;EAAQ,MAAM;EAAQ,MAAM;EAAY,MAAM;EAAQ,CAAC;CAEjE,MAAM,eAAe,OAAyB,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAI,WAAW;AAGxC,QACE,oBAAC,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA"}
@@ -1,5 +1,4 @@
1
- import type { ReactI18nCacheParams } from '@generaltranslation/react-core/pure';
2
- import type { GTServicesEnabledParams, I18nConfigParams } from 'gt-i18n/internal/types';
3
- export type InitializeGTParams = I18nConfigParams & GTServicesEnabledParams & ReactI18nCacheParams;
4
- export declare function initializeGT(config: InitializeGTParams): void;
1
+ import type { I18nConfigParams, ReactI18nCacheParams } from '@generaltranslation/react-core/pure';
2
+ export type InitializeGTParams = I18nConfigParams & ReactI18nCacheParams;
3
+ export { internalInitializeGTSRA as initializeGT } from '@generaltranslation/react-core/pure';
5
4
  //# sourceMappingURL=initializeGT.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initializeGT.d.ts","sourceRoot":"","sources":["../../../src/setup/initializeGT.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAC/C,uBAAuB,GACvB,oBAAoB,CAAC;AAEvB,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAM7D"}
1
+ {"version":3,"file":"initializeGT.d.ts","sourceRoot":"","sources":["../../../src/setup/initializeGT.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAKzE,OAAO,EAAE,uBAAuB,IAAI,YAAY,EAAE,MAAM,qCAAqC,CAAC"}
@@ -1,12 +1,2 @@
1
- import { ReactI18nCache, initializeI18nConfig, setReactI18nCache } from "@generaltranslation/react-core/pure";
2
- import { setupGTServicesEnabled } from "gt-i18n/internal";
3
- //#region src/setup/initializeGT.ts
4
- function initializeGT(config) {
5
- setupGTServicesEnabled(config);
6
- initializeI18nConfig(config, "server-render");
7
- setReactI18nCache(new ReactI18nCache(config));
8
- }
9
- //#endregion
1
+ import { internalInitializeGTSRA as initializeGT } from "@generaltranslation/react-core/pure";
10
2
  export { initializeGT };
11
-
12
- //# sourceMappingURL=initializeGT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInitialNativeConditions.d.ts","sourceRoot":"","sources":["../../../src/utils/getInitialNativeConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAO3E,KAAK,mBAAmB,GAAG,IAAI,CAAC,4BAA4B,EAAE,QAAQ,CAAC,GAAG;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,uBAAuB,GAAG,IAAI,CACjC,4BAA4B,EAC5B,YAAY,CACb,GAAG;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,cAAsC,GACvC,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAG1C;AAED,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,kBAA8C,GAC/C,EAAE,uBAAuB,GAAG,OAAO,CAKnC"}
1
+ {"version":3,"file":"getInitialNativeConditions.d.ts","sourceRoot":"","sources":["../../../src/utils/getInitialNativeConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAI3E,KAAK,mBAAmB,GAAG,IAAI,CAAC,4BAA4B,EAAE,QAAQ,CAAC,GAAG;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,uBAAuB,GAAG,IAAI,CACjC,4BAA4B,EAC5B,YAAY,CACb,GAAG;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,cAAsD,GACvD,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAG1C;AAED,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,kBAA8D,GAC/D,EAAE,uBAAuB,GAAG,OAAO,CAKnC"}
@@ -1,11 +1,11 @@
1
1
  import { nativeStoreGet } from "./nativeStore.js";
2
- import { defaultEnableI18nCookieName, defaultRegionCookieName } from "@generaltranslation/react-core/pure";
2
+ import { getI18nConfig } from "@generaltranslation/react-core/pure";
3
3
  //#region src/utils/getInitialNativeConditions.ts
4
- function getInitialRegion({ region, regionStoreKey = defaultRegionCookieName }) {
4
+ function getInitialRegion({ region, regionStoreKey = getI18nConfig().getRegionCookieName() }) {
5
5
  if (region !== void 0) return region;
6
6
  return nativeStoreGet(regionStoreKey) || void 0;
7
7
  }
8
- function getInitialEnableI18n({ enableI18n, enableI18nStoreKey = defaultEnableI18nCookieName }) {
8
+ function getInitialEnableI18n({ enableI18n, enableI18nStoreKey = getI18nConfig().getEnableI18nCookieName() }) {
9
9
  if (enableI18n !== void 0) return enableI18n;
10
10
  const storedEnableI18n = nativeStoreGet(enableI18nStoreKey);
11
11
  if (storedEnableI18n === null) return true;
@@ -1 +1 @@
1
- {"version":3,"file":"getInitialNativeConditions.js","names":["defaultRegionStoreKey","defaultEnableI18nStoreKey"],"sources":["../../../src/utils/getInitialNativeConditions.ts"],"sourcesContent":["import type { WritableConditionStoreParams } from 'gt-i18n/internal/types';\nimport {\n defaultEnableI18nCookieName as defaultEnableI18nStoreKey,\n defaultRegionCookieName as defaultRegionStoreKey,\n} from '@generaltranslation/react-core/pure';\nimport { nativeStoreGet } from './nativeStore';\n\ntype InitialRegionParams = Pick<WritableConditionStoreParams, 'region'> & {\n regionStoreKey?: string;\n};\n\ntype InitialEnableI18nParams = Pick<\n WritableConditionStoreParams,\n 'enableI18n'\n> & {\n enableI18nStoreKey?: string;\n};\n\nexport function getInitialRegion({\n region,\n regionStoreKey = defaultRegionStoreKey,\n}: InitialRegionParams): string | undefined {\n if (region !== undefined) return region;\n return nativeStoreGet(regionStoreKey) || undefined;\n}\n\nexport function getInitialEnableI18n({\n enableI18n,\n enableI18nStoreKey = defaultEnableI18nStoreKey,\n}: InitialEnableI18nParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n const storedEnableI18n = nativeStoreGet(enableI18nStoreKey);\n if (storedEnableI18n === null) return true;\n return storedEnableI18n === 'true';\n}\n"],"mappings":";;;AAkBA,SAAgB,iBAAiB,EAC/B,QACA,iBAAiBA,2BACyB;AAC1C,KAAI,WAAW,KAAA,EAAW,QAAO;AACjC,QAAO,eAAe,eAAe,IAAI,KAAA;;AAG3C,SAAgB,qBAAqB,EACnC,YACA,qBAAqBC,+BACc;AACnC,KAAI,eAAe,KAAA,EAAW,QAAO;CACrC,MAAM,mBAAmB,eAAe,mBAAmB;AAC3D,KAAI,qBAAqB,KAAM,QAAO;AACtC,QAAO,qBAAqB"}
1
+ {"version":3,"file":"getInitialNativeConditions.js","names":[],"sources":["../../../src/utils/getInitialNativeConditions.ts"],"sourcesContent":["import type { WritableConditionStoreParams } from 'gt-i18n/internal/types';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { nativeStoreGet } from './nativeStore';\n\ntype InitialRegionParams = Pick<WritableConditionStoreParams, 'region'> & {\n regionStoreKey?: string;\n};\n\ntype InitialEnableI18nParams = Pick<\n WritableConditionStoreParams,\n 'enableI18n'\n> & {\n enableI18nStoreKey?: string;\n};\n\nexport function getInitialRegion({\n region,\n regionStoreKey = getI18nConfig().getRegionCookieName(),\n}: InitialRegionParams): string | undefined {\n if (region !== undefined) return region;\n return nativeStoreGet(regionStoreKey) || undefined;\n}\n\nexport function getInitialEnableI18n({\n enableI18n,\n enableI18nStoreKey = getI18nConfig().getEnableI18nCookieName(),\n}: InitialEnableI18nParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n const storedEnableI18n = nativeStoreGet(enableI18nStoreKey);\n if (storedEnableI18n === null) return true;\n return storedEnableI18n === 'true';\n}\n"],"mappings":";;;AAeA,SAAgB,iBAAiB,EAC/B,QACA,iBAAiB,eAAe,CAAC,qBAAqB,IACZ;AAC1C,KAAI,WAAW,KAAA,EAAW,QAAO;AACjC,QAAO,eAAe,eAAe,IAAI,KAAA;;AAG3C,SAAgB,qBAAqB,EACnC,YACA,qBAAqB,eAAe,CAAC,yBAAyB,IAC3B;AACnC,KAAI,eAAe,KAAA,EAAW,QAAO;CACrC,MAAM,mBAAmB,eAAe,mBAAmB;AAC3D,KAAI,qBAAqB,KAAM,QAAO;AACtC,QAAO,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../../src/utils/getLocale.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,cAAsC,GACvC,GAAE,eAAoB,GAAG,MAAM,CAM/B"}
1
+ {"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../../src/utils/getLocale.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,cAAsD,GACvD,GAAE,eAAoB,GAAG,MAAM,CAM/B"}
@@ -1,12 +1,12 @@
1
1
  import { getNativeLocales } from "./getNativeLocales.js";
2
2
  import { nativeStoreGet } from "./nativeStore.js";
3
3
  import { resolveLocale } from "./resolveLocale.js";
4
- import { defaultLocaleCookieName } from "@generaltranslation/react-core/pure";
4
+ import { getI18nConfig } from "@generaltranslation/react-core/pure";
5
5
  //#region src/utils/getLocale.ts
6
6
  /**
7
7
  * @internal
8
8
  */
9
- function getLocale({ localeStoreKey = defaultLocaleCookieName } = {}) {
9
+ function getLocale({ localeStoreKey = getI18nConfig().getLocaleCookieName() } = {}) {
10
10
  const candidates = [];
11
11
  pushLocaleCandidates(candidates, nativeStoreGet(localeStoreKey));
12
12
  candidates.push(...getNativeLocales());
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.js","names":["defaultLocaleStoreKey"],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import type { LocaleCandidates } from 'gt-i18n/internal/types';\nimport { defaultLocaleCookieName as defaultLocaleStoreKey } from '@generaltranslation/react-core/pure';\nimport { getNativeLocales } from './getNativeLocales';\nimport { nativeStoreGet } from './nativeStore';\nimport { resolveLocale } from './resolveLocale';\n\nexport type GetLocaleParams = {\n localeStoreKey?: string;\n};\n\n/**\n * @internal\n */\nexport function getLocale({\n localeStoreKey = defaultLocaleStoreKey,\n}: GetLocaleParams = {}): string {\n const candidates: string[] = [];\n pushLocaleCandidates(candidates, nativeStoreGet(localeStoreKey));\n candidates.push(...getNativeLocales());\n\n return resolveLocale(candidates);\n}\n\nfunction pushLocaleCandidates(\n target: string[],\n locale: LocaleCandidates | null\n) {\n if (!locale) return;\n if (Array.isArray(locale)) {\n target.push(...locale);\n return;\n }\n target.push(locale);\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,UAAU,EACxB,iBAAiBA,4BACE,EAAE,EAAU;CAC/B,MAAM,aAAuB,EAAE;AAC/B,sBAAqB,YAAY,eAAe,eAAe,CAAC;AAChE,YAAW,KAAK,GAAG,kBAAkB,CAAC;AAEtC,QAAO,cAAc,WAAW;;AAGlC,SAAS,qBACP,QACA,QACA;AACA,KAAI,CAAC,OAAQ;AACb,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,GAAG,OAAO;AACtB;;AAEF,QAAO,KAAK,OAAO"}
1
+ {"version":3,"file":"getLocale.js","names":[],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import type { LocaleCandidates } from 'gt-i18n/internal/types';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getNativeLocales } from './getNativeLocales';\nimport { nativeStoreGet } from './nativeStore';\nimport { resolveLocale } from './resolveLocale';\n\nexport type GetLocaleParams = {\n localeStoreKey?: string;\n};\n\n/**\n * @internal\n */\nexport function getLocale({\n localeStoreKey = getI18nConfig().getLocaleCookieName(),\n}: GetLocaleParams = {}): string {\n const candidates: string[] = [];\n pushLocaleCandidates(candidates, nativeStoreGet(localeStoreKey));\n candidates.push(...getNativeLocales());\n\n return resolveLocale(candidates);\n}\n\nfunction pushLocaleCandidates(\n target: string[],\n locale: LocaleCandidates | null\n) {\n if (!locale) return;\n if (Array.isArray(locale)) {\n target.push(...locale);\n return;\n }\n target.push(locale);\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,UAAU,EACxB,iBAAiB,eAAe,CAAC,qBAAqB,KACnC,EAAE,EAAU;CAC/B,MAAM,aAAuB,EAAE;AAC/B,sBAAqB,YAAY,eAAe,eAAe,CAAC;AAChE,YAAW,KAAK,GAAG,kBAAkB,CAAC;AAEtC,QAAO,cAAc,WAAW;;AAGlC,SAAS,qBACP,QACA,QACA;AACA,KAAI,CAAC,OAAQ;AACb,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,GAAG,OAAO;AACtB;;AAEF,QAAO,KAAK,OAAO"}
@@ -4,7 +4,7 @@
4
4
  * This reads persisted native storage directly, so it can temporarily be out of
5
5
  * sync with React state while a locale change is in progress.
6
6
  *
7
- * If GTProvider uses a custom localeStoreKey, pass that same value as the key.
7
+ * Defaults to the store key configured through initializeGT().
8
8
  *
9
9
  * @param key - The key to get the locale from
10
10
  * @returns The locale from the native store
@@ -1 +1 @@
1
- {"version":3,"file":"nativeStore.d.ts","sourceRoot":"","sources":["../../../src/utils/nativeStore.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,SAAwB,GAC1B,MAAM,GAAG,IAAI,CAEf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW/D"}
1
+ {"version":3,"file":"nativeStore.d.ts","sourceRoot":"","sources":["../../../src/utils/nativeStore.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,SAAwC,GAC1C,MAAM,GAAG,IAAI,CAEf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAW/D"}
@@ -1,7 +1,7 @@
1
1
  import { GtReactNative } from "../NativeGtReactNative.js";
2
2
  import { ssrUnsupportedWarning } from "../errors-dir/warnings.js";
3
3
  import { Platform } from "react-native";
4
- import { defaultLocaleCookieName } from "@generaltranslation/react-core/pure";
4
+ import { getI18nConfig } from "@generaltranslation/react-core/pure";
5
5
  //#region src/utils/nativeStore.ts
6
6
  /**
7
7
  * Get the locale from the native store.
@@ -9,12 +9,12 @@ import { defaultLocaleCookieName } from "@generaltranslation/react-core/pure";
9
9
  * This reads persisted native storage directly, so it can temporarily be out of
10
10
  * sync with React state while a locale change is in progress.
11
11
  *
12
- * If GTProvider uses a custom localeStoreKey, pass that same value as the key.
12
+ * Defaults to the store key configured through initializeGT().
13
13
  *
14
14
  * @param key - The key to get the locale from
15
15
  * @returns The locale from the native store
16
16
  */
17
- function getLocaleFromNativeStore(key = defaultLocaleCookieName) {
17
+ function getLocaleFromNativeStore(key = getI18nConfig().getLocaleCookieName()) {
18
18
  return nativeStoreGet(key);
19
19
  }
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nativeStore.js","names":["defaultLocaleStoreKey"],"sources":["../../../src/utils/nativeStore.ts"],"sourcesContent":["import { defaultLocaleCookieName as defaultLocaleStoreKey } from '@generaltranslation/react-core/pure';\nimport { Platform } from 'react-native';\nimport { GtReactNative } from '../NativeGtReactNative';\nimport { ssrUnsupportedWarning } from '../errors-dir/warnings';\n\n/**\n * Get the locale from the native store.\n *\n * This reads persisted native storage directly, so it can temporarily be out of\n * sync with React state while a locale change is in progress.\n *\n * If GTProvider uses a custom localeStoreKey, pass that same value as the key.\n *\n * @param key - The key to get the locale from\n * @returns The locale from the native store\n */\nexport function getLocaleFromNativeStore(\n key = defaultLocaleStoreKey\n): string | null {\n return nativeStoreGet(key);\n}\n\n/**\n * Get a value from the native store\n * @param key - The key to get the value for\n * @returns The value for the key\n */\nexport function nativeStoreGet(key: string): string | null {\n if (Platform.OS === 'web') {\n if (typeof localStorage === 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(ssrUnsupportedWarning);\n return null;\n }\n return localStorage.getItem(key);\n }\n return GtReactNative.nativeStoreGet(key);\n}\n\n/**\n * Set a value in the native store\n * @param key - The key to set the value for\n * @param value - The value to set\n */\nexport function nativeStoreSet(key: string, value: string): void {\n if (Platform.OS === 'web') {\n if (typeof localStorage === 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(ssrUnsupportedWarning);\n return;\n }\n localStorage.setItem(key, value);\n return;\n }\n GtReactNative.nativeStoreSet(key, value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,yBACd,MAAMA,yBACS;AACf,QAAO,eAAe,IAAI;;;;;;;AAQ5B,SAAgB,eAAe,KAA4B;AACzD,KAAI,SAAS,OAAO,OAAO;AACzB,MAAI,OAAO,iBAAiB,aAAa;AAEvC,WAAQ,KAAK,sBAAsB;AACnC,UAAO;;AAET,SAAO,aAAa,QAAQ,IAAI;;AAElC,QAAO,cAAc,eAAe,IAAI;;;;;;;AAQ1C,SAAgB,eAAe,KAAa,OAAqB;AAC/D,KAAI,SAAS,OAAO,OAAO;AACzB,MAAI,OAAO,iBAAiB,aAAa;AAEvC,WAAQ,KAAK,sBAAsB;AACnC;;AAEF,eAAa,QAAQ,KAAK,MAAM;AAChC;;AAEF,eAAc,eAAe,KAAK,MAAM"}
1
+ {"version":3,"file":"nativeStore.js","names":[],"sources":["../../../src/utils/nativeStore.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { GtReactNative } from '../NativeGtReactNative';\nimport { ssrUnsupportedWarning } from '../errors-dir/warnings';\n\n/**\n * Get the locale from the native store.\n *\n * This reads persisted native storage directly, so it can temporarily be out of\n * sync with React state while a locale change is in progress.\n *\n * Defaults to the store key configured through initializeGT().\n *\n * @param key - The key to get the locale from\n * @returns The locale from the native store\n */\nexport function getLocaleFromNativeStore(\n key = getI18nConfig().getLocaleCookieName()\n): string | null {\n return nativeStoreGet(key);\n}\n\n/**\n * Get a value from the native store\n * @param key - The key to get the value for\n * @returns The value for the key\n */\nexport function nativeStoreGet(key: string): string | null {\n if (Platform.OS === 'web') {\n if (typeof localStorage === 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(ssrUnsupportedWarning);\n return null;\n }\n return localStorage.getItem(key);\n }\n return GtReactNative.nativeStoreGet(key);\n}\n\n/**\n * Set a value in the native store\n * @param key - The key to set the value for\n * @param value - The value to set\n */\nexport function nativeStoreSet(key: string, value: string): void {\n if (Platform.OS === 'web') {\n if (typeof localStorage === 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(ssrUnsupportedWarning);\n return;\n }\n localStorage.setItem(key, value);\n return;\n }\n GtReactNative.nativeStoreSet(key, value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,yBACd,MAAM,eAAe,CAAC,qBAAqB,EAC5B;AACf,QAAO,eAAe,IAAI;;;;;;;AAQ5B,SAAgB,eAAe,KAA4B;AACzD,KAAI,SAAS,OAAO,OAAO;AACzB,MAAI,OAAO,iBAAiB,aAAa;AAEvC,WAAQ,KAAK,sBAAsB;AACnC,UAAO;;AAET,SAAO,aAAa,QAAQ,IAAI;;AAElC,QAAO,cAAc,eAAe,IAAI;;;;;;;AAQ1C,SAAgB,eAAe,KAAa,OAAqB;AAC/D,KAAI,SAAS,OAAO,OAAO;AACzB,MAAI,OAAO,iBAAiB,aAAa;AAEvC,WAAQ,KAAK,sBAAsB;AACnC;;AAEF,eAAa,QAAQ,KAAK,MAAM;AAChC;;AAEF,eAAc,eAAe,KAAK,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocale.d.ts","sourceRoot":"","sources":["../../../src/utils/resolveLocale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAM1E"}
1
+ {"version":3,"file":"resolveLocale.d.ts","sourceRoot":"","sources":["../../../src/utils/resolveLocale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAE1E"}
@@ -1,8 +1,7 @@
1
1
  import { getI18nConfig } from "gt-i18n/internal";
2
2
  //#region src/utils/resolveLocale.ts
3
3
  function resolveLocale(candidates) {
4
- const i18nConfig = getI18nConfig();
5
- return i18nConfig.determineLocale(candidates ?? void 0) || i18nConfig.getDefaultLocale();
4
+ return getI18nConfig().resolveSupportedLocale(candidates ?? void 0);
6
5
  }
7
6
  //#endregion
8
7
  export { resolveLocale };
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocale.js","names":[],"sources":["../../../src/utils/resolveLocale.ts"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { LocaleCandidates } from 'gt-i18n/internal/types';\n\nexport function resolveLocale(candidates?: LocaleCandidates | null): string {\n const i18nConfig = getI18nConfig();\n return (\n i18nConfig.determineLocale(candidates ?? undefined) ||\n i18nConfig.getDefaultLocale()\n );\n}\n"],"mappings":";;AAGA,SAAgB,cAAc,YAA8C;CAC1E,MAAM,aAAa,eAAe;AAClC,QACE,WAAW,gBAAgB,cAAc,KAAA,EAAU,IACnD,WAAW,kBAAkB"}
1
+ {"version":3,"file":"resolveLocale.js","names":[],"sources":["../../../src/utils/resolveLocale.ts"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { LocaleCandidates } from 'gt-i18n/internal/types';\n\nexport function resolveLocale(candidates?: LocaleCandidates | null): string {\n return getI18nConfig().resolveSupportedLocale(candidates ?? undefined);\n}\n"],"mappings":";;AAGA,SAAgB,cAAc,YAA8C;AAC1E,QAAO,eAAe,CAAC,uBAAuB,cAAc,KAAA,EAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-react-native",
3
- "version": "11.0.0-odysseus.9",
3
+ "version": "11.0.0",
4
4
  "description": "An i18n package for React Native",
5
5
  "main": "./dist/commonjs/index.js",
6
6
  "module": "./dist/module/index.js",
@@ -92,11 +92,11 @@
92
92
  "@formatjs/intl-numberformat": "^8.15.6",
93
93
  "@formatjs/intl-pluralrules": "^5.4.6",
94
94
  "@formatjs/intl-relativetimeformat": "^11.4.13",
95
- "@generaltranslation/format": "0.1.2-odysseus.1",
96
- "@generaltranslation/react-core": "11.0.0-odysseus.9",
97
- "@generaltranslation/supported-locales": "2.1.2-odysseus.4",
98
- "generaltranslation": "9.0.0-odysseus.4",
99
- "gt-i18n": "1.0.0-odysseus.4"
95
+ "@generaltranslation/format": "0.1.2",
96
+ "@generaltranslation/react-core": "11.0.0",
97
+ "@generaltranslation/supported-locales": "2.1.2",
98
+ "generaltranslation": "9.0.0",
99
+ "gt-i18n": "1.0.0"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@babel/core": "^7.28.4",
@@ -3,11 +3,7 @@ import type {
3
3
  WritableConditionStoreInterface,
4
4
  WritableConditionStoreParams,
5
5
  } from 'gt-i18n/internal/types';
6
- import {
7
- defaultEnableI18nCookieName as defaultEnableI18nStoreKey,
8
- defaultLocaleCookieName as defaultLocaleStoreKey,
9
- defaultRegionCookieName as defaultRegionStoreKey,
10
- } from '@generaltranslation/react-core/pure';
6
+ import { getI18nConfig } from '@generaltranslation/react-core/pure';
11
7
  import { getLocale } from '../utils/getLocale';
12
8
  import {
13
9
  getInitialEnableI18n,
@@ -17,9 +13,6 @@ import { nativeStoreGet, nativeStoreSet } from '../utils/nativeStore';
17
13
  import { resolveLocale } from '../utils/resolveLocale';
18
14
 
19
15
  export type NativeConditionStoreParams = WritableConditionStoreParams & {
20
- localeStoreKey?: string;
21
- regionStoreKey?: string;
22
- enableI18nStoreKey?: string;
23
16
  _reload?: ReloadType;
24
17
  };
25
18
 
@@ -35,24 +28,14 @@ export type ReloadType = (state: NativeConditionStoreState) => void;
35
28
  * Condition store implementation for React Native.
36
29
  */
37
30
  export class NativeConditionStore implements WritableConditionStoreInterface {
38
- private localeStoreKey: string;
39
- private regionStoreKey: string;
40
- private enableI18nStoreKey: string;
41
31
  private customReload: ReloadType;
42
32
 
43
33
  constructor(config: NativeConditionStoreParams) {
44
34
  this.customReload = config._reload ?? (() => undefined);
45
- this.localeStoreKey = config.localeStoreKey ?? defaultLocaleStoreKey;
46
- this.regionStoreKey = config.regionStoreKey ?? defaultRegionStoreKey;
47
- this.enableI18nStoreKey =
48
- config.enableI18nStoreKey ?? defaultEnableI18nStoreKey;
49
35
 
50
- this.updateLocale(
51
- config.locale ?? getLocale({ localeStoreKey: this.localeStoreKey })
52
- );
36
+ this.updateLocale(config.locale ?? getLocale());
53
37
  const region = getInitialRegion({
54
38
  region: config.region,
55
- regionStoreKey: this.regionStoreKey,
56
39
  });
57
40
  if (region !== undefined) {
58
41
  this.updateRegion(region);
@@ -60,36 +43,22 @@ export class NativeConditionStore implements WritableConditionStoreInterface {
60
43
  this.updateEnableI18n(
61
44
  getInitialEnableI18n({
62
45
  enableI18n: config.enableI18n,
63
- enableI18nStoreKey: this.enableI18nStoreKey,
64
46
  })
65
47
  );
66
48
  }
67
49
 
68
- updateConfig = ({
69
- localeStoreKey,
70
- regionStoreKey,
71
- enableI18nStoreKey,
72
- }: Pick<
73
- NativeConditionStoreParams,
74
- 'localeStoreKey' | 'regionStoreKey' | 'enableI18nStoreKey'
75
- >): void => {
76
- this.localeStoreKey = localeStoreKey ?? defaultLocaleStoreKey;
77
- this.regionStoreKey = regionStoreKey ?? defaultRegionStoreKey;
78
- this.enableI18nStoreKey = enableI18nStoreKey ?? defaultEnableI18nStoreKey;
79
- };
80
-
81
50
  getLocale = (): string => {
82
- return getLocale({ localeStoreKey: this.localeStoreKey });
51
+ return getLocale();
83
52
  };
84
53
 
85
54
  setLocale = (locale: LocaleCandidates): void => {
86
55
  const nextLocale = resolveLocale(locale);
87
- nativeStoreSet(this.localeStoreKey, nextLocale);
56
+ nativeStoreSet(getLocaleStoreKey(), nextLocale);
88
57
  this.reload({ locale: nextLocale });
89
58
  };
90
59
 
91
60
  getRegion = (): string | undefined => {
92
- return nativeStoreGet(this.regionStoreKey) || undefined;
61
+ return nativeStoreGet(getRegionStoreKey()) || undefined;
93
62
  };
94
63
 
95
64
  setRegion = (region: string | undefined): void => {
@@ -98,7 +67,7 @@ export class NativeConditionStore implements WritableConditionStoreInterface {
98
67
  };
99
68
 
100
69
  getEnableI18n = (): boolean => {
101
- return nativeStoreGet(this.enableI18nStoreKey) !== 'false';
70
+ return nativeStoreGet(getEnableI18nStoreKey()) !== 'false';
102
71
  };
103
72
 
104
73
  setEnableI18n = (enableI18n: boolean): void => {
@@ -107,15 +76,15 @@ export class NativeConditionStore implements WritableConditionStoreInterface {
107
76
  };
108
77
 
109
78
  updateLocale = (locale: LocaleCandidates): void => {
110
- nativeStoreSet(this.localeStoreKey, resolveLocale(locale));
79
+ nativeStoreSet(getLocaleStoreKey(), resolveLocale(locale));
111
80
  };
112
81
 
113
82
  updateRegion = (region: string | undefined): void => {
114
- nativeStoreSet(this.regionStoreKey, region ?? '');
83
+ nativeStoreSet(getRegionStoreKey(), region ?? '');
115
84
  };
116
85
 
117
86
  updateEnableI18n = (enableI18n: boolean): void => {
118
- nativeStoreSet(this.enableI18nStoreKey, enableI18n ? 'true' : 'false');
87
+ nativeStoreSet(getEnableI18nStoreKey(), enableI18n ? 'true' : 'false');
119
88
  };
120
89
 
121
90
  reload = (state: Partial<NativeConditionStoreState> = {}): void => {
@@ -126,3 +95,15 @@ export class NativeConditionStore implements WritableConditionStoreInterface {
126
95
  });
127
96
  };
128
97
  }
98
+
99
+ function getLocaleStoreKey(): string {
100
+ return getI18nConfig().getLocaleCookieName();
101
+ }
102
+
103
+ function getRegionStoreKey(): string {
104
+ return getI18nConfig().getRegionCookieName();
105
+ }
106
+
107
+ function getEnableI18nStoreKey(): string {
108
+ return getI18nConfig().getEnableI18nCookieName();
109
+ }