angular-intlayer 8.4.1 → 8.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../client/installIntlayer.cjs`);require(`../client/index.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/editor/isEnabled`);const r=()=>{if(!n.isEnabled)return;let r=(0,t.inject)(t.DestroyRef,{optional:!0}),i=(0,t.inject)(e.INTLAYER_TOKEN,{optional:!0}),a=(0,t.inject)(t.Injector);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let n=e();if(i){let e=(0,t.runInInjectionContext)(a,()=>(0,t.effect)(()=>{let e=i.locale();e&&n.currentLocale.set(e)}));r?.onDestroy(()=>e.destroy())}}),r?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};exports.useEditor=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../client/installIntlayer.cjs`);require(`../client/index.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/editor/isEnabled`);const r=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return;let r=(0,t.inject)(t.DestroyRef,{optional:!0}),i=(0,t.inject)(e.INTLAYER_TOKEN,{optional:!0}),a=(0,t.inject)(t.Injector);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let n=e();if(i){let e=(0,t.runInInjectionContext)(a,()=>(0,t.effect)(()=>{let e=i.locale();e&&n.currentLocale.set(e)}));r?.onDestroy(()=>e.destroy())}}),r?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};exports.useEditor=r;
2
2
  //# sourceMappingURL=useEditor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (!isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"2PAWA,MAAa,MAAkB,CAC7B,GAAI,CAACA,EAAAA,UAAW,OAEhB,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CACnD,GAAA,EAAA,EAAA,QAAkCC,EAAAA,eAAgB,CACtD,SAAU,GACX,CAAQ,CACH,GAAA,EAAA,EAAA,QAAkBC,EAAAA,SAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,GAAA,EAAA,EAAA,uBAAkC,OAAA,EAAA,EAAA,YACzB,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
