@generaltranslation/react-core 11.4.3 → 11.4.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @generaltranslation/react-core
2
2
 
3
+ ## 11.4.5
4
+
5
+ ## 11.4.4
6
+
7
+ ### Patch Changes
8
+
9
+ - [#2330](https://github.com/generaltranslation/gt/pull/2330) [`9ee7dc3`](https://github.com/generaltranslation/gt/commit/9ee7dc3ae792cd81ce7edb5c6e43c963f7055261) Thanks [@eoinest](https://github.com/eoinest)! - Use server-provided locale and condition props as the only rendered state in server-rendered apps. Condition setters write cookies for middleware and request a reload; provider-free SPA apps keep their cookie-backed behavior.
10
+
11
+ - Updated dependencies [[`5d75eb4`](https://github.com/generaltranslation/gt/commit/5d75eb475a9e36a61845f0368566a9d40466251c)]:
12
+ - generaltranslation@9.5.1
13
+ - gt-i18n@1.0.32
14
+
3
15
  ## 11.4.3
4
16
 
5
17
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./context.cjs`);let t=require(`react/jsx-runtime`),n=require(`react`);const r=e.getGTContext();function i({children:e,translations:i,dictionaries:a,conditionStore:o,i18nStore:s,onMissingTranslation:c,onMissingDictionaryEntry:l,onMissingDictionaryObj:u}){let d=(0,n.useMemo)(()=>({translationsSnapshot:i,dictionariesSnapshot:a??{},i18nStore:s,conditionStore:o,onMissingTranslation:c,onMissingDictionaryEntry:l,onMissingDictionaryObj:u}),[i,a,s,o,c,l,u]);return(0,n.useEffect)(()=>{s.updateTranslations(i),s.updateDictionaries(a??{})},[i,a,s]),(0,t.jsx)(r.Provider,{value:d,children:e})}exports.InternalGTProvider=i;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./context.cjs`);let t=require(`react/jsx-runtime`),n=require(`react`);const r=e.getGTContext();function i({children:e,translations:i,dictionaries:a,locale:o,region:s,enableI18n:c,setLocale:l,setRegion:u,setEnableI18n:d,i18nStore:f,onMissingTranslation:p,onMissingDictionaryEntry:m,onMissingDictionaryObj:h}){let g=(0,n.useMemo)(()=>({translationsSnapshot:i,dictionariesSnapshot:a??{},i18nStore:f,locale:o,region:s,enableI18n:c,setLocale:l,setRegion:u,setEnableI18n:d,onMissingTranslation:p,onMissingDictionaryEntry:m,onMissingDictionaryObj:h}),[i,a,f,o,s,c,l,u,d,p,m,h]);return(0,n.useEffect)(()=>{f.updateTranslations(i),f.updateDictionaries(a??{})},[i,a,f]),(0,t.jsx)(r.Provider,{value:g,children:e})}exports.InternalGTProvider=i;
2
2
  //# sourceMappingURL=InternalGTProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalGTProvider.cjs","names":["getGTContext"],"sources":["../../src/context/InternalGTProvider.tsx"],"sourcesContent":["import { useEffect, useMemo, type ReactNode } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport type { Dictionary, Translation } from 'gt-i18n/types';\nimport type {\n Locale,\n Hash,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { getGTContext } from './context';\nimport type {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '../hooks/utils/missing-translation';\n\nexport type InternalGTProviderProps = {\n children?: ReactNode;\n // For streaming translations to server\n translations: Record<Locale, Record<Hash, Translation>>;\n dictionaries?: Record<Locale, Dictionary>;\n // Declared upstream dependent on environment\n conditionStore: WritableConditionStoreInterface;\n i18nStore: I18nStore;\n // Custom override missing translation behavior for dev hot reload\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\n// ===== Component ===== //\nconst GTContext = getGTContext();\n/**\n * - Shared provider logic btwn client and server providers\n * - This is not userfacing, it should be wrapped in a userfacing provider with runtime-specific logic\n * - Locale and translations (and dictionaries if applicable) are required\n *\n * TODO: selectively filter to only pass new translations to client for dev hot reload\n * TODO: rename parent directory to \"/provider\" (separate PR)\n */\nexport function InternalGTProvider({\n children,\n translations,\n dictionaries,\n conditionStore,\n i18nStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n}: InternalGTProviderProps) {\n const value = useMemo(\n () => ({\n translationsSnapshot: translations,\n dictionariesSnapshot: dictionaries ?? {},\n i18nStore,\n conditionStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n }),\n [\n translations,\n dictionaries,\n i18nStore,\n conditionStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n ]\n );\n\n // Update cache with data from server, do not emit events\n useEffect(() => {\n i18nStore.updateTranslations(translations);\n i18nStore.updateDictionaries(dictionaries ?? {});\n }, [translations, dictionaries, i18nStore]);\n\n return <GTContext.Provider value={value}>{children}</GTContext.Provider>;\n}\n"],"mappings":"oIA8BA,MAAM,EAAYA,EAAAA,cAAc,CAShC,SAAgB,EAAmB,CACjC,WACA,eACA,eACA,iBACA,YACA,uBACA,2BACA,0BAC0B,CAC1B,IAAM,GAAA,EAAA,EAAA,cACG,CACL,qBAAsB,EACtB,qBAAsB,GAAgB,EAAE,CACxC,YACA,iBACA,uBACA,2BACA,yBACD,EACD,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQD,OALA,EAAA,EAAA,eAAgB,CACd,EAAU,mBAAmB,EAAa,CAC1C,EAAU,mBAAmB,GAAgB,EAAE,CAAC,EAC/C,CAAC,EAAc,EAAc,EAAU,CAAC,EAEpC,EAAA,EAAA,KAAC,EAAU,SAAX,CAA2B,QAAQ,WAA8B,CAAA"}
1
+ {"version":3,"file":"InternalGTProvider.cjs","names":["getGTContext"],"sources":["../../src/context/InternalGTProvider.tsx"],"sourcesContent":["import { useEffect, useMemo, type ReactNode } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport type { Dictionary, Translation } from 'gt-i18n/types';\nimport type { Locale, Hash } from 'gt-i18n/internal/types';\nimport { getGTContext } from './context';\nimport type {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '../hooks/utils/missing-translation';\n\nexport type InternalGTProviderProps = {\n children?: ReactNode;\n // For streaming translations to server\n translations: Record<Locale, Record<Hash, Translation>>;\n dictionaries?: Record<Locale, Dictionary>;\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n setLocale: (locale: string) => void;\n setRegion: (region: string | undefined) => void;\n setEnableI18n: (enabled: boolean) => void;\n i18nStore: I18nStore;\n // Custom override missing translation behavior for dev hot reload\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\n// ===== Component ===== //\nconst GTContext = getGTContext();\n/**\n * - Shared provider logic btwn client and server providers\n * - This is not userfacing, it should be wrapped in a userfacing provider with runtime-specific logic\n * - Locale and translations (and dictionaries if applicable) are required\n *\n * TODO: selectively filter to only pass new translations to client for dev hot reload\n * TODO: rename parent directory to \"/provider\" (separate PR)\n */\nexport function InternalGTProvider({\n children,\n translations,\n dictionaries,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n i18nStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n}: InternalGTProviderProps) {\n const value = useMemo(\n () => ({\n translationsSnapshot: translations,\n dictionariesSnapshot: dictionaries ?? {},\n i18nStore,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n }),\n [\n translations,\n dictionaries,\n i18nStore,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n ]\n );\n\n // Update cache with data from server, do not emit events\n useEffect(() => {\n i18nStore.updateTranslations(translations);\n i18nStore.updateDictionaries(dictionaries ?? {});\n }, [translations, dictionaries, i18nStore]);\n\n return <GTContext.Provider value={value}>{children}</GTContext.Provider>;\n}\n"],"mappings":"oIA8BA,MAAM,EAAYA,EAAAA,cAAc,CAShC,SAAgB,EAAmB,CACjC,WACA,eACA,eACA,SACA,SACA,aACA,YACA,YACA,gBACA,YACA,uBACA,2BACA,0BAC0B,CAC1B,IAAM,GAAA,EAAA,EAAA,cACG,CACL,qBAAsB,EACtB,qBAAsB,GAAgB,EAAE,CACxC,YACA,SACA,SACA,aACA,YACA,YACA,gBACA,uBACA,2BACA,yBACD,EACD,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQD,OALA,EAAA,EAAA,eAAgB,CACd,EAAU,mBAAmB,EAAa,CAC1C,EAAU,mBAAmB,GAAgB,EAAE,CAAC,EAC/C,CAAC,EAAc,EAAc,EAAU,CAAC,EAEpC,EAAA,EAAA,KAAC,EAAU,SAAX,CAA2B,QAAQ,WAA8B,CAAA"}
@@ -2,7 +2,7 @@ import { I18nStore } from "../i18n-store/I18nStore.js";
2
2
  import { OnMissingDictionaryEntry, OnMissingDictionaryObj, OnMissingTranslation } from "../hooks/utils/missing-translation.js";
3
3
  import { ReactNode } from "react";
4
4
  import { Dictionary, Translation } from "gt-i18n/types";
5
- import { Hash, Locale, WritableConditionStoreInterface } from "gt-i18n/internal/types";
5
+ import { Hash, Locale } from "gt-i18n/internal/types";
6
6
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
7
7
 
8
8
  //#region src/context/InternalGTProvider.d.ts
@@ -10,7 +10,12 @@ type InternalGTProviderProps = {
10
10
  children?: ReactNode;
11
11
  translations: Record<Locale, Record<Hash, Translation>>;
12
12
  dictionaries?: Record<Locale, Dictionary>;
13
- conditionStore: WritableConditionStoreInterface;
13
+ locale: string;
14
+ region: string | undefined;
15
+ enableI18n: boolean;
16
+ setLocale: (locale: string) => void;
17
+ setRegion: (region: string | undefined) => void;
18
+ setEnableI18n: (enabled: boolean) => void;
14
19
  i18nStore: I18nStore;
15
20
  onMissingTranslation?: OnMissingTranslation;
16
21
  onMissingDictionaryEntry?: OnMissingDictionaryEntry;
@@ -28,7 +33,12 @@ declare function InternalGTProvider({
28
33
  children,
29
34
  translations,
30
35
  dictionaries,
31
- conditionStore,
36
+ locale,
37
+ region,
38
+ enableI18n,
39
+ setLocale,
40
+ setRegion,
41
+ setEnableI18n,
32
42
  i18nStore,
33
43
  onMissingTranslation,
34
44
  onMissingDictionaryEntry,
@@ -1 +1 @@
1
- {"version":3,"file":"InternalGTProvider.d.ts","names":[],"sources":["../../src/context/InternalGTProvider.tsx"],"mappings":";;;;;;;;KAeY,uBAAA;EACV,QAAA,GAAW,SAAA;EAEX,YAAA,EAAc,MAAA,CAAO,MAAA,EAAQ,MAAA,CAAO,IAAA,EAAM,WAAA;EAC1C,YAAA,GAAe,MAAA,CAAO,MAAA,EAAQ,UAAA;EAE9B,cAAA,EAAgB,+BAAA;EAChB,SAAA,EAAW,SAAA;EAEX,oBAAA,GAAuB,oBAAA;EACvB,wBAAA,GAA2B,wBAAA;EAC3B,sBAAA,GAAyB,sBAAA;AAAA;;;;;;;;;iBAaX,kBAAA,CAAA;EACd,QAAA;EACA,YAAA;EACA,YAAA;EACA,cAAA;EACA,SAAA;EACA,oBAAA;EACA,wBAAA;EACA;AAAA,GACC,uBAAA,GAAuB,oBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"InternalGTProvider.d.ts","names":[],"sources":["../../src/context/InternalGTProvider.tsx"],"mappings":";;;;;;;;KAWY,uBAAA;EACV,QAAA,GAAW,SAAA;EAEX,YAAA,EAAc,MAAA,CAAO,MAAA,EAAQ,MAAA,CAAO,IAAA,EAAM,WAAA;EAC1C,YAAA,GAAe,MAAA,CAAO,MAAA,EAAQ,UAAA;EAC9B,MAAA;EACA,MAAA;EACA,UAAA;EACA,SAAA,GAAY,MAAA;EACZ,SAAA,GAAY,MAAA;EACZ,aAAA,GAAgB,OAAA;EAChB,SAAA,EAAW,SAAA;EAEX,oBAAA,GAAuB,oBAAA;EACvB,wBAAA,GAA2B,wBAAA;EAC3B,sBAAA,GAAyB,sBAAA;AAAA;;;;;;;;;iBAaX,kBAAA,CAAA;EACd,QAAA;EACA,YAAA;EACA,YAAA;EACA,MAAA;EACA,MAAA;EACA,UAAA;EACA,SAAA;EACA,SAAA;EACA,aAAA;EACA,SAAA;EACA,oBAAA;EACA,wBAAA;EACA;AAAA,GACC,uBAAA,GAAuB,oBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,2 +1,2 @@
1
- import{getGTContext as e}from"./context.mjs";import{jsx as t}from"react/jsx-runtime";import{useEffect as n,useMemo as r}from"react";const i=e();function a({children:e,translations:a,dictionaries:o,conditionStore:s,i18nStore:c,onMissingTranslation:l,onMissingDictionaryEntry:u,onMissingDictionaryObj:d}){let f=r(()=>({translationsSnapshot:a,dictionariesSnapshot:o??{},i18nStore:c,conditionStore:s,onMissingTranslation:l,onMissingDictionaryEntry:u,onMissingDictionaryObj:d}),[a,o,c,s,l,u,d]);return n(()=>{c.updateTranslations(a),c.updateDictionaries(o??{})},[a,o,c]),t(i.Provider,{value:f,children:e})}export{a as InternalGTProvider};
1
+ import{getGTContext as e}from"./context.mjs";import{jsx as t}from"react/jsx-runtime";import{useEffect as n,useMemo as r}from"react";const i=e();function a({children:e,translations:a,dictionaries:o,locale:s,region:c,enableI18n:l,setLocale:u,setRegion:d,setEnableI18n:f,i18nStore:p,onMissingTranslation:m,onMissingDictionaryEntry:h,onMissingDictionaryObj:g}){let _=r(()=>({translationsSnapshot:a,dictionariesSnapshot:o??{},i18nStore:p,locale:s,region:c,enableI18n:l,setLocale:u,setRegion:d,setEnableI18n:f,onMissingTranslation:m,onMissingDictionaryEntry:h,onMissingDictionaryObj:g}),[a,o,p,s,c,l,u,d,f,m,h,g]);return n(()=>{p.updateTranslations(a),p.updateDictionaries(o??{})},[a,o,p]),t(i.Provider,{value:_,children:e})}export{a as InternalGTProvider};
2
2
  //# sourceMappingURL=InternalGTProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalGTProvider.mjs","names":[],"sources":["../../src/context/InternalGTProvider.tsx"],"sourcesContent":["import { useEffect, useMemo, type ReactNode } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport type { Dictionary, Translation } from 'gt-i18n/types';\nimport type {\n Locale,\n Hash,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { getGTContext } from './context';\nimport type {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '../hooks/utils/missing-translation';\n\nexport type InternalGTProviderProps = {\n children?: ReactNode;\n // For streaming translations to server\n translations: Record<Locale, Record<Hash, Translation>>;\n dictionaries?: Record<Locale, Dictionary>;\n // Declared upstream dependent on environment\n conditionStore: WritableConditionStoreInterface;\n i18nStore: I18nStore;\n // Custom override missing translation behavior for dev hot reload\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\n// ===== Component ===== //\nconst GTContext = getGTContext();\n/**\n * - Shared provider logic btwn client and server providers\n * - This is not userfacing, it should be wrapped in a userfacing provider with runtime-specific logic\n * - Locale and translations (and dictionaries if applicable) are required\n *\n * TODO: selectively filter to only pass new translations to client for dev hot reload\n * TODO: rename parent directory to \"/provider\" (separate PR)\n */\nexport function InternalGTProvider({\n children,\n translations,\n dictionaries,\n conditionStore,\n i18nStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n}: InternalGTProviderProps) {\n const value = useMemo(\n () => ({\n translationsSnapshot: translations,\n dictionariesSnapshot: dictionaries ?? {},\n i18nStore,\n conditionStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n }),\n [\n translations,\n dictionaries,\n i18nStore,\n conditionStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n ]\n );\n\n // Update cache with data from server, do not emit events\n useEffect(() => {\n i18nStore.updateTranslations(translations);\n i18nStore.updateDictionaries(dictionaries ?? {});\n }, [translations, dictionaries, i18nStore]);\n\n return <GTContext.Provider value={value}>{children}</GTContext.Provider>;\n}\n"],"mappings":"oIA8BA,MAAM,EAAY,GAAc,CAShC,SAAgB,EAAmB,CACjC,WACA,eACA,eACA,iBACA,YACA,uBACA,2BACA,0BAC0B,CAC1B,IAAM,EAAQ,OACL,CACL,qBAAsB,EACtB,qBAAsB,GAAgB,EAAE,CACxC,YACA,iBACA,uBACA,2BACA,yBACD,EACD,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQD,OALA,MAAgB,CACd,EAAU,mBAAmB,EAAa,CAC1C,EAAU,mBAAmB,GAAgB,EAAE,CAAC,EAC/C,CAAC,EAAc,EAAc,EAAU,CAAC,CAEpC,EAAC,EAAU,SAAX,CAA2B,QAAQ,WAA8B,CAAA"}
1
+ {"version":3,"file":"InternalGTProvider.mjs","names":[],"sources":["../../src/context/InternalGTProvider.tsx"],"sourcesContent":["import { useEffect, useMemo, type ReactNode } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport type { Dictionary, Translation } from 'gt-i18n/types';\nimport type { Locale, Hash } from 'gt-i18n/internal/types';\nimport { getGTContext } from './context';\nimport type {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '../hooks/utils/missing-translation';\n\nexport type InternalGTProviderProps = {\n children?: ReactNode;\n // For streaming translations to server\n translations: Record<Locale, Record<Hash, Translation>>;\n dictionaries?: Record<Locale, Dictionary>;\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n setLocale: (locale: string) => void;\n setRegion: (region: string | undefined) => void;\n setEnableI18n: (enabled: boolean) => void;\n i18nStore: I18nStore;\n // Custom override missing translation behavior for dev hot reload\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\n// ===== Component ===== //\nconst GTContext = getGTContext();\n/**\n * - Shared provider logic btwn client and server providers\n * - This is not userfacing, it should be wrapped in a userfacing provider with runtime-specific logic\n * - Locale and translations (and dictionaries if applicable) are required\n *\n * TODO: selectively filter to only pass new translations to client for dev hot reload\n * TODO: rename parent directory to \"/provider\" (separate PR)\n */\nexport function InternalGTProvider({\n children,\n translations,\n dictionaries,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n i18nStore,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n}: InternalGTProviderProps) {\n const value = useMemo(\n () => ({\n translationsSnapshot: translations,\n dictionariesSnapshot: dictionaries ?? {},\n i18nStore,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n }),\n [\n translations,\n dictionaries,\n i18nStore,\n locale,\n region,\n enableI18n,\n setLocale,\n setRegion,\n setEnableI18n,\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n ]\n );\n\n // Update cache with data from server, do not emit events\n useEffect(() => {\n i18nStore.updateTranslations(translations);\n i18nStore.updateDictionaries(dictionaries ?? {});\n }, [translations, dictionaries, i18nStore]);\n\n return <GTContext.Provider value={value}>{children}</GTContext.Provider>;\n}\n"],"mappings":"oIA8BA,MAAM,EAAY,GAAc,CAShC,SAAgB,EAAmB,CACjC,WACA,eACA,eACA,SACA,SACA,aACA,YACA,YACA,gBACA,YACA,uBACA,2BACA,0BAC0B,CAC1B,IAAM,EAAQ,OACL,CACL,qBAAsB,EACtB,qBAAsB,GAAgB,EAAE,CACxC,YACA,SACA,SACA,aACA,YACA,YACA,gBACA,uBACA,2BACA,yBACD,EACD,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAQD,OALA,MAAgB,CACd,EAAU,mBAAmB,EAAa,CAC1C,EAAU,mBAAmB,GAAgB,EAAE,CAAC,EAC/C,CAAC,EAAc,EAAc,EAAU,CAAC,CAEpC,EAAC,EAAU,SAAX,CAA2B,QAAQ,WAA8B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","names":["getI18nConfig"],"sources":["../../src/context/context.ts"],"sourcesContent":["import {\n Dictionary,\n Hash,\n Locale,\n ReadonlyConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from 'gt-i18n/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n /**\n * ConditionStore should always remain separate from i18nStore as\n * it manages how we perform lookups\n */\n conditionStore: ReadonlyConditionStoreInterface;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\nconst gtContextSingleton = createGlobalSingleton<\n Context<GTContextType | undefined>\n>({\n namespace: 'reactCore',\n key: 'gtContext',\n source: '@generaltranslation/react-core',\n notInitialized: () =>\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GTContext before it has been initialized',\n why: 'the internal GTContext singleton is unavailable',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n }),\n});\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n // Lazily create the React context once and share it across instances.\n if (!gtContextSingleton.isInitialized()) {\n gtContextSingleton.set(createContext<GTContextType | undefined>(undefined));\n }\n return gtContextSingleton.get();\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n"],"mappings":"sLA6CA,MAAM,GAAA,EAAA,EAAA,uBAEJ,CACA,UAAW,YACX,IAAK,YACL,OAAQ,iCACR,oBAAA,EAAA,EAAA,yBAC0B,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,uDACd,IAAK,kDACL,IAAK,yDACN,CAAC,CACL,CAAC,CAEF,SAAgB,GAAmD,CAKjE,OAHK,EAAmB,eAAe,EACrC,EAAmB,KAAA,EAAA,EAAA,eAA6C,IAAA,GAAU,CAAC,CAEtE,EAAmB,KAAK,CAGjC,SAAgB,GAA0C,CACxD,IAAM,GAAA,EAAA,EAAA,YAAqB,GAAc,CAAC,CAC1C,GAAI,GAAWA,EAAAA,eAAe,CAAC,mBAAmB,GAAK,MACrD,OAAO,EAKT,MAAU,MAAM,GAA8B,CAAC,CAGjD,SAAS,GAAuC,CAC9C,OAAA,EAAA,EAAA,yBAA+B,CAC7B,OAAQ,iCACR,SAAU,QACV,aAAc,uCACd,IAAK,mDACL,IAAK,yDACN,CAAC"}
1
+ {"version":3,"file":"context.cjs","names":["getI18nConfig"],"sources":["../../src/context/context.ts"],"sourcesContent":["import { Dictionary, Hash, Locale } from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from 'gt-i18n/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n setLocale: (locale: string) => void;\n setRegion: (region: string | undefined) => void;\n setEnableI18n: (enabled: boolean) => void;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\nconst gtContextSingleton = createGlobalSingleton<\n Context<GTContextType | undefined>\n>({\n namespace: 'reactCore',\n key: 'gtContext',\n source: '@generaltranslation/react-core',\n notInitialized: () =>\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GTContext before it has been initialized',\n why: 'the internal GTContext singleton is unavailable',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n }),\n});\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n // Lazily create the React context once and share it across instances.\n if (!gtContextSingleton.isInitialized()) {\n gtContextSingleton.set(createContext<GTContextType | undefined>(undefined));\n }\n return gtContextSingleton.get();\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n"],"mappings":"sLAyCA,MAAM,GAAA,EAAA,EAAA,uBAEJ,CACA,UAAW,YACX,IAAK,YACL,OAAQ,iCACR,oBAAA,EAAA,EAAA,yBAC0B,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,uDACd,IAAK,kDACL,IAAK,yDACN,CAAC,CACL,CAAC,CAEF,SAAgB,GAAmD,CAKjE,OAHK,EAAmB,eAAe,EACrC,EAAmB,KAAA,EAAA,EAAA,eAA6C,IAAA,GAAU,CAAC,CAEtE,EAAmB,KAAK,CAGjC,SAAgB,GAA0C,CACxD,IAAM,GAAA,EAAA,EAAA,YAAqB,GAAc,CAAC,CAC1C,GAAI,GAAWA,EAAAA,eAAe,CAAC,mBAAmB,GAAK,MACrD,OAAO,EAKT,MAAU,MAAM,GAA8B,CAAC,CAGjD,SAAS,GAAuC,CAC9C,OAAA,EAAA,EAAA,yBAA+B,CAC7B,OAAQ,iCACR,SAAU,QACV,aAAc,uCACd,IAAK,mDACL,IAAK,yDACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.mjs","names":["getI18nConfig"],"sources":["../../src/context/context.ts"],"sourcesContent":["import {\n Dictionary,\n Hash,\n Locale,\n ReadonlyConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from 'gt-i18n/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n /**\n * ConditionStore should always remain separate from i18nStore as\n * it manages how we perform lookups\n */\n conditionStore: ReadonlyConditionStoreInterface;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\nconst gtContextSingleton = createGlobalSingleton<\n Context<GTContextType | undefined>\n>({\n namespace: 'reactCore',\n key: 'gtContext',\n source: '@generaltranslation/react-core',\n notInitialized: () =>\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GTContext before it has been initialized',\n why: 'the internal GTContext singleton is unavailable',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n }),\n});\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n // Lazily create the React context once and share it across instances.\n if (!gtContextSingleton.isInitialized()) {\n gtContextSingleton.set(createContext<GTContextType | undefined>(undefined));\n }\n return gtContextSingleton.get();\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n"],"mappings":"6OA6CA,MAAM,EAAqB,EAEzB,CACA,UAAW,YACX,IAAK,YACL,OAAQ,iCACR,mBACE,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,uDACd,IAAK,kDACL,IAAK,yDACN,CAAC,CACL,CAAC,CAEF,SAAgB,GAAmD,CAKjE,OAHK,EAAmB,eAAe,EACrC,EAAmB,IAAI,EAAyC,IAAA,GAAU,CAAC,CAEtE,EAAmB,KAAK,CAGjC,SAAgB,GAA0C,CACxD,IAAM,EAAU,EAAW,GAAc,CAAC,CAC1C,GAAI,GAAWA,GAAe,CAAC,mBAAmB,GAAK,MACrD,OAAO,EAKT,MAAU,MAAM,GAA8B,CAAC,CAGjD,SAAS,GAAuC,CAC9C,OAAO,EAAwB,CAC7B,OAAQ,iCACR,SAAU,QACV,aAAc,uCACd,IAAK,mDACL,IAAK,yDACN,CAAC"}
1
+ {"version":3,"file":"context.mjs","names":["getI18nConfig"],"sources":["../../src/context/context.ts"],"sourcesContent":["import { Dictionary, Hash, Locale } from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from 'gt-i18n/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n setLocale: (locale: string) => void;\n setRegion: (region: string | undefined) => void;\n setEnableI18n: (enabled: boolean) => void;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\nconst gtContextSingleton = createGlobalSingleton<\n Context<GTContextType | undefined>\n>({\n namespace: 'reactCore',\n key: 'gtContext',\n source: '@generaltranslation/react-core',\n notInitialized: () =>\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GTContext before it has been initialized',\n why: 'the internal GTContext singleton is unavailable',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n }),\n});\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n // Lazily create the React context once and share it across instances.\n if (!gtContextSingleton.isInitialized()) {\n gtContextSingleton.set(createContext<GTContextType | undefined>(undefined));\n }\n return gtContextSingleton.get();\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n"],"mappings":"6OAyCA,MAAM,EAAqB,EAEzB,CACA,UAAW,YACX,IAAK,YACL,OAAQ,iCACR,mBACE,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,uDACd,IAAK,kDACL,IAAK,yDACN,CAAC,CACL,CAAC,CAEF,SAAgB,GAAmD,CAKjE,OAHK,EAAmB,eAAe,EACrC,EAAmB,IAAI,EAAyC,IAAA,GAAU,CAAC,CAEtE,EAAmB,KAAK,CAGjC,SAAgB,GAA0C,CACxD,IAAM,EAAU,EAAW,GAAc,CAAC,CAC1C,GAAI,GAAWA,GAAe,CAAC,mBAAmB,GAAK,MACrD,OAAO,EAKT,MAAU,MAAM,GAA8B,CAAC,CAGjD,SAAS,GAAuC,CAC9C,OAAO,EAAwB,CAC7B,OAAQ,iCACR,SAAU,QACV,aAAc,uCACd,IAAK,mDACL,IAAK,yDACN,CAAC"}
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../condition-store/singleton-operations.cjs`),t=require(`../context/context.cjs`);let n=require(`react`);function r(){return t.useGTContext()?.conditionStore??e.getConditionStore()}function i(){return r().getLocale()}function a(){return r().getRegion()}function o(){return r().getEnableI18n()}function s(){let e=r();return(0,n.useCallback)(t=>e.setLocale(t),[e])}function c(){let e=r();return(0,n.useCallback)(t=>e.setRegion(t),[e])}function l(){let e=r();return(0,n.useCallback)(t=>e.setEnableI18n(t),[e])}exports.useConditionStore=r,exports.useEnableI18n=o,exports.useLocale=i,exports.useRegion=a,exports.useSetEnableI18n=l,exports.useSetLocale=s,exports.useSetRegion=c;
1
+ const e=require(`../condition-store/singleton-operations.cjs`),t=require(`../context/context.cjs`);function n(){let n=t.useGTContext();return n?n.locale:e.getConditionStore().getLocale()}function r(){let n=t.useGTContext();return n?n.region:e.getConditionStore().getRegion()}function i(){let n=t.useGTContext();return n?n.enableI18n:e.getConditionStore().getEnableI18n()}function a(){let n=t.useGTContext();return n?n.setLocale:e.getConditionStore().setLocale}function o(){let n=t.useGTContext();return n?n.setRegion:e.getConditionStore().setRegion}function s(){let n=t.useGTContext();return n?n.setEnableI18n:e.getConditionStore().setEnableI18n}exports.useEnableI18n=i,exports.useLocale=n,exports.useRegion=r,exports.useSetEnableI18n=s,exports.useSetLocale=a,exports.useSetRegion=o;
2
2
  //# sourceMappingURL=condition-store.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"condition-store.cjs","names":["useGTContext","getReadonlyConditionStore"],"sources":["../../src/hooks/condition-store.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\nexport function useConditionStore(): ReadonlyConditionStoreInterface {\n const context = useGTContext();\n return context?.conditionStore ?? getReadonlyConditionStore();\n}\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n return useConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n return useConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n return useConditionStore().getEnableI18n();\n}\n\nexport function useSetLocale(): (locale: string) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => conditionStore.setLocale(locale),\n [conditionStore]\n );\n}\n\nexport function useSetRegion(): (region: string | undefined) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => conditionStore.setRegion(region),\n [conditionStore]\n );\n}\n\nexport function useSetEnableI18n(): (enabled: boolean) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (enabled: boolean) => conditionStore.setEnableI18n(enabled),\n [conditionStore]\n );\n}\n"],"mappings":"uKAKA,SAAgB,GAAqD,CAEnE,OADgBA,EAAAA,cACF,EAAE,gBAAkBC,EAAAA,mBAA2B,CAM/D,SAAgB,GAAoB,CAClC,OAAO,GAAmB,CAAC,WAAW,CAMxC,SAAgB,GAAgC,CAC9C,OAAO,GAAmB,CAAC,WAAW,CAMxC,SAAgB,GAAyB,CACvC,OAAO,GAAmB,CAAC,eAAe,CAG5C,SAAgB,GAAyC,CACvD,IAAM,EAAiB,GAAmB,CAC1C,OAAA,EAAA,EAAA,aACG,GAAmB,EAAe,UAAU,EAAO,CACpD,CAAC,EAAe,CACjB,CAGH,SAAgB,GAAqD,CACnE,IAAM,EAAiB,GAAmB,CAC1C,OAAA,EAAA,EAAA,aACG,GAA+B,EAAe,UAAU,EAAO,CAChE,CAAC,EAAe,CACjB,CAGH,SAAgB,GAA+C,CAC7D,IAAM,EAAiB,GAAmB,CAC1C,OAAA,EAAA,EAAA,aACG,GAAqB,EAAe,cAAc,EAAQ,CAC3D,CAAC,EAAe,CACjB"}
1
+ {"version":3,"file":"condition-store.cjs","names":["useGTContext","getReadonlyConditionStore"],"sources":["../../src/hooks/condition-store.ts"],"sourcesContent":["import { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n const context = useGTContext();\n return context ? context.locale : getReadonlyConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n const context = useGTContext();\n return context ? context.region : getReadonlyConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n const context = useGTContext();\n return context\n ? context.enableI18n\n : getReadonlyConditionStore().getEnableI18n();\n}\n\nexport function useSetLocale(): (locale: string) => void {\n const context = useGTContext();\n return context ? context.setLocale : getReadonlyConditionStore().setLocale;\n}\n\nexport function useSetRegion(): (region: string | undefined) => void {\n const context = useGTContext();\n return context ? context.setRegion : getReadonlyConditionStore().setRegion;\n}\n\nexport function useSetEnableI18n(): (enabled: boolean) => void {\n const context = useGTContext();\n return context\n ? context.setEnableI18n\n : getReadonlyConditionStore().setEnableI18n;\n}\n"],"mappings":"mGAMA,SAAgB,GAAoB,CAClC,IAAM,EAAUA,EAAAA,cAAc,CAC9B,OAAO,EAAU,EAAQ,OAASC,EAAAA,mBAA2B,CAAC,WAAW,CAM3E,SAAgB,GAAgC,CAC9C,IAAM,EAAUD,EAAAA,cAAc,CAC9B,OAAO,EAAU,EAAQ,OAASC,EAAAA,mBAA2B,CAAC,WAAW,CAM3E,SAAgB,GAAyB,CACvC,IAAM,EAAUD,EAAAA,cAAc,CAC9B,OAAO,EACH,EAAQ,WACRC,EAAAA,mBAA2B,CAAC,eAAe,CAGjD,SAAgB,GAAyC,CACvD,IAAM,EAAUD,EAAAA,cAAc,CAC9B,OAAO,EAAU,EAAQ,UAAYC,EAAAA,mBAA2B,CAAC,UAGnE,SAAgB,GAAqD,CACnE,IAAM,EAAUD,EAAAA,cAAc,CAC9B,OAAO,EAAU,EAAQ,UAAYC,EAAAA,mBAA2B,CAAC,UAGnE,SAAgB,GAA+C,CAC7D,IAAM,EAAUD,EAAAA,cAAc,CAC9B,OAAO,EACH,EAAQ,cACRC,EAAAA,mBAA2B,CAAC"}
@@ -1,7 +1,4 @@
1
- import { ReadonlyConditionStoreInterface } from "gt-i18n/internal/types";
2
-
3
1
  //#region src/hooks/condition-store.d.ts
4
- declare function useConditionStore(): ReadonlyConditionStoreInterface;
5
2
  /**
6
3
  * Returns the current locale.
7
4
  */
@@ -18,5 +15,5 @@ declare function useSetLocale(): (locale: string) => void;
18
15
  declare function useSetRegion(): (region: string | undefined) => void;
19
16
  declare function useSetEnableI18n(): (enabled: boolean) => void;
20
17
  //#endregion
21
- export { useConditionStore, useEnableI18n, useLocale, useRegion, useSetEnableI18n, useSetLocale, useSetRegion };
18
+ export { useEnableI18n, useLocale, useRegion, useSetEnableI18n, useSetLocale, useSetRegion };
22
19
  //# sourceMappingURL=condition-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"condition-store.d.ts","names":[],"sources":["../../src/hooks/condition-store.ts"],"mappings":";;;iBAKgB,iBAAA,CAAA,GAAqB,+BAAA;;AAArC;;iBAQgB,SAAA,CAAA;;;AAAhB;iBAOgB,SAAA,CAAA;;;;iBAOA,aAAA,CAAA;AAAA,iBAIA,YAAA,CAAA,IAAiB,MAAA;AAAA,iBAQjB,YAAA,CAAA,IAAiB,MAAA;AAAA,iBAQjB,gBAAA,CAAA,IAAqB,OAAA"}
1
+ {"version":3,"file":"condition-store.d.ts","names":[],"sources":["../../src/hooks/condition-store.ts"],"mappings":";;AAMA;;iBAAgB,SAAA,CAAA;;;AAQhB;iBAAgB,SAAA,CAAA;;;;iBAQA,aAAA,CAAA;AAAA,iBAOA,YAAA,CAAA,IAAiB,MAAA;AAAA,iBAKjB,YAAA,CAAA,IAAiB,MAAA;AAAA,iBAKjB,gBAAA,CAAA,IAAqB,OAAA"}
@@ -1,2 +1,2 @@
1
- import{getConditionStore as e}from"../condition-store/singleton-operations.mjs";import{useGTContext as t}from"../context/context.mjs";import{useCallback as n}from"react";function r(){return t()?.conditionStore??e()}function i(){return r().getLocale()}function a(){return r().getRegion()}function o(){return r().getEnableI18n()}function s(){let e=r();return n(t=>e.setLocale(t),[e])}function c(){let e=r();return n(t=>e.setRegion(t),[e])}function l(){let e=r();return n(t=>e.setEnableI18n(t),[e])}export{r as useConditionStore,o as useEnableI18n,i as useLocale,a as useRegion,l as useSetEnableI18n,s as useSetLocale,c as useSetRegion};
1
+ import{getConditionStore as e}from"../condition-store/singleton-operations.mjs";import{useGTContext as t}from"../context/context.mjs";function n(){let n=t();return n?n.locale:e().getLocale()}function r(){let n=t();return n?n.region:e().getRegion()}function i(){let n=t();return n?n.enableI18n:e().getEnableI18n()}function a(){let n=t();return n?n.setLocale:e().setLocale}function o(){let n=t();return n?n.setRegion:e().setRegion}function s(){let n=t();return n?n.setEnableI18n:e().setEnableI18n}export{i as useEnableI18n,n as useLocale,r as useRegion,s as useSetEnableI18n,a as useSetLocale,o as useSetRegion};
2
2
  //# sourceMappingURL=condition-store.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"condition-store.mjs","names":["getReadonlyConditionStore"],"sources":["../../src/hooks/condition-store.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\nexport function useConditionStore(): ReadonlyConditionStoreInterface {\n const context = useGTContext();\n return context?.conditionStore ?? getReadonlyConditionStore();\n}\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n return useConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n return useConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n return useConditionStore().getEnableI18n();\n}\n\nexport function useSetLocale(): (locale: string) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => conditionStore.setLocale(locale),\n [conditionStore]\n );\n}\n\nexport function useSetRegion(): (region: string | undefined) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => conditionStore.setRegion(region),\n [conditionStore]\n );\n}\n\nexport function useSetEnableI18n(): (enabled: boolean) => void {\n const conditionStore = useConditionStore();\n return useCallback(\n (enabled: boolean) => conditionStore.setEnableI18n(enabled),\n [conditionStore]\n );\n}\n"],"mappings":"0KAKA,SAAgB,GAAqD,CAEnE,OADgB,GACF,EAAE,gBAAkBA,GAA2B,CAM/D,SAAgB,GAAoB,CAClC,OAAO,GAAmB,CAAC,WAAW,CAMxC,SAAgB,GAAgC,CAC9C,OAAO,GAAmB,CAAC,WAAW,CAMxC,SAAgB,GAAyB,CACvC,OAAO,GAAmB,CAAC,eAAe,CAG5C,SAAgB,GAAyC,CACvD,IAAM,EAAiB,GAAmB,CAC1C,OAAO,EACJ,GAAmB,EAAe,UAAU,EAAO,CACpD,CAAC,EAAe,CACjB,CAGH,SAAgB,GAAqD,CACnE,IAAM,EAAiB,GAAmB,CAC1C,OAAO,EACJ,GAA+B,EAAe,UAAU,EAAO,CAChE,CAAC,EAAe,CACjB,CAGH,SAAgB,GAA+C,CAC7D,IAAM,EAAiB,GAAmB,CAC1C,OAAO,EACJ,GAAqB,EAAe,cAAc,EAAQ,CAC3D,CAAC,EAAe,CACjB"}
1
+ {"version":3,"file":"condition-store.mjs","names":["getReadonlyConditionStore"],"sources":["../../src/hooks/condition-store.ts"],"sourcesContent":["import { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n const context = useGTContext();\n return context ? context.locale : getReadonlyConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n const context = useGTContext();\n return context ? context.region : getReadonlyConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n const context = useGTContext();\n return context\n ? context.enableI18n\n : getReadonlyConditionStore().getEnableI18n();\n}\n\nexport function useSetLocale(): (locale: string) => void {\n const context = useGTContext();\n return context ? context.setLocale : getReadonlyConditionStore().setLocale;\n}\n\nexport function useSetRegion(): (region: string | undefined) => void {\n const context = useGTContext();\n return context ? context.setRegion : getReadonlyConditionStore().setRegion;\n}\n\nexport function useSetEnableI18n(): (enabled: boolean) => void {\n const context = useGTContext();\n return context\n ? context.setEnableI18n\n : getReadonlyConditionStore().setEnableI18n;\n}\n"],"mappings":"sIAMA,SAAgB,GAAoB,CAClC,IAAM,EAAU,GAAc,CAC9B,OAAO,EAAU,EAAQ,OAASA,GAA2B,CAAC,WAAW,CAM3E,SAAgB,GAAgC,CAC9C,IAAM,EAAU,GAAc,CAC9B,OAAO,EAAU,EAAQ,OAASA,GAA2B,CAAC,WAAW,CAM3E,SAAgB,GAAyB,CACvC,IAAM,EAAU,GAAc,CAC9B,OAAO,EACH,EAAQ,WACRA,GAA2B,CAAC,eAAe,CAGjD,SAAgB,GAAyC,CACvD,IAAM,EAAU,GAAc,CAC9B,OAAO,EAAU,EAAQ,UAAYA,GAA2B,CAAC,UAGnE,SAAgB,GAAqD,CACnE,IAAM,EAAU,GAAc,CAC9B,OAAO,EAAU,EAAQ,UAAYA,GAA2B,CAAC,UAGnE,SAAgB,GAA+C,CAC7D,IAAM,EAAU,GAAc,CAC9B,OAAO,EACH,EAAQ,cACRA,GAA2B,CAAC"}
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/getFormatLocales.cjs`),t=require(`./condition-store.cjs`);let n=require(`gt-i18n/internal`),r=require(`react`);const i=[];function a(n=i){let a=t.useLocale(),o=t.useEnableI18n();return(0,r.useMemo)(()=>e.getFormatLocales({locale:a,enableI18n:o,localesProp:n}),[a,o,n])}function o(){let e=t.useEnableI18n(),r=t.useLocale();return e&&(0,n.getI18nConfig)().requiresTranslation(r)}function s(){let e=t.useConditionStore(),r=e.getLocale();return{locale:r,shouldTranslate:e.getEnableI18n()&&(0,n.getI18nConfig)().requiresTranslation(r)}}function c(e){return(0,r.useMemo)(()=>(0,n.getI18nConfig)().getGTClass().getLocaleProperties(e),[e])}function l(e){let i=t.useLocale(),a=e??i;return(0,r.useMemo)(()=>(0,n.getI18nConfig)().getGTClass().getLocaleDirection(a),[a])}exports.useFormatLocales=a,exports.useLocaleDirection=l,exports.useLocaleProperties=c,exports.useShouldTranslate=o,exports.useTranslationConditions=s;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/getFormatLocales.cjs`),t=require(`./condition-store.cjs`);let n=require(`gt-i18n/internal`),r=require(`react`);const i=[];function a(n=i){let a=t.useLocale(),o=t.useEnableI18n();return(0,r.useMemo)(()=>e.getFormatLocales({locale:a,enableI18n:o,localesProp:n}),[a,o,n])}function o(){let e=t.useEnableI18n(),r=t.useLocale();return e&&(0,n.getI18nConfig)().requiresTranslation(r)}function s(){let e=t.useLocale();return{locale:e,shouldTranslate:t.useEnableI18n()&&(0,n.getI18nConfig)().requiresTranslation(e)}}function c(e){return(0,r.useMemo)(()=>(0,n.getI18nConfig)().getGTClass().getLocaleProperties(e),[e])}function l(e){let i=t.useLocale(),a=e??i;return(0,r.useMemo)(()=>(0,n.getI18nConfig)().getGTClass().getLocaleDirection(a),[a])}exports.useFormatLocales=a,exports.useLocaleDirection=l,exports.useLocaleProperties=c,exports.useShouldTranslate=o,exports.useTranslationConditions=s;
2
2
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["useLocale","useEnableI18n","getFormatLocales","useConditionStore"],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { useMemo } from 'react';\nimport { useConditionStore, useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\n/**\n * Resolves the condition values shared by translation hooks once per render.\n */\nexport function useTranslationConditions(): {\n locale: string;\n shouldTranslate: boolean;\n} {\n const conditionStore = useConditionStore();\n const locale = conditionStore.getLocale();\n const enableI18n = conditionStore.getEnableI18n();\n return {\n locale,\n shouldTranslate: enableI18n && getI18nConfig().requiresTranslation(locale),\n };\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n const currentLocale = useLocale();\n const resolvedLocale = locale ?? currentLocale;\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(resolvedLocale),\n [resolvedLocale]\n );\n}\n"],"mappings":"qLAMA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAaC,EAAAA,eAAe,CAClC,OAAA,EAAA,EAAA,aAEIC,EAAAA,iBAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAaD,EAAAA,eAAe,CAC5B,EAASD,EAAAA,WAAW,CAC1B,OAAO,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAMlE,SAAgB,GAGd,CACA,IAAM,EAAiBG,EAAAA,mBAAmB,CACpC,EAAS,EAAe,WAAW,CAEzC,MAAO,CACL,SACA,gBAHiB,EAAe,eAGL,GAAA,EAAA,EAAA,gBAAmB,CAAC,oBAAoB,EAAO,CAC3E,CAGH,SAAgB,EAAoB,EAAkC,CACpE,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgC,CACjE,IAAM,EAAgBH,EAAAA,WAAW,CAC3B,EAAiB,GAAU,EACjC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,mBAAmB,EAAe,CACrE,CAAC,EAAe,CACjB"}
1
+ {"version":3,"file":"utils.cjs","names":["useLocale","useEnableI18n","getFormatLocales"],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\n/**\n * Resolves the condition values shared by translation hooks once per render.\n */\nexport function useTranslationConditions(): {\n locale: string;\n shouldTranslate: boolean;\n} {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return {\n locale,\n shouldTranslate: enableI18n && getI18nConfig().requiresTranslation(locale),\n };\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n const currentLocale = useLocale();\n const resolvedLocale = locale ?? currentLocale;\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(resolvedLocale),\n [resolvedLocale]\n );\n}\n"],"mappings":"qLAMA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAaC,EAAAA,eAAe,CAClC,OAAA,EAAA,EAAA,aAEIC,EAAAA,iBAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAaD,EAAAA,eAAe,CAC5B,EAASD,EAAAA,WAAW,CAC1B,OAAO,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAMlE,SAAgB,GAGd,CACA,IAAM,EAASA,EAAAA,WAAW,CAE1B,MAAO,CACL,SACA,gBAHiBC,EAAAA,eAGU,GAAA,EAAA,EAAA,gBAAmB,CAAC,oBAAoB,EAAO,CAC3E,CAGH,SAAgB,EAAoB,EAAkC,CACpE,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgC,CACjE,IAAM,EAAgBD,EAAAA,WAAW,CAC3B,EAAiB,GAAU,EACjC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,mBAAmB,EAAe,CACrE,CAAC,EAAe,CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/hooks/utils.ts"],"mappings":";;;;iBAUgB,gBAAA,CACd,WAAA;AAAA,iBAqCc,mBAAA,CAAoB,MAAA,WAAiB,gBAAA;AAAA,iBAOrC,kBAAA,CAAmB,MAAA"}
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/hooks/utils.ts"],"mappings":";;;;iBAUgB,gBAAA,CACd,WAAA;AAAA,iBAoCc,mBAAA,CAAoB,MAAA,WAAiB,gBAAA;AAAA,iBAOrC,kBAAA,CAAmB,MAAA"}
@@ -1,2 +1,2 @@
1
- import{getFormatLocales as e}from"./utils/getFormatLocales.mjs";import{useConditionStore as t,useEnableI18n as n,useLocale as r}from"./condition-store.mjs";import{getI18nConfig as i}from"gt-i18n/internal";import{useMemo as a}from"react";const o=[];function s(t=o){let i=r(),s=n();return a(()=>e({locale:i,enableI18n:s,localesProp:t}),[i,s,t])}function c(){let e=n(),t=r();return e&&i().requiresTranslation(t)}function l(){let e=t(),n=e.getLocale();return{locale:n,shouldTranslate:e.getEnableI18n()&&i().requiresTranslation(n)}}function u(e){return a(()=>i().getGTClass().getLocaleProperties(e),[e])}function d(e){let t=r(),n=e??t;return a(()=>i().getGTClass().getLocaleDirection(n),[n])}export{s as useFormatLocales,d as useLocaleDirection,u as useLocaleProperties,c as useShouldTranslate,l as useTranslationConditions};
1
+ import{getFormatLocales as e}from"./utils/getFormatLocales.mjs";import{useEnableI18n as t,useLocale as n}from"./condition-store.mjs";import{getI18nConfig as r}from"gt-i18n/internal";import{useMemo as i}from"react";const a=[];function o(r=a){let o=n(),s=t();return i(()=>e({locale:o,enableI18n:s,localesProp:r}),[o,s,r])}function s(){let e=t(),i=n();return e&&r().requiresTranslation(i)}function c(){let e=n();return{locale:e,shouldTranslate:t()&&r().requiresTranslation(e)}}function l(e){return i(()=>r().getGTClass().getLocaleProperties(e),[e])}function u(e){let t=n(),a=e??t;return i(()=>r().getGTClass().getLocaleDirection(a),[a])}export{o as useFormatLocales,u as useLocaleDirection,l as useLocaleProperties,s as useShouldTranslate,c as useTranslationConditions};
2
2
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { useMemo } from 'react';\nimport { useConditionStore, useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\n/**\n * Resolves the condition values shared by translation hooks once per render.\n */\nexport function useTranslationConditions(): {\n locale: string;\n shouldTranslate: boolean;\n} {\n const conditionStore = useConditionStore();\n const locale = conditionStore.getLocale();\n const enableI18n = conditionStore.getEnableI18n();\n return {\n locale,\n shouldTranslate: enableI18n && getI18nConfig().requiresTranslation(locale),\n };\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n const currentLocale = useLocale();\n const resolvedLocale = locale ?? currentLocale;\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(resolvedLocale),\n [resolvedLocale]\n );\n}\n"],"mappings":"6OAMA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAAS,GAAW,CACpB,EAAa,GAAe,CAClC,OAAO,MAEH,EAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAa,GAAe,CAC5B,EAAS,GAAW,CAC1B,OAAO,GAAc,GAAe,CAAC,oBAAoB,EAAO,CAMlE,SAAgB,GAGd,CACA,IAAM,EAAiB,GAAmB,CACpC,EAAS,EAAe,WAAW,CAEzC,MAAO,CACL,SACA,gBAHiB,EAAe,eAGL,EAAI,GAAe,CAAC,oBAAoB,EAAO,CAC3E,CAGH,SAAgB,EAAoB,EAAkC,CACpE,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgC,CACjE,IAAM,EAAgB,GAAW,CAC3B,EAAiB,GAAU,EACjC,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,mBAAmB,EAAe,CACrE,CAAC,EAAe,CACjB"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\n/**\n * Resolves the condition values shared by translation hooks once per render.\n */\nexport function useTranslationConditions(): {\n locale: string;\n shouldTranslate: boolean;\n} {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return {\n locale,\n shouldTranslate: enableI18n && getI18nConfig().requiresTranslation(locale),\n };\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {\n const currentLocale = useLocale();\n const resolvedLocale = locale ?? currentLocale;\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(resolvedLocale),\n [resolvedLocale]\n );\n}\n"],"mappings":"sNAMA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAAS,GAAW,CACpB,EAAa,GAAe,CAClC,OAAO,MAEH,EAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAa,GAAe,CAC5B,EAAS,GAAW,CAC1B,OAAO,GAAc,GAAe,CAAC,oBAAoB,EAAO,CAMlE,SAAgB,GAGd,CACA,IAAM,EAAS,GAAW,CAE1B,MAAO,CACL,SACA,gBAHiB,GAGU,EAAI,GAAe,CAAC,oBAAoB,EAAO,CAC3E,CAGH,SAAgB,EAAoB,EAAkC,CACpE,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgC,CACjE,IAAM,EAAgB,GAAW,CAC3B,EAAiB,GAAU,EACjC,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,mBAAmB,EAAe,CACrE,CAAC,EAAe,CACjB"}
package/dist/hooks.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./hooks/condition-store.cjs`),t=require(`./hooks/i18n-config.cjs`),n=require(`./hooks/utils.cjs`),r=require(`./hooks/useGT.cjs`),i=require(`./hooks/useMessages.cjs`),a=require(`./hooks/useTranslations.cjs`),o=require(`./hooks/useInternalLocaleSelector.cjs`),s=require(`./hooks/useInternalRegionSelector.cjs`);exports.useConditionStore=e.useConditionStore,exports.useCustomMapping=t.useCustomMapping,exports.useDefaultLocale=t.useDefaultLocale,exports.useEnableI18n=e.useEnableI18n,exports.useFormatLocales=n.useFormatLocales,exports.useGT=r.useGT,exports.useInternalLocaleSelector=o.useInternalLocaleSelector,exports.useInternalRegionSelector=s.useInternalRegionSelector,exports.useLocale=e.useLocale,exports.useLocaleDirection=n.useLocaleDirection,exports.useLocaleProperties=n.useLocaleProperties,exports.useLocales=t.useLocales,exports.useMessages=i.useMessages,exports.useRegion=e.useRegion,exports.useSetEnableI18n=e.useSetEnableI18n,exports.useSetLocale=e.useSetLocale,exports.useSetRegion=e.useSetRegion,exports.useTranslations=a.useTranslations;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./hooks/condition-store.cjs`),t=require(`./hooks/i18n-config.cjs`),n=require(`./hooks/utils.cjs`),r=require(`./hooks/useGT.cjs`),i=require(`./hooks/useMessages.cjs`),a=require(`./hooks/useTranslations.cjs`),o=require(`./hooks/useInternalLocaleSelector.cjs`),s=require(`./hooks/useInternalRegionSelector.cjs`);exports.useCustomMapping=t.useCustomMapping,exports.useDefaultLocale=t.useDefaultLocale,exports.useEnableI18n=e.useEnableI18n,exports.useFormatLocales=n.useFormatLocales,exports.useGT=r.useGT,exports.useInternalLocaleSelector=o.useInternalLocaleSelector,exports.useInternalRegionSelector=s.useInternalRegionSelector,exports.useLocale=e.useLocale,exports.useLocaleDirection=n.useLocaleDirection,exports.useLocaleProperties=n.useLocaleProperties,exports.useLocales=t.useLocales,exports.useMessages=i.useMessages,exports.useRegion=e.useRegion,exports.useSetEnableI18n=e.useSetEnableI18n,exports.useSetLocale=e.useSetLocale,exports.useSetRegion=e.useSetRegion,exports.useTranslations=a.useTranslations;
package/dist/hooks.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { InternalRegionSelectorOptions, InternalRegionSelectorResult, RegionData, useInternalRegionSelector } from "./hooks/useInternalRegionSelector.js";
2
- import { useConditionStore, useEnableI18n, useLocale, useRegion, useSetEnableI18n, useSetLocale, useSetRegion } from "./hooks/condition-store.js";
2
+ import { useEnableI18n, useLocale, useRegion, useSetEnableI18n, useSetLocale, useSetRegion } from "./hooks/condition-store.js";
3
3
  import { useCustomMapping, useDefaultLocale, useLocales } from "./hooks/i18n-config.js";
4
4
  import { useGT } from "./hooks/useGT.js";
5
5
  import { useMessages } from "./hooks/useMessages.js";
6
6
  import { useTranslations } from "./hooks/useTranslations.js";
7
7
  import { useFormatLocales, useLocaleDirection, useLocaleProperties } from "./hooks/utils.js";
8
8
  import { InternalLocaleSelectorResult, useInternalLocaleSelector } from "./hooks/useInternalLocaleSelector.js";
9
- export { type InternalLocaleSelectorResult, type InternalRegionSelectorOptions, type InternalRegionSelectorResult, type RegionData, useConditionStore, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
9
+ export { type InternalLocaleSelectorResult, type InternalRegionSelectorOptions, type InternalRegionSelectorResult, type RegionData, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
package/dist/hooks.mjs CHANGED
@@ -1 +1 @@
1
- import{useConditionStore as e,useEnableI18n as t,useLocale as n,useRegion as r,useSetEnableI18n as i,useSetLocale as a,useSetRegion as o}from"./hooks/condition-store.mjs";import{useCustomMapping as s,useDefaultLocale as c,useLocales as l}from"./hooks/i18n-config.mjs";import{useFormatLocales as u,useLocaleDirection as d,useLocaleProperties as f}from"./hooks/utils.mjs";import{useGT as p}from"./hooks/useGT.mjs";import{useMessages as m}from"./hooks/useMessages.mjs";import{useTranslations as h}from"./hooks/useTranslations.mjs";import{useInternalLocaleSelector as g}from"./hooks/useInternalLocaleSelector.mjs";import{useInternalRegionSelector as _}from"./hooks/useInternalRegionSelector.mjs";export{e as useConditionStore,s as useCustomMapping,c as useDefaultLocale,t as useEnableI18n,u as useFormatLocales,p as useGT,g as useInternalLocaleSelector,_ as useInternalRegionSelector,n as useLocale,d as useLocaleDirection,f as useLocaleProperties,l as useLocales,m as useMessages,r as useRegion,i as useSetEnableI18n,a as useSetLocale,o as useSetRegion,h as useTranslations};
1
+ import{useEnableI18n as e,useLocale as t,useRegion as n,useSetEnableI18n as r,useSetLocale as i,useSetRegion as a}from"./hooks/condition-store.mjs";import{useCustomMapping as o,useDefaultLocale as s,useLocales as c}from"./hooks/i18n-config.mjs";import{useFormatLocales as l,useLocaleDirection as u,useLocaleProperties as d}from"./hooks/utils.mjs";import{useGT as f}from"./hooks/useGT.mjs";import{useMessages as p}from"./hooks/useMessages.mjs";import{useTranslations as m}from"./hooks/useTranslations.mjs";import{useInternalLocaleSelector as h}from"./hooks/useInternalLocaleSelector.mjs";import{useInternalRegionSelector as g}from"./hooks/useInternalRegionSelector.mjs";export{o as useCustomMapping,s as useDefaultLocale,e as useEnableI18n,l as useFormatLocales,f as useGT,h as useInternalLocaleSelector,g as useInternalRegionSelector,t as useLocale,u as useLocaleDirection,d as useLocaleProperties,c as useLocales,p as useMessages,n as useRegion,r as useSetEnableI18n,i as useSetLocale,a as useSetRegion,m as useTranslations};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/react-core",
3
- "version": "11.4.3",
3
+ "version": "11.4.5",
4
4
  "description": "A pure React library for internationalization",
5
5
  "files": [
6
6
  "dist",
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@generaltranslation/format": "0.1.9",
15
- "generaltranslation": "9.5.0",
16
- "gt-i18n": "1.0.31"
15
+ "generaltranslation": "9.5.1",
16
+ "gt-i18n": "1.0.32"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",