react-intlayer 8.4.1 → 8.4.3

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 (28) hide show
  1. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  2. package/dist/cjs/editor/useEditor.cjs +1 -1
  3. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  4. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -1
  5. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  6. package/dist/cjs/markdown/index.cjs +1 -1
  7. package/dist/cjs/plugins.cjs +1 -1
  8. package/dist/cjs/plugins.cjs.map +1 -1
  9. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  10. package/dist/esm/editor/useEditor.mjs +1 -1
  11. package/dist/esm/editor/useEditor.mjs.map +1 -1
  12. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -1
  13. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  14. package/dist/esm/markdown/index.mjs +1 -1
  15. package/dist/esm/plugins.mjs +1 -1
  16. package/dist/esm/plugins.mjs.map +1 -1
  17. package/dist/types/client/useRewriteURL.d.ts.map +1 -1
  18. package/dist/types/markdown/MarkdownRendererPlugin.d.ts +1 -5
  19. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  20. package/dist/types/markdown/index.d.ts +2 -2
  21. package/dist/types/plugins.d.ts.map +1 -1
  22. package/package.json +9 -9
  23. package/dist/cjs/markdown/MarkdownMetadataRendererInternal.cjs +0 -2
  24. package/dist/cjs/markdown/MarkdownMetadataRendererInternal.cjs.map +0 -1
  25. package/dist/esm/markdown/MarkdownMetadataRendererInternal.mjs +0 -2
  26. package/dist/esm/markdown/MarkdownMetadataRendererInternal.mjs.map +0 -1
  27. package/dist/types/markdown/MarkdownMetadataRendererInternal.d.ts +0 -16
  28. package/dist/types/markdown/MarkdownMetadataRendererInternal.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useRewriteURL.cjs","names":["useLocale","configuration"],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = configuration?.routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":"yRAyBA,MAAa,MAA4B,CACvC,GAAM,CAAE,UAAWA,EAAAA,WAAW,CACxB,EAAUC,EAAAA,SAAe,SAAS,SAExC,EAAA,EAAA,eAAgB,CACd,GAAI,OAAO,OAAW,KAAe,CAAC,EAAS,OAE/C,IAAM,EAAW,OAAO,SAAS,SAC3B,GAAA,EAAA,EAAA,gBAA4B,EAAU,EAAQ,EAAQ,CAExD,GAAc,IAAe,GAC/B,OAAO,QAAQ,aACb,OAAO,QAAQ,MACf,GACA,EAAa,OAAO,SAAS,OAAS,OAAO,SAAS,KACvD,EAEF,CAAC,EAAQ,EAAQ,CAAC"}
1
+ {"version":3,"file":"useRewriteURL.cjs","names":["useLocale","configuration"],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = configuration?.routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale as Locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":"yRA0BA,MAAa,MAA4B,CACvC,GAAM,CAAE,UAAWA,EAAAA,WAAW,CACxB,EAAUC,EAAAA,SAAe,SAAS,SAExC,EAAA,EAAA,eAAgB,CACd,GAAI,OAAO,OAAW,KAAe,CAAC,EAAS,OAE/C,IAAM,EAAW,OAAO,SAAS,SAC3B,GAAA,EAAA,EAAA,gBAA4B,EAAU,EAAkB,EAAQ,CAElE,GAAc,IAAe,GAC/B,OAAO,QAAQ,aACb,OAAO,QAAQ,MACf,GACA,EAAa,OAAO,SAAS,OAAS,OAAO,SAAS,KACvD,EAEF,CAAC,EAAQ,EAAQ,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/editor/isEnabled`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext),i=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(n.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,t.useEffect)(()=>{!r||!i.current||i.current.currentLocale.set(r)},[r])};exports.useEditor=r;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../client/IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/editor/isEnabled`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext),i=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.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,t.useEffect)(()=>{!r||!i.current||i.current.currentLocale.set(r)},[r])};exports.useEditor=r;
2
2
  //# sourceMappingURL=useEditor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes 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":"8OAaA,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