1
+ {"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"2PAWA,MAAa,MAAkB,CAC7B,GAAI,QAAQ,IAAI,0BAA4B,SAAW,CAACA,EAAAA,UAAW,OAEnE,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CACnD,GAAA,EAAA,EAAA,QAAkCC,EAAAA,eAAgB,CACtD,SAAU,GACX,CAAQ,CACH,GAAA,EAAA,EAAA,QAAkBC,EAAAA,SAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,GAAA,EAAA,EAAA,uBAAkC,OAAA,EAAA,EAAA,YACzB,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./renderIntlayerNode.cjs`),n=require(`./ContentSelector.component-Dfy-4WRH.cjs`),r=require(`./markdown/installIntlayerMarkdown.cjs`);let i=require(`@intlayer/core/interpreter`),a=require(`@intlayer/config/built`);a=e.t(a);let o=require(`@intlayer/core/markdown`),s=require(`@intlayer/types/nodeType`);const c=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),l={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:r,...i})=>t.renderIntlayerNode({...i,value:r,children:()=>({component:a.default?.editor.enabled?n.t:r,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},u={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,i,a)=>{let{plugins:s,...l}=i,u=a((0,o.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:e})}],dictionaryKey:l.dictionaryKey,keyPath:[]}),d=i=>t.renderIntlayerNode({...l,value:e,children:()=>({component:n.t,props:{dictionaryKey:l.dictionaryKey,keyPath:l.keyPath,...i},children:()=>{let{renderMarkdown:t}=r.useMarkdown();return t(e,i)}}),additionalProps:{metadata:u}}),f=(t,n)=>new Proxy(t,{get(t,i,a){return i===`value`?e:i===`metadata`?u:i===`toString`||i===Symbol.toPrimitive?()=>(0,o.compile)(e,{runtime:n?c(r.htmlRuntime,n):r.htmlRuntime}):i===`use`?e=>{let t={...n,...e};return f(d(t),t)}:Reflect.get(t,i,a)}});return f(d())}},d={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:s.NodeType.Markdown}],i=e[s.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[u,...t.plugins??[]]})}},f={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.HTML,transform:(e,i)=>{let a=e[s.NodeType.HTML],{plugins:l,...u}=i,d=e=>t.renderIntlayerNode({...u,value:a,children:()=>({component:n.t,props:{dictionaryKey:u.dictionaryKey,keyPath:u.keyPath,...e},children:a})}),f=(e,t)=>new Proxy(e,{get(e,n,i){return n===`value`?a:n===`toString`||n===Symbol.toPrimitive?()=>!t||typeof t==`object`&&Object.keys(t).length===0?String(a):(0,o.compile)(a,{runtime:c(r.htmlRuntime,t)}):n===`use`?e=>{let n={...t,...e};return f(d(n),n)}:Reflect.get(e,n,i)}});return f(d())}},p={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Insertion,transform:(e,n)=>{let{plugins:r,...i}=n,a=(t={})=>{let n=e.insertion;return t&&Object.entries(t).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return t.renderIntlayerNode({...i,value:a,children:a})}},m=(e,t=!0)=>[(0,i.translationPlugin)(e??a.default.internationalization.defaultLocale,t?a.default.internationalization.defaultLocale:void 0),i.enumerationPlugin,i.conditionPlugin,(0,i.nestedPlugin)(e??a.default.internationalization.defaultLocale),i.filePlugin,i.genderPlugin,l,d,f,p];exports.getPlugins=m,exports.htmlPlugin=f,exports.insertionPlugin=p,exports.intlayerNodePlugins=l,exports.markdownPlugin=d,exports.markdownStringPlugin=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./renderIntlayerNode.cjs`),n=require(`./ContentSelector.component-Dfy-4WRH.cjs`),r=require(`./markdown/installIntlayerMarkdown.cjs`);let i=require(`@intlayer/core/interpreter`),a=require(`@intlayer/config/built`);a=e.t(a);let o=require(`@intlayer/core/markdown`),s=require(`@intlayer/types/nodeType`);const c=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),l={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:r,...i})=>t.renderIntlayerNode({...i,value:r,children:()=>({component:a.default?.editor.enabled?n.t:r,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},u={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,i,s)=>{let{plugins:l,...u}=i,d=s((0,o.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:e})}],dictionaryKey:u.dictionaryKey,keyPath:[]}),f=i=>t.renderIntlayerNode({...u,value:e,children:a.default?.editor.enabled?()=>({component:n.t,props:{dictionaryKey:u.dictionaryKey,keyPath:u.keyPath,...i},children:()=>{let{renderMarkdown:t}=r.useMarkdown();return t(e,i)}}):()=>{let{renderMarkdown:t}=r.useMarkdown();return t(e,i)},additionalProps:{metadata:d}}),p=(t,n)=>new Proxy(t,{get(t,i,a){return i===`value`?e:i===`metadata`?d:i===`toString`||i===Symbol.toPrimitive?()=>(0,o.compile)(e,{runtime:n?c(r.htmlRuntime,n):r.htmlRuntime}):i===`use`?e=>{let t={...n,...e};return p(f(t),t)}:Reflect.get(t,i,a)}});return p(f())}},d={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:s.NodeType.Markdown}],i=e[s.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[u,...t.plugins??[]]})}},f={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.HTML,transform:(e,i)=>{let l=e[s.NodeType.HTML],{plugins:u,...d}=i,f=e=>t.renderIntlayerNode({...d,value:l,children:a.default?.editor.enabled?()=>({component:n.t,props:{dictionaryKey:d.dictionaryKey,keyPath:d.keyPath,...e},children:l}):l}),p=(e,t)=>new Proxy(e,{get(e,n,i){return n===`value`?l:n===`toString`||n===Symbol.toPrimitive?()=>!t||typeof t==`object`&&Object.keys(t).length===0?String(l):(0,o.compile)(l,{runtime:c(r.htmlRuntime,t)}):n===`use`?e=>{let n={...t,...e};return p(f(n),n)}:Reflect.get(e,n,i)}});return p(f())}},p={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Insertion,transform:(e,n)=>{let{plugins:r,...i}=n,a=(t={})=>{let n=e.insertion;return t&&Object.entries(t).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return t.renderIntlayerNode({...i,value:a,children:a})}},m=(e,t=!0)=>[(0,i.translationPlugin)(e??a.default.internationalization.defaultLocale,t?a.default.internationalization.defaultLocale:void 0),i.enumerationPlugin,i.conditionPlugin,(0,i.nestedPlugin)(e??a.default.internationalization.defaultLocale),i.filePlugin,i.genderPlugin,l,d,f,p];exports.getPlugins=m,exports.htmlPlugin=f,exports.insertionPlugin=p,exports.intlayerNodePlugins=l,exports.markdownPlugin=d,exports.markdownStringPlugin=u;
2
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\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: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\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: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n 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 === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = 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?: Record<keyof U, any>) => any;\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.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\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?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: 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 Angular 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 markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"maAgCA,MAAM,GAA6B,EAAkB,KAAoB,CACvE,GAAG,EACH,eAAgB,EAAa,EAAY,GAAG,IAAoB,CAC9D,IAAM,EAAW,IAAY,GAE7B,GAAI,EAAU,CAC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ACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\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: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\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: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n 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 === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = 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?: Record<keyof U, any>) => any;\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.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\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?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: 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 Angular 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,\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AAO,EAAM,CACd,EACD,CAEG,GAGT,OAAOL,EAAAA,mBAAmB,CACxB,GAAG,EACH,MAAO,EACP,SAAU,EACX,CAAC,EAEL,CAiCY,GACX,EACA,EAAoB,KACN,yBAEZ,GAAUC,EAAAA,QAAc,qBAAqB,cAC7C,EAAWA,EAAAA,QAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACDK,EAAAA,kBACAC,EAAAA,mCACa,GAAUN,EAAAA,QAAc,qBAAqB,cAAc,CACxEO,EAAAA,WACAC,EAAAA,aACA,EACA,EACA,EACA,EACD"}
@@ -1,2 +1,2 @@
1
- import{INTLAYER_TOKEN as e}from"../client/installIntlayer.mjs";import"../client/index.mjs";import{DestroyRef as t,Injector as n,effect as r,inject as i,runInInjectionContext as a}from"@angular/core";import{isEnabled as o}from"@intlayer/editor/isEnabled";const s=()=>{if(!o)return;let s=i(t,{optional:!0}),c=i(e,{optional:!0}),l=i(n);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();if(c){let e=a(l,()=>r(()=>{let e=c.locale();e&&t.currentLocale.set(e)}));s?.onDestroy(()=>e.destroy())}}),s?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};export{s as useEditor};
1
+ import{INTLAYER_TOKEN as e}from"../client/installIntlayer.mjs";import"../client/index.mjs";import{DestroyRef as t,Injector as n,effect as r,inject as i,runInInjectionContext as a}from"@angular/core";import{isEnabled as o}from"@intlayer/editor/isEnabled";const s=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!o)return;let s=i(t,{optional:!0}),c=i(e,{optional:!0}),l=i(n);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();if(c){let e=a(l,()=>r(()=>{let e=c.locale();e&&t.currentLocale.set(e)}));s?.onDestroy(()=>e.destroy())}}),s?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};export{s as useEditor};
2
2
  //# sourceMappingURL=useEditor.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (!isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"8PAWA,MAAa,MAAkB,CAC7B,GAAI,CAAC,EAAW,OAEhB,IAAM,EAAa,EAAO,EAAY,CAAE,SAAU,GAAM,CAAC,CACnD,EAAS,EAAyB,EAAgB,CACtD,SAAU,GACX,CAAQ,CACH,EAAW,EAAO,EAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,EAAY,EAAsB,MACtC,MAAa,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
