@generaltranslation/react-core 11.1.6-iris.0 → 11.1.7-iris.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/LICENSE.md +18 -102
- package/dist/components/translation/T.cjs +1 -1
- package/dist/components/translation/T.cjs.map +1 -1
- package/dist/components/translation/T.mjs +1 -1
- package/dist/components/translation/T.mjs.map +1 -1
- package/dist/components/translation/T.rsc.cjs +1 -1
- package/dist/components/translation/T.rsc.cjs.map +1 -1
- package/dist/components/translation/T.rsc.mjs +1 -1
- package/dist/components/translation/T.rsc.mjs.map +1 -1
- package/dist/components/translation/Tx.rsc.cjs +1 -1
- package/dist/components/translation/Tx.rsc.cjs.map +1 -1
- package/dist/components/translation/Tx.rsc.mjs +1 -1
- package/dist/components/translation/Tx.rsc.mjs.map +1 -1
- package/dist/setup/i18nConfig.cjs +1 -1
- package/dist/setup/i18nConfig.cjs.map +1 -1
- package/dist/setup/i18nConfig.d.ts +5 -0
- package/dist/setup/i18nConfig.d.ts.map +1 -1
- package/dist/setup/i18nConfig.mjs +1 -1
- package/dist/setup/i18nConfig.mjs.map +1 -1
- package/dist/utils/rendering/renderPreparedT.shared.cjs +1 -1
- package/dist/utils/rendering/renderPreparedT.shared.cjs.map +1 -1
- package/dist/utils/rendering/renderPreparedT.shared.d.ts +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.d.ts.map +1 -1
- package/dist/utils/rendering/renderPreparedT.shared.mjs +1 -1
- package/dist/utils/rendering/renderPreparedT.shared.mjs.map +1 -1
- package/dist/utils/translation/prepareT.shared.cjs +1 -1
- package/dist/utils/translation/prepareT.shared.cjs.map +1 -1
- package/dist/utils/translation/prepareT.shared.d.ts.map +1 -1
- package/dist/utils/translation/prepareT.shared.mjs +1 -1
- package/dist/utils/translation/prepareT.shared.mjs.map +1 -1
- package/dist/utils/translation/resolveTagHash.cjs +2 -0
- package/dist/utils/translation/resolveTagHash.cjs.map +1 -0
- package/dist/utils/translation/resolveTagHash.mjs +2 -0
- package/dist/utils/translation/resolveTagHash.mjs.map +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @generaltranslation/react-core
|
|
2
2
|
|
|
3
|
+
## 11.1.7-iris.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5d8b78a: Migrate the package license from FSL-1.1-ALv2 to MIT.
|
|
8
|
+
- Updated dependencies [f2204b9]
|
|
9
|
+
- Updated dependencies [b05b470]
|
|
10
|
+
- Updated dependencies [5d8b78a]
|
|
11
|
+
- @generaltranslation/format@0.1.5-iris.0
|
|
12
|
+
- generaltranslation@9.1.3-iris.0
|
|
13
|
+
- gt-i18n@1.0.13-iris.0
|
|
14
|
+
|
|
3
15
|
## 11.1.6-iris.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -7,6 +19,18 @@
|
|
|
7
19
|
- Updated dependencies [8d376e2]
|
|
8
20
|
- gt-i18n@1.0.12-iris.0
|
|
9
21
|
|
|
22
|
+
## 11.1.6
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [#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.
|
|
27
|
+
|
|
28
|
+
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).
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`b00b93e`](https://github.com/generaltranslation/gt/commit/b00b93eb3b830b8528ef3dbd5f503ff76d1b338a)]:
|
|
31
|
+
- generaltranslation@9.1.2
|
|
32
|
+
- gt-i18n@1.0.12
|
|
33
|
+
|
|
10
34
|
## 11.1.5
|
|
11
35
|
|
|
12
36
|
### Patch Changes
|
package/LICENSE.md
CHANGED
|
@@ -1,105 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## Abbreviation
|
|
4
|
-
|
|
5
|
-
FSL-1.1-ALv2
|
|
6
|
-
|
|
7
|
-
## Notice
|
|
1
|
+
MIT License
|
|
8
2
|
|
|
9
3
|
Copyright 2025 General Translation, Inc.
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
-
|
|
30
|
-
### Permitted Purpose
|
|
31
|
-
|
|
32
|
-
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
-
means making the Software available to others in a commercial product or
|
|
34
|
-
service that:
|
|
35
|
-
|
|
36
|
-
1. substitutes for the Software;
|
|
37
|
-
|
|
38
|
-
2. substitutes for any other product or service we offer using the Software
|
|
39
|
-
that exists as of the date we make the Software available; or
|
|
40
|
-
|
|
41
|
-
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
-
|
|
43
|
-
Permitted Purposes specifically include using the Software:
|
|
44
|
-
|
|
45
|
-
1. for your internal use and access;
|
|
46
|
-
|
|
47
|
-
2. for non-commercial education;
|
|
48
|
-
|
|
49
|
-
3. for non-commercial research; and
|
|
50
|
-
|
|
51
|
-
4. in connection with professional services that you provide to a licensee
|
|
52
|
-
using the Software in accordance with these Terms and Conditions.
|
|
53
|
-
|
|
54
|
-
### Patents
|
|
55
|
-
|
|
56
|
-
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
-
patents, the license grant above includes a license under our patents. If you
|
|
58
|
-
make a claim against any party that the Software infringes or contributes to
|
|
59
|
-
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
-
immediately.
|
|
61
|
-
|
|
62
|
-
### Redistribution
|
|
63
|
-
|
|
64
|
-
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
-
the Software.
|
|
66
|
-
|
|
67
|
-
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
-
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
-
remove any copyright notices provided in or with the Software.
|
|
70
|
-
|
|
71
|
-
### Disclaimer
|
|
72
|
-
|
|
73
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
-
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
-
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
-
|
|
77
|
-
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
-
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
-
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
-
|
|
81
|
-
### Trademarks
|
|
82
|
-
|
|
83
|
-
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
-
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
-
trademarks, trade names, service marks or product names.
|
|
86
|
-
|
|
87
|
-
## Grant of Future License
|
|
88
|
-
|
|
89
|
-
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
-
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
-
the date we make the Software available. On or after that date, you may use the
|
|
92
|
-
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
-
will apply:
|
|
94
|
-
|
|
95
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
-
this file except in compliance with the License.
|
|
97
|
-
|
|
98
|
-
You may obtain a copy of the License at
|
|
99
|
-
|
|
100
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
-
|
|
102
|
-
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
-
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
-
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
-
specific language governing permissions and limitations under the License.
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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`);let e=require(`gt-i18n/internal`),t=require(`generaltranslation/internal`),n=require(`gt-i18n/internal/cookies`);const r=`server-render`,i=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var a=class extends e.I18nConfig{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=r){super(e),l(t),Object.defineProperty(this,i,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??n.defaultLocaleCookieName,this.regionCookieName=e.regionCookieName??n.defaultRegionCookieName,this.enableI18nCookieName=e.enableI18nCookieName??n.defaultEnableI18nCookieName}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function o(){let n=(0,e.getI18nConfig)();if(u(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 s(t){(0,e.setI18nConfig)(t)}function c(e={},t=r){let n=new a(e,t);return s(n),n}function l(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 u(e){if(e instanceof a)return!0;let t=e;return t[i]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}exports.getI18nConfig=o,exports.initializeI18nConfig=c;
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`gt-i18n/internal`),t=require(`generaltranslation/internal`),n=require(`gt-i18n/internal/cookies`);const r=`server-render`,i=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var a=class extends e.I18nConfig{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(e={},t=r){super(e),l(t),Object.defineProperty(this,i,{value:!0}),this.renderStrategy=t,this.localeCookieName=e.localeCookieName??n.defaultLocaleCookieName,this.regionCookieName=e.regionCookieName??n.defaultRegionCookieName,this.enableI18nCookieName=e.enableI18nCookieName??n.defaultEnableI18nCookieName}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}isIdTaggingEnabled(){return this.runtimeConfig._tagIds===!0}};function o(){let n=(0,e.getI18nConfig)();if(u(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 s(t){(0,e.setI18nConfig)(t)}function c(e={},t=r){let n=new a(e,t);return s(n),n}function l(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 u(e){if(e instanceof a)return!0;let t=e;return t[i]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}exports.getI18nConfig=o,exports.initializeI18nConfig=c;
|
|
2
2
|
//# sourceMappingURL=i18nConfig.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nConfig.cjs","names":["I18nConfig","defaultLocaleCookieName","defaultRegionCookieName","defaultEnableI18nCookieName"],"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":"8JA4BA,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,kBAAoBC,EAAAA,wBACnD,KAAK,iBAAmB,EAAO,kBAAoBC,EAAAA,wBACnD,KAAK,qBACH,EAAO,sBAAwBC,EAAAA,4BAGnC,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"i18nConfig.cjs","names":["I18nConfig","defaultLocaleCookieName","defaultRegionCookieName","defaultEnableI18nCookieName"],"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":"8JA4BA,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,kBAAoBC,EAAAA,wBACnD,KAAK,iBAAmB,EAAO,kBAAoBC,EAAAA,wBACnD,KAAK,qBACH,EAAO,sBAAwBC,EAAAA,4BAGnC,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{defaultEnableI18nCookieName as e,defaultLocaleCookieName as t,defaultRegionCookieName as n}from"./cookieNames.mjs";import{I18nConfig as r,getI18nConfig as i,setI18nConfig as a}from"gt-i18n/internal";import{createDiagnosticMessage as o}from"generaltranslation/internal";const s=`server-render`,c=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var l=class extends r{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(r={},i=s){super(r),p(i),Object.defineProperty(this,c,{value:!0}),this.renderStrategy=i,this.localeCookieName=r.localeCookieName??t,this.regionCookieName=r.regionCookieName??n,this.enableI18nCookieName=r.enableI18nCookieName??e}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}};function u(){let e=i();if(m(e))return e;throw Error(o({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 d(e){a(e)}function f(e={},t=s){let n=new l(e,t);return d(n),n}function p(e){if(!(e===`SPA`||e===`server-render`))throw Error(o({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 m(e){if(e instanceof l)return!0;let t=e;return t[c]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}export{u as getI18nConfig,f as initializeI18nConfig};
|
|
1
|
+
import{defaultEnableI18nCookieName as e,defaultLocaleCookieName as t,defaultRegionCookieName as n}from"./cookieNames.mjs";import{I18nConfig as r,getI18nConfig as i,setI18nConfig as a}from"gt-i18n/internal";import{createDiagnosticMessage as o}from"generaltranslation/internal";const s=`server-render`,c=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var l=class extends r{renderStrategy;localeCookieName;regionCookieName;enableI18nCookieName;constructor(r={},i=s){super(r),p(i),Object.defineProperty(this,c,{value:!0}),this.renderStrategy=i,this.localeCookieName=r.localeCookieName??t,this.regionCookieName=r.regionCookieName??n,this.enableI18nCookieName=r.enableI18nCookieName??e}getRenderStrategy(){return this.renderStrategy}getLocaleCookieName(){return this.localeCookieName}getRegionCookieName(){return this.regionCookieName}getEnableI18nCookieName(){return this.enableI18nCookieName}isIdTaggingEnabled(){return this.runtimeConfig._tagIds===!0}};function u(){let e=i();if(m(e))return e;throw Error(o({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 d(e){a(e)}function f(e={},t=s){let n=new l(e,t);return d(n),n}function p(e){if(!(e===`SPA`||e===`server-render`))throw Error(o({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 m(e){if(e instanceof l)return!0;let t=e;return t[c]===!0&&typeof t.getRenderStrategy==`function`&&typeof t.getLocaleCookieName==`function`&&typeof t.getRegionCookieName==`function`&&typeof t.getEnableI18nCookieName==`function`}export{u as getI18nConfig,f 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":"oRA4BA,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,kBAAoB,EACnD,KAAK,iBAAmB,EAAO,kBAAoB,EACnD,KAAK,qBACH,EAAO,sBAAwB,EAGnC,mBAAoC,CAClC,OAAO,KAAK,eAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,qBAA8B,CAC5B,OAAO,KAAK,iBAGd,yBAAkC,CAChC,OAAO,KAAK,
|
|
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":"oRA4BA,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,kBAAoB,EACnD,KAAK,iBAAmB,EAAO,kBAAoB,EACnD,KAAK,qBACH,EAAO,sBAAwB,EAGnC,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:
|
|
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
|
|
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 // The shared persisted wire also admits empty-rendering boolean/null\n // values. The outer null check and existing renderer fallback own those\n // cases; this narrower internal renderer type describes its recursive\n // element/string grammar without changing React runtime behavior.\n target: targetJsxChildren as RenderTranslatedChildrenArgs['target'],\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,EAKR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderPreparedT.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"mappings":";;;;;
|
|
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}){
|
|
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
|
|
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 // The shared persisted wire also admits empty-rendering boolean/null\n // values. The outer null check and existing renderer fallback own those\n // cases; this narrower internal renderer type describes its recursive\n // element/string grammar without changing React runtime behavior.\n target: targetJsxChildren as RenderTranslatedChildrenArgs['target'],\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,EAKR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../internal/addGTIdentifier.cjs`),
|
|
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":"
|
|
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":";;;;;;;
|
|
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{
|
|
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":"
|
|
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.
|
|
3
|
+
"version": "11.1.7-iris.0",
|
|
4
4
|
"description": "A pure React library for internationalization",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"react": ">=18.0.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@generaltranslation/format": "0.1.
|
|
15
|
-
"generaltranslation": "9.1.
|
|
16
|
-
"gt-i18n": "1.0.
|
|
14
|
+
"@generaltranslation/format": "0.1.5-iris.0",
|
|
15
|
+
"generaltranslation": "9.1.3-iris.0",
|
|
16
|
+
"gt-i18n": "1.0.13-iris.0"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "git+https://github.com/generaltranslation/gt.git"
|
|
21
21
|
},
|
|
22
22
|
"author": "General Translation, Inc.",
|
|
23
|
-
"license": "
|
|
23
|
+
"license": "MIT",
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/generaltranslation/gt/issues"
|
|
26
26
|
},
|