react-intlayer 9.0.0-canary.9 → 9.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 (328) hide show
  1. package/dist/cjs/IntlayerNode.cjs +1 -2
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +0 -1
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/analytics/AnalyticsProvider.cjs +16 -0
  6. package/dist/cjs/analytics/AnalyticsProvider.cjs.map +1 -0
  7. package/dist/cjs/analytics/exposureSink.cjs +27 -0
  8. package/dist/cjs/analytics/exposureSink.cjs.map +1 -0
  9. package/dist/cjs/analytics/index.cjs +10 -0
  10. package/dist/cjs/analytics/useAnalytics.cjs +54 -0
  11. package/dist/cjs/analytics/useAnalytics.cjs.map +1 -0
  12. package/dist/cjs/analytics/useConversion.cjs +32 -0
  13. package/dist/cjs/analytics/useConversion.cjs.map +1 -0
  14. package/dist/cjs/analytics/useExperiment.cjs +65 -0
  15. package/dist/cjs/analytics/useExperiment.cjs.map +1 -0
  16. package/dist/cjs/client/IntlayerProvider.cjs +6 -2
  17. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  18. package/dist/cjs/client/format/useCompact.cjs +0 -1
  19. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  20. package/dist/cjs/client/format/useCurrency.cjs +0 -1
  21. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  22. package/dist/cjs/client/format/useDate.cjs +0 -1
  23. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  24. package/dist/cjs/client/format/useIntl.cjs +0 -1
  25. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  26. package/dist/cjs/client/format/useList.cjs +0 -1
  27. package/dist/cjs/client/format/useList.cjs.map +1 -1
  28. package/dist/cjs/client/format/useNumber.cjs +0 -1
  29. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  30. package/dist/cjs/client/format/usePercentage.cjs +0 -1
  31. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  32. package/dist/cjs/client/format/useRelativeTime.cjs +0 -1
  33. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  34. package/dist/cjs/client/format/useUnit.cjs +0 -1
  35. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  36. package/dist/cjs/client/t.cjs +0 -1
  37. package/dist/cjs/client/t.cjs.map +1 -1
  38. package/dist/cjs/client/useDictionary.cjs +0 -1
  39. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  40. package/dist/cjs/client/useDictionaryAsync.cjs +0 -1
  41. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  42. package/dist/cjs/client/useDictionaryDynamic.cjs +0 -1
  43. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  44. package/dist/cjs/client/useI18n.cjs +0 -1
  45. package/dist/cjs/client/useI18n.cjs.map +1 -1
  46. package/dist/cjs/client/useIntlayer.cjs +0 -1
  47. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  48. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  49. package/dist/cjs/client/useLocale.cjs +0 -1
  50. package/dist/cjs/client/useLocale.cjs.map +1 -1
  51. package/dist/cjs/client/useLocaleBase.cjs +0 -1
  52. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  53. package/dist/cjs/client/useLocaleStorage.cjs +0 -1
  54. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  55. package/dist/cjs/client/usePathname.cjs +0 -1
  56. package/dist/cjs/client/usePathname.cjs.map +1 -1
  57. package/dist/cjs/client/useRewriteURL.cjs +0 -1
  58. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  59. package/dist/cjs/client/useTraduction.cjs +0 -1
  60. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  61. package/dist/cjs/editor/ContentSelector.cjs +0 -1
  62. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  63. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  64. package/dist/cjs/editor/useEditor.cjs +0 -1
  65. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  66. package/dist/cjs/getDictionary.cjs +0 -1
  67. package/dist/cjs/getDictionary.cjs.map +1 -1
  68. package/dist/cjs/getIntlayer.cjs +0 -1
  69. package/dist/cjs/getIntlayer.cjs.map +1 -1
  70. package/dist/cjs/html/HTMLProvider.cjs +0 -1
  71. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  72. package/dist/cjs/html/HTMLRenderer.cjs +0 -1
  73. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  74. package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
  75. package/dist/cjs/index.cjs +8 -0
  76. package/dist/cjs/index.cjs.map +1 -1
  77. package/dist/cjs/markdown/MarkdownProvider.cjs +0 -1
  78. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  79. package/dist/cjs/markdown/MarkdownRenderer.cjs +0 -1
  80. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  81. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  82. package/dist/cjs/markdown/processor.cjs +0 -1
  83. package/dist/cjs/markdown/processor.cjs.map +1 -1
  84. package/dist/cjs/markdown/runtime.cjs +0 -1
  85. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  86. package/dist/cjs/plugins.cjs +33 -15
  87. package/dist/cjs/plugins.cjs.map +1 -1
  88. package/dist/cjs/reactElement/renderReactElement.cjs +0 -1
  89. package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
  90. package/dist/cjs/server/IntlayerServerProvider.cjs +0 -1
  91. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  92. package/dist/cjs/server/format/useCompact.cjs +0 -1
  93. package/dist/cjs/server/format/useCompact.cjs.map +1 -1
  94. package/dist/cjs/server/format/useCurrency.cjs +0 -1
  95. package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
  96. package/dist/cjs/server/format/useDate.cjs +0 -1
  97. package/dist/cjs/server/format/useDate.cjs.map +1 -1
  98. package/dist/cjs/server/format/useIntl.cjs +0 -1
  99. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  100. package/dist/cjs/server/format/useList.cjs +0 -1
  101. package/dist/cjs/server/format/useList.cjs.map +1 -1
  102. package/dist/cjs/server/format/useNumber.cjs +0 -1
  103. package/dist/cjs/server/format/useNumber.cjs.map +1 -1
  104. package/dist/cjs/server/format/usePercentage.cjs +0 -1
  105. package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
  106. package/dist/cjs/server/format/useRelativeTime.cjs +0 -1
  107. package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
  108. package/dist/cjs/server/format/useUnit.cjs +0 -1
  109. package/dist/cjs/server/format/useUnit.cjs.map +1 -1
  110. package/dist/cjs/server/serverContext.cjs.map +1 -1
  111. package/dist/cjs/server/t.cjs +0 -1
  112. package/dist/cjs/server/t.cjs.map +1 -1
  113. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  114. package/dist/cjs/server/useDictionaryAsync.cjs +0 -1
  115. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  116. package/dist/cjs/server/useDictionaryDynamic.cjs +0 -1
  117. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  118. package/dist/cjs/server/useI18n.cjs.map +1 -1
  119. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  120. package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
  121. package/dist/cjs/server/useLocale.cjs +0 -1
  122. package/dist/cjs/server/useLocale.cjs.map +1 -1
  123. package/dist/esm/IntlayerNode.mjs +1 -1
  124. package/dist/esm/IntlayerNode.mjs.map +1 -1
  125. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  126. package/dist/esm/analytics/AnalyticsProvider.mjs +15 -0
  127. package/dist/esm/analytics/AnalyticsProvider.mjs.map +1 -0
  128. package/dist/esm/analytics/exposureSink.mjs +24 -0
  129. package/dist/esm/analytics/exposureSink.mjs.map +1 -0
  130. package/dist/esm/analytics/index.mjs +6 -0
  131. package/dist/esm/analytics/useAnalytics.mjs +53 -0
  132. package/dist/esm/analytics/useAnalytics.mjs.map +1 -0
  133. package/dist/esm/analytics/useConversion.mjs +31 -0
  134. package/dist/esm/analytics/useConversion.mjs.map +1 -0
  135. package/dist/esm/analytics/useExperiment.mjs +64 -0
  136. package/dist/esm/analytics/useExperiment.mjs.map +1 -0
  137. package/dist/esm/client/IntlayerProvider.mjs +6 -1
  138. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  139. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  140. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  141. package/dist/esm/client/format/useDate.mjs.map +1 -1
  142. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  143. package/dist/esm/client/format/useList.mjs.map +1 -1
  144. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  145. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  146. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  147. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  148. package/dist/esm/client/t.mjs.map +1 -1
  149. package/dist/esm/client/useDictionary.mjs.map +1 -1
  150. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  151. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  152. package/dist/esm/client/useI18n.mjs.map +1 -1
  153. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  154. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  155. package/dist/esm/client/useLocale.mjs.map +1 -1
  156. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  157. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  158. package/dist/esm/client/usePathname.mjs.map +1 -1
  159. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  160. package/dist/esm/client/useTraduction.mjs.map +1 -1
  161. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  162. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  163. package/dist/esm/editor/useEditor.mjs.map +1 -1
  164. package/dist/esm/getDictionary.mjs.map +1 -1
  165. package/dist/esm/getIntlayer.mjs.map +1 -1
  166. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  167. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  168. package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
  169. package/dist/esm/index.mjs +5 -1
  170. package/dist/esm/index.mjs.map +1 -1
  171. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  172. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  173. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  174. package/dist/esm/markdown/processor.mjs.map +1 -1
  175. package/dist/esm/markdown/runtime.mjs.map +1 -1
  176. package/dist/esm/plugins.mjs +34 -16
  177. package/dist/esm/plugins.mjs.map +1 -1
  178. package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
  179. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  180. package/dist/esm/server/format/useCompact.mjs.map +1 -1
  181. package/dist/esm/server/format/useCurrency.mjs.map +1 -1
  182. package/dist/esm/server/format/useDate.mjs.map +1 -1
  183. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  184. package/dist/esm/server/format/useList.mjs.map +1 -1
  185. package/dist/esm/server/format/useNumber.mjs.map +1 -1
  186. package/dist/esm/server/format/usePercentage.mjs.map +1 -1
  187. package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
  188. package/dist/esm/server/format/useUnit.mjs.map +1 -1
  189. package/dist/esm/server/serverContext.mjs.map +1 -1
  190. package/dist/esm/server/t.mjs.map +1 -1
  191. package/dist/esm/server/useDictionary.mjs.map +1 -1
  192. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  193. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  194. package/dist/esm/server/useI18n.mjs.map +1 -1
  195. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  196. package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
  197. package/dist/esm/server/useLocale.mjs.map +1 -1
  198. package/dist/types/IntlayerNode.d.ts +1 -6
  199. package/dist/types/IntlayerNode.d.ts.map +1 -1
  200. package/dist/types/UI/ContentSelector.d.ts +0 -1
  201. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  202. package/dist/types/analytics/AnalyticsProvider.d.ts +10 -0
  203. package/dist/types/analytics/AnalyticsProvider.d.ts.map +1 -0
  204. package/dist/types/analytics/exposureSink.d.ts +32 -0
  205. package/dist/types/analytics/exposureSink.d.ts.map +1 -0
  206. package/dist/types/analytics/index.d.ts +5 -0
  207. package/dist/types/analytics/useAnalytics.d.ts +15 -0
  208. package/dist/types/analytics/useAnalytics.d.ts.map +1 -0
  209. package/dist/types/analytics/useConversion.d.ts +31 -0
  210. package/dist/types/analytics/useConversion.d.ts.map +1 -0
  211. package/dist/types/analytics/useExperiment.d.ts +41 -0
  212. package/dist/types/analytics/useExperiment.d.ts.map +1 -0
  213. package/dist/types/client/IntlayerProvider.d.ts +1 -3
  214. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  215. package/dist/types/client/format/useCompact.d.ts +1 -3
  216. package/dist/types/client/format/useCompact.d.ts.map +1 -1
  217. package/dist/types/client/format/useCurrency.d.ts +1 -3
  218. package/dist/types/client/format/useCurrency.d.ts.map +1 -1
  219. package/dist/types/client/format/useDate.d.ts +0 -1
  220. package/dist/types/client/format/useDate.d.ts.map +1 -1
  221. package/dist/types/client/format/useIntl.d.ts +0 -1
  222. package/dist/types/client/format/useIntl.d.ts.map +1 -1
  223. package/dist/types/client/format/useList.d.ts +4 -6
  224. package/dist/types/client/format/useList.d.ts.map +1 -1
  225. package/dist/types/client/format/useNumber.d.ts +1 -3
  226. package/dist/types/client/format/useNumber.d.ts.map +1 -1
  227. package/dist/types/client/format/usePercentage.d.ts +1 -3
  228. package/dist/types/client/format/usePercentage.d.ts.map +1 -1
  229. package/dist/types/client/format/useRelativeTime.d.ts +1 -3
  230. package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
  231. package/dist/types/client/format/useUnit.d.ts +1 -3
  232. package/dist/types/client/format/useUnit.d.ts.map +1 -1
  233. package/dist/types/client/t.d.ts +0 -1
  234. package/dist/types/client/t.d.ts.map +1 -1
  235. package/dist/types/client/useDictionary.d.ts +2 -5
  236. package/dist/types/client/useDictionary.d.ts.map +1 -1
  237. package/dist/types/client/useDictionaryAsync.d.ts +0 -1
  238. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  239. package/dist/types/client/useDictionaryDynamic.d.ts +0 -1
  240. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  241. package/dist/types/client/useI18n.d.ts +0 -1
  242. package/dist/types/client/useI18n.d.ts.map +1 -1
  243. package/dist/types/client/useIntlayer.d.ts +2 -5
  244. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  245. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  246. package/dist/types/client/useLocale.d.ts +1 -5
  247. package/dist/types/client/useLocale.d.ts.map +1 -1
  248. package/dist/types/client/useLocaleBase.d.ts +2 -4
  249. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  250. package/dist/types/client/useLocaleStorage.d.ts +5 -10
  251. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  252. package/dist/types/client/usePathname.d.ts.map +1 -1
  253. package/dist/types/client/useRewriteURL.d.ts.map +1 -1
  254. package/dist/types/client/useTraduction.d.ts +0 -1
  255. package/dist/types/client/useTraduction.d.ts.map +1 -1
  256. package/dist/types/editor/ContentSelector.d.ts +0 -1
  257. package/dist/types/editor/ContentSelector.d.ts.map +1 -1
  258. package/dist/types/editor/EditorProvider.d.ts +0 -1
  259. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  260. package/dist/types/editor/useEditor.d.ts.map +1 -1
  261. package/dist/types/getDictionary.d.ts +0 -1
  262. package/dist/types/getDictionary.d.ts.map +1 -1
  263. package/dist/types/getIntlayer.d.ts +0 -1
  264. package/dist/types/getIntlayer.d.ts.map +1 -1
  265. package/dist/types/html/HTMLComponentTypes.d.ts +8 -9
  266. package/dist/types/html/HTMLComponentTypes.d.ts.map +1 -1
  267. package/dist/types/html/HTMLProvider.d.ts +0 -1
  268. package/dist/types/html/HTMLProvider.d.ts.map +1 -1
  269. package/dist/types/html/HTMLRenderer.d.ts +2 -7
  270. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  271. package/dist/types/html/HTMLRendererPlugin.d.ts +0 -1
  272. package/dist/types/html/HTMLRendererPlugin.d.ts.map +1 -1
  273. package/dist/types/html/types.d.ts +0 -1
  274. package/dist/types/html/types.d.ts.map +1 -1
  275. package/dist/types/index.d.ts +18 -35
  276. package/dist/types/index.d.ts.map +1 -1
  277. package/dist/types/markdown/MarkdownProvider.d.ts +7 -4
  278. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  279. package/dist/types/markdown/MarkdownRenderer.d.ts +2 -17
  280. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  281. package/dist/types/markdown/MarkdownRendererPlugin.d.ts +0 -1
  282. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  283. package/dist/types/markdown/processor.d.ts +0 -1
  284. package/dist/types/markdown/processor.d.ts.map +1 -1
  285. package/dist/types/markdown/runtime.d.ts +0 -1
  286. package/dist/types/markdown/runtime.d.ts.map +1 -1
  287. package/dist/types/plugins.d.ts +1 -2
  288. package/dist/types/plugins.d.ts.map +1 -1
  289. package/dist/types/reactElement/renderReactElement.d.ts +0 -1
  290. package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
  291. package/dist/types/server/IntlayerServerProvider.d.ts +1 -3
  292. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
  293. package/dist/types/server/format/useCompact.d.ts +0 -1
  294. package/dist/types/server/format/useCompact.d.ts.map +1 -1
  295. package/dist/types/server/format/useCurrency.d.ts +0 -1
  296. package/dist/types/server/format/useCurrency.d.ts.map +1 -1
  297. package/dist/types/server/format/useDate.d.ts +0 -1
  298. package/dist/types/server/format/useDate.d.ts.map +1 -1
  299. package/dist/types/server/format/useIntl.d.ts +0 -1
  300. package/dist/types/server/format/useIntl.d.ts.map +1 -1
  301. package/dist/types/server/format/useList.d.ts +0 -1
  302. package/dist/types/server/format/useList.d.ts.map +1 -1
  303. package/dist/types/server/format/useNumber.d.ts +0 -1
  304. package/dist/types/server/format/useNumber.d.ts.map +1 -1
  305. package/dist/types/server/format/usePercentage.d.ts +0 -1
  306. package/dist/types/server/format/usePercentage.d.ts.map +1 -1
  307. package/dist/types/server/format/useRelativeTime.d.ts +0 -1
  308. package/dist/types/server/format/useRelativeTime.d.ts.map +1 -1
  309. package/dist/types/server/format/useUnit.d.ts +0 -1
  310. package/dist/types/server/format/useUnit.d.ts.map +1 -1
  311. package/dist/types/server/serverContext.d.ts +1 -5
  312. package/dist/types/server/serverContext.d.ts.map +1 -1
  313. package/dist/types/server/t.d.ts +0 -1
  314. package/dist/types/server/t.d.ts.map +1 -1
  315. package/dist/types/server/useDictionary.d.ts +2 -5
  316. package/dist/types/server/useDictionary.d.ts.map +1 -1
  317. package/dist/types/server/useDictionaryAsync.d.ts +2 -5
  318. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  319. package/dist/types/server/useDictionaryDynamic.d.ts +0 -1
  320. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  321. package/dist/types/server/useI18n.d.ts +0 -1
  322. package/dist/types/server/useI18n.d.ts.map +1 -1
  323. package/dist/types/server/useIntlayer.d.ts +2 -5
  324. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  325. package/dist/types/server/useLoadDynamic.d.ts.map +1 -1
  326. package/dist/types/server/useLocale.d.ts +0 -1
  327. package/dist/types/server/useLocale.d.ts.map +1 -1
  328. package/package.json +22 -12
