@generaltranslation/react-core 11.0.7 → 11.0.9

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,25 @@
1
1
  # @generaltranslation/react-core
2
2
 
3
+ ## 11.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1852](https://github.com/generaltranslation/gt/pull/1852) [`ffa855f`](https://github.com/generaltranslation/gt/commit/ffa855fa929d1c668e75d0c27a99dc704fcb2561) Thanks [@bgub](https://github.com/bgub)! - Move the default cookie-name constants (`defaultLocaleCookieName`, `defaultRegionCookieName`, `defaultEnableI18nCookieName`, `defaultResetLocaleCookieName`) into a dependency-free module. They were co-located with `ReactI18nConfig`, so importing just a cookie name from `@generaltranslation/react-core/pure` could drag the `gt-i18n/internal` runtime (~60KB) into size-constrained bundles like gt-next's edge middleware. The `/pure` entry re-exports them unchanged.
8
+
9
+ - [#1888](https://github.com/generaltranslation/gt/pull/1888) [`b320e17`](https://github.com/generaltranslation/gt/commit/b320e176d581bfade57f0d122f7b95e8e3229cbf) Thanks [@bgub](https://github.com/bgub)! - Share condition setter hooks through react-core instead of duplicating them in the React and React Native packages.
10
+
11
+ - Updated dependencies [[`5d93858`](https://github.com/generaltranslation/gt/commit/5d9385872eb041af0991fc273d5eddd7a032e584), [`8836fbd`](https://github.com/generaltranslation/gt/commit/8836fbda088b5192b2eaa8e2109a724256458bc2), [`5721267`](https://github.com/generaltranslation/gt/commit/57212672a595c8c8578366636767bcbfe8ab6e57), [`8b9b440`](https://github.com/generaltranslation/gt/commit/8b9b4404b703b552b9aa327dc0ae85fce584c97c)]:
12
+ - generaltranslation@9.0.2
13
+ - gt-i18n@1.0.6
14
+
15
+ ## 11.0.8
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`3ad93f8`](https://github.com/generaltranslation/gt/commit/3ad93f89da099ef345b707bf37db425662d87e2a)]:
20
+ - generaltranslation@9.0.1
21
+ - gt-i18n@1.0.5
22
+
3
23
  ## 11.0.7
4
24
 
5
25
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- const e=require(`../condition-store/singleton-operations.cjs`),t=require(`../context/context.cjs`);function n(){return t.useGTContext()?.conditionStore??e.getConditionStore()}function r(){return n().getLocale()}function i(){return n().getRegion()}function a(){return n().getEnableI18n()}exports.useConditionStore=n,exports.useEnableI18n=a,exports.useLocale=r,exports.useRegion=i;
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;
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 { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core\n * Some server environments are read only, so we cannot implement these hooks.\n */\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"],"mappings":"mGASA,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"}
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,10 +1,6 @@
1
1
  import { ReadonlyConditionStoreInterface } from "gt-i18n/internal/types";
2
2
 
3
3
  //#region src/hooks/condition-store.d.ts
4
- /**
5
- * NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core
6
- * Some server environments are read only, so we cannot implement these hooks.
7
- */
8
4
  declare function useConditionStore(): ReadonlyConditionStoreInterface;
9
5
  /**
10
6
  * Returns the current locale.
@@ -18,6 +14,9 @@ declare function useRegion(): string | undefined;
18
14
  * Returns the current enableI18n flag.
19
15
  */
20
16
  declare function useEnableI18n(): boolean;
17
+ declare function useSetLocale(): (locale: string) => void;
18
+ declare function useSetRegion(): (region: string | undefined) => void;
19
+ declare function useSetEnableI18n(): (enabled: boolean) => void;
21
20
  //#endregion
22
- export { useConditionStore, useEnableI18n, useLocale, useRegion };
21
+ export { useConditionStore, useEnableI18n, useLocale, useRegion, useSetEnableI18n, useSetLocale, useSetRegion };
23
22
  //# sourceMappingURL=condition-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"condition-store.d.ts","names":[],"sources":["../../src/hooks/condition-store.ts"],"mappings":";;;;;AASA;;iBAAgB,iBAAA,CAAA,GAAqB,+BAAA;;;AAQrC;iBAAgB,SAAA,CAAA;;;;iBAOA,SAAA,CAAA;;;;iBAOA,aAAA,CAAA"}
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,2 +1,2 @@
1
- import{getConditionStore as e}from"../condition-store/singleton-operations.mjs";import{useGTContext as t}from"../context/context.mjs";function n(){return t()?.conditionStore??e()}function r(){return n().getLocale()}function i(){return n().getRegion()}function a(){return n().getEnableI18n()}export{n as useConditionStore,a as useEnableI18n,r as useLocale,i as useRegion};
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};
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 { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core\n * Some server environments are read only, so we cannot implement these hooks.\n */\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"],"mappings":"sIASA,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"}
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"}
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.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.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;
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 } from "./hooks/condition-store.js";
2
+ import { useConditionStore, 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, useTranslations };
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 };
package/dist/hooks.mjs CHANGED
@@ -1 +1 @@
1
- import{useConditionStore as e,useEnableI18n as t,useLocale as n,useRegion as r}from"./hooks/condition-store.mjs";import{useCustomMapping as i,useDefaultLocale as a,useLocales as o}from"./hooks/i18n-config.mjs";import{useFormatLocales as s,useLocaleDirection as c,useLocaleProperties as l}from"./hooks/utils.mjs";import{useGT as u}from"./hooks/useGT.mjs";import{useMessages as d}from"./hooks/useMessages.mjs";import{useTranslations as f}from"./hooks/useTranslations.mjs";import{useInternalLocaleSelector as p}from"./hooks/useInternalLocaleSelector.mjs";import{useInternalRegionSelector as m}from"./hooks/useInternalRegionSelector.mjs";export{e as useConditionStore,i as useCustomMapping,a as useDefaultLocale,t as useEnableI18n,s as useFormatLocales,u as useGT,p as useInternalLocaleSelector,m as useInternalRegionSelector,n as useLocale,c as useLocaleDirection,l as useLocaleProperties,o as useLocales,d as useMessages,r as useRegion,f as useTranslations};
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};
package/dist/pure.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./hooks/utils/getFormatLocales.cjs`),t=require(`./i18n-cache/singleton-operations.cjs`),n=require(`./functions/helpers/getTranslationsSnapshot.cjs`),r=require(`./setup/i18nConfig.cjs`),i=require(`./condition-store/singleton-operations.cjs`),a=require(`./functions/translation/t.cjs`),o=require(`./utils/rendering/createRenderPipeline.cjs`),s=require(`./utils/rendering/getDefaultRenderSettings.cjs`),c=require(`./i18n-cache/ReactI18nCache.cjs`),l=require(`./setup/initializeGTSRA.cjs`),u=require(`./i18n-store/singleton-operations.cjs`),d=require(`./i18n-store/I18nStore.cjs`);let f=require(`gt-i18n`),p=require(`gt-i18n/internal`);exports.I18nStore=d.I18nStore,exports.ReactI18nCache=c.ReactI18nCache,Object.defineProperty(exports,`ReadonlyConditionStore`,{enumerable:!0,get:function(){return p.ReadonlyConditionStore}}),exports.createRenderPipeline=o.createRenderPipeline,Object.defineProperty(exports,`declareVar`,{enumerable:!0,get:function(){return f.declareVar}}),Object.defineProperty(exports,`decodeMsg`,{enumerable:!0,get:function(){return f.decodeMsg}}),Object.defineProperty(exports,`decodeOptions`,{enumerable:!0,get:function(){return f.decodeOptions}}),Object.defineProperty(exports,`decodeVars`,{enumerable:!0,get:function(){return f.decodeVars}}),exports.defaultEnableI18nCookieName=r.defaultEnableI18nCookieName,exports.defaultLocaleCookieName=r.defaultLocaleCookieName,exports.defaultRegionCookieName=r.defaultRegionCookieName,exports.defaultResetLocaleCookieName=r.defaultResetLocaleCookieName,Object.defineProperty(exports,`derive`,{enumerable:!0,get:function(){return f.derive}}),Object.defineProperty(exports,`getDefaultLocale`,{enumerable:!0,get:function(){return f.getDefaultLocale}}),exports.getDefaultRenderSettings=s.getDefaultRenderSettings,exports.getFormatLocales=e.getFormatLocales,exports.getI18nConfig=r.getI18nConfig,Object.defineProperty(exports,`getLocaleProperties`,{enumerable:!0,get:function(){return f.getLocaleProperties}}),Object.defineProperty(exports,`getLocales`,{enumerable:!0,get:function(){return f.getLocales}}),exports.getReactI18nCache=t.getReactI18nCache,exports.getReadonlyConditionStore=i.getConditionStore,exports.getTranslationsSnapshot=n.getTranslationsSnapshot,Object.defineProperty(exports,`getVersionId`,{enumerable:!0,get:function(){return f.getVersionId}}),Object.defineProperty(exports,`gtFallback`,{enumerable:!0,get:function(){return f.gtFallback}}),exports.initializeI18nConfig=r.initializeI18nConfig,exports.internalInitializeGTSRA=l.internalInitializeGTSRA,Object.defineProperty(exports,`mFallback`,{enumerable:!0,get:function(){return f.mFallback}}),Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return f.msg}}),Object.defineProperty(exports,`resolveCanonicalLocale`,{enumerable:!0,get:function(){return f.resolveCanonicalLocale}}),exports.setI18nStore=u.setI18nStore,exports.setReactI18nCache=t.setReactI18nCache,exports.t=a.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./hooks/utils/getFormatLocales.cjs`),t=require(`./i18n-cache/singleton-operations.cjs`),n=require(`./functions/helpers/getTranslationsSnapshot.cjs`),r=require(`./setup/cookieNames.cjs`),i=require(`./setup/i18nConfig.cjs`),a=require(`./condition-store/singleton-operations.cjs`),o=require(`./functions/translation/t.cjs`),s=require(`./utils/rendering/createRenderPipeline.cjs`),c=require(`./utils/rendering/getDefaultRenderSettings.cjs`),l=require(`./i18n-cache/ReactI18nCache.cjs`),u=require(`./setup/initializeGTSRA.cjs`),d=require(`./i18n-store/singleton-operations.cjs`),f=require(`./i18n-store/I18nStore.cjs`);let p=require(`gt-i18n`),m=require(`gt-i18n/internal`);exports.I18nStore=f.I18nStore,exports.ReactI18nCache=l.ReactI18nCache,Object.defineProperty(exports,`ReadonlyConditionStore`,{enumerable:!0,get:function(){return m.ReadonlyConditionStore}}),exports.createRenderPipeline=s.createRenderPipeline,Object.defineProperty(exports,`declareVar`,{enumerable:!0,get:function(){return p.declareVar}}),Object.defineProperty(exports,`decodeMsg`,{enumerable:!0,get:function(){return p.decodeMsg}}),Object.defineProperty(exports,`decodeOptions`,{enumerable:!0,get:function(){return p.decodeOptions}}),Object.defineProperty(exports,`decodeVars`,{enumerable:!0,get:function(){return p.decodeVars}}),exports.defaultEnableI18nCookieName=r.defaultEnableI18nCookieName,exports.defaultLocaleCookieName=r.defaultLocaleCookieName,exports.defaultRegionCookieName=r.defaultRegionCookieName,exports.defaultResetLocaleCookieName=r.defaultResetLocaleCookieName,Object.defineProperty(exports,`derive`,{enumerable:!0,get:function(){return p.derive}}),Object.defineProperty(exports,`getDefaultLocale`,{enumerable:!0,get:function(){return p.getDefaultLocale}}),exports.getDefaultRenderSettings=c.getDefaultRenderSettings,exports.getFormatLocales=e.getFormatLocales,exports.getI18nConfig=i.getI18nConfig,Object.defineProperty(exports,`getLocaleProperties`,{enumerable:!0,get:function(){return p.getLocaleProperties}}),Object.defineProperty(exports,`getLocales`,{enumerable:!0,get:function(){return p.getLocales}}),exports.getReactI18nCache=t.getReactI18nCache,exports.getReadonlyConditionStore=a.getConditionStore,exports.getTranslationsSnapshot=n.getTranslationsSnapshot,Object.defineProperty(exports,`getVersionId`,{enumerable:!0,get:function(){return p.getVersionId}}),Object.defineProperty(exports,`gtFallback`,{enumerable:!0,get:function(){return p.gtFallback}}),exports.initializeI18nConfig=i.initializeI18nConfig,exports.internalInitializeGTSRA=u.internalInitializeGTSRA,Object.defineProperty(exports,`mFallback`,{enumerable:!0,get:function(){return p.mFallback}}),Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return p.msg}}),Object.defineProperty(exports,`resolveCanonicalLocale`,{enumerable:!0,get:function(){return p.resolveCanonicalLocale}}),exports.setI18nStore=d.setI18nStore,exports.setReactI18nCache=t.setReactI18nCache,exports.t=o.t;
package/dist/pure.d.ts CHANGED
@@ -6,8 +6,9 @@ import { getFormatLocales } from "./hooks/utils/getFormatLocales.js";
6
6
  import { RenderPipeline, createRenderPipeline } from "./utils/rendering/createRenderPipeline.js";
