@generaltranslation/react-core 11.1.5 → 11.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/translation/T.cjs +1 -1
  3. package/dist/components/translation/T.cjs.map +1 -1
  4. package/dist/components/translation/T.mjs +1 -1
  5. package/dist/components/translation/T.mjs.map +1 -1
  6. package/dist/components/translation/T.rsc.cjs +1 -1
  7. package/dist/components/translation/T.rsc.cjs.map +1 -1
  8. package/dist/components/translation/T.rsc.mjs +1 -1
  9. package/dist/components/translation/T.rsc.mjs.map +1 -1
  10. package/dist/components/translation/Tx.rsc.cjs +1 -1
  11. package/dist/components/translation/Tx.rsc.cjs.map +1 -1
  12. package/dist/components/translation/Tx.rsc.mjs +1 -1
  13. package/dist/components/translation/Tx.rsc.mjs.map +1 -1
  14. package/dist/setup/i18nConfig.cjs +1 -1
  15. package/dist/setup/i18nConfig.cjs.map +1 -1
  16. package/dist/setup/i18nConfig.d.ts +5 -0
  17. package/dist/setup/i18nConfig.d.ts.map +1 -1
  18. package/dist/setup/i18nConfig.mjs +1 -1
  19. package/dist/setup/i18nConfig.mjs.map +1 -1
  20. package/dist/utils/rendering/renderPreparedT.shared.cjs +1 -1
  21. package/dist/utils/rendering/renderPreparedT.shared.cjs.map +1 -1
  22. package/dist/utils/rendering/renderPreparedT.shared.d.ts +1 -0
  23. package/dist/utils/rendering/renderPreparedT.shared.d.ts.map +1 -1
  24. package/dist/utils/rendering/renderPreparedT.shared.mjs +1 -1
  25. package/dist/utils/rendering/renderPreparedT.shared.mjs.map +1 -1
  26. package/dist/utils/translation/prepareT.shared.cjs +1 -1
  27. package/dist/utils/translation/prepareT.shared.cjs.map +1 -1
  28. package/dist/utils/translation/prepareT.shared.d.ts.map +1 -1
  29. package/dist/utils/translation/prepareT.shared.mjs +1 -1
  30. package/dist/utils/translation/prepareT.shared.mjs.map +1 -1
  31. package/dist/utils/translation/resolveTagHash.cjs +2 -0
  32. package/dist/utils/translation/resolveTagHash.cjs.map +1 -0
  33. package/dist/utils/translation/resolveTagHash.mjs +2 -0
  34. package/dist/utils/translation/resolveTagHash.mjs.map +1 -0
  35. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @generaltranslation/react-core
2
2
 
