preact-intlayer 8.9.7 → 8.9.8
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.
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
- package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/format/useCompact.cjs.map +1 -1
- package/dist/cjs/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/format/useDate.cjs.map +1 -1
- package/dist/cjs/format/useIntl.cjs.map +1 -1
- package/dist/cjs/format/useList.cjs.map +1 -1
- package/dist/cjs/format/useNumber.cjs.map +1 -1
- package/dist/cjs/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/format/useUnit.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/runtime.cjs.map +1 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelector.mjs.map +1 -1
- package/dist/esm/editor/EditorProvider.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/format/useCompact.mjs.map +1 -1
- package/dist/esm/format/useCurrency.mjs.map +1 -1
- package/dist/esm/format/useDate.mjs.map +1 -1
- package/dist/esm/format/useIntl.mjs.map +1 -1
- package/dist/esm/format/useList.mjs.map +1 -1
- package/dist/esm/format/useNumber.mjs.map +1 -1
- package/dist/esm/format/usePercentage.mjs.map +1 -1
- package/dist/esm/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/format/useUnit.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/html/HTMLProvider.mjs.map +1 -1
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/runtime.mjs.map +1 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +1 -2
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -4
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -4
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +4 -6
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +4 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +1 -3
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +1 -3
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +1 -3
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +1 -3
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +1 -3
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +1 -3
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +1 -3
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -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,
|
|
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,MACF;AAEA,MAAa,2BAA2B,WAAW,eAAe;AAElE,MAAM,gBACJ,gBACA,aACA,UAAmC,CAAC,GACpC,aAA+C,CAAC,GAChD,YAC0B;CAC1B,OAAO;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;EAAW;CACjD;AACF;AAEA,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;CACF;CAGA,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;EAQtB,OAAO,gBAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,CAAC,GACvB,eAE2C,CAAC;CAChD;CAIA,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,eAAe;CAChD;CAG5B,OACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;EACN;EAEC;CACuB;AAE9B"}
|
|
@@ -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,
|
|
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,CAAC,MACV;CAYhB,OAAO,gBAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;CAG4C,CAAC;AACjD;AAEA,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,CAAC,MAAM;CAC9B,MAAM,UAAU,mBAAmB;CAEnC,QAAQ,YAAoB;EAC1B,IAAI,SACF,OAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;EACF,GACA,YACA,OACF;EAGF,OAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;CACH;AACF;;;;;;;AA8BA,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAU,mBAAmB;CAEnC,IAAI,sBACF,OACE,0CACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,EACD;CAIN,IAAI,SACF,OACE,0CACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;CACF,GACA,YACA,OACF,EACA;CAIN,OAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -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,
|
|
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,mBAAmB;CAGnC,QAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,CAAC;EAC5B,GAAI,cAAc,CAAC;CACrB,CAAC;AACH;AAMA,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkB,UAAU;CAU5C,OANmB,wBAFF,oBAAoB,QAG5B,GACP,iBACA,aAGc;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport {
|
|
1
|
+
{"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;;AAsBA,MAAa,mBACX,WAAmB,IACnB,UAAmC,CAAC,MACjC,mBAAmB,UAAU,eAAe,OAAO;AAGxD,MAAa,WAAW;AACxB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,aACK,cAAc,MAAa,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,aACK,cAAc,MAAa,OAAO,GAAG,QAAQ;CAEvD,eACE,SACA,OACA,GAAG,aACK,aAAa,SAAkB,OAAO,GAAG,QAAQ;CAE3D;CAEA,iBACE,MACA,UACwB;AAC5B"}
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 pluralPlugin,\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, type FunctionComponent, h, type VNode } from 'preact';\nimport { useLoadDynamic } from './client/useLoadDynamic';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_HTML'] !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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 =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\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\nconst MarkdownSuspenseRenderer: FunctionComponent<Record<string, any>> = ({\n children,\n ...props\n}) => {\n const { MarkdownRendererPlugin } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownRendererPlugin as any, { ...props, children });\n};\n\nconst MarkdownMetadataSuspenseRenderer: FunctionComponent<\n Record<string, any>\n> = ({ children, ...props }) => {\n const { MarkdownMetadataRenderer } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownMetadataRenderer as any, { ...props, children });\n};\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\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') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\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 =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\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\nconst HTMLSuspenseRenderer: FunctionComponent<Record<string, any>> = (\n props\n) => {\n const HTMLRenderer = useLoadDynamic(\n 'preact-html-renderer',\n htmlRendererModulePromise!\n );\n return h(HTMLRenderer as any, props);\n};\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, { ...rest, html, userComponents })\n )\n : h(HTMLSuspenseRenderer, { ...rest, html, userComponents }),\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') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\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 pluralPlugin(locale ?? internationalization.defaultLocale),\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":";;;;;;;;;;;;AAkCA,MAAM,gCACJ,QAAQ,IAAI,mCAAmC,UAC3C,OAAO,yCAAqC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;CAC7B,EAAE,GACH;AAEN,MAAM,4BACJ,QAAQ,IAAI,+BAA+B,UACvC,OAAO,2BAAuB,MAAM,MAAM,EAAE,aAAa,GACzD;;AAWN,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAW,OAAO,UAC3D,8BAAC,iBAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAEV,CAAC;CACL;;AAcD,MAAa,oBACX,QAAQ,IAAI,sCAAsC,UAC9C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO;EACP,UACE,QAAQ,IAAI,+BAA+B,WAC3C,OAAO,UACL,oBAAC,iBAAD;GAAiB,GAAI;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ACtD,MAAM,SAAU,OAAO,UAAkB;IACzC,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,KAAK,KAAK;;GAE5D,IAAI,SAAS,OACX,QAAQ,mBACN,OAAO,eAAe;GAC1B,OAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAEW;;CAEf;AAmCP,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,SAAS,EAC5B,OAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;CAED,aAAa,IAAI,UAAU,QAAQ;CAEnC,OAAO"}
|
|
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 pluralPlugin,\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, type FunctionComponent, h, type VNode } from 'preact';\nimport { useLoadDynamic } from './client/useLoadDynamic';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_HTML'] !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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 =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\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\nconst MarkdownSuspenseRenderer: FunctionComponent<Record<string, any>> = ({\n children,\n ...props\n}) => {\n const { MarkdownRendererPlugin } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownRendererPlugin as any, { ...props, children });\n};\n\nconst MarkdownMetadataSuspenseRenderer: FunctionComponent<\n Record<string, any>\n> = ({ children, ...props }) => {\n const { MarkdownMetadataRenderer } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownMetadataRenderer as any, { ...props, children });\n};\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\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') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\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 =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\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\nconst HTMLSuspenseRenderer: FunctionComponent<Record<string, any>> = (\n props\n) => {\n const HTMLRenderer = useLoadDynamic(\n 'preact-html-renderer',\n htmlRendererModulePromise!\n );\n return h(HTMLRenderer as any, props);\n};\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\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 process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, { ...rest, html, userComponents })\n )\n : h(HTMLSuspenseRenderer, { ...rest, html, userComponents }),\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') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\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 pluralPlugin(locale ?? internationalization.defaultLocale),\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":";;;;;;;;;;;;AAkCA,MAAM,gCACJ,QAAQ,IAAI,mCAAmC,UAC3C,OAAO,yCAAqC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;AAC9B,EAAE,IACF;AAEN,MAAM,4BACJ,QAAQ,IAAI,+BAA+B,UACvC,OAAO,2BAAuB,MAAM,MAAM,EAAE,YAAY,IACxD;;AAWN,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAW,OAAO,UAC3D,8BAAC,iBAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;EAEpB,GADd,KAAK,QACS,IAEjB,KAAK;CAEX,CAAC;AACL;;AAcA,MAAa,oBACX,QAAQ,IAAI,sCAAsC,UAC9C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO;EACP,UACE,QAAQ,IAAI,+BAA+B,WAC3C,OAAO,UACL,oBAAC,iBAAD;GAAiB,GAAI;aAClB,oBAAoB,IAAI;EACV,KAEjB,oBAAoB,IAAI;CAE9B,CAAC;AACL;;;;AAuBN,MAAM,WAAW,UAA+B;CAC9C,OACE,UAAU,QACV,UAAU,UACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAErB;;;;AAKA,MAAM,yBACJ,UACA,WACU;CAIV,IAAI,CAFa,O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;EACjC,EACF,CAEW;CACb;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAGlC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EAEA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -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;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,
|
|
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;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,QAAQ,GAAG;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,KAAmB,CACzC;GAEA,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;IAAe;GACtD;EACF,OAAO,IAAI,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,QAAsB;GAChE,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,aAAa;IAAE;GACvD;EACF;EAEA,OAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,CAAC;GAAE;EAC1C;CACF;CAMA,MAAM,EAAE,MAAM,UAJO,uBACnB,OAGiC;CAGnC,OAAO,cACJ,QAAgB,QACjB,OACA,GAAI,MAAM,QACZ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;;KAUY,YAAA,KACN,SAAA,sCAEF,cAAA,CAAe,CAAA,EAAG,KAAA;EACpB,KAAA,EAAO,CAAA;AAAA,IACL,eAAA,GACF,CAAA;AAAA,KAEG,uBAAA;EACH,KAAA,EAAO,CAAA;EACP,QAAA,EAAU,
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;;KAUY,YAAA,KACN,SAAA,sCAEF,cAAA,CAAe,CAAA,EAAG,KAAA;EACpB,KAAA,EAAO,CAAA;AAAA,IACL,eAAA,GACF,CAAA;AAAA,KAEG,uBAAA;EACH,KAAA,EAAO,CAAA;EACP,QAAA,EAAU,iBAAiB;EAC3B,eAAA;IAAA,CAAqB,GAAA;EAAA;AAAA;AAAA,cAGV,kBAAA;EAEX,QAAA;EAAA,KAAA;EAAA;AAAA,GAIC,uBAAA,CAAwB,CAAA,MAAK,YAAA,CAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;;KAKK,oBAAA;EACH,OAAA;EACA,OAAA;EACA,SAAA;EACA,cAAA;EACA,aAAA;EACA,WAAA;AAAA,IACE,IAAA,CAAK,GAAA,CAAI,cAAA,CAAe,cAAA;AAAA,cAEf,eAAA,EAAiB,
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;;KAKK,oBAAA;EACH,OAAA;EACA,OAAA;EACA,SAAA;EACA,cAAA;EACA,aAAA;EACA,WAAA;AAAA,IACE,IAAA,CAAK,GAAA,CAAI,cAAA,CAAe,cAAA;AAAA,cAEf,eAAA,EAAiB,mBAAmB,CAAC,oBAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$preact from "preact";
|
|
3
2
|
import { ComponentChild, FunctionComponent } from "preact";
|
|
4
3
|
|
|
5
4
|
//#region src/client/IntlayerProvider.d.ts
|
|
@@ -11,7 +10,7 @@ type IntlayerValue = {
|
|
|
11
10
|
/**
|
|
12
11
|
* Context that store the current locale on the client side
|
|
13
12
|
*/
|
|
14
|
-
declare const IntlayerClientContext:
|
|
13
|
+
declare const IntlayerClientContext: import("preact").Context<IntlayerValue>;
|
|
15
14
|
/**
|
|
16
15
|
* Hook that provides the current locale
|
|
17
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;KAaK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAa;EACpC,eAAA;AAAA;;;;cAMW,qBAAA,mBAAqB,OAAA,CAAA,aAAA;;;;cAQrB,kBAAA;AAAA,KAED,qBAAA;EACV,QAAA,GAAW,cAAA;EACX,MAAA,GAAS,aAAA;EACT,aAAA,GAAgB,aAAA;EAChB,SAAA,IAAa,MAAA,EAAQ,aAAA;EACrB,eAAA;AAAA;;;;cAMW,uBAAA,EAAyB,iBAAiB,CACrD,qBAAA;AAZF;;;;;;;;;;;;;;;;;;;;AAAA,cAyFa,gBAAA,EAAkB,iBAAiB,CAAC,qBAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
2
|
|
|
4
3
|
//#region src/client/useContent.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* On the client side, hook to get the translation content based on the locale
|
|
7
6
|
*/
|
|
8
7
|
declare const useContent: <Content>(languageContent: StrictModeLocaleMap<Content>) => {
|
|
9
|
-
locale:
|
|
8
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
10
9
|
content: Content;
|
|
11
10
|
t: <Content_1 = string>(languageContent: StrictModeLocaleMap<Content_1>) => Content_1;
|
|
12
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;AAOA;cAAa,UAAA,YACX,eAAA,EAAiB,mBAAA,CAAoB,OAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { IInterpreterPluginState
|
|
2
|
-
import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
1
|
+
import { IInterpreterPluginState } from "../plugins.js";
|
|
3
2
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
5
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
4
|
|
|
7
5
|
//#region src/client/useDictionary.d.ts
|
|
@@ -10,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
8
|
*
|
|
11
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
10
|
*/
|
|
13
|
-
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) =>
|
|
11
|
+
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => import("@intlayer/core/interpreter").DeepTransformContent<T["content"], IInterpreterPluginState, import("@intlayer/types").Locale>;
|
|
14
12
|
//#endregion
|
|
15
13
|
export { useDictionary };
|
|
16
14
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;AAcA;;cAAa,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,0CAAC,oBAAA,CAAA,CAAA,aAAA,uBAAA,4BAAA,MAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { IInterpreterPluginState
|
|
2
|
-
import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
1
|
+
import { IInterpreterPluginState } from "../plugins.js";
|
|
3
2
|
import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
4
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
5
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
4
|
|
|
7
5
|
//#region src/client/useDictionaryDynamic.d.ts
|
|
@@ -10,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
8
|
*
|
|
11
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
10
|
*/
|
|
13
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) =>
|
|
11
|
+
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => import("@intlayer/core/interpreter").DeepTransformContent<T["content"], IInterpreterPluginState, import("@intlayer/types").Locale>;
|
|
14
12
|
//#endregion
|
|
15
13
|
export { useDictionaryDynamic };
|
|
16
14
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;AAgBA;;cAAa,oBAAA,aACD,UAAA,YACA,cAAA,EAEV,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,0CAAa,oBAAA,CAAA,CAAA,aAAA,uBAAA,4BAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;KASK,cAAA;EACH,eAAA;EACA,cAAA,IAAkB,MAAA,EAAQ,
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;KASK,cAAA;EACH,eAAA;EACA,cAAA,IAAkB,MAAA,EAAQ,eAAe;AAAA;AAAA,KAGtC,eAAA;EACH,MAAA,EAAQ,eAAA;EACR,aAAA,EAAe,eAAA;EACf,gBAAA,EAAkB,eAAA;EAClB,SAAA,GAAY,MAAA,EAAQ,aAAA;AAAA;;AAPqB;AAAA;;;;;;;;;;;;;;;;;;;AAOR;AA0BnC;cAAa,SAAA;EAAa,eAAA;EAAA;AAAA,IAGvB,cAAA,KAAsB,eAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/client/useLocaleBase.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* On the client side, hook to get the current locale and all related fields
|
|
6
4
|
*/
|
|
7
5
|
declare const useLocaleBase: () => {
|
|
8
|
-
locale:
|
|
9
|
-
defaultLocale:
|
|
10
|
-
availableLocales:
|
|
11
|
-
setLocale: (newLocale:
|
|
6
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
7
|
+
defaultLocale: import("@intlayer/types").Locale;
|
|
8
|
+
availableLocales: import("@intlayer/types").Locale[];
|
|
9
|
+
setLocale: (newLocale: import("@intlayer/types").LocalesValues) => void;
|
|
12
10
|
};
|
|
13
11
|
//#endregion
|
|
14
12
|
export { useLocaleBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;AASA;;cAAa,aAAA"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
2
|
|
|
4
3
|
//#region src/client/useLocaleStorage.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Get the locale cookie
|
|
7
6
|
*/
|
|
8
|
-
declare const localeInStorage:
|
|
7
|
+
declare const localeInStorage: import("@intlayer/types").Locale;
|
|
9
8
|
/**
|
|
10
9
|
* @deprecated Use localeInStorage instead
|
|
11
10
|
*
|
|
12
11
|
* Get the locale cookie
|
|
13
12
|
*/
|
|
14
|
-
declare const localeCookie:
|
|
13
|
+
declare const localeCookie: import("@intlayer/types").Locale;
|
|
15
14
|
/**
|
|
16
15
|
* Set the locale cookie
|
|
17
16
|
*/
|
|
@@ -26,7 +25,7 @@ declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean)
|
|
|
26
25
|
* Hook that provides the locale storage and a function to set it
|
|
27
26
|
*/
|
|
28
27
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
29
|
-
getLocale: () =>
|
|
28
|
+
getLocale: () => import("@intlayer/types").Locale;
|
|
30
29
|
setLocale: (locale: LocalesValues) => void;
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
@@ -37,7 +36,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
37
36
|
* Hook that provides the locale cookie and a function to set it
|
|
38
37
|
*/
|
|
39
38
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
40
|
-
getLocale: () =>
|
|
39
|
+
getLocale: () => import("@intlayer/types").Locale;
|
|
41
40
|
setLocale: (locale: LocalesValues) => void;
|
|
42
41
|
};
|
|
43
42
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;AAYA;cAAa,eAAA,4BAAe,MAAmD;;;AAAA;AAM/E;;cAAa,YAAA,4BAAY,MAAkB;;AAAA;AAK3C;cAAa,kBAAA,GACX,MAAA,EAAQ,aAAa,EACrB,eAAA;;;;;;cAYW,eAAA,GAAe,MAAA,EAblB,aAAa,EAAA,eAAA;AACG;AAY1B;;AAZ0B,cAiBb,gBAAA,GAAoB,eAAA;;sBAQ9B,aAAA;AAAA;;;AAzBuB;AAiB1B;;;;cAiBa,eAAA,GAAe,eAAA;;sBAAmB,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTraduction.d.ts","names":[],"sources":["../../../src/client/useTraduction.ts"],"mappings":";;;;;AA0BA
|
|
1
|
+
{"version":3,"file":"useTraduction.d.ts","names":[],"sources":["../../../src/client/useTraduction.ts"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;AASC;;;;;cATY,cAAA,qBACX,eAAA,EAAiB,mBAAA,CAAoB,OAAA,MACpC,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"mappings":";;;;;YAOY,GAAA;IAAA,UACE,iBAAA;MACR,mCAAA,EAAqC,
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"mappings":";;;;;YAOY,GAAA;IAAA,UACE,iBAAA;MACR,mCAAA,EAAqC,cAAc,CAAC,WAAA;QAClD,UAAA;QACA,gBAAA;MAAA;IAAA;EAAA;AAAA;AAAA,KAMI,2BAAA,GAA8B,SAAA,GACxC,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAET,eAAA,EAAiB,mBAAmB,CAC/C,2BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"mappings":";;;cAGa,cAAA,EAAgB,
|
|
1
|
+
{"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"mappings":";;;cAGa,cAAA,EAAgB,iBAAiB;EAC5C,QAAA,GAAW,cAAA;AAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useCompact.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a compact number formatter
|
|
@@ -12,7 +10,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
12
10
|
* ```
|
|
13
11
|
*/
|
|
14
12
|
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
15
|
-
locale?:
|
|
13
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
16
14
|
}) => string;
|
|
17
15
|
//#endregion
|
|
18
16
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";;AAcA;;;;;;;;;cAAa,UAAA,SAAU,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useCurrency.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a currency formatter
|
|
@@ -26,7 +24,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
26
24
|
* ```
|
|
27
25
|
*/
|
|
28
26
|
declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
29
|
-
locale?:
|
|
27
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
30
28
|
}) => string;
|
|
31
29
|
//#endregion
|
|
32
30
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";;AA4BA;;;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,SAAW,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;;AA8BA
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;;AA8BA;;;;;;;;AAGyC;;;;;;;;;;;;;;;;cAH5B,OAAA,YAGA,IAAA,EAAM,UAAU,QAAQ,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":";;;;;;AAuBA
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":";;;;;;AAuBA;;;;;;;;AAKC;;;;;;;;cALY,OAAA,GAAW,MAAA,GAAS,aAAA,KAAa,WAK7C"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useList.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a list formatter
|
|
@@ -27,7 +25,7 @@ declare const useList: () => (values: (string | number)[], options?: {
|
|
|
27
25
|
type?: "conjunction" | "disjunction" | "unit";
|
|
28
26
|
style?: "long" | "short" | "narrow";
|
|
29
27
|
} & {
|
|
30
|
-
locale?:
|
|
28
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
31
29
|
}) => string;
|
|
32
30
|
//#endregion
|
|
33
31
|
export { useList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";;AAyBA;;;;;;;;;;;;;;;;;;;;cAAa,OAAA,SAAO,MAAA,uBAAA,OAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useNumber.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a localized number formatter.
|
|
@@ -24,7 +22,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
24
22
|
* A number formatting function bound to the active locale.
|
|
25
23
|
*/
|
|
26
24
|
declare const useNumber: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
27
|
-
locale?:
|
|
25
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
28
26
|
}) => string;
|
|
29
27
|
//#endregion
|
|
30
28
|
export { useNumber };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;AA0BA;;;;;;;;;;;;;;;;;;;;;cAAa,SAAA,SAAS,KAAA,mBAAA,MAAA,GAAA,IAAA,CAAA,mBAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/usePercentage.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React hook to provide a percentage formatter function
|
|
@@ -20,7 +18,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
20
18
|
* A function that formats numbers or numeric strings into localized percentages.
|
|
21
19
|
*/
|
|
22
20
|
declare const usePercentage: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
23
|
-
locale?:
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
24
22
|
}) => string;
|
|
25
23
|
//#endregion
|
|
26
24
|
export { usePercentage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;cAAa,aAAA,SAAa,KAAA,mBAAA,MAAA,GAAA,IAAA,CAAA,mBAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useRelativeTime.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* Client-side React hook for accessing a localized relative time formatter.
|
|
@@ -20,7 +18,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
20
18
|
* bound to the current client locale.
|
|
21
19
|
*/
|
|
22
20
|
declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
23
|
-
locale?:
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
24
22
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
25
23
|
}) => string;
|
|
26
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;cAAa,eAAA,SAAe,IAAA,oBAAA,IAAA,EAAA,EAAA,qBAAA,IAAA,EAAA,OAAA,GAAA,IAAA,CAAA,yBAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/format/useUnit.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React hook that provides a unit formatting function
|
|
@@ -19,7 +17,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
19
17
|
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
20
18
|
*/
|
|
21
19
|
declare const useUnit: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
22
|
-
locale?:
|
|
20
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
23
21
|
}) => string;
|
|
24
22
|
//#endregion
|
|
25
23
|
export { useUnit };
|