preact-intlayer 8.3.4 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +1 -1
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/client/index.cjs +1 -1
  4. package/dist/cjs/client/useLocaleStorage.cjs +1 -1
  5. package/dist/cjs/editor/ContentSelector.cjs +2 -0
  6. package/dist/cjs/editor/ContentSelector.cjs.map +1 -0
  7. package/dist/cjs/editor/EditorProvider.cjs +1 -1
  8. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  9. package/dist/cjs/editor/useEditor.cjs +2 -0
  10. package/dist/cjs/editor/useEditor.cjs.map +1 -0
  11. package/dist/cjs/html/HTMLRenderer.cjs +1 -1
  12. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  13. package/dist/cjs/index.cjs +1 -1
  14. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -1
  15. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  16. package/dist/cjs/plugins.cjs +1 -1
  17. package/dist/cjs/plugins.cjs.map +1 -1
  18. package/dist/esm/client/IntlayerProvider.mjs +1 -1
  19. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  20. package/dist/esm/client/index.mjs +1 -1
  21. package/dist/esm/client/useLocaleStorage.mjs +1 -1
  22. package/dist/esm/editor/ContentSelector.mjs +2 -0
  23. package/dist/esm/editor/ContentSelector.mjs.map +1 -0
  24. package/dist/esm/editor/EditorProvider.mjs +1 -1
  25. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  26. package/dist/esm/editor/useEditor.mjs +2 -0
  27. package/dist/esm/editor/useEditor.mjs.map +1 -0
  28. package/dist/esm/html/HTMLRenderer.mjs +1 -1
  29. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  30. package/dist/esm/index.mjs +1 -1
  31. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -1
  32. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  33. package/dist/esm/plugins.mjs +1 -1
  34. package/dist/esm/plugins.mjs.map +1 -1
  35. package/dist/types/client/IntlayerProvider.d.ts +0 -2
  36. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  37. package/dist/types/editor/ContentSelector.d.ts +19 -0
  38. package/dist/types/editor/ContentSelector.d.ts.map +1 -0
  39. package/dist/types/editor/EditorProvider.d.ts +5 -18
  40. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  41. package/dist/types/editor/useEditor.d.ts +10 -0
  42. package/dist/types/editor/useEditor.d.ts.map +1 -0
  43. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  44. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  45. package/dist/types/plugins.d.ts.map +1 -1
  46. package/package.json +7 -7
  47. package/dist/cjs/editor/CommunicatorContext.cjs +0 -2
  48. package/dist/cjs/editor/CommunicatorContext.cjs.map +0 -1
  49. package/dist/cjs/editor/ConfigurationContext.cjs +0 -2
  50. package/dist/cjs/editor/ConfigurationContext.cjs.map +0 -1
  51. package/dist/cjs/editor/ContentSelectorWrapper.cjs +0 -2
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +0 -1
  53. package/dist/cjs/editor/DictionariesRecordContext.cjs +0 -2
  54. package/dist/cjs/editor/DictionariesRecordContext.cjs.map +0 -1
  55. package/dist/cjs/editor/EditedContentContext.cjs +0 -2
  56. package/dist/cjs/editor/EditedContentContext.cjs.map +0 -1
  57. package/dist/cjs/editor/EditorEnabledContext.cjs +0 -2
  58. package/dist/cjs/editor/EditorEnabledContext.cjs.map +0 -1
  59. package/dist/cjs/editor/EditorStateContext.cjs +0 -2
  60. package/dist/cjs/editor/EditorStateContext.cjs.map +0 -1
  61. package/dist/cjs/editor/FocusDictionaryContext.cjs +0 -2
  62. package/dist/cjs/editor/FocusDictionaryContext.cjs.map +0 -1
  63. package/dist/cjs/editor/IntlayerEditorProvider.cjs +0 -2
  64. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +0 -1
  65. package/dist/cjs/editor/index.cjs +0 -1
  66. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +0 -2
  67. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +0 -1
  68. package/dist/cjs/editor/useCrossFrameState.cjs +0 -2
  69. package/dist/cjs/editor/useCrossFrameState.cjs.map +0 -1
  70. package/dist/cjs/editor/useCrossURLPathState.cjs +0 -2
  71. package/dist/cjs/editor/useCrossURLPathState.cjs.map +0 -1
  72. package/dist/cjs/editor/useEditedContentRenderer.cjs +0 -2
  73. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +0 -1
  74. package/dist/cjs/editor/useIframeClickInterceptor.cjs +0 -2
  75. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +0 -1
  76. package/dist/esm/editor/CommunicatorContext.mjs +0 -2
  77. package/dist/esm/editor/CommunicatorContext.mjs.map +0 -1
  78. package/dist/esm/editor/ConfigurationContext.mjs +0 -2
  79. package/dist/esm/editor/ConfigurationContext.mjs.map +0 -1
  80. package/dist/esm/editor/ContentSelectorWrapper.mjs +0 -2
  81. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +0 -1
  82. package/dist/esm/editor/DictionariesRecordContext.mjs +0 -2
  83. package/dist/esm/editor/DictionariesRecordContext.mjs.map +0 -1
  84. package/dist/esm/editor/EditedContentContext.mjs +0 -2
  85. package/dist/esm/editor/EditedContentContext.mjs.map +0 -1
  86. package/dist/esm/editor/EditorEnabledContext.mjs +0 -2
  87. package/dist/esm/editor/EditorEnabledContext.mjs.map +0 -1
  88. package/dist/esm/editor/EditorStateContext.mjs +0 -2
  89. package/dist/esm/editor/EditorStateContext.mjs.map +0 -1
  90. package/dist/esm/editor/FocusDictionaryContext.mjs +0 -2
  91. package/dist/esm/editor/FocusDictionaryContext.mjs.map +0 -1
  92. package/dist/esm/editor/IntlayerEditorProvider.mjs +0 -2
  93. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +0 -1
  94. package/dist/esm/editor/index.mjs +0 -1
  95. package/dist/esm/editor/useCrossFrameMessageListener.mjs +0 -2
  96. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +0 -1
  97. package/dist/esm/editor/useCrossFrameState.mjs +0 -2
  98. package/dist/esm/editor/useCrossFrameState.mjs.map +0 -1
  99. package/dist/esm/editor/useCrossURLPathState.mjs +0 -2
  100. package/dist/esm/editor/useCrossURLPathState.mjs.map +0 -1
  101. package/dist/esm/editor/useEditedContentRenderer.mjs +0 -2
  102. package/dist/esm/editor/useEditedContentRenderer.mjs.map +0 -1
  103. package/dist/esm/editor/useIframeClickInterceptor.mjs +0 -2
  104. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +0 -1
  105. package/dist/types/editor/CommunicatorContext.d.ts +0 -12
  106. package/dist/types/editor/CommunicatorContext.d.ts.map +0 -1
  107. package/dist/types/editor/ConfigurationContext.d.ts +0 -10
  108. package/dist/types/editor/ConfigurationContext.d.ts.map +0 -1
  109. package/dist/types/editor/ContentSelectorWrapper.d.ts +0 -9
  110. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +0 -1
  111. package/dist/types/editor/DictionariesRecordContext.d.ts +0 -16
  112. package/dist/types/editor/DictionariesRecordContext.d.ts.map +0 -1
  113. package/dist/types/editor/EditedContentContext.d.ts +0 -35
  114. package/dist/types/editor/EditedContentContext.d.ts.map +0 -1
  115. package/dist/types/editor/EditorEnabledContext.d.ts +0 -11
  116. package/dist/types/editor/EditorEnabledContext.d.ts.map +0 -1
  117. package/dist/types/editor/EditorStateContext.d.ts +0 -12
  118. package/dist/types/editor/EditorStateContext.d.ts.map +0 -1
  119. package/dist/types/editor/FocusDictionaryContext.d.ts +0 -16
  120. package/dist/types/editor/FocusDictionaryContext.d.ts.map +0 -1
  121. package/dist/types/editor/IntlayerEditorProvider.d.ts +0 -9
  122. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +0 -1
  123. package/dist/types/editor/index.d.ts +0 -3
  124. package/dist/types/editor/useCrossFrameMessageListener.d.ts +0 -7
  125. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +0 -1
  126. package/dist/types/editor/useCrossFrameState.d.ts +0 -13
  127. package/dist/types/editor/useCrossFrameState.d.ts.map +0 -1
  128. package/dist/types/editor/useCrossURLPathState.d.ts +0 -6
  129. package/dist/types/editor/useCrossURLPathState.d.ts.map +0 -1
  130. package/dist/types/editor/useEditedContentRenderer.d.ts +0 -21
  131. package/dist/types/editor/useEditedContentRenderer.d.ts.map +0 -1
  132. package/dist/types/editor/useIframeClickInterceptor.d.ts +0 -6
  133. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../editor/IntlayerEditorProvider.cjs`),n=require(`../editor/useCrossFrameState.cjs`),r=require(`./useLocaleStorage.cjs`);let i=require(`@intlayer/config/built`);i=e.__toESM(i);let a=require(`preact`),o=require(`@intlayer/editor`),s=require(`preact/hooks`),c=require(`@intlayer/core/localization`),l=require(`preact/jsx-runtime`);const u=(0,a.createContext)({locale:r.localeInStorage??i.default?.internationalization?.defaultLocale,setLocale:()=>null,disableEditor:!1}),d=()=>(0,s.useContext)(u),f=({locale:e,defaultLocale:t,children:a,setLocale:d,disableEditor:f,isCookieEnabled:p})=>{let{internationalization:m}=i.default??{},{defaultLocale:h,locales:g}=m??{},_=e??r.localeInStorage??t??h,[v,y]=n.useCrossFrameState(o.MessageKey.INTLAYER_CURRENT_LOCALE,_);(0,s.useEffect)(()=>{e&&e!==v&&y(e)},[e,v,y]);let b=d??(e=>{if(v.toString()!==e.toString()){if(!g?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}y(e),r.setLocaleInStorage(e,p??!0)}}),x=(0,c.localeResolver)(e??v);return(0,l.jsx)(u.Provider,{value:{locale:x,setLocale:b,disableEditor:f,isCookieEnabled:p},children:a})},p=e=>(0,l.jsx)(t.IntlayerEditorProvider,{children:(0,l.jsx)(f,{...e})});exports.IntlayerClientContext=u,exports.IntlayerProvider=p,exports.IntlayerProviderContent=f,exports.useIntlayerContext=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../editor/EditorProvider.cjs`),n=require(`./useLocaleStorage.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);let i=require(`preact`),a=require(`preact/hooks`),o=require(`preact/jsx-runtime`),s=require(`@intlayer/core/localization`);const c=(0,i.createContext)({locale:n.localeInStorage??r.default?.internationalization?.defaultLocale,setLocale:()=>null}),l=()=>(0,a.useContext)(c),u=({locale:e,defaultLocale:t,children:i,setLocale:l,isCookieEnabled:u})=>{let{internationalization:d}=r.default??{},{defaultLocale:f,locales:p}=d??{},[m,h]=(0,a.useState)(e??n.localeInStorage??t??f);(0,a.useEffect)(()=>{e&&e!==m&&h(e)},[e,m,h]);let g=l??(e=>{if(m.toString()!==e.toString()){if(!p?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}h(e),n.setLocaleInStorage(e,u??!0)}}),_=(0,s.localeResolver)(e??m);return(0,o.jsx)(c.Provider,{value:{locale:_,setLocale:g,isCookieEnabled:u},children:i})},d=({children:e,...n})=>(0,o.jsxs)(u,{...n,children:[(0,o.jsx)(t.EditorProvider,{}),e]});exports.IntlayerClientContext=c,exports.IntlayerProvider=d,exports.IntlayerProviderContent=u,exports.useIntlayerContext=l;
2
2
  //# sourceMappingURL=IntlayerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","useCrossFrameState","MessageKey","IntlayerEditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport { MessageKey } from '@intlayer/editor';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect } from 'preact/hooks';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { useCrossFrameState } from '../editor/useCrossFrameState';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n disableEditor: false,\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 disableEditor?: boolean;\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 disableEditor,\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] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\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 disableEditor,\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 props\n) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":"4cAwBA,MAAa,GAAA,EAAA,EAAA,eAAqD,CAChE,OAAQA,EAAAA,iBAAmBC,EAAAA,SAAe,sBAAsB,cAChE,cAAiB,KACjB,cAAe,GAChB,CAAC,CAKW,OAAA,EAAA,EAAA,YAAsC,EAAsB,CAc5D,GAER,CACH,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,gBACA,qBACI,CACJ,GAAM,CAAE,wBAAyBA,EAAAA,SAAiB,EAAE,CAC9C,CAAE,cAAe,EAAqB,QAAS,GACnD,GAAwB,EAAE,CAEtB,EACJ,GAAcD,EAAAA,iBAAmB,GAAqB,EAElD,CAAC,EAAe,GAAoBE,EAAAA,mBACxCC,EAAAA,WAAW,wBACX,EACD,EAED,EAAA,EAAA,eAAgB,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,EAAA,mBAAmB,EAAW,GAAmB,GAAK,IAKlD,GAAA,EAAA,EAAA,gBAAgC,GAAc,EAAc,CAElE,OACE,EAAA,EAAA,KAAC,EAAsB,SAAvB,CACE,MAAO,CACL,OAAQ,EACR,YACA,gBACA,kBACD,CAEA,WAC8B,CAAA,EAwBxB,EACX,IAEA,EAAA,EAAA,KAACC,EAAAA,uBAAD,CAAA,UACE,EAAA,EAAA,KAAC,EAAD,CAAyB,GAAI,EAAS,CAAA,CACf,CAAA"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["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":"wXAqBA,MAAa,GAAA,EAAA,EAAA,eAAqD,CAChE,OAAQA,EAAAA,iBAAmBC,EAAAA,SAAe,sBAAsB,cAChE,cAAiB,KAClB,CAAC,CAKW,OAAA,EAAA,EAAA,YAAsC,EAAsB,CAa5D,GAER,CACH,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,qBACI,CACJ,GAAM,CAAE,wBAAyBA,EAAAA,SAAiB,EAAE,CAC9C,CAAE,cAAe,EAAqB,QAAS,GACnD,GAAwB,EAAE,CAKtB,CAAC,EAAe,IAAA,EAAA,EAAA,UAFpB,GAAcD,EAAAA,iBAAmB,GAAqB,EAIvD,EAED,EAAA,EAAA,eAAgB,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,EAAA,mBAAmB,EAAW,GAAmB,GAAK,IAKlD,GAAA,EAAA,EAAA,gBAAgC,GAAc,EAAc,CAElE,OACE,EAAA,EAAA,KAAC,EAAsB,SAAvB,CACE,MAAO,CACL,OAAQ,EACR,YACA,kBACD,CAEA,WAC8B,CAAA,EAwBxB,GAA8D,CACzE,WACA,GAAG,MAEH,EAAA,EAAA,MAAC,EAAD,CAAyB,GAAI,WAA7B,EACE,EAAA,EAAA,KAACE,EAAAA,eAAD,EAAkB,CAAA,CACjB,EACuB"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useLocaleStorage.cjs`),t=require(`./IntlayerProvider.cjs`),n=require(`./format/useIntl.cjs`),r=require(`./t.cjs`),i=require(`./useDictionary.cjs`),a=require(`./useDictionaryAsync.cjs`),o=require(`./useLoadDynamic.cjs`),s=require(`./useDictionaryDynamic.cjs`),c=require(`./useIntlayer.cjs`),l=require(`./useLocale.cjs`),u=require(`./useLocaleBase.cjs`);exports.IntlayerClientContext=t.IntlayerClientContext,exports.IntlayerProvider=t.IntlayerProvider,exports.IntlayerProviderContent=t.IntlayerProviderContent,exports.localeCookie=e.localeCookie,exports.localeInStorage=e.localeInStorage,exports.setLocaleCookie=e.setLocaleCookie,exports.setLocaleInStorage=e.setLocaleInStorage,exports.t=r.t,exports.useDictionary=i.useDictionary,exports.useDictionaryAsync=a.useDictionaryAsync,exports.useDictionaryDynamic=s.useDictionaryDynamic,exports.useIntl=n.useIntl,exports.useIntlayer=c.useIntlayer,exports.useIntlayerContext=t.useIntlayerContext,exports.useLoadDynamic=o.useLoadDynamic,exports.useLocale=l.useLocale,exports.useLocaleBase=u.useLocaleBase,exports.useLocaleCookie=e.useLocaleCookie,exports.useLocaleStorage=e.useLocaleStorage;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useLocaleStorage.cjs`),t=require(`./IntlayerProvider.cjs`),n=require(`./useLocale.cjs`),r=require(`./format/useIntl.cjs`),i=require(`./t.cjs`),a=require(`./useDictionary.cjs`),o=require(`./useDictionaryAsync.cjs`),s=require(`./useLoadDynamic.cjs`),c=require(`./useDictionaryDynamic.cjs`),l=require(`./useIntlayer.cjs`),u=require(`./useLocaleBase.cjs`);exports.IntlayerClientContext=t.IntlayerClientContext,exports.IntlayerProvider=t.IntlayerProvider,exports.IntlayerProviderContent=t.IntlayerProviderContent,exports.localeCookie=e.localeCookie,exports.localeInStorage=e.localeInStorage,exports.setLocaleCookie=e.setLocaleCookie,exports.setLocaleInStorage=e.setLocaleInStorage,exports.t=i.t,exports.useDictionary=a.useDictionary,exports.useDictionaryAsync=o.useDictionaryAsync,exports.useDictionaryDynamic=c.useDictionaryDynamic,exports.useIntl=r.useIntl,exports.useIntlayer=l.useIntlayer,exports.useIntlayerContext=t.useIntlayerContext,exports.useLoadDynamic=s.useLoadDynamic,exports.useLocale=n.useLocale,exports.useLocaleBase=u.useLocaleBase,exports.useLocaleCookie=e.useLocaleCookie,exports.useLocaleStorage=e.useLocaleStorage;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/core/utils`),t=require(`preact/hooks`),n=require(`@intlayer/core/localization`);const r=(0,e.getLocaleFromStorage)(n.localeStorageOptions),i=r,a=(t,r)=>(0,e.setLocaleInStorage)(t,{...n.localeStorageOptions,isCookieEnabled:r}),o=a,s=r=>(0,t.useMemo)(()=>(0,e.LocaleStorage)({...n.localeStorageOptions,isCookieEnabled:r}),[r]),c=e=>{let t=s(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};exports.localeCookie=i,exports.localeInStorage=r,exports.setLocaleCookie=o,exports.setLocaleInStorage=a,exports.useLocaleCookie=c,exports.useLocaleStorage=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`preact/hooks`),t=require(`@intlayer/core/localization`),n=require(`@intlayer/core/utils`);const r=(0,n.getLocaleFromStorage)(t.localeStorageOptions),i=r,a=(e,r)=>(0,n.setLocaleInStorage)(e,{...t.localeStorageOptions,isCookieEnabled:r}),o=a,s=r=>(0,e.useMemo)(()=>(0,n.LocaleStorage)({...t.localeStorageOptions,isCookieEnabled:r}),[r]),c=e=>{let t=s(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};exports.localeCookie=i,exports.localeInStorage=r,exports.setLocaleCookie=o,exports.setLocaleInStorage=a,exports.useLocaleCookie=c,exports.useLocaleStorage=s;
2
2
  //# sourceMappingURL=useLocaleStorage.cjs.map
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/editor/isEnabled`),t=require(`preact/hooks`),n=require(`preact/jsx-runtime`);const r=({children:r,dictionaryKey:i,keyPath:a})=>((0,t.useEffect)(()=>{!e.isEnabled||typeof window>`u`||import(`@intlayer/editor`).then(({defineIntlayerElements:e})=>{e()})},[e.isEnabled]),e.isEnabled?(0,n.jsx)(`intlayer-content-selector-wrapper`,{"key-path":JSON.stringify(a),"dictionary-key":i,children:r}):r);exports.ContentSelector=r;
2
+ //# sourceMappingURL=ContentSelector.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (!isEnabled || typeof window === 'undefined') return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (!isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":"sNAoBA,MAAa,GAER,CAAE,WAAU,gBAAe,eAC9B,EAAA,EAAA,eAAgB,CACV,CAACA,EAAAA,WAAa,OAAO,OAAW,KACpC,OAAO,oBAAoB,MAAM,CAAE,4BAA6B,CAC9D,GAAwB,EACxB,EACD,CAACA,EAAAA,UAAU,CAAC,CAEVA,EAAAA,WAKH,EAAA,EAAA,KAAC,oCAAD,CACE,WAAU,KAAK,UAAU,EAAQ,CACjC,iBAAgB,EAEf,WACiC,CAAA,CAT7B"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./EditorStateContext.cjs`),n=require(`./EditorEnabledContext.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);let i=require(`@intlayer/editor`),a=require(`preact/hooks`),o=require(`preact/jsx-runtime`);const{editor:s}=r.default??{},c=()=>({allowedOrigins:[s?.applicationURL,s?.editorURL,s?.cmsURL].filter(Boolean),postMessageFn:(e,t)=>{typeof window>`u`||window.self!==window.top&&(window.parent?.postMessage(e,t),window.postMessage(e,t))}}),l=({children:e,fallback:t})=>{let{enabled:r}=n.useEditorEnabled();return r?e:t},u=({children:e,fallback:t})=>{let[n,r]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{r(window.self!==window.top)},[]),n?e:t},d=({children:e,mode:n=`client`,configuration:s,postMessage:d,allowedOrigins:f})=>{let p=(0,a.useRef)(null);p.current||=new i.EditorStateManager({mode:n,messenger:d||f?{allowedOrigins:f??[`*`],postMessageFn:d?e=>d(e):c().postMessageFn}:c(),configuration:s??r.default});let m=p.current;return(0,a.useEffect)(()=>((0,i.defineIntlayerElements)(),m.start(),()=>m.stop()),[m]),(0,o.jsx)(t.EditorStateProvider,{manager:m,children:n===`editor`?e:(0,o.jsx)(u,{fallback:e,children:(0,o.jsx)(l,{fallback:e,children:e})})})};exports.EditorProvider=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useEditor.cjs`),t=({children:t})=>(e.useEditor(),t);exports.EditorProvider=t;
2
2
  //# sourceMappingURL=EditorProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.cjs","names":["configuration","useEditorEnabled","EditorStateManager","EditorStateProvider"],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n defineIntlayerElements,\n EditorStateManager,\n type MessengerConfig,\n} from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useEditorEnabled } from './EditorEnabledContext';\nimport { EditorStateProvider } from './EditorStateContext';\n\nconst { editor } = configuration ?? {};\n\nconst buildDefaultMessengerConfig = (): MessengerConfig => ({\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ].filter(Boolean) as string[],\n postMessageFn: (payload, origin) => {\n if (typeof window === 'undefined') return;\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n window.parent?.postMessage(payload, origin);\n window.postMessage(payload, origin);\n },\n});\n\ntype FallbackProps = {\n fallback: ComponentChildren;\n children?: ComponentChildren;\n};\n\nconst EditorEnabledCheckRenderer: FunctionComponent<FallbackProps> = ({\n children,\n fallback,\n}) => {\n const { enabled } = useEditorEnabled();\n return enabled ? children : fallback;\n};\n\nconst IframeCheckRenderer: FunctionComponent<FallbackProps> = ({\n children,\n fallback,\n}) => {\n const [isInIframe, setIsInIframe] = useState(false);\n\n useEffect(() => {\n setIsInIframe(window.self !== window.top);\n }, []);\n\n return isInIframe ? children : fallback;\n};\n\nexport type EditorProviderProps = {\n mode?: 'editor' | 'client';\n configuration?: IntlayerConfig;\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n children?: ComponentChildren;\n};\n\nexport const EditorProvider: FunctionComponent<EditorProviderProps> = ({\n children,\n mode = 'client',\n configuration: configProp,\n postMessage: customPostMessage,\n allowedOrigins: customAllowedOrigins,\n}) => {\n const managerRef = useRef<EditorStateManager | null>(null);\n if (!managerRef.current) {\n const messengerConfig: MessengerConfig =\n customPostMessage || customAllowedOrigins\n ? {\n allowedOrigins: customAllowedOrigins ?? ['*'],\n postMessageFn: customPostMessage\n ? (payload) => customPostMessage(payload)\n : buildDefaultMessengerConfig().postMessageFn,\n }\n : buildDefaultMessengerConfig();\n managerRef.current = new EditorStateManager({\n mode,\n messenger: messengerConfig,\n configuration: configProp ?? configuration,\n });\n }\n const manager = managerRef.current;\n\n useEffect(() => {\n defineIntlayerElements();\n manager.start();\n return () => manager.stop();\n }, [manager]);\n\n const content =\n mode === 'editor' ? (\n children\n ) : (\n <IframeCheckRenderer fallback={children}>\n <EditorEnabledCheckRenderer fallback={children}>\n {children}\n </EditorEnabledCheckRenderer>\n </IframeCheckRenderer>\n );\n\n return <EditorStateProvider manager={manager}>{content}</EditorStateProvider>;\n};\n\n// Backward-compat types\nexport type CommunicatorProviderProps = {\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n};\nexport type ConfigurationProviderProps = { configuration?: IntlayerConfig };\n"],"mappings":"yVAYA,KAAM,CAAE,UAAWA,EAAAA,SAAiB,EAAE,CAEhC,OAAsD,CAC1D,eAAgB,CACd,GAAQ,eACR,GAAQ,UACR,GAAQ,OACT,CAAC,OAAO,QAAQ,CACjB,eAAgB,EAAS,IAAW,CAC9B,OAAO,OAAW,KACH,OAAO,OAAS,OAAO,MAE1C,OAAO,QAAQ,YAAY,EAAS,EAAO,CAC3C,OAAO,YAAY,EAAS,EAAO,GAEtC,EAOK,GAAgE,CACpE,WACA,cACI,CACJ,GAAM,CAAE,WAAYC,EAAAA,kBAAkB,CACtC,OAAO,EAAU,EAAW,GAGxB,GAAyD,CAC7D,WACA,cACI,CACJ,GAAM,CAAC,EAAY,IAAA,EAAA,EAAA,UAA0B,GAAM,CAMnD,OAJA,EAAA,EAAA,eAAgB,CACd,EAAc,OAAO,OAAS,OAAO,IAAI,EACxC,EAAE,CAAC,CAEC,EAAa,EAAW,GAWpB,GAA0D,CACrE,WACA,OAAO,SACP,cAAe,EACf,YAAa,EACb,eAAgB,KACZ,CACJ,IAAM,GAAA,EAAA,EAAA,QAA+C,KAAK,CAC1D,AAUE,EAAW,UAAU,IAAIC,EAAAA,mBAAmB,CAC1C,OACA,UAVA,GAAqB,EACjB,CACE,eAAgB,GAAwB,CAAC,IAAI,CAC7C,cAAe,EACV,GAAY,EAAkB,EAAQ,CACvC,GAA6B,CAAC,cACnC,CACD,GAA6B,CAIjC,cAAe,GAAcF,EAAAA,QAC9B,CAAC,CAEJ,IAAM,EAAU,EAAW,QAmB3B,OAjBA,EAAA,EAAA,iBACE,EAAA,EAAA,yBAAwB,CACxB,EAAQ,OAAO,KACF,EAAQ,MAAM,EAC1B,CAAC,EAAQ,CAAC,EAaN,EAAA,EAAA,KAACG,EAAAA,oBAAD,CAA8B,mBAVnC,IAAS,SACP,GAEA,EAAA,EAAA,KAAC,EAAD,CAAqB,SAAU,YAC7B,EAAA,EAAA,KAAC,EAAD,CAA4B,SAAU,EACnC,WAC0B,CAAA,CACT,CAAA,CAGmD,CAAA"}