3
+ ## 11.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2017](https://github.com/generaltranslation/gt/pull/2017) [`b00b93e`](https://github.com/generaltranslation/gt/commit/b00b93eb3b830b8528ef3dbd5f503ff76d1b338a) Thanks [@logflash](https://github.com/logflash)! - Add opt-in `<T>` id-tagging (`_tagIds`). When enabled via `withGTConfig(config, { _tagIds: true })`, each `<T>`/`<Tx>` exposes its published-translation hash as a `data-_gt-hash` attribute, so tooling (localized replay, in-context QA) can map a rendered DOM node back to its published translation. Off by default; apps not using it pay nothing. No effect on `gt()` strings, and DOM-only — skipped on React Native.
8
+
9
+ Span injection is kept to the minimum necessary: when a `<T>` renders a single host element the attribute is placed directly on that element (no wrapper), so `<T>` keeps copying the source 1:1 and stays valid inside parents that reject a `<span>` (e.g. `<tr>`/`<select>`/`<ul>`). A layout-neutral `display:contents` span is injected only when there is no element to carry the attribute (bare text or a fragment).
10
+
11
+ - Updated dependencies [[`b00b93e`](https://github.com/generaltranslation/gt/commit/b00b93eb3b830b8528ef3dbd5f503ff76d1b338a)]:
12
+ - generaltranslation@9.1.2
13
+ - gt-i18n@1.0.12
14
+
3
15
  ## 11.1.5
4
16
 
5
17
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../hooks/external-store.cjs`),t=require(`../../utils/rendering/renderPipeline.cjs`),n=require(`../../utils/translation/usePrepareT.cjs`);let r=require(`gt-i18n/internal`),i=require(`react`);function a(e){return s(e)}function o(e){return s(e)}a._gtt=`translate-client`,o._gtt=`translate-client-automatic`;function s({children:a,_locale:o,_enableI18n:s,_renderPreparedT:c=t.renderPreparedT,...l}){let{defaultLocale:u,locale:d,enableI18n:f,targetOptions:p,taggedSourceChildren:m,sourceJsxChildren:h,shouldTranslate:g}=n.usePrepareT({sourceChildren:a,params:l,_locale:o,_enableI18n:s}),_=e.useTranslate({locale:d,message:h,options:p}),v=(0,i.useRef)(null);if(process.env.NODE_ENV!==`production`&&(0,r.getI18nConfig)().isDevHotReloadEnabled()&&_==null&&v.current!=null&&g)return v.current;let y=c({taggedSourceChildren:m,targetJsxChildren:_,locale:d,defaultLocale:u,enableI18n:f,shouldTranslate:g});return v.current=y,y}exports.GtInternalTranslateJsx=o,exports.T=a;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../hooks/external-store.cjs`),t=require(`../../utils/rendering/renderPipeline.cjs`),n=require(`../../utils/translation/usePrepareT.cjs`);let r=require(`gt-i18n/internal`),i=require(`react`);function a(e){return s(e)}function o(e){return s(e)}a._gtt=`translate-client`,o._gtt=`translate-client-automatic`;function s({children:a,_locale:o,_enableI18n:s,_renderPreparedT:c=t.renderPreparedT,...l}){let{defaultLocale:u,locale:d,enableI18n:f,targetOptions:p,taggedSourceChildren:m,sourceJsxChildren:h,shouldTranslate:g}=n.usePrepareT({sourceChildren:a,params:l,_locale:o,_enableI18n:s}),_=e.useTranslate({locale:d,message:h,options:p}),v=(0,i.useRef)(null);if(process.env.NODE_ENV!==`production`&&(0,r.getI18nConfig)().isDevHotReloadEnabled()&&_==null&&v.current!=null&&g)return v.current;let y=c({taggedSourceChildren:m,targetJsxChildren:_,locale:d,defaultLocale:u,enableI18n:f,shouldTranslate:g,hash:p.$_hash});return v.current=y,y}exports.GtInternalTranslateJsx=o,exports.T=a;
2
2
  //# sourceMappingURL=T.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.cjs","names":["renderPreparedT","usePrepareT","useTranslate"],"sources":["../../../src/components/translation/T.tsx"],"sourcesContent":["import { useTranslate } from '../../hooks/external-store';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { useRef, type ReactNode } from 'react';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline';\nimport type { TProps } from '../../utils/translation/prepareT.shared';\nimport { usePrepareT } from '../../utils/translation/usePrepareT';\n\n// ===== Component ===== //\n\n/**\n * External-store version of the `<T>` component.\n */\nfunction T(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\nfunction GtInternalTranslateJsx(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-client';\nGtInternalTranslateJsx._gtt = 'translate-client-automatic';\n\nexport { GtInternalTranslateJsx, T };\n\n/**\n * Render logic\n */\nfunction useComputeT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n _renderPreparedT = renderPreparedT,\n ...params\n}: TProps): ReactNode {\n // Prepare our source children for rendering\n const {\n defaultLocale,\n locale,\n enableI18n,\n targetOptions,\n taggedSourceChildren,\n sourceJsxChildren,\n shouldTranslate,\n } = usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n });\n\n // Lookup translation in cache\n const targetJsxChildren = useTranslate({\n locale,\n message: sourceJsxChildren,\n options: targetOptions,\n });\n\n // Tx hot reload: render previous translation while loading new one\n // TODO: account for success vs loading vs failed request states\n const prev = useRef<ReactNode | null>(null);\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled() &&\n targetJsxChildren == null &&\n prev.current != null &&\n shouldTranslate\n ) {\n return prev.current;\n }\n\n const result = _renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n\n // record previous result\n prev.current = result;\n\n return result;\n}\n"],"mappings":"kQAYA,SAAS,EAAE,EAA0B,CACnC,OAAO,EAAY,EAAM,CAG3B,SAAS,EAAuB,EAA0B,CACxD,OAAO,EAAY,EAAM,CAI3B,EAAE,KAAO,mBACT,EAAuB,KAAO,6BAO9B,SAAS,EAAY,CACnB,SAAU,EACV,UACA,cACA,mBAAmBA,EAAAA,gBACnB,GAAG,GACiB,CAEpB,GAAM,CACJ,gBACA,SACA,aACA,gBACA,uBACA,oBACA,mBACEC,EAAAA,YAAY,CACd,iBACA,SACA,UACA,cACD,CAAC,CAGI,EAAoBC,EAAAA,aAAa,CACrC,SACA,QAAS,EACT,QAAS,EACV,CAAC,CAII,GAAA,EAAA,EAAA,QAAgC,KAAK,CAC3C,GACE,QAAQ,IAAI,WAAa,eAAA,EAAA,EAAA,gBACV,CAAC,uBAAuB,EACvC,GAAqB,MACrB,EAAK,SAAW,MAChB,EAEA,OAAO,EAAK,QAGd,IAAM,EAAS,EAAiB,CAC9B,uBACA,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAKF,MAFA,GAAK,QAAU,EAER"}
1
+ {"version":3,"file":"T.cjs","names":["renderPreparedT","usePrepareT","useTranslate"],"sources":["../../../src/components/translation/T.tsx"],"sourcesContent":["import { useTranslate } from '../../hooks/external-store';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { useRef, type ReactNode } from 'react';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline';\nimport type { TProps } from '../../utils/translation/prepareT.shared';\nimport { usePrepareT } from '../../utils/translation/usePrepareT';\n\n// ===== Component ===== //\n\n/**\n * External-store version of the `<T>` component.\n */\nfunction T(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\nfunction GtInternalTranslateJsx(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-client';\nGtInternalTranslateJsx._gtt = 'translate-client-automatic';\n\nexport { GtInternalTranslateJsx, T };\n\n/**\n * Render logic\n */\nfunction useComputeT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n _renderPreparedT = renderPreparedT,\n ...params\n}: TProps): ReactNode {\n // Prepare our source children for rendering\n const {\n defaultLocale,\n locale,\n enableI18n,\n targetOptions,\n taggedSourceChildren,\n sourceJsxChildren,\n shouldTranslate,\n } = usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n });\n\n // Lookup translation in cache\n const targetJsxChildren = useTranslate({\n locale,\n message: sourceJsxChildren,\n options: targetOptions,\n });\n\n // Tx hot reload: render previous translation while loading new one\n // TODO: account for success vs loading vs failed request states\n const prev = useRef<ReactNode | null>(null);\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled() &&\n targetJsxChildren == null &&\n prev.current != null &&\n shouldTranslate\n ) {\n return prev.current;\n }\n\n const result = _renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: targetOptions.$_hash,\n });\n\n // record previous result\n prev.current = result;\n\n return result;\n}\n"],"mappings":"kQAYA,SAAS,EAAE,EAA0B,CACnC,OAAO,EAAY,EAAM,CAG3B,SAAS,EAAuB,EAA0B,CACxD,OAAO,EAAY,EAAM,CAI3B,EAAE,KAAO,mBACT,EAAuB,KAAO,6BAO9B,SAAS,EAAY,CACnB,SAAU,EACV,UACA,cACA,mBAAmBA,EAAAA,gBACnB,GAAG,GACiB,CAEpB,GAAM,CACJ,gBACA,SACA,aACA,gBACA,uBACA,oBACA,mBACEC,EAAAA,YAAY,CACd,iBACA,SACA,UACA,cACD,CAAC,CAGI,EAAoBC,EAAAA,aAAa,CACrC,SACA,QAAS,EACT,QAAS,EACV,CAAC,CAII,GAAA,EAAA,EAAA,QAAgC,KAAK,CAC3C,GACE,QAAQ,IAAI,WAAa,eAAA,EAAA,EAAA,gBACV,CAAC,uBAAuB,EACvC,GAAqB,MACrB,EAAK,SAAW,MAChB,EAEA,OAAO,EAAK,QAGd,IAAM,EAAS,EAAiB,CAC9B,uBACA,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAc,OACrB,CAAC,CAKF,MAFA,GAAK,QAAU,EAER"}
@@ -1,2 +1,2 @@
1
- import{useTranslate as e}from"../../hooks/external-store.mjs";import{renderPreparedT as t}from"../../utils/rendering/renderPipeline.mjs";import{usePrepareT as n}from"../../utils/translation/usePrepareT.mjs";import{getI18nConfig as r}from"gt-i18n/internal";import{useRef as i}from"react";function a(e){return s(e)}function o(e){return s(e)}a._gtt=`translate-client`,o._gtt=`translate-client-automatic`;function s({children:a,_locale:o,_enableI18n:s,_renderPreparedT:c=t,...l}){let{defaultLocale:u,locale:d,enableI18n:f,targetOptions:p,taggedSourceChildren:m,sourceJsxChildren:h,shouldTranslate:g}=n({sourceChildren:a,params:l,_locale:o,_enableI18n:s}),_=e({locale:d,message:h,options:p}),v=i(null);if(process.env.NODE_ENV!==`production`&&r().isDevHotReloadEnabled()&&_==null&&v.current!=null&&g)return v.current;let y=c({taggedSourceChildren:m,targetJsxChildren:_,locale:d,defaultLocale:u,enableI18n:f,shouldTranslate:g});return v.current=y,y}export{o as GtInternalTranslateJsx,a as T};
1
+ import{useTranslate as e}from"../../hooks/external-store.mjs";import{renderPreparedT as t}from"../../utils/rendering/renderPipeline.mjs";import{usePrepareT as n}from"../../utils/translation/usePrepareT.mjs";import{getI18nConfig as r}from"gt-i18n/internal";import{useRef as i}from"react";function a(e){return s(e)}function o(e){return s(e)}a._gtt=`translate-client`,o._gtt=`translate-client-automatic`;function s({children:a,_locale:o,_enableI18n:s,_renderPreparedT:c=t,...l}){let{defaultLocale:u,locale:d,enableI18n:f,targetOptions:p,taggedSourceChildren:m,sourceJsxChildren:h,shouldTranslate:g}=n({sourceChildren:a,params:l,_locale:o,_enableI18n:s}),_=e({locale:d,message:h,options:p}),v=i(null);if(process.env.NODE_ENV!==`production`&&r().isDevHotReloadEnabled()&&_==null&&v.current!=null&&g)return v.current;let y=c({taggedSourceChildren:m,targetJsxChildren:_,locale:d,defaultLocale:u,enableI18n:f,shouldTranslate:g,hash:p.$_hash});return v.current=y,y}export{o as GtInternalTranslateJsx,a as T};
2
2
  //# sourceMappingURL=T.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.mjs","names":[],"sources":["../../../src/components/translation/T.tsx"],"sourcesContent":["import { useTranslate } from '../../hooks/external-store';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { useRef, type ReactNode } from 'react';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline';\nimport type { TProps } from '../../utils/translation/prepareT.shared';\nimport { usePrepareT } from '../../utils/translation/usePrepareT';\n\n// ===== Component ===== //\n\n/**\n * External-store version of the `<T>` component.\n */\nfunction T(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\nfunction GtInternalTranslateJsx(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-client';\nGtInternalTranslateJsx._gtt = 'translate-client-automatic';\n\nexport { GtInternalTranslateJsx, T };\n\n/**\n * Render logic\n */\nfunction useComputeT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n _renderPreparedT = renderPreparedT,\n ...params\n}: TProps): ReactNode {\n // Prepare our source children for rendering\n const {\n defaultLocale,\n locale,\n enableI18n,\n targetOptions,\n taggedSourceChildren,\n sourceJsxChildren,\n shouldTranslate,\n } = usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n });\n\n // Lookup translation in cache\n const targetJsxChildren = useTranslate({\n locale,\n message: sourceJsxChildren,\n options: targetOptions,\n });\n\n // Tx hot reload: render previous translation while loading new one\n // TODO: account for success vs loading vs failed request states\n const prev = useRef<ReactNode | null>(null);\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled() &&\n targetJsxChildren == null &&\n prev.current != null &&\n shouldTranslate\n ) {\n return prev.current;\n }\n\n const result = _renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n\n // record previous result\n prev.current = result;\n\n return result;\n}\n"],"mappings":"+RAYA,SAAS,EAAE,EAA0B,CACnC,OAAO,EAAY,EAAM,CAG3B,SAAS,EAAuB,EAA0B,CACxD,OAAO,EAAY,EAAM,CAI3B,EAAE,KAAO,mBACT,EAAuB,KAAO,6BAO9B,SAAS,EAAY,CACnB,SAAU,EACV,UACA,cACA,mBAAmB,EACnB,GAAG,GACiB,CAEpB,GAAM,CACJ,gBACA,SACA,aACA,gBACA,uBACA,oBACA,mBACE,EAAY,CACd,iBACA,SACA,UACA,cACD,CAAC,CAGI,EAAoB,EAAa,CACrC,SACA,QAAS,EACT,QAAS,EACV,CAAC,CAII,EAAO,EAAyB,KAAK,CAC3C,GACE,QAAQ,IAAI,WAAa,cACzB,GAAe,CAAC,uBAAuB,EACvC,GAAqB,MACrB,EAAK,SAAW,MAChB,EAEA,OAAO,EAAK,QAGd,IAAM,EAAS,EAAiB,CAC9B,uBACA,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAKF,MAFA,GAAK,QAAU,EAER"}
1
+ {"version":3,"file":"T.mjs","names":[],"sources":["../../../src/components/translation/T.tsx"],"sourcesContent":["import { useTranslate } from '../../hooks/external-store';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { useRef, type ReactNode } from 'react';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline';\nimport type { TProps } from '../../utils/translation/prepareT.shared';\nimport { usePrepareT } from '../../utils/translation/usePrepareT';\n\n// ===== Component ===== //\n\n/**\n * External-store version of the `<T>` component.\n */\nfunction T(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\nfunction GtInternalTranslateJsx(props: TProps): ReactNode {\n return useComputeT(props);\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-client';\nGtInternalTranslateJsx._gtt = 'translate-client-automatic';\n\nexport { GtInternalTranslateJsx, T };\n\n/**\n * Render logic\n */\nfunction useComputeT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n _renderPreparedT = renderPreparedT,\n ...params\n}: TProps): ReactNode {\n // Prepare our source children for rendering\n const {\n defaultLocale,\n locale,\n enableI18n,\n targetOptions,\n taggedSourceChildren,\n sourceJsxChildren,\n shouldTranslate,\n } = usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n });\n\n // Lookup translation in cache\n const targetJsxChildren = useTranslate({\n locale,\n message: sourceJsxChildren,\n options: targetOptions,\n });\n\n // Tx hot reload: render previous translation while loading new one\n // TODO: account for success vs loading vs failed request states\n const prev = useRef<ReactNode | null>(null);\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled() &&\n targetJsxChildren == null &&\n prev.current != null &&\n shouldTranslate\n ) {\n return prev.current;\n }\n\n const result = _renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: targetOptions.$_hash,\n });\n\n // record previous result\n prev.current = result;\n\n return result;\n}\n"],"mappings":"+RAYA,SAAS,EAAE,EAA0B,CACnC,OAAO,EAAY,EAAM,CAG3B,SAAS,EAAuB,EAA0B,CACxD,OAAO,EAAY,EAAM,CAI3B,EAAE,KAAO,mBACT,EAAuB,KAAO,6BAO9B,SAAS,EAAY,CACnB,SAAU,EACV,UACA,cACA,mBAAmB,EACnB,GAAG,GACiB,CAEpB,GAAM,CACJ,gBACA,SACA,aACA,gBACA,uBACA,oBACA,mBACE,EAAY,CACd,iBACA,SACA,UACA,cACD,CAAC,CAGI,EAAoB,EAAa,CACrC,SACA,QAAS,EACT,QAAS,EACV,CAAC,CAII,EAAO,EAAyB,KAAK,CAC3C,GACE,QAAQ,IAAI,WAAa,cACzB,GAAe,CAAC,uBAAuB,EACvC,GAAqB,MACrB,EAAK,SAAW,MAChB,EAEA,OAAO,EAAK,QAGd,IAAM,EAAS,EAAiB,CAC9B,uBACA,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAc,OACrB,CAAC,CAKF,MAFA,GAAK,QAAU,EAER"}
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`),t=require(`../../utils/translation/prepareT.shared.cjs`),n=require(`../../utils/rendering/renderPipeline.rsc.cjs`);let r=require(`gt-i18n/internal`);async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n.renderPreparedT,...c}){let l=a,u=o,d=(0,r.getI18nConfig)().getDefaultLocale(),f=u&&(0,r.getI18nConfig)().requiresTranslation(l),p=t.prepareT({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f});let m,h=e.getReactI18nCache();return m=process.env.NODE_ENV!==`production`&&(0,r.getI18nConfig)().isDevHotReloadEnabled()?await h.lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions):(await h.getLookupTranslation(l))(p.sourceJsxChildren,p.targetOptions),s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f})}i._gtt=`translate-server`,exports.RscT=i;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`),t=require(`../../utils/translation/prepareT.shared.cjs`),n=require(`../../utils/rendering/renderPipeline.rsc.cjs`);let r=require(`gt-i18n/internal`);async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n.renderPreparedT,...c}){let l=a,u=o,d=(0,r.getI18nConfig)().getDefaultLocale(),f=u&&(0,r.getI18nConfig)().requiresTranslation(l),p=t.prepareT({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash});let m,h=e.getReactI18nCache();return m=process.env.NODE_ENV!==`production`&&(0,r.getI18nConfig)().isDevHotReloadEnabled()?await h.lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions):(await h.getLookupTranslation(l))(p.sourceJsxChildren,p.targetOptions),s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash})}i._gtt=`translate-server`,exports.RscT=i;
2
2
  //# sourceMappingURL=T.rsc.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.rsc.cjs","names":["renderPreparedT","prepareT","getReactI18nCache"],"sources":["../../../src/components/translation/T.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\nimport { JsxChildren } from '@generaltranslation/format/types';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n }\n\n let targetJsxChildren: JsxChildren | undefined;\n const i18nCache = getReactI18nCache();\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled()\n ) {\n targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n } else {\n const lookupTranslation = await i18nCache.getLookupTranslation(locale);\n targetJsxChildren = lookupTranslation(\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n }\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscT._gtt = 'translate-server';\n\n// ===== Exports ===== //\n\nexport { RscT };\n"],"mappings":"kQAcA,eAAe,EAAK,CAClB,SAAU,EACV,UACA,cAEA,mBAAmBA,EAAAA,gBACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,GAAA,EAAA,EAAA,gBAA+B,CAAC,kBAAkB,CAClD,EACJ,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CACrD,EAAWC,EAAAA,SAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACD,CAAC,CAGJ,IAAI,EACE,EAAYC,EAAAA,mBAAmB,CAkBrC,MAjBA,CAWE,EAVA,QAAQ,IAAI,WAAa,eAAA,EAAA,EAAA,gBACV,CAAC,uBAAuB,CAEnB,MAAM,EAAU,8BAClC,EACA,EAAS,kBACT,EAAS,cACV,EAGmB,MADY,EAAU,qBAAqB,EAAO,EAEpE,EAAS,kBACT,EAAS,cACV,CAGI,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,EAAK,KAAO"}
