preact-intlayer 8.7.6 → 8.7.7

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 +1 @@
1
- {"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,4CAAe;AAIlC,QAAO;EACL;EACA,SAJcC,4CAAe,gBAAgB;EAK7C,GAAGA;EACJ"}
1
+ {"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,4CAAe;AAIlC,QAAO;EACL;EACA,SAJcC,4CAAe,gBAItB;EACP,GAAGA;EACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,+CACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,gCACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,+CACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CAAc,gCAPnB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,+CACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,+CACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.cjs","names":["Fragment","useHTMLContext"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,EAAE,KAAsB,EAAE,KACzB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,WAAW,CACvB,QAAQ,GAAG,eAAe,UAAU,CACpC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,wBAAiB,WAAkB,MAAM,CAC3C,CAAC,CACL;AAiBD,sBAASA,iBAAU,8CAAc,SAdP,IAAI,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;AAChB,MAAI,OAAO,SAAS,YAAY,QAAQ,OACtC,QAAO,OAAO;AAGhB,MAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,KAAK,CAC3D,SAAQ,wBAAiB,MAAM,MAAM;IAI1C,CAAC,CAGiE,CAAC;;;;;;;;AAStE,MAAa,mBAAmB,EAAE,eAAgC,EAAE,KAAK;CACvE,MAAM,UAAUC,0CAAgB;AAEhC,SAAQ,YAAoB;AAC1B,SAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;GACJ,EACF,CAAC;;;;;;AAwBN,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;AAIJ,QAHe,gBAAgB,EAAE,YAAY,CAAC,CAC9B,YAAY,QAAQ,GAEd"}
1
+ {"version":3,"file":"HTMLRenderer.cjs","names":["Fragment","useHTMLContext"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,EAAE,KAAsB,EAAE,KACzB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,WAAW,CACvB,QAAQ,GAAG,eAAe,UAAU,CACpC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,wBAAiB,WAAkB,MAAM,CAC3C,CAAC,CACL;AAiBD,sBAASA,iBAAU,8CAAc,SAAS,IAdZ,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;AAChB,MAAI,OAAO,SAAS,YAAY,QAAQ,OACtC,QAAO,OAAO;AAGhB,MAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,KAAK,CAC3D,SAAQ,wBAAiB,MAAM,MAAM;IAI1C,CAG0D,CAAQ,CAAC;;;;;;;;AAStE,MAAa,mBAAmB,EAAE,eAAgC,EAAE,KAAK;CACvE,MAAM,UAAUC,0CAAgB;AAEhC,SAAQ,YAAoB;AAC1B,SAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;GACJ,EACF,CAAC;;;;;;AAwBN,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;AAIJ,QAHe,gBAAgB,EAAE,YAAY,CAGhC,CAFG,YAAY,QAAQ,GAEd"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AA0EA,MAAM,4CACJ,OACD;AAED,MAAa,wDAAsC,gBAAgB;AAEnE,MAAM,gBACJ,gBACA,aACA,UAAmC,EAAE,EACrC,aAA+C,EAAE,EACjD,YAC0B;AAC1B,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;GAAY;EACjD;;AAGH,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;EACD;CAGD,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;AAQtB,SAAOA,0CAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,EAAE,EACxB,gBACD,CAC8C;;CAKjD,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,4CAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,gBAAgB;EAChD;AAG7B,QACE,4CAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;GACL;EAEA;EACwB"}
1
+ {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AA0EA,MAAM,4CACJ,OACD;AAED,MAAa,wDAAsC,gBAAgB;AAEnE,MAAM,gBACJ,gBACA,aACA,UAAmC,EAAE,EACrC,aAA+C,EAAE,EACjD,YAC0B;AAC1B,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;GAAY;EACjD;;AAGH,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;EACD;CAGD,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;AAQtB,SAAOA,0CAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,EAAE,EACxB,gBAE4C,CAAC;;CAKjD,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,4CAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,gBAAgB;EAChD;AAG7B,QACE,4CAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;GACL;EAEA;EACwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KACX;AAYhB,QAAOA,0CAAgB,SAV0B;EAC/C;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;EACD,CAE+C;;AAGlD,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KAAK;CAC9B,MAAM,UAAUC,sDAAoB;AAEpC,SAAQ,YAAoB;AAC1B,MAAI,QACF,QAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;GACD,EACD,YACA,QACD;AAGH,SAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;;;;;;;;AAgCN,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAUA,sDAAoB;AAEpC,KAAI,qBACF,QACE,qFACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EACD;AAIP,KAAI,QACF,QACE,qFACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;EACD,EACD,YACA,QACD,EACA;AAIP,QAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KACX;AAYhB,QAAOA,0CAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;EAG6C,CAAC;;AAGlD,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KAAK;CAC9B,MAAM,UAAUC,sDAAoB;AAEpC,SAAQ,YAAoB;AAC1B,MAAI,QACF,QAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;GACD,EACD,YACA,QACD;AAGH,SAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;;;;;;;;AAgCN,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAUA,sDAAoB;AAEpC,KAAI,qBACF,QACE,qFACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EACD;AAIP,KAAI,QACF,QACE,qFACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;EACD,EACD,YACA,QACD,EACA;AAIP,QAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAUA,sDAAoB;AAGpC,SAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,EAAE;EAC7B,GAAI,cAAc,EAAE;EACrB,CAAC;;AAOJ,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkBC,oCAAW;AAU7C,2HARqC,SAAS,EAI5C,iBACA,cACD"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAUA,sDAAoB;AAGpC,SAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,EAAE;EAC7B,GAAI,cAAc,EAAE;EACrB,CAAC;;AAOJ,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkBC,oCAAW;AAU7C,2HARqC,SAG3B,EACR,iBACA,cAGe"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","editor","ContentSelector","renderPreactElement","Fragment","NodeTypes","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\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 = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\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:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.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 | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n 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 [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\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', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\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 !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,yBACJ,QAAQ,IAAI,sCAAsC;;;;AAKpD,MAAM,sBACJ,QAAQ,IAAI,mCAAmC;;;;AAKjD,MAAM,kBAAkB,QAAQ,IAAI,+BAA+B;;;;AAKnE,MAAM,uBACJ,QAAQ,IAAI,oCAAoC;;;;AAKlD,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAOrE,MAAM,+BACJ,sBACI,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,sBACI,0EAEE,0C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AAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,SAfc,IAAI,MAAM,SAAS,EAC/B,IAAI,QAAQ,MAAM;AAChB,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAAC;;CAIL;AAmCL,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUC,4CAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;EACAC;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
1
+ {"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","editor","ContentSelector","renderPreactElement","Fragment","NodeTypes","func","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\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 = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\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:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.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 | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n 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 [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\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', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\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 !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,yBACJ,QAAQ,IAAI,sCAAsC;;;;AAKpD,MAAM,sBACJ,QAAQ,IAAI,mCAAmC;;;;AAKjD,MAAM,kBAAkB,QAAQ,IAAI,+BAA+B;;;;AAKnE,MAAM,uBACJ,QAAQ,IAAI,oCAAoC;;;;AAKlD,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAOrE,MAAM,+BACJ,sBACI,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,sBACI,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,kBACI,0EAEE,4BAA8B,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B,2BACxCA,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,CAAC,qBAAqBC,8BAAO,UAC3B,0CAACC,gDAAD;GAAiB,GAA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IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;EACAC;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,YAA6B;AAC/D,KAAI,YAAY,QAAQ,OAAO,YAAY,SACzC,QAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;AAEhC,MAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,MAAoB,CACzC;AAED,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;aACQ,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,SAAuB;AACjE,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;AAGH,SAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QACD;AAKD,kCACG,QAAgB,QACjB,OACA,GAAI,MAAM,SACX"}
1
+ {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,YAA6B;AAC/D,KAAI,YAAY,QAAQ,OAAO,YAAY,SACzC,QAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;AAEhC,MAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,MAAoB,CACzC;AAED,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;aACQ,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,SAAuB;AACjE,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;AAGH,SAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QAGkC;AAGpC,kCACG,QAAgB,QACjB,OACA,GAAI,MAAM,SACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"useContent.mjs","names":[],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAW,eAAe;AAIlC,QAAO;EACL;EACA,SAJc,eAAe,gBAAgB;EAK7C,GAAG;EACJ"}
1
+ {"version":3,"file":"useContent.mjs","names":[],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAW,eAAe;AAIlC,QAAO;EACL;EACA,SAJc,eAAe,gBAItB;EACP,GAAG;EACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cARY,MAAM,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cAAc,MARI,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,EAAE,KAAsB,EAAE,KACzB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,WAAW,CACvB,QAAQ,GAAG,eAAe,UAAU,CACpC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,UAAe,EAAE,WAAkB,MAAM,CAC3C,CAAC,CACL;AAiBD,QAAO,EAAE,UAAU,MAAM,QAAQ,SAdP,IAAI,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;AAChB,MAAI,OAAO,SAAS,YAAY,QAAQ,OACtC,QAAO,OAAO;AAGhB,MAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,KAAK,CAC3D,SAAQ,UAAe,EAAE,MAAM,MAAM;IAI1C,CAAC,CAGiE,CAAC;;;;;;;;AAStE,MAAa,mBAAmB,EAAE,eAAgC,EAAE,KAAK;CACvE,MAAM,UAAU,gBAAgB;AAEhC,SAAQ,YAAoB;AAC1B,SAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;GACJ,EACF,CAAC;;;;;;AAwBN,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;AAIJ,QAHe,gBAAgB,EAAE,YAAY,CAAC,CAC9B,YAAY,QAAQ,GAEd"}
1
+ {"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,EAAE,KAAsB,EAAE,KACzB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,WAAW,CACvB,QAAQ,GAAG,eAAe,UAAU,CACpC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,UAAe,EAAE,WAAkB,MAAM,CAC3C,CAAC,CACL;AAiBD,QAAO,EAAE,UAAU,MAAM,QAAQ,SAAS,IAdZ,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;AAChB,MAAI,OAAO,SAAS,YAAY,QAAQ,OACtC,QAAO,OAAO;AAGhB,MAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,KAAK,CAC3D,SAAQ,UAAe,EAAE,MAAM,MAAM;IAI1C,CAG0D,CAAQ,CAAC;;;;;;;;AAStE,MAAa,mBAAmB,EAAE,eAAgC,EAAE,KAAK;CACvE,MAAM,UAAU,gBAAgB;AAEhC,SAAQ,YAAoB;AAC1B,SAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;GACJ,EACF,CAAC;;;;;;AAwBN,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;AAIJ,QAHe,gBAAgB,EAAE,YAAY,CAGhC,CAFG,YAAY,QAAQ,GAEd"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;AA0EA,MAAM,kBAAkB,cACtB,OACD;AAED,MAAa,2BAA2B,WAAW,gBAAgB;AAEnE,MAAM,gBACJ,gBACA,aACA,UAAmC,EAAE,EACrC,aAA+C,EAAE,EACjD,YAC0B;AAC1B,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;GAAY;EACjD;;AAGH,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;EACD;CAGD,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;AAQtB,SAAO,gBAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,EAAE,EACxB,gBACD,CAC8C;;CAKjD,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,gBAAgB;EAChD;AAG7B,QACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;GACL;EAEA;EACwB"}
1
+ {"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;AA0EA,MAAM,kBAAkB,cACtB,OACD;AAED,MAAa,2BAA2B,WAAW,gBAAgB;AAEnE,MAAM,gBACJ,gBACA,aACA,UAAmC,EAAE,EACrC,aAA+C,EAAE,EACjD,YAC0B;AAC1B,QAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;GAAY;EACjD;;AAGH,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;EACD;CAGD,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;AAQtB,SAAO,gBAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,EAAE,EACxB,gBAE4C,CAAC;;CAKjD,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,gBAAgB;EAChD;AAG7B,QACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;GACL;EAEA;EACwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KACX;AAYhB,QAAO,gBAAgB,SAV0B;EAC/C;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;EACD,CAE+C;;AAGlD,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KAAK;CAC9B,MAAM,UAAU,oBAAoB;AAEpC,SAAQ,YAAoB;AAC1B,MAAI,QACF,QAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;GACD,EACD,YACA,QACD;AAGH,SAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;;;;;;;;AAgCN,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAU,oBAAoB;AAEpC,KAAI,qBACF,QACE,0CACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EACD;AAIP,KAAI,QACF,QACE,0CACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;EACD,EACD,YACA,QACD,EACA;AAIP,QAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KACX;AAYhB,QAAO,gBAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;EAG6C,CAAC;;AAGlD,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KAAK;CAC9B,MAAM,UAAU,oBAAoB;AAEpC,SAAQ,YAAoB;AAC1B,MAAI,QACF,QAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;GACD,EACD,YACA,QACD;AAGH,SAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;;;;;;;;AAgCN,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAU,oBAAoB;AAEpC,KAAI,qBACF,QACE,0CACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EACD;AAIP,KAAI,QACF,QACE,0CACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;EACD,EACD,YACA,QACD,EACA;AAIP,QAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAU,oBAAoB;AAGpC,SAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,EAAE;EAC7B,GAAI,cAAc,EAAE;EACrB,CAAC;;AAOJ,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkB,WAAW;AAU7C,QANmB,wBAFF,oBAAoB,SAAS,EAI5C,iBACA,cACD"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAU,oBAAoB;AAGpC,SAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,EAAE;EAC7B,GAAI,cAAc,EAAE;EACrB,CAAC;;AAOJ,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkB,WAAW;AAU7C,QANmB,wBAFF,oBAAoB,SAG3B,EACR,iBACA,cAGe"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\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 = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\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:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.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 | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n 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 [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\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', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\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 !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,yBACJ,QAAQ,IAAI,sCAAsC;;;;AAKpD,MAAM,sBACJ,QAAQ,IAAI,mCAAmC;;;;AAKjD,MAAM,kBAAkB,QAAQ,IAAI,+BAA+B;;;;AAKnE,MAAM,uBACJ,QAAQ,IAAI,oCAAoC;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AAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH,CACF,GACD,EACE,UACA,EAAE,UAAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACR,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,SAfc,IAAI,MAAM,SAAS,EAC/B,IAAI,QAAQ,MAAM;AAChB,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAAC;;CAIL;AAmCL,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
1
+ {"version":3,"file":"plugins.mjs","names":["func"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\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 = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\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:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.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 | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n 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 [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\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', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\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 !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,yBACJ,QAAQ,IAAI,sCAAsC;;;;AAKpD,MAAM,sBACJ,QAAQ,IAAI,mCAAmC;;;;AAKjD,MAAM,kBAAkB,QAAQ,IAAI,+BAA+B;;;;AAKnE,MAAM,uBACJ,QAAQ,IAAI,oCAAoC;;;;AAKlD,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAOrE,MAAM,+BACJ,sBACI,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,sBACI,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,kBACI,OACA,WACE,OAAO,2BAAuB,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B,2BACxC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH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G;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreactElement.mjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;AAGA,MAAa,uBAAuB,YAA6B;AAC/D,KAAI,YAAY,QAAQ,OAAO,YAAY,SACzC,QAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;AAEhC,MAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,MAAoB,CACzC;AAED,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;aACQ,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,SAAuB;AACjE,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;AAGH,SAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QACD;AAKD,QAAO,cACJ,QAAgB,QACjB,OACA,GAAI,MAAM,SACX"}
1
+ {"version":3,"file":"renderPreactElement.mjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;AAGA,MAAa,uBAAuB,YAA6B;AAC/D,KAAI,YAAY,QAAQ,OAAO,YAAY,SACzC,QAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;AAEhC,MAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,MAAoB,CACzC;AAED,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;aACQ,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,SAAuB;AACjE,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;AAGH,SAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QAGkC;AAGpC,QAAO,cACJ,QAAgB,QACjB,OACA,GAAI,MAAM,SACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-intlayer",
3
- "version": "8.7.6",
3
+ "version": "8.7.7",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -100,12 +100,12 @@
100
100
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
101
101
  },
102
102
  "dependencies": {
103
- "@intlayer/api": "8.7.6",
104
- "@intlayer/chokidar": "8.7.6",
105
- "@intlayer/config": "8.7.6",
106
- "@intlayer/core": "8.7.6",
107
- "@intlayer/editor": "8.7.6",
108
- "@intlayer/types": "8.7.6"
103
+ "@intlayer/api": "8.7.7",
104
+ "@intlayer/chokidar": "8.7.7",
105
+ "@intlayer/config": "8.7.7",
106
+ "@intlayer/core": "8.7.7",
107
+ "@intlayer/editor": "8.7.7",
108
+ "@intlayer/types": "8.7.7"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@types/node": "25.6.0",
@@ -113,9 +113,9 @@
113
113
  "@utils/ts-config-types": "1.0.4",
114
114
  "@utils/tsdown-config": "1.0.4",
115
115
  "rimraf": "6.1.3",
116
- "tsdown": "0.21.9",
116
+ "tsdown": "0.21.10",
117
117
  "typescript": "6.0.3",
118
- "vitest": "4.1.4"
118
+ "vitest": "4.1.5"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "preact": ">=8.0.0"