1
+ {"version":3,"file":"EditorProvider.cjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["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"],"mappings":"sGAGa,GAEP,CAAE,eACN,EAAA,WAAW,CAEJ"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/IntlayerProvider.cjs`);let t=require(`@intlayer/editor/isEnabled`),n=require(`preact/hooks`);const r=()=>{let{locale:r}=(0,n.useContext)(e.IntlayerClientContext),i=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(t.isEnabled)return import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();i.current=t,r&&t.currentLocale.set(r)}),()=>{i.current=null,import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}},[]),(0,n.useEffect)(()=>{!r||!i.current||i.current.currentLocale.set(r)},[r])};exports.useEditor=r;
2
+ //# sourceMappingURL=useEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.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 (!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"],"mappings":"wOAWA,MAAa,MAAkB,CAC7B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAC9C,GAAA,EAAA,EAAA,QAA+C,KAAK,EAE1D,EAAA,EAAA,eAAgB,CACTC,KAAAA,UASL,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,EAEN,EAAA,EAAA,eAAgB,CACV,CAAC,GAAU,CAAC,EAAW,SAE3B,EAAW,QAAQ,cAAc,IAAI,EAAiB,EACrD,CAAC,EAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../editor/useEditedContentRenderer.cjs`),t=require(`./HTMLProvider.cjs`);let n=require(`@intlayer/core/interpreter`),r=require(`preact`),i=require(`@intlayer/core/transpiler`);const a=(()=>{let e={};for(let t of i.HTML_TAGS)e[t]=({children:e,...n})=>(0,r.h)(t,n,e);return e})(),o=(e,{components:t}={})=>{let i={...a,...t};return(0,r.h)(r.Fragment,null,(0,n.getHTML)(e,Object.fromEntries(Object.entries(i).filter(([,e])=>e).map(([e,t])=>[e,e=>(0,r.h)(t,e)]))))},s=({components:e}={})=>{let n=t.useHTMLContext();return t=>o(t,{components:{...n?.components,...e}})},c=({children:t=``,html:n,components:r,dictionaryKey:i,keyPath:a})=>{let o=s({components:r}),c=t||n||``,l=e.useEditedContentRenderer({dictionaryKey:i,keyPath:a,children:c});return o(i&&a&&typeof l==`string`?l:c)};exports.HTMLRenderer=c,exports.defaultHTMLComponents=a,exports.renderHTML=o,exports.useHTMLRenderer=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./HTMLProvider.cjs`);let t=require(`@intlayer/core/interpreter`),n=require(`preact`),r=require(`@intlayer/core/transpiler`);const i=(()=>{let e={};for(let t of r.HTML_TAGS)e[t]=({children:e,...r})=>(0,n.h)(t,r,e);return e})(),a=(e,{components:r}={})=>{let a={...i,...r};return(0,n.h)(n.Fragment,null,(0,t.getHTML)(e,Object.fromEntries(Object.entries(a).filter(([,e])=>e).map(([e,t])=>[e,e=>(0,n.h)(t,e)]))))},o=({components:t}={})=>{let n=e.useHTMLContext();return e=>a(e,{components:{...n?.components,...t}})},s=({children:e=``,html:t,components:n})=>o({components:n})(e||t||``);exports.HTMLRenderer=s,exports.defaultHTMLComponents=i,exports.renderHTML=a,exports.useHTMLRenderer=o;
2
2
  //# sourceMappingURL=HTMLRenderer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.cjs","names":["HTML_TAGS","Fragment","useHTMLContext","useEditedContentRenderer"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport { HTML_TAGS } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\n/**\n * Type for Preact HTML tag components.\n */\ntype HTMLTagComponent = (props: {\n children?: any;\n [key: string]: any;\n}) => JSX.Element;\n\nconst createDefaultHTMLComponents = (): Record<string, HTMLTagComponent> => {\n const components: Record<string, HTMLTagComponent> = {};\n\n for (const tag of HTML_TAGS) {\n components[tag] = ({ children, ...props }) =>\n h(tag as any, props, children);\n }\n\n return components;\n};\n\nexport const defaultHTMLComponents = createDefaultHTMLComponents();\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components }: RenderHTMLProps = {}\n): JSX.Element => {\n const mergedComponents = {\n ...defaultHTMLComponents,\n ...components,\n };\n\n // Wrap all components to ensure they are rendered via Preact's h\n const wrappedComponents = Object.fromEntries(\n Object.entries(mergedComponents)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n return h(Fragment, null, getHTML(content, wrappedComponents));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n dictionaryKey,\n keyPath,\n}) => {\n const render = useHTMLRenderer({ components: components });\n const content = children || html || '';\n\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey: dictionaryKey!,\n keyPath: keyPath!,\n children: content,\n });\n\n const contentToRender =\n dictionaryKey && keyPath && typeof editedContentContext === 'string'\n ? editedContentContext\n : content;\n\n return render(contentToRender);\n};\n"],"mappings":"iTA2BA,MAAa,OAX+D,CAC1E,IAAM,EAA+C,EAAE,CAEvD,IAAK,IAAM,KAAOA,EAAAA,UAChB,EAAW,IAAQ,CAAE,WAAU,GAAG,MAAA,EAAA,EAAA,GAC9B,EAAY,EAAO,EAAS,CAGlC,OAAO,KAGyD,CAgBrD,GACX,EACA,CAAE,cAAgC,EAAE,GACpB,CAChB,IAAM,EAAmB,CACvB,GAAG,EACH,GAAG,EACJ,CAYD,OAAA,EAAA,EAAA,GAASC,EAAAA,SAAU,MAAA,EAAA,EAAA,SAAc,EATP,OAAO,YAC/B,OAAO,QAAQ,EAAiB,CAC7B,QAAQ,EAAG,KAAe,EAAU,CACpC,KAAK,CAAC,EAAK,KAAe,CACzB,EACC,IAAA,EAAA,EAAA,GAAiB,EAAkB,EAAM,CAC3C,CAAC,CACL,CAE2D,CAAC,EASlD,GAAmB,CAAE,cAAgC,EAAE,GAAK,CACvE,IAAM,EAAUC,EAAAA,gBAAgB,CAEhC,MAAQ,IACC,EAAW,EAAS,CACzB,WAAY,CACV,GAAG,GAAS,WACZ,GAAG,EACJ,CACF,CAAC,EAwBO,GAAsD,CACjE,WAAW,GACX,OACA,aACA,gBACA,aACI,CACJ,IAAM,EAAS,EAAgB,CAAc,aAAY,CAAC,CACpD,EAAU,GAAY,GAAQ,GAE9B,EAAuBC,EAAAA,yBAAyB,CACrC,gBACN,UACT,SAAU,EACX,CAAC,CAOF,OAAO,EAJL,GAAiB,GAAW,OAAO,GAAyB,SACxD,EACA,EAEwB"}
1
+ {"version":3,"file":"HTMLRenderer.cjs","names":["HTML_TAGS","Fragment","useHTMLContext"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport { HTML_TAGS } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\n/**\n * Type for Preact HTML tag components.\n */\ntype HTMLTagComponent = (props: {\n children?: any;\n [key: string]: any;\n}) => JSX.Element;\n\nconst createDefaultHTMLComponents = (): Record<string, HTMLTagComponent> => {\n const components: Record<string, HTMLTagComponent> = {};\n\n for (const tag of HTML_TAGS) {\n components[tag] = ({ children, ...props }) =>\n h(tag as any, props, children);\n }\n\n return components;\n};\n\nexport const defaultHTMLComponents = createDefaultHTMLComponents();\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components }: RenderHTMLProps = {}\n): JSX.Element => {\n const mergedComponents = {\n ...defaultHTMLComponents,\n ...components,\n };\n\n // Wrap all components to ensure they are rendered via Preact's h\n const wrappedComponents = Object.fromEntries(\n Object.entries(mergedComponents)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n return h(Fragment, null, getHTML(content, wrappedComponents));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components: components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":"6PA0BA,MAAa,OAX+D,CAC1E,IAAM,EAA+C,EAAE,CAEvD,IAAK,IAAM,KAAOA,EAAAA,UAChB,EAAW,IAAQ,CAAE,WAAU,GAAG,MAAA,EAAA,EAAA,GAC9B,EAAY,EAAO,EAAS,CAGlC,OAAO,KAGyD,CAgBrD,GACX,EACA,CAAE,cAAgC,EAAE,GACpB,CAChB,IAAM,EAAmB,CACvB,GAAG,EACH,GAAG,EACJ,CAYD,OAAA,EAAA,EAAA,GAASC,EAAAA,SAAU,MAAA,EAAA,EAAA,SAAc,EATP,OAAO,YAC/B,OAAO,QAAQ,EAAiB,CAC7B,QAAQ,EAAG,KAAe,EAAU,CACpC,KAAK,CAAC,EAAK,KAAe,CACzB,EACC,IAAA,EAAA,EAAA,GAAiB,EAAkB,EAAM,CAC3C,CAAC,CACL,CAE2D,CAAC,EASlD,GAAmB,CAAE,cAAgC,EAAE,GAAK,CACvE,IAAM,EAAUC,EAAAA,gBAAgB,CAEhC,MAAQ,IACC,EAAW,EAAS,CACzB,WAAY,CACV,GAAG,GAAS,WACZ,GAAG,EACJ,CACF,CAAC,EAwBO,GAAsD,CACjE,WAAW,GACX,OACA,gBAEe,EAAgB,CAAc,aAAY,CAAC,CAC1C,GAAY,GAAQ,GAEd"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client/useLocaleStorage.cjs`),t=require(`./client/IntlayerProvider.cjs`),n=require(`./client/format/useIntl.cjs`),r=require(`./client/t.cjs`),i=require(`./getDictionary.cjs`),a=require(`./client/useDictionary.cjs`),o=require(`./client/useDictionaryAsync.cjs`),s=require(`./client/useLoadDynamic.cjs`),c=require(`./client/useDictionaryDynamic.cjs`),l=require(`./getIntlayer.cjs`),u=require(`./client/useIntlayer.cjs`),d=require(`./client/useLocale.cjs`),f=require(`./client/useLocaleBase.cjs`),p=require(`./html/HTMLProvider.cjs`),m=require(`./html/HTMLRenderer.cjs`),h=require(`./markdown/runtime.cjs`),g=require(`./markdown/compiler.cjs`),_=require(`./markdown/MarkdownProvider.cjs`),v=require(`./markdown/MarkdownRenderer.cjs`),y=require(`./plugins.cjs`);exports.HTMLProvider=p.HTMLProvider,exports.HTMLRenderer=m.HTMLRenderer,exports.IntlayerClientContext=t.IntlayerClientContext,exports.IntlayerProvider=t.IntlayerProvider,exports.IntlayerProviderContent=t.IntlayerProviderContent,exports.MarkdownProvider=_.MarkdownProvider,exports.MarkdownRenderer=v.MarkdownRenderer,exports.compileMarkdown=g.compileMarkdown,exports.getDictionary=i.getDictionary,exports.getIntlayer=l.getIntlayer,exports.htmlPlugin=y.htmlPlugin,exports.intlayerNodePlugins=y.intlayerNodePlugins,exports.localeCookie=e.localeCookie,exports.markdownPlugin=y.markdownPlugin,exports.markdownStringPlugin=y.markdownStringPlugin,exports.preactNodePlugins=y.preactNodePlugins,exports.preactRuntime=h,exports.renderHTML=m.renderHTML,exports.renderMarkdown=v.renderMarkdown,exports.setLocaleCookie=e.setLocaleCookie,exports.setLocaleInStorage=e.setLocaleInStorage,exports.t=r.t,exports.useDictionary=a.useDictionary,exports.useDictionaryAsync=o.useDictionaryAsync,exports.useDictionaryDynamic=c.useDictionaryDynamic,exports.useHTMLRenderer=m.useHTMLRenderer,exports.useIntl=n.useIntl,exports.useIntlayer=u.useIntlayer,exports.useIntlayerContext=t.useIntlayerContext,exports.useLoadDynamic=s.useLoadDynamic,exports.useLocale=d.useLocale,exports.useLocaleBase=f.useLocaleBase,exports.useLocaleCookie=e.useLocaleCookie,exports.useLocaleStorage=e.useLocaleStorage,exports.useMarkdownRenderer=v.useMarkdownRenderer;
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,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/useLocale.cjs`),t=require(`../editor/useEditedContentRenderer.cjs`),n=require(`./MarkdownProvider.cjs`);let r=require(`@intlayer/core/markdown`),i=require(`@intlayer/core/dictionaryManipulator`);const a=e=>{let{dictionaryKey:r,keyPath:i,children:a,options:o,components:s}=e,c=n.useMarkdownContext(),l=c?.renderMarkdown??(e=>e),u=t.useEditedContentRenderer({dictionaryKey:r,keyPath:i,children:a});return l(typeof u==`string`?u:a,o,{...c?.components??{},...s??{}})},o=({dictionaryKey:n,keyPath:a,children:o,metadataKeyPath:s})=>{let c=t.useEditedContentRenderer({dictionaryKey:n,keyPath:a,children:o}),{locale:l}=e.useLocale();return(0,i.getContentNodeByKeyPath)((0,r.getMarkdownMetadata)(c),s,l)};exports.MarkdownMetadataRenderer=o,exports.MarkdownRendererPlugin=a;
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;
2
2
  //# sourceMappingURL=MarkdownRendererPlugin.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useEditedContentRenderer","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["import { 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 { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\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 { dictionaryKey, keyPath, children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n const contentToRender =\n typeof editedContentContext === 'string' ? editedContentContext : children;\n\n return renderMarkdown(contentToRender, 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> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ComponentChildren => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(editedContentContext as string);\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":"8UAuBA,MAAa,EAER,GAA6B,CAChC,GAAM,CAAE,gBAAe,UAAS,WAAU,UAAS,cAAe,EAC5D,EAAUA,EAAAA,oBAAoB,CAC9B,EAAiB,GAAS,iBAAoB,GAAO,GACrD,EAAuBC,EAAAA,yBAAyB,CACpD,gBACA,UACA,WACD,CAAC,CAKF,OAAO,EAFL,OAAO,GAAyB,SAAW,EAAuB,EAE7B,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOS,GAER,CACH,gBACA,UACA,WACA,qBACuB,CACvB,IAAM,EAAuBA,EAAAA,yBAAyB,CACpD,gBACA,UACA,WACD,CAAC,CACI,CAAE,OAAQ,GAAkBC,EAAAA,WAAW,CAU7C,OAAA,EAAA,EAAA,0BAAA,EAAA,EAAA,qBARqC,EAA+B,CAIlE,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":"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,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./editor/ContentSelectorWrapper.cjs`),n=require(`./editor/useEditedContentRenderer.cjs`),r=require(`./html/HTMLRenderer.cjs`),i=require(`./IntlayerNode.cjs`),a=require(`./markdown/MarkdownRendererPlugin.cjs`),o=require(`./preactElement/renderPreactElement.cjs`);let s=require(`@intlayer/config/built`);s=e.__toESM(s);let c=require(`@intlayer/core/interpreter`),l=require(`@intlayer/core/markdown`),u=require(`@intlayer/types/nodeType`),d=require(`preact`),f=require(`preact/jsx-runtime`);const p={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:r,...a})=>i.renderIntlayerNode({...a,value:a.children,children:s.default?.editor.enabled?(0,d.createElement)(t.ContentSelectorRenderer,{...a,key:a.children},(0,f.jsx)(n.EditedContentRenderer,{...a,children:a.children})):a.children})},m={id:`preact-node-plugin`,canHandle:e=>typeof e==`object`&&e.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...r})=>i.renderIntlayerNode({...r,value:`[[preact-element]]`,children:s.default?.editor.enabled?(0,f.jsx)(t.ContentSelectorRenderer,{...r,children:o.renderPreactElement(e)}):o.renderPreactElement(e)})},h=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,g=(e,t)=>{if(!Object.values(t).some(h))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,d.h)(d.Fragment,null,...n.map((e,t)=>(0,d.h)(d.Fragment,{key:t},e)))},_={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===u.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:u.NodeType.Insertion}],i=e[u.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=g(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},v={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let{plugins:o,...s}=n,c=r((0,l.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>i.renderIntlayerNode({...r,value:n,children:(0,f.jsx)(t.ContentSelectorRenderer,{...s,children:(0,f.jsx)(a.MarkdownMetadataRenderer,{...s,metadataKeyPath:r.keyPath,children:e})})})}],dictionaryKey:s.dictionaryKey,keyPath:[]}),u=r=>i.renderIntlayerNode({...n,value:e,children:(0,f.jsx)(t.ContentSelectorRenderer,{...s,children:(0,f.jsx)(a.MarkdownRendererPlugin,{...s,components:r,children:e})}),additionalProps:{metadata:c}}),d=u();return new Proxy(d,{get(t,n){return n===`value`?e:n===`metadata`?c:n===`use`?e=>u(e):Reflect.get(t,n)}})}},y={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===u.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:u.NodeType.Markdown}],i=e[u.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[v,...t.plugins??[]]})}},b={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===u.NodeType.HTML,transform:(e,t)=>{let n=e[u.NodeType.HTML];e.tags;let{plugins:i,...a}=t,o=e=>(0,d.h)(r.HTMLRenderer,{...a,html:n,userComponents:e}),s=o();return new Proxy(s,{get(e,t){return t===`value`?n:t===`use`?e=>o(e):Reflect.get(e,t)}})}},x=(e,t=!0)=>[(0,c.translationPlugin)(e??s.default.internationalization.defaultLocale,t?s.default.internationalization.defaultLocale:void 0),c.enumerationPlugin,c.conditionPlugin,(0,c.nestedPlugin)(e??s.default.internationalization.defaultLocale),c.filePlugin,c.genderPlugin,p,m,_,y,b];exports.getPlugins=x,exports.htmlPlugin=b,exports.insertionPlugin=_,exports.intlayerNodePlugins=p,exports.markdownPlugin=y,exports.markdownStringPlugin=v,exports.preactNodePlugins=m;
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;
2
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorRenderer","EditedContentRenderer","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 { ContentSelectorRenderer } from './editor';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\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 <ContentSelectorRenderer {...rest} key={rest.children}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\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 <ContentSelectorRenderer {...rest}>\n {renderPreactElement(node)}\n </ContentSelectorRenderer>\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 <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\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 <ContentSelectorRenderer {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelectorRenderer>\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
+ {"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":"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"}
@@ -1,2 +1,2 @@
1
- import{IntlayerEditorProvider as e}from"../editor/IntlayerEditorProvider.mjs";import{useCrossFrameState as t}from"../editor/useCrossFrameState.mjs";import{localeInStorage as n,setLocaleInStorage as r}from"./useLocaleStorage.mjs";import i from"@intlayer/config/built";import{createContext as a}from"preact";import{MessageKey as o}from"@intlayer/editor";import{useContext as s,useEffect as c}from"preact/hooks";import{localeResolver as l}from"@intlayer/core/localization";import{jsx as u}from"preact/jsx-runtime";const d=a({locale:n??i?.internationalization?.defaultLocale,setLocale:()=>null,disableEditor:!1}),f=()=>s(d),p=({locale:e,defaultLocale:a,children:s,setLocale:f,disableEditor:p,isCookieEnabled:m})=>{let{internationalization:h}=i??{},{defaultLocale:g,locales:_}=h??{},v=e??n??a??g,[y,b]=t(o.INTLAYER_CURRENT_LOCALE,v);c(()=>{e&&e!==y&&b(e)},[e,y,b]);let x=f??(e=>{if(y.toString()!==e.toString()){if(!_?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}b(e),r(e,m??!0)}}),S=l(e??y);return u(d.Provider,{value:{locale:S,setLocale:x,disableEditor:p,isCookieEnabled:m},children:s})},m=t=>u(e,{children:u(p,{...t})});export{d as IntlayerClientContext,m as IntlayerProvider,p as IntlayerProviderContent,f as useIntlayerContext};
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
2
  //# sourceMappingURL=IntlayerProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport { MessageKey } from '@intlayer/editor';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect } from 'preact/hooks';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { useCrossFrameState } from '../editor/useCrossFrameState';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n disableEditor: false,\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 disableEditor?: boolean;\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 disableEditor,\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] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\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 disableEditor,\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 props\n) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":"+fAwBA,MAAa,EAAwB,EAA6B,CAChE,OAAQ,GAAmB,GAAe,sBAAsB,cAChE,cAAiB,KACjB,cAAe,GAChB,CAAC,CAKW,MAA2B,EAAW,EAAsB,CAc5D,GAER,CACH,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,gBACA,qBACI,CACJ,GAAM,CAAE,wBAAyB,GAAiB,EAAE,CAC9C,CAAE,cAAe,EAAqB,QAAS,GACnD,GAAwB,EAAE,CAEtB,EACJ,GAAc,GAAmB,GAAqB,EAElD,CAAC,EAAe,GAAoB,EACxC,EAAW,wBACX,EACD,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,gBACA,kBACD,CAEA,WAC8B,CAAA,EAwBxB,EACX,GAEA,EAAC,EAAD,CAAA,SACE,EAAC,EAAD,CAAyB,GAAI,EAAS,CAAA,CACf,CAAA"}
1
+ {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["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":"mZAqBA,MAAa,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 +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{useIntl as u}from"./format/useIntl.mjs";import{t as d}from"./t.mjs";import{useDictionary as f}from"./useDictionary.mjs";import{useDictionaryAsync as p}from"./useDictionaryAsync.mjs";import{useLoadDynamic as m}from"./useLoadDynamic.mjs";import{useDictionaryDynamic as h}from"./useDictionaryDynamic.mjs";import{useIntlayer as g}from"./useIntlayer.mjs";import{useLocale as _}from"./useLocale.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,d as t,f as useDictionary,p as useDictionaryAsync,h as useDictionaryDynamic,u as useIntl,g as useIntlayer,l as useIntlayerContext,m as useLoadDynamic,_ as useLocale,v as useLocaleBase,i as useLocaleCookie,a as useLocaleStorage};
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,2 +1,2 @@
1
- import{LocaleStorage as e,getLocaleFromStorage as t,setLocaleInStorage as n}from"@intlayer/core/utils";import{useMemo as r}from"preact/hooks";import{localeStorageOptions as i}from"@intlayer/core/localization";const a=t(i),o=a,s=(e,t)=>n(e,{...i,isCookieEnabled:t}),c=s,l=t=>r(()=>e({...i,isCookieEnabled:t}),[t]),u=e=>{let t=l(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};export{o as localeCookie,a as localeInStorage,c as setLocaleCookie,s as setLocaleInStorage,u as useLocaleCookie,l as useLocaleStorage};
1
+ import{useMemo as e}from"preact/hooks";import{localeStorageOptions as t}from"@intlayer/core/localization";import{LocaleStorage as n,getLocaleFromStorage as r,setLocaleInStorage as i}from"@intlayer/core/utils";const a=r(t),o=a,s=(e,n)=>i(e,{...t,isCookieEnabled:n}),c=s,l=r=>e(()=>n({...t,isCookieEnabled:r}),[r]),u=e=>{let t=l(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};export{o as localeCookie,a as localeInStorage,c as setLocaleCookie,s as setLocaleInStorage,u as useLocaleCookie,l as useLocaleStorage};
2
2
  //# sourceMappingURL=useLocaleStorage.mjs.map
@@ -0,0 +1,2 @@
1
+ import{isEnabled as e}from"@intlayer/editor/isEnabled";import{useEffect as t}from"preact/hooks";import{jsx as n}from"preact/jsx-runtime";const r=({children:r,dictionaryKey:i,keyPath:a})=>(t(()=>{!e||typeof window>`u`||import(`@intlayer/editor`).then(({defineIntlayerElements:e})=>{e()})},[e]),e?n(`intlayer-content-selector-wrapper`,{"key-path":JSON.stringify(a),"dictionary-key":i,children:r}):r);export{r as ContentSelector};
2
+ //# sourceMappingURL=ContentSelector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (!isEnabled || typeof window === 'undefined') return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (!isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":"yIAoBA,MAAa,GAER,CAAE,WAAU,gBAAe,cAC9B,MAAgB,CACV,CAAC,GAAa,OAAO,OAAW,KACpC,OAAO,oBAAoB,MAAM,CAAE,4BAA6B,CAC9D,GAAwB,EACxB,EACD,CAAC,EAAU,CAAC,CAEV,EAKH,EAAC,oCAAD,CACE,WAAU,KAAK,UAAU,EAAQ,CACjC,iBAAgB,EAEf,WACiC,CAAA,CAT7B"}
@@ -1,2 +1,2 @@
1
- import{EditorStateProvider as e}from"./EditorStateContext.mjs";import{useEditorEnabled as t}from"./EditorEnabledContext.mjs";import n from"@intlayer/config/built";import{EditorStateManager as r,defineIntlayerElements as i}from"@intlayer/editor";import{useEffect as a,useRef as o,useState as s}from"preact/hooks";import{jsx as c}from"preact/jsx-runtime";const{editor:l}=n??{},u=()=>({allowedOrigins:[l?.applicationURL,l?.editorURL,l?.cmsURL].filter(Boolean),postMessageFn:(e,t)=>{typeof window>`u`||window.self!==window.top&&(window.parent?.postMessage(e,t),window.postMessage(e,t))}}),d=({children:e,fallback:n})=>{let{enabled:r}=t();return r?e:n},f=({children:e,fallback:t})=>{let[n,r]=s(!1);return a(()=>{r(window.self!==window.top)},[]),n?e:t},p=({children:t,mode:s=`client`,configuration:l,postMessage:p,allowedOrigins:m})=>{let h=o(null);h.current||=new r({mode:s,messenger:p||m?{allowedOrigins:m??[`*`],postMessageFn:p?e=>p(e):u().postMessageFn}:u(),configuration:l??n});let g=h.current;return a(()=>(i(),g.start(),()=>g.stop()),[g]),c(e,{manager:g,children:s===`editor`?t:c(f,{fallback:t,children:c(d,{fallback:t,children:t})})})};export{p as EditorProvider};
1
+ import{useEditor as e}from"./useEditor.mjs";const t=({children:t})=>(e(),t);export{t as EditorProvider};
2
2
  //# sourceMappingURL=EditorProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n defineIntlayerElements,\n EditorStateManager,\n type MessengerConfig,\n} from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useEditorEnabled } from './EditorEnabledContext';\nimport { EditorStateProvider } from './EditorStateContext';\n\nconst { editor } = configuration ?? {};\n\nconst buildDefaultMessengerConfig = (): MessengerConfig => ({\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ].filter(Boolean) as string[],\n postMessageFn: (payload, origin) => {\n if (typeof window === 'undefined') return;\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n window.parent?.postMessage(payload, origin);\n window.postMessage(payload, origin);\n },\n});\n\ntype FallbackProps = {\n fallback: ComponentChildren;\n children?: ComponentChildren;\n};\n\nconst EditorEnabledCheckRenderer: FunctionComponent<FallbackProps> = ({\n children,\n fallback,\n}) => {\n const { enabled } = useEditorEnabled();\n return enabled ? children : fallback;\n};\n\nconst IframeCheckRenderer: FunctionComponent<FallbackProps> = ({\n children,\n fallback,\n}) => {\n const [isInIframe, setIsInIframe] = useState(false);\n\n useEffect(() => {\n setIsInIframe(window.self !== window.top);\n }, []);\n\n return isInIframe ? children : fallback;\n};\n\nexport type EditorProviderProps = {\n mode?: 'editor' | 'client';\n configuration?: IntlayerConfig;\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n children?: ComponentChildren;\n};\n\nexport const EditorProvider: FunctionComponent<EditorProviderProps> = ({\n children,\n mode = 'client',\n configuration: configProp,\n postMessage: customPostMessage,\n allowedOrigins: customAllowedOrigins,\n}) => {\n const managerRef = useRef<EditorStateManager | null>(null);\n if (!managerRef.current) {\n const messengerConfig: MessengerConfig =\n customPostMessage || customAllowedOrigins\n ? {\n allowedOrigins: customAllowedOrigins ?? ['*'],\n postMessageFn: customPostMessage\n ? (payload) => customPostMessage(payload)\n : buildDefaultMessengerConfig().postMessageFn,\n }\n : buildDefaultMessengerConfig();\n managerRef.current = new EditorStateManager({\n mode,\n messenger: messengerConfig,\n configuration: configProp ?? configuration,\n });\n }\n const manager = managerRef.current;\n\n useEffect(() => {\n defineIntlayerElements();\n manager.start();\n return () => manager.stop();\n }, [manager]);\n\n const content =\n mode === 'editor' ? (\n children\n ) : (\n <IframeCheckRenderer fallback={children}>\n <EditorEnabledCheckRenderer fallback={children}>\n {children}\n </EditorEnabledCheckRenderer>\n </IframeCheckRenderer>\n );\n\n return <EditorStateProvider manager={manager}>{content}</EditorStateProvider>;\n};\n\n// Backward-compat types\nexport type CommunicatorProviderProps = {\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n};\nexport type ConfigurationProviderProps = { configuration?: IntlayerConfig };\n"],"mappings":"iWAYA,KAAM,CAAE,UAAW,GAAiB,EAAE,CAEhC,OAAsD,CAC1D,eAAgB,CACd,GAAQ,eACR,GAAQ,UACR,GAAQ,OACT,CAAC,OAAO,QAAQ,CACjB,eAAgB,EAAS,IAAW,CAC9B,OAAO,OAAW,KACH,OAAO,OAAS,OAAO,MAE1C,OAAO,QAAQ,YAAY,EAAS,EAAO,CAC3C,OAAO,YAAY,EAAS,EAAO,GAEtC,EAOK,GAAgE,CACpE,WACA,cACI,CACJ,GAAM,CAAE,WAAY,GAAkB,CACtC,OAAO,EAAU,EAAW,GAGxB,GAAyD,CAC7D,WACA,cACI,CACJ,GAAM,CAAC,EAAY,GAAiB,EAAS,GAAM,CAMnD,OAJA,MAAgB,CACd,EAAc,OAAO,OAAS,OAAO,IAAI,EACxC,EAAE,CAAC,CAEC,EAAa,EAAW,GAWpB,GAA0D,CACrE,WACA,OAAO,SACP,cAAe,EACf,YAAa,EACb,eAAgB,KACZ,CACJ,IAAM,EAAa,EAAkC,KAAK,CAC1D,AAUE,EAAW,UAAU,IAAI,EAAmB,CAC1C,OACA,UAVA,GAAqB,EACjB,CACE,eAAgB,GAAwB,CAAC,IAAI,CAC7C,cAAe,EACV,GAAY,EAAkB,EAAQ,CACvC,GAA6B,CAAC,cACnC,CACD,GAA6B,CAIjC,cAAe,GAAc,EAC9B,CAAC,CAEJ,IAAM,EAAU,EAAW,QAmB3B,OAjBA,OACE,GAAwB,CACxB,EAAQ,OAAO,KACF,EAAQ,MAAM,EAC1B,CAAC,EAAQ,CAAC,CAaN,EAAC,EAAD,CAA8B,mBAVnC,IAAS,SACP,EAEA,EAAC,EAAD,CAAqB,SAAU,WAC7B,EAAC,EAAD,CAA4B,SAAU,EACnC,WAC0B,CAAA,CACT,CAAA,CAGmD,CAAA"}
1
+ {"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["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"],"mappings":"4CAGA,MAAa,GAEP,CAAE,eACN,GAAW,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{IntlayerClientContext as e}from"../client/IntlayerProvider.mjs";import{isEnabled as t}from"@intlayer/editor/isEnabled";import{useContext as n,useEffect as r,useRef as i}from"preact/hooks";const a=()=>{let{locale:a}=n(e),o=i(null);r(()=>{if(t)return import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();o.current=t,a&&t.currentLocale.set(a)}),()=>{o.current=null,import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}},[]),r(()=>{!a||!o.current||o.current.currentLocale.set(a)},[a])};export{a as useEditor};
2
+ //# sourceMappingURL=useEditor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.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 (!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"],"mappings":"mMAWA,MAAa,MAAkB,CAC7B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAC9C,EAAa,EAAkC,KAAK,CAE1D,MAAgB,CACT,KASL,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"}
@@ -1,2 +1,2 @@
1
- import{useEditedContentRenderer as e}from"../editor/useEditedContentRenderer.mjs";import{useHTMLContext as t}from"./HTMLProvider.mjs";import{getHTML as n}from"@intlayer/core/interpreter";import{Fragment as r,h as i}from"preact";import{HTML_TAGS as a}from"@intlayer/core/transpiler";const o=(()=>{let e={};for(let t of a)e[t]=({children:e,...n})=>i(t,n,e);return e})(),s=(e,{components:t}={})=>{let a={...o,...t};return i(r,null,n(e,Object.fromEntries(Object.entries(a).filter(([,e])=>e).map(([e,t])=>[e,e=>i(t,e)]))))},c=({components:e}={})=>{let n=t();return t=>s(t,{components:{...n?.components,...e}})},l=({children:t=``,html:n,components:r,dictionaryKey:i,keyPath:a})=>{let o=c({components:r}),s=t||n||``,l=e({dictionaryKey:i,keyPath:a,children:s});return o(i&&a&&typeof l==`string`?l:s)};export{l as HTMLRenderer,o as defaultHTMLComponents,s as renderHTML,c as useHTMLRenderer};
1
+ import{useHTMLContext as e}from"./HTMLProvider.mjs";import{getHTML as t}from"@intlayer/core/interpreter";import{Fragment as n,h as r}from"preact";import{HTML_TAGS as i}from"@intlayer/core/transpiler";const a=(()=>{let e={};for(let t of i)e[t]=({children:e,...n})=>r(t,n,e);return e})(),o=(e,{components:i}={})=>{let o={...a,...i};return r(n,null,t(e,Object.fromEntries(Object.entries(o).filter(([,e])=>e).map(([e,t])=>[e,e=>r(t,e)]))))},s=({components:t}={})=>{let n=e();return e=>o(e,{components:{...n?.components,...t}})},c=({children:e=``,html:t,components:n})=>s({components:n})(e||t||``);export{c as HTMLRenderer,a as defaultHTMLComponents,o as renderHTML,s as useHTMLRenderer};
2
2
  //# sourceMappingURL=HTMLRenderer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport { HTML_TAGS } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\n/**\n * Type for Preact HTML tag components.\n */\ntype HTMLTagComponent = (props: {\n children?: any;\n [key: string]: any;\n}) => JSX.Element;\n\nconst createDefaultHTMLComponents = (): Record<string, HTMLTagComponent> => {\n const components: Record<string, HTMLTagComponent> = {};\n\n for (const tag of HTML_TAGS) {\n components[tag] = ({ children, ...props }) =>\n h(tag as any, props, children);\n }\n\n return components;\n};\n\nexport const defaultHTMLComponents = createDefaultHTMLComponents();\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components }: RenderHTMLProps = {}\n): JSX.Element => {\n const mergedComponents = {\n ...defaultHTMLComponents,\n ...components,\n };\n\n // Wrap all components to ensure they are rendered via Preact's h\n const wrappedComponents = Object.fromEntries(\n Object.entries(mergedComponents)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n return h(Fragment, null, getHTML(content, wrappedComponents));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n dictionaryKey,\n keyPath,\n}) => {\n const render = useHTMLRenderer({ components: components });\n const content = children || html || '';\n\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey: dictionaryKey!,\n keyPath: keyPath!,\n children: content,\n });\n\n const contentToRender =\n dictionaryKey && keyPath && typeof editedContentContext === 'string'\n ? editedContentContext\n : content;\n\n return render(contentToRender);\n};\n"],"mappings":"0RA2BA,MAAa,OAX+D,CAC1E,IAAM,EAA+C,EAAE,CAEvD,IAAK,IAAM,KAAO,EAChB,EAAW,IAAQ,CAAE,WAAU,GAAG,KAChC,EAAE,EAAY,EAAO,EAAS,CAGlC,OAAO,KAGyD,CAgBrD,GACX,EACA,CAAE,cAAgC,EAAE,GACpB,CAChB,IAAM,EAAmB,CACvB,GAAG,EACH,GAAG,EACJ,CAYD,OAAO,EAAE,EAAU,KAAM,EAAQ,EATP,OAAO,YAC/B,OAAO,QAAQ,EAAiB,CAC7B,QAAQ,EAAG,KAAe,EAAU,CACpC,KAAK,CAAC,EAAK,KAAe,CACzB,EACC,GAAe,EAAE,EAAkB,EAAM,CAC3C,CAAC,CACL,CAE2D,CAAC,EASlD,GAAmB,CAAE,cAAgC,EAAE,GAAK,CACvE,IAAM,EAAU,GAAgB,CAEhC,MAAQ,IACC,EAAW,EAAS,CACzB,WAAY,CACV,GAAG,GAAS,WACZ,GAAG,EACJ,CACF,CAAC,EAwBO,GAAsD,CACjE,WAAW,GACX,OACA,aACA,gBACA,aACI,CACJ,IAAM,EAAS,EAAgB,CAAc,aAAY,CAAC,CACpD,EAAU,GAAY,GAAQ,GAE9B,EAAuB,EAAyB,CACrC,gBACN,UACT,SAAU,EACX,CAAC,CAOF,OAAO,EAJL,GAAiB,GAAW,OAAO,GAAyB,SACxD,EACA,EAEwB"}
1
+ {"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport { HTML_TAGS } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\n/**\n * Type for Preact HTML tag components.\n */\ntype HTMLTagComponent = (props: {\n children?: any;\n [key: string]: any;\n}) => JSX.Element;\n\nconst createDefaultHTMLComponents = (): Record<string, HTMLTagComponent> => {\n const components: Record<string, HTMLTagComponent> = {};\n\n for (const tag of HTML_TAGS) {\n components[tag] = ({ children, ...props }) =>\n h(tag as any, props, children);\n }\n\n return components;\n};\n\nexport const defaultHTMLComponents = createDefaultHTMLComponents();\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components }: RenderHTMLProps = {}\n): JSX.Element => {\n const mergedComponents = {\n ...defaultHTMLComponents,\n ...components,\n };\n\n // Wrap all components to ensure they are rendered via Preact's h\n const wrappedComponents = Object.fromEntries(\n Object.entries(mergedComponents)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n return h(Fragment, null, getHTML(content, wrappedComponents));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components: components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":"wMA0BA,MAAa,OAX+D,CAC1E,IAAM,EAA+C,EAAE,CAEvD,IAAK,IAAM,KAAO,EAChB,EAAW,IAAQ,CAAE,WAAU,GAAG,KAChC,EAAE,EAAY,EAAO,EAAS,CAGlC,OAAO,KAGyD,CAgBrD,GACX,EACA,CAAE,cAAgC,EAAE,GACpB,CAChB,IAAM,EAAmB,CACvB,GAAG,EACH,GAAG,EACJ,CAYD,OAAO,EAAE,EAAU,KAAM,EAAQ,EATP,OAAO,YAC/B,OAAO,QAAQ,EAAiB,CAC7B,QAAQ,EAAG,KAAe,EAAU,CACpC,KAAK,CAAC,EAAK,KAAe,CACzB,EACC,GAAe,EAAE,EAAkB,EAAM,CAC3C,CAAC,CACL,CAE2D,CAAC,EASlD,GAAmB,CAAE,cAAgC,EAAE,GAAK,CACvE,IAAM,EAAU,GAAgB,CAEhC,MAAQ,IACC,EAAW,EAAS,CACzB,WAAY,CACV,GAAG,GAAS,WACZ,GAAG,EACJ,CACF,CAAC,EAwBO,GAAsD,CACjE,WAAW,GACX,OACA,gBAEe,EAAgB,CAAc,aAAY,CAAC,CAC1C,GAAY,GAAQ,GAEd"}
@@ -1 +1 @@
1
- import{localeCookie as e,setLocaleCookie as t,setLocaleInStorage as n,useLocaleCookie as r,useLocaleStorage as i}from"./client/useLocaleStorage.mjs";import{IntlayerClientContext as a,IntlayerProvider as o,IntlayerProviderContent as s,useIntlayerContext as c}from"./client/IntlayerProvider.mjs";import{useIntl as l}from"./client/format/useIntl.mjs";import{t as u}from"./client/t.mjs";import{getDictionary as d}from"./getDictionary.mjs";import{useDictionary as f}from"./client/useDictionary.mjs";import{useDictionaryAsync as p}from"./client/useDictionaryAsync.mjs";import{useLoadDynamic as m}from"./client/useLoadDynamic.mjs";import{useDictionaryDynamic as h}from"./client/useDictionaryDynamic.mjs";import{getIntlayer as g}from"./getIntlayer.mjs";import{useIntlayer as _}from"./client/useIntlayer.mjs";import{useLocale as v}from"./client/useLocale.mjs";import{useLocaleBase as y}from"./client/useLocaleBase.mjs";import{HTMLProvider as b}from"./html/HTMLProvider.mjs";import{HTMLRenderer as x,renderHTML as S,useHTMLRenderer as C}from"./html/HTMLRenderer.mjs";import w from"./markdown/runtime.mjs";import{compileMarkdown as T}from"./markdown/compiler.mjs";import{MarkdownProvider as E}from"./markdown/MarkdownProvider.mjs";import{MarkdownRenderer as D,renderMarkdown as O,useMarkdownRenderer as k}from"./markdown/MarkdownRenderer.mjs";import{htmlPlugin as A,intlayerNodePlugins as j,markdownPlugin as M,markdownStringPlugin as N,preactNodePlugins as P}from"./plugins.mjs";export{b as HTMLProvider,x as HTMLRenderer,a as IntlayerClientContext,o as IntlayerProvider,s as IntlayerProviderContent,E as MarkdownProvider,D as MarkdownRenderer,T as compileMarkdown,d as getDictionary,g as getIntlayer,A as htmlPlugin,j as intlayerNodePlugins,e as localeCookie,M as markdownPlugin,N as markdownStringPlugin,P as preactNodePlugins,w as preactRuntime,S as renderHTML,O as renderMarkdown,t as setLocaleCookie,n as setLocaleInStorage,u as t,f as useDictionary,p as useDictionaryAsync,h as useDictionaryDynamic,C as useHTMLRenderer,l as useIntl,_ as useIntlayer,c as useIntlayerContext,m as useLoadDynamic,v as useLocale,y as useLocaleBase,r as useLocaleCookie,i as useLocaleStorage,k as useMarkdownRenderer};
1
+ import{HTMLProvider as e}from"./html/HTMLProvider.mjs";import{HTMLRenderer as t,renderHTML as n,useHTMLRenderer as r}from"./html/HTMLRenderer.mjs";import i from"./markdown/runtime.mjs";import{compileMarkdown as a}from"./markdown/compiler.mjs";import{MarkdownProvider as o}from"./markdown/MarkdownProvider.mjs";import{MarkdownRenderer as s,renderMarkdown as c,useMarkdownRenderer as l}from"./markdown/MarkdownRenderer.mjs";import{localeCookie as u,setLocaleCookie as d,setLocaleInStorage as f,useLocaleCookie as p,useLocaleStorage as m}from"./client/useLocaleStorage.mjs";import{IntlayerClientContext as h,IntlayerProvider as g,IntlayerProviderContent as _,useIntlayerContext as v}from"./client/IntlayerProvider.mjs";import{useLocale as y}from"./client/useLocale.mjs";import{htmlPlugin as b,intlayerNodePlugins as x,markdownPlugin as S,markdownStringPlugin as C,preactNodePlugins as w}from"./plugins.mjs";import{getIntlayer as T}from"./getIntlayer.mjs";import{getDictionary as E}from"./getDictionary.mjs";import{useIntl as D}from"./client/format/useIntl.mjs";import{t as O}from"./client/t.mjs";import{useDictionary as k}from"./client/useDictionary.mjs";import{useDictionaryAsync as A}from"./client/useDictionaryAsync.mjs";import{useLoadDynamic as j}from"./client/useLoadDynamic.mjs";import{useDictionaryDynamic as M}from"./client/useDictionaryDynamic.mjs";import{useIntlayer as N}from"./client/useIntlayer.mjs";import{useLocaleBase as P}from"./client/useLocaleBase.mjs";export{e as HTMLProvider,t as HTMLRenderer,h as IntlayerClientContext,g as IntlayerProvider,_ as IntlayerProviderContent,o as MarkdownProvider,s as MarkdownRenderer,a as compileMarkdown,E as getDictionary,T as getIntlayer,b as htmlPlugin,x as intlayerNodePlugins,u as localeCookie,S as markdownPlugin,C as markdownStringPlugin,w as preactNodePlugins,i as preactRuntime,n as renderHTML,c as renderMarkdown,d as setLocaleCookie,f as setLocaleInStorage,O as t,k as useDictionary,A as useDictionaryAsync,M as useDictionaryDynamic,r as useHTMLRenderer,D as useIntl,N as useIntlayer,v as useIntlayerContext,j as useLoadDynamic,y as useLocale,P as useLocaleBase,p as useLocaleCookie,m as useLocaleStorage,l as useMarkdownRenderer};
@@ -1,2 +1,2 @@
1
- import{useLocale as e}from"../client/useLocale.mjs";import{useEditedContentRenderer as t}from"../editor/useEditedContentRenderer.mjs";import{useMarkdownContext as n}from"./MarkdownProvider.mjs";import{getMarkdownMetadata as r}from"@intlayer/core/markdown";import{getContentNodeByKeyPath as i}from"@intlayer/core/dictionaryManipulator";const a=e=>{let{dictionaryKey:r,keyPath:i,children:a,options:o,components:s}=e,c=n(),l=c?.renderMarkdown??(e=>e),u=t({dictionaryKey:r,keyPath:i,children:a});return l(typeof u==`string`?u:a,o,{...c?.components??{},...s??{}})},o=({dictionaryKey:n,keyPath:a,children:o,metadataKeyPath:s})=>{let c=t({dictionaryKey:n,keyPath:a,children:o}),{locale:l}=e();return i(r(c),s,l)};export{o as MarkdownMetadataRenderer,a as MarkdownRendererPlugin};
1
+ "use client";import{useMarkdownContext as e}from"./MarkdownProvider.mjs";import{useLocale as t}from"../client/useLocale.mjs";import{getMarkdownMetadata as n}from"@intlayer/core/markdown";import{getContentNodeByKeyPath as r}from"@intlayer/core/dictionaryManipulator";const i=t=>{let{children:n,options:r,components:i}=t,a=e();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},a=({children:e,metadataKeyPath:i})=>{let{locale:a}=t();return r(n(e),i,a)};export{a as MarkdownMetadataRenderer,i as MarkdownRendererPlugin};
2
2
  //# sourceMappingURL=MarkdownRendererPlugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["import { 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 { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\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 { dictionaryKey, keyPath, children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n const contentToRender =\n typeof editedContentContext === 'string' ? editedContentContext : children;\n\n return renderMarkdown(contentToRender, 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> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ComponentChildren => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(editedContentContext as string);\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":"+UAuBA,MAAa,EAER,GAA6B,CAChC,GAAM,CAAE,gBAAe,UAAS,WAAU,UAAS,cAAe,EAC5D,EAAU,GAAoB,CAC9B,EAAiB,GAAS,iBAAoB,GAAO,GACrD,EAAuB,EAAyB,CACpD,gBACA,UACA,WACD,CAAC,CAKF,OAAO,EAFL,OAAO,GAAyB,SAAW,EAAuB,EAE7B,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOS,GAER,CACH,gBACA,UACA,WACA,qBACuB,CACvB,IAAM,EAAuB,EAAyB,CACpD,gBACA,UACA,WACD,CAAC,CACI,CAAE,OAAQ,GAAkB,GAAW,CAU7C,OANmB,EAFF,EAAoB,EAA+B,CAIlE,EACA,EACD"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"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":"0QAwBA,MAAa,EAER,GAA6B,CAChC,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAU,GAAoB,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,GAAkB,GAAW,CAU7C,OANmB,EAFF,EAAoB,EAAS,CAI5C,EACA,EACD"}
@@ -1,2 +1,2 @@
1
- import{ContentSelectorRenderer as e}from"./editor/ContentSelectorWrapper.mjs";import{EditedContentRenderer as t}from"./editor/useEditedContentRenderer.mjs";import{HTMLRenderer as n}from"./html/HTMLRenderer.mjs";import{renderIntlayerNode as r}from"./IntlayerNode.mjs";import{MarkdownMetadataRenderer as i,MarkdownRendererPlugin as a}from"./markdown/MarkdownRendererPlugin.mjs";import{renderPreactElement as o}from"./preactElement/renderPreactElement.mjs";import s from"@intlayer/config/built";import{conditionPlugin as c,enumerationPlugin as l,filePlugin as u,genderPlugin as d,nestedPlugin as f,translationPlugin as p}from"@intlayer/core/interpreter";import{getMarkdownMetadata as m}from"@intlayer/core/markdown";import{NodeType as h}from"@intlayer/types/nodeType";import{Fragment as g,createElement as _,h as v}from"preact";import{jsx as y}from"preact/jsx-runtime";const b={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(n,{plugins:i,...a})=>r({...a,value:a.children,children:s?.editor.enabled?_(e,{...a,key:a.children},y(t,{...a,children:a.children})):a.children})},x={id:`preact-node-plugin`,canHandle:e=>typeof e==`object`&&e.props!==void 0&&e.key!==void 0,transform:(t,{plugins:n,...i})=>r({...i,value:`[[preact-element]]`,children:s?.editor.enabled?y(e,{...i,children:o(t)}):o(t)})},S=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,C=(e,t)=>{if(!Object.values(t).some(S))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)),v(g,null,...n.map((e,t)=>v(g,{key:t},e)))},w={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.Insertion}],i=e[h.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=C(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},T={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(t,n,o)=>{let{plugins:s,...c}=n,l=o(m(t),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,a)=>r({...a,value:n,children:y(e,{...c,children:y(i,{...c,metadataKeyPath:a.keyPath,children:t})})})}],dictionaryKey:c.dictionaryKey,keyPath:[]}),u=i=>r({...n,value:t,children:y(e,{...c,children:y(a,{...c,components:i,children:t})}),additionalProps:{metadata:l}}),d=u();return new Proxy(d,{get(e,n){return n===`value`?t:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(e,n)}})}},E={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.Markdown}],i=e[h.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[T,...t.plugins??[]]})}},D={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.HTML,transform:(e,t)=>{let r=e[h.HTML];e.tags;let{plugins:i,...a}=t,o=e=>v(n,{...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)}})}},O=(e,t=!0)=>[p(e??s.internationalization.defaultLocale,t?s.internationalization.defaultLocale:void 0),l,c,f(e??s.internationalization.defaultLocale),u,d,b,x,w,E,D];export{O as getPlugins,D as htmlPlugin,w as insertionPlugin,b as intlayerNodePlugins,E as markdownPlugin,T as markdownStringPlugin,x as preactNodePlugins};
1
+ import{ContentSelector as e}from"./editor/ContentSelector.mjs";import{HTMLRenderer as t}from"./html/HTMLRenderer.mjs";import{renderIntlayerNode as n}from"./IntlayerNode.mjs";import{MarkdownMetadataRenderer as r,MarkdownRendererPlugin as i}from"./markdown/MarkdownRendererPlugin.mjs";import{renderPreactElement as a}from"./preactElement/renderPreactElement.mjs";import o from"@intlayer/config/built";import{conditionPlugin as s,enumerationPlugin as c,filePlugin as l,genderPlugin as u,nestedPlugin as d,translationPlugin as f}from"@intlayer/core/interpreter";import{getMarkdownMetadata as p}from"@intlayer/core/markdown";import{NodeType as m}from"@intlayer/types/nodeType";import{Fragment as h,createElement as g,h as _}from"preact";import{jsx as v}from"preact/jsx-runtime";const y={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(t,{plugins:r,...i})=>n({...i,value:i.children,children:o?.editor.enabled?g(e,{...i,key:i.children},i.children):i.children})},b={id:`preact-node-plugin`,canHandle:e=>typeof e==`object`&&e.props!==void 0&&e.key!==void 0,transform:(t,{plugins:r,...i})=>n({...i,value:`[[preact-element]]`,children:o?.editor.enabled?v(e,{...i,children:a(t)}):a(t)})},x=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,S=(e,t)=>{if(!Object.values(t).some(x))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)),_(h,null,...n.map((e,t)=>_(h,{key:t},e)))},C={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===m.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:m.Insertion}],i=e[m.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=S(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},w={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(t,a,o)=>{let{plugins:s,...c}=a,l=o(p(t),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(i,a)=>n({...a,value:i,children:v(e,{...c,children:v(r,{...c,metadataKeyPath:a.keyPath,children:t})})})}],dictionaryKey:c.dictionaryKey,keyPath:[]}),u=r=>n({...a,value:t,children:v(e,{...c,children:v(i,{...c,components:r,children:t})}),additionalProps:{metadata:l}}),d=u();return new Proxy(d,{get(e,n){return n===`value`?t:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(e,n)}})}},T={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===m.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:m.Markdown}],i=e[m.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[w,...t.plugins??[]]})}},E={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===m.HTML,transform:(e,n)=>{let r=e[m.HTML];e.tags;let{plugins:i,...a}=n,o=e=>_(t,{...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)}})}},D=(e,t=!0)=>[f(e??o.internationalization.defaultLocale,t?o.internationalization.defaultLocale:void 0),c,s,d(e??o.internationalization.defaultLocale),l,u,y,b,C,T,E];export{D as getPlugins,E as htmlPlugin,C as insertionPlugin,y as intlayerNodePlugins,T as markdownPlugin,w as markdownStringPlugin,b as preactNodePlugins};
2
2
  //# sourceMappingURL=plugins.mjs.map