1
+ {"version":3,"file":"T.rsc.cjs","names":["renderPreparedT","prepareT","getReactI18nCache"],"sources":["../../../src/components/translation/T.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\nimport { JsxChildren } from '@generaltranslation/format/types';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n }\n\n let targetJsxChildren: JsxChildren | undefined;\n const i18nCache = getReactI18nCache();\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled()\n ) {\n targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n } else {\n const lookupTranslation = await i18nCache.getLookupTranslation(locale);\n targetJsxChildren = lookupTranslation(\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n }\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscT._gtt = 'translate-server';\n\n// ===== Exports ===== //\n\nexport { RscT };\n"],"mappings":"kQAcA,eAAe,EAAK,CAClB,SAAU,EACV,UACA,cAEA,mBAAmBA,EAAAA,gBACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,GAAA,EAAA,EAAA,gBAA+B,CAAC,kBAAkB,CAClD,EACJ,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CACrD,EAAWC,EAAAA,SAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAGJ,IAAI,EACE,EAAYC,EAAAA,mBAAmB,CAkBrC,MAjBA,CAWE,EAVA,QAAQ,IAAI,WAAa,eAAA,EAAA,EAAA,gBACV,CAAC,uBAAuB,CAEnB,MAAM,EAAU,8BAClC,EACA,EAAS,kBACT,EAAS,cACV,EAGmB,MADY,EAAU,qBAAqB,EAAO,EAEpE,EAAS,kBACT,EAAS,cACV,CAGI,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,EAAK,KAAO"}
@@ -1,2 +1,2 @@
1
- import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{prepareT as t}from"../../utils/translation/prepareT.shared.mjs";import{renderPreparedT as n}from"../../utils/rendering/renderPipeline.rsc.mjs";import{getI18nConfig as r}from"gt-i18n/internal";async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n,...c}){let l=a,u=o,d=r().getDefaultLocale(),f=u&&r().requiresTranslation(l),p=t({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f});let m,h=e();return m=process.env.NODE_ENV!==`production`&&r().isDevHotReloadEnabled()?await h.lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions):(await h.getLookupTranslation(l))(p.sourceJsxChildren,p.targetOptions),s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f})}i._gtt=`translate-server`;export{i as RscT};
1
+ import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{prepareT as t}from"../../utils/translation/prepareT.shared.mjs";import{renderPreparedT as n}from"../../utils/rendering/renderPipeline.rsc.mjs";import{getI18nConfig as r}from"gt-i18n/internal";async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n,...c}){let l=a,u=o,d=r().getDefaultLocale(),f=u&&r().requiresTranslation(l),p=t({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash});let m,h=e();return m=process.env.NODE_ENV!==`production`&&r().isDevHotReloadEnabled()?await h.lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions):(await h.getLookupTranslation(l))(p.sourceJsxChildren,p.targetOptions),s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash})}i._gtt=`translate-server`;export{i as RscT};
2
2
  //# sourceMappingURL=T.rsc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.rsc.mjs","names":[],"sources":["../../../src/components/translation/T.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\nimport { JsxChildren } from '@generaltranslation/format/types';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n }\n\n let targetJsxChildren: JsxChildren | undefined;\n const i18nCache = getReactI18nCache();\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled()\n ) {\n targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n } else {\n const lookupTranslation = await i18nCache.getLookupTranslation(locale);\n targetJsxChildren = lookupTranslation(\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n }\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscT._gtt = 'translate-server';\n\n// ===== Exports ===== //\n\nexport { RscT };\n"],"mappings":"qRAcA,eAAe,EAAK,CAClB,SAAU,EACV,UACA,cAEA,mBAAmB,EACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,EAAgB,GAAe,CAAC,kBAAkB,CAClD,EACJ,GAAc,GAAe,CAAC,oBAAoB,EAAO,CACrD,EAAW,EAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACD,CAAC,CAGJ,IAAI,EACE,EAAY,GAAmB,CAkBrC,MAjBA,CAWE,EAVA,QAAQ,IAAI,WAAa,cACzB,GAAe,CAAC,uBAAuB,CAEnB,MAAM,EAAU,8BAClC,EACA,EAAS,kBACT,EAAS,cACV,EAGmB,MADY,EAAU,qBAAqB,EAAO,EAEpE,EAAS,kBACT,EAAS,cACV,CAGI,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,EAAK,KAAO"}