+ {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext);\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":"8OAaA,MAAa,MAAkB,CAC7B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAC9C,GAAA,EAAA,EAAA,QAA+C,KAAK,EAE1D,EAAA,EAAA,eAAgB,CACV,aAAQ,IAAI,0BAA4B,SAAW,CAACC,EAAAA,WASxD,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
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);let r=require(`react`),i=require(`react/jsx-runtime`);const a=e=>{let{children:n,options:r,components:i}=e,a=t.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=(0,r.lazy)(()=>Promise.resolve().then(()=>require(`./MarkdownMetadataRendererInternal.cjs`)).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:t}=n.default??{},a=t?.enabled??!1;return typeof window<`u`&&a?(0,i.jsx)(r.Suspense,{fallback:null,children:(0,i.jsx)(o,{...e})}):null};exports.MarkdownMetadataRenderer=s,exports.MarkdownRendererPlugin=a;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./MarkdownProvider.cjs`),t=t=>{let{children:n,options:r,components:i}=t,a=e.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})};exports.MarkdownRendererPlugin=t;
2
2
  //# sourceMappingURL=MarkdownRendererPlugin.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","configuration","Suspense"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { type FC, lazy, type ReactNode, Suspense } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\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: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nconst DynamicMarkdownMetadataRendererInternal = lazy(() =>\n import('./MarkdownMetadataRendererInternal').then((module) => ({\n default: module.MarkdownMetadataRendererInternal,\n }))\n);\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = (\n props\n): ReactNode => {\n const { editor } = configuration ?? {};\n const isEnabled = editor?.enabled ?? false;\n\n if (typeof window !== 'undefined' && isEnabled) {\n return (\n <Suspense fallback={null}>\n <DynamicMarkdownMetadataRendererInternal {...props} />\n </Suspense>\n );\n }\n\n return null;\n};\n"],"mappings":"sRAqBA,MAAa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAUA,EAAAA,oBAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOE,GAAA,EAAA,EAAA,UAAA,QAAA,SAAA,CAAA,SAAA,QACJ,yCAAA,CAAA,CAA6C,KAAM,IAAY,CAC7D,QAAS,EAAO,iCACjB,EAAE,CACJ,CAEY,EACX,GACc,CACd,GAAM,CAAE,UAAWC,EAAAA,SAAiB,EAAE,CAChC,EAAY,GAAQ,SAAW,GAUrC,OARI,OAAO,OAAW,KAAe,GAEjC,EAAA,EAAA,KAACC,EAAAA,SAAD,CAAU,SAAU,eAClB,EAAA,EAAA,KAAC,EAAD,CAAyC,GAAI,EAAS,CAAA,CAC7C,CAAA,CAIR"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { FC, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\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: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n"],"mappings":"0HAoBa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAUA,EAAAA,oBAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./processor.cjs`),t=require(`./MarkdownProvider.cjs`),n=require(`./MarkdownRenderer.cjs`),r=require(`./MarkdownRendererPlugin.cjs`),i=require(`./runtime.cjs`);let a=require(`@intlayer/core/markdown`);exports.LegacyMarkdownRenderer=e.LegacyMarkdownRenderer,exports.MarkdownMetadataRenderer=r.MarkdownMetadataRenderer,exports.MarkdownProvider=t.MarkdownProvider,exports.MarkdownRenderer=n.MarkdownRenderer,exports.MarkdownRendererPlugin=r.MarkdownRendererPlugin,exports.RuleType=a.RuleType,exports.compile=e.compile,exports.compileMarkdown=e.compileMarkdown,exports.compiler=e.compiler,exports.createReactRuntime=i.createReactRuntime,exports.reactRuntime=i,exports.renderMarkdown=n.renderMarkdown,exports.sanitizer=a.sanitizer,exports.slugify=a.slugify,exports.useMarkdownContext=t.useMarkdownContext,exports.useMarkdownRenderer=n.useMarkdownRenderer;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./processor.cjs`),t=require(`./MarkdownProvider.cjs`),n=require(`./MarkdownRenderer.cjs`),r=require(`./MarkdownRendererPlugin.cjs`),i=require(`./runtime.cjs`);let a=require(`@intlayer/core/markdown`);exports.LegacyMarkdownRenderer=e.LegacyMarkdownRenderer,exports.MarkdownProvider=t.MarkdownProvider,exports.MarkdownRenderer=n.MarkdownRenderer,exports.MarkdownRendererPlugin=r.MarkdownRendererPlugin,exports.RuleType=a.RuleType,exports.compile=e.compile,exports.compileMarkdown=e.compileMarkdown,exports.compiler=e.compiler,exports.createReactRuntime=i.createReactRuntime,exports.reactRuntime=i,exports.renderMarkdown=n.renderMarkdown,exports.sanitizer=a.sanitizer,exports.slugify=a.slugify,exports.useMarkdownContext=t.useMarkdownContext,exports.useMarkdownRenderer=n.useMarkdownRenderer;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./editor/ContentSelector.cjs`),n=require(`./html/HTMLRendererPlugin.cjs`),r=require(`./IntlayerNode.cjs`),i=require(`./markdown/MarkdownRendererPlugin.cjs`),a=require(`./reactElement/renderReactElement.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(`react`),d=require(`react/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,d.jsx)(t.ContentSelector,{...i,children:i.children}):i.children})},p={id:`react-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:`[[react-element]]`,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:a.renderReactElement(e)}):a.renderReactElement(e)})},m=(e,t)=>{let n=(0,s.splitInsertionTemplate)(e,t);return n.isSimple?n.parts:(0,u.createElement)(u.Fragment,null,...n.parts.map((e,t)=>(0,u.createElement)(u.Fragment,{key:t},e)))},h={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=m(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[l.NodeType.Enumeration,l.NodeType.Condition].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},g={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,r){return n===`value`?e:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(t,n,r)}})}},_={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:[g,...t.plugins??[]]})}},v={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.HTML,transform:(e,t)=>{let r=e[l.NodeType.HTML],{plugins:i,...a}=t,o=e=>(0,u.createElement)(n.HTMLRendererPlugin,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t,n){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t,n)}})}},y=(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,h,_,v];exports.getPlugins=y,exports.htmlPlugin=v,exports.insertionPlugin=h,exports.intlayerNodePlugins=f,exports.markdownPlugin=_,exports.markdownStringPlugin=g,exports.reactNodePlugins=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./editor/ContentSelector.cjs`),n=require(`./html/HTMLRendererPlugin.cjs`),r=require(`./IntlayerNode.cjs`),i=require(`./markdown/MarkdownRendererPlugin.cjs`),a=require(`./reactElement/renderReactElement.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(`react`),d=require(`react/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,d.jsx)(t.ContentSelector,{...i,children:i.children}):i.children})},p={id:`react-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:`[[react-element]]`,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:a.renderReactElement(e)}):a.renderReactElement(e)})},m=(e,t)=>{let n=(0,s.splitInsertionTemplate)(e,t);return n.isSimple?n.parts:(0,u.createElement)(u.Fragment,null,...n.parts.map((e,t)=>(0,u.createElement)(u.Fragment,{key:t},e)))},h={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=m(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[l.NodeType.Enumeration,l.NodeType.Condition].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},g={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,a)=>{let{plugins:s,...l}=n,u=a((0,c.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,i)=>r.renderIntlayerNode({...i,value:n,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:e}):e})}],dictionaryKey:l.dictionaryKey,keyPath:[]}),f=a=>r.renderIntlayerNode({...n,value:e,children:o.default.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e})}):(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e}),additionalProps:{metadata:u}}),p=f();return new Proxy(p,{get(t,n,r){return n===`value`?e:n===`metadata`?u:n===`use`?e=>f(e):Reflect.get(t,n,r)}})}},_={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:[g,...t.plugins??[]]})}},v={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.HTML,transform:(e,t)=>{let r=e[l.NodeType.HTML],{plugins:i,...a}=t,o=e=>(0,u.createElement)(n.HTMLRendererPlugin,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t,n){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t,n)}})}},y=(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,h,_,v];exports.getPlugins=y,exports.htmlPlugin=v,exports.insertionPlugin=h,exports.intlayerNodePlugins=f,exports.markdownPlugin=_,exports.markdownStringPlugin=g,exports.reactNodePlugins=p;
2
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeType","MarkdownMetadataRenderer","MarkdownRendererPlugin","HTMLRendererPlugin","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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\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}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-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: '[[react-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\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', {}>) => ReactNode;\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?: HTMLComponents) =>\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 unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 reactNodePlugins,\n insertionPlugin,\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,CAU1B,OATI,IAAS,QACJ,EAGL,IAAS,MAEH,GAAoC,EAAO,EAAe,CAG7D,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC,EAEL,CAuCY,GACX,EACA,EAAoB,KACN,yBAEZ,GAAUP,EAAAA,QAAc,qBAAqB,cAC7C,EAAWA,EAAAA,QAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACDQ,EAAAA,kBACAC,EAAAA,mCACa,GAAUT,EAAAA,QAAc,qBAAqB,cAAc,CACxEU,EAAAA,WACAC,EAAAA,aACA,EACA,EACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeType","MarkdownRendererPlugin","HTMLRendererPlugin","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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\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}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-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: '[[react-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\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?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ) : (\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"kjBA+CA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WACE,EACA,CACE,UACA,GAAG,KAGLA,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,EAAK,SACZ,SAAUC,EAAAA,SAAe,OAAO,SAC9B,EAAA,EAAA,KAACC,EAAAA,gBAAD,CAAiB,GAAI,WAAO,EAAK,SA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C,EAAAA,mCACa,GAAUR,EAAAA,QAAc,qBAAqB,cAAc,CACxES,EAAAA,WACAC,EAAAA,aACA,EACA,EACA,EACA,EACA,EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRewriteURL.mjs","names":[],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = configuration?.routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":"8LAyBA,MAAa,MAA4B,CACvC,GAAM,CAAE,UAAW,GAAW,CACxB,EAAU,GAAe,SAAS,QAExC,MAAgB,CACd,GAAI,OAAO,OAAW,KAAe,CAAC,EAAS,OAE/C,IAAM,EAAW,OAAO,SAAS,SAC3B,EAAa,EAAe,EAAU,EAAQ,EAAQ,CAExD,GAAc,IAAe,GAC/B,OAAO,QAAQ,aACb,OAAO,QAAQ,MACf,GACA,EAAa,OAAO,SAAS,OAAS,OAAO,SAAS,KACvD,EAEF,CAAC,EAAQ,EAAQ,CAAC"}
1
+ {"version":3,"file":"useRewriteURL.mjs","names":[],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = configuration?.routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale as Locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":"8LA0BA,MAAa,MAA4B,CACvC,GAAM,CAAE,UAAW,GAAW,CACxB,EAAU,GAAe,SAAS,QAExC,MAAgB,CACd,GAAI,OAAO,OAAW,KAAe,CAAC,EAAS,OAE/C,IAAM,EAAW,OAAO,SAAS,SAC3B,EAAa,EAAe,EAAU,EAAkB,EAAQ,CAElE,GAAc,IAAe,GAC/B,OAAO,QAAQ,aACb,OAAO,QAAQ,MACf,GACA,EAAa,OAAO,SAAS,OAAS,OAAO,SAAS,KACvD,EAEF,CAAC,EAAQ,EAAQ,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";import{IntlayerClientContext as e}from"../client/IntlayerProvider.mjs";import{useContext as t,useEffect as n,useRef as r}from"react";import{isEnabled as i}from"@intlayer/editor/isEnabled";const a=()=>{let{locale:a}=t(e),o=r(null);n(()=>{if(i)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()})}},[]),n(()=>{!a||!o.current||o.current.currentLocale.set(a)},[a])};export{a as useEditor};
1
+ "use client";import{IntlayerClientContext as e}from"../client/IntlayerProvider.mjs";import{useContext as t,useEffect as n,useRef as r}from"react";import{isEnabled as i}from"@intlayer/editor/isEnabled";const a=()=>{let{locale:a}=t(e),o=r(null);n(()=>{if(!(process.env.INTLAYER_EDITOR_ENABLED===`false`||!i))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()})}},[]),n(()=>{!a||!o.current||o.current.currentLocale.set(a)},[a])};export{a as useEditor};
2
2
  //# sourceMappingURL=useEditor.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes 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":"yMAaA,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
+ {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext);\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":"yMAaA,MAAa,MAAkB,CAC7B,GAAM,CAAE,UAAW,EAAW,EAAsB,CAC9C,EAAa,EAAkC,KAAK,CAE1D,MAAgB,CACV,aAAQ,IAAI,0BAA4B,SAAW,CAAC,GASxD,OAPA,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAClC,EAAW,QAAU,EAEjB,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,KAEW,CACX,EAAW,QAAU,KACrB,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,GAEH,EAAE,CAAC,CAEN,MAAgB,CACV,CAAC,GAAU,CAAC,EAAW,SAE3B,EAAW,QAAQ,cAAc,IAAI,EAAiB,EACrD,CAAC,EAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";import{useMarkdownContext as e}from"./MarkdownProvider.mjs";import t from"@intlayer/config/built";import{Suspense as n,lazy as r}from"react";import{jsx as i}from"react/jsx-runtime";const a=t=>{let{children:n,options:r,components:i}=t,a=e();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=r(()=>import(`./MarkdownMetadataRendererInternal.mjs`).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:r}=t??{},a=r?.enabled??!1;return typeof window<`u`&&a?i(n,{fallback:null,children:i(o,{...e})}):null};export{s as MarkdownMetadataRenderer,a as MarkdownRendererPlugin};
1
+ "use client";import{useMarkdownContext as e}from"./MarkdownProvider.mjs";const t=t=>{let{children:n,options:r,components:i}=t,a=e();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})};export{t as MarkdownRendererPlugin};
2
2
  //# sourceMappingURL=MarkdownRendererPlugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { type FC, lazy, type ReactNode, Suspense } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\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: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nconst DynamicMarkdownMetadataRendererInternal = lazy(() =>\n import('./MarkdownMetadataRendererInternal').then((module) => ({\n default: module.MarkdownMetadataRendererInternal,\n }))\n);\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = (\n props\n): ReactNode => {\n const { editor } = configuration ?? {};\n const isEnabled = editor?.enabled ?? false;\n\n if (typeof window !== 'undefined' && isEnabled) {\n return (\n <Suspense fallback={null}>\n <DynamicMarkdownMetadataRendererInternal {...props} />\n </Suspense>\n );\n }\n\n return null;\n};\n"],"mappings":"kMAqBA,MAAa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAU,GAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOE,EAA0C,MAC9C,OAAO,0CAAsC,KAAM,IAAY,CAC7D,QAAS,EAAO,iCACjB,EAAE,CACJ,CAEY,EACX,GACc,CACd,GAAM,CAAE,UAAW,GAAiB,EAAE,CAChC,EAAY,GAAQ,SAAW,GAUrC,OARI,OAAO,OAAW,KAAe,EAEjC,EAAC,EAAD,CAAU,SAAU,cAClB,EAAC,EAAD,CAAyC,GAAI,EAAS,CAAA,CAC7C,CAAA,CAIR"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { FC, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\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: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n"],"mappings":"yEAoBA,MAAa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAU,GAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC"}
@@ -1 +1 @@
1
- import{LegacyMarkdownRenderer as e,RuleType as t,compile as n,compileMarkdown as r,compiler as i,sanitizer as a,slugify as o}from"./processor.mjs";import{MarkdownProvider as s,useMarkdownContext as c}from"./MarkdownProvider.mjs";import{MarkdownRenderer as l,renderMarkdown as u,useMarkdownRenderer as d}from"./MarkdownRenderer.mjs";import{MarkdownMetadataRenderer as f,MarkdownRendererPlugin as p}from"./MarkdownRendererPlugin.mjs";import m,{createReactRuntime as h}from"./runtime.mjs";export{e as LegacyMarkdownRenderer,f as MarkdownMetadataRenderer,s as MarkdownProvider,l as MarkdownRenderer,p as MarkdownRendererPlugin,t as RuleType,n as compile,r as compileMarkdown,i as compiler,h as createReactRuntime,m as reactRuntime,u as renderMarkdown,a as sanitizer,o as slugify,c as useMarkdownContext,d as useMarkdownRenderer};
1
+ import{LegacyMarkdownRenderer as e,RuleType as t,compile as n,compileMarkdown as r,compiler as i,sanitizer as a,slugify as o}from"./processor.mjs";import{MarkdownProvider as s,useMarkdownContext as c}from"./MarkdownProvider.mjs";import{MarkdownRenderer as l,renderMarkdown as u,useMarkdownRenderer as d}from"./MarkdownRenderer.mjs";import{MarkdownRendererPlugin as f}from"./MarkdownRendererPlugin.mjs";import p,{createReactRuntime as m}from"./runtime.mjs";export{e as LegacyMarkdownRenderer,s as MarkdownProvider,l as MarkdownRenderer,f as MarkdownRendererPlugin,t as RuleType,n as compile,r as compileMarkdown,i as compiler,m as createReactRuntime,p as reactRuntime,u as renderMarkdown,a as sanitizer,o as slugify,c as useMarkdownContext,d as useMarkdownRenderer};
@@ -1,2 +1,2 @@
1
- import{ContentSelector as e}from"./editor/ContentSelector.mjs";import{HTMLRendererPlugin as t}from"./html/HTMLRendererPlugin.mjs";import{renderIntlayerNode as n}from"./IntlayerNode.mjs";import{MarkdownMetadataRenderer as r,MarkdownRendererPlugin as i}from"./markdown/MarkdownRendererPlugin.mjs";import{renderReactElement as a}from"./reactElement/renderReactElement.mjs";import o from"@intlayer/config/built";import{conditionPlugin as s,enumerationPlugin as c,filePlugin as l,genderPlugin as u,nestedPlugin as d,splitInsertionTemplate 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 _}from"react";import{jsx as v}from"react/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?v(e,{...i,children:i.children}):i.children})},b={id:`react-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0&&e.key!==void 0,transform:(t,{plugins:r,...i})=>n({...i,value:`[[react-element]]`,children:o?.editor.enabled?v(e,{...i,children:a(t)}):a(t)})},x=(e,t)=>{let n=f(e,t);return n.isSimple?n.parts:_(g,null,...n.parts.map((e,t)=>_(g,{key:t},e)))},S={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=x(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[h.Enumeration,h.Condition].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},C={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(t,a,o)=>{let{plugins:s,...c}=a,l=o(m(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,r){return n===`value`?t:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(e,n,r)}})}},w={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:[C,...t.plugins??[]]})}},T={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.HTML,transform:(e,n)=>{let r=e[h.HTML],{plugins:i,...a}=n,o=e=>_(t,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t,n){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t,n)}})}},E=(e,t=!0)=>[p(e??o.internationalization.defaultLocale,t?o.internationalization.defaultLocale:void 0),c,s,d(e??o.internationalization.defaultLocale),l,u,y,b,S,w,T];export{E as getPlugins,T as htmlPlugin,S as insertionPlugin,y as intlayerNodePlugins,w as markdownPlugin,C as markdownStringPlugin,b as reactNodePlugins};
1
+ import{ContentSelector as e}from"./editor/ContentSelector.mjs";import{HTMLRendererPlugin as t}from"./html/HTMLRendererPlugin.mjs";import{renderIntlayerNode as n}from"./IntlayerNode.mjs";import{MarkdownRendererPlugin as r}from"./markdown/MarkdownRendererPlugin.mjs";import{renderReactElement as i}from"./reactElement/renderReactElement.mjs";import a from"@intlayer/config/built";import{conditionPlugin as o,enumerationPlugin as s,filePlugin as c,genderPlugin as l,nestedPlugin as u,splitInsertionTemplate 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}from"react";import{jsx as _}from"react/jsx-runtime";const v={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:a?.editor.enabled?_(e,{...i,children:i.children}):i.children})},y={id:`react-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0&&e.key!==void 0,transform:(t,{plugins:r,...o})=>n({...o,value:`[[react-element]]`,children:a?.editor.enabled?_(e,{...o,children:i(t)}):i(t)})},b=(e,t)=>{let n=d(e,t);return n.isSimple?n.parts:g(h,null,...n.parts.map((e,t)=>g(h,{key:t},e)))},x={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=b(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[m.Enumeration,m.Condition].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},S={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(t,i,o)=>{let{plugins:s,...c}=i,l=o(p(t),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(r,i)=>n({...i,value:r,children:a?.editor.enabled?_(e,{...c,children:t}):t})}],dictionaryKey:c.dictionaryKey,keyPath:[]}),u=o=>n({...i,value:t,children:a.editor.enabled?_(e,{...c,children:_(r,{...c,components:o,children:t})}):_(r,{...c,components:o,children:t}),additionalProps:{metadata:l}}),d=u();return new Proxy(d,{get(e,n,r){return n===`value`?t:n===`metadata`?l:n===`use`?e=>u(e):Reflect.get(e,n,r)}})}},C={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:[S,...t.plugins??[]]})}},w={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===m.HTML,transform:(e,n)=>{let r=e[m.HTML],{plugins:i,...a}=n,o=e=>g(t,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t,n){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t,n)}})}},T=(e,t=!0)=>[f(e??a.internationalization.defaultLocale,t?a.internationalization.defaultLocale:void 0),s,o,u(e??a.internationalization.defaultLocale),c,l,v,y,x,C,w];export{T as getPlugins,w as htmlPlugin,x as insertionPlugin,v as intlayerNodePlugins,C as markdownPlugin,S as markdownStringPlugin,y as reactNodePlugins};
2
2
  //# sourceMappingURL=plugins.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\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}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-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: '[[react-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\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', {}>) => ReactNode;\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?: HTMLComponents) =>\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 unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"iyBA+CA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WACE,EACA,CACE,UACA,GAAG,KAGL,EAAmB,CACjB,GAAG,EACH,MAAO,EAAK,SACZ,SAAU,GAAe,OAAO,QAC9B,EAAC,EAAD,CAAiB,GAAI,WAAO,EAAK,SAA2B,CAAA,CAE5D,EAAK,SAER,CAAC,CACL,CAcY,EAA4B,CACvC,GAAI,oBACJ,UAAY,GACV,OAAO,GAAS,UACT,GAAM,QAAU,QAChB,EAAK,MAAQ,OAEtB,WACE,EACA,CACE,UACA,GAAG,KAGL,EAA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H,WACA,QAAS,EACT,QAAS,CAAC,EAAsB,GAAI,EAAM,SAAW,EAAE,CAAE,CAC1D,CAAC,EAEL,CA4BY,EAAsB,CACjC,GAAI,cACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAE1D,WAAY,EAA2B,IAAU,CAC/C,IAAM,EAAO,EAAK,EAAS,MACrB,CAAE,UAAS,GAAG,GAAS,EAGvB,EAAU,GACd,EAAc,EAAoB,CAAE,GAAG,EAAM,OAAM,iBAAgB,CAAC,CAEhE,EAAU,GAAQ,CAExB,OAAO,IAAI,MAAM,EAAS,CACxB,IAAI,EAAQ,EAAM,EAAU,CAU1B,OATI,IAAS,QACJ,EAGL,IAAS,MAEH,GAAoC,EAAO,EAAe,CAG7D,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC,EAEL,CAuCY,GACX,EACA,EAAoB,KACN,CACd,EACE,GAAU,EAAc,qBAAqB,cAC7C,EAAW,EAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACD,EACA,EACA,EAAa,GAAU,EAAc,qBAAqB,cAAc,CACxE,EACA,EACA,EACA,EACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\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}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-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: '[[react-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\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?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ) : (\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"mwBA+CA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY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;;;;;;;;;;;;;;;;;cAAa,aAAA"}
1
+ {"version":3,"file":"useRewriteURL.d.ts","names":[],"sources":["../../../src/client/useRewriteURL.ts"],"mappings":";;AA0BA;;;;;;;;;;;;;;;;;cAAa,aAAA"}
@@ -14,10 +14,6 @@ type MarkdownRendererPluginProps = {
14
14
  components?: HTMLComponents<'permissive', {}>;
15
15
  };
16
16
  declare const MarkdownRendererPlugin: FC<MarkdownRendererPluginProps>;
17
- type MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {
18
- metadataKeyPath: KeyPath[];
19
- };
20
- declare const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>;
21
17
  //#endregion
22
- export { MarkdownMetadataRenderer, MarkdownRendererPlugin };
18
+ export { MarkdownRendererPlugin };
23
19
  //# sourceMappingURL=MarkdownRendererPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;KAYK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,OAAA,GAAU,uBAAA;EACV,UAAA,GAAa,cAAA;AAAA;AAAA,cAGF,sBAAA,EAAwB,EAAA,CAAG,2BAAA;AAAA,KAcnC,6BAAA,GAAgC,2BAAA;EACnC,eAAA,EAAiB,OAAA;AAAA;AAAA,cASN,wBAAA,EAA0B,EAAA,CAAG,6BAAA"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;KAWK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,OAAA,GAAU,uBAAA;EACV,UAAA,GAAa,cAAA;AAAA;AAAA,cAGF,sBAAA,EAAwB,EAAA,CAAG,2BAAA"}
@@ -1,6 +1,6 @@
1
1
  import { MarkdownProvider, MarkdownProviderOptions, useMarkdownContext } from "./MarkdownProvider.js";
2
2
  import { MarkdownRenderer, MarkdownRendererProps, RenderMarkdownProps, renderMarkdown, useMarkdownRenderer } from "./MarkdownRenderer.js";
3
- import { MarkdownMetadataRenderer, MarkdownRendererPlugin } from "./MarkdownRendererPlugin.js";
3
+ import { MarkdownRendererPlugin } from "./MarkdownRendererPlugin.js";
4
4
  import { LegacyMarkdownRenderer, MarkdownRendererOptions, RuleType, compile, compileMarkdown, compiler, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "./processor.js";
5
5
  import reactRuntime, { createReactRuntime } from "./runtime.js";
6
- export { LegacyMarkdownRenderer, MarkdownMetadataRenderer, MarkdownProvider, MarkdownProviderOptions, MarkdownRenderer, MarkdownRendererOptions, MarkdownRendererPlugin, MarkdownRendererProps, RenderMarkdownProps, RuleType, compile, compileMarkdown, compiler, createReactRuntime, reactRuntime, renderMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify, useMarkdownContext, useMarkdownRenderer };
6
+ export { LegacyMarkdownRenderer, MarkdownProvider, MarkdownProviderOptions, MarkdownRenderer, MarkdownRendererOptions, MarkdownRendererPlugin, MarkdownRendererProps, RenderMarkdownProps, RuleType, compile, compileMarkdown, compiler, createReactRuntime, reactRuntime, renderMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify, useMarkdownContext, useMarkdownRenderer };
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;AA0CA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;;cAIJ,mBAAA,EAAqB,OAAA;;;;KA4BtB,aAAA,MAAmB,CAAA;EAC7B,KAAA;EACA,GAAA;AAAA,IAEE,SAAA;;cAIS,gBAAA,EAAkB,OAAA;;AApC/B;;KAiEY,aAAA,MAAmB,CAAA;EAC7B,QAAA,EAAU,QAAA;EAAA,CACT,QAAA,CAAS,SAAA;EACV,M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cAMlD,UAAA,EAAY,OAAA;;;;KAoCb,uBAAA,mBAA0C,aAAA;EACpD,SAAA,EAAW,aAAA,CAAc,CAAA;EACzB,iBAAA,EAAmB,gBAAA,CAAiB,CAAA;EACpC,cAAA,EAAgB,aAAA,CAAc,CAAA;EAC9B,aAAA,EAAe,YAAA,CAAa,CAAA;EAC5B,SAAA,EAAW,cAAA,CAAe,CAAA;AAAA;;;;AAlM5B;;KA0MY,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,SAAA;EACA,iBAAA;EACA,aAAA;EACA,SAAA;EACA,cAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAM5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "8.4.1",
3
+ "version": "8.4.3",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -115,14 +115,14 @@
115
115
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
116
116
  },
117
117
  "dependencies": {
118
- "@intlayer/api": "8.4.1",
119
- "@intlayer/config": "8.4.1",
120
- "@intlayer/core": "8.4.1",
121
- "@intlayer/dictionaries-entry": "8.4.1",
122
- "@intlayer/editor": "8.4.1",
123
- "@intlayer/editor-react": "8.4.1",
124
- "@intlayer/types": "8.4.1",
125
- "intlayer": "8.4.1"
118
+ "@intlayer/api": "8.4.3",
119
+ "@intlayer/config": "8.4.3",
120
+ "@intlayer/core": "8.4.3",
121
+ "@intlayer/dictionaries-entry": "8.4.3",
122
+ "@intlayer/editor": "8.4.3",
123
+ "@intlayer/editor-react": "8.4.3",
124
+ "@intlayer/types": "8.4.3",
125
+ "intlayer": "8.4.3"
126
126
  },
127
127
  "devDependencies": {
128
128
  "@craco/types": "7.1.0",
@@ -1,2 +0,0 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/core/markdown`),t=require(`react`),n=require(`@intlayer/editor/isEnabled`),r=require(`@intlayer/core/dictionaryManipulator`);const i=(e,r,i)=>{let[a,o]=(0,t.useState)(i);return(0,t.useEffect)(()=>{if(!n.isEnabled)return;let t=!1,i,a,s=t=>{let n=()=>{let n=t.getContentValue(e,r);typeof n==`string`&&o(n)};n(),t.editedContent.addEventListener(`change`,n),i=()=>t.editedContent.removeEventListener(`change`,n)};return import(`@intlayer/editor`).then(({getGlobalEditorManager:e,onGlobalEditorManagerChange:n})=>{if(t)return;let r=e();r?s(r):a=n(e=>{t||(i&&=(i(),void 0),e&&s(e))})}),()=>{t=!0,i?.(),a?.()}},[e,r,i]),a},a=({dictionaryKey:t,keyPath:n,children:a,metadataKeyPath:o})=>(0,r.getContentNodeByKeyPath)((0,e.getMarkdownMetadata)(i(t,n,a)),o);exports.MarkdownMetadataRendererInternal=a;
2
- //# sourceMappingURL=MarkdownMetadataRendererInternal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownMetadataRendererInternal.cjs","names":["isEnabled"],"sources":["../../../src/markdown/MarkdownMetadataRendererInternal.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { FC, ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\n\ntype MarkdownMetadataRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n metadataKeyPath: KeyPath[];\n};\n\n/**\n * Gets the edited markdown string for this node from the global manager,\n * falling back to the original children string.\n */\nconst useEditedMarkdown = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n children: string\n): string => {\n const [editedMarkdown, setEditedMarkdown] = useState<string>(children);\n\n useEffect(() => {\n if (!isEnabled) return;\n\n let stopped = false;\n let unsubscribeFromManager: (() => void) | undefined;\n let unsubscribeFromGlobalChange: (() => void) | undefined;\n\n const setupManager = (manager: EditorStateManager) => {\n const updateValue = () => {\n const edited = manager.getContentValue(dictionaryKey, keyPath);\n if (typeof edited === 'string') {\n setEditedMarkdown(edited);\n }\n };\n\n updateValue();\n manager.editedContent.addEventListener('change', updateValue);\n unsubscribeFromManager = () =>\n manager.editedContent.removeEventListener('change', updateValue);\n };\n\n import('@intlayer/editor').then(\n ({ getGlobalEditorManager, onGlobalEditorManagerChange }) => {\n if (stopped) return;\n\n const manager = getGlobalEditorManager();\n\n if (manager) {\n setupManager(manager);\n } else {\n unsubscribeFromGlobalChange = onGlobalEditorManagerChange(\n (newManager) => {\n if (stopped) return;\n\n if (unsubscribeFromManager) {\n unsubscribeFromManager();\n unsubscribeFromManager = undefined;\n }\n\n if (newManager) {\n setupManager(newManager);\n }\n }\n );\n }\n }\n );\n\n return () => {\n stopped = true;\n unsubscribeFromManager?.();\n unsubscribeFromGlobalChange?.();\n };\n }, [dictionaryKey, keyPath, children]);\n\n return editedMarkdown;\n};\n\nexport const MarkdownMetadataRendererInternal: FC<\n MarkdownMetadataRendererProps\n> = ({ dictionaryKey, keyPath, children, metadataKeyPath }): ReactNode => {\n const markdownContent = useEditedMarkdown(dictionaryKey, keyPath, children);\n\n const metadata = getMarkdownMetadata(markdownContent);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":"mRAwBA,MAAM,GACJ,EACA,EACA,IACW,CACX,GAAM,CAAC,EAAgB,IAAA,EAAA,EAAA,UAAsC,EAAS,CAyDtE,OAvDA,EAAA,EAAA,eAAgB,CACd,GAAI,CAACA,EAAAA,UAAW,OAEhB,IAAI,EAAU,GACV,EACA,EAEE,EAAgB,GAAgC,CACpD,IAAM,MAAoB,CACxB,IAAM,EAAS,EAAQ,gBAAgB,EAAe,EAAQ,CAC1D,OAAO,GAAW,UACpB,EAAkB,EAAO,EAI7B,GAAa,CACb,EAAQ,cAAc,iBAAiB,SAAU,EAAY,CAC7D,MACE,EAAQ,cAAc,oBAAoB,SAAU,EAAY,EA8BpE,OA3BA,OAAO,oBAAoB,MACxB,CAAE,yBAAwB,iCAAkC,CAC3D,GAAI,EAAS,OAEb,IAAM,EAAU,GAAwB,CAEpC,EACF,EAAa,EAAQ,CAErB,EAA8B,EAC3B,GAAe,CACV,IAEJ,AAEE,KADA,GAAwB,CACC,IAAA,IAGvB,GACF,EAAa,EAAW,GAG7B,EAGN,KAEY,CACX,EAAU,GACV,KAA0B,CAC1B,KAA+B,GAEhC,CAAC,EAAe,EAAS,EAAS,CAAC,CAE/B,GAGI,GAER,CAAE,gBAAe,UAAS,WAAU,sBAUvC,EAAA,EAAA,0BAAA,EAAA,EAAA,qBATwB,EAAkB,EAAe,EAAS,EAAS,CAEtB,CAInD,EACD"}
@@ -1,2 +0,0 @@
1
- "use client";import{getMarkdownMetadata as e}from"@intlayer/core/markdown";import{useEffect as t,useState as n}from"react";import{isEnabled as r}from"@intlayer/editor/isEnabled";import{getContentNodeByKeyPath as i}from"@intlayer/core/dictionaryManipulator";const a=(e,i,a)=>{let[o,s]=n(a);return t(()=>{if(!r)return;let t=!1,n,a,o=t=>{let r=()=>{let n=t.getContentValue(e,i);typeof n==`string`&&s(n)};r(),t.editedContent.addEventListener(`change`,r),n=()=>t.editedContent.removeEventListener(`change`,r)};return import(`@intlayer/editor`).then(({getGlobalEditorManager:e,onGlobalEditorManagerChange:r})=>{if(t)return;let i=e();i?o(i):a=r(e=>{t||(n&&=(n(),void 0),e&&o(e))})}),()=>{t=!0,n?.(),a?.()}},[e,i,a]),o},o=({dictionaryKey:t,keyPath:n,children:r,metadataKeyPath:o})=>i(e(a(t,n,r)),o);export{o as MarkdownMetadataRendererInternal};
2
- //# sourceMappingURL=MarkdownMetadataRendererInternal.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownMetadataRendererInternal.mjs","names":[],"sources":["../../../src/markdown/MarkdownMetadataRendererInternal.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { FC, ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\n\ntype MarkdownMetadataRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n metadataKeyPath: KeyPath[];\n};\n\n/**\n * Gets the edited markdown string for this node from the global manager,\n * falling back to the original children string.\n */\nconst useEditedMarkdown = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n children: string\n): string => {\n const [editedMarkdown, setEditedMarkdown] = useState<string>(children);\n\n useEffect(() => {\n if (!isEnabled) return;\n\n let stopped = false;\n let unsubscribeFromManager: (() => void) | undefined;\n let unsubscribeFromGlobalChange: (() => void) | undefined;\n\n const setupManager = (manager: EditorStateManager) => {\n const updateValue = () => {\n const edited = manager.getContentValue(dictionaryKey, keyPath);\n if (typeof edited === 'string') {\n setEditedMarkdown(edited);\n }\n };\n\n updateValue();\n manager.editedContent.addEventListener('change', updateValue);\n unsubscribeFromManager = () =>\n manager.editedContent.removeEventListener('change', updateValue);\n };\n\n import('@intlayer/editor').then(\n ({ getGlobalEditorManager, onGlobalEditorManagerChange }) => {\n if (stopped) return;\n\n const manager = getGlobalEditorManager();\n\n if (manager) {\n setupManager(manager);\n } else {\n unsubscribeFromGlobalChange = onGlobalEditorManagerChange(\n (newManager) => {\n if (stopped) return;\n\n if (unsubscribeFromManager) {\n unsubscribeFromManager();\n unsubscribeFromManager = undefined;\n }\n\n if (newManager) {\n setupManager(newManager);\n }\n }\n );\n }\n }\n );\n\n return () => {\n stopped = true;\n unsubscribeFromManager?.();\n unsubscribeFromGlobalChange?.();\n };\n }, [dictionaryKey, keyPath, children]);\n\n return editedMarkdown;\n};\n\nexport const MarkdownMetadataRendererInternal: FC<\n MarkdownMetadataRendererProps\n> = ({ dictionaryKey, keyPath, children, metadataKeyPath }): ReactNode => {\n const markdownContent = useEditedMarkdown(dictionaryKey, keyPath, children);\n\n const metadata = getMarkdownMetadata(markdownContent);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":"iQAwBA,MAAM,GACJ,EACA,EACA,IACW,CACX,GAAM,CAAC,EAAgB,GAAqB,EAAiB,EAAS,CAyDtE,OAvDA,MAAgB,CACd,GAAI,CAAC,EAAW,OAEhB,IAAI,EAAU,GACV,EACA,EAEE,EAAgB,GAAgC,CACpD,IAAM,MAAoB,CACxB,IAAM,EAAS,EAAQ,gBAAgB,EAAe,EAAQ,CAC1D,OAAO,GAAW,UACpB,EAAkB,EAAO,EAI7B,GAAa,CACb,EAAQ,cAAc,iBAAiB,SAAU,EAAY,CAC7D,MACE,EAAQ,cAAc,oBAAoB,SAAU,EAAY,EA8BpE,OA3BA,OAAO,oBAAoB,MACxB,CAAE,yBAAwB,iCAAkC,CAC3D,GAAI,EAAS,OAEb,IAAM,EAAU,GAAwB,CAEpC,EACF,EAAa,EAAQ,CAErB,EAA8B,EAC3B,GAAe,CACV,IAEJ,AAEE,KADA,GAAwB,CACC,IAAA,IAGvB,GACF,EAAa,EAAW,GAG7B,EAGN,KAEY,CACX,EAAU,GACV,KAA0B,CAC1B,KAA+B,GAEhC,CAAC,EAAe,EAAS,EAAS,CAAC,CAE/B,GAGI,GAER,CAAE,gBAAe,UAAS,WAAU,qBAKpB,EAFF,EAFO,EAAkB,EAAe,EAAS,EAAS,CAEtB,CAInD,EACD"}
@@ -1,16 +0,0 @@
1
- import { LocalesValues } from "@intlayer/types/module_augmentation";
2
- import { FC } from "react";
3
- import { KeyPath } from "@intlayer/types/keyPath";
4
-
5
- //#region src/markdown/MarkdownMetadataRendererInternal.d.ts
6
- type MarkdownMetadataRendererProps = {
7
- dictionaryKey: string;
8
- keyPath: KeyPath[];
9
- locale?: LocalesValues;
10
- children: string;
11
- metadataKeyPath: KeyPath[];
12
- };
13
- declare const MarkdownMetadataRendererInternal: FC<MarkdownMetadataRendererProps>;
14
- //#endregion
15
- export { MarkdownMetadataRendererInternal };
16
- //# sourceMappingURL=MarkdownMetadataRendererInternal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownMetadataRendererInternal.d.ts","names":[],"sources":["../../../src/markdown/MarkdownMetadataRendererInternal.tsx"],"mappings":";;;;;KAYK,6BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,eAAA,EAAiB,OAAA;AAAA;AAAA,cAwEN,gCAAA,EAAkC,EAAA,CAC7C,6BAAA"}