preact-intlayer 8.7.14 → 8.8.0
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/plugins.cjs +1 -0
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/plugins.mjs +2 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/useContent.d.ts +2 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +3 -3
- package/dist/types/client/useLocaleBase.d.ts +5 -5
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +2 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +2 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +2 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +2 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +2 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +2 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +2 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/types/intlayer/dist/types/index.d.ts +0 -4
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -232,6 +232,7 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
232
232
|
const plugins = [
|
|
233
233
|
(0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale, fallback ? _intlayer_config_built.internationalization.defaultLocale : void 0),
|
|
234
234
|
_intlayer_core_interpreter.enumerationPlugin,
|
|
235
|
+
(0, _intlayer_core_interpreter.pluralPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale),
|
|
235
236
|
_intlayer_core_interpreter.conditionPlugin,
|
|
236
237
|
(0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale),
|
|
237
238
|
_intlayer_core_interpreter.filePlugin,
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","editor","ContentSelector","fallbackPlugin","renderPreactElement","Fragment","NodeTypes","func","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\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\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 <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\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\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(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAM,+BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,QAAQ,IAAI,+BAA+B,UACvC,0EAEE,4BAA8B,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,Y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,IAAI,QAAQ,MAAM;AAChB,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAEW;;CAEf;AAmCP,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUC,4CAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;EACAC;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","editor","ContentSelector","fallbackPlugin","renderPreactElement","Fragment","NodeTypes","func","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n 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, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\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\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 <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\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\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(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n 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,+BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE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A;IACD,CAAC,CACH,CACF,iBAECA,wBACA,EAAE,UAAU,MAAM,gBAChB,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACR,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,SAAO,IAfW,MAAM,SAAS,EAC/B,IAAI,QAAQ,MAAM;AAChB,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAEW;;CAEf;AAmCP,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUC,4CAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;+CACa,UAAUD,4CAAqB,cAAc;EAC1DE;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
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 { renderPreactElement } from "./preactElement/renderPreactElement.mjs";
|
|
4
4
|
import { editor, internationalization } from "@intlayer/config/built";
|
|
5
|
-
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin } from "@intlayer/core/interpreter";
|
|
5
|
+
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, pluralPlugin, 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, createElement, h } from "preact";
|
|
@@ -229,6 +229,7 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
229
229
|
const plugins = [
|
|
230
230
|
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
|
|
231
231
|
enumerationPlugin,
|
|
232
|
+
pluralPlugin(locale ?? internationalization.defaultLocale),
|
|
232
233
|
conditionPlugin,
|
|
233
234
|
nestedPlugin(locale ?? internationalization.defaultLocale),
|
|
234
235
|
filePlugin,
|
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 translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\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\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 <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\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\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(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;AAiCA,MAAM,+BACJ,QAAQ,IAAI,mCAAmC,UAC3C,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,QAAQ,IAAI,mCAAmC,UAC3C,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,QAAQ,IAAI,+BAA+B,UACvC,OACA,WACE,OAAO,2BAAuB,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,m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B,UAAO,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;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":["func"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n 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, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\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\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 <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n 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\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\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\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(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n 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,+BACJ,QAAQ,IAAI,mCAAmC,UAC3C,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,QAAQ,IAAI,mCAAmC,UAC3C,OACA,WACE,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,QAAQ,IAAI,+BAA+B,UACvC,OACA,WACE,OAAO,2BAAuB,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OA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S,QACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,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;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { LocalesValues as LocalesValues$1 } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useContent.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* On the client side, hook to get the translation content based on the locale
|
|
7
7
|
*/
|
|
8
8
|
declare const useContent: <Content>(languageContent: StrictModeLocaleMap<Content>) => {
|
|
9
|
-
locale: LocalesValues
|
|
9
|
+
locale: _$_intlayer_types0.LocalesValues;
|
|
10
10
|
content: Content;
|
|
11
11
|
t: <Content_1 = string>(languageContent: StrictModeLocaleMap<Content_1>) => Content_1;
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;;;cAOa,UAAA,YACX,eAAA,EAAiB,mBAAA,CAAoB,OAAA;UAAD,
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;;;cAOa,UAAA,YACX,eAAA,EAAiB,mBAAA,CAAoB,OAAA;UAAD,kBAAA,CAAA,aAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
3
2
|
import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
4
3
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
5
5
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
6
|
|
|
7
7
|
//#region src/client/useDictionary.d.ts
|
|
@@ -10,7 +10,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
10
|
*
|
|
11
11
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
12
|
*/
|
|
13
|
-
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, Locale>;
|
|
13
|
+
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, _$_intlayer_types0.Locale>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useDictionary };
|
|
16
16
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;;;cAca,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;;;cAca,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,kBAAA,CAAA,MAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
3
2
|
import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
4
3
|
import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
4
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
5
5
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
6
|
|
|
7
7
|
//#region src/client/useDictionaryDynamic.d.ts
|
|
@@ -10,7 +10,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
10
|
*
|
|
11
11
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
12
|
*/
|
|
13
|
-
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, Locale>;
|
|
13
|
+
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, _$_intlayer_types0.Locale>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useDictionaryDynamic };
|
|
16
16
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;cAgBa,oBAAA,aACD,UAAA,YACA,cAAA,EAEV,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KAAa,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;cAgBa,oBAAA,aACD,UAAA,YACA,cAAA,EAEV,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KAAa,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,kBAAA,CAAA,MAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useLocale.d.ts
|
|
5
5
|
type useLocaleProps = {
|
|
@@ -34,8 +34,8 @@ declare const useLocale: ({
|
|
|
34
34
|
onLocaleChange
|
|
35
35
|
}?: useLocaleProps) => {
|
|
36
36
|
locale: LocalesValues;
|
|
37
|
-
defaultLocale: Locale;
|
|
38
|
-
availableLocales: Locale[];
|
|
37
|
+
defaultLocale: _$_intlayer_types0.Locale;
|
|
38
|
+
availableLocales: _$_intlayer_types0.Locale[];
|
|
39
39
|
setLocale: (locale: LocalesValues) => void;
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/client/useLocaleBase.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* On the client side, hook to get the current locale and all related fields
|
|
6
6
|
*/
|
|
7
7
|
declare const useLocaleBase: () => {
|
|
8
|
-
locale: LocalesValues;
|
|
9
|
-
defaultLocale: Locale;
|
|
10
|
-
availableLocales: Locale[];
|
|
11
|
-
setLocale: (newLocale: LocalesValues) => void;
|
|
8
|
+
locale: _$_intlayer_types0.LocalesValues;
|
|
9
|
+
defaultLocale: _$_intlayer_types0.Locale;
|
|
10
|
+
availableLocales: _$_intlayer_types0.Locale[];
|
|
11
|
+
setLocale: (newLocale: _$_intlayer_types0.LocalesValues) => void;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
14
|
export { useLocaleBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;;;cASa,aAAA;UASZ,aAAA"}
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;;;cASa,aAAA;UASZ,kBAAA,CAAA,aAAA"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useLocaleStorage.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Get the locale cookie
|
|
7
7
|
*/
|
|
8
|
-
declare const localeInStorage: Locale;
|
|
8
|
+
declare const localeInStorage: _$_intlayer_types0.Locale;
|
|
9
9
|
/**
|
|
10
10
|
* @deprecated Use localeInStorage instead
|
|
11
11
|
*
|
|
12
12
|
* Get the locale cookie
|
|
13
13
|
*/
|
|
14
|
-
declare const localeCookie: Locale;
|
|
14
|
+
declare const localeCookie: _$_intlayer_types0.Locale;
|
|
15
15
|
/**
|
|
16
16
|
* Set the locale cookie
|
|
17
17
|
*/
|
|
@@ -26,7 +26,7 @@ declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean)
|
|
|
26
26
|
* Hook that provides the locale storage and a function to set it
|
|
27
27
|
*/
|
|
28
28
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
29
|
-
getLocale: () => Locale;
|
|
29
|
+
getLocale: () => _$_intlayer_types0.Locale;
|
|
30
30
|
setLocale: (locale: LocalesValues) => void;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -37,7 +37,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
37
37
|
* Hook that provides the locale cookie and a function to set it
|
|
38
38
|
*/
|
|
39
39
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
40
|
-
getLocale: () => Locale;
|
|
40
|
+
getLocale: () => _$_intlayer_types0.Locale;
|
|
41
41
|
setLocale: (locale: LocalesValues) => void;
|
|
42
42
|
};
|
|
43
43
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;cAYa,eAAA,EAAkE,MAAA;;;;;
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;cAYa,eAAA,EAAkE,kBAAA,CAAnD,MAAA;;;;;AAM5B;cAAa,YAAA,EAA8B,kBAAA,CAAlB,MAAA;;;;cAKZ,kBAAA,GACX,MAAA,EAAQ,aAAA,EACR,eAAA;;;;;;cAYW,eAAA,GAAe,MAAA,EAblB,aAAA,EAAa,eAAA;;;AAavB;cAKa,gBAAA,GAAoB,eAAA;mBAQ9B,kBAAA,CAAA,MAAA;sBAAA,aAAA;AAAA;;;;;AARH;;;cAiBa,eAAA,GAAe,eAAA;mBAAmB,kBAAA,CAAA,MAAA;sBAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useCompact.d.ts
|
|
4
4
|
/**
|
|
@@ -12,7 +12,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
15
|
-
locale?: LocalesValues;
|
|
15
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
16
16
|
}) => string;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
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;WAAA,aAAA;AAAA"}
|
|
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;WAAA,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useCurrency.d.ts
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
29
|
-
locale?: LocalesValues;
|
|
29
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
30
30
|
}) => string;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
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;WAAA,aAAA;AAAA"}
|
|
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;WAAA,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useList.d.ts
|
|
4
4
|
/**
|
|
@@ -27,7 +27,7 @@ declare const useList: () => (values: (string | number)[], options?: {
|
|
|
27
27
|
type?: "conjunction" | "disjunction" | "unit";
|
|
28
28
|
style?: "long" | "short" | "narrow";
|
|
29
29
|
} & {
|
|
30
|
-
locale?: LocalesValues;
|
|
30
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
31
31
|
}) => string;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { useList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";;;;;;AAyBA;;;;;;;;;;;;;;;;;;cAAa,OAAA,SAAO,MAAA,uBAAA,OAAA;;;;;WAWnB,aAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";;;;;;AAyBA;;;;;;;;;;;;;;;;;;cAAa,OAAA,SAAO,MAAA,uBAAA,OAAA;;;;;WAWnB,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useNumber.d.ts
|
|
4
4
|
/**
|
|
@@ -24,7 +24,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
24
24
|
* A number formatting function bound to the active locale.
|
|
25
25
|
*/
|
|
26
26
|
declare const useNumber: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
27
|
-
locale?: LocalesValues;
|
|
27
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
28
28
|
}) => string;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { useNumber };
|
|
@@ -1 +1 @@
|
|
|
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;WAAA,aAAA;AAAA"}
|
|
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;WAAA,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/usePercentage.d.ts
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
20
20
|
* A function that formats numbers or numeric strings into localized percentages.
|
|
21
21
|
*/
|
|
22
22
|
declare const usePercentage: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
23
|
-
locale?: LocalesValues;
|
|
23
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
24
24
|
}) => string;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { usePercentage };
|
|
@@ -1 +1 @@
|
|
|
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;WAAA,aAAA;AAAA"}
|
|
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;WAAA,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useRelativeTime.d.ts
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
20
20
|
* bound to the current client locale.
|
|
21
21
|
*/
|
|
22
22
|
declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
23
|
-
locale?: LocalesValues;
|
|
23
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
24
24
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
25
25
|
}) => string;
|
|
26
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
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;WAAA,aAAA"}
|
|
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;WAAA,kBAAA,CAAA,aAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/format/useUnit.d.ts
|
|
4
4
|
/**
|
|
@@ -19,7 +19,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
19
19
|
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
20
20
|
*/
|
|
21
21
|
declare const useUnit: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
22
|
-
locale?: LocalesValues;
|
|
22
|
+
locale?: _$_intlayer_types0.LocalesValues;
|
|
23
23
|
}) => string;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { useUnit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";;;;;;AAqBA;;;;;;;;;;;;;;cAAa,OAAA,SAAO,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,aAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";;;;;;AAqBA;;;;;;;;;;;;;;cAAa,OAAA,SAAO,KAAA,mBAAA,OAAA,GAAA,IAAA,CAAA,mBAAA;WAAA,kBAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file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AA,EAAY,cAAA,CAAe,CAAA;EAC3B,kBAAA,EAAoB,gBAAA,CAAiB,CAAA;EACrC,eAAA,EAAiB,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA;EACrC,cAAA,EAAgB,YAAA,CAAa,CAAA;EAC7B,UAAA,EAAY,cAAA,CAAe,CAAA;AAAA;;;;;;KAQjB,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,UAAA;EACA,kBAAA;EACA,eAAA;EACA,cAAA;EACA,UAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAQ5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact-intlayer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@intlayer/api": "8.
|
|
104
|
-
"@intlayer/chokidar": "8.
|
|
105
|
-
"@intlayer/config": "8.
|
|
106
|
-
"@intlayer/core": "8.
|
|
107
|
-
"@intlayer/editor": "8.
|
|
108
|
-
"@intlayer/types": "8.
|
|
103
|
+
"@intlayer/api": "8.8.0",
|
|
104
|
+
"@intlayer/chokidar": "8.8.0",
|
|
105
|
+
"@intlayer/config": "8.8.0",
|
|
106
|
+
"@intlayer/core": "8.8.0",
|
|
107
|
+
"@intlayer/editor": "8.8.0",
|
|
108
|
+
"@intlayer/types": "8.8.0"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/node": "25.6.0",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LocalesValues as LocalesValues$1 } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Locale as Locale$1 } from "@intlayer/types/allLocales";
|
|
3
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
export { type Locale$1 as Locale, type LocalesValues$1 as LocalesValues };
|