1
+ {"version":3,"file":"T.rsc.mjs","names":[],"sources":["../../../src/components/translation/T.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\nimport { JsxChildren } from '@generaltranslation/format/types';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscT({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n }\n\n let targetJsxChildren: JsxChildren | undefined;\n const i18nCache = getReactI18nCache();\n if (\n process.env.NODE_ENV !== 'production' &&\n getI18nConfig().isDevHotReloadEnabled()\n ) {\n targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n } else {\n const lookupTranslation = await i18nCache.getLookupTranslation(locale);\n targetJsxChildren = lookupTranslation(\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n }\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscT._gtt = 'translate-server';\n\n// ===== Exports ===== //\n\nexport { RscT };\n"],"mappings":"qRAcA,eAAe,EAAK,CAClB,SAAU,EACV,UACA,cAEA,mBAAmB,EACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,EAAgB,GAAe,CAAC,kBAAkB,CAClD,EACJ,GAAc,GAAe,CAAC,oBAAoB,EAAO,CACrD,EAAW,EAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAGJ,IAAI,EACE,EAAY,GAAmB,CAkBrC,MAjBA,CAWE,EAVA,QAAQ,IAAI,WAAa,cACzB,GAAe,CAAC,uBAAuB,CAEnB,MAAM,EAAU,8BAClC,EACA,EAAS,kBACT,EAAS,cACV,EAGmB,MADY,EAAU,qBAAqB,EAAO,EAEpE,EAAS,kBACT,EAAS,cACV,CAGI,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,EAAK,KAAO"}
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`),t=require(`../../utils/translation/prepareT.shared.cjs`),n=require(`../../utils/rendering/renderPipeline.rsc.cjs`);let r=require(`gt-i18n/internal`);async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n.renderPreparedT,...c}){let l=a,u=o,d=(0,r.getI18nConfig)().getDefaultLocale(),f=u&&(0,r.getI18nConfig)().requiresTranslation(l),p=t.prepareT({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f});let m=await e.getReactI18nCache().lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions);return s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f})}i._gtt=`translate-runtime`,exports.RscTx=i;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../i18n-cache/singleton-operations.cjs`),t=require(`../../utils/translation/prepareT.shared.cjs`),n=require(`../../utils/rendering/renderPipeline.rsc.cjs`);let r=require(`gt-i18n/internal`);async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n.renderPreparedT,...c}){let l=a,u=o,d=(0,r.getI18nConfig)().getDefaultLocale(),f=u&&(0,r.getI18nConfig)().requiresTranslation(l),p=t.prepareT({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash});let m=await e.getReactI18nCache().lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions);return s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash})}i._gtt=`translate-runtime`,exports.RscTx=i;
2
2
  //# sourceMappingURL=Tx.rsc.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tx.rsc.cjs","names":["renderPreparedT","prepareT","getReactI18nCache"],"sources":["../../../src/components/translation/Tx.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscTx({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n }\n\n const i18nCache = getReactI18nCache();\n const targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscTx._gtt = 'translate-runtime';\n\n// ===== Exports ===== //\n\nexport { RscTx };\n"],"mappings":"kQAaA,eAAe,EAAM,CACnB,SAAU,EACV,UACA,cAEA,mBAAmBA,EAAAA,gBACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,GAAA,EAAA,EAAA,gBAA+B,CAAC,kBAAkB,CAClD,EACJ,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CACrD,EAAWC,EAAAA,SAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,IAAM,EAAoB,MADRC,EAAAA,mBACuB,CAAC,8BACxC,EACA,EAAS,kBACT,EAAS,cACV,CAED,OAAO,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,EAAM,KAAO"}
1
+ {"version":3,"file":"Tx.rsc.cjs","names":["renderPreparedT","prepareT","getReactI18nCache"],"sources":["../../../src/components/translation/Tx.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscTx({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n }\n\n const i18nCache = getReactI18nCache();\n const targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscTx._gtt = 'translate-runtime';\n\n// ===== Exports ===== //\n\nexport { RscTx };\n"],"mappings":"kQAaA,eAAe,EAAM,CACnB,SAAU,EACV,UACA,cAEA,mBAAmBA,EAAAA,gBACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,GAAA,EAAA,EAAA,gBAA+B,CAAC,kBAAkB,CAClD,EACJ,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CACrD,EAAWC,EAAAA,SAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,IAAM,EAAoB,MADRC,EAAAA,mBACuB,CAAC,8BACxC,EACA,EAAS,kBACT,EAAS,cACV,CAED,OAAO,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,EAAM,KAAO"}
@@ -1,2 +1,2 @@
1
- import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{prepareT as t}from"../../utils/translation/prepareT.shared.mjs";import{renderPreparedT as n}from"../../utils/rendering/renderPipeline.rsc.mjs";import{getI18nConfig as r}from"gt-i18n/internal";async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n,...c}){let l=a,u=o,d=r().getDefaultLocale(),f=u&&r().requiresTranslation(l),p=t({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f});let m=await e().lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions);return s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f})}i._gtt=`translate-runtime`;export{i as RscTx};
1
+ import{getReactI18nCache as e}from"../../i18n-cache/singleton-operations.mjs";import{prepareT as t}from"../../utils/translation/prepareT.shared.mjs";import{renderPreparedT as n}from"../../utils/rendering/renderPipeline.rsc.mjs";import{getI18nConfig as r}from"gt-i18n/internal";async function i({children:i,_locale:a,_enableI18n:o,_renderPreparedT:s=n,...c}){let l=a,u=o,d=r().getDefaultLocale(),f=u&&r().requiresTranslation(l),p=t({sourceChildren:i,params:c,locale:l});if(!f)return s({...p,targetJsxChildren:void 0,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash});let m=await e().lookupTranslationWithFallback(l,p.sourceJsxChildren,p.targetOptions);return s({...p,targetJsxChildren:m,locale:l,defaultLocale:d,enableI18n:u,shouldTranslate:f,hash:p.targetOptions.$_hash})}i._gtt=`translate-runtime`;export{i as RscTx};
2
2
  //# sourceMappingURL=Tx.rsc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tx.rsc.mjs","names":[],"sources":["../../../src/components/translation/Tx.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscTx({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n }\n\n const i18nCache = getReactI18nCache();\n const targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscTx._gtt = 'translate-runtime';\n\n// ===== Exports ===== //\n\nexport { RscTx };\n"],"mappings":"qRAaA,eAAe,EAAM,CACnB,SAAU,EACV,UACA,cAEA,mBAAmB,EACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,EAAgB,GAAe,CAAC,kBAAkB,CAClD,EACJ,GAAc,GAAe,CAAC,oBAAoB,EAAO,CACrD,EAAW,EAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,IAAM,EAAoB,MADR,GACuB,CAAC,8BACxC,EACA,EAAS,kBACT,EAAS,cACV,CAED,OAAO,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACD,CAAC,CAIJ,EAAM,KAAO"}
