@generaltranslation/react-core 11.0.0-odysseus.4 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/CHANGELOG.md +301 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/components/branches/Branch.cjs +2 -0
  4. package/dist/components/branches/Branch.cjs.map +1 -0
  5. package/dist/components/branches/Branch.d.ts +30 -0
  6. package/dist/components/branches/Branch.d.ts.map +1 -0
  7. package/dist/components/branches/Branch.mjs +2 -0
  8. package/dist/components/branches/Branch.mjs.map +1 -0
  9. package/dist/components/branches/Plural.cjs +2 -0
  10. package/dist/components/branches/Plural.cjs.map +1 -0
  11. package/dist/components/branches/Plural.d.ts +19 -0
  12. package/dist/components/branches/Plural.d.ts.map +1 -0
  13. package/dist/components/branches/Plural.mjs +2 -0
  14. package/dist/components/branches/Plural.mjs.map +1 -0
  15. package/dist/components/branches/Plural.rsc.cjs +2 -0
  16. package/dist/components/branches/Plural.rsc.cjs.map +1 -0
  17. package/dist/components/branches/Plural.rsc.d.ts +15 -0
  18. package/dist/components/branches/Plural.rsc.d.ts.map +1 -0
  19. package/dist/components/branches/Plural.rsc.mjs +2 -0
  20. package/dist/components/branches/Plural.rsc.mjs.map +1 -0
  21. package/dist/components/branches/Plural.shared.cjs +2 -0
  22. package/dist/components/branches/Plural.shared.cjs.map +1 -0
  23. package/dist/components/branches/Plural.shared.d.ts +18 -0
  24. package/dist/components/branches/Plural.shared.d.ts.map +1 -0
  25. package/dist/components/branches/Plural.shared.mjs +2 -0
  26. package/dist/components/branches/Plural.shared.mjs.map +1 -0
  27. package/dist/components/derivation/Derive.cjs +2 -0
  28. package/dist/components/derivation/Derive.cjs.map +1 -0
  29. package/dist/components/derivation/Derive.d.ts +19 -0
  30. package/dist/components/derivation/Derive.d.ts.map +1 -0
  31. package/dist/components/derivation/Derive.mjs +2 -0
  32. package/dist/components/derivation/Derive.mjs.map +1 -0
  33. package/dist/components/helpers/InternalLocaleSelector.cjs +2 -0
  34. package/dist/components/helpers/InternalLocaleSelector.cjs.map +1 -0
  35. package/dist/components/helpers/InternalLocaleSelector.d.ts +38 -0
  36. package/dist/components/helpers/InternalLocaleSelector.d.ts.map +1 -0
  37. package/dist/components/helpers/InternalLocaleSelector.mjs +2 -0
  38. package/dist/components/helpers/InternalLocaleSelector.mjs.map +1 -0
  39. package/dist/components/helpers/InternalRegionSelector.cjs +2 -0
  40. package/dist/components/helpers/InternalRegionSelector.cjs.map +1 -0
  41. package/dist/components/helpers/InternalRegionSelector.d.ts +33 -0
  42. package/dist/components/helpers/InternalRegionSelector.d.ts.map +1 -0
  43. package/dist/components/helpers/InternalRegionSelector.mjs +2 -0
  44. package/dist/components/helpers/InternalRegionSelector.mjs.map +1 -0
  45. package/dist/components/translation/T.cjs +2 -0
  46. package/dist/components/translation/T.cjs.map +1 -0
  47. package/dist/components/translation/T.d.ts +18 -0
  48. package/dist/components/translation/T.d.ts.map +1 -0
  49. package/dist/components/translation/T.mjs +2 -0
  50. package/dist/components/translation/T.mjs.map +1 -0
  51. package/dist/components/translation/T.rsc.cjs +2 -0
  52. package/dist/components/translation/T.rsc.cjs.map +1 -0
  53. package/dist/components/translation/T.rsc.d.ts +17 -0
  54. package/dist/components/translation/T.rsc.d.ts.map +1 -0
  55. package/dist/components/translation/T.rsc.mjs +2 -0
  56. package/dist/components/translation/T.rsc.mjs.map +1 -0
  57. package/dist/components/translation/Tx.rsc.cjs +2 -0
  58. package/dist/components/translation/Tx.rsc.cjs.map +1 -0
  59. package/dist/components/translation/Tx.rsc.d.ts +17 -0
  60. package/dist/components/translation/Tx.rsc.d.ts.map +1 -0
  61. package/dist/components/translation/Tx.rsc.mjs +2 -0
  62. package/dist/components/translation/Tx.rsc.mjs.map +1 -0
  63. package/dist/components/variables/Currency.cjs +2 -0
  64. package/dist/components/variables/Currency.cjs.map +1 -0
  65. package/dist/components/variables/Currency.d.ts +18 -0
  66. package/dist/components/variables/Currency.d.ts.map +1 -0
  67. package/dist/components/variables/Currency.mjs +2 -0
  68. package/dist/components/variables/Currency.mjs.map +1 -0
  69. package/dist/components/variables/Currency.rsc.cjs +2 -0
  70. package/dist/components/variables/Currency.rsc.cjs.map +1 -0
  71. package/dist/components/variables/Currency.rsc.d.ts +14 -0
  72. package/dist/components/variables/Currency.rsc.d.ts.map +1 -0
  73. package/dist/components/variables/Currency.rsc.mjs +2 -0
  74. package/dist/components/variables/Currency.rsc.mjs.map +1 -0
  75. package/dist/components/variables/Currency.shared.cjs +2 -0
  76. package/dist/components/variables/Currency.shared.cjs.map +1 -0
  77. package/dist/components/variables/Currency.shared.d.ts +17 -0
  78. package/dist/components/variables/Currency.shared.d.ts.map +1 -0
  79. package/dist/components/variables/Currency.shared.mjs +2 -0
  80. package/dist/components/variables/Currency.shared.mjs.map +1 -0
  81. package/dist/components/variables/DateTime.cjs +2 -0
  82. package/dist/components/variables/DateTime.cjs.map +1 -0
  83. package/dist/components/variables/DateTime.d.ts +18 -0
  84. package/dist/components/variables/DateTime.d.ts.map +1 -0
  85. package/dist/components/variables/DateTime.mjs +2 -0
  86. package/dist/components/variables/DateTime.mjs.map +1 -0
  87. package/dist/components/variables/DateTime.rsc.cjs +2 -0
  88. package/dist/components/variables/DateTime.rsc.cjs.map +1 -0
  89. package/dist/components/variables/DateTime.rsc.d.ts +14 -0
  90. package/dist/components/variables/DateTime.rsc.d.ts.map +1 -0
  91. package/dist/components/variables/DateTime.rsc.mjs +2 -0
  92. package/dist/components/variables/DateTime.rsc.mjs.map +1 -0
  93. package/dist/components/variables/DateTime.shared.cjs +2 -0
  94. package/dist/components/variables/DateTime.shared.cjs.map +1 -0
  95. package/dist/components/variables/DateTime.shared.d.ts +16 -0
  96. package/dist/components/variables/DateTime.shared.d.ts.map +1 -0
  97. package/dist/components/variables/DateTime.shared.mjs +2 -0
  98. package/dist/components/variables/DateTime.shared.mjs.map +1 -0
  99. package/dist/components/variables/Num.cjs +2 -0
  100. package/dist/components/variables/Num.cjs.map +1 -0
  101. package/dist/components/variables/Num.d.ts +18 -0
  102. package/dist/components/variables/Num.d.ts.map +1 -0
  103. package/dist/components/variables/Num.mjs +2 -0
  104. package/dist/components/variables/Num.mjs.map +1 -0
  105. package/dist/components/variables/Num.rsc.cjs +2 -0
  106. package/dist/components/variables/Num.rsc.cjs.map +1 -0
  107. package/dist/components/variables/Num.rsc.d.ts +14 -0
  108. package/dist/components/variables/Num.rsc.d.ts.map +1 -0
  109. package/dist/components/variables/Num.rsc.mjs +2 -0
  110. package/dist/components/variables/Num.rsc.mjs.map +1 -0
  111. package/dist/components/variables/Num.shared.cjs +2 -0
  112. package/dist/components/variables/Num.shared.cjs.map +1 -0
  113. package/dist/components/variables/Num.shared.d.ts +16 -0
  114. package/dist/components/variables/Num.shared.d.ts.map +1 -0
  115. package/dist/components/variables/Num.shared.mjs +2 -0
  116. package/dist/components/variables/Num.shared.mjs.map +1 -0
  117. package/dist/components/variables/RelativeTime.cjs +2 -0
  118. package/dist/components/variables/RelativeTime.cjs.map +1 -0
  119. package/dist/components/variables/RelativeTime.d.ts +18 -0
  120. package/dist/components/variables/RelativeTime.d.ts.map +1 -0
  121. package/dist/components/variables/RelativeTime.mjs +2 -0
  122. package/dist/components/variables/RelativeTime.mjs.map +1 -0
  123. package/dist/components/variables/RelativeTime.rsc.cjs +2 -0
  124. package/dist/components/variables/RelativeTime.rsc.cjs.map +1 -0
  125. package/dist/components/variables/RelativeTime.rsc.d.ts +14 -0
  126. package/dist/components/variables/RelativeTime.rsc.d.ts.map +1 -0
  127. package/dist/components/variables/RelativeTime.rsc.mjs +2 -0
  128. package/dist/components/variables/RelativeTime.rsc.mjs.map +1 -0
  129. package/dist/components/variables/RelativeTime.shared.cjs +2 -0
  130. package/dist/components/variables/RelativeTime.shared.cjs.map +1 -0
  131. package/dist/components/variables/RelativeTime.shared.d.ts +20 -0
  132. package/dist/components/variables/RelativeTime.shared.d.ts.map +1 -0
  133. package/dist/components/variables/RelativeTime.shared.mjs +2 -0
  134. package/dist/components/variables/RelativeTime.shared.mjs.map +1 -0
  135. package/dist/components/variables/Var.cjs +2 -0
  136. package/dist/components/variables/Var.cjs.map +1 -0
  137. package/dist/components/variables/Var.d.ts +27 -0
  138. package/dist/components/variables/Var.d.ts.map +1 -0
  139. package/dist/components/variables/Var.mjs +2 -0
  140. package/dist/components/variables/Var.mjs.map +1 -0
  141. package/dist/components-rsc.cjs +1 -0
  142. package/dist/components-rsc.d.ts +32 -531
  143. package/dist/components-rsc.mjs +1 -0
  144. package/dist/components.cjs +1 -0
  145. package/dist/components.d.ts +14 -495
  146. package/dist/components.mjs +1 -0
  147. package/dist/condition-store/singleton-operations.cjs +2 -0
  148. package/dist/condition-store/singleton-operations.cjs.map +1 -0
  149. package/dist/condition-store/singleton-operations.d.ts +7 -0
  150. package/dist/condition-store/singleton-operations.d.ts.map +1 -0
  151. package/dist/condition-store/singleton-operations.mjs +2 -0
  152. package/dist/condition-store/singleton-operations.mjs.map +1 -0
  153. package/dist/context/InternalGTProvider.cjs +2 -0
  154. package/dist/context/InternalGTProvider.cjs.map +1 -0
  155. package/dist/context/InternalGTProvider.d.ts +39 -0
  156. package/dist/context/InternalGTProvider.d.ts.map +1 -0
  157. package/dist/context/InternalGTProvider.mjs +2 -0
  158. package/dist/context/InternalGTProvider.mjs.map +1 -0
  159. package/dist/context/context.cjs +2 -0
  160. package/dist/context/context.cjs.map +1 -0
  161. package/dist/context/context.mjs +2 -0
  162. package/dist/context/context.mjs.map +1 -0
  163. package/dist/functions/helpers/getTranslationsSnapshot.cjs +2 -0
  164. package/dist/functions/helpers/getTranslationsSnapshot.cjs.map +1 -0
  165. package/dist/functions/helpers/getTranslationsSnapshot.d.ts +14 -0
  166. package/dist/functions/helpers/getTranslationsSnapshot.d.ts.map +1 -0
  167. package/dist/functions/helpers/getTranslationsSnapshot.mjs +2 -0
  168. package/dist/functions/helpers/getTranslationsSnapshot.mjs.map +1 -0
  169. package/dist/functions/translation/t.cjs +2 -0
  170. package/dist/functions/translation/t.cjs.map +1 -0
  171. package/dist/functions/translation/t.d.ts +34 -0
  172. package/dist/functions/translation/t.d.ts.map +1 -0
  173. package/dist/functions/translation/t.mjs +2 -0
  174. package/dist/functions/translation/t.mjs.map +1 -0
  175. package/dist/hooks/condition-store.cjs +2 -0
  176. package/dist/hooks/condition-store.cjs.map +1 -0
  177. package/dist/hooks/condition-store.d.ts +23 -0
  178. package/dist/hooks/condition-store.d.ts.map +1 -0
  179. package/dist/hooks/condition-store.mjs +2 -0
  180. package/dist/hooks/condition-store.mjs.map +1 -0
  181. package/dist/hooks/external-store/useSubscribeToTrackedLookups.cjs +2 -0
  182. package/dist/hooks/external-store/useSubscribeToTrackedLookups.cjs.map +1 -0
  183. package/dist/hooks/external-store/useSubscribeToTrackedLookups.mjs +2 -0
  184. package/dist/hooks/external-store/useSubscribeToTrackedLookups.mjs.map +1 -0
  185. package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs +2 -0
  186. package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs.map +1 -0
  187. package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs +2 -0
  188. package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs.map +1 -0
  189. package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs +2 -0
  190. package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs.map +1 -0
  191. package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs +2 -0
  192. package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs.map +1 -0
  193. package/dist/hooks/external-store/useTrackedTranslationResolver.cjs +2 -0
  194. package/dist/hooks/external-store/useTrackedTranslationResolver.cjs.map +1 -0
  195. package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts +10 -0
  196. package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts.map +1 -0
  197. package/dist/hooks/external-store/useTrackedTranslationResolver.mjs +2 -0
  198. package/dist/hooks/external-store/useTrackedTranslationResolver.mjs.map +1 -0
  199. package/dist/hooks/external-store.cjs +2 -0
  200. package/dist/hooks/external-store.cjs.map +1 -0
  201. package/dist/hooks/external-store.mjs +2 -0
  202. package/dist/hooks/external-store.mjs.map +1 -0
  203. package/dist/hooks/i18n-config.cjs +2 -0
  204. package/dist/hooks/i18n-config.cjs.map +1 -0
  205. package/dist/hooks/i18n-config.d.ts +9 -0
  206. package/dist/hooks/i18n-config.d.ts.map +1 -0
  207. package/dist/hooks/i18n-config.mjs +2 -0
  208. package/dist/hooks/i18n-config.mjs.map +1 -0
  209. package/dist/hooks/useGT.cjs +2 -0
  210. package/dist/hooks/useGT.cjs.map +1 -0
  211. package/dist/hooks/useGT.d.ts +8 -0
  212. package/dist/hooks/useGT.d.ts.map +1 -0
  213. package/dist/hooks/useGT.mjs +2 -0
  214. package/dist/hooks/useGT.mjs.map +1 -0
  215. package/dist/hooks/useInternalLocaleSelector.cjs +2 -0
  216. package/dist/hooks/useInternalLocaleSelector.cjs.map +1 -0
  217. package/dist/hooks/useInternalLocaleSelector.d.ts +12 -0
  218. package/dist/hooks/useInternalLocaleSelector.d.ts.map +1 -0
  219. package/dist/hooks/useInternalLocaleSelector.mjs +2 -0
  220. package/dist/hooks/useInternalLocaleSelector.mjs.map +1 -0
  221. package/dist/hooks/useInternalRegionSelector.cjs +2 -0
  222. package/dist/hooks/useInternalRegionSelector.cjs.map +1 -0
  223. package/dist/hooks/useInternalRegionSelector.d.ts +42 -0
  224. package/dist/hooks/useInternalRegionSelector.d.ts.map +1 -0
  225. package/dist/hooks/useInternalRegionSelector.mjs +2 -0
  226. package/dist/hooks/useInternalRegionSelector.mjs.map +1 -0
  227. package/dist/hooks/useMessages.cjs +2 -0
  228. package/dist/hooks/useMessages.cjs.map +1 -0
  229. package/dist/hooks/useMessages.d.ts +8 -0
  230. package/dist/hooks/useMessages.d.ts.map +1 -0
  231. package/dist/hooks/useMessages.mjs +2 -0
  232. package/dist/hooks/useMessages.mjs.map +1 -0
  233. package/dist/hooks/useTranslations.cjs +2 -0
  234. package/dist/hooks/useTranslations.cjs.map +1 -0
  235. package/dist/hooks/useTranslations.d.ts +10 -0
  236. package/dist/hooks/useTranslations.d.ts.map +1 -0
  237. package/dist/hooks/useTranslations.mjs +2 -0
  238. package/dist/hooks/useTranslations.mjs.map +1 -0
  239. package/dist/hooks/utils/getFormatLocales.cjs +2 -0
  240. package/dist/hooks/utils/getFormatLocales.cjs.map +1 -0
  241. package/dist/hooks/utils/getFormatLocales.d.ts +13 -0
  242. package/dist/hooks/utils/getFormatLocales.d.ts.map +1 -0
  243. package/dist/hooks/utils/getFormatLocales.mjs +2 -0
  244. package/dist/hooks/utils/getFormatLocales.mjs.map +1 -0
  245. package/dist/hooks/utils/getShouldTranslate.cjs +2 -0
  246. package/dist/hooks/utils/getShouldTranslate.cjs.map +1 -0
  247. package/dist/hooks/utils/getShouldTranslate.d.ts +8 -0
  248. package/dist/hooks/utils/getShouldTranslate.d.ts.map +1 -0
  249. package/dist/hooks/utils/getShouldTranslate.mjs +2 -0
  250. package/dist/hooks/utils/getShouldTranslate.mjs.map +1 -0
  251. package/dist/hooks/utils/missing-translation.cjs +2 -0
  252. package/dist/hooks/utils/missing-translation.cjs.map +1 -0
  253. package/dist/hooks/utils/missing-translation.d.ts +10 -0
  254. package/dist/hooks/utils/missing-translation.d.ts.map +1 -0
  255. package/dist/hooks/utils/missing-translation.mjs +2 -0
  256. package/dist/hooks/utils/missing-translation.mjs.map +1 -0
  257. package/dist/hooks/utils.cjs +2 -0
  258. package/dist/hooks/utils.cjs.map +1 -0
  259. package/dist/hooks/utils.d.ts +10 -0
  260. package/dist/hooks/utils.d.ts.map +1 -0
  261. package/dist/hooks/utils.mjs +2 -0
  262. package/dist/hooks/utils.mjs.map +1 -0
  263. package/dist/hooks.cjs +1 -0
  264. package/dist/hooks.d.ts +9 -130
  265. package/dist/hooks.mjs +1 -0
  266. package/dist/i18n-cache/ReactI18nCache.cjs +2 -0
  267. package/dist/i18n-cache/ReactI18nCache.cjs.map +1 -0
  268. package/dist/i18n-cache/ReactI18nCache.d.ts +10 -0
  269. package/dist/i18n-cache/ReactI18nCache.d.ts.map +1 -0
  270. package/dist/i18n-cache/ReactI18nCache.mjs +2 -0
  271. package/dist/i18n-cache/ReactI18nCache.mjs.map +1 -0
  272. package/dist/i18n-cache/singleton-operations.cjs +2 -0
  273. package/dist/i18n-cache/singleton-operations.cjs.map +1 -0
  274. package/dist/i18n-cache/singleton-operations.d.ts +8 -0
  275. package/dist/i18n-cache/singleton-operations.d.ts.map +1 -0
  276. package/dist/i18n-cache/singleton-operations.mjs +2 -0
  277. package/dist/i18n-cache/singleton-operations.mjs.map +1 -0
  278. package/dist/i18n-store/I18nStore.cjs +2 -0
  279. package/dist/i18n-store/I18nStore.cjs.map +1 -0
  280. package/dist/i18n-store/I18nStore.d.ts +41 -0
  281. package/dist/i18n-store/I18nStore.d.ts.map +1 -0
  282. package/dist/i18n-store/I18nStore.mjs +2 -0
  283. package/dist/i18n-store/I18nStore.mjs.map +1 -0
  284. package/dist/i18n-store/singleton-operations.cjs +2 -0
  285. package/dist/i18n-store/singleton-operations.cjs.map +1 -0
  286. package/dist/i18n-store/singleton-operations.d.ts +7 -0
  287. package/dist/i18n-store/singleton-operations.d.ts.map +1 -0
  288. package/dist/i18n-store/singleton-operations.mjs +2 -0
  289. package/dist/i18n-store/singleton-operations.mjs.map +1 -0
  290. package/dist/i18n-store/storeTypes.d.ts +22 -0
  291. package/dist/i18n-store/storeTypes.d.ts.map +1 -0
  292. package/dist/i18n-store/useI18nStore.cjs +2 -0
  293. package/dist/i18n-store/useI18nStore.cjs.map +1 -0
  294. package/dist/i18n-store/useI18nStore.mjs +2 -0
  295. package/dist/i18n-store/useI18nStore.mjs.map +1 -0
  296. package/dist/i18n-store/utils/dictionaries.cjs +2 -0
  297. package/dist/i18n-store/utils/dictionaries.cjs.map +1 -0
  298. package/dist/i18n-store/utils/dictionaries.mjs +2 -0
  299. package/dist/i18n-store/utils/dictionaries.mjs.map +1 -0
  300. package/dist/i18n-store/utils/subscriptions.cjs +2 -0
  301. package/dist/i18n-store/utils/subscriptions.cjs.map +1 -0
  302. package/dist/i18n-store/utils/subscriptions.mjs +2 -0
  303. package/dist/i18n-store/utils/subscriptions.mjs.map +1 -0
  304. package/dist/i18n-store/utils/translations.cjs +2 -0
  305. package/dist/i18n-store/utils/translations.cjs.map +1 -0
  306. package/dist/i18n-store/utils/translations.mjs +2 -0
  307. package/dist/i18n-store/utils/translations.mjs.map +1 -0
  308. package/dist/pure.cjs +1 -0
  309. package/dist/pure.d.ts +18 -677
  310. package/dist/pure.mjs +1 -0
  311. package/dist/setup/i18nConfig.cjs +2 -0
  312. package/dist/setup/i18nConfig.cjs.map +1 -0
  313. package/dist/setup/i18nConfig.d.ts +48 -0
  314. package/dist/setup/i18nConfig.d.ts.map +1 -0
  315. package/dist/setup/i18nConfig.mjs +2 -0
  316. package/dist/setup/i18nConfig.mjs.map +1 -0
  317. package/dist/setup/initializeGTSRA.cjs +2 -0
  318. package/dist/setup/initializeGTSRA.cjs.map +1 -0
  319. package/dist/setup/initializeGTSRA.d.ts +11 -0
  320. package/dist/setup/initializeGTSRA.d.ts.map +1 -0
  321. package/dist/setup/initializeGTSRA.mjs +2 -0
  322. package/dist/setup/initializeGTSRA.mjs.map +1 -0
  323. package/dist/utils/internal/addGTIdentifier.cjs +2 -0
  324. package/dist/utils/internal/addGTIdentifier.cjs.map +1 -0
  325. package/dist/utils/internal/addGTIdentifier.mjs +2 -0
  326. package/dist/utils/internal/addGTIdentifier.mjs.map +1 -0
  327. package/dist/utils/internal/removeInjectedT.cjs +2 -0
  328. package/dist/utils/internal/removeInjectedT.cjs.map +1 -0
  329. package/dist/utils/internal/removeInjectedT.mjs +2 -0
  330. package/dist/utils/internal/removeInjectedT.mjs.map +1 -0
  331. package/dist/utils/internal/writeChildrenAsObjects.cjs +2 -0
  332. package/dist/utils/internal/writeChildrenAsObjects.cjs.map +1 -0
  333. package/dist/utils/internal/writeChildrenAsObjects.mjs +2 -0
  334. package/dist/utils/internal/writeChildrenAsObjects.mjs.map +1 -0
  335. package/dist/utils/plurals/getPluralBranch.cjs +2 -0
  336. package/dist/utils/plurals/getPluralBranch.cjs.map +1 -0
  337. package/dist/utils/plurals/getPluralBranch.d.ts +12 -0
  338. package/dist/utils/plurals/getPluralBranch.d.ts.map +1 -0
  339. package/dist/utils/plurals/getPluralBranch.mjs +2 -0
  340. package/dist/utils/plurals/getPluralBranch.mjs.map +1 -0
  341. package/dist/utils/rendering/createRenderPipeline.cjs +2 -0
  342. package/dist/utils/rendering/createRenderPipeline.cjs.map +1 -0
  343. package/dist/utils/rendering/createRenderPipeline.d.ts +18 -0
  344. package/dist/utils/rendering/createRenderPipeline.d.ts.map +1 -0
  345. package/dist/utils/rendering/createRenderPipeline.mjs +2 -0
  346. package/dist/utils/rendering/createRenderPipeline.mjs.map +1 -0
  347. package/dist/utils/rendering/createRenderVariable.cjs +2 -0
  348. package/dist/utils/rendering/createRenderVariable.cjs.map +1 -0
  349. package/dist/utils/rendering/createRenderVariable.d.ts +46 -0
  350. package/dist/utils/rendering/createRenderVariable.d.ts.map +1 -0
  351. package/dist/utils/rendering/createRenderVariable.mjs +2 -0
  352. package/dist/utils/rendering/createRenderVariable.mjs.map +1 -0
  353. package/dist/utils/rendering/getDefaultRenderSettings.cjs +2 -0
  354. package/dist/utils/rendering/getDefaultRenderSettings.cjs.map +1 -0
  355. package/dist/utils/rendering/getDefaultRenderSettings.d.ts +10 -0
  356. package/dist/utils/rendering/getDefaultRenderSettings.d.ts.map +1 -0
  357. package/dist/utils/rendering/getDefaultRenderSettings.mjs +2 -0
  358. package/dist/utils/rendering/getDefaultRenderSettings.mjs.map +1 -0
  359. package/dist/utils/rendering/getGTTag.cjs +2 -0
  360. package/dist/utils/rendering/getGTTag.cjs.map +1 -0
  361. package/dist/utils/rendering/getGTTag.mjs +2 -0
  362. package/dist/utils/rendering/getGTTag.mjs.map +1 -0
  363. package/dist/utils/rendering/renderDefaultChildren.shared.cjs +2 -0
  364. package/dist/utils/rendering/renderDefaultChildren.shared.cjs.map +1 -0
  365. package/dist/utils/rendering/renderDefaultChildren.shared.d.ts +12 -0
  366. package/dist/utils/rendering/renderDefaultChildren.shared.d.ts.map +1 -0
  367. package/dist/utils/rendering/renderDefaultChildren.shared.mjs +2 -0
  368. package/dist/utils/rendering/renderDefaultChildren.shared.mjs.map +1 -0
  369. package/dist/utils/rendering/renderPipeline.cjs +2 -0
  370. package/dist/utils/rendering/renderPipeline.cjs.map +1 -0
  371. package/dist/utils/rendering/renderPipeline.mjs +2 -0
  372. package/dist/utils/rendering/renderPipeline.mjs.map +1 -0
  373. package/dist/utils/rendering/renderPipeline.rsc.cjs +2 -0
  374. package/dist/utils/rendering/renderPipeline.rsc.cjs.map +1 -0
  375. package/dist/utils/rendering/renderPipeline.rsc.d.ts +11 -0
  376. package/dist/utils/rendering/renderPipeline.rsc.d.ts.map +1 -0
  377. package/dist/utils/rendering/renderPipeline.rsc.mjs +2 -0
  378. package/dist/utils/rendering/renderPipeline.rsc.mjs.map +1 -0
  379. package/dist/utils/rendering/renderPreparedT.shared.cjs +2 -0
  380. package/dist/utils/rendering/renderPreparedT.shared.cjs.map +1 -0
  381. package/dist/utils/rendering/renderPreparedT.shared.d.ts +16 -0
  382. package/dist/utils/rendering/renderPreparedT.shared.d.ts.map +1 -0
  383. package/dist/utils/rendering/renderPreparedT.shared.mjs +2 -0
  384. package/dist/utils/rendering/renderPreparedT.shared.mjs.map +1 -0
  385. package/dist/utils/rendering/renderTranslatedChildren.shared.cjs +2 -0
  386. package/dist/utils/rendering/renderTranslatedChildren.shared.cjs.map +1 -0
  387. package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts +13 -0
  388. package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts.map +1 -0
  389. package/dist/utils/rendering/renderTranslatedChildren.shared.mjs +2 -0
  390. package/dist/utils/rendering/renderTranslatedChildren.shared.mjs.map +1 -0
  391. package/dist/utils/translation/prepareT.shared.cjs +2 -0
  392. package/dist/utils/translation/prepareT.shared.cjs.map +1 -0
  393. package/dist/utils/translation/prepareT.shared.d.ts +40 -0
  394. package/dist/utils/translation/prepareT.shared.d.ts.map +1 -0
  395. package/dist/utils/translation/prepareT.shared.mjs +2 -0
  396. package/dist/utils/translation/prepareT.shared.mjs.map +1 -0
  397. package/dist/utils/translation/usePrepareT.cjs +2 -0
  398. package/dist/utils/translation/usePrepareT.cjs.map +1 -0
  399. package/dist/utils/translation/usePrepareT.mjs +2 -0
  400. package/dist/utils/translation/usePrepareT.mjs.map +1 -0
  401. package/dist/utils/types.d.ts +64 -0
  402. package/dist/utils/types.d.ts.map +1 -0
  403. package/dist/utils/utils.cjs +2 -0
  404. package/dist/utils/utils.cjs.map +1 -0
  405. package/dist/utils/utils.mjs +2 -0
  406. package/dist/utils/utils.mjs.map +1 -0
  407. package/dist/utils/variables/_getVariableProps.cjs +2 -0
  408. package/dist/utils/variables/_getVariableProps.cjs.map +1 -0
  409. package/dist/utils/variables/_getVariableProps.mjs +2 -0
  410. package/dist/utils/variables/_getVariableProps.mjs.map +1 -0
  411. package/dist/utils/variables/getVariableName.cjs +2 -0
  412. package/dist/utils/variables/getVariableName.cjs.map +1 -0
  413. package/dist/utils/variables/getVariableName.mjs +2 -0
  414. package/dist/utils/variables/getVariableName.mjs.map +1 -0
  415. package/package.json +13 -41
  416. package/dist/components-rsc.cjs.min.cjs +0 -2
  417. package/dist/components-rsc.cjs.min.cjs.map +0 -1
  418. package/dist/components-rsc.d.ts.map +0 -1
  419. package/dist/components-rsc.esm.min.mjs +0 -2
  420. package/dist/components-rsc.esm.min.mjs.map +0 -1
  421. package/dist/components.cjs.min.cjs +0 -2
  422. package/dist/components.cjs.min.cjs.map +0 -1
  423. package/dist/components.d.ts.map +0 -1
  424. package/dist/components.esm.min.mjs +0 -2
  425. package/dist/components.esm.min.mjs.map +0 -1
  426. package/dist/cookies.cjs.min.cjs +0 -2
  427. package/dist/cookies.cjs.min.cjs.map +0 -1
  428. package/dist/cookies.d.ts +0 -16
  429. package/dist/cookies.d.ts.map +0 -1
  430. package/dist/cookies.esm.min.mjs +0 -2
  431. package/dist/cookies.esm.min.mjs.map +0 -1
  432. package/dist/hooks.cjs.min.cjs +0 -2
  433. package/dist/hooks.cjs.min.cjs.map +0 -1
  434. package/dist/hooks.d.ts.map +0 -1
  435. package/dist/hooks.esm.min.mjs +0 -2
  436. package/dist/hooks.esm.min.mjs.map +0 -1
  437. package/dist/pure.cjs.min.cjs +0 -2
  438. package/dist/pure.cjs.min.cjs.map +0 -1
  439. package/dist/pure.d.ts.map +0 -1
  440. package/dist/pure.esm.min.mjs +0 -2
  441. package/dist/pure.esm.min.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderDefaultChildren.shared.cjs","names":["libraryDefaultLocale","getGTTag","isVariableElementProps","getVariableProps","getPluralBranch","React"],"sources":["../../../src/utils/rendering/renderDefaultChildren.shared.ts"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n getVariableProps,\n isVariableElementProps,\n} from '../variables/_getVariableProps';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport { TaggedChild, TaggedChildren, TaggedElement } from '../types';\nimport { getGTTag } from './getGTTag';\nimport { getPluralBranch } from '../plurals/getPluralBranch';\nimport type { RenderVariable } from '../types';\n\n// Shared implementation: the variable renderer is dependency-injected by a\n// factory so neither code path statically imports the other's variable\n// components. Callsites use the pre-instantiated renderPipeline /\n// renderPipeline.rsc modules instead of importing this directly.\n\ntype RenderDefaultChildrenArgs = {\n children: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n};\n\nexport type { RenderDefaultChildrenArgs };\n\nfunction createRenderDefaultChildren({\n renderVariable,\n}: {\n renderVariable: RenderVariable;\n}): (args: RenderDefaultChildrenArgs) => React.ReactNode {\n return function renderDefaultChildren({\n children,\n defaultLocale = libraryDefaultLocale,\n enableI18n,\n }: RenderDefaultChildrenArgs): React.ReactNode {\n const handleSingleChildElement = (child: TaggedElement): ReactNode => {\n const generaltranslation = getGTTag(child);\n\n // Variable\n if (isVariableElementProps(child.props)) {\n const { variableType, variableValue, variableOptions, injectionType } =\n getVariableProps(child.props);\n return renderVariable({\n variableType,\n variableValue,\n variableOptions,\n locales: [defaultLocale],\n enableI18n,\n injectionType,\n });\n }\n\n // Plural\n if (generaltranslation?.transformation === 'plural') {\n const branches = generaltranslation.branches || {};\n if (typeof child.props.n !== 'number') {\n return child.props.children != null\n ? handleChildren(child.props.children)\n : null;\n }\n const resolvedBranch = getPluralBranch(\n child.props.n,\n [defaultLocale],\n branches\n );\n return handleChildren(\n (resolvedBranch != null\n ? resolvedBranch\n : child.props.children) as TaggedChildren\n );\n }\n\n // Branch\n if (generaltranslation?.transformation === 'branch') {\n const { children, branch } = child.props;\n const branches = generaltranslation.branches || {};\n const branchKey =\n branch == null || branch === '' ? undefined : branch.toString();\n return handleChildren(\n branchKey && branches[branchKey] !== undefined\n ? branches[branchKey]\n : children\n );\n }\n\n // Fragment\n if (generaltranslation?.transformation === 'fragment') {\n return React.createElement(React.Fragment, {\n key: child.props.key,\n children: handleChildren(child.props.children),\n });\n }\n\n // Default\n if (child.props.children) {\n return React.cloneElement(child, {\n ...child.props,\n 'data-_gt': undefined,\n children: handleChildren(child.props.children) as TaggedChildren,\n });\n }\n return React.cloneElement(child, {\n ...child.props,\n 'data-_gt': undefined,\n });\n };\n\n const handleSingleChild = (child: TaggedChild): ReactNode => {\n if (React.isValidElement(child)) {\n return handleSingleChildElement(child);\n }\n return child;\n };\n\n const handleChildren = (children: TaggedChildren): ReactNode => {\n return Array.isArray(children)\n ? React.Children.map(children, handleSingleChild)\n : handleSingleChild(children);\n };\n\n return handleChildren(children);\n };\n}\n\nexport { createRenderDefaultChildren };\n"],"mappings":"+PAwBA,SAAS,EAA4B,CACnC,kBAGuD,CACvD,OAAO,SAA+B,CACpC,WACA,gBAAgBA,EAAAA,qBAChB,cAC6C,CAC7C,IAAM,EAA4B,GAAoC,CACpE,IAAM,EAAqBC,EAAAA,SAAS,EAAM,CAG1C,GAAIC,EAAAA,uBAAuB,EAAM,MAAM,CAAE,CACvC,GAAM,CAAE,eAAc,gBAAe,kBAAiB,iBACpDC,EAAAA,iBAAiB,EAAM,MAAM,CAC/B,OAAO,EAAe,CACpB,eACA,gBACA,kBACA,QAAS,CAAC,EAAc,CACxB,aACA,gBACD,CAAC,CAIJ,GAAI,GAAoB,iBAAmB,SAAU,CACnD,IAAM,EAAW,EAAmB,UAAY,EAAE,CAWlD,OAVI,OAAO,EAAM,MAAM,GAAM,SAUtB,EALgBC,EAAAA,gBACrB,EAAM,MAAM,EACZ,CAAC,EAAc,CACf,EAGC,EAEG,EAAM,MAAM,SACjB,CAbQ,EAAM,MAAM,UAAY,KAE3B,KADA,EAAe,EAAM,MAAM,SAAS,CAgB5C,GAAI,GAAoB,iBAAmB,SAAU,CACnD,GAAM,CAAE,WAAU,UAAW,EAAM,MAC7B,EAAW,EAAmB,UAAY,EAAE,CAC5C,EACJ,GAAU,MAAQ,IAAW,GAAK,IAAA,GAAY,EAAO,UAAU,CACjE,OAAO,EACL,GAAa,EAAS,KAAe,IAAA,GACjC,EAAS,GACT,EACL,CAmBH,OAfI,GAAoB,iBAAmB,WAClCC,EAAAA,QAAM,cAAcA,EAAAA,QAAM,SAAU,CACzC,IAAK,EAAM,MAAM,IACjB,SAAU,EAAe,EAAM,MAAM,SAAS,CAC/C,CAAC,CAIA,EAAM,MAAM,SACPA,EAAAA,QAAM,aAAa,EAAO,CAC/B,GAAG,EAAM,MACT,WAAY,IAAA,GACZ,SAAU,EAAe,EAAM,MAAM,SAAS,CAC/C,CAAC,CAEGA,EAAAA,QAAM,aAAa,EAAO,CAC/B,GAAG,EAAM,MACT,WAAY,IAAA,GACb,CAAC,EAGE,EAAqB,GACrBA,EAAAA,QAAM,eAAe,EAAM,CACtB,EAAyB,EAAM,CAEjC,EAGH,EAAkB,GACf,MAAM,QAAQ,EAAS,CAC1BA,EAAAA,QAAM,SAAS,IAAI,EAAU,EAAkB,CAC/C,EAAkB,EAAS,CAGjC,OAAO,EAAe,EAAS"}
