preact-intlayer 8.4.0 → 8.4.2

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 (217) hide show
  1. package/dist/cjs/IntlayerNode.cjs +1 -1
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/IntlayerProvider-sM1gzsx7.cjs +2 -0
  4. package/dist/cjs/IntlayerProvider-sM1gzsx7.cjs.map +1 -0
  5. package/dist/cjs/UI/ContentSelector.cjs +1 -1
  6. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  7. package/dist/cjs/client/IntlayerProvider.cjs +1 -2
  8. package/dist/cjs/client/format/useCompact.cjs +1 -1
  9. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  10. package/dist/cjs/client/format/useCurrency.cjs +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  12. package/dist/cjs/client/format/useDate.cjs +1 -1
  13. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  14. package/dist/cjs/client/format/useIntl.cjs +1 -1
  15. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  16. package/dist/cjs/client/format/useList.cjs +1 -1
  17. package/dist/cjs/client/format/useList.cjs.map +1 -1
  18. package/dist/cjs/client/format/useNumber.cjs +1 -1
  19. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  20. package/dist/cjs/client/format/usePercentage.cjs +1 -1
  21. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  22. package/dist/cjs/client/format/useRelativeTime.cjs +1 -1
  23. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  24. package/dist/cjs/client/format/useUnit.cjs +1 -1
  25. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  26. package/dist/cjs/client/index.cjs +1 -1
  27. package/dist/cjs/client/t.cjs +1 -1
  28. package/dist/cjs/client/t.cjs.map +1 -1
  29. package/dist/cjs/client/useDictionary.cjs +1 -1
  30. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  31. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  33. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  35. package/dist/cjs/client/useIntlayer.cjs +1 -1
  36. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  37. package/dist/cjs/client/useLocale.cjs +1 -1
  38. package/dist/cjs/client/useLocale.cjs.map +1 -1
  39. package/dist/cjs/client/useLocaleBase.cjs +1 -1
  40. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  41. package/dist/cjs/client/useLocaleStorage.cjs +1 -1
  42. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  43. package/dist/cjs/client/useTraduction.cjs +1 -1
  44. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  45. package/dist/cjs/editor/ContentSelector.cjs +1 -1
  46. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  47. package/dist/cjs/editor/EditorProvider.cjs +1 -2
  48. package/dist/cjs/editor/useEditor.cjs +1 -2
  49. package/dist/cjs/getDictionary.cjs +1 -1
  50. package/dist/cjs/getDictionary.cjs.map +1 -1
  51. package/dist/cjs/getIntlayer.cjs +1 -1
  52. package/dist/cjs/getIntlayer.cjs.map +1 -1
  53. package/dist/cjs/html/HTMLProvider.cjs +1 -1
  54. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  55. package/dist/cjs/html/HTMLRenderer.cjs +1 -1
  56. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  57. package/dist/cjs/index.cjs +1 -1
  58. package/dist/cjs/markdown/MarkdownProvider.cjs +1 -1
  59. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  60. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
  61. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  62. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -1
  63. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  64. package/dist/cjs/markdown/compiler.cjs +1 -1
  65. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  66. package/dist/cjs/markdown/index.cjs +1 -1
  67. package/dist/cjs/markdown/runtime.cjs +1 -1
  68. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  69. package/dist/cjs/plugins.cjs +1 -1
  70. package/dist/cjs/plugins.cjs.map +1 -1
  71. package/dist/cjs/preactElement/renderPreactElement.cjs +1 -1
  72. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  73. package/dist/esm/IntlayerProvider-ClOcEK3A.mjs +2 -0
  74. package/dist/esm/IntlayerProvider-ClOcEK3A.mjs.map +1 -0
  75. package/dist/esm/client/IntlayerProvider.mjs +1 -2
  76. package/dist/esm/client/format/useCompact.mjs +1 -1
  77. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  78. package/dist/esm/client/format/useCurrency.mjs +1 -1
  79. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  80. package/dist/esm/client/format/useDate.mjs +1 -1
  81. package/dist/esm/client/format/useDate.mjs.map +1 -1
  82. package/dist/esm/client/format/useIntl.mjs +1 -1
  83. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  84. package/dist/esm/client/format/useList.mjs +1 -1
  85. package/dist/esm/client/format/useList.mjs.map +1 -1
  86. package/dist/esm/client/format/useNumber.mjs +1 -1
  87. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  88. package/dist/esm/client/format/usePercentage.mjs +1 -1
  89. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  90. package/dist/esm/client/format/useRelativeTime.mjs +1 -1
  91. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  92. package/dist/esm/client/format/useUnit.mjs +1 -1
  93. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  94. package/dist/esm/client/index.mjs +1 -1
  95. package/dist/esm/client/t.mjs +1 -1
  96. package/dist/esm/client/t.mjs.map +1 -1
  97. package/dist/esm/client/useDictionary.mjs +1 -1
  98. package/dist/esm/client/useDictionary.mjs.map +1 -1
  99. package/dist/esm/client/useDictionaryAsync.mjs +1 -1
  100. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  101. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  102. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  103. package/dist/esm/client/useIntlayer.mjs +1 -1
  104. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  105. package/dist/esm/client/useLocale.mjs +1 -1
  106. package/dist/esm/client/useLocale.mjs.map +1 -1
  107. package/dist/esm/client/useLocaleBase.mjs +1 -1
  108. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  109. package/dist/esm/client/useTraduction.mjs +1 -1
  110. package/dist/esm/client/useTraduction.mjs.map +1 -1
  111. package/dist/esm/editor/ContentSelector.mjs +1 -1
  112. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  113. package/dist/esm/editor/EditorProvider.mjs +1 -2
  114. package/dist/esm/editor/useEditor.mjs +1 -2
  115. package/dist/esm/index.mjs +1 -1
  116. package/dist/esm/plugins.mjs +1 -1
  117. package/dist/esm/plugins.mjs.map +1 -1
  118. package/dist/types/HTMLProvider-8sO8DU8H.d.ts +18 -0
  119. package/dist/types/HTMLProvider-8sO8DU8H.d.ts.map +1 -0
  120. package/dist/types/HTMLRenderer-NNa_9oMD.d.ts +61 -0
  121. package/dist/types/HTMLRenderer-NNa_9oMD.d.ts.map +1 -0
  122. package/dist/types/IntlayerNode-CIzFHYnC.d.ts +23 -0
  123. package/dist/types/IntlayerNode-CIzFHYnC.d.ts.map +1 -0
  124. package/dist/types/IntlayerNode.d.ts +2 -23
  125. package/dist/types/IntlayerProvider-aV596OL4.d.ts +53 -0
  126. package/dist/types/IntlayerProvider-aV596OL4.d.ts.map +1 -0
  127. package/dist/types/MarkdownProvider-chUIO05u.d.ts +52 -0
  128. package/dist/types/MarkdownProvider-chUIO05u.d.ts.map +1 -0
  129. package/dist/types/MarkdownRenderer-BMhuurZW.d.ts +61 -0
  130. package/dist/types/MarkdownRenderer-BMhuurZW.d.ts.map +1 -0
  131. package/dist/types/MarkdownRendererPlugin-DFRVdHCA.d.ts +23 -0
  132. package/dist/types/MarkdownRendererPlugin-DFRVdHCA.d.ts.map +1 -0
  133. package/dist/types/client/IntlayerProvider.d.ts +2 -53
  134. package/dist/types/client/format/useIntl.d.ts +2 -82
  135. package/dist/types/client/format/useList.d.ts +5 -1
  136. package/dist/types/client/format/useList.d.ts.map +1 -1
  137. package/dist/types/client/index.d.ts +11 -11
  138. package/dist/types/client/t.d.ts +2 -13
  139. package/dist/types/client/useDictionary.d.ts +2 -16
  140. package/dist/types/client/useDictionaryAsync.d.ts +2 -13
  141. package/dist/types/client/useDictionaryDynamic.d.ts +2 -16
  142. package/dist/types/client/useIntlayer.d.ts +2 -28
  143. package/dist/types/client/useLoadDynamic.d.ts +2 -5
  144. package/dist/types/client/useLocale.d.ts +2 -43
  145. package/dist/types/client/useLocaleBase.d.ts +2 -16
  146. package/dist/types/client/useLocaleStorage.d.ts +2 -45
  147. package/dist/types/compiler-BB0gAVbe.d.ts +14 -0
  148. package/dist/types/compiler-BB0gAVbe.d.ts.map +1 -0
  149. package/dist/types/getDictionary.d.ts +1 -1
  150. package/dist/types/getIntlayer.d.ts +1 -1
  151. package/dist/types/html/HTMLProvider.d.ts +2 -18
  152. package/dist/types/html/HTMLRenderer.d.ts +2 -61
  153. package/dist/types/html/index.d.ts +2 -2
  154. package/dist/types/html/types.d.ts +2 -38
  155. package/dist/types/index.d.ts +19 -19
  156. package/dist/types/markdown/MarkdownProvider.d.ts +2 -52
  157. package/dist/types/markdown/MarkdownRenderer.d.ts +2 -61
  158. package/dist/types/markdown/MarkdownRendererPlugin.d.ts +2 -23
  159. package/dist/types/markdown/compiler.d.ts +2 -14
  160. package/dist/types/markdown/index.d.ts +5 -5
  161. package/dist/types/markdown/runtime.d.ts +2 -10
  162. package/dist/types/plugins-D6OB94dO.d.ts +95 -0
  163. package/dist/types/plugins-D6OB94dO.d.ts.map +1 -0
  164. package/dist/types/plugins.d.ts +2 -95
  165. package/dist/types/runtime-BMHAtT-R.d.ts +10 -0
  166. package/dist/types/runtime-BMHAtT-R.d.ts.map +1 -0
  167. package/dist/types/t-CalXqnSB.d.ts +13 -0
  168. package/dist/types/t-CalXqnSB.d.ts.map +1 -0
  169. package/dist/types/types-B3Kzdco6.d.ts +38 -0
  170. package/dist/types/types-B3Kzdco6.d.ts.map +1 -0
  171. package/dist/types/useDictionary-cjQAc1l1.d.ts +16 -0
  172. package/dist/types/useDictionary-cjQAc1l1.d.ts.map +1 -0
  173. package/dist/types/useDictionaryAsync-CDCcBnXn.d.ts +13 -0
  174. package/dist/types/useDictionaryAsync-CDCcBnXn.d.ts.map +1 -0
  175. package/dist/types/useDictionaryDynamic-BQgaM0vp.d.ts +16 -0
  176. package/dist/types/useDictionaryDynamic-BQgaM0vp.d.ts.map +1 -0
  177. package/dist/types/useIntl-DfzrSGu4.d.ts +26 -0
  178. package/dist/types/useIntl-DfzrSGu4.d.ts.map +1 -0
  179. package/dist/types/useIntlayer-BINmW9T1.d.ts +28 -0
  180. package/dist/types/useIntlayer-BINmW9T1.d.ts.map +1 -0
  181. package/dist/types/useLoadDynamic-DFXHehpF.d.ts +5 -0
  182. package/dist/types/useLoadDynamic-DFXHehpF.d.ts.map +1 -0
  183. package/dist/types/useLocale-BDQ4yLc5.d.ts +43 -0
  184. package/dist/types/useLocale-BDQ4yLc5.d.ts.map +1 -0
  185. package/dist/types/useLocaleBase-1L1RLyXD.d.ts +16 -0
  186. package/dist/types/useLocaleBase-1L1RLyXD.d.ts.map +1 -0
  187. package/dist/types/useLocaleStorage-BwH9gqN5.d.ts +45 -0
  188. package/dist/types/useLocaleStorage-BwH9gqN5.d.ts.map +1 -0
  189. package/package.json +7 -7
  190. package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -1
  191. package/dist/cjs/client/IntlayerProvider.cjs.map +0 -1
  192. package/dist/cjs/editor/EditorProvider.cjs.map +0 -1
  193. package/dist/cjs/editor/useEditor.cjs.map +0 -1
  194. package/dist/esm/client/IntlayerProvider.mjs.map +0 -1
  195. package/dist/esm/editor/EditorProvider.mjs.map +0 -1
  196. package/dist/esm/editor/useEditor.mjs.map +0 -1
  197. package/dist/types/IntlayerNode.d.ts.map +0 -1
  198. package/dist/types/client/IntlayerProvider.d.ts.map +0 -1
  199. package/dist/types/client/format/useIntl.d.ts.map +0 -1
  200. package/dist/types/client/t.d.ts.map +0 -1
  201. package/dist/types/client/useDictionary.d.ts.map +0 -1
  202. package/dist/types/client/useDictionaryAsync.d.ts.map +0 -1
  203. package/dist/types/client/useDictionaryDynamic.d.ts.map +0 -1
  204. package/dist/types/client/useIntlayer.d.ts.map +0 -1
  205. package/dist/types/client/useLoadDynamic.d.ts.map +0 -1
  206. package/dist/types/client/useLocale.d.ts.map +0 -1
  207. package/dist/types/client/useLocaleBase.d.ts.map +0 -1
  208. package/dist/types/client/useLocaleStorage.d.ts.map +0 -1
  209. package/dist/types/html/HTMLProvider.d.ts.map +0 -1
  210. package/dist/types/html/HTMLRenderer.d.ts.map +0 -1
  211. package/dist/types/html/types.d.ts.map +0 -1
  212. package/dist/types/markdown/MarkdownProvider.d.ts.map +0 -1
  213. package/dist/types/markdown/MarkdownRenderer.d.ts.map +0 -1
  214. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +0 -1
  215. package/dist/types/markdown/compiler.d.ts.map +0 -1
  216. package/dist/types/markdown/runtime.d.ts.map +0 -1
  217. package/dist/types/plugins.d.ts.map +0 -1
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./html/HTMLProvider.cjs`),t=require(`./html/HTMLRenderer.cjs`),n=require(`./markdown/runtime.cjs`),r=require(`./markdown/compiler.cjs`),i=require(`./markdown/MarkdownProvider.cjs`),a=require(`./markdown/MarkdownRenderer.cjs`),o=require(`./client/useLocaleStorage.cjs`),s=require(`./client/IntlayerProvider.cjs`),c=require(`./client/useLocale.cjs`),l=require(`./plugins.cjs`),u=require(`./getIntlayer.cjs`),d=require(`./getDictionary.cjs`),f=require(`./client/format/useIntl.cjs`),p=require(`./client/t.cjs`),m=require(`./client/useDictionary.cjs`),h=require(`./client/useDictionaryAsync.cjs`),g=require(`./client/useLoadDynamic.cjs`),_=require(`./client/useDictionaryDynamic.cjs`),v=require(`./client/useIntlayer.cjs`),y=require(`./client/useLocaleBase.cjs`);exports.HTMLProvider=e.HTMLProvider,exports.HTMLRenderer=t.HTMLRenderer,exports.IntlayerClientContext=s.IntlayerClientContext,exports.IntlayerProvider=s.IntlayerProvider,exports.IntlayerProviderContent=s.IntlayerProviderContent,exports.MarkdownProvider=i.MarkdownProvider,exports.MarkdownRenderer=a.MarkdownRenderer,exports.compileMarkdown=r.compileMarkdown,exports.getDictionary=d.getDictionary,exports.getIntlayer=u.getIntlayer,exports.htmlPlugin=l.htmlPlugin,exports.intlayerNodePlugins=l.intlayerNodePlugins,exports.localeCookie=o.localeCookie,exports.markdownPlugin=l.markdownPlugin,exports.markdownStringPlugin=l.markdownStringPlugin,exports.preactNodePlugins=l.preactNodePlugins,exports.preactRuntime=n,exports.renderHTML=t.renderHTML,exports.renderMarkdown=a.renderMarkdown,exports.setLocaleCookie=o.setLocaleCookie,exports.setLocaleInStorage=o.setLocaleInStorage,exports.t=p.t,exports.useDictionary=m.useDictionary,exports.useDictionaryAsync=h.useDictionaryAsync,exports.useDictionaryDynamic=_.useDictionaryDynamic,exports.useHTMLRenderer=t.useHTMLRenderer,exports.useIntl=f.useIntl,exports.useIntlayer=v.useIntlayer,exports.useIntlayerContext=s.useIntlayerContext,exports.useLoadDynamic=g.useLoadDynamic,exports.useLocale=c.useLocale,exports.useLocaleBase=y.useLocaleBase,exports.useLocaleCookie=o.useLocaleCookie,exports.useLocaleStorage=o.useLocaleStorage,exports.useMarkdownRenderer=a.useMarkdownRenderer;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./IntlayerProvider-sM1gzsx7.cjs`),t=require(`./html/HTMLProvider.cjs`),n=require(`./html/HTMLRenderer.cjs`),r=require(`./markdown/runtime.cjs`),i=require(`./markdown/compiler.cjs`),a=require(`./markdown/MarkdownProvider.cjs`),o=require(`./markdown/MarkdownRenderer.cjs`),s=require(`./client/useLocaleStorage.cjs`),c=require(`./client/useLocale.cjs`),l=require(`./plugins.cjs`),u=require(`./getIntlayer.cjs`),d=require(`./getDictionary.cjs`),f=require(`./client/format/useIntl.cjs`),p=require(`./client/t.cjs`),m=require(`./client/useDictionary.cjs`),h=require(`./client/useDictionaryAsync.cjs`),g=require(`./client/useLoadDynamic.cjs`),_=require(`./client/useDictionaryDynamic.cjs`),v=require(`./client/useIntlayer.cjs`),y=require(`./client/useLocaleBase.cjs`);require(`./client/index.cjs`),require(`./html/index.cjs`),exports.HTMLProvider=t.HTMLProvider,exports.HTMLRenderer=n.HTMLRenderer,exports.IntlayerClientContext=e.t,exports.IntlayerProvider=e.n,exports.IntlayerProviderContent=e.r,exports.MarkdownProvider=a.MarkdownProvider,exports.MarkdownRenderer=o.MarkdownRenderer,exports.compileMarkdown=i.compileMarkdown,exports.getDictionary=d.getDictionary,exports.getIntlayer=u.getIntlayer,exports.htmlPlugin=l.htmlPlugin,exports.intlayerNodePlugins=l.intlayerNodePlugins,exports.localeCookie=s.localeCookie,exports.markdownPlugin=l.markdownPlugin,exports.markdownStringPlugin=l.markdownStringPlugin,exports.preactNodePlugins=l.preactNodePlugins,exports.preactRuntime=r,exports.renderHTML=n.renderHTML,exports.renderMarkdown=o.renderMarkdown,exports.setLocaleCookie=s.setLocaleCookie,exports.setLocaleInStorage=s.setLocaleInStorage,exports.t=p.t,exports.useDictionary=m.useDictionary,exports.useDictionaryAsync=h.useDictionaryAsync,exports.useDictionaryDynamic=_.useDictionaryDynamic,exports.useHTMLRenderer=n.useHTMLRenderer,exports.useIntl=f.useIntl,exports.useIntlayer=v.useIntlayer,exports.useIntlayerContext=e.i,exports.useLoadDynamic=g.useLoadDynamic,exports.useLocale=c.useLocale,exports.useLocaleBase=y.useLocaleBase,exports.useLocaleCookie=s.useLocaleCookie,exports.useLocaleStorage=s.useLocaleStorage,exports.useMarkdownRenderer=o.useMarkdownRenderer;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./compiler.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(0,t.createContext)(void 0),a=()=>(0,n.useContext)(i),o=(e,t,n={},r={},i)=>({...t,...n,forceBlock:n.forceBlock??t.forceBlock,forceInline:n.forceInline??t.forceInline,preserveFrontmatter:n.preserveFrontmatter??t.preserveFrontmatter,tagfilter:n.tagfilter??t.tagfilter,wrapper:i||t.wrapper,forceWrapper:!!(i||t.wrapper),components:{...e,...r}}),s=({children:t,components:n,wrapper:a,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u,renderMarkdown:d})=>{let f={forceBlock:s,forceInline:c,wrapper:a,forceWrapper:!!a,preserveFrontmatter:l,tagfilter:u};return(0,r.jsx)(i.Provider,{value:{components:n,renderMarkdown:d?(e,t,n,a)=>(0,r.jsx)(i.Provider,{value:void 0,children:d?.(e,t,n,a)}):(t,r,i,a)=>e.compileMarkdown(t,o(n,f,r,i??{},a))},children:t})};exports.MarkdownProvider=s,exports.useMarkdownContext=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);const e=require(`./compiler.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(0,t.createContext)(void 0),a=()=>(0,n.useContext)(i),o=(e,t,n={},r={},i)=>({...t,...n,forceBlock:n.forceBlock??t.forceBlock,forceInline:n.forceInline??t.forceInline,preserveFrontmatter:n.preserveFrontmatter??t.preserveFrontmatter,tagfilter:n.tagfilter??t.tagfilter,wrapper:i||t.wrapper,forceWrapper:!!(i||t.wrapper),components:{...e,...r}}),s=({children:t,components:n,wrapper:a,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u,renderMarkdown:d})=>{let f={forceBlock:s,forceInline:c,wrapper:a,forceWrapper:!!a,preserveFrontmatter:l,tagfilter:u};return(0,r.jsx)(i.Provider,{value:{components:n,renderMarkdown:d?(e,t,n,a)=>(0,r.jsx)(i.Provider,{value:void 0,children:d?.(e,t,n,a)}):(t,r,i,a)=>e.compileMarkdown(t,o(n,f,r,i??{},a))},children:t})};exports.MarkdownProvider=s,exports.useMarkdownContext=a;
2
2
  //# sourceMappingURL=MarkdownProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: any;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: any\n ) => ComponentChildren;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: any;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: any\n ) => ComponentChildren;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: any\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: any\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: any\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":"oOAuEA,MAAM,GAAA,EAAA,EAAA,eACJ,IAAA,GACD,CAEY,OAAA,EAAA,EAAA,YAAsC,EAAgB,CAE7D,GACJ,EACA,EACA,EAAmC,EAAE,CACrC,EAA+C,EAAE,CACjD,KAEO,CACL,GAAG,EACH,GAAG,EACH,WAAY,EAAQ,YAAc,EAAY,WAC9C,YAAa,EAAQ,aAAe,EAAY,YAChD,oBACE,EAAQ,qBAAuB,EAAY,oBAC7C,UAAW,EAAQ,WAAa,EAAY,UAC5C,QAAS,GAAW,EAAY,QAChC,aAAc,CAAC,EAAE,GAAW,EAAY,SACxC,WAAY,CAAE,GAAG,EAAgB,GAAG,EAAY,CACjD,EAGU,GAA8D,CACzE,WACA,aACA,UACA,aACA,cACA,sBACA,YACA,eAAgB,KACZ,CACJ,IAAM,EAAyD,CAC7D,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAgCD,OACE,EAAA,EAAA,KAAC,EAAgB,SAAjB,CACE,MAAO,CACL,aACA,eAAgB,GAdpB,EACA,EACA,EACA,KAEA,EAAA,EAAA,KAAC,EAAgB,SAAjB,CAA0B,MAAO,IAAA,YAC9B,IAAiB,EAAU,EAAS,EAAoB,EAAgB,CAChD,CAAA,EAzB3B,EACA,EACA,EACA,IASOA,EAAAA,gBAAgB,EAPD,EACpB,EACA,EACA,EACA,GAAsB,EAAE,CACxB,EACD,CAC8C,CAuB5C,CAEA,WACwB,CAAA"}
1
+ {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: any;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: any\n ) => ComponentChildren;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: any;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: any\n ) => ComponentChildren;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: any\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: any\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: any\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":"mOAuEA,MAAM,GAAA,EAAA,EAAA,eACJ,IAAA,GACD,CAEY,OAAA,EAAA,EAAA,YAAsC,EAAgB,CAE7D,GACJ,EACA,EACA,EAAmC,EAAE,CACrC,EAA+C,EAAE,CACjD,KAEO,CACL,GAAG,EACH,GAAG,EACH,WAAY,EAAQ,YAAc,EAAY,WAC9C,YAAa,EAAQ,aAAe,EAAY,YAChD,oBACE,EAAQ,qBAAuB,EAAY,oBAC7C,UAAW,EAAQ,WAAa,EAAY,UAC5C,QAAS,GAAW,EAAY,QAChC,aAAc,CAAC,EAAE,GAAW,EAAY,SACxC,WAAY,CAAE,GAAG,EAAgB,GAAG,EAAY,CACjD,EAGU,GAA8D,CACzE,WACA,aACA,UACA,aACA,cACA,sBACA,YACA,eAAgB,KACZ,CACJ,IAAM,EAAyD,CAC7D,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAgCD,OACE,EAAA,EAAA,KAAC,EAAgB,SAAjB,CACE,MAAO,CACL,aACA,eAAgB,GAdpB,EACA,EACA,EACA,KAEA,EAAA,EAAA,KAAC,EAAgB,SAAjB,CAA0B,MAAO,IAAA,YAC9B,IAAiB,EAAU,EAAS,EAAoB,EAAgB,CAChD,CAAA,EAzB3B,EACA,EACA,EACA,IASOA,EAAAA,gBAAgB,EAPD,EACpB,EACA,EACA,EACA,GAAsB,EAAE,CACxB,EACD,CAC8C,CAuB5C,CAEA,WACwB,CAAA"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./compiler.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`preact/jsx-runtime`);const r=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e.compileMarkdown(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),i=({components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t.useMarkdownContext();return t=>c?c.renderMarkdown(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}):r(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s})},a=({children:e=``,components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l,renderMarkdown:u})=>{let d=t.useMarkdownContext();return u?(0,n.jsx)(n.Fragment,{children:u(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):d?(0,n.jsx)(n.Fragment,{children:d.renderMarkdown(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):r(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})};exports.MarkdownRenderer=a,exports.renderMarkdown=r,exports.useMarkdownRenderer=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);const e=require(`./compiler.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`preact/jsx-runtime`);const r=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e.compileMarkdown(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),i=({components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t.useMarkdownContext();return t=>c?c.renderMarkdown(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}):r(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s})},a=({children:e=``,components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l,renderMarkdown:u})=>{let d=t.useMarkdownContext();return u?(0,n.jsx)(n.Fragment,{children:u(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):d?(0,n.jsx)(n.Fragment,{children:d.renderMarkdown(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):r(e,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})};exports.MarkdownRenderer=a,exports.renderMarkdown=r,exports.useMarkdownRenderer=i;
2
2
  //# sourceMappingURL=MarkdownRenderer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type { ComponentChildren, FunctionComponent, JSX } from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: FunctionComponent<any>;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\ntype MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FunctionComponent<any>;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":"0NAqBA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapBA,EAAAA,gBAAgB,EAV0B,CAC/C,aACA,aACA,cACS,UACT,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE+C,CAGrC,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAUC,EAAAA,oBAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eAAe,EAAS,CACrC,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CAGG,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EAgCO,GAA8D,CACzE,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,eAAgB,KACZ,CACJ,IAAM,EAAUA,EAAAA,oBAAoB,CAgCpC,OA9BI,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAqB,EAAU,CAC9B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAQ,eAAe,EAAU,CAChC,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIA,EAAe,EAAU,CAC9B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC"}
1
+ {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type { ComponentChildren, FunctionComponent, JSX } from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: FunctionComponent<any>;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\ntype MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FunctionComponent<any>;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":"yNAqBA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapBA,EAAAA,gBAAgB,EAV0B,CAC/C,aACA,aACA,cACS,UACT,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE+C,CAGrC,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAUC,EAAAA,oBAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eAAe,EAAS,CACrC,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CAGG,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EAgCO,GAA8D,CACzE,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,eAAgB,KACZ,CACJ,IAAM,EAAUA,EAAAA,oBAAoB,CAgCpC,OA9BI,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAqB,EAAU,CAC9B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAQ,eAAe,EAAU,CAChC,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIA,EAAe,EAAU,CAC9B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./MarkdownProvider.cjs`),t=require(`../client/useLocale.cjs`);let n=require(`@intlayer/core/markdown`),r=require(`@intlayer/core/dictionaryManipulator`);const i=t=>{let{children:n,options:r,components:i}=t,a=e.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},a=({children:e,metadataKeyPath:i})=>{let{locale:a}=t.useLocale();return(0,r.getContentNodeByKeyPath)((0,n.getMarkdownMetadata)(e),i,a)};exports.MarkdownMetadataRenderer=a,exports.MarkdownRendererPlugin=i;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);const e=require(`./MarkdownProvider.cjs`),t=require(`../client/useLocale.cjs`);let n=require(`@intlayer/core/markdown`),r=require(`@intlayer/core/dictionaryManipulator`);const i=t=>{let{children:n,options:r,components:i}=t,a=e.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},a=({children:e,metadataKeyPath:i})=>{let{locale:a}=t.useLocale();return(0,r.getContentNodeByKeyPath)((0,n.getMarkdownMetadata)(e),i,a)};exports.MarkdownMetadataRenderer=a,exports.MarkdownRendererPlugin=i;
2
2
  //# sourceMappingURL=MarkdownRendererPlugin.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":"uSAwBA,MAAa,EAER,GAA6B,CAChC,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAUA,EAAAA,oBAAoB,CAGpC,OAFuB,GAAS,iBAAoB,GAAO,IAErC,EAAU,EAAS,CACvC,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOS,GAER,CAAE,WAAU,qBAAyC,CACxD,GAAM,CAAE,OAAQ,GAAkBC,EAAAA,WAAW,CAU7C,OAAA,EAAA,EAAA,0BAAA,EAAA,EAAA,qBARqC,EAAS,CAI5C,EACA,EACD"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":"sSAwBA,MAAa,EAER,GAA6B,CAChC,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAUA,EAAAA,oBAAoB,CAGpC,OAFuB,GAAS,iBAAoB,GAAO,IAErC,EAAU,EAAS,CACvC,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOS,GAER,CAAE,WAAU,qBAAyC,CACxD,GAAM,CAAE,OAAQ,GAAkBC,EAAAA,WAAW,CAU7C,OAAA,EAAA,EAAA,0BAAA,EAAA,EAAA,qBARqC,EAAS,CAI5C,EACA,EACD"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./runtime.cjs`);let t=require(`@intlayer/core/markdown`);const n=(n=``,r={})=>(0,t.compileWithOptions)(n,e.default,r),r=n,i=n;exports.RuleType=t.RuleType,exports.compile=i,exports.compileMarkdown=n,exports.compiler=r,exports.sanitizer=t.sanitizer,exports.slugify=t.slugify;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);const e=require(`./runtime.cjs`);let t=require(`@intlayer/core/markdown`);const n=(n=``,r={})=>(0,t.compileWithOptions)(n,e.default,r),r=n,i=n;exports.RuleType=t.RuleType,exports.compile=i,exports.compileMarkdown=n,exports.compiler=r,exports.sanitizer=t.sanitizer,exports.slugify=t.slugify;
2
2
  //# sourceMappingURL=compiler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.cjs","names":["preactRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { RuleType };\nexport { defaultSlugify as slugify, defaultSanitizer as sanitizer };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":"0LAuBA,MAAa,GACX,EAAmB,GACnB,EAAmC,EAAE,IAAA,EAAA,EAAA,oBACf,EAAUA,EAAAA,QAAe,EAAQ,CAG5C,EAAW,EACX,EAAU"}
1
+ {"version":3,"file":"compiler.cjs","names":["preactRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { RuleType };\nexport { defaultSlugify as slugify, defaultSanitizer as sanitizer };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":"yLAuBA,MAAa,GACX,EAAmB,GACnB,EAAmC,EAAE,IAAA,EAAA,EAAA,oBACf,EAAUA,EAAAA,QAAe,EAAQ,CAG5C,EAAW,EACX,EAAU"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./runtime.cjs`),t=require(`./compiler.cjs`),n=require(`./MarkdownProvider.cjs`),r=require(`./MarkdownRenderer.cjs`),i=require(`./MarkdownRendererPlugin.cjs`);let a=require(`@intlayer/core/markdown`);exports.MarkdownMetadataRenderer=i.MarkdownMetadataRenderer,exports.MarkdownProvider=n.MarkdownProvider,exports.MarkdownRenderer=r.MarkdownRenderer,exports.MarkdownRendererPlugin=i.MarkdownRendererPlugin,exports.RuleType=a.RuleType,exports.compile=t.compile,exports.compileMarkdown=t.compileMarkdown,exports.compiler=t.compiler,exports.preactRuntime=e,exports.renderMarkdown=r.renderMarkdown,exports.sanitizer=a.sanitizer,exports.slugify=a.slugify,exports.useMarkdownContext=n.useMarkdownContext,exports.useMarkdownRenderer=r.useMarkdownRenderer;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);const e=require(`./runtime.cjs`),t=require(`./compiler.cjs`),n=require(`./MarkdownProvider.cjs`),r=require(`./MarkdownRenderer.cjs`),i=require(`./MarkdownRendererPlugin.cjs`);let a=require(`@intlayer/core/markdown`);exports.MarkdownMetadataRenderer=i.MarkdownMetadataRenderer,exports.MarkdownProvider=n.MarkdownProvider,exports.MarkdownRenderer=r.MarkdownRenderer,exports.MarkdownRendererPlugin=i.MarkdownRendererPlugin,exports.RuleType=a.RuleType,exports.compile=t.compile,exports.compileMarkdown=t.compileMarkdown,exports.compiler=t.compiler,exports.preactRuntime=e,exports.renderMarkdown=r.renderMarkdown,exports.sanitizer=a.sanitizer,exports.slugify=a.slugify,exports.useMarkdownContext=n.useMarkdownContext,exports.useMarkdownRenderer=r.useMarkdownRenderer;
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`preact`);const t={createElement:(t,n,...r)=>(0,e.createElement)(t,n,...r),cloneElement:(t,n,...r)=>(0,e.cloneElement)(t,n,...r),Fragment:e.Fragment,normalizeProps:(e,t)=>t};exports.default=t,exports.preactRuntime=t;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../IntlayerProvider-sM1gzsx7.cjs`);let e=require(`preact`);const t={createElement:(t,n,...r)=>(0,e.createElement)(t,n,...r),cloneElement:(t,n,...r)=>(0,e.cloneElement)(t,n,...r),Fragment:e.Fragment,normalizeProps:(e,t)=>t};exports.default=t,exports.preactRuntime=t;
2
2
  //# sourceMappingURL=runtime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":"oKAgBA,MAAa,EAAiC,CAC5C,eACE,EACA,EACA,GAAG,KAAA,EAAA,EAAA,eACmB,EAAa,EAAO,GAAG,EAAS,CAExD,cACE,EACA,EACA,GAAG,KAAA,EAAA,EAAA,cACkB,EAAkB,EAAO,GAAG,EAAS,CAE5D,SAAA,EAAA,SAEA,gBACE,EACA,IACwB,EAC3B"}
1
+ {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":"mKAgBA,MAAa,EAAiC,CAC5C,eACE,EACA,EACA,GAAG,KAAA,EAAA,EAAA,eACmB,EAAa,EAAO,GAAG,EAAS,CAExD,cACE,EACA,EACA,GAAG,KAAA,EAAA,EAAA,cACkB,EAAkB,EAAO,GAAG,EAAS,CAE5D,SAAA,EAAA,SAEA,gBACE,EACA,IACwB,EAC3B"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./editor/ContentSelector.cjs`),n=require(`./html/HTMLRenderer.cjs`),r=require(`./IntlayerNode.cjs`),i=require(`./markdown/MarkdownRendererPlugin.cjs`),a=require(`./preactElement/renderPreactElement.cjs`);let o=require(`@intlayer/config/built`);o=e.__toESM(o);let s=require(`@intlayer/core/interpreter`),c=require(`@intlayer/core/markdown`),l=require(`@intlayer/types/nodeType`),u=require(`preact`),d=require(`preact/jsx-runtime`);const f={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:i.children,children:o.default?.editor.enabled?(0,u.createElement)(t.ContentSelector,{...i,key:i.children},i.children):i.children})},p={id:`preact-node-plugin`,canHandle:e=>typeof e==`object`&&e.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:`[[preact-element]]`,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:a.renderPreactElement(e)}):a.renderPreactElement(e)})},m=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,h=(e,t)=>{if(!Object.values(t).some(m))return e.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,n)=>(t[n.trim()]??``).toString());let n=[],r=0,i=/\{\{\s*(.*?)\s*\}\}/g,a=i.exec(e);for(;a!==null;){a.index>r&&n.push(e.substring(r,a.index));let o=t[a[1].trim()];o!=null&&n.push(typeof o==`number`?String(o):o),r=a.index+a[0].length,a=i.exec(e)}return r<e.length&&n.push(e.substring(r)),(0,u.h)(u.Fragment,null,...n.map((e,t)=>(0,u.h)(u.Fragment,{key:t},e)))},g={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Insertion}],i=e[l.NodeType.Insertion],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=h(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},_={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,a)=>{let{plugins:o,...s}=n,l=a((0,c.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,a)=>r.renderIntlayerNode({...a,value:n,children:(0,d.jsx)(t.ContentSelector,{...s,children:(0,d.jsx)(i.MarkdownMetadataRenderer,{...s,metadataKeyPath:a.keyPath,children:e})})})}],dictionaryKey:s.dictionaryKey,keyPath:[]}),u=a=>r.renderIntlayerNode({...n,value:e,children:(0,d.jsx)(t.ContentSelector,{...s,children:(0,d.jsx)(i.MarkdownRendererPlugin,{...s,components:a,children:e})}),additionalProps:{metadata:l}}),f=u();return new Proxy(f,{get(t,n){return n===`value`?e:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(t,n)}})}},v={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Markdown}],i=e[l.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[_,...t.plugins??[]]})}},y={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.HTML,transform:(e,t)=>{let r=e[l.NodeType.HTML];e.tags;let{plugins:i,...a}=t,o=e=>(0,u.h)(n.HTMLRenderer,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t)}})}},b=(e,t=!0)=>[(0,s.translationPlugin)(e??o.default.internationalization.defaultLocale,t?o.default.internationalization.defaultLocale:void 0),s.enumerationPlugin,s.conditionPlugin,(0,s.nestedPlugin)(e??o.default.internationalization.defaultLocale),s.filePlugin,s.genderPlugin,f,p,g,v,y];exports.getPlugins=b,exports.htmlPlugin=y,exports.insertionPlugin=g,exports.intlayerNodePlugins=f,exports.markdownPlugin=v,exports.markdownStringPlugin=_,exports.preactNodePlugins=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./IntlayerProvider-sM1gzsx7.cjs`),t=require(`./editor/ContentSelector.cjs`),n=require(`./html/HTMLRenderer.cjs`),r=require(`./IntlayerNode.cjs`),i=require(`./markdown/MarkdownRendererPlugin.cjs`),a=require(`./preactElement/renderPreactElement.cjs`);let o=require(`@intlayer/config/built`);o=e.s(o);let s=require(`@intlayer/core/interpreter`),c=require(`@intlayer/core/markdown`),l=require(`@intlayer/types/nodeType`),u=require(`preact`),d=require(`preact/jsx-runtime`);const f={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:i.children,children:o.default?.editor.enabled?(0,u.createElement)(t.ContentSelector,{...i,key:i.children},i.children):i.children})},p={id:`preact-node-plugin`,canHandle:e=>typeof e==`object`&&e.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:`[[preact-element]]`,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:a.renderPreactElement(e)}):a.renderPreactElement(e)})},m=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,h=(e,t)=>{if(!Object.values(t).some(m))return e.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,n)=>(t[n.trim()]??``).toString());let n=[],r=0,i=/\{\{\s*(.*?)\s*\}\}/g,a=i.exec(e);for(;a!==null;){a.index>r&&n.push(e.substring(r,a.index));let o=t[a[1].trim()];o!=null&&n.push(typeof o==`number`?String(o):o),r=a.index+a[0].length,a=i.exec(e)}return r<e.length&&n.push(e.substring(r)),(0,u.h)(u.Fragment,null,...n.map((e,t)=>(0,u.h)(u.Fragment,{key:t},e)))},g={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Insertion}],i=e[l.NodeType.Insertion],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=h(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},_={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,a)=>{let{plugins:s,...l}=n,u=a((0,c.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,a)=>r.renderIntlayerNode({...a,value:n,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:(0,d.jsx)(i.MarkdownMetadataRenderer,{...l,metadataKeyPath:a.keyPath,children:e})}):(0,d.jsx)(i.MarkdownMetadataRenderer,{...l,metadataKeyPath:a.keyPath,children:e})})}],dictionaryKey:l.dictionaryKey,keyPath:[]}),f=a=>r.renderIntlayerNode({...n,value:e,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e})}):(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e}),additionalProps:{metadata:u}}),p=f();return new Proxy(p,{get(t,n){return n===`value`?e:n===`metadata`?u:n===`use`?e=>f(e):Reflect.get(t,n)}})}},v={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Markdown}],i=e[l.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[_,...t.plugins??[]]})}},y={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.HTML,transform:(e,t)=>{let r=e[l.NodeType.HTML];e.tags;let{plugins:i,...a}=t,o=e=>(0,u.h)(n.HTMLRenderer,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t)}})}},b=(e,t=!0)=>[(0,s.translationPlugin)(e??o.default.internationalization.defaultLocale,t?o.default.internationalization.defaultLocale:void 0),s.enumerationPlugin,s.conditionPlugin,(0,s.nestedPlugin)(e??o.default.internationalization.defaultLocale),s.filePlugin,s.genderPlugin,f,p,g,v,y];exports.getPlugins=b,exports.htmlPlugin=y,exports.insertionPlugin=g,exports.intlayerNodePlugins=f,exports.markdownPlugin=v,exports.markdownStringPlugin=_,exports.preactNodePlugins=p;
2
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderPreactElement","Fragment","NodeType","MarkdownMetadataRenderer","MarkdownRendererPlugin","HTMLRenderer","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRenderer } from './html/HTMLRenderer';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderPreactElement(node)}</ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelector {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelector>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n h(HTMLRenderer as any, { ...rest, html, userComponents } as any);\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"gjBAyCA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WACE,EACA,CACE,UACA,GAAG,KAGLA,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,EAAK,SACZ,SAAUC,EAAAA,SAAe,OAAO,SAC9B,EAAA,EAAA,eAACC,EAAAA,gBAAD,CAAiB,GAAI,EAAM,IAAK,EAAK,SAEnB,CADf,EAAK,SACU,CAElB,EAAK,SAER,CAAC,CACL,CAcY,EAA6B,CACxC,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UACT,EAAK,QAAU,QACf,EAAK,MAAQ,OAEtB,WACE,EACA,CACE,UACA,GAAG,KAGLF,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,qBACP,SAAUC,EAAAA,SAAe,OAAO,SAC9B,EAAA,EAAA,KAACC,EAAAA,gBAAD,CAAiB,GAAI,WAAOC,EAAAA,oBAAoB,EAAK,CAAmB,CAAA,CAExEA,EAAAA,oBAAoB,EAAK,CAE5B,CAAC,CACL,CAuBK,EAAW,GAEb,GAAU,MAEV,OAAO,GAAU,UACjB,OAAO,GAAU,UACjB,OAAO,GAAU,UAOf,GACJ,EACA,IACU,CAIV,GAAI,CAFa,OAAO,OAAO,EAAO,CAAC,KAAK,EAAQ,CAIlD,OAAO,EAAS,QAAQ,wBAAyB,EAAG,KAE1C,EADW,EAAI,MAAM,GACC,IAAI,UAAU,CAC5C,CAIJ,IAAM,EAA4B,EAAE,CAChC,EAAY,EACV,EAAQ,uBACV,EAAgC,EAAM,KAAK,EAAS,CAExD,KAAO,IAAU,MAAM,CAEjB,EAAM,MAAQ,GAChB,EAAM,KAAK,EAAS,UAAU,EAAW,EAAM,MAAM,CAAC,CAKxD,IAAM,EAAQ,EADF,EAAM,GAAG,MAAM,EAEvB,GAAiC,MACnC,EAAM,KAAK,OAAO,GAAU,SAAW,OAAO,EAAM,CAAG,EAAM,CAG/D,EAAY,EAAM,MAAQ,EAAM,GAAG,OACnC,EAAQ,EAAM,KAAK,EAAS,CAS9B,OALI,EAAY,EAAS,QACvB,EAAM,KAAK,EAAS,UAAU,EAAU,CAAC,EAI3C,EAAA,EAAA,GACEC,EAAAA,SACA,KACA,GAAG,EAAM,KAAK,EAAM,KAAA,EAAA,EAAA,GAAYA,EAAAA,SAAU,CAAE,IAAK,EAAO,CAAE,EAAK,CAAC,CACjE,EAIU,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaC,EAAAA,SAAS,UAC1D,WAAY,EAAwB,EAAO,IAAsB,CAC/D,IAAM,EAAwB,CAC5B,GAAG,EAAM,QACT,CACE,KAAMA,EAAAA,SAAS,UAChB,CACF,CAEK,EAAW,EAAKA,EAAAA,SAAS,WAGzB,EAAiC,CACrC,GAAI,0BACJ,UAAY,GAAS,OAAO,GAAS,SACrC,WAAY,EAAc,EAAU,IAAsB,CACxD,IAAM,EAAoB,EAAkB,EAAM,CAChD,GAAG,EACH,SAAU,EACV,QAAS,CACP,IAAI,EAAM,SAAY,EAAE,EAAgB,OACrC,GAAW,EAAO,KAAO,uBAC3B,CACF,CACF,CAAC,CAEF,MACE,IAGG,CACH,IAAM,EAAS,EAAsB,EAAmB,EAAO,CAE/D,OAAO,EAAkB,EAAQ,CAC/B,GAAG,EACH,QAAS,EAAM,QACf,SAAU,EACX,CAAC,GAGP,CAED,OAAO,EAAkB,EAAU,CACjC,GAAG,EACH,WACA,QAAS,EACT,QAAS,CAAC,EAAuB,GAAI,EAAM,SAAW,EAAE,CAAE,CAC3D,CAAC,EAEL,CAiBY,EAAgC,CAC3C,GAAI,yBACJ,UAAY,GAAS,OAAO,GAAS,SACrC,WAAY,EAAc,EAAO,IAAsB,CACrD,GAAM,CACJ,UACA,GAAG,GACD,EA6BE,EAAgB,GAAA,EAAA,EAAA,qBA3Be,EAAK,CA2BQ,CAChD,QAAS,CA1BsB,CAC/B,GAAI,2BACJ,UAAY,GACV,OAAO,GAAiB,UACxB,OAAO,GAAiB,UACxB,OAAO,GAAiB,WACxB,CAAC,EACH,WAAY,EAAc,IACxBL,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,EACP,UACE,EAAA,EAAA,KAACE,EAAAA,gBAAD,CAAiB,GAAI,YACnB,EAAA,EAAA,KAACI,EAAAA,yBAAD,CACE,GAAI,EACJ,gBAAiB,EAAM,iBAEtB,EACwB,CAAA,CACX,CAAA,CAErB,CAAC,CACL,CAI2B,CAC1B,cAAe,EAAK,cACpB,QAAS,EAAE,CACZ,CAAC,CAEI,EAAU,GACdN,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,EACP,UACE,EAAA,EAAA,KAACE,EAAAA,gBAAD,CAAiB,GAAI,YACnB,EAAA,EAAA,KAACK,EAAAA,uBAAD,CAAwB,GAAI,EAAkB,sBAC3C,EACsB,CAAA,CACT,CAAA,CAEpB,gBAAiB,CACf,SAAU,EACX,CACF,CAAC,CAEE,EAAU,GAAQ,CAExB,OAAO,IAAI,MAAM,EAAS,CACxB,IAAI,EAAQ,EAAM,CAYhB,OAXI,IAAS,QACJ,EAEL,IAAS,WACJ,EAGL,IAAS,MACH,GAAqB,EAAO,EAAW,CAG1C,QAAQ,IAAI,EAAQ,EAAK,EAEnC,CAAC,EAEL,CAcY,EAA0B,CACrC,GAAI,kBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaF,EAAAA,SAAS,SAC1D,WAAY,EAAuB,EAAO,IAAsB,CAC9D,IAAM,EAAwB,CAC5B,GAAG,EAAM,QACT,CACE,KAAMA,EAAAA,SAAS,SAChB,CACF,CAEK,EAAW,EAAKA,EAAAA,SAAS,UAE/B,OAAO,EAAkB,EAAU,CACjC,GAAG,EACH,WACA,QAAS,EACT,QAAS,CAAC,EAAsB,GAAI,EAAM,SAAW,EAAE,CAAE,CAC1D,CAAC,EAEL,CAiBY,EAAsB,CACjC,GAAI,cACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,KAC1D,WAAY,EAA2B,IAAU,CAC/C,IAAM,EAAO,EAAKA,EAAAA,SAAS,MACb,EAAK,KACnB,GAAM,CAAE,UAAS,GAAG,GAAS,EAGvB,EAAU,IAAA,EAAA,EAAA,GACZG,EAAAA,aAAqB,CAAE,GAAG,EAAM,OAAM,iBAAgB,CAAQ,CAE5D,EAAU,GAAQ,CAgBxB,OAdc,IAAI,MAAM,EAAS,CAC/B,IAAI,EAAQ,EAAM,CAShB,OARI,IAAS,QACJ,EAGL,IAAS,MACH,GAAoC,EAAO,EAAe,CAG7D,QAAQ,IAAI,EAAQ,EAAK,EAEnC,CAAC,EAIL,CAuCY,GACX,EACA,EAAoB,KACN,yBAEZ,GAAUP,EAAAA,QAAc,qBAAqB,cAC7C,EAAWA,EAAAA,QAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACDQ,EAAAA,kBACAC,EAAAA,mCACa,GAAUT,EAAAA,QAAc,qBAAqB,cAAc,CACxEU,EAAAA,WACAC,EAAAA,aACA,EACA,EACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderPreactElement","Fragment","NodeType","MarkdownMetadataRenderer","MarkdownRendererPlugin","HTMLRenderer","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRenderer } from './html/HTMLRenderer';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderPreactElement(node)}</ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataRenderer {...rest} metadataKeyPath={props.keyPath}>\n {node}\n </MarkdownMetadataRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ) : (\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n h(HTMLRenderer as any, { ...rest, html, userComponents } as any);\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`preact`);const t=n=>{if(typeof n!=`object`||!n)return n;let{type:r,props:i}=(e=>{let n=e.props?.children;if(Array.isArray(n)){let r=n.map(e=>t(e));return{...e,props:{...e.props,children:r}}}else if(n!=null){let r=t(n);return{...e,props:{...e.props,children:[r]}}}return{...e,props:{...e.props,children:[]}}})(n);return(0,e.createElement)(r??`span`,i,...i.children)};exports.renderPreactElement=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../IntlayerProvider-sM1gzsx7.cjs`);let e=require(`preact`);const t=n=>{if(typeof n!=`object`||!n)return n;let{type:r,props:i}=(e=>{let n=e.props?.children;if(Array.isArray(n)){let r=n.map(e=>t(e));return{...e,props:{...e.props,children:r}}}else if(n!=null){let r=t(n);return{...e,props:{...e.props,children:[r]}}}return{...e,props:{...e.props,children:[]}}})(n);return(0,e.createElement)(r??`span`,i,...i.children)};exports.renderPreactElement=t;
2
2
  //# sourceMappingURL=renderPreactElement.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":"wIAGA,MAAa,EAAuB,GAA6B,CAC/D,GAAwB,OAAO,GAAY,WAAvC,EACF,OAAO,EAmCT,GAAM,CAAE,OAAM,UA/BZ,GAC4D,CAC5D,IAAM,EAAW,EAAQ,OAAO,SAEhC,GAAI,MAAM,QAAQ,EAAS,CAAE,CAC3B,IAAM,EAAmC,EAAS,IAAK,GACrD,EAAoB,EAAoB,CACzC,CAED,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAgB,CACtD,SACe,GAAyC,KAAM,CAC/D,IAAM,EAAgB,EAAoB,EAAuB,CACjE,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,CAAC,EAAc,CAAE,CACvD,CAGH,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAE,CAAE,CAC1C,GAID,EACD,CAKD,OAAA,EAAA,EAAA,eACG,GAAgB,OACjB,EACA,GAAI,EAAM,SACX"}
1
+ {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":"uIAGA,MAAa,EAAuB,GAA6B,CAC/D,GAAwB,OAAO,GAAY,WAAvC,EACF,OAAO,EAmCT,GAAM,CAAE,OAAM,UA/BZ,GAC4D,CAC5D,IAAM,EAAW,EAAQ,OAAO,SAEhC,GAAI,MAAM,QAAQ,EAAS,CAAE,CAC3B,IAAM,EAAmC,EAAS,IAAK,GACrD,EAAoB,EAAoB,CACzC,CAED,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAgB,CACtD,SACe,GAAyC,KAAM,CAC/D,IAAM,EAAgB,EAAoB,EAAuB,CACjE,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,CAAC,EAAc,CAAE,CACvD,CAGH,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAE,CAAE,CAC1C,GAID,EACD,CAKD,OAAA,EAAA,EAAA,eACG,GAAgB,OACjB,EACA,GAAI,EAAM,SACX"}
@@ -0,0 +1,2 @@
1
+ import{localeInStorage as e,setLocaleInStorage as t}from"./client/useLocaleStorage.mjs";import n from"@intlayer/config/built";import{createContext as r}from"preact";import{isEnabled as i}from"@intlayer/editor/isEnabled";import{useContext as a,useEffect as o,useRef as s,useState as c}from"preact/hooks";import{jsx as l,jsxs as u}from"preact/jsx-runtime";import{localeResolver as d}from"@intlayer/core/localization";const f=()=>{let{locale:e}=a(m),t=s(null);o(()=>{if(!(process.env.INTLAYER_EDITOR_ENABLED===`false`||!i))return import(`@intlayer/editor`).then(({initEditorClient:n})=>{let r=n();t.current=r,e&&r.currentLocale.set(e)}),()=>{t.current=null,import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}},[]),o(()=>{!e||!t.current||t.current.currentLocale.set(e)},[e])},p=({children:e})=>(f(),e),m=r({locale:e??n?.internationalization?.defaultLocale,setLocale:()=>null}),h=()=>a(m),g=({locale:r,defaultLocale:i,children:a,setLocale:s,isCookieEnabled:u})=>{let{internationalization:f}=n??{},{defaultLocale:p,locales:h}=f??{},[g,_]=c(r??e??i??p);o(()=>{r&&r!==g&&_(r)},[r,g,_]);let v=s??(e=>{if(g.toString()!==e.toString()){if(!h?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}_(e),t(e,u??!0)}}),y=d(r??g);return l(m.Provider,{value:{locale:y,setLocale:v,isCookieEnabled:u},children:a})},_=({children:e,...t})=>u(g,{...t,children:[l(p,{}),e]});export{p as a,h as i,_ as n,f as o,g as r,m as t};
2
+ //# sourceMappingURL=IntlayerProvider-ClOcEK3A.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerProvider-ClOcEK3A.mjs","names":[],"sources":["../../src/editor/useEditor.tsx","../../src/editor/EditorProvider.tsx","../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext);\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n","import type { ComponentChild, FunctionComponent } from 'preact';\nimport { useEditor } from './useEditor';\n\nexport const EditorProvider: FunctionComponent<{\n children?: ComponentChild;\n}> = ({ children }) => {\n useEditor();\n\n return children;\n};\n","import configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\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); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":"+ZAWA,MAAa,MAAkB,CAC7B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAC9C,EAAa,EAAkC,KAAK,CAE1D,MAAgB,CACV,aAAQ,IAAI,0BAA4B,SAAW,CAAC,GASxD,OAPA,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAClC,EAAW,QAAU,EAEjB,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,KAEW,CACX,EAAW,QAAU,KACrB,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,GAEH,EAAE,CAAC,CAEN,MAAgB,CACV,CAAC,GAAU,CAAC,EAAW,SAE3B,EAAW,QAAQ,cAAc,IAAI,EAAiB,EACrD,CAAC,EAAO,CAAC,EClCD,GAEP,CAAE,eACN,GAAW,CAEJ,GCaI,EAAwB,EAA6B,CAChE,OAAQ,GAAmB,GAAe,sBAAsB,cAChE,cAAiB,KAClB,CAAC,CAKW,MAA2B,EAAW,EAAsB,CAa5D,GAER,CACH,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,qBACI,CACJ,GAAM,CAAE,wBAAyB,GAAiB,EAAE,CAC9C,CAAE,cAAe,EAAqB,QAAS,GACnD,GAAwB,EAAE,CAKtB,CAAC,EAAe,GAAoB,EAFxC,GAAc,GAAmB,GAAqB,EAIvD,CAED,MAAgB,CACV,GAAc,IAAe,GAC/B,EAAiB,EAAW,EAE7B,CAAC,EAAY,EAAe,EAAiB,CAAC,CAcjD,IAAM,EAAY,IAZK,GAA6B,CAC9C,KAAc,UAAU,GAAK,EAAU,UAAU,CAErD,IAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGF,EAAiB,EAAU,CAC3B,EAAmB,EAAW,GAAmB,GAAK,IAKlD,EAAiB,EAAe,GAAc,EAAc,CAElE,OACE,EAAC,EAAsB,SAAvB,CACE,MAAO,CACL,OAAQ,EACR,YACA,kBACD,CAEA,WAC8B,CAAA,EAwBxB,GAA8D,CACzE,WACA,GAAG,KAEH,EAAC,EAAD,CAAyB,GAAI,WAA7B,CACE,EAAC,EAAD,EAAkB,CAAA,CACjB,EACuB"}
@@ -1,2 +1 @@
1
- import{EditorProvider as e}from"../editor/EditorProvider.mjs";import{localeInStorage as t,setLocaleInStorage as n}from"./useLocaleStorage.mjs";import r from"@intlayer/config/built";import{createContext as i}from"preact";import{useContext as a,useEffect as o,useState as s}from"preact/hooks";import{jsx as c,jsxs as l}from"preact/jsx-runtime";import{localeResolver as u}from"@intlayer/core/localization";const d=i({locale:t??r?.internationalization?.defaultLocale,setLocale:()=>null}),f=()=>a(d),p=({locale:e,defaultLocale:i,children:a,setLocale:l,isCookieEnabled:f})=>{let{internationalization:p}=r??{},{defaultLocale:m,locales:h}=p??{},[g,_]=s(e??t??i??m);o(()=>{e&&e!==g&&_(e)},[e,g,_]);let v=l??(e=>{if(g.toString()!==e.toString()){if(!h?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}_(e),n(e,f??!0)}}),y=u(e??g);return c(d.Provider,{value:{locale:y,setLocale:v,isCookieEnabled:f},children:a})},m=({children:t,...n})=>l(p,{...n,children:[c(e,{}),t]});export{d as IntlayerClientContext,m as IntlayerProvider,p as IntlayerProviderContent,f as useIntlayerContext};
2
- //# sourceMappingURL=IntlayerProvider.mjs.map
1
+ import{i as e,n as t,r as n,t as r}from"../IntlayerProvider-ClOcEK3A.mjs";export{r as IntlayerClientContext,t as IntlayerProvider,n as IntlayerProviderContent,e as useIntlayerContext};
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{compact as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useCompact};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{compact as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useCompact};
2
2
  //# sourceMappingURL=useCompact.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"+KAcA,MAAa,MAAmB,CAC9B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAQ,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"uKAcA,MAAa,MAAmB,CAC9B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAQ,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{currency as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useCurrency};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{currency as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useCurrency};
2
2
  //# sourceMappingURL=useCurrency.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"gLA4BA,MAAa,MAAoB,CAC/B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAS,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"wKA4BA,MAAa,MAAoB,CAC/B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAS,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useContext as t}from"preact/hooks";import{date as n}from"@intlayer/core/formatters";const r=()=>{let{locale:r}=t(e);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useDate};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useContext as t}from"preact/hooks";import{date as n}from"@intlayer/core/formatters";const r=()=>{let{locale:r}=t(e);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useDate};
2
2
  //# sourceMappingURL=useDate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\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 date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"2JA8BA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAQ,GAAG,IACT,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\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 date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"mJA8BA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAQ,GAAG,IACT,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useContext as t,useMemo as n}from"preact/hooks";import{bindIntl as r}from"@intlayer/core/formatters";const i=i=>{let{locale:a}=t(e),o=i??a;return n(()=>r(o),[o])};export{i as useIntl};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useContext as t,useMemo as n}from"preact/hooks";import{bindIntl as r}from"@intlayer/core/formatters";const i=i=>{let{locale:a}=t(e),o=i??a;return n(()=>r(o),[o])};export{i as useIntl};
2
2
  //# sourceMappingURL=useIntl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["import { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Preact 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 locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"4KAuBA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAO,MAAc,EAAS,EAAc,CAAE,CAAC,EAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Preact 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 locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\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":"oKAuBA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAO,MAA2B,EAAS,EAAc,CAAE,CAAC,EAAc,CAAC"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{list as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useList};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{list as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useList};
2
2
  //# sourceMappingURL=useList.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"4KAyBA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"oKAyBA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{number as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useNumber};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{number as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useNumber};
2
2
  //# sourceMappingURL=useNumber.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"8KA0BA,MAAa,MAAkB,CAC7B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAO,EAAK,GAAI,CACd,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\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":"sKA0BA,MAAa,MAAkB,CAC7B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAO,EAAK,GAAI,CACd,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{percentage as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as usePercentage};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{percentage as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as usePercentage};
2
2
  //# sourceMappingURL=usePercentage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"kLAsBA,MAAa,MAAsB,CACjC,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAW,EAAK,GAAI,CAClB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"0KAsBA,MAAa,MAAsB,CACjC,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAW,EAAK,GAAI,CAClB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{relativeTime as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],e[1],{...e[2],locale:e[2]?.locale??i}),[i])};export{i as useRelativeTime};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{relativeTime as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],e[1],{...e[2],locale:e[2]?.locale??i}),[i])};export{i as useRelativeTime};
2
2
  //# sourceMappingURL=useRelativeTime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"oLAsBA,MAAa,MAAwB,CACnC,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAa,EAAK,GAAI,EAAK,GAAI,CAC7B,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"4KAsBA,MAAa,MAAwB,CACnC,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAa,EAAK,GAAI,EAAK,GAAI,CAC7B,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"../IntlayerProvider.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{units as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useUnit};
1
+ import{t as e}from"../../IntlayerProvider-ClOcEK3A.mjs";import{useCallback as t,useContext as n}from"preact/hooks";import{units as r}from"@intlayer/core/formatters";const i=()=>{let{locale:i}=n(e);return t((...e)=>r(e[0],{...e[1],locale:e[1]?.locale??i}),[i])};export{i as useUnit};
2
2
  //# sourceMappingURL=useUnit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"6KAqBA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAM,EAAK,GAAI,CACb,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"qKAqBA,MAAa,MAAgB,CAC3B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAEpD,OAAO,GACJ,GAAG,IACF,EAAM,EAAK,GAAI,CACb,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1 +1 @@
1
- import{localeCookie as e,localeInStorage as t,setLocaleCookie as n,setLocaleInStorage as r,useLocaleCookie as i,useLocaleStorage as a}from"./useLocaleStorage.mjs";import{IntlayerClientContext as o,IntlayerProvider as s,IntlayerProviderContent as c,useIntlayerContext as l}from"./IntlayerProvider.mjs";import{useLocale as u}from"./useLocale.mjs";import{useIntl as d}from"./format/useIntl.mjs";import{t as f}from"./t.mjs";import{useDictionary as p}from"./useDictionary.mjs";import{useDictionaryAsync as m}from"./useDictionaryAsync.mjs";import{useLoadDynamic as h}from"./useLoadDynamic.mjs";import{useDictionaryDynamic as g}from"./useDictionaryDynamic.mjs";import{useIntlayer as _}from"./useIntlayer.mjs";import{useLocaleBase as v}from"./useLocaleBase.mjs";export{o as IntlayerClientContext,s as IntlayerProvider,c as IntlayerProviderContent,e as localeCookie,t as localeInStorage,n as setLocaleCookie,r as setLocaleInStorage,f as t,p as useDictionary,m as useDictionaryAsync,g as useDictionaryDynamic,d as useIntl,_ as useIntlayer,l as useIntlayerContext,h as useLoadDynamic,u as useLocale,v as useLocaleBase,i as useLocaleCookie,a as useLocaleStorage};
1
+ import{i as e,n as t,r as n,t as r}from"../IntlayerProvider-ClOcEK3A.mjs";import{localeCookie as i,localeInStorage as a,setLocaleCookie as o,setLocaleInStorage as s,useLocaleCookie as c,useLocaleStorage as l}from"./useLocaleStorage.mjs";import{useLocale as u}from"./useLocale.mjs";import{useIntl as d}from"./format/useIntl.mjs";import{t as f}from"./t.mjs";import{useDictionary as p}from"./useDictionary.mjs";import{useDictionaryAsync as m}from"./useDictionaryAsync.mjs";import{useLoadDynamic as h}from"./useLoadDynamic.mjs";import{useDictionaryDynamic as g}from"./useDictionaryDynamic.mjs";import{useIntlayer as _}from"./useIntlayer.mjs";import{useLocaleBase as v}from"./useLocaleBase.mjs";export{r as IntlayerClientContext,t as IntlayerProvider,n as IntlayerProviderContent,i as localeCookie,a as localeInStorage,o as setLocaleCookie,s as setLocaleInStorage,f as t,p as useDictionary,m as useDictionaryAsync,g as useDictionaryDynamic,d as useIntl,_ as useIntlayer,e as useIntlayerContext,h as useLoadDynamic,u as useLocale,v as useLocaleBase,c as useLocaleCookie,l as useLocaleStorage};
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"./IntlayerProvider.mjs";import{getTranslation as t}from"@intlayer/core/interpreter";import{useContext as n}from"preact/hooks";const r=(r,i)=>{let{locale:a}=n(e);return t(r,i??a)};export{r as t};
1
+ import{t as e}from"../IntlayerProvider-ClOcEK3A.mjs";import{getTranslation as t}from"@intlayer/core/interpreter";import{useContext as n}from"preact/hooks";const r=(r,i)=>{let{locale:a}=n(e);return t(r,i??a)};export{r as t};
2
2
  //# sourceMappingURL=t.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"qKAWA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAGnE,OAAO,EAAwB,EAFV,GAAU,EAE+B"}
1
+ {"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"2JAWA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAGnE,OAAO,EAAwB,EAFV,GAAU,EAE+B"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"./IntlayerProvider.mjs";import{getDictionary as t}from"../getDictionary.mjs";import{useContext as n,useMemo as r}from"preact/hooks";const i=(i,a)=>{let{locale:o}=n(e);return r(()=>t(i,a??o),[i.key,o,a])};export{i as useDictionary};
1
+ import{t as e}from"../IntlayerProvider-ClOcEK3A.mjs";import{getDictionary as t}from"../getDictionary.mjs";import{useContext as n,useMemo as r}from"preact/hooks";const i=(i,a)=>{let{locale:o}=n(e);return r(()=>t(i,a??o),[i.key,o,a])};export{i as useDictionary};
2
2
  //# sourceMappingURL=useDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\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 client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":"2KAcA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAEnE,OAAO,MAGE,EAAoB,EAFN,GAAU,EAE0B,CACxD,CAAC,EAAW,IAAK,EAAe,EAAO,CAAC"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\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 client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":"iKAcA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAEnE,OAAO,MAGE,EAAoB,EAFN,GAAU,EAE0B,CACxD,CAAC,EAAW,IAAK,EAAe,EAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"./IntlayerProvider.mjs";import{useDictionary as t}from"./useDictionary.mjs";import n from"@intlayer/config/built";import{useContext as r,useMemo as i}from"preact/hooks";const a=async(a,o)=>{let{locale:s}=r(e),c=i(()=>o??s??n?.internationalization.defaultLocale,[s,o]);return t(await i(async()=>await a[c]?.(),[a,c]),c)};export{a as useDictionaryAsync};
1
+ import{t as e}from"../IntlayerProvider-ClOcEK3A.mjs";import{useDictionary as t}from"./useDictionary.mjs";import n from"@intlayer/config/built";import{useContext as r,useMemo as i}from"preact/hooks";const a=async(a,o)=>{let{locale:s}=r(e),c=i(()=>o??s??n?.internationalization.defaultLocale,[s,o]);return t(await i(async()=>await a[c]?.(),[a,c]),c)};export{a as useDictionaryAsync};
2
2
  //# sourceMappingURL=useDictionaryAsync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\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 client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":"gNAeA,MAAa,EAAqB,MAChC,EACA,IACe,CACf,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAE7D,EAAe,MAEjB,GACA,GACA,GAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAUD,OAAO,EARY,MAAM,EACvB,SACG,MAAM,EACL,MACG,CACP,CAAC,EAAmB,EAAa,CAClC,CAEgC,EAAa"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\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 client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":"sMAeA,MAAa,EAAqB,MAChC,EACA,IACe,CACf,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAE7D,EAAe,MAEjB,GACA,GACA,GAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAUD,OAAO,EARY,MAAM,EACvB,SACG,MAAM,EACL,MACG,CACP,CAAC,EAAmB,EAAa,CAClC,CAEgC,EAAa"}
@@ -1,2 +1,2 @@
1
- import{IntlayerClientContext as e}from"./IntlayerProvider.mjs";import{useDictionary as t}from"./useDictionary.mjs";import{useLoadDynamic as n}from"./useLoadDynamic.mjs";import{useContext as r,useMemo as i}from"preact/hooks";const a=(a,o,s)=>{let{locale:c}=r(e),l=i(()=>s??c,[c,s]);return t(n(`${String(o)}.${l}`,a[l]?.()),l)};export{a as useDictionaryDynamic};
1
+ import{t as e}from"../IntlayerProvider-ClOcEK3A.mjs";import{useDictionary as t}from"./useDictionary.mjs";import{useLoadDynamic as n}from"./useLoadDynamic.mjs";import{useContext as r,useMemo as i}from"preact/hooks";const a=(a,o,s)=>{let{locale:c}=r(e),l=i(()=>s??c,[c,s]);return t(n(`${String(o)}.${l}`,a[l]?.()),l)};export{a as useDictionaryDynamic};
2
2
  //# sourceMappingURL=useDictionaryDynamic.mjs.map