1
+ {"version":3,"file":"Tx.rsc.mjs","names":[],"sources":["../../../src/components/translation/Tx.rsc.tsx"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\nimport type { ReactNode } from 'react';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\nimport { renderPreparedT } from '../../utils/rendering/renderPipeline.rsc';\nimport {\n prepareT,\n type ResolvedTProps,\n} from '../../utils/translation/prepareT.shared';\n\n// RSC implementation: request conditions are passed explicitly instead of\n// being read from hooks. This module must stay free of hook/context imports\n// so it can be exported from the components-rsc entrypoint.\n\nasync function RscTx({\n children: sourceChildren,\n _locale,\n _enableI18n,\n // TODO: don't expose to consumer, this should be thru an internal path\n _renderPreparedT = renderPreparedT,\n ...params\n}: ResolvedTProps): Promise<ReactNode> {\n const locale = _locale;\n const enableI18n = _enableI18n;\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = prepareT({\n sourceChildren,\n params,\n locale,\n });\n\n if (!shouldTranslate) {\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren: undefined,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n }\n\n const i18nCache = getReactI18nCache();\n const targetJsxChildren = await i18nCache.lookupTranslationWithFallback(\n locale,\n prepared.sourceJsxChildren,\n prepared.targetOptions\n );\n\n return _renderPreparedT({\n ...prepared,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash: prepared.targetOptions.$_hash,\n });\n}\n\n/** @internal _gtt - The GT transformation for the component. */\nRscTx._gtt = 'translate-runtime';\n\n// ===== Exports ===== //\n\nexport { RscTx };\n"],"mappings":"qRAaA,eAAe,EAAM,CACnB,SAAU,EACV,UACA,cAEA,mBAAmB,EACnB,GAAG,GACkC,CACrC,IAAM,EAAS,EACT,EAAa,EACb,EAAgB,GAAe,CAAC,kBAAkB,CAClD,EACJ,GAAc,GAAe,CAAC,oBAAoB,EAAO,CACrD,EAAW,EAAS,CACxB,iBACA,SACA,SACD,CAAC,CAEF,GAAI,CAAC,EACH,OAAO,EAAiB,CACtB,GAAG,EACH,kBAAmB,IAAA,GACnB,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,IAAM,EAAoB,MADR,GACuB,CAAC,8BACxC,EACA,EAAS,kBACT,EAAS,cACV,CAED,OAAO,EAAiB,CACtB,GAAG,EACH,oBACA,SACA,gBACA,aACA,kBACA,KAAM,EAAS,cAAc,OAC9B,CAAC,CAIJ,EAAM,KAAO"}
@@ -1,2 +1,2 @@
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;
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}isIdTaggingEnabled(){return this.runtimeConfig._tagIds===!0}};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';\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"}
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 /**\n * Opt-in (`_tagIds`): whether `<T>` output should carry its translation hash as\n * a `data-_gt-hash` attribute for tooling. Requires the literal `true`.\n */\n isIdTaggingEnabled(): boolean {\n return this.runtimeConfig._tagIds === true;\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,qBAOd,oBAA8B,CAC5B,OAAO,KAAK,cAAc,UAAY,KAI1C,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"}
@@ -24,6 +24,11 @@ declare class ReactI18nConfig extends I18nConfig {
24
24
  getLocaleCookieName(): string;
25
25
  getRegionCookieName(): string;
26
26
  getEnableI18nCookieName(): string;
27
+ /**
28
+ * Opt-in (`_tagIds`): whether `<T>` output should carry its translation hash as
29
+ * a `data-_gt-hash` attribute for tooling. Requires the literal `true`.
30
+ */
31
+ isIdTaggingEnabled(): boolean;
27
32
  }
28
33
  declare function getI18nConfig(): ReactI18nConfig;
29
34
  declare function initializeI18nConfig(params?: ReactI18nConfigParams, renderStrategy?: RenderStrategy): ReactI18nConfig;
@@ -1 +1 @@
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
+ {"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;EAhC2B;;;;EAwC3B,kBAAA,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"./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};
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}isIdTaggingEnabled(){return this.runtimeConfig._tagIds===!0}};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';\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"}
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 /**\n * Opt-in (`_tagIds`): whether `<T>` output should carry its translation hash as\n * a `data-_gt-hash` attribute for tooling. Requires the literal `true`.\n */\n isIdTaggingEnabled(): boolean {\n return this.runtimeConfig._tagIds === true;\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,qBAOd,oBAA8B,CAC5B,OAAO,KAAK,cAAc,UAAY,KAI1C,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,2 +1,2 @@
1
- function e({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:a,enableI18n:o,shouldTranslate:s}){return!s||t==null?r({taggedSourceChildren:e,defaultLocale:a,enableI18n:o}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,a],enableI18n:o})}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}exports.createRenderPreparedT=e;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../translation/resolveTagHash.cjs`);let t=require(`react`);const n={display:`contents`},r=globalThis.navigator?.product===`ReactNative`;function i(e){if(e==null||typeof e==`boolean`||e===``)return!0;if(Array.isArray(e))return!e.some(e=>!i(e));if((0,t.isValidElement)(e)&&e.type===t.Fragment){let t=e.props.children;return t==null||i(t)}return!1}function a(a,o){return r||!e.idTaggingEnabled()?a:(0,t.isValidElement)(a)&&typeof a.type==`string`?(0,t.cloneElement)(a,{"data-_gt-hash":o}):i(a)?a:(0,t.createElement)(`span`,{"data-_gt-hash":o,style:n},a)}function o({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:o,enableI18n:s,shouldTranslate:c,hash:l}){let u=!c||t==null?r({taggedSourceChildren:e,defaultLocale:o,enableI18n:s}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,o],enableI18n:s});return l?a(u,l):u}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}exports.createRenderPreparedT=o;
2
2
  //# sourceMappingURL=renderPreparedT.shared.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreparedT.shared.cjs","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { TaggedChildren } from '../types';\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n }: RenderPreparedTParams): ReactNode {\n if (!shouldTranslate || targetJsxChildren == null) {\n return renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n return renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"AAoBA,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,mBACmC,CASnC,MARI,CAAC,GAAmB,GAAqB,KACpC,EAAa,CAClB,uBACA,gBACA,aACD,CAAC,CAGG,EAAa,CAClB,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
1
+ {"version":3,"file":"renderPreparedT.shared.cjs","names":["Fragment","idTaggingEnabled"],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport {\n cloneElement,\n createElement,\n Fragment,\n isValidElement,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { TaggedChildren } from '../types';\nimport { idTaggingEnabled } from '../translation/resolveTagHash';\n\n// Opt-in id-tagging: when a `hash` is provided, the translation hash is exposed\n// on the DOM as `data-_gt-hash` so tooling can map a rendered node back to its\n// published translation.\n//\n// Span injection is kept to the minimum necessary: when the <T> renders a single\n// host element we put the attribute directly on THAT element (no wrapper), so <T>\n// keeps copying the source 1:1. Only when there is no element to carry it — bare\n// text, a fragment, or a component root — do we inject a layout-neutral span\n// (`display: contents`, so it generates no box and children lay out as before).\n//\n// DOM-only: skipped on React Native (there is no `span`/DOM attribute analog).\n// The rest of this module stays platform-agnostic; this is a runtime guard, not a\n// native import.\nconst TAG_STYLE = { display: 'contents' } as const;\n// Canonical React Native detection (RN sets navigator.product = 'ReactNative').\n// False in the browser AND in Node SSR/RSC, so the span is still emitted server-\n// side (where the harvest reads it).\nconst IS_REACT_NATIVE =\n (globalThis as { navigator?: { product?: string } }).navigator?.product ===\n 'ReactNative';\n\n// Whether a rendered node produces NO DOM — so id-tagging must leave it untouched\n// (wrapping it in a hash span would create an empty <span>, altering :empty/child\n// structure and injecting an invalid span under restricted parents). Covers the\n// scalar non-renderers (null / undefined / booleans / ''), arrays whose every\n// element renders nothing (`items.map(...)` over an empty list, `[null, false]`,\n// nested empties — TaggedChildren accepts arrays), and empty React fragments.\n// NB: 0 and NaN DO render text, so they are intentionally NOT treated as empty.\nfunction rendersNothing(node: ReactNode): boolean {\n if (node == null || typeof node === 'boolean' || node === '') return true;\n if (Array.isArray(node)) return !node.some((n) => !rendersNothing(n));\n if (isValidElement(node) && node.type === Fragment) {\n const children = (node.props as { children?: ReactNode }).children;\n return children == null || rendersNothing(children);\n }\n return false;\n}\n\n// Opt-in id-tagging (powers RRWeb localized replay / in-context tooling): expose\n// the translation hash on the DOM as `data-_gt-hash`. Factored out of the render\n// path so it's clear this whole block is dedicated to id-tagging, not core <T>\n// behavior. Called only when a `hash` was produced (see resolveTagHash).\nfunction applyIdTag(rendered: ReactNode, hash: string): ReactNode {\n // `hash` is only produced when tagging is on, but re-assert the config here so a\n // stray hash can never inject DOM; and never on React Native (no span/DOM attr\n // analog — IS_REACT_NATIVE is checked first so the config isn't read there).\n if (IS_REACT_NATIVE || !idTaggingEnabled()) return rendered;\n // Single host element (e.g. `<T><td>…</td></T>`) → annotate it directly, no\n // wrapper. Valid wherever the element itself is valid — including inside\n // <tr>/<select>/<ul> — and avoids the span entirely.\n if (isValidElement(rendered) && typeof rendered.type === 'string') {\n return cloneElement(rendered as ReactElement<Record<string, unknown>>, {\n 'data-_gt-hash': hash,\n });\n }\n // Output that renders no DOM stays no-DOM: an empty <span data-_gt-hash> would\n // change :empty/child structure and inject an (invalid, under restricted\n // parents) span even for an empty branch.\n if (rendersNothing(rendered)) return rendered;\n // No element to carry the attribute (bare text / fragment / component root) →\n // wrap in a layout-neutral span. This is the only case that injects one.\n return createElement(\n 'span',\n { 'data-_gt-hash': hash, style: TAG_STYLE },\n rendered\n );\n}\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n // The translation hash for this <T> (see resolveTagHash) — the same key the\n // published-translation cache/CDN is keyed by. Set only when id-tagging is\n // enabled; when undefined the output is rendered untouched. Presence of `hash`\n // is the single signal to tag (there is no separate boolean).\n hash?: string;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash,\n }: RenderPreparedTParams): ReactNode {\n const rendered =\n !shouldTranslate || targetJsxChildren == null\n ? renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n })\n : renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n\n // Opt-in id-tagging is entirely handled by applyIdTag; `hash` presence is the\n // enable signal (produced by resolveTagHash only when tagging is on).\n return hash ? applyIdTag(rendered, hash) : rendered;\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"4HA2BA,MAAM,EAAY,CAAE,QAAS,WAAY,CAInC,EACH,WAAoD,WAAW,UAChE,cASF,SAAS,EAAe,EAA0B,CAChD,GAAI,GAAQ,MAAQ,OAAO,GAAS,WAAa,IAAS,GAAI,MAAO,GACrE,GAAI,MAAM,QAAQ,EAAK,CAAE,MAAO,CAAC,EAAK,KAAM,GAAM,CAAC,EAAe,EAAE,CAAC,CACrE,IAAA,EAAA,EAAA,gBAAmB,EAAK,EAAI,EAAK,OAASA,EAAAA,SAAU,CAClD,IAAM,EAAY,EAAK,MAAmC,SAC1D,OAAO,GAAY,MAAQ,EAAe,EAAS,CAErD,MAAO,GAOT,SAAS,EAAW,EAAqB,EAAyB,CAmBhE,OAfI,GAAmB,CAACC,EAAAA,kBAAkB,CAAS,GAInD,EAAA,EAAA,gBAAmB,EAAS,EAAI,OAAO,EAAS,MAAS,UACvD,EAAA,EAAA,cAAoB,EAAmD,CACrE,gBAAiB,EAClB,CAAC,CAKA,EAAe,EAAS,CAAS,GAGrC,EAAA,EAAA,eACE,OACA,CAAE,gBAAiB,EAAM,MAAO,EAAW,CAC3C,EACD,CAsBH,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,kBACA,QACmC,CACnC,IAAM,EACJ,CAAC,GAAmB,GAAqB,KACrC,EAAa,CACX,uBACA,gBACA,aACD,CAAC,CACF,EAAa,CACX,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAIR,OAAO,EAAO,EAAW,EAAU,EAAK,CAAG,EAG7C,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
@@ -10,6 +10,7 @@ type RenderPreparedTParams = {
10
10
  defaultLocale: string;
11
11
  enableI18n: boolean;
12
12
  shouldTranslate: boolean;
13
+ hash?: string;
13
14
  };
14
15
  //#endregion
15
16
  export { type RenderPreparedTParams };
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreparedT.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"mappings":";;;;;KAWK,qBAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,MAAA;EACA,aAAA;EACA,UAAA;EACA,eAAA;AAAA"}
1
+ {"version":3,"file":"renderPreparedT.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"mappings":";;;;;KAuFK,qBAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,MAAA;EACA,aAAA;EACA,UAAA;EACA,eAAA;EAKA,IAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- function e({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:a,enableI18n:o,shouldTranslate:s}){return!s||t==null?r({taggedSourceChildren:e,defaultLocale:a,enableI18n:o}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,a],enableI18n:o})}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}export{e as createRenderPreparedT};
1
+ import{idTaggingEnabled as e}from"../translation/resolveTagHash.mjs";import{Fragment as t,cloneElement as n,createElement as r,isValidElement as i}from"react";const a={display:`contents`},o=globalThis.navigator?.product===`ReactNative`;function s(e){if(e==null||typeof e==`boolean`||e===``)return!0;if(Array.isArray(e))return!e.some(e=>!s(e));if(i(e)&&e.type===t){let t=e.props.children;return t==null||s(t)}return!1}function c(t,c){return o||!e()?t:i(t)&&typeof t.type==`string`?n(t,{"data-_gt-hash":c}):s(t)?t:r(`span`,{"data-_gt-hash":c,style:a},t)}function l({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:a,enableI18n:o,shouldTranslate:s,hash:l}){let u=!s||t==null?r({taggedSourceChildren:e,defaultLocale:a,enableI18n:o}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,a],enableI18n:o});return l?c(u,l):u}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}export{l as createRenderPreparedT};
2
2
  //# sourceMappingURL=renderPreparedT.shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreparedT.shared.mjs","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { TaggedChildren } from '../types';\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n }: RenderPreparedTParams): ReactNode {\n if (!shouldTranslate || targetJsxChildren == null) {\n return renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n return renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"AAoBA,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,mBACmC,CASnC,MARI,CAAC,GAAmB,GAAqB,KACpC,EAAa,CAClB,uBACA,gBACA,aACD,CAAC,CAGG,EAAa,CAClB,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
1
+ {"version":3,"file":"renderPreparedT.shared.mjs","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport {\n cloneElement,\n createElement,\n Fragment,\n isValidElement,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { TaggedChildren } from '../types';\nimport { idTaggingEnabled } from '../translation/resolveTagHash';\n\n// Opt-in id-tagging: when a `hash` is provided, the translation hash is exposed\n// on the DOM as `data-_gt-hash` so tooling can map a rendered node back to its\n// published translation.\n//\n// Span injection is kept to the minimum necessary: when the <T> renders a single\n// host element we put the attribute directly on THAT element (no wrapper), so <T>\n// keeps copying the source 1:1. Only when there is no element to carry it — bare\n// text, a fragment, or a component root — do we inject a layout-neutral span\n// (`display: contents`, so it generates no box and children lay out as before).\n//\n// DOM-only: skipped on React Native (there is no `span`/DOM attribute analog).\n// The rest of this module stays platform-agnostic; this is a runtime guard, not a\n// native import.\nconst TAG_STYLE = { display: 'contents' } as const;\n// Canonical React Native detection (RN sets navigator.product = 'ReactNative').\n// False in the browser AND in Node SSR/RSC, so the span is still emitted server-\n// side (where the harvest reads it).\nconst IS_REACT_NATIVE =\n (globalThis as { navigator?: { product?: string } }).navigator?.product ===\n 'ReactNative';\n\n// Whether a rendered node produces NO DOM — so id-tagging must leave it untouched\n// (wrapping it in a hash span would create an empty <span>, altering :empty/child\n// structure and injecting an invalid span under restricted parents). Covers the\n// scalar non-renderers (null / undefined / booleans / ''), arrays whose every\n// element renders nothing (`items.map(...)` over an empty list, `[null, false]`,\n// nested empties — TaggedChildren accepts arrays), and empty React fragments.\n// NB: 0 and NaN DO render text, so they are intentionally NOT treated as empty.\nfunction rendersNothing(node: ReactNode): boolean {\n if (node == null || typeof node === 'boolean' || node === '') return true;\n if (Array.isArray(node)) return !node.some((n) => !rendersNothing(n));\n if (isValidElement(node) && node.type === Fragment) {\n const children = (node.props as { children?: ReactNode }).children;\n return children == null || rendersNothing(children);\n }\n return false;\n}\n\n// Opt-in id-tagging (powers RRWeb localized replay / in-context tooling): expose\n// the translation hash on the DOM as `data-_gt-hash`. Factored out of the render\n// path so it's clear this whole block is dedicated to id-tagging, not core <T>\n// behavior. Called only when a `hash` was produced (see resolveTagHash).\nfunction applyIdTag(rendered: ReactNode, hash: string): ReactNode {\n // `hash` is only produced when tagging is on, but re-assert the config here so a\n // stray hash can never inject DOM; and never on React Native (no span/DOM attr\n // analog — IS_REACT_NATIVE is checked first so the config isn't read there).\n if (IS_REACT_NATIVE || !idTaggingEnabled()) return rendered;\n // Single host element (e.g. `<T><td>…</td></T>`) → annotate it directly, no\n // wrapper. Valid wherever the element itself is valid — including inside\n // <tr>/<select>/<ul> — and avoids the span entirely.\n if (isValidElement(rendered) && typeof rendered.type === 'string') {\n return cloneElement(rendered as ReactElement<Record<string, unknown>>, {\n 'data-_gt-hash': hash,\n });\n }\n // Output that renders no DOM stays no-DOM: an empty <span data-_gt-hash> would\n // change :empty/child structure and inject an (invalid, under restricted\n // parents) span even for an empty branch.\n if (rendersNothing(rendered)) return rendered;\n // No element to carry the attribute (bare text / fragment / component root) →\n // wrap in a layout-neutral span. This is the only case that injects one.\n return createElement(\n 'span',\n { 'data-_gt-hash': hash, style: TAG_STYLE },\n rendered\n );\n}\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n // The translation hash for this <T> (see resolveTagHash) — the same key the\n // published-translation cache/CDN is keyed by. Set only when id-tagging is\n // enabled; when undefined the output is rendered untouched. Presence of `hash`\n // is the single signal to tag (there is no separate boolean).\n hash?: string;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n hash,\n }: RenderPreparedTParams): ReactNode {\n const rendered =\n !shouldTranslate || targetJsxChildren == null\n ? renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n })\n : renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n\n // Opt-in id-tagging is entirely handled by applyIdTag; `hash` presence is the\n // enable signal (produced by resolveTagHash only when tagging is on).\n return hash ? applyIdTag(rendered, hash) : rendered;\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"+JA2BA,MAAM,EAAY,CAAE,QAAS,WAAY,CAInC,EACH,WAAoD,WAAW,UAChE,cASF,SAAS,EAAe,EAA0B,CAChD,GAAI,GAAQ,MAAQ,OAAO,GAAS,WAAa,IAAS,GAAI,MAAO,GACrE,GAAI,MAAM,QAAQ,EAAK,CAAE,MAAO,CAAC,EAAK,KAAM,GAAM,CAAC,EAAe,EAAE,CAAC,CACrE,GAAI,EAAe,EAAK,EAAI,EAAK,OAAS,EAAU,CAClD,IAAM,EAAY,EAAK,MAAmC,SAC1D,OAAO,GAAY,MAAQ,EAAe,EAAS,CAErD,MAAO,GAOT,SAAS,EAAW,EAAqB,EAAyB,CAmBhE,OAfI,GAAmB,CAAC,GAAkB,CAAS,EAI/C,EAAe,EAAS,EAAI,OAAO,EAAS,MAAS,SAChD,EAAa,EAAmD,CACrE,gBAAiB,EAClB,CAAC,CAKA,EAAe,EAAS,CAAS,EAG9B,EACL,OACA,CAAE,gBAAiB,EAAM,MAAO,EAAW,CAC3C,EACD,CAsBH,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,kBACA,QACmC,CACnC,IAAM,EACJ,CAAC,GAAmB,GAAqB,KACrC,EAAa,CACX,uBACA,gBACA,aACD,CAAC,CACF,EAAa,CACX,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAIR,OAAO,EAAO,EAAW,EAAU,EAAK,CAAG,EAG7C,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
@@ -1,2 +1,2 @@
1
- const e=require(`../internal/addGTIdentifier.cjs`),t=require(`../internal/removeInjectedT.cjs`),n=require(`../internal/writeChildrenAsObjects.cjs`);function r({sourceChildren:e,params:t,locale:n}){let r=i(e);return{taggedSourceChildren:r,sourceJsxChildren:a(r),targetOptions:o({options:s(t),locale:n})}}function i(n){return e.addGTIdentifier(t.removeInjectedT(n))}function a(e){return n.writeChildrenAsObjects(e)}function o({options:e,locale:t}){return{...e,$locale:t}}function s(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}exports.prepareT=r;
1
+ const e=require(`./resolveTagHash.cjs`),t=require(`../internal/addGTIdentifier.cjs`),n=require(`../internal/removeInjectedT.cjs`),r=require(`../internal/writeChildrenAsObjects.cjs`);function i({sourceChildren:t,params:n,locale:r}){let i=a(t),l=o(i),u=s({options:c(n),locale:r});return e.resolveTagHash(l,u),{taggedSourceChildren:i,sourceJsxChildren:l,targetOptions:u}}function a(e){return t.addGTIdentifier(n.removeInjectedT(e))}function o(e){return r.writeChildrenAsObjects(e)}function s({options:e,locale:t}){return{...e,$locale:t}}function c(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}exports.prepareT=i;
2
2
  //# sourceMappingURL=prepareT.shared.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareT.shared.cjs","names":["addGTIdentifier","removeInjectedT","writeChildrenAsObjects"],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"oJA2CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAKxE,MAAO,CACL,uBACA,kBANwB,EAAyB,EAMhC,CACjB,cALoB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAK/C,CACd,CAGH,SAAS,EACP,EACgB,CAChB,OAAOA,EAAAA,gBAAgBC,EAAAA,gBAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAOC,EAAAA,uBAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
1
+ {"version":3,"file":"prepareT.shared.cjs","names":["addGTIdentifier","removeInjectedT","writeChildrenAsObjects"],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\nimport { resolveTagHash } from './resolveTagHash';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n // Caches the id-tagging hash onto targetOptions.$_hash so the lookup reuses it.\n resolveTagHash(sourceJsxChildren, targetOptions);\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"sLA4CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAClE,EAAoB,EAAyB,EAAqB,CAElE,EAAgB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAAC,CAK/D,OAFA,EAAA,eAAe,EAAmB,EAAc,CAEzC,CACL,uBACA,oBACA,gBACD,CAGH,SAAS,EACP,EACgB,CAChB,OAAOA,EAAAA,gBAAgBC,EAAAA,gBAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAOC,EAAAA,uBAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"prepareT.shared.d.ts","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"mappings":";;;;;;;KAaK,iBAAA,oBACS,CAAA,IAAK,CAAA,4BAA6B,IAAA,GAAO,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGxD,uBAAA,GAAwB,iBAAA,CAAkB,qBAAA,IAC7C,qBAAA;AAAA,KAEG,SAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,aAAA,EAAe,qBAAA;IACb,OAAA;IACA,OAAA;EAAA;AAAA;AAAA,KAIC,eAAA,IAAmB,MAAA,EAAQ,qBAAA,KAA0B,SAAA;AAAA,KAErD,MAAA;EACH,QAAA,EAAU,SAAA;EACV,OAAA;EACA,WAAA;EACA,gBAAA,GAAmB,eAAA;AAAA,IACjB,uBAAA;AAAA,KAEC,cAAA,GAAiB,MAAA;EACpB,OAAA;EACA,WAAA;AAAA;AAAA,iBAGO,QAAA,CAAA;EACP,cAAA;EACA,MAAA;EACA;AAAA;EAEA,cAAA,EAAgB,SAAA;EAChB,MAAA,EAAQ,uBAAA;EACR,MAAA;AAAA,IACE,SAAA"}
1
+ {"version":3,"file":"prepareT.shared.d.ts","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"mappings":";;;;;;;KAcK,iBAAA,oBACS,CAAA,IAAK,CAAA,4BAA6B,IAAA,GAAO,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGxD,uBAAA,GAAwB,iBAAA,CAAkB,qBAAA,IAC7C,qBAAA;AAAA,KAEG,SAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,aAAA,EAAe,qBAAA;IACb,OAAA;IACA,OAAA;EAAA;AAAA;AAAA,KAIC,eAAA,IAAmB,MAAA,EAAQ,qBAAA,KAA0B,SAAA;AAAA,KAErD,MAAA;EACH,QAAA,EAAU,SAAA;EACV,OAAA;EACA,WAAA;EACA,gBAAA,GAAmB,eAAA;AAAA,IACjB,uBAAA;AAAA,KAEC,cAAA,GAAiB,MAAA;EACpB,OAAA;EACA,WAAA;AAAA;AAAA,iBAGO,QAAA,CAAA;EACP,cAAA;EACA,MAAA;EACA;AAAA;EAEA,cAAA,EAAgB,SAAA;EAChB,MAAA,EAAQ,uBAAA;EACR,MAAA;AAAA,IACE,SAAA"}
@@ -1,2 +1,2 @@
1
- import{addGTIdentifier as e}from"../internal/addGTIdentifier.mjs";import{removeInjectedT as t}from"../internal/removeInjectedT.mjs";import{writeChildrenAsObjects as n}from"../internal/writeChildrenAsObjects.mjs";function r({sourceChildren:e,params:t,locale:n}){let r=i(e);return{taggedSourceChildren:r,sourceJsxChildren:a(r),targetOptions:o({options:s(t),locale:n})}}function i(n){return e(t(n))}function a(e){return n(e)}function o({options:e,locale:t}){return{...e,$locale:t}}function s(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}export{r as prepareT};
1
+ import{resolveTagHash as e}from"./resolveTagHash.mjs";import{addGTIdentifier as t}from"../internal/addGTIdentifier.mjs";import{removeInjectedT as n}from"../internal/removeInjectedT.mjs";import{writeChildrenAsObjects as r}from"../internal/writeChildrenAsObjects.mjs";function i({sourceChildren:t,params:n,locale:r}){let i=a(t),l=o(i),u=s({options:c(n),locale:r});return e(l,u),{taggedSourceChildren:i,sourceJsxChildren:l,targetOptions:u}}function a(e){return t(n(e))}function o(e){return r(e)}function s({options:e,locale:t}){return{...e,$locale:t}}function c(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}export{i as prepareT};
2
2
  //# sourceMappingURL=prepareT.shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareT.shared.mjs","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"oNA2CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAKxE,MAAO,CACL,uBACA,kBANwB,EAAyB,EAMhC,CACjB,cALoB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAK/C,CACd,CAGH,SAAS,EACP,EACgB,CAChB,OAAO,EAAgB,EAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAO,EAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
1
+ {"version":3,"file":"prepareT.shared.mjs","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\nimport { resolveTagHash } from './resolveTagHash';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n // Caches the id-tagging hash onto targetOptions.$_hash so the lookup reuses it.\n resolveTagHash(sourceJsxChildren, targetOptions);\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"0QA4CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAClE,EAAoB,EAAyB,EAAqB,CAElE,EAAgB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAAC,CAK/D,OAFA,EAAe,EAAmB,EAAc,CAEzC,CACL,uBACA,oBACA,gBACD,CAGH,SAAS,EACP,EACgB,CAChB,OAAO,EAAgB,EAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAO,EAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`gt-i18n/internal`);function t(){let t=(0,e.getI18nConfig)();return typeof t.isIdTaggingEnabled==`function`&&t.isIdTaggingEnabled()}function n(...n){if(!t())return;let r=(0,e.hashMessage)(...n);return n[1].$_hash=r,r}exports.idTaggingEnabled=t,exports.resolveTagHash=n;
2
+ //# sourceMappingURL=resolveTagHash.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTagHash.cjs","names":[],"sources":["../../../src/utils/translation/resolveTagHash.ts"],"sourcesContent":["import { getI18nConfig, hashMessage } from 'gt-i18n/internal';\n\n// Capability-safe id-tagging gate. isIdTaggingEnabled lives on react-core's\n// ReactI18nConfig, but the config is a first-writer-wins singleton shared across\n// bundled package copies, so an OLDER copy — which has no isIdTaggingEnabled\n// method — can win initialization. Calling it unconditionally would throw a\n// TypeError on EVERY <T>/<Tx> render; treat a missing method as disabled.\nexport function idTaggingEnabled(): boolean {\n const config = getI18nConfig() as { isIdTaggingEnabled?: () => boolean };\n return (\n typeof config.isIdTaggingEnabled === 'function' &&\n config.isIdTaggingEnabled()\n );\n}\n\n// Single source of truth for the <T> id-tagging hash. Returns the translation\n// hash ONLY when id-tagging is enabled (otherwise `undefined` → the output is\n// rendered untouched, so apps not using the feature pay nothing).\n//\n// It also CACHES the result on `options.$_hash`. hashMessage short-circuits to\n// `options.$_hash` when present, so every downstream hash of these same options\n// — the translation lookup (client store + RSC cache key both go through\n// hashMessage) — reuses this value instead of hashing again. Net effect when\n// id-tagging is on: a single hash shared by tag + lookup, or ZERO extra hashing\n// when the compiler already injected `$_hash`. Called from prepareT (once,\n// BEFORE the lookup) so the lookup benefits from the cached value.\nexport function resolveTagHash(\n ...args: Parameters<typeof hashMessage>\n): string | undefined {\n if (!idTaggingEnabled()) {\n return undefined;\n }\n const hash = hashMessage(...args); // reuses args[1].$_hash when already set\n (args[1] as { $_hash?: string }).$_hash = hash; // cache for the lookup\n return hash;\n}\n"],"mappings":"kFAOA,SAAgB,GAA4B,CAC1C,IAAM,GAAA,EAAA,EAAA,gBAAwB,CAC9B,OACE,OAAO,EAAO,oBAAuB,YACrC,EAAO,oBAAoB,CAe/B,SAAgB,EACd,GAAG,EACiB,CACpB,GAAI,CAAC,GAAkB,CACrB,OAEF,IAAM,GAAA,EAAA,EAAA,aAAmB,GAAG,EAAK,CAEjC,MADC,GAAK,GAA2B,OAAS,EACnC"}
@@ -0,0 +1,2 @@
1
+ import{getI18nConfig as e,hashMessage as t}from"gt-i18n/internal";function n(){let t=e();return typeof t.isIdTaggingEnabled==`function`&&t.isIdTaggingEnabled()}function r(...e){if(!n())return;let r=t(...e);return e[1].$_hash=r,r}export{n as idTaggingEnabled,r as resolveTagHash};
2
+ //# sourceMappingURL=resolveTagHash.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTagHash.mjs","names":[],"sources":["../../../src/utils/translation/resolveTagHash.ts"],"sourcesContent":["import { getI18nConfig, hashMessage } from 'gt-i18n/internal';\n\n// Capability-safe id-tagging gate. isIdTaggingEnabled lives on react-core's\n// ReactI18nConfig, but the config is a first-writer-wins singleton shared across\n// bundled package copies, so an OLDER copy — which has no isIdTaggingEnabled\n// method — can win initialization. Calling it unconditionally would throw a\n// TypeError on EVERY <T>/<Tx> render; treat a missing method as disabled.\nexport function idTaggingEnabled(): boolean {\n const config = getI18nConfig() as { isIdTaggingEnabled?: () => boolean };\n return (\n typeof config.isIdTaggingEnabled === 'function' &&\n config.isIdTaggingEnabled()\n );\n}\n\n// Single source of truth for the <T> id-tagging hash. Returns the translation\n// hash ONLY when id-tagging is enabled (otherwise `undefined` → the output is\n// rendered untouched, so apps not using the feature pay nothing).\n//\n// It also CACHES the result on `options.$_hash`. hashMessage short-circuits to\n// `options.$_hash` when present, so every downstream hash of these same options\n// — the translation lookup (client store + RSC cache key both go through\n// hashMessage) — reuses this value instead of hashing again. Net effect when\n// id-tagging is on: a single hash shared by tag + lookup, or ZERO extra hashing\n// when the compiler already injected `$_hash`. Called from prepareT (once,\n// BEFORE the lookup) so the lookup benefits from the cached value.\nexport function resolveTagHash(\n ...args: Parameters<typeof hashMessage>\n): string | undefined {\n if (!idTaggingEnabled()) {\n return undefined;\n }\n const hash = hashMessage(...args); // reuses args[1].$_hash when already set\n (args[1] as { $_hash?: string }).$_hash = hash; // cache for the lookup\n return hash;\n}\n"],"mappings":"kEAOA,SAAgB,GAA4B,CAC1C,IAAM,EAAS,GAAe,CAC9B,OACE,OAAO,EAAO,oBAAuB,YACrC,EAAO,oBAAoB,CAe/B,SAAgB,EACd,GAAG,EACiB,CACpB,GAAI,CAAC,GAAkB,CACrB,OAEF,IAAM,EAAO,EAAY,GAAG,EAAK,CAEjC,MADC,GAAK,GAA2B,OAAS,EACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/react-core",
3
- "version": "11.1.5",
3
+ "version": "11.1.6",
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.4",
15
- "generaltranslation": "9.1.1",
16
- "gt-i18n": "1.0.11"
15
+ "gt-i18n": "1.0.12",
16
+ "generaltranslation": "9.1.2"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",