7
7
  import { ReactI18nCache, ReactI18nCacheParams } from "./i18n-cache/ReactI18nCache.js";
8
8
  import { getReactI18nCache, setReactI18nCache } from "./i18n-cache/singleton-operations.js";
9
- import { ReactI18nConfigParams, defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, defaultResetLocaleCookieName, getI18nConfig, initializeI18nConfig } from "./setup/i18nConfig.js";
9
+ import { defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, defaultResetLocaleCookieName } from "./setup/cookieNames.js";
10
10
  import { getDefaultRenderSettings } from "./utils/rendering/getDefaultRenderSettings.js";
11
+ import { ReactI18nConfigParams, getI18nConfig, initializeI18nConfig } from "./setup/i18nConfig.js";
11
12
  import { internalInitializeGTSRA } from "./setup/initializeGTSRA.js";
12
13
  import { I18nStore } from "./i18n-store/I18nStore.js";
13
14
  import { setI18nStore } from "./i18n-store/singleton-operations.js";
package/dist/pure.mjs CHANGED
@@ -1 +1 @@
1
- import{getFormatLocales as e}from"./hooks/utils/getFormatLocales.mjs";import{getReactI18nCache as t,setReactI18nCache as n}from"./i18n-cache/singleton-operations.mjs";import{getTranslationsSnapshot as r}from"./functions/helpers/getTranslationsSnapshot.mjs";import{defaultEnableI18nCookieName as i,defaultLocaleCookieName as a,defaultRegionCookieName as o,defaultResetLocaleCookieName as s,getI18nConfig as c,initializeI18nConfig as l}from"./setup/i18nConfig.mjs";import{getConditionStore as u}from"./condition-store/singleton-operations.mjs";import{t as d}from"./functions/translation/t.mjs";import{createRenderPipeline as f}from"./utils/rendering/createRenderPipeline.mjs";import{getDefaultRenderSettings as p}from"./utils/rendering/getDefaultRenderSettings.mjs";import{ReactI18nCache as m}from"./i18n-cache/ReactI18nCache.mjs";import{internalInitializeGTSRA as h}from"./setup/initializeGTSRA.mjs";import{setI18nStore as g}from"./i18n-store/singleton-operations.mjs";import{I18nStore as _}from"./i18n-store/I18nStore.mjs";import{declareVar as v,decodeMsg as y,decodeOptions as b,decodeVars as x,derive as S,getDefaultLocale as C,getLocaleProperties as w,getLocales as T,getVersionId as E,gtFallback as D,mFallback as O,msg as k,resolveCanonicalLocale as A}from"gt-i18n";import{ReadonlyConditionStore as j}from"gt-i18n/internal";export{_ as I18nStore,m as ReactI18nCache,j as ReadonlyConditionStore,f as createRenderPipeline,v as declareVar,y as decodeMsg,b as decodeOptions,x as decodeVars,i as defaultEnableI18nCookieName,a as defaultLocaleCookieName,o as defaultRegionCookieName,s as defaultResetLocaleCookieName,S as derive,C as getDefaultLocale,p as getDefaultRenderSettings,e as getFormatLocales,c as getI18nConfig,w as getLocaleProperties,T as getLocales,t as getReactI18nCache,u as getReadonlyConditionStore,r as getTranslationsSnapshot,E as getVersionId,D as gtFallback,l as initializeI18nConfig,h as internalInitializeGTSRA,O as mFallback,k as msg,A as resolveCanonicalLocale,g as setI18nStore,n as setReactI18nCache,d as t};
1
+ import{getFormatLocales as e}from"./hooks/utils/getFormatLocales.mjs";import{getReactI18nCache as t,setReactI18nCache as n}from"./i18n-cache/singleton-operations.mjs";import{getTranslationsSnapshot as r}from"./functions/helpers/getTranslationsSnapshot.mjs";import{defaultEnableI18nCookieName as i,defaultLocaleCookieName as a,defaultRegionCookieName as o,defaultResetLocaleCookieName as s}from"./setup/cookieNames.mjs";import{getI18nConfig as c,initializeI18nConfig as l}from"./setup/i18nConfig.mjs";import{getConditionStore as u}from"./condition-store/singleton-operations.mjs";import{t as d}from"./functions/translation/t.mjs";import{createRenderPipeline as f}from"./utils/rendering/createRenderPipeline.mjs";import{getDefaultRenderSettings as p}from"./utils/rendering/getDefaultRenderSettings.mjs";import{ReactI18nCache as m}from"./i18n-cache/ReactI18nCache.mjs";import{internalInitializeGTSRA as h}from"./setup/initializeGTSRA.mjs";import{setI18nStore as g}from"./i18n-store/singleton-operations.mjs";import{I18nStore as _}from"./i18n-store/I18nStore.mjs";import{declareVar as v,decodeMsg as y,decodeOptions as b,decodeVars as x,derive as S,getDefaultLocale as C,getLocaleProperties as w,getLocales as T,getVersionId as E,gtFallback as D,mFallback as O,msg as k,resolveCanonicalLocale as A}from"gt-i18n";import{ReadonlyConditionStore as j}from"gt-i18n/internal";export{_ as I18nStore,m as ReactI18nCache,j as ReadonlyConditionStore,f as createRenderPipeline,v as declareVar,y as decodeMsg,b as decodeOptions,x as decodeVars,i as defaultEnableI18nCookieName,a as defaultLocaleCookieName,o as defaultRegionCookieName,s as defaultResetLocaleCookieName,S as derive,C as getDefaultLocale,p as getDefaultRenderSettings,e as getFormatLocales,c as getI18nConfig,w as getLocaleProperties,T as getLocales,t as getReactI18nCache,u as getReadonlyConditionStore,r as getTranslationsSnapshot,E as getVersionId,D as gtFallback,l as initializeI18nConfig,h as internalInitializeGTSRA,O as mFallback,k as msg,A as resolveCanonicalLocale,g as setI18nStore,n as setReactI18nCache,d as t};
@@ -0,0 +1,2 @@
1
+ exports.defaultEnableI18nCookieName=`generaltranslation.enable-i18n`,exports.defaultLocaleCookieName=`generaltranslation.locale`,exports.defaultRegionCookieName=`generaltranslation.region`,exports.defaultResetLocaleCookieName=`generaltranslation.locale-reset`;
2
+ //# sourceMappingURL=cookieNames.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookieNames.cjs","names":[],"sources":["../../src/setup/cookieNames.ts"],"sourcesContent":["// Dependency-free module: these constants are imported by size-constrained\n// consumers (e.g. gt-next's edge middleware), which must not pull in the\n// ReactI18nConfig class or its gt-i18n imports.\n\n/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n\n/**\n * Cookie name for tracking the locale reset.\n */\nexport const defaultResetLocaleCookieName = 'generaltranslation.locale-reset';\n"],"mappings":""}
@@ -0,0 +1,20 @@
1
+ //#region src/setup/cookieNames.d.ts
2
+ /**
3
+ * Cookie name for tracking the user's selected locale.
4
+ */
5
+ declare const defaultLocaleCookieName = "generaltranslation.locale";
6
+ /**
7
+ * Cookie name for tracking the user's selected region.
8
+ */
9
+ declare const defaultRegionCookieName = "generaltranslation.region";
10
+ /**
11
+ * Cookie name for persisting the enableI18n feature flag.
12
+ */
13
+ declare const defaultEnableI18nCookieName = "generaltranslation.enable-i18n";
14
+ /**
15
+ * Cookie name for tracking the locale reset.
16
+ */
17
+ declare const defaultResetLocaleCookieName = "generaltranslation.locale-reset";
18
+ //#endregion
19
+ export { defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, defaultResetLocaleCookieName };
20
+ //# sourceMappingURL=cookieNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookieNames.d.ts","names":[],"sources":["../../src/setup/cookieNames.ts"],"mappings":";;AAOA;;cAAa,uBAAA;;;AAKb;cAAa,uBAAA;;;;cAKA,2BAAA;;;;cAKA,4BAAA"}
@@ -0,0 +1,2 @@
1
+ const e=`generaltranslation.locale`,t=`generaltranslation.region`,n=`generaltranslation.enable-i18n`,r=`generaltranslation.locale-reset`;export{n as defaultEnableI18nCookieName,e as defaultLocaleCookieName,t as defaultRegionCookieName,r as defaultResetLocaleCookieName};
2
+ //# sourceMappingURL=cookieNames.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookieNames.mjs","names":[],"sources":["../../src/setup/cookieNames.ts"],"sourcesContent":["// Dependency-free module: these constants are imported by size-constrained\n// consumers (e.g. gt-next's edge middleware), which must not pull in the\n// ReactI18nConfig class or its gt-i18n imports.\n\n/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n\n/**\n * Cookie name for tracking the locale reset.\n */\nexport const defaultResetLocaleCookieName = 'generaltranslation.locale-reset';\n"],"mappings":"AAOA,MAAa,EAA0B,4BAK1B,EAA0B,4BAK1B,EAA8B,iCAK9B,EAA+B"}
@@ -1,2 +1,2 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`gt-i18n/internal`),t=require(`generaltranslation/internal`);const n=`server-render`,r=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var i=class extends e.I18nConfig{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=n){super(e),c(t),Object.defineProperty(this,r,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??`generaltranslation.locale`,this.regionCookieName=e.regionCookieName??`generaltranslation.region`,this.enableI18nCookieName=e.enableI18nCookieName??`generaltranslation.enable-i18n`}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function a(){let n=(0,e.getI18nConfig)();if(l(n))return n;throw Error((0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function o(t){(0,e.setI18nConfig)(t)}function s(e={},t=n){let r=new i(e,t);return o(r),r}function c(e){if(!(e===`SPA`||e===`server-render`))throw Error((0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function l(e){if(e instanceof i)return!0;let t=e;return t[r]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}exports.defaultEnableI18nCookieName=`generaltranslation.enable-i18n`,exports.defaultLocaleCookieName=`generaltranslation.locale`,exports.defaultRegionCookieName=`generaltranslation.region`,exports.defaultResetLocaleCookieName=`generaltranslation.locale-reset`,exports.getI18nConfig=a,exports.initializeI18nConfig=s;
1
+ require(`../_virtual/_rolldown/runtime.cjs`),require(`./cookieNames.cjs`);let e=require(`gt-i18n/internal`),t=require(`generaltranslation/internal`);const n=`server-render`,r=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var i=class extends e.I18nConfig{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=n){super(e),c(t),Object.defineProperty(this,r,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??`generaltranslation.locale`,this.regionCookieName=e.regionCookieName??`generaltranslation.region`,this.enableI18nCookieName=e.enableI18nCookieName??`generaltranslation.enable-i18n`}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function a(){let n=(0,e.getI18nConfig)();if(l(n))return n;throw Error((0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function o(t){(0,e.setI18nConfig)(t)}function s(e={},t=n){let r=new i(e,t);return o(r),r}function c(e){if(!(e===`SPA`||e===`server-render`))throw Error((0,t.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function l(e){if(e instanceof i)return!0;let t=e;return t[r]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}exports.getI18nConfig=a,exports.initializeI18nConfig=s;
2
2
  //# sourceMappingURL=i18nConfig.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18nConfig.cjs","names":["I18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams as BaseI18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n\n/**\n * Cookie name for tracking the locale reset.\n */\nexport const defaultResetLocaleCookieName = 'generaltranslation.locale-reset';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\ntype CookieNameConfig = {\n localeCookieName?: string;\n regionCookieName?: string;\n enableI18nCookieName?: string;\n};\n\nexport type ReactI18nConfigParams = BaseI18nConfigParams & CookieNameConfig;\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n private localeCookieName: string;\n private regionCookieName: string;\n private enableI18nCookieName: string;\n\n constructor(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n this.localeCookieName = params.localeCookieName ?? defaultLocaleCookieName;\n this.regionCookieName = params.regionCookieName ?? defaultRegionCookieName;\n this.enableI18nCookieName =\n params.enableI18nCookieName ?? defaultEnableI18nCookieName;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getRegionCookieName(): string {\n return this.regionCookieName;\n }\n\n getEnableI18nCookieName(): string {\n return this.enableI18nCookieName;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function' &&\n typeof maybeReactI18nConfig.getLocaleCookieName === 'function' &&\n typeof maybeReactI18nConfig.getRegionCookieName === 'function' &&\n typeof maybeReactI18nConfig.getEnableI18nCookieName === 'function'\n );\n}\n"],"mappings":"wHAWA,MAgCM,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqCA,EAAAA,UAAW,CAC9C,eACA,iBACA,iBACA,qBAEA,YACE,EAAgC,EAAE,CAClC,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EACtB,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,qBACH,EAAO,sBAAA,iCAGX,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,uBAIhB,SAAgB,GAAiC,CAC/C,IAAM,GAAA,EAAA,EAAA,gBAAgC,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgB,EAAc,EAAuC,EACnE,EAAA,EAAA,eAAkB,EAAe,CAGnC,SAAgB,EACd,EAAgC,EAAE,CAClC,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB,YAClD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,yBAA4B"}
1
+ {"version":3,"file":"i18nConfig.cjs","names":["I18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams as BaseI18nConfigParams } from 'gt-i18n/internal/types';\nimport {\n defaultEnableI18nCookieName,\n defaultLocaleCookieName,\n defaultRegionCookieName,\n} from './cookieNames';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\ntype CookieNameConfig = {\n localeCookieName?: string;\n regionCookieName?: string;\n enableI18nCookieName?: string;\n};\n\nexport type ReactI18nConfigParams = BaseI18nConfigParams & CookieNameConfig;\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n private localeCookieName: string;\n private regionCookieName: string;\n private enableI18nCookieName: string;\n\n constructor(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n this.localeCookieName = params.localeCookieName ?? defaultLocaleCookieName;\n this.regionCookieName = params.regionCookieName ?? defaultRegionCookieName;\n this.enableI18nCookieName =\n params.enableI18nCookieName ?? defaultEnableI18nCookieName;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getRegionCookieName(): string {\n return this.regionCookieName;\n }\n\n getEnableI18nCookieName(): string {\n return this.enableI18nCookieName;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function' &&\n typeof maybeReactI18nConfig.getLocaleCookieName === 'function' &&\n typeof maybeReactI18nConfig.getRegionCookieName === 'function' &&\n typeof maybeReactI18nConfig.getEnableI18nCookieName === 'function'\n );\n}\n"],"mappings":"qJA4BA,MAAM,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqCA,EAAAA,UAAW,CAC9C,eACA,iBACA,iBACA,qBAEA,YACE,EAAgC,EAAE,CAClC,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EACtB,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,qBACH,EAAO,sBAAA,iCAGX,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,uBAIhB,SAAgB,GAAiC,CAC/C,IAAM,GAAA,EAAA,EAAA,gBAAgC,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgB,EAAc,EAAuC,EACnE,EAAA,EAAA,eAAkB,EAAe,CAGnC,SAAgB,EACd,EAAgC,EAAE,CAClC,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB,YAClD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,yBAA4B"}
@@ -2,22 +2,6 @@ import { I18nConfigParams } from "gt-i18n/internal/types";
2
2
  import { I18nConfig } from "gt-i18n/internal";
3
3
 
4
4
  //#region src/setup/i18nConfig.d.ts
5
- /**
6
- * Cookie name for tracking the user's selected locale.
7
- */
8
- declare const defaultLocaleCookieName = "generaltranslation.locale";
9
- /**
10
- * Cookie name for tracking the user's selected region.
11
- */
12
- declare const defaultRegionCookieName = "generaltranslation.region";
13
- /**
14
- * Cookie name for persisting the enableI18n feature flag.
15
- */
16
- declare const defaultEnableI18nCookieName = "generaltranslation.enable-i18n";
17
- /**
18
- * Cookie name for tracking the locale reset.
19
- */
20
- declare const defaultResetLocaleCookieName = "generaltranslation.locale-reset";
21
5
  /**
22
6
  * Helps us distinguish behavior for SPA vs server-rendered apps.
23
7
  * - server-rendered apps must use context
@@ -44,5 +28,5 @@ declare class ReactI18nConfig extends I18nConfig {
44
28
  declare function getI18nConfig(): ReactI18nConfig;
45
29
  declare function initializeI18nConfig(params?: ReactI18nConfigParams, renderStrategy?: RenderStrategy): ReactI18nConfig;
46
30
  //#endregion
47
- export { ReactI18nConfigParams, defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, defaultResetLocaleCookieName, getI18nConfig, initializeI18nConfig };
31
+ export { ReactI18nConfigParams, getI18nConfig, initializeI18nConfig };
48
32
  //# sourceMappingURL=i18nConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18nConfig.d.ts","names":[],"sources":["../../src/setup/i18nConfig.ts"],"mappings":";;;;;;AAWA;cAAa,uBAAA;;;;cAKA,uBAAA;;;;cAKA,2BAAA;AAAb;;;AAAA,cAKa,4BAAA;;AAAb;;;;KAOY,cAAA;AAAA,KAEP,gBAAA;EACH,gBAAA;EACA,gBAAA;EACA,oBAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,gBAAA,GAAuB,gBAAA;AAAA,cAO9C,eAAA,SAAwB,UAAA;EAAA,QAC3B,cAAA;EAAA,QACA,gBAAA;EAAA,QACA,gBAAA;EAAA,QACA,oBAAA;cAGN,MAAA,GAAQ,qBAAA,EACR,cAAA,GAAgB,cAAA;EAYlB,iBAAA,CAAA,GAAqB,cAAA;EAIrB,mBAAA,CAAA;EAIA,mBAAA,CAAA;EAIA,uBAAA,CAAA;AAAA;AAAA,iBAKc,aAAA,CAAA,GAAiB,eAAA;AAAA,iBAoBjB,oBAAA,CACd,MAAA,GAAQ,qBAAA,EACR,cAAA,GAAgB,cAAA,GACf,eAAA"}
1
+ {"version":3,"file":"i18nConfig.d.ts","names":[],"sources":["../../src/setup/i18nConfig.ts"],"mappings":";;;;;;AAkBA;;;KAAY,cAAA;AAAA,KAEP,gBAAA;EACH,gBAAA;EACA,gBAAA;EACA,oBAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,gBAAA,GAAuB,gBAAA;AAAA,cAO9C,eAAA,SAAwB,UAAA;EAAA,QAC3B,cAAA;EAAA,QACA,gBAAA;EAAA,QACA,gBAAA;EAAA,QACA,oBAAA;cAGN,MAAA,GAAQ,qBAAA,EACR,cAAA,GAAgB,cAAA;EAYlB,iBAAA,CAAA,GAAqB,cAAA;EAIrB,mBAAA,CAAA;EAIA,mBAAA,CAAA;EAIA,uBAAA,CAAA;AAAA;AAAA,iBAKc,aAAA,CAAA,GAAiB,eAAA;AAAA,iBAoBjB,oBAAA,CACd,MAAA,GAAQ,qBAAA,EACR,cAAA,GAAgB,cAAA,GACf,eAAA"}
@@ -1,2 +1,2 @@
1
- import{I18nConfig as e,getI18nConfig as t,setI18nConfig as n}from"gt-i18n/internal";import{createDiagnosticMessage as r}from"generaltranslation/internal";const i=`generaltranslation.locale`,a=`generaltranslation.region`,o=`generaltranslation.enable-i18n`,s=`generaltranslation.locale-reset`,c=`server-render`,l=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var u=class extends e{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=c){super(e),m(t),Object.defineProperty(this,l,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??`generaltranslation.locale`,this.regionCookieName=e.regionCookieName??`generaltranslation.region`,this.enableI18nCookieName=e.enableI18nCookieName??`generaltranslation.enable-i18n`}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function d(){let e=t();if(h(e))return e;throw Error(r({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function f(e){n(e)}function p(e={},t=c){let n=new u(e,t);return f(n),n}function m(e){if(!(e===`SPA`||e===`server-render`))throw Error(r({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function h(e){if(e instanceof u)return!0;let t=e;return t[l]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}export{o as defaultEnableI18nCookieName,i as defaultLocaleCookieName,a as defaultRegionCookieName,s as defaultResetLocaleCookieName,d as getI18nConfig,p as initializeI18nConfig};
1
+ import"./cookieNames.mjs";import{I18nConfig as e,getI18nConfig as t,setI18nConfig as n}from"gt-i18n/internal";import{createDiagnosticMessage as r}from"generaltranslation/internal";const i=`server-render`,a=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var o=class extends e{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=i){super(e),u(t),Object.defineProperty(this,a,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??`generaltranslation.locale`,this.regionCookieName=e.regionCookieName??`generaltranslation.region`,this.enableI18nCookieName=e.enableI18nCookieName??`generaltranslation.enable-i18n`}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function s(){let e=t();if(d(e))return e;throw Error(r({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function c(e){n(e)}function l(e={},t=i){let n=new o(e,t);return c(n),n}function u(e){if(!(e===`SPA`||e===`server-render`))throw Error(r({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function d(e){if(e instanceof o)return!0;let t=e;return t[a]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}export{s as getI18nConfig,l as initializeI18nConfig};
2
2
  //# sourceMappingURL=i18nConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18nConfig.mjs","names":["getI18nConfig","getBaseI18nConfig","setI18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams as BaseI18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n\n/**\n * Cookie name for tracking the locale reset.\n */\nexport const defaultResetLocaleCookieName = 'generaltranslation.locale-reset';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\ntype CookieNameConfig = {\n localeCookieName?: string;\n regionCookieName?: string;\n enableI18nCookieName?: string;\n};\n\nexport type ReactI18nConfigParams = BaseI18nConfigParams & CookieNameConfig;\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n private localeCookieName: string;\n private regionCookieName: string;\n private enableI18nCookieName: string;\n\n constructor(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n this.localeCookieName = params.localeCookieName ?? defaultLocaleCookieName;\n this.regionCookieName = params.regionCookieName ?? defaultRegionCookieName;\n this.enableI18nCookieName =\n params.enableI18nCookieName ?? defaultEnableI18nCookieName;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getRegionCookieName(): string {\n return this.regionCookieName;\n }\n\n getEnableI18nCookieName(): string {\n return this.enableI18nCookieName;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function' &&\n typeof maybeReactI18nConfig.getLocaleCookieName === 'function' &&\n typeof maybeReactI18nConfig.getRegionCookieName === 'function' &&\n typeof maybeReactI18nConfig.getEnableI18nCookieName === 'function'\n );\n}\n"],"mappings":"0JAWA,MAAa,EAA0B,4BAK1B,EAA0B,4BAK1B,EAA8B,iCAK9B,EAA+B,kCAiBtC,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqC,CAAW,CAC9C,eACA,iBACA,iBACA,qBAEA,YACE,EAAgC,EAAE,CAClC,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EACtB,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,qBACH,EAAO,sBAAA,iCAGX,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,uBAIhB,SAAgBA,GAAiC,CAC/C,IAAM,EAAaC,GAAmB,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgBC,EAAc,EAAuC,CACnE,EAAkB,EAAe,CAGnC,SAAgB,EACd,EAAgC,EAAE,CAClC,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB,YAClD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,yBAA4B"}
1
+ {"version":3,"file":"i18nConfig.mjs","names":["getI18nConfig","getBaseI18nConfig","setI18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams as BaseI18nConfigParams } from 'gt-i18n/internal/types';\nimport {\n defaultEnableI18nCookieName,\n defaultLocaleCookieName,\n defaultRegionCookieName,\n} from './cookieNames';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\ntype CookieNameConfig = {\n localeCookieName?: string;\n regionCookieName?: string;\n enableI18nCookieName?: string;\n};\n\nexport type ReactI18nConfigParams = BaseI18nConfigParams & CookieNameConfig;\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n private localeCookieName: string;\n private regionCookieName: string;\n private enableI18nCookieName: string;\n\n constructor(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n this.localeCookieName = params.localeCookieName ?? defaultLocaleCookieName;\n this.regionCookieName = params.regionCookieName ?? defaultRegionCookieName;\n this.enableI18nCookieName =\n params.enableI18nCookieName ?? defaultEnableI18nCookieName;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getRegionCookieName(): string {\n return this.regionCookieName;\n }\n\n getEnableI18nCookieName(): string {\n return this.enableI18nCookieName;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: ReactI18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function' &&\n typeof maybeReactI18nConfig.getLocaleCookieName === 'function' &&\n typeof maybeReactI18nConfig.getRegionCookieName === 'function' &&\n typeof maybeReactI18nConfig.getEnableI18nCookieName === 'function'\n );\n}\n"],"mappings":"oLA4BA,MAAM,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqC,CAAW,CAC9C,eACA,iBACA,iBACA,qBAEA,YACE,EAAgC,EAAE,CAClC,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EACtB,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,iBAAmB,EAAO,kBAAA,4BAC/B,KAAK,qBACH,EAAO,sBAAA,iCAGX,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,uBAIhB,SAAgBA,GAAiC,CAC/C,IAAM,EAAaC,GAAmB,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgBC,EAAc,EAAuC,CACnE,EAAkB,EAAe,CAGnC,SAAgB,EACd,EAAgC,EAAE,CAClC,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB,YAClD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,qBAAwB,YACpD,OAAO,EAAqB,yBAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/react-core",
3
- "version": "11.0.7",
3
+ "version": "11.0.9",
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.2",
15
- "generaltranslation": "9.0.0",
16
- "gt-i18n": "1.0.4"
15
+ "gt-i18n": "1.0.6",
16
+ "generaltranslation": "9.0.2"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",