react-intlayer 8.6.0 → 8.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +14 -14
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/plugins.mjs +15 -15
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -16,7 +16,7 @@ const useEditor = () => {
|
|
|
16
16
|
const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
17
17
|
const managerRef = (0, react.useRef)(null);
|
|
18
18
|
(0, react.useEffect)(() => {
|
|
19
|
-
if (
|
|
19
|
+
if (!_intlayer_editor_isEnabled.isEnabled) return;
|
|
20
20
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
21
21
|
const manager = initEditorClient();
|
|
22
22
|
managerRef.current = manager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (!isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;CAC1D,MAAM,+BAA+C,KAAK;AAE1D,4BAAgB;AACd,MAAI,CAACC,qCAAW;AAEhB,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,4BAAgB;AACd,MAAI,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -16,7 +16,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
16
16
|
const LazyMarkdownRendererPlugin = (0, react.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
17
17
|
const LazyHTMLRendererPlugin = (0, react.lazy)(() => Promise.resolve().then(() => require("./html/HTMLRendererPlugin.cjs")).then((m) => ({ default: m.HTMLRendererPlugin })));
|
|
18
18
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
19
|
-
const intlayerNodePlugins = {
|
|
19
|
+
const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
20
20
|
id: "intlayer-node-plugin",
|
|
21
21
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
22
22
|
transform: (_node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
@@ -29,7 +29,7 @@ const intlayerNodePlugins = {
|
|
|
29
29
|
})
|
|
30
30
|
};
|
|
31
31
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
32
|
-
const reactNodePlugins = {
|
|
32
|
+
const reactNodePlugins = process.env.INTLAYER_NODE_TYPE_REACT_NODE === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
33
33
|
id: "react-node-plugin",
|
|
34
34
|
canHandle: (node) => typeof node === "object" && typeof node?.props !== "undefined" && typeof node.key !== "undefined",
|
|
35
35
|
transform: (node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
@@ -50,7 +50,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
50
50
|
return (0, react.createElement)(react.Fragment, null, ...result.parts.map((part, index) => (0, react.createElement)(react.Fragment, { key: index }, part)));
|
|
51
51
|
};
|
|
52
52
|
/** Insertion plugin for React. Handles component/node insertion. */
|
|
53
|
-
const insertionPlugin = {
|
|
53
|
+
const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
54
54
|
id: "insertion-plugin",
|
|
55
55
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
|
|
56
56
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -91,7 +91,7 @@ const insertionPlugin = {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
94
|
-
const markdownStringPlugin = {
|
|
94
|
+
const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
95
95
|
id: "markdown-string-plugin",
|
|
96
96
|
canHandle: (node) => typeof node === "string",
|
|
97
97
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -159,7 +159,7 @@ const markdownPlugin = {
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
/** HTML plugin. Replaces node with a function that takes components => ReactNode. */
|
|
162
|
-
const htmlPlugin = {
|
|
162
|
+
const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
163
163
|
id: "html-plugin",
|
|
164
164
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
|
|
165
165
|
transform: (node, props) => {
|
|
@@ -190,17 +190,17 @@ const htmlPlugin = {
|
|
|
190
190
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
191
191
|
*/
|
|
192
192
|
const getPlugins = (locale, fallback = true) => [
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
(0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale, fallback ? _intlayer_config_built.default.internationalization.defaultLocale : void 0),
|
|
194
|
+
_intlayer_core_interpreter.enumerationPlugin,
|
|
195
|
+
_intlayer_core_interpreter.conditionPlugin,
|
|
196
|
+
(0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale),
|
|
197
|
+
_intlayer_core_interpreter.filePlugin,
|
|
198
|
+
_intlayer_core_interpreter.genderPlugin,
|
|
199
199
|
intlayerNodePlugins,
|
|
200
200
|
reactNodePlugins,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
insertionPlugin,
|
|
202
|
+
markdownPlugin,
|
|
203
|
+
htmlPlugin
|
|
204
204
|
].filter(Boolean);
|
|
205
205
|
|
|
206
206
|
//#endregion
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeTypes","Suspense","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n process.env.INTLAYER_NODE_TYPE_TRANSLATION !== 'false' &&\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n process.env.INTLAYER_NODE_TYPE_ENUMERATION !== 'false' && enumerationPlugin,\n process.env.INTLAYER_NODE_TYPE_CONDITION !== 'false' && conditionPlugin,\n process.env.INTLAYER_NODE_TYPE_NESTED !== 'false' &&\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n process.env.INTLAYER_NODE_TYPE_FILE !== 'false' && filePlugin,\n process.env.INTLAYER_NODE_TYPE_GENDER !== 'false' && genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n reactNodePlugins,\n process.env.INTLAYER_NODE_TYPE_INSERTION !== 'false' && insertionPlugin,\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' && markdownPlugin,\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false' && htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,MAAM,wFACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,oFACJ,kCAAoC,MAAM,OAAO,EAC/C,SAAS,EAAE,oBACZ,EAAE,CACJ;;AAWD,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wC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,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;;;;;AAuCD,MAAa,cACX,QACA,WAAoB,SAEpB;CACE,QAAQ,IAAI,mCAAmC,6DAE3C,UAAUL,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACH,QAAQ,IAAI,mCAAmC,WAAWM;CAC1D,QAAQ,IAAI,iCAAiC,WAAWC;CACxD,QAAQ,IAAI,8BAA8B,wDAC3B,UAAUP,+BAAc,qBAAqB,cAAc;CAC1E,QAAQ,IAAI,4BAA4B,WAAWQ;CACnD,QAAQ,IAAI,8BAA8B,WAAWC;CAErD;CACA;CACA,QAAQ,IAAI,iCAAiC,WAAW;CACxD,QAAQ,IAAI,gCAAgC,WAAW;CACvD,QAAQ,IAAI,4BAA4B,WAAW;CACpD,CAAC,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeTypes","Suspense","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_REACT_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n {renderReactElement(node)}\n </ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n 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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins =\n 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\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n // Env var allows the bundler to to remove the plugin if not used to make the bundle smaller\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAM,wFACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,oFACJ,kCAAoC,MAAM,OAAO,EAC/C,SAAS,EAAE,oBACZ,EAAE,CACJ;;AAWD,MAAa,sBACX,QAAQ,IAAI,qCAAqC,UAC7CA,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UAAUC,+BAAc,OAAO,UAC7B,2CAACC,gDAAD;GAAiB,GAAI;aAAO,K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AAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;;;;;AAuCP,MAAa,cACX,QACA,WAAoB,SAEpB;mDAGI,UAAUL,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDM;CACAC;8CACa,UAAUP,+BAAc,qBAAqB,cAAc;CACxEQ;CACAC;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
|
|
@@ -14,7 +14,7 @@ const useEditor = () => {
|
|
|
14
14
|
const { locale } = useContext(IntlayerClientContext) ?? {};
|
|
15
15
|
const managerRef = useRef(null);
|
|
16
16
|
useEffect(() => {
|
|
17
|
-
if (
|
|
17
|
+
if (!isEnabled) return;
|
|
18
18
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
19
19
|
const manager = initEditorClient();
|
|
20
20
|
managerRef.current = manager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (!isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAC1D,MAAM,aAAa,OAAkC,KAAK;AAE1D,iBAAgB;AACd,MAAI,CAAC,UAAW;AAEhB,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,iBAAgB;AACd,MAAI,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { ContentSelector } from "./editor/ContentSelector.mjs";
|
|
|
2
2
|
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
3
3
|
import { renderReactElement } from "./reactElement/renderReactElement.mjs";
|
|
4
4
|
import configuration from "@intlayer/config/built";
|
|
5
|
-
import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, nestedPlugin, splitInsertionTemplate, translationPlugin } from "@intlayer/core/interpreter";
|
|
5
|
+
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, splitInsertionTemplate, translationPlugin } from "@intlayer/core/interpreter";
|
|
6
6
|
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
7
7
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
8
8
|
import { Fragment, Suspense, createElement, lazy } from "react";
|
|
@@ -12,7 +12,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
12
12
|
const LazyMarkdownRendererPlugin = lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
13
13
|
const LazyHTMLRendererPlugin = lazy(() => import("./html/HTMLRendererPlugin.mjs").then((m) => ({ default: m.HTMLRendererPlugin })));
|
|
14
14
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
15
|
-
const intlayerNodePlugins = {
|
|
15
|
+
const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? fallbackPlugin : {
|
|
16
16
|
id: "intlayer-node-plugin",
|
|
17
17
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
18
18
|
transform: (_node, { plugins, ...rest }) => renderIntlayerNode({
|
|
@@ -25,7 +25,7 @@ const intlayerNodePlugins = {
|
|
|
25
25
|
})
|
|
26
26
|
};
|
|
27
27
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
28
|
-
const reactNodePlugins = {
|
|
28
|
+
const reactNodePlugins = process.env.INTLAYER_NODE_TYPE_REACT_NODE === "false" ? fallbackPlugin : {
|
|
29
29
|
id: "react-node-plugin",
|
|
30
30
|
canHandle: (node) => typeof node === "object" && typeof node?.props !== "undefined" && typeof node.key !== "undefined",
|
|
31
31
|
transform: (node, { plugins, ...rest }) => renderIntlayerNode({
|
|
@@ -46,7 +46,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
46
46
|
return createElement(Fragment, null, ...result.parts.map((part, index) => createElement(Fragment, { key: index }, part)));
|
|
47
47
|
};
|
|
48
48
|
/** Insertion plugin for React. Handles component/node insertion. */
|
|
49
|
-
const insertionPlugin = {
|
|
49
|
+
const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? fallbackPlugin : {
|
|
50
50
|
id: "insertion-plugin",
|
|
51
51
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
52
52
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -87,7 +87,7 @@ const insertionPlugin = {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
90
|
-
const markdownStringPlugin = {
|
|
90
|
+
const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
91
91
|
id: "markdown-string-plugin",
|
|
92
92
|
canHandle: (node) => typeof node === "string",
|
|
93
93
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -155,7 +155,7 @@ const markdownPlugin = {
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
/** HTML plugin. Replaces node with a function that takes components => ReactNode. */
|
|
158
|
-
const htmlPlugin = {
|
|
158
|
+
const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
|
|
159
159
|
id: "html-plugin",
|
|
160
160
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
161
161
|
transform: (node, props) => {
|
|
@@ -186,17 +186,17 @@ const htmlPlugin = {
|
|
|
186
186
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
187
187
|
*/
|
|
188
188
|
const getPlugins = (locale, fallback = true) => [
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
translationPlugin(locale ?? configuration.internationalization.defaultLocale, fallback ? configuration.internationalization.defaultLocale : void 0),
|
|
190
|
+
enumerationPlugin,
|
|
191
|
+
conditionPlugin,
|
|
192
|
+
nestedPlugin(locale ?? configuration.internationalization.defaultLocale),
|
|
193
|
+
filePlugin,
|
|
194
|
+
genderPlugin,
|
|
195
195
|
intlayerNodePlugins,
|
|
196
196
|
reactNodePlugins,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
insertionPlugin,
|
|
198
|
+
markdownPlugin,
|
|
199
|
+
htmlPlugin
|
|
200
200
|
].filter(Boolean);
|
|
201
201
|
|
|
202
202
|
//#endregion
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n process.env.INTLAYER_NODE_TYPE_TRANSLATION !== 'false' &&\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n process.env.INTLAYER_NODE_TYPE_ENUMERATION !== 'false' && enumerationPlugin,\n process.env.INTLAYER_NODE_TYPE_CONDITION !== 'false' && conditionPlugin,\n process.env.INTLAYER_NODE_TYPE_NESTED !== 'false' &&\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n process.env.INTLAYER_NODE_TYPE_FILE !== 'false' && filePlugin,\n process.env.INTLAYER_NODE_TYPE_GENDER !== 'false' && genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n reactNodePlugins,\n process.env.INTLAYER_NODE_TYPE_INSERTION !== 'false' && insertionPlugin,\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' && markdownPlugin,\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false' && htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;AAyCA,MAAM,6BAA6B,WACjC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,yBAAyB,WAC7B,OAAO,iCAA6B,MAAM,OAAO,EAC/C,SAAS,EAAE,oBACZ,EAAE,CACJ;;AAWD,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,UAAU,cAAc,OAAO,UAC7B,oBAAC,iBAAD;GAAiB,GAAI;aAAO,KAAK;GAA2B,IAE5D,KAAK;EAER,CAAC;CACL;;AAcD,MAAa,mBAA4B;CACvC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,MAAM,UAAU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C,WAAW;CACxD,QAAQ,IAAI,8BAA8B,WACxC,aAAa,UAAU,cAAc,qBAAqB,cAAc;CAC1E,QAAQ,IAAI,4BAA4B,WAAW;CACnD,QAAQ,IAAI,8BAA8B,WAAW;CAErD;CACA;CACA,QAAQ,IAAI,iCAAiC,WAAW;CACxD,QAAQ,IAAI,gCAAgC,WAAW;CACvD,QAAQ,IAAI,4BAA4B,WAAW;CACpD,CAAC,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_REACT_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n {renderReactElement(node)}\n </ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [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', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n 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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === 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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins =\n 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\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n // Env var allows the bundler to to remove the plugin if not used to make the bundle smaller\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;AA0CA,MAAM,6BAA6B,WACjC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,yBAAyB,WAC7B,OAAO,iCAA6B,MAAM,OAAO,EAC/C,SAAS,EAAE,oBACZ,EAAE,CACJ;;AAWD,MAAa,sBACX,QAAQ,IAAI,qCAAqC,UAC7C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UAAU,cAAc,OAAO,UAC7B,oBAAC,iBAAD;GAAiB,GAAI;aAAO,KAAK;GAA2B,IAE5D,KAAK;EAER,CAAC;CACL;;AAcP,MAAa,mBACX,QAAQ,IAAI,kCAAkC,UAC1C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,MAAM,UAAU,eACvB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO;EACP,UAAU,cAAc,OAAO,UAC7B,oBAAC,iBAAD;GAAiB,GAAI;aAClB,mBAAmB,KAAK;GACT,IA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
* If the locale is not provided, it will use the locale from the client context
|
|
11
11
|
*/
|
|
12
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, "
|
|
12
|
+
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "id" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ms" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi" | "mi-NZ" | "mr" | "mr-IN" | "mn" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA" | (string & {})>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { useDictionaryDynamic };
|
|
15
15
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ declare const useMarkdownRenderer: ({
|
|
|
70
70
|
forceInline,
|
|
71
71
|
preserveFrontmatter,
|
|
72
72
|
tagfilter
|
|
73
|
-
}?: RenderMarkdownProps$1) => (content: string) => string | number | bigint | boolean |
|
|
73
|
+
}?: RenderMarkdownProps$1) => (content: string) => string | number | bigint | boolean | _$react.JSX.Element | Iterable<_$react.ReactNode> | Promise<_$react.ReactNode>;
|
|
74
74
|
/**
|
|
75
75
|
* @deprecated import from react-intlayer/markdown instead
|
|
76
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,uBAAA,CAAwB,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;;;;AAJe;;;AAAA,cAwD5C,gBAAA,UAAgB,EAAA,CAAA,yBAAA;eAAA,cAAA;;gDAtBX,yBAAA,EAAA,UAAA,GAAA,cAAA,oBAEZ,OAAA,GACN,OAAA,CAAA,EAAA,CAAA,OAAA,CAAA,cAAA,CAAA,WAAA,OAAA,OAAA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AA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;AAAA;;;;KAwCV,uBAAA,GAA0B,yBAAA;;AARtC;;cAYa,cAAA,GAAc,OAAA;EAAA,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,KAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;;;cAId,mBAAA;EAAmB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,MAa44C,OAAA,kDAAe,OAAA,CAAA,GAAA,CAAA,OAAA,GAAA,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,CAAA,OAAA,CAAA,SAAA;;;;cAT96C,gBAAA,EAAgB,OAAA,CAAA,EAAA,CAAA,uBAAA;;;;KAIjB,mBAAA,GAAsB,qBAAA;;;;KAItB,qBAAA,GAAwB,uBAAA"}
|
|
@@ -133,7 +133,7 @@ declare const useMarkdownRenderer: ({
|
|
|
133
133
|
forceInline,
|
|
134
134
|
preserveFrontmatter,
|
|
135
135
|
tagfilter
|
|
136
|
-
}?: RenderMarkdownProps) => (content: string) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<ReactNode
|
|
136
|
+
}?: RenderMarkdownProps) => (content: string) => string | number | bigint | boolean | JSX.Element | Iterable<ReactNode> | Promise<ReactNode>;
|
|
137
137
|
/**
|
|
138
138
|
* Props for the MarkdownRenderer component.
|
|
139
139
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;AA6BA;;;;;;;;;;;;;;;;;KAAY,mBAAA,GAAsB,uBAAA;EAwBO;AA4BzC;;;;;;;;;;;;EAtCE,UAAA,GAAa,cAAA;EAuCb;;;;;;;;;EA7BA,OAAA,GAAU,EAAA,CAAG,cAAA,CAAe,WAAA;AAAA;;;;;;;;AA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;IACA,WAAA;IACA,mBAAA;IACA,SAAA;EAAA,MAEC,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgEd,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;AA0DA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;;cAIJ,mBAAA,EAAqB,OAAA;;;;KA+BtB,aAAA,MAAmB,CAAA;EAC7B,KAAA;EACA,GAAA;AAAA,IAEE,SAAA;;cAIS,gBAAA,EAAkB,OAAA;;AAvC/B;;KAyEY,aAAA,MAAmB,CAAA;EAC7B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,SAAA;EACX,MAAA;AAAA,uBAEqB,CAAA,qBAAsB,SAAA,IACvC,MAAA,EAAQ,CAAA,KACL,CAAA,OAAQ,CAAA,4BACT,YAAA,WACA,YAAA,CAAa,SAAA;;cA4BR,eAAA,EAAiB,OAAA;;;;KAuFlB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAGI,QAAA,EAAU,oBAAA;EACV,GAAA,GAAM,UAAA,EAAY,cAAA,uBAAqC,SAAA;AAAA;;cAMlD,oBAAA,EAAsB,OAAA;AAAA,KAwFvB,YAAA,MAAkB,CAAA;EAC5B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,QAAA;EACX,IAAA;EACA,QAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,SAAA;EACvD,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAK1B,cAAA,EAAgB,OAAA;;;;;;;;;;;;KAmCjB,cAAA,MAAoB,CAAA;EAC9B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,SAAA;AAAA;;cAMlD,UAAA,EAAY,OAAA;;;;KAoDb,uBAAA,mBAA0C,aAAA;EACpD,SAAA,EAAW,aAAA,CAAc,CAAA;EACzB,iBAAA,EAAmB,gBAAA,CAAiB,CAAA;EACpC,cAAA,EAAgB,aAAA,CAAc,CAAA;EAC9B,aAAA,EAAe,YAAA,CAAa,CAAA;EAC5B,SAAA,EAAW,cAAA,CAAe,CAAA;AAAA;;;;AA5N5B;;KAoOY,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,SAAA;EACA,iBAAA;EACA,aAAA;EACA,SAAA;EACA,cAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAM5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -123,14 +123,14 @@
|
|
|
123
123
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
|
-
"@intlayer/api": "8.6.
|
|
127
|
-
"@intlayer/config": "8.6.
|
|
128
|
-
"@intlayer/core": "8.6.
|
|
129
|
-
"@intlayer/dictionaries-entry": "8.6.
|
|
130
|
-
"@intlayer/editor": "8.6.
|
|
131
|
-
"@intlayer/editor-react": "8.6.
|
|
132
|
-
"@intlayer/types": "8.6.
|
|
133
|
-
"intlayer": "8.6.
|
|
126
|
+
"@intlayer/api": "8.6.2",
|
|
127
|
+
"@intlayer/config": "8.6.2",
|
|
128
|
+
"@intlayer/core": "8.6.2",
|
|
129
|
+
"@intlayer/dictionaries-entry": "8.6.2",
|
|
130
|
+
"@intlayer/editor": "8.6.2",
|
|
131
|
+
"@intlayer/editor-react": "8.6.2",
|
|
132
|
+
"@intlayer/types": "8.6.2",
|
|
133
|
+
"intlayer": "8.6.2"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
136
|
"@craco/types": "7.1.0",
|