1
+ {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"8PAWA,MAAa,MAAkB,CAC7B,GAAI,QAAQ,IAAI,0BAA4B,SAAW,CAAC,EAAW,OAEnE,IAAM,EAAa,EAAO,EAAY,CAAE,SAAU,GAAM,CAAC,CACnD,EAAS,EAAyB,EAAgB,CACtD,SAAU,GACX,CAAQ,CACH,EAAW,EAAO,EAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,EAAY,EAAsB,MACtC,MAAa,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
@@ -1,2 +1,2 @@
1
- import{renderIntlayerNode as e}from"./renderIntlayerNode.mjs";import{t}from"./ContentSelector.component-B9Uvy9gY.mjs";import{htmlRuntime as n,useMarkdown as r}from"./markdown/installIntlayerMarkdown.mjs";import{conditionPlugin as i,enumerationPlugin as a,filePlugin as o,genderPlugin as s,nestedPlugin as c,translationPlugin as l}from"@intlayer/core/interpreter";import u from"@intlayer/config/built";import{compile as d,getMarkdownMetadata as f}from"@intlayer/core/markdown";import{NodeType as p}from"@intlayer/types/nodeType";const m=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),h={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(n,{children:r,...i})=>e({...i,value:r,children:()=>({component:u?.editor.enabled?t:r,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},g={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(i,a,o)=>{let{plugins:s,...c}=a,l=o(f(i),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>e({...n,value:t,children:i})}],dictionaryKey:c.dictionaryKey,keyPath:[]}),u=n=>e({...c,value:i,children:()=>({component:t,props:{dictionaryKey:c.dictionaryKey,keyPath:c.keyPath,...n},children:()=>{let{renderMarkdown:e}=r();return e(i,n)}}),additionalProps:{metadata:l}}),p=(e,t)=>new Proxy(e,{get(e,r,a){return r===`value`?i:r===`metadata`?l:r===`toString`||r===Symbol.toPrimitive?()=>d(i,{runtime:t?m(n,t):n}):r===`use`?e=>{let n={...t,...e};return p(u(n),n)}:Reflect.get(e,r,a)}});return p(u())}},_={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:p.Markdown}],i=e[p.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[g,...t.plugins??[]]})}},v={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.HTML,transform:(r,i)=>{let a=r[p.HTML],{plugins:o,...s}=i,c=n=>e({...s,value:a,children:()=>({component:t,props:{dictionaryKey:s.dictionaryKey,keyPath:s.keyPath,...n},children:a})}),l=(e,t)=>new Proxy(e,{get(e,r,i){return r===`value`?a:r===`toString`||r===Symbol.toPrimitive?()=>!t||typeof t==`object`&&Object.keys(t).length===0?String(a):d(a,{runtime:m(n,t)}):r===`use`?e=>{let n={...t,...e};return l(c(n),n)}:Reflect.get(e,r,i)}});return l(c())}},y={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.Insertion,transform:(t,n)=>{let{plugins:r,...i}=n,a=(e={})=>{let n=t.insertion;return e&&Object.entries(e).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return e({...i,value:a,children:a})}},b=(e,t=!0)=>[l(e??u.internationalization.defaultLocale,t?u.internationalization.defaultLocale:void 0),a,i,c(e??u.internationalization.defaultLocale),o,s,h,_,v,y];export{b as getPlugins,v as htmlPlugin,y as insertionPlugin,h as intlayerNodePlugins,_ as markdownPlugin,g as markdownStringPlugin};
1
+ import{renderIntlayerNode as e}from"./renderIntlayerNode.mjs";import{t}from"./ContentSelector.component-B9Uvy9gY.mjs";import{htmlRuntime as n,useMarkdown as r}from"./markdown/installIntlayerMarkdown.mjs";import{conditionPlugin as i,enumerationPlugin as a,filePlugin as o,genderPlugin as s,nestedPlugin as c,translationPlugin as l}from"@intlayer/core/interpreter";import u from"@intlayer/config/built";import{compile as d,getMarkdownMetadata as f}from"@intlayer/core/markdown";import{NodeType as p}from"@intlayer/types/nodeType";const m=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),h={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(n,{children:r,...i})=>e({...i,value:r,children:()=>({component:u?.editor.enabled?t:r,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},g={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(i,a,o)=>{let{plugins:s,...c}=a,l=o(f(i),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>e({...n,value:t,children:i})}],dictionaryKey:c.dictionaryKey,keyPath:[]}),p=n=>e({...c,value:i,children:u?.editor.enabled?()=>({component:t,props:{dictionaryKey:c.dictionaryKey,keyPath:c.keyPath,...n},children:()=>{let{renderMarkdown:e}=r();return e(i,n)}}):()=>{let{renderMarkdown:e}=r();return e(i,n)},additionalProps:{metadata:l}}),h=(e,t)=>new Proxy(e,{get(e,r,a){return r===`value`?i:r===`metadata`?l:r===`toString`||r===Symbol.toPrimitive?()=>d(i,{runtime:t?m(n,t):n}):r===`use`?e=>{let n={...t,...e};return h(p(n),n)}:Reflect.get(e,r,a)}});return h(p())}},_={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:p.Markdown}],i=e[p.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[g,...t.plugins??[]]})}},v={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.HTML,transform:(r,i)=>{let a=r[p.HTML],{plugins:o,...s}=i,c=n=>e({...s,value:a,children:u?.editor.enabled?()=>({component:t,props:{dictionaryKey:s.dictionaryKey,keyPath:s.keyPath,...n},children:a}):a}),l=(e,t)=>new Proxy(e,{get(e,r,i){return r===`value`?a:r===`toString`||r===Symbol.toPrimitive?()=>!t||typeof t==`object`&&Object.keys(t).length===0?String(a):d(a,{runtime:m(n,t)}):r===`use`?e=>{let n={...t,...e};return l(c(n),n)}:Reflect.get(e,r,i)}});return l(c())}},y={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===p.Insertion,transform:(t,n)=>{let{plugins:r,...i}=n,a=(e={})=>{let n=t.insertion;return e&&Object.entries(e).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return e({...i,value:a,children:a})}},b=(e,t=!0)=>[l(e??u.internationalization.defaultLocale,t?u.internationalization.defaultLocale:void 0),a,i,c(e??u.internationalization.defaultLocale),o,s,h,_,v,y];export{b as getPlugins,v as htmlPlugin,y as insertionPlugin,h as intlayerNodePlugins,_ as markdownPlugin,g as markdownStringPlugin};
2
2
  //# sourceMappingURL=plugins.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\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: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\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: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n 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 === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = 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?: Record<keyof U, any>) => any;\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.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\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?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: 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 Angular 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 markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"ghBAgCA,MAAM,GAA6B,EAAkB,KAAoB,CACvE,GAAG,EACH,eAAgB,EAAa,EAAY,GAAG,IAAoB,CAC9D,IAAM,EAAW,IAAY,GAE7B,GAAI,EAAU,CACZ,IAAM,EAAW,CAAE,GAAG,EAAO,GAAG,EAAU,CAGpC,EAAgB,GAAO,OAAS,GAAO,UACvC,EAAgB,EAAS,OAAS,EAAS,UAOjD,OALI,GAAiB,IACnB,EAAS,MAAQ,GAAG,EAAc,GAAG,IACrC,EAAS,UAAY,IAAA,IAGhB,EAAY,cAAc,EAAK,EAAU,GAAG,EAAS,CAG9D,OAAO,EAAY,cAAc,EAAK,EAAO,GAAG,EAAS,EAE5D,EAiBY,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WAAY,EAAO,CAAE,WAAU,GAAG,KAChC,EAAmB,CACjB,GAAG,EACH,MAAO,EACP,cAAiB,CACf,UAAW,GAAe,OAAO,QAC7B,EACA,EACJ,MAAO,CACL,cAAe,EAAK,cACpB,QAAS,EAAK,QACf,CACS,WACX,EACF,CAAC,CACL,CAWY,EAAgC,CAC3C,GAAI,yBACJ,UAAY,GAAS,OAAO,GAAS,SACrC,WAAY,EAAc,EAAO,IAAsB,CACrD,GAAM,CACJ,UACA,GAAG,GACD,EAoBE,EAAgB,EAlBL,EAAoB,EAAK,CAkBQ,CAChD,QAAS,CAjBsB,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EACH,MAAO,EACP,SAAU,EACX,CAAC,EAEL,CAiCY,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,EACD"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\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: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\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: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n 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 === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = 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?: Record<keyof U, any>) => any;\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.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\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?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: 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 Angular 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 markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"ghBAgCA,MAAM,GAA6B,EAAkB,KAAoB,CACvE,GAAG,EACH,eAAgB,EAAa,EAAY,GAAG,IAAoB,CAC9D,IAAM,EAAW,IAAY,GAE7B,GAAI,EAAU,CACZ,IAAM,EAAW,CAAE,GAAG,EAAO,GAAG,EAAU,CAGpC,EAAgB,GAAO,OAAS,GAAO,UACvC,EAAgB,EAAS,OAAS,EAAS,UAOjD,OALI,GAAiB,IACnB,EAAS,MAAQ,GAAG,EAAc,GAAG,IACrC,EAAS,UAAY,IAAA,IAGhB,EAAY,cAAc,EAAK,EAAU,GAAG,EAAS,CAG9D,OAAO,EAAY,cAAc,EAAK,EAAO,GAAG,EAAS,EAE5D,EAiBY,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WAAY,EAAO,CAAE,WAAU,GAAG,KAChC,EAAmB,CACjB,GAAG,EACH,MAAO,EACP,cAAiB,CACf,UAAW,GAAe,OAAO,QAC7B,EACA,EACJ,MAAO,CACL,cAAe,EAAK,cACpB,QAAS,EAAK,QACf,CACS,WACX,EACF,CAAC,CACL,CAWY,EAAgC,CAC3C,GAAI,yBACJ,UAAY,GAAS,OAAO,GAAS,SACrC,WAAY,EAAc,EAAO,IAAsB,CACrD,GAAM,CACJ,UACA,GAAG,GACD,EAoBE,EAAgB,EAlBL,EAAoB,EAAK,CAkBQ,CAChD,QAAS,CAjBsB,CAC/B,GAAI,2BACJ,UAAY,GACV,OAAO,GAAiB,UACxB,OAAO,GAAiB,UACxB,OAAO,GAAiB,WACxB,CAAC,EACH,WAAY,EAAc,IACxB,EAAmB,CACjB,GAAG,EACH,MAAO,EACP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IAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,MAAA,OAAa,CAAA;AAAA;;cAM3B,UAAA,EAAY,OAAA;;;AAxKzB;;;;KAuQY,mBAAA,MAAyB,CAAA;EACnC,QAAA,EAAU,QAAA;EAAA,CACT,QAAA,CAAS,SAAA;AAAA,KAEP,IAAA,EAAM,MAAA;AAAA,cAGE,eAAA,EAAiB,OAAA;AAAA,UA6Bb,yBAAA,iBAA0C,aAAA;EACzD,mBAAA,EAAqB,gBAAA,CAAiB,CAAA;EACtC,eAAA,EAAiB,YAAA,CAAa,CAAA,EAAG,CAAA,EAAG,CAAA;EACpC,WAAA,EAAa,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EAClC,gBAAA,EAAkB,mBAAA,CAAoB,CAAA;AAAA;;;;;;KAQ5B,yBAAA,GAA0B,IAAA,CACpC,uBAAA;EAGA,mBAAA;EACA,eAAA;EACA,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,sBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,oBAAA,CAAyB,CAAA,EAAG,yBAAA,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": "angular-intlayer",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -86,13 +86,13 @@
86
86
  "dependencies": {
87
87
  "@babel/plugin-syntax-import-attributes": "^7.28.6",
88
88
  "@babel/preset-env": "^7.29.0",
89
- "@intlayer/chokidar": "8.4.1",
90
- "@intlayer/config": "8.4.1",
91
- "@intlayer/core": "8.4.1",
92
- "@intlayer/dictionaries-entry": "8.4.1",
93
- "@intlayer/editor": "8.4.1",
94
- "@intlayer/types": "8.4.1",
95
- "@intlayer/webpack": "8.4.1",
89
+ "@intlayer/chokidar": "8.4.2",
90
+ "@intlayer/config": "8.4.2",
91
+ "@intlayer/core": "8.4.2",
92
+ "@intlayer/dictionaries-entry": "8.4.2",
93
+ "@intlayer/editor": "8.4.2",
94
+ "@intlayer/types": "8.4.2",
95
+ "@intlayer/webpack": "8.4.2",
96
96
  "babel-loader": "^10.1.1",
97
97
  "defu": "6.1.4"
98
98
  },