@@ -0,0 +1,12 @@
1
+ import { TaggedChildren } from "../types.js";
2
+ import React from "react";
3
+
4
+ //#region src/utils/rendering/renderDefaultChildren.shared.d.ts
5
+ type RenderDefaultChildrenArgs = {
6
+ children: TaggedChildren;
7
+ defaultLocale: string;
8
+ enableI18n: boolean;
9
+ };
10
+ //#endregion
11
+ export { type RenderDefaultChildrenArgs };
12
+ //# sourceMappingURL=renderDefaultChildren.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderDefaultChildren.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderDefaultChildren.shared.ts"],"mappings":";;;;KAgBK,yBAAA;EACH,QAAA,EAAU,cAAA;EACV,aAAA;EACA,UAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{getVariableProps as e,isVariableElementProps as t}from"../variables/_getVariableProps.mjs";import{getGTTag as n}from"./getGTTag.mjs";import{getPluralBranch as r}from"../plurals/getPluralBranch.mjs";import{libraryDefaultLocale as i}from"generaltranslation/internal";import a from"react";function o({renderVariable:o}){return function({children:s,defaultLocale:c=i,enableI18n:l}){let u=i=>{let s=n(i);if(t(i.props)){let{variableType:t,variableValue:n,variableOptions:r,injectionType:a}=e(i.props);return o({variableType:t,variableValue:n,variableOptions:r,locales:[c],enableI18n:l,injectionType:a})}if(s?.transformation===`plural`){let e=s.branches||{};return typeof i.props.n==`number`?f(r(i.props.n,[c],e)??i.props.children):i.props.children==null?null:f(i.props.children)}if(s?.transformation===`branch`){let{children:e,branch:t}=i.props,n=s.branches||{},r=t==null||t===``?void 0:t.toString();return f(r&&n[r]!==void 0?n[r]:e)}return s?.transformation===`fragment`?a.createElement(a.Fragment,{key:i.props.key,children:f(i.props.children)}):i.props.children?a.cloneElement(i,{...i.props,"data-_gt":void 0,children:f(i.props.children)}):a.cloneElement(i,{...i.props,"data-_gt":void 0})},d=e=>a.isValidElement(e)?u(e):e,f=e=>Array.isArray(e)?a.Children.map(e,d):d(e);return f(s)}}export{o as createRenderDefaultChildren};
2
+ //# sourceMappingURL=renderDefaultChildren.shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderDefaultChildren.shared.mjs","names":[],"sources":["../../../src/utils/rendering/renderDefaultChildren.shared.ts"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n getVariableProps,\n isVariableElementProps,\n} from '../variables/_getVariableProps';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport { TaggedChild, TaggedChildren, TaggedElement } from '../types';\nimport { getGTTag } from './getGTTag';\nimport { getPluralBranch } from '../plurals/getPluralBranch';\nimport type { RenderVariable } from '../types';\n\n// Shared implementation: the variable renderer is dependency-injected by a\n// factory so neither code path statically imports the other's variable\n// components. Callsites use the pre-instantiated renderPipeline /\n// renderPipeline.rsc modules instead of importing this directly.\n\ntype RenderDefaultChildrenArgs = {\n children: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n};\n\nexport type { RenderDefaultChildrenArgs };\n\nfunction createRenderDefaultChildren({\n renderVariable,\n}: {\n renderVariable: RenderVariable;\n}): (args: RenderDefaultChildrenArgs) => React.ReactNode {\n return function renderDefaultChildren({\n children,\n defaultLocale = libraryDefaultLocale,\n enableI18n,\n }: RenderDefaultChildrenArgs): React.ReactNode {\n const handleSingleChildElement = (child: TaggedElement): ReactNode => {\n const generaltranslation = getGTTag(child);\n\n // Variable\n if (isVariableElementProps(child.props)) {\n const { variableType, variableValue, variableOptions, injectionType } =\n getVariableProps(child.props);\n return renderVariable({\n variableType,\n variableValue,\n variableOptions,\n locales: [defaultLocale],\n enableI18n,\n injectionType,\n });\n }\n\n // Plural\n if (generaltranslation?.transformation === 'plural') {\n const branches = generaltranslation.branches || {};\n if (typeof child.props.n !== 'number') {\n return child.props.children != null\n ? handleChildren(child.props.children)\n : null;\n }\n const resolvedBranch = getPluralBranch(\n child.props.n,\n [defaultLocale],\n branches\n );\n return handleChildren(\n (resolvedBranch != null\n ? resolvedBranch\n : child.props.children) as TaggedChildren\n );\n }\n\n // Branch\n if (generaltranslation?.transformation === 'branch') {\n const { children, branch } = child.props;\n const branches = generaltranslation.branches || {};\n const branchKey =\n branch == null || branch === '' ? undefined : branch.toString();\n return handleChildren(\n branchKey && branches[branchKey] !== undefined\n ? branches[branchKey]\n : children\n );\n }\n\n // Fragment\n if (generaltranslation?.transformation === 'fragment') {\n return React.createElement(React.Fragment, {\n key: child.props.key,\n children: handleChildren(child.props.children),\n });\n }\n\n // Default\n if (child.props.children) {\n return React.cloneElement(child, {\n ...child.props,\n 'data-_gt': undefined,\n children: handleChildren(child.props.children) as TaggedChildren,\n });\n }\n return React.cloneElement(child, {\n ...child.props,\n 'data-_gt': undefined,\n });\n };\n\n const handleSingleChild = (child: TaggedChild): ReactNode => {\n if (React.isValidElement(child)) {\n return handleSingleChildElement(child);\n }\n return child;\n };\n\n const handleChildren = (children: TaggedChildren): ReactNode => {\n return Array.isArray(children)\n ? React.Children.map(children, handleSingleChild)\n : handleSingleChild(children);\n };\n\n return handleChildren(children);\n };\n}\n\nexport { createRenderDefaultChildren };\n"],"mappings":"qSAwBA,SAAS,EAA4B,CACnC,kBAGuD,CACvD,OAAO,SAA+B,CACpC,WACA,gBAAgB,EAChB,cAC6C,CAC7C,IAAM,EAA4B,GAAoC,CACpE,IAAM,EAAqB,EAAS,EAAM,CAG1C,GAAI,EAAuB,EAAM,MAAM,CAAE,CACvC,GAAM,CAAE,eAAc,gBAAe,kBAAiB,iBACpD,EAAiB,EAAM,MAAM,CAC/B,OAAO,EAAe,CACpB,eACA,gBACA,kBACA,QAAS,CAAC,EAAc,CACxB,aACA,gBACD,CAAC,CAIJ,GAAI,GAAoB,iBAAmB,SAAU,CACnD,IAAM,EAAW,EAAmB,UAAY,EAAE,CAWlD,OAVI,OAAO,EAAM,MAAM,GAAM,SAUtB,EALgB,EACrB,EAAM,MAAM,EACZ,CAAC,EAAc,CACf,EAGC,EAEG,EAAM,MAAM,SACjB,CAbQ,EAAM,MAAM,UAAY,KAE3B,KADA,EAAe,EAAM,MAAM,SAAS,CAgB5C,GAAI,GAAoB,iBAAmB,SAAU,CACnD,GAAM,CAAE,WAAU,UAAW,EAAM,MAC7B,EAAW,EAAmB,UAAY,EAAE,CAC5C,EACJ,GAAU,MAAQ,IAAW,GAAK,IAAA,GAAY,EAAO,UAAU,CACjE,OAAO,EACL,GAAa,EAAS,KAAe,IAAA,GACjC,EAAS,GACT,EACL,CAmBH,OAfI,GAAoB,iBAAmB,WAClC,EAAM,cAAc,EAAM,SAAU,CACzC,IAAK,EAAM,MAAM,IACjB,SAAU,EAAe,EAAM,MAAM,SAAS,CAC/C,CAAC,CAIA,EAAM,MAAM,SACP,EAAM,aAAa,EAAO,CAC/B,GAAG,EAAM,MACT,WAAY,IAAA,GACZ,SAAU,EAAe,EAAM,MAAM,SAAS,CAC/C,CAAC,CAEG,EAAM,aAAa,EAAO,CAC/B,GAAG,EAAM,MACT,WAAY,IAAA,GACb,CAAC,EAGE,EAAqB,GACrB,EAAM,eAAe,EAAM,CACtB,EAAyB,EAAM,CAEjC,EAGH,EAAkB,GACf,MAAM,QAAQ,EAAS,CAC1B,EAAM,SAAS,IAAI,EAAU,EAAkB,CAC/C,EAAkB,EAAS,CAGjC,OAAO,EAAe,EAAS"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./createRenderPipeline.cjs`),t=require(`../../components/variables/Currency.cjs`),n=require(`../../components/variables/DateTime.cjs`),r=require(`../../components/variables/Num.cjs`),i=require(`../../components/variables/RelativeTime.cjs`),a=require(`../../components/variables/Var.cjs`),{renderVariable:o,renderDefaultChildren:s,renderTranslatedChildren:c,renderPreparedT:l}=e.createRenderPipeline({Currency:t.Currency,GtInternalCurrency:t.GtInternalCurrency,DateTime:n.DateTime,GtInternalDateTime:n.GtInternalDateTime,Num:r.Num,GtInternalNum:r.GtInternalNum,RelativeTime:i.RelativeTime,GtInternalRelativeTime:i.GtInternalRelativeTime,Var:a.Var,GtInternalVar:a.GtInternalVar});exports.renderPreparedT=l;
2
+ //# sourceMappingURL=renderPipeline.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPipeline.cjs","names":["createRenderPipeline"],"sources":["../../../src/utils/rendering/renderPipeline.ts"],"sourcesContent":["import {\n Currency,\n GtInternalCurrency,\n} from '../../components/variables/Currency';\nimport {\n DateTime,\n GtInternalDateTime,\n} from '../../components/variables/DateTime';\nimport { GtInternalNum, Num } from '../../components/variables/Num';\nimport {\n GtInternalRelativeTime,\n RelativeTime,\n} from '../../components/variables/RelativeTime';\nimport { GtInternalVar, Var } from '../../components/variables/Var';\nimport { createRenderPipeline } from './createRenderPipeline';\n\n// Hook-capable render pipeline: bound to variable components that resolve\n// request conditions from hooks. RSC code must use renderPipeline.rsc instead.\n\nexport const {\n renderVariable,\n renderDefaultChildren,\n renderTranslatedChildren,\n renderPreparedT,\n} = createRenderPipeline({\n Currency,\n GtInternalCurrency,\n DateTime,\n GtInternalDateTime,\n Num,\n GtInternalNum,\n RelativeTime,\n GtInternalRelativeTime,\n Var,\n GtInternalVar,\n});\n"],"mappings":"iTAmBa,CACX,iBACA,wBACA,2BACA,mBACEA,EAAAA,qBAAqB,CACvB,SAAA,EAAA,SACA,mBAAA,EAAA,mBACA,SAAA,EAAA,SACA,mBAAA,EAAA,mBACA,IAAA,EAAA,IACA,cAAA,EAAA,cACA,aAAA,EAAA,aACA,uBAAA,EAAA,uBACA,IAAA,EAAA,IACA,cAAA,EAAA,cACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{createRenderPipeline as e}from"./createRenderPipeline.mjs";import{Currency as t,GtInternalCurrency as n}from"../../components/variables/Currency.mjs";import{DateTime as r,GtInternalDateTime as i}from"../../components/variables/DateTime.mjs";import{GtInternalNum as a,Num as o}from"../../components/variables/Num.mjs";import{GtInternalRelativeTime as s,RelativeTime as c}from"../../components/variables/RelativeTime.mjs";import{GtInternalVar as l,Var as u}from"../../components/variables/Var.mjs";const{renderVariable:d,renderDefaultChildren:f,renderTranslatedChildren:p,renderPreparedT:m}=e({Currency:t,GtInternalCurrency:n,DateTime:r,GtInternalDateTime:i,Num:o,GtInternalNum:a,RelativeTime:c,GtInternalRelativeTime:s,Var:u,GtInternalVar:l});export{m as renderPreparedT};
2
+ //# sourceMappingURL=renderPipeline.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPipeline.mjs","names":[],"sources":["../../../src/utils/rendering/renderPipeline.ts"],"sourcesContent":["import {\n Currency,\n GtInternalCurrency,\n} from '../../components/variables/Currency';\nimport {\n DateTime,\n GtInternalDateTime,\n} from '../../components/variables/DateTime';\nimport { GtInternalNum, Num } from '../../components/variables/Num';\nimport {\n GtInternalRelativeTime,\n RelativeTime,\n} from '../../components/variables/RelativeTime';\nimport { GtInternalVar, Var } from '../../components/variables/Var';\nimport { createRenderPipeline } from './createRenderPipeline';\n\n// Hook-capable render pipeline: bound to variable components that resolve\n// request conditions from hooks. RSC code must use renderPipeline.rsc instead.\n\nexport const {\n renderVariable,\n renderDefaultChildren,\n renderTranslatedChildren,\n renderPreparedT,\n} = createRenderPipeline({\n Currency,\n GtInternalCurrency,\n DateTime,\n GtInternalDateTime,\n Num,\n GtInternalNum,\n RelativeTime,\n GtInternalRelativeTime,\n Var,\n GtInternalVar,\n});\n"],"mappings":"ufAmBA,KAAa,CACX,iBACA,wBACA,2BACA,mBACE,EAAqB,CACvB,WACA,qBACA,WACA,qBACA,MACA,gBACA,eACA,yBACA,MACA,gBACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./createRenderPipeline.cjs`),t=require(`../../components/variables/Var.cjs`),n=require(`../../components/variables/Currency.rsc.cjs`),r=require(`../../components/variables/DateTime.rsc.cjs`),i=require(`../../components/variables/Num.rsc.cjs`),a=require(`../../components/variables/RelativeTime.rsc.cjs`),{renderVariable:o,renderDefaultChildren:s,renderTranslatedChildren:c,renderPreparedT:l}=e.createRenderPipeline({Currency:n.RscCurrency,GtInternalCurrency:n.RscGtInternalCurrency,DateTime:r.RscDateTime,GtInternalDateTime:r.RscGtInternalDateTime,Num:i.RscNum,GtInternalNum:i.RscGtInternalNum,RelativeTime:a.RscRelativeTime,GtInternalRelativeTime:a.RscGtInternalRelativeTime,Var:t.Var,GtInternalVar:t.GtInternalVar});exports.renderDefaultChildren=s,exports.renderPreparedT=l,exports.renderTranslatedChildren=c,exports.renderVariable=o;
2
+ //# sourceMappingURL=renderPipeline.rsc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPipeline.rsc.cjs","names":["createRenderPipeline","RscCurrency","RscGtInternalCurrency","RscDateTime","RscGtInternalDateTime","RscNum","RscGtInternalNum","RscRelativeTime","RscGtInternalRelativeTime"],"sources":["../../../src/utils/rendering/renderPipeline.rsc.ts"],"sourcesContent":["import {\n RscCurrency,\n RscGtInternalCurrency,\n} from '../../components/variables/Currency.rsc';\nimport {\n RscDateTime,\n RscGtInternalDateTime,\n} from '../../components/variables/DateTime.rsc';\nimport { RscGtInternalNum, RscNum } from '../../components/variables/Num.rsc';\nimport {\n RscGtInternalRelativeTime,\n RscRelativeTime,\n} from '../../components/variables/RelativeTime.rsc';\nimport { GtInternalVar, Var } from '../../components/variables/Var';\nimport { createRenderPipeline } from './createRenderPipeline';\n\n// RSC render pipeline: bound to the variable renderer backed by the Rsc\n// variable implementations, which receive request conditions explicitly.\n// This module must stay free of hook/context imports so it can be reached\n// from the components-rsc entrypoint.\n\nexport const {\n renderVariable,\n renderDefaultChildren,\n renderTranslatedChildren,\n renderPreparedT,\n} = createRenderPipeline({\n Currency: RscCurrency,\n GtInternalCurrency: RscGtInternalCurrency,\n DateTime: RscDateTime,\n GtInternalDateTime: RscGtInternalDateTime,\n Num: RscNum,\n GtInternalNum: RscGtInternalNum,\n RelativeTime: RscRelativeTime,\n GtInternalRelativeTime: RscGtInternalRelativeTime,\n Var,\n GtInternalVar,\n});\n"],"mappings":"iUAqBa,CACX,iBACA,wBACA,2BACA,mBACEA,EAAAA,qBAAqB,CACvB,SAAUC,EAAAA,YACV,mBAAoBC,EAAAA,sBACpB,SAAUC,EAAAA,YACV,mBAAoBC,EAAAA,sBACpB,IAAKC,EAAAA,OACL,cAAeC,EAAAA,iBACf,aAAcC,EAAAA,gBACd,uBAAwBC,EAAAA,0BACxB,IAAA,EAAA,IACA,cAAA,EAAA,cACD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { RenderVariable } from "../types.js";
2
+ import { RenderDefaultChildrenArgs } from "./renderDefaultChildren.shared.js";
3
+ import { RenderTranslatedChildrenArgs } from "./renderTranslatedChildren.shared.js";
4
+ import { RenderPreparedTParams } from "./renderPreparedT.shared.js";
5
+ import * as _$react from "react";
6
+
7
+ //#region src/utils/rendering/renderPipeline.rsc.d.ts
8
+ declare const renderVariable: RenderVariable, renderDefaultChildren: (args: RenderDefaultChildrenArgs) => _$react.ReactNode, renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => _$react.ReactNode, renderPreparedT: (args: RenderPreparedTParams) => _$react.ReactNode;
9
+ //#endregion
10
+ export { renderDefaultChildren, renderPreparedT, renderTranslatedChildren, renderVariable };
11
+ //# sourceMappingURL=renderPipeline.rsc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPipeline.rsc.d.ts","names":[],"sources":["../../../src/utils/rendering/renderPipeline.rsc.ts"],"mappings":";;;;;;;cAsBE,cAAA,EAAc,cAAA,EAAA,qBAAA,GACO,IAAA,EADP,yBAAA,KACO,OAAA,CAAA,SAAA,EAAA,wBAAA,GACG,IAAA,EADH,4BAAA,KACG,OAAA,CAAA,SAAA,EAAA,eAAA,GACT,IAAA,EADS,qBAAA,KACT,OAAA,CAAA,SAAA"}
@@ -0,0 +1,2 @@
1
+ import{createRenderPipeline as e}from"./createRenderPipeline.mjs";import{GtInternalVar as t,Var as n}from"../../components/variables/Var.mjs";import{RscCurrency as r,RscGtInternalCurrency as i}from"../../components/variables/Currency.rsc.mjs";import{RscDateTime as a,RscGtInternalDateTime as o}from"../../components/variables/DateTime.rsc.mjs";import{RscGtInternalNum as s,RscNum as c}from"../../components/variables/Num.rsc.mjs";import{RscGtInternalRelativeTime as l,RscRelativeTime as u}from"../../components/variables/RelativeTime.rsc.mjs";const{renderVariable:d,renderDefaultChildren:f,renderTranslatedChildren:p,renderPreparedT:m}=e({Currency:r,GtInternalCurrency:i,DateTime:a,GtInternalDateTime:o,Num:c,GtInternalNum:s,RelativeTime:u,GtInternalRelativeTime:l,Var:n,GtInternalVar:t});export{f as renderDefaultChildren,m as renderPreparedT,p as renderTranslatedChildren,d as renderVariable};
2
+ //# sourceMappingURL=renderPipeline.rsc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPipeline.rsc.mjs","names":[],"sources":["../../../src/utils/rendering/renderPipeline.rsc.ts"],"sourcesContent":["import {\n RscCurrency,\n RscGtInternalCurrency,\n} from '../../components/variables/Currency.rsc';\nimport {\n RscDateTime,\n RscGtInternalDateTime,\n} from '../../components/variables/DateTime.rsc';\nimport { RscGtInternalNum, RscNum } from '../../components/variables/Num.rsc';\nimport {\n RscGtInternalRelativeTime,\n RscRelativeTime,\n} from '../../components/variables/RelativeTime.rsc';\nimport { GtInternalVar, Var } from '../../components/variables/Var';\nimport { createRenderPipeline } from './createRenderPipeline';\n\n// RSC render pipeline: bound to the variable renderer backed by the Rsc\n// variable implementations, which receive request conditions explicitly.\n// This module must stay free of hook/context imports so it can be reached\n// from the components-rsc entrypoint.\n\nexport const {\n renderVariable,\n renderDefaultChildren,\n renderTranslatedChildren,\n renderPreparedT,\n} = createRenderPipeline({\n Currency: RscCurrency,\n GtInternalCurrency: RscGtInternalCurrency,\n DateTime: RscDateTime,\n GtInternalDateTime: RscGtInternalDateTime,\n Num: RscNum,\n GtInternalNum: RscGtInternalNum,\n RelativeTime: RscRelativeTime,\n GtInternalRelativeTime: RscGtInternalRelativeTime,\n Var,\n GtInternalVar,\n});\n"],"mappings":"+hBAqBA,KAAa,CACX,iBACA,wBACA,2BACA,mBACE,EAAqB,CACvB,SAAU,EACV,mBAAoB,EACpB,SAAU,EACV,mBAAoB,EACpB,IAAK,EACL,cAAe,EACf,aAAc,EACd,uBAAwB,EACxB,MACA,gBACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ function e({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:a,enableI18n:o,shouldTranslate:s}){return!s||t==null?r({taggedSourceChildren:e,defaultLocale:a,enableI18n:o}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,a],enableI18n:o})}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}exports.createRenderPreparedT=e;
2
+ //# sourceMappingURL=renderPreparedT.shared.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPreparedT.shared.cjs","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { TaggedChildren } from '../types';\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n }: RenderPreparedTParams): ReactNode {\n if (!shouldTranslate || targetJsxChildren == null) {\n return renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n return renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"AAoBA,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,mBACmC,CASnC,MARI,CAAC,GAAmB,GAAqB,KACpC,EAAa,CAClB,uBACA,gBACA,aACD,CAAC,CAGG,EAAa,CAClB,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
@@ -0,0 +1,16 @@
1
+ import { TaggedChildren } from "../types.js";
2
+ import { ReactNode } from "react";
3
+ import { JsxChildren } from "generaltranslation/types";
4
+
5
+ //#region src/utils/rendering/renderPreparedT.shared.d.ts
6
+ type RenderPreparedTParams = {
7
+ taggedSourceChildren: TaggedChildren;
8
+ targetJsxChildren: JsxChildren | null | undefined;
9
+ locale: string;
10
+ defaultLocale: string;
11
+ enableI18n: boolean;
12
+ shouldTranslate: boolean;
13
+ };
14
+ //#endregion
15
+ export { type RenderPreparedTParams };
16
+ //# sourceMappingURL=renderPreparedT.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPreparedT.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"mappings":";;;;;KAWK,qBAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,MAAA;EACA,aAAA;EACA,UAAA;EACA,eAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ function e({renderDefaultChildren:e,renderTranslatedChildren:t}){function n({taggedSourceChildren:e,targetJsxChildren:t,locale:n,defaultLocale:a,enableI18n:o,shouldTranslate:s}){return!s||t==null?r({taggedSourceChildren:e,defaultLocale:a,enableI18n:o}):i({taggedSourceChildren:e,targetJsxChildren:t,locales:[n,a],enableI18n:o})}function r({taggedSourceChildren:t,defaultLocale:n,enableI18n:r}){return e({children:t,defaultLocale:n,enableI18n:r})}function i({taggedSourceChildren:e,targetJsxChildren:n,locales:r,enableI18n:i}){return t({source:e,target:n,locales:r,enableI18n:i})}return n}export{e as createRenderPreparedT};
2
+ //# sourceMappingURL=renderPreparedT.shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPreparedT.shared.mjs","names":[],"sources":["../../../src/utils/rendering/renderPreparedT.shared.ts"],"sourcesContent":["import type { RenderDefaultChildrenArgs } from './renderDefaultChildren.shared';\nimport type { RenderTranslatedChildrenArgs } from './renderTranslatedChildren.shared';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { TaggedChildren } from '../types';\n\n// Shared rendering logic. The child renderers are injected so the RSC code path\n// never statically imports the hook-based variable components, and so the\n// pipeline can build them once and share them. This module must stay free of\n// hook/context imports so it can be reached from the components-rsc entrypoint.\n\ntype RenderPreparedTParams = {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren | null | undefined;\n locale: string;\n defaultLocale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n};\n\nfunction createRenderPreparedT({\n renderDefaultChildren,\n renderTranslatedChildren,\n}: {\n renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;\n renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;\n}): (args: RenderPreparedTParams) => ReactNode {\n function renderPreparedT({\n taggedSourceChildren,\n targetJsxChildren,\n locale,\n defaultLocale,\n enableI18n,\n shouldTranslate,\n }: RenderPreparedTParams): ReactNode {\n if (!shouldTranslate || targetJsxChildren == null) {\n return renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n return renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales: [locale, defaultLocale],\n enableI18n,\n });\n }\n\n function renderSource({\n taggedSourceChildren,\n defaultLocale,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n defaultLocale: string;\n enableI18n: boolean;\n }): ReactNode {\n return renderDefaultChildren({\n children: taggedSourceChildren,\n defaultLocale,\n enableI18n,\n });\n }\n\n function renderTarget({\n taggedSourceChildren,\n targetJsxChildren,\n locales,\n enableI18n,\n }: {\n taggedSourceChildren: TaggedChildren;\n targetJsxChildren: JsxChildren;\n locales: string[];\n enableI18n: boolean;\n }): ReactNode {\n return renderTranslatedChildren({\n source: taggedSourceChildren,\n target: targetJsxChildren,\n locales,\n enableI18n,\n });\n }\n\n return renderPreparedT;\n}\n\nexport { createRenderPreparedT };\nexport type { RenderPreparedTParams };\n"],"mappings":"AAoBA,SAAS,EAAsB,CAC7B,wBACA,4BAI6C,CAC7C,SAAS,EAAgB,CACvB,uBACA,oBACA,SACA,gBACA,aACA,mBACmC,CASnC,MARI,CAAC,GAAmB,GAAqB,KACpC,EAAa,CAClB,uBACA,gBACA,aACD,CAAC,CAGG,EAAa,CAClB,uBACA,oBACA,QAAS,CAAC,EAAQ,EAAc,CAChC,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,gBACA,cAKY,CACZ,OAAO,EAAsB,CAC3B,SAAU,EACV,gBACA,aACD,CAAC,CAGJ,SAAS,EAAa,CACpB,uBACA,oBACA,UACA,cAMY,CACZ,OAAO,EAAyB,CAC9B,OAAQ,EACR,OAAQ,EACR,UACA,aACD,CAAC,CAGJ,OAAO"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../variables/_getVariableProps.cjs`),n=require(`./getGTTag.cjs`),r=require(`../plurals/getPluralBranch.cjs`),i=require(`./renderDefaultChildren.shared.cjs`);let a=require(`generaltranslation/internal`),o=require(`react/jsx-runtime`),s=require(`react`);s=e.__toESM(s);let c=require(`@generaltranslation/format/types`);function l({renderVariable:e}){let l=i.createRenderDefaultChildren({renderVariable:e});function u({sourceElement:e,targetElement:t,locales:n=[a.libraryDefaultLocale],enableI18n:i}){let{props:o}=e,u=o[`data-_gt`],f=u?.transformation,p=t.d,m={};if(p&&Object.entries(c.HTML_CONTENT_PROPS).forEach(([e,t])=>{p[e]&&(m[t]=p[e])}),f===`plural`){let a=e.props.n;return typeof a==`number`?d({source:r.getPluralBranch(a,n,u.branches||{})??e.props.children,target:r.getPluralBranch(a,n,t.d?.b||{})??t.c,locales:n,enableI18n:i}):l({children:e,defaultLocale:n[0],enableI18n:i})}if(f===`branch`){let{branch:e,children:r}=o,a=e==null||e===``?void 0:e.toString(),s=u.branches||{},c=t.d?.b||{};return d({source:a&&s[a]!==void 0?s[a]:r,target:a&&c[a]!==void 0?c[a]:t.c,locales:n,enableI18n:i})}return f===`fragment`&&t.c?s.default.createElement(s.default.Fragment,{key:e.props.key,children:d({source:o.children,target:t.c,locales:n,enableI18n:i})}):o?.children&&t?.c?s.default.cloneElement(e,{...o,...m,"data-_gt":void 0,children:d({source:o.children,target:t.c,locales:n,enableI18n:i})}):l({children:e,defaultLocale:n[0],enableI18n:i})}function d({source:r,target:i,locales:c=[a.libraryDefaultLocale],enableI18n:d}){if(i==null&&r)return l({children:r,defaultLocale:c[0],enableI18n:d});if(typeof i==`string`)return i;if(Array.isArray(i)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(i)){let l={},f={},p={},m=r.filter(e=>{if(s.default.isValidElement(e))if(t.isVariableElementProps(e.props)){let{variableName:n,variableValue:r,variableOptions:i,injectionType:a}=t.getVariableProps(e.props);l[n]=r,f[n]=i,p[n]=a}else return!0;return!1}),h=e=>m.find(t=>{let r=n.getGTTag(t);return r?.id===void 0?!1:r.id===e.i})||m.shift();return i.map((t,n)=>{if(typeof t==`string`)return(0,o.jsx)(s.default.Fragment,{children:t},`string_${n}`);if((0,a.isVariable)(t))return(0,o.jsx)(s.default.Fragment,{children:e({variableType:t.v||`v`,variableValue:l[t.k],variableOptions:f[t.k],locales:c,enableI18n:d,injectionType:p[t.k]||`manual`})},`var_${n}`);let r=h(t);return r?(0,o.jsx)(s.default.Fragment,{children:u({sourceElement:r,targetElement:t,locales:c,enableI18n:d})},`element_${n}`):null})}if(i&&typeof i==`object`&&!Array.isArray(i)){let n=(0,a.isVariable)(i)?`variable`:`element`;if(s.default.isValidElement(r)){if(n===`element`)return u({sourceElement:r,targetElement:i,locales:c,enableI18n:d});if(t.isVariableElementProps(r.props)){let{variableValue:n,variableOptions:i,variableType:a,injectionType:o}=t.getVariableProps(r.props);return e({variableType:a,variableValue:n,variableOptions:i,locales:c,enableI18n:d,injectionType:o})}}}return l({children:r,defaultLocale:c[0],enableI18n:d})}return d}exports.createRenderTranslatedChildren=l;
2
+ //# sourceMappingURL=renderTranslatedChildren.shared.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTranslatedChildren.shared.cjs","names":["createRenderDefaultChildren","libraryDefaultLocale","HTML_CONTENT_PROPS","getPluralBranch","React","isVariableElementProps","getVariableProps","getGTTag"],"sources":["../../../src/utils/rendering/renderTranslatedChildren.shared.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n TaggedChildren,\n TaggedElement,\n TranslatedChildren,\n TranslatedElement,\n VariableProps,\n} from '../types';\nimport {\n getVariableProps,\n isVariableElementProps,\n} from '../variables/_getVariableProps';\nimport { createRenderDefaultChildren } from './renderDefaultChildren.shared';\nimport { isVariable, libraryDefaultLocale } from 'generaltranslation/internal';\nimport { getPluralBranch } from '../plurals/getPluralBranch';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\nimport { getGTTag } from './getGTTag';\nimport type { RenderVariable } from '../types';\n\n// Shared implementation: the variable renderer is dependency-injected by a\n// factory so neither code path statically imports the other's variable\n// components. Callsites use the pre-instantiated renderPipeline /\n// renderPipeline.rsc modules instead of importing this directly.\n\ntype RenderTranslatedChildrenArgs = {\n source: TaggedChildren;\n target: TranslatedChildren;\n locales: string[];\n enableI18n: boolean;\n};\n\nfunction createRenderTranslatedChildren({\n renderVariable,\n}: {\n renderVariable: RenderVariable;\n}): (args: RenderTranslatedChildrenArgs) => ReactNode {\n const renderDefaultChildren = createRenderDefaultChildren({ renderVariable });\n\n function renderTranslatedElement({\n sourceElement,\n targetElement,\n locales = [libraryDefaultLocale],\n enableI18n,\n }: {\n sourceElement: TaggedElement;\n targetElement: TranslatedElement;\n locales: string[];\n enableI18n: boolean;\n }): React.ReactNode {\n // Get props and generaltranslation\n const { props: sourceProps } = sourceElement;\n const sourceGT = sourceProps['data-_gt'];\n const transformation = sourceGT?.transformation;\n\n // Get translated props\n const unprocessedTargetGT = targetElement.d;\n const translatedProps: HtmlContentPropValuesRecord = {};\n if (unprocessedTargetGT) {\n Object.entries(HTML_CONTENT_PROPS).forEach(([minifiedName, fullName]) => {\n if (\n unprocessedTargetGT[minifiedName as keyof typeof HTML_CONTENT_PROPS]\n ) {\n translatedProps[fullName] = unprocessedTargetGT[\n minifiedName as keyof typeof HTML_CONTENT_PROPS\n ] as string;\n }\n });\n }\n\n // plural (choose a branch)\n if (transformation === 'plural') {\n const n = sourceElement.props.n;\n if (typeof n !== 'number') {\n return renderDefaultChildren({\n children: sourceElement,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n const sourceBranches = sourceGT.branches || {};\n const resolvedSourceBranch = getPluralBranch(n, locales, sourceBranches);\n const sourceBranch =\n resolvedSourceBranch != null\n ? resolvedSourceBranch\n : sourceElement.props.children;\n const targetBranches = targetElement.d?.b || {};\n const resolvedTargetBranch = getPluralBranch(n, locales, targetBranches);\n const targetBranch =\n resolvedTargetBranch != null ? resolvedTargetBranch : targetElement.c;\n return renderTranslatedChildren({\n source: sourceBranch as TaggedChildren,\n target: targetBranch as TranslatedChildren,\n locales,\n enableI18n,\n });\n }\n\n // branch (choose a branch)\n if (transformation === 'branch') {\n const { branch, children } = sourceProps;\n const branchKey =\n branch == null || branch === '' ? undefined : branch.toString();\n const sourceBranches = sourceGT.branches || {};\n const targetBranches = targetElement.d?.b || {};\n const sourceBranch =\n branchKey && sourceBranches[branchKey] !== undefined\n ? sourceBranches[branchKey]\n : children;\n const targetBranch =\n branchKey && targetBranches[branchKey] !== undefined\n ? targetBranches[branchKey]\n : targetElement.c;\n return renderTranslatedChildren({\n source: sourceBranch as TaggedChildren,\n target: targetBranch as TranslatedChildren,\n locales,\n enableI18n,\n });\n }\n\n // fragment (create a valid fragment)\n if (transformation === 'fragment' && targetElement.c) {\n return React.createElement(React.Fragment, {\n key: sourceElement.props.key,\n children: renderTranslatedChildren({\n source: sourceProps.children as TaggedChildren,\n target: targetElement.c,\n locales,\n enableI18n,\n }) as TaggedChildren,\n });\n }\n\n // other\n if (sourceProps?.children && targetElement?.c) {\n return React.cloneElement(sourceElement, {\n ...sourceProps,\n ...translatedProps,\n 'data-_gt': undefined,\n children: renderTranslatedChildren({\n source: sourceProps.children as TaggedChildren,\n target: targetElement.c,\n locales,\n enableI18n,\n }) as TaggedChildren,\n });\n }\n\n // fallback\n return renderDefaultChildren({\n children: sourceElement,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n\n function renderTranslatedChildren({\n source,\n target,\n locales = [libraryDefaultLocale],\n enableI18n,\n }: RenderTranslatedChildrenArgs): ReactNode {\n // Most straightforward case, return a valid React node\n if ((target === null || typeof target === 'undefined') && source)\n return renderDefaultChildren({\n children: source,\n defaultLocale: locales[0],\n enableI18n,\n });\n if (typeof target === 'string') return target;\n\n // Convert source to an array in case target has multiple children where source only has one\n if (Array.isArray(target) && !Array.isArray(source) && source)\n source = [source];\n\n // Multiple children\n if (Array.isArray(source) && Array.isArray(target)) {\n // Track the variables\n const variables: Record<string, VariableProps['variableValue']> = {};\n const variablesOptions: Record<string, VariableProps['variableOptions']> =\n {};\n const variableInjectionTypes: Record<\n string,\n VariableProps['injectionType']\n > = {};\n\n // Extract source elements\n // Extract variable props\n // Filter out variable elements\n const sourceElements: TaggedElement[] = source.filter(\n (sourceChild): sourceChild is TaggedElement => {\n if (React.isValidElement(sourceChild)) {\n if (isVariableElementProps(sourceChild.props)) {\n const {\n variableName,\n variableValue,\n variableOptions,\n injectionType,\n } = getVariableProps(sourceChild.props);\n variables[variableName] = variableValue;\n variablesOptions[variableName] = variableOptions;\n variableInjectionTypes[variableName] = injectionType;\n } else {\n return true;\n }\n }\n return false;\n }\n );\n\n // TODO: pre-index these to avoid O(n/2) lookups\n const findMatchingSourceElement = (\n targetElement: TranslatedElement\n ): TaggedElement | undefined => {\n return (\n sourceElements.find((sourceChild): sourceChild is TaggedElement => {\n const generaltranslation = getGTTag(sourceChild);\n if (typeof generaltranslation?.id !== 'undefined') {\n const sourceId = generaltranslation.id;\n const targetId = targetElement.i;\n return sourceId === targetId;\n }\n return false;\n }) || sourceElements.shift()\n ); // assumes fixed order, not recommended\n };\n\n // map target to source\n return target.map((targetChild, index) => {\n if (typeof targetChild === 'string')\n return (\n <React.Fragment key={`string_${index}`}>\n {targetChild}\n </React.Fragment>\n );\n\n // Render variable\n if (isVariable(targetChild)) {\n return (\n <React.Fragment key={`var_${index}`}>\n {renderVariable({\n variableType: targetChild.v || 'v',\n variableValue: variables[targetChild.k],\n variableOptions: variablesOptions[targetChild.k],\n locales,\n enableI18n,\n injectionType:\n variableInjectionTypes[targetChild.k] || 'manual',\n })}\n </React.Fragment>\n );\n }\n\n // Render element (targetChild is a TranslatedElement)\n const matchingSourceElement = findMatchingSourceElement(\n targetChild as TranslatedElement\n );\n if (!matchingSourceElement) return null;\n return (\n <React.Fragment key={`element_${index}`}>\n {renderTranslatedElement({\n sourceElement: matchingSourceElement,\n targetElement: targetChild,\n locales,\n enableI18n,\n })}\n </React.Fragment>\n );\n });\n }\n\n // Single child\n if (target && typeof target === 'object' && !Array.isArray(target)) {\n const targetType: 'variable' | 'element' = isVariable(target)\n ? 'variable'\n : 'element';\n\n if (React.isValidElement(source)) {\n if (targetType === 'element') {\n return renderTranslatedElement({\n sourceElement: source,\n targetElement: target as TranslatedElement,\n locales,\n enableI18n,\n });\n }\n\n // Render variable\n if (isVariableElementProps(source.props)) {\n const {\n variableValue,\n variableOptions,\n variableType,\n injectionType,\n } = getVariableProps(source.props);\n return renderVariable({\n variableType,\n variableValue,\n variableOptions,\n locales,\n enableI18n,\n injectionType,\n });\n }\n }\n }\n\n // fallback\n return renderDefaultChildren({\n children: source,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n\n return renderTranslatedChildren;\n}\n\nexport { createRenderTranslatedChildren };\nexport type { RenderTranslatedChildrenArgs };\n"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ import { TaggedChildren, TranslatedChildren } from "../types.js";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/utils/rendering/renderTranslatedChildren.shared.d.ts
5
+ type RenderTranslatedChildrenArgs = {
6
+ source: TaggedChildren;
7
+ target: TranslatedChildren;
8
+ locales: string[];
9
+ enableI18n: boolean;
10
+ };
11
+ //#endregion
12
+ export { type RenderTranslatedChildrenArgs };
13
+ //# sourceMappingURL=renderTranslatedChildren.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTranslatedChildren.shared.d.ts","names":[],"sources":["../../../src/utils/rendering/renderTranslatedChildren.shared.tsx"],"mappings":";;;;KA2BK,4BAAA;EACH,MAAA,EAAQ,cAAA;EACR,MAAA,EAAQ,kBAAA;EACR,OAAA;EACA,UAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{getVariableProps as e,isVariableElementProps as t}from"../variables/_getVariableProps.mjs";import{getGTTag as n}from"./getGTTag.mjs";import{getPluralBranch as r}from"../plurals/getPluralBranch.mjs";import{createRenderDefaultChildren as i}from"./renderDefaultChildren.shared.mjs";import{isVariable as a,libraryDefaultLocale as o}from"generaltranslation/internal";import{jsx as s}from"react/jsx-runtime";import c from"react";import{HTML_CONTENT_PROPS as l}from"@generaltranslation/format/types";function u({renderVariable:u}){let d=i({renderVariable:u});function f({sourceElement:e,targetElement:t,locales:n=[o],enableI18n:i}){let{props:a}=e,s=a[`data-_gt`],u=s?.transformation,f=t.d,m={};if(f&&Object.entries(l).forEach(([e,t])=>{f[e]&&(m[t]=f[e])}),u===`plural`){let a=e.props.n;return typeof a==`number`?p({source:r(a,n,s.branches||{})??e.props.children,target:r(a,n,t.d?.b||{})??t.c,locales:n,enableI18n:i}):d({children:e,defaultLocale:n[0],enableI18n:i})}if(u===`branch`){let{branch:e,children:r}=a,o=e==null||e===``?void 0:e.toString(),c=s.branches||{},l=t.d?.b||{};return p({source:o&&c[o]!==void 0?c[o]:r,target:o&&l[o]!==void 0?l[o]:t.c,locales:n,enableI18n:i})}return u===`fragment`&&t.c?c.createElement(c.Fragment,{key:e.props.key,children:p({source:a.children,target:t.c,locales:n,enableI18n:i})}):a?.children&&t?.c?c.cloneElement(e,{...a,...m,"data-_gt":void 0,children:p({source:a.children,target:t.c,locales:n,enableI18n:i})}):d({children:e,defaultLocale:n[0],enableI18n:i})}function p({source:r,target:i,locales:l=[o],enableI18n:p}){if(i==null&&r)return d({children:r,defaultLocale:l[0],enableI18n:p});if(typeof i==`string`)return i;if(Array.isArray(i)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(i)){let o={},d={},m={},h=r.filter(n=>{if(c.isValidElement(n))if(t(n.props)){let{variableName:t,variableValue:r,variableOptions:i,injectionType:a}=e(n.props);o[t]=r,d[t]=i,m[t]=a}else return!0;return!1}),g=e=>h.find(t=>{let r=n(t);return r?.id===void 0?!1:r.id===e.i})||h.shift();return i.map((e,t)=>{if(typeof e==`string`)return s(c.Fragment,{children:e},`string_${t}`);if(a(e))return s(c.Fragment,{children:u({variableType:e.v||`v`,variableValue:o[e.k],variableOptions:d[e.k],locales:l,enableI18n:p,injectionType:m[e.k]||`manual`})},`var_${t}`);let n=g(e);return n?s(c.Fragment,{children:f({sourceElement:n,targetElement:e,locales:l,enableI18n:p})},`element_${t}`):null})}if(i&&typeof i==`object`&&!Array.isArray(i)){let n=a(i)?`variable`:`element`;if(c.isValidElement(r)){if(n===`element`)return f({sourceElement:r,targetElement:i,locales:l,enableI18n:p});if(t(r.props)){let{variableValue:t,variableOptions:n,variableType:i,injectionType:a}=e(r.props);return u({variableType:i,variableValue:t,variableOptions:n,locales:l,enableI18n:p,injectionType:a})}}}return d({children:r,defaultLocale:l[0],enableI18n:p})}return p}export{u as createRenderTranslatedChildren};
2
+ //# sourceMappingURL=renderTranslatedChildren.shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTranslatedChildren.shared.mjs","names":[],"sources":["../../../src/utils/rendering/renderTranslatedChildren.shared.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n TaggedChildren,\n TaggedElement,\n TranslatedChildren,\n TranslatedElement,\n VariableProps,\n} from '../types';\nimport {\n getVariableProps,\n isVariableElementProps,\n} from '../variables/_getVariableProps';\nimport { createRenderDefaultChildren } from './renderDefaultChildren.shared';\nimport { isVariable, libraryDefaultLocale } from 'generaltranslation/internal';\nimport { getPluralBranch } from '../plurals/getPluralBranch';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\nimport { getGTTag } from './getGTTag';\nimport type { RenderVariable } from '../types';\n\n// Shared implementation: the variable renderer is dependency-injected by a\n// factory so neither code path statically imports the other's variable\n// components. Callsites use the pre-instantiated renderPipeline /\n// renderPipeline.rsc modules instead of importing this directly.\n\ntype RenderTranslatedChildrenArgs = {\n source: TaggedChildren;\n target: TranslatedChildren;\n locales: string[];\n enableI18n: boolean;\n};\n\nfunction createRenderTranslatedChildren({\n renderVariable,\n}: {\n renderVariable: RenderVariable;\n}): (args: RenderTranslatedChildrenArgs) => ReactNode {\n const renderDefaultChildren = createRenderDefaultChildren({ renderVariable });\n\n function renderTranslatedElement({\n sourceElement,\n targetElement,\n locales = [libraryDefaultLocale],\n enableI18n,\n }: {\n sourceElement: TaggedElement;\n targetElement: TranslatedElement;\n locales: string[];\n enableI18n: boolean;\n }): React.ReactNode {\n // Get props and generaltranslation\n const { props: sourceProps } = sourceElement;\n const sourceGT = sourceProps['data-_gt'];\n const transformation = sourceGT?.transformation;\n\n // Get translated props\n const unprocessedTargetGT = targetElement.d;\n const translatedProps: HtmlContentPropValuesRecord = {};\n if (unprocessedTargetGT) {\n Object.entries(HTML_CONTENT_PROPS).forEach(([minifiedName, fullName]) => {\n if (\n unprocessedTargetGT[minifiedName as keyof typeof HTML_CONTENT_PROPS]\n ) {\n translatedProps[fullName] = unprocessedTargetGT[\n minifiedName as keyof typeof HTML_CONTENT_PROPS\n ] as string;\n }\n });\n }\n\n // plural (choose a branch)\n if (transformation === 'plural') {\n const n = sourceElement.props.n;\n if (typeof n !== 'number') {\n return renderDefaultChildren({\n children: sourceElement,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n const sourceBranches = sourceGT.branches || {};\n const resolvedSourceBranch = getPluralBranch(n, locales, sourceBranches);\n const sourceBranch =\n resolvedSourceBranch != null\n ? resolvedSourceBranch\n : sourceElement.props.children;\n const targetBranches = targetElement.d?.b || {};\n const resolvedTargetBranch = getPluralBranch(n, locales, targetBranches);\n const targetBranch =\n resolvedTargetBranch != null ? resolvedTargetBranch : targetElement.c;\n return renderTranslatedChildren({\n source: sourceBranch as TaggedChildren,\n target: targetBranch as TranslatedChildren,\n locales,\n enableI18n,\n });\n }\n\n // branch (choose a branch)\n if (transformation === 'branch') {\n const { branch, children } = sourceProps;\n const branchKey =\n branch == null || branch === '' ? undefined : branch.toString();\n const sourceBranches = sourceGT.branches || {};\n const targetBranches = targetElement.d?.b || {};\n const sourceBranch =\n branchKey && sourceBranches[branchKey] !== undefined\n ? sourceBranches[branchKey]\n : children;\n const targetBranch =\n branchKey && targetBranches[branchKey] !== undefined\n ? targetBranches[branchKey]\n : targetElement.c;\n return renderTranslatedChildren({\n source: sourceBranch as TaggedChildren,\n target: targetBranch as TranslatedChildren,\n locales,\n enableI18n,\n });\n }\n\n // fragment (create a valid fragment)\n if (transformation === 'fragment' && targetElement.c) {\n return React.createElement(React.Fragment, {\n key: sourceElement.props.key,\n children: renderTranslatedChildren({\n source: sourceProps.children as TaggedChildren,\n target: targetElement.c,\n locales,\n enableI18n,\n }) as TaggedChildren,\n });\n }\n\n // other\n if (sourceProps?.children && targetElement?.c) {\n return React.cloneElement(sourceElement, {\n ...sourceProps,\n ...translatedProps,\n 'data-_gt': undefined,\n children: renderTranslatedChildren({\n source: sourceProps.children as TaggedChildren,\n target: targetElement.c,\n locales,\n enableI18n,\n }) as TaggedChildren,\n });\n }\n\n // fallback\n return renderDefaultChildren({\n children: sourceElement,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n\n function renderTranslatedChildren({\n source,\n target,\n locales = [libraryDefaultLocale],\n enableI18n,\n }: RenderTranslatedChildrenArgs): ReactNode {\n // Most straightforward case, return a valid React node\n if ((target === null || typeof target === 'undefined') && source)\n return renderDefaultChildren({\n children: source,\n defaultLocale: locales[0],\n enableI18n,\n });\n if (typeof target === 'string') return target;\n\n // Convert source to an array in case target has multiple children where source only has one\n if (Array.isArray(target) && !Array.isArray(source) && source)\n source = [source];\n\n // Multiple children\n if (Array.isArray(source) && Array.isArray(target)) {\n // Track the variables\n const variables: Record<string, VariableProps['variableValue']> = {};\n const variablesOptions: Record<string, VariableProps['variableOptions']> =\n {};\n const variableInjectionTypes: Record<\n string,\n VariableProps['injectionType']\n > = {};\n\n // Extract source elements\n // Extract variable props\n // Filter out variable elements\n const sourceElements: TaggedElement[] = source.filter(\n (sourceChild): sourceChild is TaggedElement => {\n if (React.isValidElement(sourceChild)) {\n if (isVariableElementProps(sourceChild.props)) {\n const {\n variableName,\n variableValue,\n variableOptions,\n injectionType,\n } = getVariableProps(sourceChild.props);\n variables[variableName] = variableValue;\n variablesOptions[variableName] = variableOptions;\n variableInjectionTypes[variableName] = injectionType;\n } else {\n return true;\n }\n }\n return false;\n }\n );\n\n // TODO: pre-index these to avoid O(n/2) lookups\n const findMatchingSourceElement = (\n targetElement: TranslatedElement\n ): TaggedElement | undefined => {\n return (\n sourceElements.find((sourceChild): sourceChild is TaggedElement => {\n const generaltranslation = getGTTag(sourceChild);\n if (typeof generaltranslation?.id !== 'undefined') {\n const sourceId = generaltranslation.id;\n const targetId = targetElement.i;\n return sourceId === targetId;\n }\n return false;\n }) || sourceElements.shift()\n ); // assumes fixed order, not recommended\n };\n\n // map target to source\n return target.map((targetChild, index) => {\n if (typeof targetChild === 'string')\n return (\n <React.Fragment key={`string_${index}`}>\n {targetChild}\n </React.Fragment>\n );\n\n // Render variable\n if (isVariable(targetChild)) {\n return (\n <React.Fragment key={`var_${index}`}>\n {renderVariable({\n variableType: targetChild.v || 'v',\n variableValue: variables[targetChild.k],\n variableOptions: variablesOptions[targetChild.k],\n locales,\n enableI18n,\n injectionType:\n variableInjectionTypes[targetChild.k] || 'manual',\n })}\n </React.Fragment>\n );\n }\n\n // Render element (targetChild is a TranslatedElement)\n const matchingSourceElement = findMatchingSourceElement(\n targetChild as TranslatedElement\n );\n if (!matchingSourceElement) return null;\n return (\n <React.Fragment key={`element_${index}`}>\n {renderTranslatedElement({\n sourceElement: matchingSourceElement,\n targetElement: targetChild,\n locales,\n enableI18n,\n })}\n </React.Fragment>\n );\n });\n }\n\n // Single child\n if (target && typeof target === 'object' && !Array.isArray(target)) {\n const targetType: 'variable' | 'element' = isVariable(target)\n ? 'variable'\n : 'element';\n\n if (React.isValidElement(source)) {\n if (targetType === 'element') {\n return renderTranslatedElement({\n sourceElement: source,\n targetElement: target as TranslatedElement,\n locales,\n enableI18n,\n });\n }\n\n // Render variable\n if (isVariableElementProps(source.props)) {\n const {\n variableValue,\n variableOptions,\n variableType,\n injectionType,\n } = getVariableProps(source.props);\n return renderVariable({\n variableType,\n variableValue,\n variableOptions,\n locales,\n enableI18n,\n injectionType,\n });\n }\n }\n }\n\n // fallback\n return renderDefaultChildren({\n children: source,\n defaultLocale: locales[0],\n enableI18n,\n });\n }\n\n return renderTranslatedChildren;\n}\n\nexport { createRenderTranslatedChildren };\nexport type { RenderTranslatedChildrenArgs };\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../internal/addGTIdentifier.cjs`),t=require(`../internal/removeInjectedT.cjs`),n=require(`../internal/writeChildrenAsObjects.cjs`);function r({sourceChildren:e,params:t,locale:n}){let r=i(e);return{taggedSourceChildren:r,sourceJsxChildren:a(r),targetOptions:o({options:s(t),locale:n})}}function i(n){return e.addGTIdentifier(t.removeInjectedT(n))}function a(e){return n.writeChildrenAsObjects(e)}function o({options:e,locale:t}){return{...e,$locale:t}}function s(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}exports.prepareT=r;
2
+ //# sourceMappingURL=prepareT.shared.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareT.shared.cjs","names":["addGTIdentifier","removeInjectedT","writeChildrenAsObjects"],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"oJA2CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAKxE,MAAO,CACL,uBACA,kBANwB,EAAyB,EAMhC,CACjB,cALoB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAK/C,CACd,CAGH,SAAS,EACP,EACgB,CAChB,OAAOA,EAAAA,gBAAgBC,EAAAA,gBAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAOC,EAAAA,uBAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
@@ -0,0 +1,40 @@
1
+ import { TaggedChildren } from "../types.js";
2
+ import { RenderPreparedTParams } from "../rendering/renderPreparedT.shared.js";
3
+ import { ReactNode } from "react";
4
+ import { JsxTranslationOptions } from "gt-i18n/types";
5
+ import { JsxChildren } from "generaltranslation/types";
6
+
7
+ //#region src/utils/translation/prepareT.shared.d.ts
8
+ type StripDollarPrefix<T> = { [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K] };
9
+ type JsxTranslationOptions$1 = StripDollarPrefix<JsxTranslationOptions> & JsxTranslationOptions;
10
+ type PreparedT = {
11
+ taggedSourceChildren: TaggedChildren;
12
+ sourceJsxChildren: JsxChildren;
13
+ targetOptions: JsxTranslationOptions & {
14
+ $format: 'JSX';
15
+ $locale: string;
16
+ };
17
+ };
18
+ type RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;
19
+ type TProps = {
20
+ children: ReactNode;
21
+ _locale?: string;
22
+ _enableI18n?: boolean;
23
+ _renderPreparedT?: RenderPreparedT;
24
+ } & JsxTranslationOptions$1;
25
+ type ResolvedTProps = TProps & {
26
+ _locale: string;
27
+ _enableI18n: boolean;
28
+ };
29
+ declare function prepareT({
30
+ sourceChildren,
31
+ params,
32
+ locale
33
+ }: {
34
+ sourceChildren: ReactNode;
35
+ params: JsxTranslationOptions$1;
36
+ locale: string;
37
+ }): PreparedT;
38
+ //#endregion
39
+ export { type JsxTranslationOptions$1 as JsxTranslationOptions, type PreparedT, type RenderPreparedT, type ResolvedTProps, type TProps, prepareT };
40
+ //# sourceMappingURL=prepareT.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareT.shared.d.ts","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"mappings":";;;;;;;KAaK,iBAAA,oBACS,CAAA,IAAK,CAAA,4BAA6B,IAAA,GAAO,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGxD,uBAAA,GAAwB,iBAAA,CAAkB,qBAAA,IAC7C,qBAAA;AAAA,KAEG,SAAA;EACH,oBAAA,EAAsB,cAAA;EACtB,iBAAA,EAAmB,WAAA;EACnB,aAAA,EAAe,qBAAA;IACb,OAAA;IACA,OAAA;EAAA;AAAA;AAAA,KAIC,eAAA,IAAmB,MAAA,EAAQ,qBAAA,KAA0B,SAAA;AAAA,KAErD,MAAA;EACH,QAAA,EAAU,SAAA;EACV,OAAA;EACA,WAAA;EACA,gBAAA,GAAmB,eAAA;AAAA,IACjB,uBAAA;AAAA,KAEC,cAAA,GAAiB,MAAA;EACpB,OAAA;EACA,WAAA;AAAA;AAAA,iBAGO,QAAA,CAAA;EACP,cAAA;EACA,MAAA;EACA;AAAA;EAEA,cAAA,EAAgB,SAAA;EAChB,MAAA,EAAQ,uBAAA;EACR,MAAA;AAAA,IACE,SAAA"}
@@ -0,0 +1,2 @@
1
+ import{addGTIdentifier as e}from"../internal/addGTIdentifier.mjs";import{removeInjectedT as t}from"../internal/removeInjectedT.mjs";import{writeChildrenAsObjects as n}from"../internal/writeChildrenAsObjects.mjs";function r({sourceChildren:e,params:t,locale:n}){let r=i(e);return{taggedSourceChildren:r,sourceJsxChildren:a(r),targetOptions:o({options:s(t),locale:n})}}function i(n){return e(t(n))}function a(e){return n(e)}function o({options:e,locale:t}){return{...e,$locale:t}}function s(e){return{...e,$format:`JSX`,$context:e.$context??e.context,$id:e.$id??e.id,$_hash:e.$_hash??e._hash,$maxChars:e.$maxChars??e.maxChars,$requiresReview:e.$requiresReview??e.requiresReview}}export{r as prepareT};
2
+ //# sourceMappingURL=prepareT.shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareT.shared.mjs","names":[],"sources":["../../../src/utils/translation/prepareT.shared.ts"],"sourcesContent":["import { addGTIdentifier } from '../internal/addGTIdentifier';\nimport { removeInjectedT } from '../internal/removeInjectedT';\nimport { writeChildrenAsObjects } from '../internal/writeChildrenAsObjects';\nimport type { JsxTranslationOptions as JsxTranslationOptionsWithSugar } from 'gt-i18n/types';\nimport type { JsxChildren } from 'generaltranslation/types';\nimport type { ReactNode } from 'react';\nimport type { RenderPreparedTParams } from '../rendering/renderPreparedT.shared';\nimport type { TaggedChildren } from '../types';\n\n// Pure preparation logic shared by the hook wrapper (usePrepareT) and the RSC\n// code path. This module must stay free of hook/context imports so it can be\n// reached from the components-rsc entrypoint.\n\ntype StripDollarPrefix<T> = {\n [K in keyof T as K extends `$${infer Rest}` ? Rest : K]: T[K];\n};\n\ntype JsxTranslationOptions = StripDollarPrefix<JsxTranslationOptionsWithSugar> &\n JsxTranslationOptionsWithSugar;\n\ntype PreparedT = {\n taggedSourceChildren: TaggedChildren;\n sourceJsxChildren: JsxChildren;\n targetOptions: JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n };\n};\n\ntype RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;\n\ntype TProps = {\n children: ReactNode;\n _locale?: string;\n _enableI18n?: boolean;\n _renderPreparedT?: RenderPreparedT;\n} & JsxTranslationOptions;\n\ntype ResolvedTProps = TProps & {\n _locale: string;\n _enableI18n: boolean;\n};\n\nfunction prepareT({\n sourceChildren,\n params,\n locale,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n locale: string;\n}): PreparedT {\n const taggedSourceChildren = prepareTaggedSourceChildren(sourceChildren);\n const sourceJsxChildren = prepareSourceJsxChildren(taggedSourceChildren);\n const options = normalizeParameters(params);\n const targetOptions = prepareTargetOptions({ options, locale });\n\n return {\n taggedSourceChildren,\n sourceJsxChildren,\n targetOptions,\n };\n}\n\nfunction prepareTaggedSourceChildren(\n sourceChildren: ReactNode\n): TaggedChildren {\n return addGTIdentifier(removeInjectedT(sourceChildren));\n}\n\nfunction prepareSourceJsxChildren(\n taggedSourceChildren: TaggedChildren\n): JsxChildren {\n return writeChildrenAsObjects(taggedSourceChildren);\n}\n\nfunction prepareTargetOptions({\n options,\n locale,\n}: {\n options: JsxTranslationOptionsWithSugar & { $format: 'JSX' };\n locale: string;\n}): JsxTranslationOptionsWithSugar & {\n $format: 'JSX';\n $locale: string;\n} {\n return { ...options, $locale: locale };\n}\n\nfunction normalizeParameters(\n parameters: {\n context?: string;\n id?: string;\n _hash?: string;\n } & JsxTranslationOptions\n): JsxTranslationOptionsWithSugar & { $format: 'JSX' } {\n return {\n ...parameters,\n $format: 'JSX',\n $context: parameters.$context ?? parameters.context,\n $id: parameters.$id ?? parameters.id,\n $_hash: parameters.$_hash ?? parameters._hash,\n $maxChars: parameters.$maxChars ?? parameters.maxChars,\n $requiresReview: parameters.$requiresReview ?? parameters.requiresReview,\n };\n}\n\nexport { prepareT };\nexport type {\n JsxTranslationOptions,\n PreparedT,\n RenderPreparedT,\n ResolvedTProps,\n TProps,\n};\n"],"mappings":"oNA2CA,SAAS,EAAS,CAChB,iBACA,SACA,UAKY,CACZ,IAAM,EAAuB,EAA4B,EAAe,CAKxE,MAAO,CACL,uBACA,kBANwB,EAAyB,EAMhC,CACjB,cALoB,EAAqB,CAAE,QAD7B,EAAoB,EACgB,CAAE,SAAQ,CAK/C,CACd,CAGH,SAAS,EACP,EACgB,CAChB,OAAO,EAAgB,EAAgB,EAAe,CAAC,CAGzD,SAAS,EACP,EACa,CACb,OAAO,EAAuB,EAAqB,CAGrD,SAAS,EAAqB,CAC5B,UACA,UAOA,CACA,MAAO,CAAE,GAAG,EAAS,QAAS,EAAQ,CAGxC,SAAS,EACP,EAKqD,CACrD,MAAO,CACL,GAAG,EACH,QAAS,MACT,SAAU,EAAW,UAAY,EAAW,QAC5C,IAAK,EAAW,KAAO,EAAW,GAClC,OAAQ,EAAW,QAAU,EAAW,MACxC,UAAW,EAAW,WAAa,EAAW,SAC9C,gBAAiB,EAAW,iBAAmB,EAAW,eAC3D"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../hooks/condition-store.cjs`),t=require(`../../hooks/i18n-config.cjs`),n=require(`./prepareT.shared.cjs`);let r=require(`gt-i18n/internal`),i=require(`react`);function a({sourceChildren:a,params:o,_locale:s,_enableI18n:c}){let l=e.useLocale(),u=e.useEnableI18n(),d=t.useDefaultLocale(),f=s??l,p=c??u;return{defaultLocale:d,enableI18n:p,locale:f,shouldTranslate:p&&(0,r.getI18nConfig)().requiresTranslation(f),...(0,i.useMemo)(()=>n.prepareT({sourceChildren:a,params:o,locale:f}),[f,o,a])}}exports.usePrepareT=a;
2
+ //# sourceMappingURL=usePrepareT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrepareT.cjs","names":["useLocale","useEnableI18n","useDefaultLocale","prepareT"],"sources":["../../../src/utils/translation/usePrepareT.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from '../../hooks/condition-store';\nimport { useDefaultLocale } from '../../hooks/i18n-config';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport {\n prepareT,\n type JsxTranslationOptions,\n type PreparedT,\n} from './prepareT.shared';\nimport type { ReactNode } from 'react';\n\nfunction usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n _locale?: string;\n _enableI18n?: boolean;\n}): PreparedT & {\n defaultLocale: string;\n locale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n} {\n const contextLocale = useLocale();\n const contextEnableI18n = useEnableI18n();\n const defaultLocale = useDefaultLocale();\n const locale = _locale ?? contextLocale;\n const enableI18n = _enableI18n ?? contextEnableI18n;\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = useMemo(\n () =>\n prepareT({\n sourceChildren,\n params,\n locale,\n }),\n [locale, params, sourceChildren]\n );\n\n return {\n defaultLocale,\n enableI18n,\n locale,\n shouldTranslate,\n ...prepared,\n };\n}\n\nexport { usePrepareT };\n"],"mappings":"oOAWA,SAAS,EAAY,CACnB,iBACA,SACA,UACA,eAWA,CACA,IAAM,EAAgBA,EAAAA,WAAW,CAC3B,EAAoBC,EAAAA,eAAe,CACnC,EAAgBC,EAAAA,kBAAkB,CAClC,EAAS,GAAW,EACpB,EAAa,GAAe,EAalC,MAAO,CACL,gBACA,aACA,SACA,gBAfA,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAgBzD,IAAA,EAAA,EAAA,aAbEC,EAAAA,SAAS,CACP,iBACA,SACA,SACD,CAAC,CACJ,CAAC,EAAQ,EAAQ,EAAe,CAQrB,CACZ"}
@@ -0,0 +1,2 @@
1
+ import{useEnableI18n as e,useLocale as t}from"../../hooks/condition-store.mjs";import{useDefaultLocale as n}from"../../hooks/i18n-config.mjs";import{prepareT as r}from"./prepareT.shared.mjs";import{getI18nConfig as i}from"gt-i18n/internal";import{useMemo as a}from"react";function o({sourceChildren:o,params:s,_locale:c,_enableI18n:l}){let u=t(),d=e(),f=n(),p=c??u,m=l??d;return{defaultLocale:f,enableI18n:m,locale:p,shouldTranslate:m&&i().requiresTranslation(p),...a(()=>r({sourceChildren:o,params:s,locale:p}),[p,s,o])}}export{o as usePrepareT};
2
+ //# sourceMappingURL=usePrepareT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrepareT.mjs","names":[],"sources":["../../../src/utils/translation/usePrepareT.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from '../../hooks/condition-store';\nimport { useDefaultLocale } from '../../hooks/i18n-config';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport {\n prepareT,\n type JsxTranslationOptions,\n type PreparedT,\n} from './prepareT.shared';\nimport type { ReactNode } from 'react';\n\nfunction usePrepareT({\n sourceChildren,\n params,\n _locale,\n _enableI18n,\n}: {\n sourceChildren: ReactNode;\n params: JsxTranslationOptions;\n _locale?: string;\n _enableI18n?: boolean;\n}): PreparedT & {\n defaultLocale: string;\n locale: string;\n enableI18n: boolean;\n shouldTranslate: boolean;\n} {\n const contextLocale = useLocale();\n const contextEnableI18n = useEnableI18n();\n const defaultLocale = useDefaultLocale();\n const locale = _locale ?? contextLocale;\n const enableI18n = _enableI18n ?? contextEnableI18n;\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n const prepared = useMemo(\n () =>\n prepareT({\n sourceChildren,\n params,\n locale,\n }),\n [locale, params, sourceChildren]\n );\n\n return {\n defaultLocale,\n enableI18n,\n locale,\n shouldTranslate,\n ...prepared,\n };\n}\n\nexport { usePrepareT };\n"],"mappings":"gRAWA,SAAS,EAAY,CACnB,iBACA,SACA,UACA,eAWA,CACA,IAAM,EAAgB,GAAW,CAC3B,EAAoB,GAAe,CACnC,EAAgB,GAAkB,CAClC,EAAS,GAAW,EACpB,EAAa,GAAe,EAalC,MAAO,CACL,gBACA,aACA,SACA,gBAfA,GAAc,GAAe,CAAC,oBAAoB,EAAO,CAgBzD,GAfe,MAEb,EAAS,CACP,iBACA,SACA,SACD,CAAC,CACJ,CAAC,EAAQ,EAAQ,EAAe,CAQrB,CACZ"}
@@ -0,0 +1,64 @@
1
+ import React from "react";
2
+ import { GTFunctionType as GTFunctionType$1, GTTranslationOptions as GTTranslationOptions$1, MFunctionType as MFunctionType$1, RuntimeTranslationOptions } from "gt-i18n/types";
3
+ import { InjectionType, TransformationPrefix, VariableTransformationSuffix } from "generaltranslation/types";
4
+ import { GTProp, Variable, VariableType } from "@generaltranslation/format/types";
5
+
6
+ //#region src/utils/types.d.ts
7
+ /**
8
+ * TaggedElement is a React element with a GTProp property.
9
+ */
10
+ type GTTag = {
11
+ id: number;
12
+ injectionType: InjectionType;
13
+ transformation?: TransformationPrefix;
14
+ branches?: Record<string, TaggedChildren>;
15
+ variableType?: VariableTransformationSuffix;
16
+ };
17
+ type TaggedElementProps = Record<string, unknown> & {
18
+ 'data-_gt': GTTag;
19
+ children?: TaggedChildren;
20
+ branch?: string | number | boolean;
21
+ n?: number;
22
+ key?: React.Key;
23
+ };
24
+ type TaggedElement = React.ReactElement<TaggedElementProps>;
25
+ type TaggedChild = Exclude<React.ReactNode, React.ReactElement> | TaggedElement;
26
+ type TaggedChildren = TaggedChild[] | TaggedChild;
27
+ /**
28
+ * Translated content types
29
+ * TODO: move these types to JsxElement etc from generaltranslation/types
30
+ * remember to omit the t property (tag name) from the translated element
31
+ */
32
+ type TranslatedElement = {
33
+ i?: number;
34
+ d?: GTProp;
35
+ c?: TranslatedChildren;
36
+ };
37
+ type TranslatedChild = TranslatedElement | string | Variable;
38
+ type TranslatedChildren = TranslatedChild | TranslatedChild[];
39
+ type RelativeTimeFormatOptions = Intl.RelativeTimeFormatOptions & {
40
+ unit?: Intl.RelativeTimeFormatUnit;
41
+ baseDate?: Date;
42
+ };
43
+ type VariableProps = {
44
+ /** Whether the variable was automatically injected by the compiler */variableType: VariableType;
45
+ variableValue: unknown;
46
+ variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | RelativeTimeFormatOptions;
47
+ variableName: string;
48
+ injectionType: InjectionType;
49
+ };
50
+ type RenderVariable = ({
51
+ variableType,
52
+ variableValue,
53
+ variableOptions,
54
+ locales,
55
+ enableI18n,
56
+ injectionType
57
+ }: Omit<VariableProps, 'variableName'> & {
58
+ locales: string[];
59
+ enableI18n: boolean;
60
+ }) => React.ReactNode;
61
+ type RenderMethod = 'skeleton' | 'replace' | 'default';
62
+ //#endregion
63
+ export { type GTFunctionType$1 as GTFunctionType, type GTProp, type GTTranslationOptions$1 as GTTranslationOptions, type MFunctionType$1 as MFunctionType, RelativeTimeFormatOptions, RenderMethod, RenderVariable, type RuntimeTranslationOptions, TaggedChildren, TranslatedChildren, VariableProps };
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/utils/types.ts"],"mappings":";;;;;;;AAuBA;;KAAY,KAAA;EACV,EAAA;EACA,aAAA,EAAe,aAAA;EACf,cAAA,GAAiB,oBAAA;EACjB,QAAA,GAAW,MAAA,SAAe,cAAA;EAC1B,YAAA,GAAe,4BAAA;AAAA;AAAA,KAEL,kBAAA,GAAqB,MAAA;EAC/B,UAAA,EAAY,KAAA;EACZ,QAAA,GAAW,cAAA;EACX,MAAA;EACA,CAAA;EACA,GAAA,GAAM,KAAA,CAAM,GAAA;AAAA;AAAA,KAEF,aAAA,GAAgB,KAAA,CAAM,YAAA,CAAa,kBAAA;AAAA,KACnC,WAAA,GACR,OAAA,CAAQ,KAAA,CAAM,SAAA,EAAW,KAAA,CAAM,YAAA,IAC/B,aAAA;AAAA,KACQ,cAAA,GAAiB,WAAA,KAAgB,WAAA;;;;AAX7C;;KAoBY,iBAAA;EACV,CAAA;EACA,CAAA,GAAI,MAAA;EACJ,CAAA,GAAI,kBAAA;AAAA;AAAA,KAEM,eAAA,GAAkB,iBAAA,YAA6B,QAAA;AAAA,KAC/C,kBAAA,GAAqB,eAAA,GAAkB,eAAA;AAAA,KA8BvC,yBAAA,GAA4B,IAAA,CAAK,yBAAA;EAC3C,IAAA,GAAO,IAAA,CAAK,sBAAA;EACZ,QAAA,GAAW,IAAA;AAAA;AAAA,KAED,aAAA;EAlDK,sEAoDf,YAAA,EAAc,YAAA;EACd,aAAA;EACA,eAAA,EACI,IAAA,CAAK,mBAAA,GACL,IAAA,CAAK,qBAAA,GACL,yBAAA;EACJ,YAAA;EACA,aAAA,EAAe,aAAA;AAAA;AAAA,KAGL,cAAA;EACV,YAAA;EACA,aAAA;EACA,eAAA;EACA,OAAA;EACA,UAAA;EACA;AAAA,GACC,IAAA,CAAK,aAAA;EACN,OAAA;EACA,UAAA;AAAA,MACI,KAAA,CAAM,SAAA;AAAA,KAKA,YAAA"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`react`);t=e.__toESM(t);function n(e){return t.default.isValidElement(e)}exports.isValidTaggedElement=n;
2
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","names":["React"],"sources":["../../src/utils/utils.tsx"],"sourcesContent":["import React from 'react';\nimport { TaggedElement, TaggedElementProps } from './types';\n\nexport function isValidTaggedElement(target: unknown): target is TaggedElement {\n return React.isValidElement<TaggedElementProps>(target);\n}\n"],"mappings":"2FAGA,SAAgB,EAAqB,EAA0C,CAC7E,OAAOA,EAAAA,QAAM,eAAmC,EAAO"}
@@ -0,0 +1,2 @@
1
+ import e from"react";function t(t){return e.isValidElement(t)}export{t as isValidTaggedElement};
2
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils/utils.tsx"],"sourcesContent":["import React from 'react';\nimport { TaggedElement, TaggedElementProps } from './types';\n\nexport function isValidTaggedElement(target: unknown): target is TaggedElement {\n return React.isValidElement<TaggedElementProps>(target);\n}\n"],"mappings":"qBAGA,SAAgB,EAAqB,EAA0C,CAC7E,OAAO,EAAM,eAAmC,EAAO"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./getVariableName.cjs`);let t=require(`generaltranslation/internal`);function n(e){return typeof e==`object`&&!!e&&`data-_gt`in e&&typeof e[`data-_gt`]==`object`&&!!e[`data-_gt`]&&`transformation`in e[`data-_gt`]&&e[`data-_gt`]?.transformation===`variable`}function r(n){let r=n[`data-_gt`]?.variableType||`variable`;return{variableName:e.getVariableName(n,r),variableType:(0,t.minifyVariableType)(r),injectionType:n[`data-_gt`]?.injectionType||`manual`,variableValue:(()=>{if(n.value!==void 0)return n.value;if(n.date!==void 0)return n.date;if(n[`data-_gt-unformatted-value`]!==void 0)return n[`data-_gt-unformatted-value`];if(n.children!==void 0)return n.children})(),variableOptions:(()=>{let e={...n.currency!==void 0&&{currency:n.currency},...n.unit!==void 0&&{unit:n.unit},...n.baseDate!==void 0&&{baseDate:n.baseDate},...n.options!==void 0&&n.options};return Object.keys(e).length?e:typeof n[`data-_gt-variable-options`]==`string`?JSON.parse(n[`data-_gt-variable-options`]):n[`data-_gt-variable-options`]||void 0})()}}exports.getVariableProps=r,exports.isVariableElementProps=n;
2
+ //# sourceMappingURL=_getVariableProps.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_getVariableProps.cjs","names":["getVariableName"],"sources":["../../../src/utils/variables/_getVariableProps.ts"],"sourcesContent":["import { VariableTransformationSuffix } from 'generaltranslation/types';\nimport { GTTag, VariableProps } from '../types';\nimport { getVariableName } from './getVariableName';\nimport { minifyVariableType } from 'generaltranslation/internal';\n\ntype VariableElementProps = {\n 'data-_gt': GTTag & {\n transformation: 'variable';\n };\n [key: string]: unknown;\n};\n\nexport function isVariableElementProps(\n props: unknown\n): props is VariableElementProps {\n return (\n typeof props === 'object' &&\n !!props &&\n 'data-_gt' in props &&\n typeof props['data-_gt'] === 'object' &&\n !!props['data-_gt'] &&\n 'transformation' in props['data-_gt'] &&\n props['data-_gt']?.transformation === 'variable'\n );\n}\n\nexport function getVariableProps(props: VariableElementProps): VariableProps {\n const variableType: VariableTransformationSuffix =\n props['data-_gt']?.variableType || 'variable';\n\n const result: VariableProps = {\n variableName: getVariableName(props, variableType),\n variableType: minifyVariableType(variableType),\n injectionType: props['data-_gt']?.injectionType || 'manual',\n variableValue: (() => {\n if (typeof props.value !== 'undefined') return props.value;\n if (typeof props.date !== 'undefined') return props.date;\n if (typeof props['data-_gt-unformatted-value'] !== 'undefined')\n return props['data-_gt-unformatted-value'];\n if (typeof props.children !== 'undefined') return props.children;\n return undefined;\n })(),\n variableOptions: (() => {\n const variableOptions = {\n ...(typeof props.currency !== 'undefined' && {\n currency: props.currency,\n }),\n ...(typeof props.unit !== 'undefined' && {\n unit: props.unit,\n }),\n ...(typeof props.baseDate !== 'undefined' && {\n baseDate: props.baseDate,\n }),\n ...(typeof props.options !== 'undefined' && props.options),\n };\n if (Object.keys(variableOptions).length) return variableOptions;\n if (typeof props['data-_gt-variable-options'] === 'string')\n return JSON.parse(props['data-_gt-variable-options']);\n return props['data-_gt-variable-options'] || undefined;\n })(),\n };\n\n return result;\n}\n"],"mappings":"sIAYA,SAAgB,EACd,EAC+B,CAC/B,OACE,OAAO,GAAU,UACjB,CAAC,CAAC,GACF,aAAc,GACd,OAAO,EAAM,aAAgB,UAC7B,CAAC,CAAC,EAAM,aACR,mBAAoB,EAAM,aAC1B,EAAM,aAAa,iBAAmB,WAI1C,SAAgB,EAAiB,EAA4C,CAC3E,IAAM,EACJ,EAAM,aAAa,cAAgB,WAkCrC,MAAO,CA/BL,aAAcA,EAAAA,gBAAgB,EAAO,EAAa,CAClD,cAAA,EAAA,EAAA,oBAAiC,EAAa,CAC9C,cAAe,EAAM,aAAa,eAAiB,SACnD,mBAAsB,CACpB,GAAW,EAAM,QAAU,OAAa,OAAO,EAAM,MACrD,GAAW,EAAM,OAAS,OAAa,OAAO,EAAM,KACpD,GAAW,EAAM,gCAAkC,OACjD,OAAO,EAAM,8BACf,GAAW,EAAM,WAAa,OAAa,OAAO,EAAM,YAEtD,CACJ,qBAAwB,CACtB,IAAM,EAAkB,CACtB,GAAW,EAAM,WAAa,QAAe,CAC3C,SAAU,EAAM,SACjB,CACD,GAAW,EAAM,OAAS,QAAe,CACvC,KAAM,EAAM,KACb,CACD,GAAW,EAAM,WAAa,QAAe,CAC3C,SAAU,EAAM,SACjB,CACD,GAAW,EAAM,UAAY,QAAe,EAAM,QACnD,CAID,OAHI,OAAO,KAAK,EAAgB,CAAC,OAAe,EAC5C,OAAO,EAAM,8BAAiC,SACzC,KAAK,MAAM,EAAM,6BAA6B,CAChD,EAAM,8BAAgC,IAAA,MAC3C,CAGO"}
@@ -0,0 +1,2 @@
1
+ import{getVariableName as e}from"./getVariableName.mjs";import{minifyVariableType as t}from"generaltranslation/internal";function n(e){return typeof e==`object`&&!!e&&`data-_gt`in e&&typeof e[`data-_gt`]==`object`&&!!e[`data-_gt`]&&`transformation`in e[`data-_gt`]&&e[`data-_gt`]?.transformation===`variable`}function r(n){let r=n[`data-_gt`]?.variableType||`variable`;return{variableName:e(n,r),variableType:t(r),injectionType:n[`data-_gt`]?.injectionType||`manual`,variableValue:(()=>{if(n.value!==void 0)return n.value;if(n.date!==void 0)return n.date;if(n[`data-_gt-unformatted-value`]!==void 0)return n[`data-_gt-unformatted-value`];if(n.children!==void 0)return n.children})(),variableOptions:(()=>{let e={...n.currency!==void 0&&{currency:n.currency},...n.unit!==void 0&&{unit:n.unit},...n.baseDate!==void 0&&{baseDate:n.baseDate},...n.options!==void 0&&n.options};return Object.keys(e).length?e:typeof n[`data-_gt-variable-options`]==`string`?JSON.parse(n[`data-_gt-variable-options`]):n[`data-_gt-variable-options`]||void 0})()}}export{r as getVariableProps,n as isVariableElementProps};
2
+ //# sourceMappingURL=_getVariableProps.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_getVariableProps.mjs","names":[],"sources":["../../../src/utils/variables/_getVariableProps.ts"],"sourcesContent":["import { VariableTransformationSuffix } from 'generaltranslation/types';\nimport { GTTag, VariableProps } from '../types';\nimport { getVariableName } from './getVariableName';\nimport { minifyVariableType } from 'generaltranslation/internal';\n\ntype VariableElementProps = {\n 'data-_gt': GTTag & {\n transformation: 'variable';\n };\n [key: string]: unknown;\n};\n\nexport function isVariableElementProps(\n props: unknown\n): props is VariableElementProps {\n return (\n typeof props === 'object' &&\n !!props &&\n 'data-_gt' in props &&\n typeof props['data-_gt'] === 'object' &&\n !!props['data-_gt'] &&\n 'transformation' in props['data-_gt'] &&\n props['data-_gt']?.transformation === 'variable'\n );\n}\n\nexport function getVariableProps(props: VariableElementProps): VariableProps {\n const variableType: VariableTransformationSuffix =\n props['data-_gt']?.variableType || 'variable';\n\n const result: VariableProps = {\n variableName: getVariableName(props, variableType),\n variableType: minifyVariableType(variableType),\n injectionType: props['data-_gt']?.injectionType || 'manual',\n variableValue: (() => {\n if (typeof props.value !== 'undefined') return props.value;\n if (typeof props.date !== 'undefined') return props.date;\n if (typeof props['data-_gt-unformatted-value'] !== 'undefined')\n return props['data-_gt-unformatted-value'];\n if (typeof props.children !== 'undefined') return props.children;\n return undefined;\n })(),\n variableOptions: (() => {\n const variableOptions = {\n ...(typeof props.currency !== 'undefined' && {\n currency: props.currency,\n }),\n ...(typeof props.unit !== 'undefined' && {\n unit: props.unit,\n }),\n ...(typeof props.baseDate !== 'undefined' && {\n baseDate: props.baseDate,\n }),\n ...(typeof props.options !== 'undefined' && props.options),\n };\n if (Object.keys(variableOptions).length) return variableOptions;\n if (typeof props['data-_gt-variable-options'] === 'string')\n return JSON.parse(props['data-_gt-variable-options']);\n return props['data-_gt-variable-options'] || undefined;\n })(),\n };\n\n return result;\n}\n"],"mappings":"yHAYA,SAAgB,EACd,EAC+B,CAC/B,OACE,OAAO,GAAU,UACjB,CAAC,CAAC,GACF,aAAc,GACd,OAAO,EAAM,aAAgB,UAC7B,CAAC,CAAC,EAAM,aACR,mBAAoB,EAAM,aAC1B,EAAM,aAAa,iBAAmB,WAI1C,SAAgB,EAAiB,EAA4C,CAC3E,IAAM,EACJ,EAAM,aAAa,cAAgB,WAkCrC,MAAO,CA/BL,aAAc,EAAgB,EAAO,EAAa,CAClD,aAAc,EAAmB,EAAa,CAC9C,cAAe,EAAM,aAAa,eAAiB,SACnD,mBAAsB,CACpB,GAAW,EAAM,QAAU,OAAa,OAAO,EAAM,MACrD,GAAW,EAAM,OAAS,OAAa,OAAO,EAAM,KACpD,GAAW,EAAM,gCAAkC,OACjD,OAAO,EAAM,8BACf,GAAW,EAAM,WAAa,OAAa,OAAO,EAAM,YAEtD,CACJ,qBAAwB,CACtB,IAAM,EAAkB,CACtB,GAAW,EAAM,WAAa,QAAe,CAC3C,SAAU,EAAM,SACjB,CACD,GAAW,EAAM,OAAS,QAAe,CACvC,KAAM,EAAM,KACb,CACD,GAAW,EAAM,WAAa,QAAe,CAC3C,SAAU,EAAM,SACjB,CACD,GAAW,EAAM,UAAY,QAAe,EAAM,QACnD,CAID,OAHI,OAAO,KAAK,EAAgB,CAAC,OAAe,EAC5C,OAAO,EAAM,8BAAiC,SACzC,KAAK,MAAM,EAAM,6BAA6B,CAChD,EAAM,8BAAgC,IAAA,MAC3C,CAGO"}
@@ -0,0 +1,2 @@
1
+ const e={variable:`value`,number:`n`,datetime:`date`,currency:`cost`,"relative-time":`time`};function t(t={},n){return typeof t.name==`string`?t.name:`_gt_${e[n]||`value`}_${t[`data-_gt`]?.id}`}exports.getVariableName=t;
2
+ //# sourceMappingURL=getVariableName.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVariableName.cjs","names":[],"sources":["../../../src/utils/variables/getVariableName.ts"],"sourcesContent":["const defaultVariableNames = {\n variable: 'value',\n number: 'n',\n datetime: 'date',\n currency: 'cost',\n 'relative-time': 'time',\n} as const;\n\nexport const baseVariablePrefix = '_gt_';\n\nexport function getVariableName(\n props: Record<string, unknown> = {},\n variableType: keyof typeof defaultVariableNames\n): string {\n if (typeof props.name === 'string') return props.name;\n const baseVariableName = defaultVariableNames[variableType] || 'value';\n const gtTag = props['data-_gt'] as { id?: number } | undefined;\n return `${baseVariablePrefix}${baseVariableName}_${gtTag?.id}`;\n}\n"],"mappings":"AAAA,MAAM,EAAuB,CAC3B,SAAU,QACV,OAAQ,IACR,SAAU,OACV,SAAU,OACV,gBAAiB,OAClB,CAID,SAAgB,EACd,EAAiC,EAAE,CACnC,EACQ,CAIR,OAHI,OAAO,EAAM,MAAS,SAAiB,EAAM,KAG1C,OAFkB,EAAqB,IAAiB,QAEf,GADlC,EAAM,aACsC"}
@@ -0,0 +1,2 @@
1
+ const e={variable:`value`,number:`n`,datetime:`date`,currency:`cost`,"relative-time":`time`};function t(t={},n){return typeof t.name==`string`?t.name:`_gt_${e[n]||`value`}_${t[`data-_gt`]?.id}`}export{t as getVariableName};
2
+ //# sourceMappingURL=getVariableName.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVariableName.mjs","names":[],"sources":["../../../src/utils/variables/getVariableName.ts"],"sourcesContent":["const defaultVariableNames = {\n variable: 'value',\n number: 'n',\n datetime: 'date',\n currency: 'cost',\n 'relative-time': 'time',\n} as const;\n\nexport const baseVariablePrefix = '_gt_';\n\nexport function getVariableName(\n props: Record<string, unknown> = {},\n variableType: keyof typeof defaultVariableNames\n): string {\n if (typeof props.name === 'string') return props.name;\n const baseVariableName = defaultVariableNames[variableType] || 'value';\n const gtTag = props['data-_gt'] as { id?: number } | undefined;\n return `${baseVariablePrefix}${baseVariableName}_${gtTag?.id}`;\n}\n"],"mappings":"AAAA,MAAM,EAAuB,CAC3B,SAAU,QACV,OAAQ,IACR,SAAU,OACV,SAAU,OACV,gBAAiB,OAClB,CAID,SAAgB,EACd,EAAiC,EAAE,CACnC,EACQ,CAIR,OAHI,OAAO,EAAM,MAAS,SAAiB,EAAM,KAG1C,OAFkB,EAAqB,IAAiB,QAEf,GADlC,EAAM,aACsC"}