preact-intlayer 9.5.9 → 9.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerNode.cjs +16 -18
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs +27 -21
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +12 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +29 -44
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +16 -18
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +29 -23
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +13 -3
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/plugins.mjs +29 -44
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +10 -0
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +4 -5
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +14 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +1 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +1 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +1 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +1 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +1 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +1 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +1 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +3 -3
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +6 -1
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/types/intlayer/dist/types/index.d.ts +0 -14
package/dist/esm/plugins.mjs
CHANGED
|
@@ -22,20 +22,26 @@ htmlRendererModulePromise?.catch(() => {});
|
|
|
22
22
|
const intlayerNodePlugins = {
|
|
23
23
|
id: "intlayer-node-plugin",
|
|
24
24
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
25
|
-
transform: (_node,
|
|
25
|
+
transform: (_node, props) => {
|
|
26
26
|
if (process.env.INTLAYER_ANALYTICS_ENABLED !== "false") reportExposure({
|
|
27
|
-
dictionaryKey:
|
|
28
|
-
keyPath:
|
|
29
|
-
locale:
|
|
27
|
+
dictionaryKey: props.dictionaryKey,
|
|
28
|
+
keyPath: props.keyPath,
|
|
29
|
+
locale: props.locale,
|
|
30
30
|
nodeType: "text"
|
|
31
31
|
});
|
|
32
|
+
if (process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled) {
|
|
33
|
+
const { plugins, ...rest } = props;
|
|
34
|
+
return renderIntlayerNode({
|
|
35
|
+
value: rest.children,
|
|
36
|
+
children: /* @__PURE__ */ createElement(ContentSelector, {
|
|
37
|
+
...rest,
|
|
38
|
+
key: rest.children
|
|
39
|
+
}, rest.children)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
32
42
|
return renderIntlayerNode({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && editor.enabled ? /* @__PURE__ */ createElement(ContentSelector, {
|
|
36
|
-
...rest,
|
|
37
|
-
key: rest.children
|
|
38
|
-
}, rest.children) : rest.children
|
|
43
|
+
value: props.children,
|
|
44
|
+
children: props.children
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
};
|
|
@@ -177,22 +183,12 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
177
183
|
components,
|
|
178
184
|
children: node
|
|
179
185
|
}),
|
|
180
|
-
additionalProps: {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return new Proxy(element, { get(target, prop) {
|
|
184
|
-
if (prop === "value") return node;
|
|
185
|
-
if (prop === Symbol.toPrimitive) return () => node;
|
|
186
|
-
if (prop === "toString") return () => node;
|
|
187
|
-
if (prop === "valueOf") return () => node;
|
|
188
|
-
if (typeof prop === "string" && prop !== "constructor") {
|
|
189
|
-
const method = String.prototype[prop];
|
|
190
|
-
if (typeof method === "function") return method.bind(node);
|
|
186
|
+
additionalProps: {
|
|
187
|
+
metadata: metadataNodes,
|
|
188
|
+
use: render
|
|
191
189
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return Reflect.get(target, prop);
|
|
195
|
-
} });
|
|
190
|
+
});
|
|
191
|
+
return render();
|
|
196
192
|
}
|
|
197
193
|
};
|
|
198
194
|
const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
|
|
@@ -229,21 +225,10 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
|
|
|
229
225
|
...rest,
|
|
230
226
|
html,
|
|
231
227
|
components: userComponents
|
|
232
|
-
})
|
|
228
|
+
}),
|
|
229
|
+
additionalProps: { use: render }
|
|
233
230
|
});
|
|
234
|
-
|
|
235
|
-
return new Proxy(element, { get(target, prop) {
|
|
236
|
-
if (prop === "value") return html;
|
|
237
|
-
if (prop === Symbol.toPrimitive) return () => html;
|
|
238
|
-
if (prop === "toString") return () => html;
|
|
239
|
-
if (prop === "valueOf") return () => html;
|
|
240
|
-
if (typeof prop === "string" && prop !== "constructor") {
|
|
241
|
-
const method = String.prototype[prop];
|
|
242
|
-
if (typeof method === "function") return method.bind(html);
|
|
243
|
-
}
|
|
244
|
-
if (prop === "use") return (userComponents) => render(userComponents);
|
|
245
|
-
return Reflect.get(target, prop);
|
|
246
|
-
} });
|
|
231
|
+
return render();
|
|
247
232
|
}
|
|
248
233
|
};
|
|
249
234
|
const pluginsCache = /* @__PURE__ */ new Map();
|
|
@@ -254,7 +239,8 @@ const pluginsCache = /* @__PURE__ */ new Map();
|
|
|
254
239
|
const getPlugins = (locale, fallback = true) => {
|
|
255
240
|
const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;
|
|
256
241
|
if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
|
|
257
|
-
const
|
|
242
|
+
const enabledPlugins = [
|
|
243
|
+
intlayerNodePlugins,
|
|
258
244
|
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
|
|
259
245
|
enumerationPlugin,
|
|
260
246
|
pluralPlugin(locale ?? internationalization.defaultLocale),
|
|
@@ -263,14 +249,13 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
263
249
|
filePlugin,
|
|
264
250
|
genderPlugin,
|
|
265
251
|
selectPlugin,
|
|
266
|
-
intlayerNodePlugins,
|
|
267
252
|
preactNodePlugins,
|
|
268
253
|
insertionPlugin,
|
|
269
254
|
markdownPlugin,
|
|
270
255
|
htmlPlugin
|
|
271
|
-
];
|
|
272
|
-
pluginsCache.set(cacheKey,
|
|
273
|
-
return
|
|
256
|
+
].filter((plugin) => plugin !== fallbackPlugin);
|
|
257
|
+
pluginsCache.set(cacheKey, enabledPlugins);
|
|
258
|
+
return enabledPlugins;
|
|
274
259
|
};
|
|
275
260
|
|
|
276
261
|
//#endregion
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { lazy } from 'preact/compat';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n// These preloads are read later by `useLoadDynamic`, so the rejection must stay\n// on the promise: a `.catch()` chained into it would resolve with `undefined`\n// and be mistaken for a loaded module. Handle it on the side instead, so an\n// aborted chunk load never escapes as an unhandled rejection.\nmarkdownRendererModulePromise?.catch(() => {});\nhtmlRendererModulePromise?.catch(() => {});\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 // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'text',\n });\n }\n\n return 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/** ---------------------------------------------\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 if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'preact-node',\n });\n }\n\n return 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/** ---------------------------------------------\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) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n // VNodes cannot be injected into a raw markup string, so string\n // interpolation (not `splitAndJoinInsertion`) is used here.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\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 return resolveInsertedSelector(children, 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/**\n * Code-split renderers are loaded with `lazy` rather than a hand-rolled\n * suspender. A node that suspended on the hand-rolled one never recovered once\n * the chunk landed, so every markdown node present on the first paint stayed\n * blank forever; `lazy` implements the suspend/retry handshake correctly.\n */\nconst MarkdownSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownRendererPlugin as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\nconst MarkdownMetadataSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownMetadataRenderer as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer = lazy(() =>\n htmlRendererModulePromise!.then((HTMLRenderer) => ({\n default: HTMLRenderer as FunctionComponent<Record<string, any>>,\n }))\n);\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n // `children` is dropped deliberately: `HTMLRenderer` resolves its\n // content as `children || html`, so forwarding the raw node here would\n // shadow the HTML string and render nothing.\n const { plugins, children: _nodeChildren, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n })\n )\n : h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\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') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\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":";;;;;;;;;;;;;AAuCA,MAAM,gCACJ,QAAQ,IAAI,gCAAgC,UACxC,OAAO,wCAAoC,CAAC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;AAC9B,EAAE,IACF;AAEN,MAAM,4BACJ,QAAQ,IAAI,4BAA4B,UACpC,OAAO,0BAAsB,CAAC,MAAM,MAAM,EAAE,YAAY,IACxD;AAMN,+BAA+B,YAAY,CAAC,CAAC;AAC7C,2BAA2B,YAAY,CAAC,CAAC;;AAWzC,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,S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D;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { lazy } from 'preact/compat';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n// These preloads are read later by `useLoadDynamic`, so the rejection must stay\n// on the promise: a `.catch()` chained into it would resolve with `undefined`\n// and be mistaken for a loaded module. Handle it on the side instead, so an\n// aborted chunk load never escapes as an unhandled rejection.\nmarkdownRendererModulePromise?.catch(() => {});\nhtmlRendererModulePromise?.catch(() => {});\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: (_node, props) => {\n // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: props.dictionaryKey,\n keyPath: props.keyPath,\n locale: props.locale,\n nodeType: 'text',\n });\n }\n\n // Props are only forwarded to the editor selector: copying them for every\n // leaf would cost an allocation per rendered string\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n return renderIntlayerNode({\n value: rest.children,\n children: (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ),\n });\n }\n\n return renderIntlayerNode({\n value: props.children,\n children: props.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 if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'preact-node',\n });\n }\n\n return 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/** ---------------------------------------------\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) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n // VNodes cannot be injected into a raw markup string, so string\n // interpolation (not `splitAndJoinInsertion`) is used here.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\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 return resolveInsertedSelector(children, 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/**\n * Code-split renderers are loaded with `lazy` rather than a hand-rolled\n * suspender. A node that suspended on the hand-rolled one never recovered once\n * the chunk landed, so every markdown node present on the first paint stayed\n * blank forever; `lazy` implements the suspend/retry handshake correctly.\n */\nconst MarkdownSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownRendererPlugin as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\nconst MarkdownMetadataSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownMetadataRenderer as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n use: render,\n },\n });\n\n return render() as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer = lazy(() =>\n htmlRendererModulePromise!.then((HTMLRenderer) => ({\n default: HTMLRenderer as FunctionComponent<Record<string, any>>,\n }))\n);\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n // `children` is dropped deliberately: `HTMLRenderer` resolves its\n // content as `children || html`, so forwarding the raw node here would\n // shadow the HTML string and render nothing.\n const { plugins, children: _nodeChildren, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n })\n )\n : h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n }),\n additionalProps: { use: render },\n }) as any;\n\n return render();\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 // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\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 selectPlugin,\n // Always include: handle plain strings/numbers and React elements\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return enabledPlugins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AQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAK,UAAU;EACd,KAAK;EAInB,MAAM,EAAE,SAAS,UAAU,eAAe,GAAG,SAAS;EAGtD,MAAM,UAAU,mBACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,QAAQ,IAAI,4BAA4B,WACxC,OAAO,UACH,EACE,iBACA,EAAE,GAAG,KAAK,GACV,EAAE,sBAAsB;IACtB,GAAG;IACH;IACA,YAAY;GACd,CAAC,CACH,IACA,EAAE,sBAAsB;IACtB,GAAG;IACH;IACA,YAAY;GACd,CAAC;GACP,iBAAiB,EAAE,KAAK,OAAO;EACjC,CAAC;EAEH,OAAO,OAAO;CAChB;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAyBlC,MAAM,iBAAiB;EApBrB;EACA,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EACA;EAEA;EACA;EACA;EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAW,cAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
|
|
@@ -12,6 +12,16 @@ type RenderIntlayerNodeProps<T> = {
|
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Renders content as a Preact vnode that also behaves like its value
|
|
17
|
+
* (`node.value`, `${node}`, `node.toUpperCase()`).
|
|
18
|
+
*
|
|
19
|
+
* The node is a copy of the vnode built on a shared prototype serving the
|
|
20
|
+
* value's members, rather than a Proxy, so the renderer reads plain fields.
|
|
21
|
+
*
|
|
22
|
+
* @param props - The value, the rendered children and extra node members.
|
|
23
|
+
* @returns The renderable node.
|
|
24
|
+
*/
|
|
15
25
|
export declare const renderIntlayerNode: <T>({ children, value, additionalProps }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
16
26
|
//#endregion
|
|
17
27
|
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;YAWY,aACV,IAAI,uBACJ,wBACE,eAAe,GAAG;EACpB,OAAO;IACL,kBACF;KAEG,wBAAwB;EAC3B,OAAO;EACP,UAAU;EACV;KAAqB;;;;;;;;;;;;;qBAaV,qBACX,KAAC,UAAA,OAAA,mBAKA,wBAAwB,OAAK,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAuBK;EACH,QAAQ;EACR,YAAY,WAAW;;;;;EAKvB,UAAU;EACV;;;;;qBAMW,wCAAqB,QAAA;;;;qBAWrB;YAED;EACV,WAAW;EACX,SAAS;EACT,gBAAgB;;;;;;;;;;;;;;;;;;EAkBhB,UAAU;EACV,aAAa,QAAQ;EACrB;;;;;qBAMW,yBAAyB,kBACpC;;;;;;;;;;;;;;;;;;;;;qBAsFW,kBAAkB,kBAAkB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues as LocalesValues$1 } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { useTranslation } from "./useTraduction.js";
|
|
3
2
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
4
3
|
//#region src/client/useContent.d.ts
|
|
@@ -6,7 +5,7 @@ import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
|
6
5
|
* On the client side, hook to get the translation content based on the locale
|
|
7
6
|
*/
|
|
8
7
|
export declare const useContent: <Content>(languageContent: StrictModeLocaleMap<Content>) => {
|
|
9
|
-
locale: LocalesValues
|
|
8
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
10
9
|
content: Content;
|
|
11
10
|
t: typeof useTranslation;
|
|
12
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;;qBAOa,aAAc,SAAO,iBACf,oBAAoB"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Locale, LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/useLocaleBase.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* On the client side, hook to get the current locale and all related fields
|
|
5
4
|
*/
|
|
6
5
|
export declare const useLocaleBase: () => {
|
|
7
|
-
locale: LocalesValues;
|
|
8
|
-
defaultLocale: Locale;
|
|
9
|
-
availableLocales: Locale[];
|
|
10
|
-
setLocale: (newLocale: LocalesValues) => void;
|
|
6
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
7
|
+
defaultLocale: import("@intlayer/types").Locale;
|
|
8
|
+
availableLocales: import("@intlayer/types").Locale[];
|
|
9
|
+
setLocale: (newLocale: import("@intlayer/types").LocalesValues) => void;
|
|
11
10
|
};
|
|
12
11
|
//#endregion
|
|
13
12
|
//# sourceMappingURL=useLocaleBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;qBASa"}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
//#region src/client/useLocaleStorage.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
5
|
+
*
|
|
6
|
+
* Unlike `localeInStorage`, read on first call rather than at import, then
|
|
7
|
+
* cached until the next `setLocaleInStorage`. Never cached on the server.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getLocaleInStorage: () => import("@intlayer/types").Locale | undefined;
|
|
4
10
|
/**
|
|
5
11
|
* Get the locale cookie
|
|
12
|
+
*
|
|
13
|
+
* Read once at import time; marked pure so bundlers drop the read when nothing
|
|
14
|
+
* imports it.
|
|
6
15
|
*/
|
|
7
|
-
export declare const localeInStorage: Locale;
|
|
16
|
+
export declare const localeInStorage: import("@intlayer/types").Locale;
|
|
8
17
|
/**
|
|
9
18
|
* @deprecated Use localeInStorage instead
|
|
10
19
|
*
|
|
11
20
|
* Get the locale cookie
|
|
12
21
|
*/
|
|
13
|
-
export declare const localeCookie: Locale;
|
|
22
|
+
export declare const localeCookie: import("@intlayer/types").Locale;
|
|
14
23
|
/**
|
|
15
24
|
* Set the locale cookie
|
|
16
25
|
*/
|
|
17
|
-
export declare const setLocaleInStorage: (locale: LocalesValues, isCookieEnabled
|
|
26
|
+
export declare const setLocaleInStorage: (locale: LocalesValues, isCookieEnabled?: boolean) => void;
|
|
18
27
|
/**
|
|
19
28
|
* @deprecated Use setLocaleInStorage instead
|
|
20
29
|
*
|
|
@@ -25,7 +34,7 @@ export declare const setLocaleCookie: typeof setLocaleInStorage;
|
|
|
25
34
|
* Hook that provides the locale storage and a function to set it
|
|
26
35
|
*/
|
|
27
36
|
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
28
|
-
getLocale: () => Locale;
|
|
37
|
+
getLocale: () => import("@intlayer/types").Locale;
|
|
29
38
|
setLocale: (locale: LocalesValues) => void;
|
|
30
39
|
};
|
|
31
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;;qBAgBa,oDAAkB;;;;;;;qBAQlB,2CAAe;;;;;;qBAOf,wCAAY;;;;qBAKZ,qBAAkB,QACrB,eAAa;;;;;;qBAaV,wBAAe;;;;qBAKf,mBAAgB;;sBAAhB;;;;;;;;;qBAiBA,wBAAe"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useCompact.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a compact number formatter
|
|
@@ -11,7 +10,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
11
10
|
* ```
|
|
12
11
|
*/
|
|
13
12
|
export declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
14
|
-
locale?: LocalesValues;
|
|
13
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
15
14
|
}) => string;
|
|
16
15
|
//#endregion
|
|
17
16
|
//# sourceMappingURL=useCompact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";;;;;;;;;;;qBAca,mBAAU,wBAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useCurrency.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a currency formatter
|
|
@@ -25,7 +24,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
export declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
28
|
-
locale?: LocalesValues;
|
|
27
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
29
28
|
}) => string;
|
|
30
29
|
//#endregion
|
|
31
30
|
//# sourceMappingURL=useCurrency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;qBA4Ba,oBAAW,wBAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useList.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a list formatter
|
|
@@ -22,7 +21,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
23
|
export declare const useList: () => (values: (string | number)[], options?: import("@intlayer/core/formatters").ListFormatOptions & {
|
|
25
|
-
locale?: LocalesValues;
|
|
24
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
26
25
|
}) => string;
|
|
27
26
|
//#endregion
|
|
28
27
|
//# sourceMappingURL=useList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;qBAyBa,gBAAO,6BAAA,8CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useNumber.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a localized number formatter.
|
|
@@ -23,7 +22,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
23
22
|
* A number formatting function bound to the active locale.
|
|
24
23
|
*/
|
|
25
24
|
export declare const useNumber: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
26
|
-
locale?: LocalesValues;
|
|
25
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
27
26
|
}) => string;
|
|
28
27
|
//#endregion
|
|
29
28
|
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBA0Ba,kBAAS,wBAAA,SAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/usePercentage.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React hook to provide a percentage formatter function
|
|
@@ -19,7 +18,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
19
18
|
* A function that formats numbers or numeric strings into localized percentages.
|
|
20
19
|
*/
|
|
21
20
|
export declare const usePercentage: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
22
|
-
locale?: LocalesValues;
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
23
22
|
}) => string;
|
|
24
23
|
//#endregion
|
|
25
24
|
//# sourceMappingURL=usePercentage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAsBa,sBAAa,wBAAA,SAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useRelativeTime.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Client-side React hook for accessing a localized relative time formatter.
|
|
@@ -19,7 +18,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
19
18
|
* bound to the current client locale.
|
|
20
19
|
*/
|
|
21
20
|
export declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
22
|
-
locale?: LocalesValues;
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
23
22
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
24
23
|
}) => string;
|
|
25
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAsBa,wBAAe,wBAAA,MAAA,uBAAA,MAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/format/useUnit.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React hook that provides a unit formatting function
|
|
@@ -18,7 +17,7 @@ import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
|
18
17
|
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
19
18
|
*/
|
|
20
19
|
export declare const useUnit: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
21
|
-
locale?: LocalesValues;
|
|
20
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
22
21
|
}) => string;
|
|
23
22
|
//#endregion
|
|
24
23
|
//# sourceMappingURL=useUnit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAqBa,gBAAO,wBAAA,UAAA,KAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { useLoadDynamic } from "./client/useLoadDynamic.js";
|
|
|
15
15
|
import { useLocale } from "./client/useLocale.js";
|
|
16
16
|
import { useLocaleBase } from "./client/useLocaleBase.js";
|
|
17
17
|
import { localeCookie, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.js";
|
|
18
|
+
import { usePathname } from "./client/usePathname.js";
|
|
18
19
|
import "./client/index.js";
|
|
19
20
|
import { getDictionary } from "./getDictionary.js";
|
|
20
21
|
import { getIntlayer } from "./getIntlayer.js";
|
|
@@ -24,5 +25,5 @@ declare module '@intlayer/core/interpreter' {
|
|
|
24
25
|
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginPreact<T, S, L> {}
|
|
25
26
|
}
|
|
26
27
|
//#endregion
|
|
27
|
-
export { AnalyticsProvider, type ConversionParams, type ExperimentState, IntlayerClientContext, type IntlayerNode, IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, getDictionary, getIntlayer, localeCookie, setLocaleCookie, setLocaleInStorage, t, useAnalytics, useConversion, useDictionary, useDictionaryAsync, useDictionaryDynamic, useExperiment, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage };
|
|
28
|
+
export { AnalyticsProvider, type ConversionParams, type ExperimentState, IntlayerClientContext, type IntlayerNode, IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, getDictionary, getIntlayer, localeCookie, setLocaleCookie, setLocaleInStorage, t, useAnalytics, useConversion, useDictionary, useDictionaryAsync, useDictionaryDynamic, useExperiment, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage, usePathname };
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;YAIY,mBAAmB,GAAG,GAAG,UAAU,uBACnC,yBAAyB,GAAG,GAAG"}
|
|
@@ -28,7 +28,7 @@ export type MarkdownProviderOptions = {
|
|
|
28
28
|
};
|
|
29
29
|
type MarkdownContextValue = {
|
|
30
30
|
components?: HTMLComponents<'permissive', {}>;
|
|
31
|
-
renderMarkdown: (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ComponentType<
|
|
31
|
+
renderMarkdown: (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ComponentType<unknown> | keyof JSX.IntrinsicElements) => ComponentChildren | Promise<ComponentChildren>;
|
|
32
32
|
};
|
|
33
33
|
type MarkdownProviderProps = PropsWithChildren<MarkdownProviderOptions & {
|
|
34
34
|
/**
|
|
@@ -38,12 +38,12 @@ type MarkdownProviderProps = PropsWithChildren<MarkdownProviderOptions & {
|
|
|
38
38
|
/**
|
|
39
39
|
* Wrapper element or component to be used when there are multiple children.
|
|
40
40
|
*/
|
|
41
|
-
wrapper?: ComponentType<
|
|
41
|
+
wrapper?: ComponentType<unknown> | keyof JSX.IntrinsicElements;
|
|
42
42
|
/**
|
|
43
43
|
* Custom render function for markdown.
|
|
44
44
|
* If provided, it will overwrite all rules and default rendering.
|
|
45
45
|
*/
|
|
46
|
-
renderMarkdown?: (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ComponentType<
|
|
46
|
+
renderMarkdown?: (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ComponentType<unknown> | keyof JSX.IntrinsicElements) => ComponentChildren | Promise<ComponentChildren>;
|
|
47
47
|
}>;
|
|
48
48
|
export declare const useMarkdownContext: () => MarkdownContextValue;
|
|
49
49
|
export declare const MarkdownProvider: FunctionComponent<MarkdownProviderProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.d.ts","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"mappings":";;;;KAWK,kBAAkB,UAAU;EAAM,WAAW;;;;;YAKtC;;;;EAIV;;;;EAIA;;;;EAIA;;;;EAIA;;KASG;EACH,aAAa;EACb,iBACE,mBAAmB,gBACnB,UAAU,yBACV,aAAa,kCACb,UAAU,
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.d.ts","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"mappings":";;;;KAWK,kBAAkB,UAAU;EAAM,WAAW;;;;;YAKtC;;;;EAIV;;;;EAIA;;;;EAIA;;;;EAIA;;KASG;EACH,aAAa;EACb,iBACE,mBAAmB,gBACnB,UAAU,yBACV,aAAa,kCACb,UAAU,+BAA+B,IAAI,sBAC1C,oBAAoB,QAAQ;;KAG9B,wBAAwB,kBAC3B;;;;EAIE,aAAa;;;;EAIb,UAAU,+BAA+B,IAAI;;;;;EAK7C,kBACE,mBAAmB,gBACnB,UAAU,yBACV,aAAa,kCACb,UAAU,+BAA+B,IAAI,sBAC1C,oBAAoB,QAAQ;;qBAQxB,0BAAkB;qBAuBlB,kBAAkB,kBAAkB"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { HTMLComponents } from "../html/types.js";
|
|
2
|
+
import { ComponentType, JSX } from "preact";
|
|
1
3
|
import { CompileOptions, ParsedMarkdown } from "@intlayer/core/markdown";
|
|
2
4
|
//#region src/markdown/compiler.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* Options accepted by `compileMarkdown` and `parseMarkdown` to customise
|
|
5
7
|
* rendering behaviour (custom components, sanitizer, slugify, rule hooks, …).
|
|
6
8
|
*/
|
|
7
|
-
export type MarkdownCompilerOptions = CompileOptions
|
|
9
|
+
export type MarkdownCompilerOptions = Omit<CompileOptions<HTMLComponents<'permissive', {}>>, 'wrapper' | 'components'> & {
|
|
10
|
+
wrapper?: ComponentType<unknown> | keyof JSX.IntrinsicElements | null;
|
|
11
|
+
components?: HTMLComponents<'permissive', {}>;
|
|
12
|
+
};
|
|
8
13
|
/**
|
|
9
14
|
* **Step 1 of 2 — parse only.**
|
|
10
15
|
* Converts a raw markdown string into a `ParsedMarkdown` AST without rendering
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/markdown/compiler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/markdown/compiler.ts"],"mappings":";;;;;;;;YAqBY,0BAA0B,KACpC,eAAe;EAGf,UAAU,+BAA+B,IAAI;EAC7C,aAAa;;;;;;;;;;;;;;;;;;;;qBA4BF,gBAAa,mBACR,UACP,4BACR;;;;;;;;;;;;;;;;qBAyCU,kBAAe,iBACV,gBAAc,UACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;YA+DY,iBAAiB,KAAK,4BAC9B,aAAa;;qBAIJ,qBAAqB;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;YA+DY,iBAAiB,KAAK,4BAC9B,aAAa;;qBAIJ,qBAAqB;;;;YA+CtB,eAAe,KAAK;EAC9B;EACA;IAEE;;qBAIS,mBAAmB;;;;YA8CpB,cAAc,GAAG,IAAI,UAAU,iBAAiB;EAC1D,UAAU;GACT,UAAU,kBAAkB;EAC7B,wBAAwB;KAErB,aAAa,KAAK,QAAQ,+BAA+B,UACxD,QAAQ,MACL,mBACD,QAAQ,6BACN,uBACA,aAAa,SACf,qBAAqB,GAAG;;qBAuEnB,iBAAiB;;;;YAuFlB,mBAAmB,KAAK,mBAChC;EAGI,UAAU;EACV,MAAM,aAAa,qCAAqC;;;qBA4BnD,sBAAsB;YAiFvB,aAAa,KAAK;EAC5B,UAAU;GACT,UAAU,iBAAiB;EAC5B,iBAAiB;EACjB,aAAa;;EAGT,MAAM,aAAa,6BAA6B,OAAO;EACvD,UAAU,qBAAqB;;qBAIxB,gBAAgB;;;;YA8BjB,eAAe,KAAK;EAC9B,UAAU;GACT,UAAU,aAAa;EACxB,aAAa;;EAGT,MAAM,aAAa,6BAA6B,OAAO,aAAa;;;qBAW7D,YAAY;;;;iBAgDR,yBAAyB,GAAG,GAAG,UAAU;EACxD,YAAY,eAAe;EAC3B,oBAAoB,iBAAiB;EACrC,iBAAiB,cAAc,GAAG,GAAG;EACrC,gBAAgB,aAAa;EAC7B,YAAY,eAAe;;;;;;;YAQjB,0BAA0B,KACpC;EAGA;EACA;EACA;EACA;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
|