@@ -1 +1 @@
1
- {"version":3,"file":"serverContext.cjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,QAAW;AAEvD,MAAa,uBAA2B,iBAAuC;AAC7E,gBAAe;CAKf,MAAM,YAFQ,cAAM,SAAuB,sBAEb,EAC5B,OAAO,QACR,EAAE;CAEH,MAAM,YAAkD,EACtD,UACA,YACI;AACJ,YAAU,CAAC,QAAQ;AACnB,SAAO;;CAGT,MAAM,gBAAgB;AACtB,eAAc,WAAW;AACzB,eAAc,YAAY,UAAU;EAClC,MAAM,QAAQ,UAAU;AACxB,SAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,aAAa;;AAE3D,eAAc,WAAW;AACzB,eAAc,gBAAgB;AAE9B,QAAO;;;;;;;;;AAUT,MAAa,oBAAwB,EACnC,UACA,oBACsB;CAEtB,MAAM,QAAQ,UAAU;AACxB,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,MAAM;;;;;;AAgBf,MAAM,sBAAyC;AAE7C,KAAI,OAAO,WAAW,YACpB,OAAM,IAAI,MAAM,sDAAsD"}
1
+ {"version":3,"file":"serverContext.cjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,OAAU;AAEtD,MAAa,uBAA2B,iBAAuC;CAC7E,cAAc;CAKd,MAAM,YAFQ,cAAM,SAAuB,cAErB,QAAQ,EAC5B,OAAO,OACT,EAAE;CAEF,MAAM,YAAkD,EACtD,UACA,YACI;EACJ,SAAS,CAAC,CAAC,QAAQ;EACnB,OAAO;CACT;CAEA,MAAM,gBAAgB;CACtB,cAAc,WAAW;CACzB,cAAc,YAAY,UAAU;EAClC,MAAM,QAAQ,SAAS;EACvB,OAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,YAAY;CAC1D;CACA,cAAc,WAAW;CACzB,cAAc,gBAAgB;CAE9B,OAAO;AACT;;;;;;;;AASA,MAAa,oBAAwB,EACnC,UACA,oBACsB;CAEtB,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,MAAM;AACf;;;;;AAeA,MAAM,sBAAyC;CAE7C,IAAI,OAAO,WAAW,aACpB,MAAM,IAAI,MAAM,qDAAqD;AAEzE"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_server_serverContext = require('./serverContext.cjs');
4
3
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
4
  let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
@@ -1 +1 @@
1
- {"version":3,"file":"t.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../src/server/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string, L extends LocalesValues = DeclaredLocales>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: L\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? (currentLocale as LocalesValues);\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,gBAAgBA,8CAAgCC,4DAAsB;AAG5E,uDAA+B,kBAFV,UAAW,cAE8B"}
1
+ {"version":3,"file":"t.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../src/server/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string, L extends LocalesValues = DeclaredLocales>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: L\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? (currentLocale as LocalesValues);\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,gBAAgBA,8CAAgCC,2DAAqB;CAG3E,sDAA+B,kBAFV,UAAW,aAE6B;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["getServerContext","IntlayerServerContext","getDictionary"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,4DAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAOC,oCAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,oCAAoB,YAFL,oBAAoB,cAEU"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["getServerContext","IntlayerServerContext","getDictionary"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAOC,oCAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAOA,oCAAoB,YAFL,oBAAoB,aAES;AACrD"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_server_serverContext = require('./serverContext.cjs');
4
3
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
4
  const require_server_useDictionary = require('./useDictionary.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","internationalization","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAIvB,QAAOC,2CAAoB,MAFD,kBAA0B,iBAAiB,EAE9B,aAAkB"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","internationalization","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,2DAAqB,KACrD,kBACAC,4CAAqB;CAIvB,OAAOC,2CAAoB,MAFD,kBAA0B,aAAa,GAAG,GAE7B,YAAiB;AAC1D"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_getDictionary = require('../getDictionary.cjs');
4
3
  const require_server_serverContext = require('./serverContext.cjs');
5
4
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,4EACF,iBAAiB,GACxD;EACE,QAAQ;EACR,UAAU;EACX;CAEP,MAAM,eACJ,kBACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAEvB,KACE,QAAQ,IAAI,iCAAiC,iFACjB,kBAAkB,CAE9C,iFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,IAAI;EAChB,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,QAAQ;EACrE,YAAY,eAAeC,oCAAc,YAAY,aAAa;EACnE,CAAC;CAGJ,MAAM,eAAe;AASrB,QAAOA,oCALYD,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBAClB,aAAa,iBAA8C,CAG9B,EAAE,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,4EACF,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACAA,8CAAgCC,2DAAqB,KACrD,kBACAC,4CAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAE7C,gFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,OAAO;EACpE,YAAY,eAAeC,oCAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAOA,oCALYD,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.cjs","names":["getIntlayer","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,WACX,WACA,WACG;CAKH,MAAM,oBAAoBA,gCAAY,WAHpC,UAAUC,8CAAgCC,4DAAsB,CAGJ;CAI9D,MAAM,KACJ,SACsE;AACtE,MAAI,CAAC,KACH,QAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAI,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAC3B,aAAU,UAAU;AACpB,OAAI,YAAY,OAEd,QAAO;;AAIX,SAAO;;AAGT,QAAO"}
1
+ {"version":3,"file":"useI18n.cjs","names":["getIntlayer","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,WACX,WACA,WACG;CAKH,MAAM,oBAAoBA,gCAAY,WAHpC,UAAUC,8CAAgCC,2DAAqB,CAGJ;CAI7D,MAAM,KACJ,SACsE;EACtE,IAAI,CAAC,MACH,OAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,GAAG;EAC5C,IAAI,UAAe;EAEnB,KAAK,MAAM,OAAO,WAAW;GAC3B,UAAU,UAAU;GACpB,IAAI,YAAY,QAEd,OAAO;EAEX;EAEA,OAAO;CACT;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,4DAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,gCAAkB,KAFH,oBAAoB,cAEC"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAOA,gCAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/server/useLoadDynamic.ts"],"sourcesContent":["import react from 'react';\n\nexport const useLoadDynamic = <T>(_key: string, promise: Promise<T>): T => {\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cachedPromise = react.cache(async () => await promise)();\n\n /** @ts-ignore remove error Property 'use' does not exist on type 'typeof React'. */\n const dictionary = react.use(cachedPromise);\n\n return dictionary;\n};\n"],"mappings":";;;;;;AAEA,MAAa,kBAAqB,MAAc,YAA2B;;CAEzE,MAAM,gBAAgB,cAAM,MAAM,YAAY,MAAM,QAAQ,EAAE;AAK9D,QAFmB,cAAM,IAAI,cAEZ"}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/server/useLoadDynamic.ts"],"sourcesContent":["import react from 'react';\n\nexport const useLoadDynamic = <T>(_key: string, promise: Promise<T>): T => {\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cachedPromise = react.cache(async () => await promise)();\n\n /** @ts-ignore remove error Property 'use' does not exist on type 'typeof React'. */\n const dictionary = react.use(cachedPromise);\n\n return dictionary;\n};\n"],"mappings":";;;;;;AAEA,MAAa,kBAAqB,MAAc,YAA2B;;CAEzE,MAAM,gBAAgB,cAAM,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;CAK7D,OAFmB,cAAM,IAAI,aAEb;AAClB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_server_serverContext = require('./serverContext.cjs');
4
3
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;AAK5B,QAAO;EAAE,QAHOC,8CAAiBC,4DAAsB,IACrD;EAEe;EAAe;EAAkB"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,CAAC;CAK3B,OAAO;EAAE,QAHOC,8CAAiBC,2DAAqB,KACpD;EAEe;EAAe;CAAiB;AACnD"}
@@ -9,7 +9,7 @@ const renderIntlayerNode = ({ children, value, additionalProps }) => {
9
9
  if (prop === Symbol.toPrimitive) return () => value ?? "";
10
10
  if (prop === "toString") return () => String(value ?? "");
11
11
  if (prop === "valueOf") return () => value;
12
- if (additionalProps && prop in additionalProps) return additionalProps[prop];
12
+ if (additionalProps && Object.hasOwn(additionalProps, prop)) return additionalProps[prop];
13
13
  if (value !== null && value !== void 0 && typeof prop === "string" && prop !== "constructor" && !(prop in target)) {
14
14
  const valObj = Object(value);
15
15
  if (prop in valObj) {
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.mjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n isValidElement,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = Record<string, never>,\n> = ResolvedEditor<T, ReactNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence\n if (additionalProps && prop in additionalProps) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting React internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n // Fallback to React Element\n return Reflect.get(target, prop, receiver);\n },\n }) as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;;AAuBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CACjD,MAAM,UAA6B,eAAe,SAAS,GACzD,WAEA,kCAAG,UAAY;AAGjB,QAAO,IAAI,MAAM,SAAyB,EACxC,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QAAS,QAAO;AAC7B,MAAI,SAAS,OAAO,YAAa,cAAa,SAAS;AACvD,MAAI,SAAS,WAAY,cAAa,OAAO,SAAS,GAAG;AACzD,MAAI,SAAS,UAAW,cAAa;AAGrC,MAAI,mBAAmB,QAAQ,gBAC7B,QAAO,gBAAgB;AAIzB,MACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,MAAM;AAE5B,OAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;AACvB,WAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,MAAM,GAAG;;;AAKjE,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC"}
1
+ {"version":3,"file":"IntlayerNode.mjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n isValidElement,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = Record<string, never>,\n> = ResolvedEditor<T, ReactNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence. Own keys only: `in` would also match\n // inherited `Object.prototype` members such as `constructor`, which are\n // never meant to be served as additional props.\n if (additionalProps && Object.hasOwn(additionalProps, prop)) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting React internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n // Fallback to React Element\n return Reflect.get(target, prop, receiver);\n },\n }) as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;;AAuBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CACjD,MAAM,UAA6B,eAAe,QAAQ,IACxD,WAEA,kCAAG,SAAW;CAGhB,OAAO,IAAI,MAAM,SAAyB,EACxC,IAAI,QAAQ,MAAM,UAAU;EAC1B,IAAI,SAAS,SAAS,OAAO;EAC7B,IAAI,SAAS,OAAO,aAAa,aAAa,SAAS;EACvD,IAAI,SAAS,YAAY,aAAa,OAAO,SAAS,EAAE;EACxD,IAAI,SAAS,WAAW,aAAa;EAKrC,IAAI,mBAAmB,OAAO,OAAO,iBAAiB,IAAI,GACxD,OAAO,gBAAgB;EAIzB,IACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,KAAK;GAE3B,IAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;IACvB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,KAAK,IAAI;GAC/D;EACF;EAGA,OAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;CAC3C,EACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;AAYA,MAAM,gCAAgC;AAWtC,MAAa,mBAA6C,EACxD,UACA,SACA,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,KAAK;CAC3C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,gBAAgB;CACzE,MAAM,gBAAgB,OAA6C,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;AAC9B,sBAAoB,KAAK;AACzB,WAAS;;CAGX,MAAM,wBAAwB;AAC5B,gBAAc,UAAU,iBAAiB;AACvC,sBAAmB;KAClB,cAAc;;CAGnB,MAAM,wBAAwB;AAC5B,MAAI,cAAc,SAAS;AACzB,gBAAa,cAAc,QAAQ;AACnC,iBAAc,UAAU;;;CAI5B,MAAM,wBAAwB;AAC5B,mBAAiB;AACjB,mBAAiB;;CAGnB,MAAM,yBAAyB;AAC7B,eAAa,KAAK;AAClB,aAAW;;CAGb,MAAM,sBAAsB;AAC1B,eAAa;AACb,eAAa,MAAM;AACnB,mBAAiB;;CAInB,MAAM,qBAAqB,aACxB,UAAsB;AACrB,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;AACpE,uBAAoB,MAAM;AAC1B,iBAAc;;IAGlB,CAAC,WAAW,CACb;AAED,iBAAgB;AAEd,WAAS,iBAAiB,aAAa,mBAAmB;AAE1D,eAAa;AAEX,YAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAoD,MAAM;AAC9D,MAAI,kBAAkB;AACpB,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;AAEzB,sBAAoB,MAAM;;AAG5B,QACE,oBAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;GACb;EACD,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;EACI"}
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;AAYA,MAAM,gCAAgC;AAWtC,MAAa,mBAA6C,EACxD,UACA,SACA,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe;CACxE,MAAM,gBAAgB,OAA6C,IAAI;CACvE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,IAAI;EACxB,QAAQ;CACV;CAEA,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,kBAAkB;EACpB,GAAG,aAAa;CAClB;CAEA,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,OAAO;GAClC,cAAc,UAAU;EAC1B;CACF;CAEA,MAAM,wBAAwB;EAC5B,gBAAgB;EAChB,gBAAgB;CAClB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,IAAI;EACjB,UAAU;CACZ;CAEA,MAAM,sBAAsB;EAC1B,YAAY;EACZ,aAAa,KAAK;EAClB,gBAAgB;CAClB;CAGA,MAAM,qBAAqB,aACxB,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;GACpE,oBAAoB,KAAK;GACzB,aAAa;EACf;CACF,GACA,CAAC,UAAU,CACb;CAEA,gBAAgB;EAEd,SAAS,iBAAiB,aAAa,kBAAkB;EAEzD,aAAa;GAEX,SAAS,oBAAoB,aAAa,kBAAkB;EAE9D;CACF,GAAG,CAAC,kBAAkB,CAAC;CAEvB,MAAM,iBAAoD,MAAM;EAC9D,IAAI,kBAAkB;GACpB,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB;CACF;CAEA,MAAM,qBAAqB;EAEzB,oBAAoB,KAAK;CAC3B;CAEA,OACE,oBAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;EACd;EACA,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;CACG;AAEV"}
@@ -0,0 +1,15 @@
1
+ import { useAnalytics } from "./useAnalytics.mjs";
2
+
3
+ //#region src/analytics/AnalyticsProvider.tsx
4
+ /**
5
+ * Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
6
+ * {@link IntlayerProvider} alongside `EditorProvider`.
7
+ */
8
+ const AnalyticsProvider = ({ children }) => {
9
+ useAnalytics();
10
+ return children;
11
+ };
12
+
13
+ //#endregion
14
+ export { AnalyticsProvider };
15
+ //# sourceMappingURL=AnalyticsProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsProvider.mjs","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { useAnalytics } from './useAnalytics';\n\n/**\n * Runs {@link useAnalytics} and renders its children unchanged. Mounted inside\n * {@link IntlayerProvider} alongside `EditorProvider`.\n */\nexport const AnalyticsProvider: FC<PropsWithChildren> = ({ children }) => {\n useAnalytics();\n\n return children;\n};\n"],"mappings":";;;;;;;AAOA,MAAa,qBAA4C,EAAE,eAAe;CACxE,aAAa;CAEb,OAAO;AACT"}
@@ -0,0 +1,24 @@
1
+ //#region src/analytics/exposureSink.ts
2
+ let sink = null;
3
+ /**
4
+ * Installs (or clears) the exposure sink. `useAnalytics` sets this once the
5
+ * analytics client has loaded, and clears it on unmount.
6
+ *
7
+ * @param next - The sink to install, or `null` to clear.
8
+ */
9
+ const setExposureSink = (next) => {
10
+ sink = next;
11
+ };
12
+ /**
13
+ * Forwards a content exposure to the installed sink. A cheap null-check when
14
+ * analytics is not running, so it is safe to call from every node resolution.
15
+ *
16
+ * @param input - The node metadata to report.
17
+ */
18
+ const reportExposure = (input) => {
19
+ sink?.(input);
20
+ };
21
+
22
+ //#endregion
23
+ export { reportExposure, setExposureSink };
24
+ //# sourceMappingURL=exposureSink.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureSink.mjs","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';\n\n/**\n * Node metadata reported for a content exposure. Kept dependency-free (types\n * only) so the interpreter hot path in `plugins.tsx` never statically imports\n * `@intlayer/analytics` — the package stays optional and tree-shakeable.\n */\nexport type ExposureInput = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: string;\n nodeType?: string;\n};\n\n/** Consumer of exposure reports, installed by `useAnalytics` after init. */\nexport type ExposureSink = (input: ExposureInput) => void;\n\nlet sink: ExposureSink | null = null;\n\n/**\n * Installs (or clears) the exposure sink. `useAnalytics` sets this once the\n * analytics client has loaded, and clears it on unmount.\n *\n * @param next - The sink to install, or `null` to clear.\n */\nexport const setExposureSink = (next: ExposureSink | null): void => {\n sink = next;\n};\n\n/**\n * Forwards a content exposure to the installed sink. A cheap null-check when\n * analytics is not running, so it is safe to call from every node resolution.\n *\n * @param input - The node metadata to report.\n */\nexport const reportExposure = (input: ExposureInput): void => {\n sink?.(input);\n};\n"],"mappings":";AAiBA,IAAI,OAA4B;;;;;;;AAQhC,MAAa,mBAAmB,SAAoC;CAClE,OAAO;AACT;;;;;;;AAQA,MAAa,kBAAkB,UAA+B;CAC5D,OAAO,KAAK;AACd"}
@@ -0,0 +1,6 @@
1
+ import { useAnalytics } from "./useAnalytics.mjs";
2
+ import { AnalyticsProvider } from "./AnalyticsProvider.mjs";
3
+ import { useConversion } from "./useConversion.mjs";
4
+ import { useExperiment } from "./useExperiment.mjs";
5
+
6
+ export { AnalyticsProvider, useAnalytics, useConversion, useExperiment };
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+
3
+ import { setExposureSink } from "./exposureSink.mjs";
4
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
5
+ import { useContext, useEffect, useRef } from "react";
6
+ import { isEnabled } from "@intlayer/analytics/isEnabled";
7
+
8
+ //#region src/analytics/useAnalytics.tsx
9
+ /**
10
+ * Initializes the Intlayer analytics client singleton when analytics is enabled
11
+ * and keeps it aware of the current locale.
12
+ *
13
+ * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
14
+ * ships as its own async chunk, off the critical rendering path. Apps that
15
+ * don't opt in (`analytics.enabled !== true`) pay nothing — the whole body is
16
+ * guarded by `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build
17
+ * time.
18
+ */
19
+ const useAnalytics = () => {
20
+ const { locale } = useContext(IntlayerClientContext) ?? {};
21
+ const clientRef = useRef(null);
22
+ useEffect(() => {
23
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
24
+ let cancelled = false;
25
+ let initialized = false;
26
+ import("@intlayer/analytics").then(({ initAnalyticsClient, buildContentExposure }) => {
27
+ if (cancelled) return;
28
+ const client = initAnalyticsClient();
29
+ initialized = true;
30
+ clientRef.current = client;
31
+ if (locale) client.setLocale(locale);
32
+ client.trackPageView({ reason: "initial" });
33
+ setExposureSink((input) => client.trackContentExposure(buildContentExposure(input)));
34
+ }).catch(() => {});
35
+ return () => {
36
+ cancelled = true;
37
+ clientRef.current = null;
38
+ setExposureSink(null);
39
+ import("@intlayer/analytics").then(({ stopAnalyticsClient }) => {
40
+ if (initialized) stopAnalyticsClient();
41
+ }).catch(() => {});
42
+ };
43
+ }, []);
44
+ useEffect(() => {
45
+ if (!locale || !clientRef.current) return;
46
+ clientRef.current.setLocale(locale);
47
+ clientRef.current.trackPageView({ reason: "locale_change" });
48
+ }, [locale]);
49
+ };
50
+
51
+ //#endregion
52
+ export { useAnalytics };
53
+ //# sourceMappingURL=useAnalytics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnalytics.mjs","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"sourcesContent":["'use client';\n\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is enabled\n * and keeps it aware of the current locale.\n *\n * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it\n * ships as its own async chunk, off the critical rendering path. Apps that\n * don't opt in (`analytics.enabled !== true`) pay nothing — the whole body is\n * guarded by `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build\n * time.\n */\nexport const useAnalytics = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const clientRef = useRef<AnalyticsClient | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n let cancelled = false;\n // Tracks whether initAnalyticsClient actually ran, so cleanup never calls\n // stopAnalyticsClient for an init that was cancelled — that would decrement\n // the shared reference count once too many and could stop a client another\n // provider still uses.\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient, buildContentExposure }) => {\n if (cancelled) return;\n\n const client = initAnalyticsClient();\n initialized = true;\n clientRef.current = client;\n\n if (locale) client.setLocale(locale);\n client.trackPageView({ reason: 'initial' });\n\n // Route node-level exposures (from the interpreter plugins) into the\n // client. Serialization happens here, off the hot render path.\n setExposureSink((input) =>\n client.trackContentExposure(buildContentExposure(input))\n );\n })\n .catch(() => {\n /* chunk failed to load — analytics stays a no-op */\n });\n\n return () => {\n cancelled = true;\n clientRef.current = null;\n setExposureSink(null);\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n };\n // Run once on mount; locale updates are handled by the effect below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!locale || !clientRef.current) return;\n\n clientRef.current.setLocale(locale);\n clientRef.current.trackPageView({ reason: 'locale_change' });\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqB;CAChC,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CACzD,MAAM,YAAY,OAA+B,IAAI;CAErD,gBAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAGF,IAAI,YAAY;EAKhB,IAAI,cAAc;EAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,qBAAqB,2BAA2B;GACvD,IAAI,WAAW;GAEf,MAAM,SAAS,oBAAoB;GACnC,cAAc;GACd,UAAU,UAAU;GAEpB,IAAI,QAAQ,OAAO,UAAU,MAAM;GACnC,OAAO,cAAc,EAAE,QAAQ,UAAU,CAAC;GAI1C,iBAAiB,UACf,OAAO,qBAAqB,qBAAqB,KAAK,CAAC,CACzD;EACF,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EAEH,aAAa;GACX,YAAY;GACZ,UAAU,UAAU;GACpB,gBAAgB,IAAI;GACpB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;IACjC,IAAI,aAAa,oBAAoB;GACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACnB;CAGF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,CAAC,UAAU,CAAC,UAAU,SAAS;EAEnC,UAAU,QAAQ,UAAU,MAAM;EAClC,UAAU,QAAQ,cAAc,EAAE,QAAQ,gBAAgB,CAAC;CAC7D,GAAG,CAAC,MAAM,CAAC;AACb"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ import { useCallback } from "react";
4
+ import { isEnabled } from "@intlayer/analytics/isEnabled";
5
+
6
+ //#region src/analytics/useConversion.tsx
7
+ /**
8
+ * Returns a stable `trackConversion` callback for content A/B testing. Safe to
9
+ * call from any component: it resolves to a no-op when analytics is disabled
10
+ * or the client has not been initialized yet.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const trackConversion = useConversion();
15
+ * <button onClick={() => trackConversion({
16
+ * experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',
17
+ * })}>Get started</button>
18
+ * ```
19
+ */
20
+ const useConversion = () => {
21
+ return useCallback((params) => {
22
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
23
+ import("@intlayer/analytics").then(({ getGlobalAnalyticsClient }) => {
24
+ getGlobalAnalyticsClient()?.trackConversion(params);
25
+ }).catch(() => {});
26
+ }, []);
27
+ };
28
+
29
+ //#endregion
30
+ export { useConversion };
31
+ //# sourceMappingURL=useConversion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversion.mjs","names":[],"sources":["../../../src/analytics/useConversion.tsx"],"sourcesContent":["'use client';\n\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useCallback } from 'react';\n\n/**\n * Parameters describing a conversion to record.\n */\nexport type ConversionParams = {\n /** The experiment this conversion is attributed to. */\n experimentKey: string;\n /** The variant the session was assigned. */\n variant: string;\n /** The goal reached (e.g. `\"signup\"`, `\"cta_click\"`). */\n goal: string;\n /** Optional numeric value (e.g. revenue). */\n value?: number;\n};\n\n/**\n * Returns a stable `trackConversion` callback for content A/B testing. Safe to\n * call from any component: it resolves to a no-op when analytics is disabled\n * or the client has not been initialized yet.\n *\n * @example\n * ```tsx\n * const trackConversion = useConversion();\n * <button onClick={() => trackConversion({\n * experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',\n * })}>Get started</button>\n * ```\n */\nexport const useConversion = () => {\n return useCallback((params: ConversionParams) => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n import('@intlayer/analytics')\n .then(({ getGlobalAnalyticsClient }) => {\n getGlobalAnalyticsClient()?.trackConversion(params);\n })\n .catch(() => {});\n }, []);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAa,sBAAsB;CACjC,OAAO,aAAa,WAA6B;EAC/C,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAGF,OAAO,sBAAsB,CAC1B,MAAM,EAAE,+BAA+B;GACtC,yBAAyB,CAAC,EAAE,gBAAgB,MAAM;EACpD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB,GAAG,CAAC,CAAC;AACP"}
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { isEnabled } from "@intlayer/analytics/isEnabled";
5
+
6
+ //#region src/analytics/useExperiment.tsx
7
+ /**
8
+ * Assigns this session to a variant of an A/B experiment and records the
9
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
10
+ * conversion rates against `useConversion` events.
11
+ *
12
+ * Assignment is deterministic per session (no server round-trip, stable across
13
+ * re-mounts). The exposure is recorded once per mount.
14
+ *
15
+ * @param experimentKey - Unique key identifying the experiment.
16
+ * @param variants - The candidate variant names; the first one is the control.
17
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
18
+ * @returns The {@link ExperimentState} for this session.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const { variant } = useExperiment('homepage-hero', ['a', 'b']);
23
+ * const content = useIntlayer(variant === 'b' ? 'hero-b' : 'hero');
24
+ * ```
25
+ */
26
+ const useExperiment = (experimentKey, variants, weights) => {
27
+ const [state, setState] = useState({
28
+ variant: variants[0] ?? "",
29
+ isAssigned: false
30
+ });
31
+ useEffect(() => {
32
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !isEnabled) return;
33
+ let cancelled = false;
34
+ let initialized = false;
35
+ import("@intlayer/analytics").then(({ initAnalyticsClient }) => {
36
+ if (cancelled) return;
37
+ const client = initAnalyticsClient();
38
+ initialized = true;
39
+ const variant = client.getVariant(experimentKey, variants, weights);
40
+ setState({
41
+ variant,
42
+ isAssigned: true
43
+ });
44
+ client.trackContentExposure({
45
+ dictionaryKey: experimentKey,
46
+ keyPath: "",
47
+ nodeType: "experiment",
48
+ experimentKey,
49
+ variant
50
+ });
51
+ }).catch(() => {});
52
+ return () => {
53
+ cancelled = true;
54
+ import("@intlayer/analytics").then(({ stopAnalyticsClient }) => {
55
+ if (initialized) stopAnalyticsClient();
56
+ }).catch(() => {});
57
+ };
58
+ }, [experimentKey]);
59
+ return state;
60
+ };
61
+
62
+ //#endregion
63
+ export { useExperiment };
64
+ //# sourceMappingURL=useExperiment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExperiment.mjs","names":[],"sources":["../../../src/analytics/useExperiment.tsx"],"sourcesContent":["'use client';\n\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useEffect, useState } from 'react';\n\n/**\n * The state of an A/B experiment for the current session.\n */\nexport type ExperimentState = {\n /**\n * The variant assigned to this session. Until assignment resolves (and on\n * the server, or when analytics is disabled), this is the first variant —\n * treat the first variant as the control.\n */\n variant: string;\n /**\n * `true` once the variant has been deterministically assigned and its\n * exposure recorded. Useful to defer rendering when a flash of the control\n * variant is not acceptable.\n */\n isAssigned: boolean;\n};\n\n/**\n * Assigns this session to a variant of an A/B experiment and records the\n * exposure, scoped to `experimentKey`, so the backend can compute per-variant\n * conversion rates against `useConversion` events.\n *\n * Assignment is deterministic per session (no server round-trip, stable across\n * re-mounts). The exposure is recorded once per mount.\n *\n * @param experimentKey - Unique key identifying the experiment.\n * @param variants - The candidate variant names; the first one is the control.\n * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).\n * @returns The {@link ExperimentState} for this session.\n *\n * @example\n * ```tsx\n * const { variant } = useExperiment('homepage-hero', ['a', 'b']);\n * const content = useIntlayer(variant === 'b' ? 'hero-b' : 'hero');\n * ```\n */\nexport const useExperiment = (\n experimentKey: string,\n variants: string[],\n weights?: number[]\n): ExperimentState => {\n const [state, setState] = useState<ExperimentState>({\n variant: variants[0] ?? '',\n isAssigned: false,\n });\n\n useEffect(() => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n let cancelled = false;\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient }) => {\n if (cancelled) return;\n\n // Ref-counted: guarantees a live client even when this hook's import\n // resolves before the provider's. Balanced by stop in the cleanup.\n const client = initAnalyticsClient();\n initialized = true;\n\n const variant = client.getVariant(experimentKey, variants, weights);\n setState({ variant, isAssigned: true });\n\n // Experiment-level exposure — the denominator of the conversion rate.\n client.trackContentExposure({\n dictionaryKey: experimentKey,\n keyPath: '',\n nodeType: 'experiment',\n experimentKey,\n variant,\n });\n })\n .catch(() => {\n /* chunk failed to load — control variant stays in place */\n });\n\n return () => {\n cancelled = true;\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n };\n // Assignment is deterministic; re-running on variant-array identity churn\n // would double-record exposures.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [experimentKey]);\n\n return state;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,iBACX,eACA,UACA,YACoB;CACpB,MAAM,CAAC,OAAO,YAAY,SAA0B;EAClD,SAAS,SAAS,MAAM;EACxB,YAAY;CACd,CAAC;CAED,gBAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAGF,IAAI,YAAY;EAChB,IAAI,cAAc;EAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;GACjC,IAAI,WAAW;GAIf,MAAM,SAAS,oBAAoB;GACnC,cAAc;GAEd,MAAM,UAAU,OAAO,WAAW,eAAe,UAAU,OAAO;GAClE,SAAS;IAAE;IAAS,YAAY;GAAK,CAAC;GAGtC,OAAO,qBAAqB;IAC1B,eAAe;IACf,SAAS;IACT,UAAU;IACV;IACA;GACF,CAAC;EACH,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EAEH,aAAa;GACX,YAAY;GACZ,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;IACjC,IAAI,aAAa,oBAAoB;GACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACnB;CAIF,GAAG,CAAC,aAAa,CAAC;CAElB,OAAO;AACT"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { EditorProvider } from "../editor/EditorProvider.mjs";
4
4
  import { localeInStorage, setLocaleInStorage } from "./useLocaleStorage.mjs";
5
+ import { AnalyticsProvider } from "../analytics/AnalyticsProvider.mjs";
5
6
  import { internationalization } from "@intlayer/config/built";
6
7
  import { createContext, useContext, useEffect, useState } from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -82,7 +83,11 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
82
83
  */
83
84
  const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ jsxs(IntlayerProviderContent, {
84
85
  ...props,
85
- children: [/* @__PURE__ */ jsx(EditorProvider, {}), children]
86
+ children: [
87
+ /* @__PURE__ */ jsx(EditorProvider, {}),
88
+ /* @__PURE__ */ jsx(AnalyticsProvider, {}),
89
+ children
90
+ ]
86
91
  });
87
92
 
88
93
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,2BAA2B,WAAW,sBAAsB,IAAI,EAAE;;;;;;;;;AAoC/E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,oBAGhB;AAGxC,iBAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;AAEhB,iBAAgB;AACd,yBAAuB;IACtB,EAAE,CAAC;CAEN,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qBAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,cAAc;AAEpD,QACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,EAAkB,GACjB,SACuB"}
1
+ {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { AnalyticsProvider } from '../analytics/AnalyticsProvider';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n <AnalyticsProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,2BAA2B,WAAW,qBAAqB,KAAK,CAAC;;;;;;;;;AAoC9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,mBAGjB;CAGvC,gBAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG,CAAC,UAAU,CAAC;CAEf,gBAAgB;EACd,sBAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mBAAmB,WAAW,eAAe;CAC/C;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,aAAa;CAEnD,OACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B;EACE,oBAAC,gBAAD,CAAiB;EACjB,oBAAC,mBAAD,CAAoB;EACnB;CACsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;AAE1D,QAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;AAE1D,QAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;AAE1D,SAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAa;GAAQ,GACvC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU;GAAQ;AAEvD,SAAO,KAAK,KAAK,IAAI,QAAsC"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAa;EAAO,IACtC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,gBAAgB,UAAU;AAEhC,QAAO,cAA2B,SAAS,cAAc,EAAE,CAAC,cAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CACxE,MAAM,gBAAgB,UAAU;CAEhC,OAAO,cAA2B,SAAS,aAAa,GAAG,CAAC,aAAa,CAAC;AAC5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;AAE1D,QAAO,aACJ,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;AAE1D,QAAO,aACJ,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}