preact-intlayer 8.7.11 → 8.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/ContentSelector.cjs +2 -3
- package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +2 -3
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +14 -38
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/editor/ContentSelector.mjs +2 -3
- package/dist/esm/editor/ContentSelector.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +2 -3
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/plugins.mjs +14 -38
- 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 +6 -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/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/useEditor.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
|
@@ -5,15 +5,14 @@ let preact_hooks = require("preact/hooks");
|
|
|
5
5
|
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
6
6
|
|
|
7
7
|
//#region src/editor/ContentSelector.tsx
|
|
8
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
9
8
|
const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
10
9
|
(0, preact_hooks.useEffect)(() => {
|
|
11
|
-
if (
|
|
10
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !_intlayer_editor_isEnabled.isEnabled || typeof window === "undefined") return;
|
|
12
11
|
import("@intlayer/editor").then(({ defineIntlayerElements }) => {
|
|
13
12
|
defineIntlayerElements();
|
|
14
13
|
});
|
|
15
14
|
}, [_intlayer_editor_isEnabled.isEnabled]);
|
|
16
|
-
if (
|
|
15
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !_intlayer_editor_isEnabled.isEnabled) return children;
|
|
17
16
|
return /* @__PURE__ */ (0, preact_jsx_runtime.jsx)("intlayer-content-selector-wrapper", {
|
|
18
17
|
"key-path": JSON.stringify(keyPath),
|
|
19
18
|
"dictionary-key": dictionaryKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\
|
|
1
|
+
{"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;AAC5C,mCAAgB;AACd,MACE,QAAQ,IAAI,+BAA+B,WAC3C,CAACA,wCACD,OAAO,WAAW,YAElB;AACF,SAAO,oBAAoB,MAAM,EAAE,6BAA6B;AAC9D,2BAAwB;IACxB;IACD,CAACA,qCAAU,CAAC;AAEf,KAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,qCACzD,QAAO;AAGT,QACE,4CAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
|
|
@@ -5,7 +5,6 @@ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
|
5
5
|
let preact_hooks = require("preact/hooks");
|
|
6
6
|
|
|
7
7
|
//#region src/editor/useEditor.tsx
|
|
8
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
9
8
|
/**
|
|
10
9
|
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
11
10
|
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
@@ -15,7 +14,7 @@ const useEditor = () => {
|
|
|
15
14
|
const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
16
15
|
const managerRef = (0, preact_hooks.useRef)(null);
|
|
17
16
|
(0, preact_hooks.useEffect)(() => {
|
|
18
|
-
if (
|
|
17
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !_intlayer_editor_isEnabled.isEnabled) return;
|
|
19
18
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
20
19
|
const manager = initEditorClient();
|
|
21
20
|
managerRef.current = manager;
|
|
@@ -29,7 +28,7 @@ const useEditor = () => {
|
|
|
29
28
|
};
|
|
30
29
|
}, []);
|
|
31
30
|
(0, preact_hooks.useEffect)(() => {
|
|
32
|
-
if (
|
|
31
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !locale || !managerRef.current) return;
|
|
33
32
|
managerRef.current.currentLocale.set(locale);
|
|
34
33
|
}, [locale]);
|
|
35
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAC1D,MAAM,sCAA+C,KAAK;AAE1D,mCAAgB;AACd,MAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACC,qCACzD;AAEF,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,mCAAgB;AACd,MACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,QAEZ;AAEF,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -13,54 +13,30 @@ let preact_compat = require("preact/compat");
|
|
|
13
13
|
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
14
14
|
|
|
15
15
|
//#region src/plugins.tsx
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const TREE_SHAKE_INTLAYER_NODE = process.env["INTLAYER_NODE_TYPE_INTLAYER_NODE"] === "false";
|
|
20
|
-
/**
|
|
21
|
-
* True when the preact node type is explicitly disabled at build time.
|
|
22
|
-
*/
|
|
23
|
-
const TREE_SHAKE_PREACT_NODE = process.env["INTLAYER_NODE_TYPE_PREACT_NODE"] === "false";
|
|
24
|
-
/**
|
|
25
|
-
* True when the markdown node type is explicitly disabled at build time.
|
|
26
|
-
*/
|
|
27
|
-
const TREE_SHAKE_MARKDOWN = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false";
|
|
28
|
-
/**
|
|
29
|
-
* True when the HTML node type is explicitly disabled at build time.
|
|
30
|
-
*/
|
|
31
|
-
const TREE_SHAKE_HTML = process.env["INTLAYER_NODE_TYPE_HTML"] === "false";
|
|
32
|
-
/**
|
|
33
|
-
* True when the insertion node type is explicitly disabled at build time.
|
|
34
|
-
*/
|
|
35
|
-
const TREE_SHAKE_INSERTION = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false";
|
|
36
|
-
/**
|
|
37
|
-
* True when the editor is explicitly disabled at build time.
|
|
38
|
-
*/
|
|
39
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
40
|
-
const LazyMarkdownMetadataRenderer = TREE_SHAKE_MARKDOWN ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
41
|
-
const LazyMarkdownRendererPlugin = TREE_SHAKE_MARKDOWN ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
42
|
-
const LazyHTMLRenderer = TREE_SHAKE_HTML ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./html/HTMLRenderer.cjs")).then((m) => ({ default: m.HTMLRenderer })));
|
|
16
|
+
const LazyMarkdownMetadataRenderer = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
17
|
+
const LazyMarkdownRendererPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
18
|
+
const LazyHTMLRenderer = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./html/HTMLRenderer.cjs")).then((m) => ({ default: m.HTMLRenderer })));
|
|
43
19
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
44
|
-
const intlayerNodePlugins =
|
|
20
|
+
const intlayerNodePlugins = {
|
|
45
21
|
id: "intlayer-node-plugin",
|
|
46
22
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
47
23
|
transform: (_node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
48
24
|
...rest,
|
|
49
25
|
value: rest.children,
|
|
50
|
-
children:
|
|
26
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact.createElement)(require_editor_ContentSelector.ContentSelector, {
|
|
51
27
|
...rest,
|
|
52
28
|
key: rest.children
|
|
53
29
|
}, rest.children) : rest.children
|
|
54
30
|
})
|
|
55
31
|
};
|
|
56
32
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
57
|
-
const preactNodePlugins =
|
|
33
|
+
const preactNodePlugins = process.env["INTLAYER_NODE_TYPE_PREACT_NODE"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
58
34
|
id: "preact-node-plugin",
|
|
59
35
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
60
36
|
transform: (node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
61
37
|
...rest,
|
|
62
38
|
value: "[[preact-element]]",
|
|
63
|
-
children:
|
|
39
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
64
40
|
...rest,
|
|
65
41
|
children: require_preactElement_renderPreactElement.renderPreactElement(node)
|
|
66
42
|
}) : require_preactElement_renderPreactElement.renderPreactElement(node)
|
|
@@ -94,7 +70,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
94
70
|
return (0, preact.h)(preact.Fragment, null, ...parts.map((part, index) => (0, preact.h)(preact.Fragment, { key: index }, part)));
|
|
95
71
|
};
|
|
96
72
|
/** Insertion plugin for Preact. Handles component/node insertion. */
|
|
97
|
-
const insertionPlugin =
|
|
73
|
+
const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
98
74
|
id: "insertion-plugin",
|
|
99
75
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
|
|
100
76
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -135,7 +111,7 @@ const insertionPlugin = TREE_SHAKE_INSERTION ? _intlayer_core_interpreter.fallba
|
|
|
135
111
|
}
|
|
136
112
|
};
|
|
137
113
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
138
|
-
const markdownStringPlugin =
|
|
114
|
+
const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
139
115
|
id: "markdown-string-plugin",
|
|
140
116
|
canHandle: (node) => typeof node === "string",
|
|
141
117
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -147,7 +123,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fa
|
|
|
147
123
|
transform: (metadataNode, props) => require_IntlayerNode.renderIntlayerNode({
|
|
148
124
|
...props,
|
|
149
125
|
value: metadataNode,
|
|
150
|
-
children:
|
|
126
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
151
127
|
...rest,
|
|
152
128
|
children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
|
|
153
129
|
fallback: node,
|
|
@@ -173,7 +149,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fa
|
|
|
173
149
|
const render = (components) => require_IntlayerNode.renderIntlayerNode({
|
|
174
150
|
...props,
|
|
175
151
|
value: node,
|
|
176
|
-
children:
|
|
152
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
177
153
|
...rest,
|
|
178
154
|
children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
|
|
179
155
|
fallback: node,
|
|
@@ -202,7 +178,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fa
|
|
|
202
178
|
} });
|
|
203
179
|
}
|
|
204
180
|
};
|
|
205
|
-
const markdownPlugin =
|
|
181
|
+
const markdownPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
206
182
|
id: "markdown-plugin",
|
|
207
183
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
|
|
208
184
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -217,7 +193,7 @@ const markdownPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fallback
|
|
|
217
193
|
}
|
|
218
194
|
};
|
|
219
195
|
/** HTML plugin. Replaces node with a function that takes components => VNode. */
|
|
220
|
-
const htmlPlugin =
|
|
196
|
+
const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
221
197
|
id: "html-plugin",
|
|
222
198
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
|
|
223
199
|
transform: (node, props) => {
|
|
@@ -227,7 +203,7 @@ const htmlPlugin = TREE_SHAKE_HTML ? _intlayer_core_interpreter.fallbackPlugin :
|
|
|
227
203
|
const render = (userComponents) => require_IntlayerNode.renderIntlayerNode({
|
|
228
204
|
...rest,
|
|
229
205
|
value: html,
|
|
230
|
-
children:
|
|
206
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? (0, preact.h)(require_editor_ContentSelector.ContentSelector, { ...rest }, (0, preact.h)(preact_compat.Suspense, { fallback: html }, (0, preact.h)(LazyHTMLRenderer, {
|
|
231
207
|
...rest,
|
|
232
208
|
html,
|
|
233
209
|
userComponents
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","editor","ContentSelector","renderPreactElement","Fragment","NodeTypes","func","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,M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AK;EACnB,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACdL,wCAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,CAAC,qBAAqBC,8BAAO,wBAEvBC,gDACA,EAAE,GAAG,MAAM,gBAETK,wBACA,EAAE,UAAU,MAAM,gBAChB,kBAAyB;IACzB,GAAG;IACH;IACA;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;AAmCL,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUC,4CAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;EACAC;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["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,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAWC,8BAAO,UAC3D,0CAACC,gDAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAEV,CAAC;CACL;;AAcD,MAAa,oBACX,QAAQ,IAAI,sCAAsC,UAC9CC,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLH,wCAAmB;EACjB,GAAG;EACH,OAAO;EACP,UACE,QAAQ,IAAI,+BAA+B,WAC3CC,8BAAO,UACL,4CAACC,gDAAD;GAAiB,GAAI;aAClBE,8DAAoB,KAAK;GACV,IAElBA,8DAAoB,KAAK;EAE9B,CAAC;CACL;;;;AAuBP,MAAM,WAAW,UAA+B;AAC9C,QACE,UAAU,QACV,UAAU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I;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaG,yBAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAKA,yBAAU;AACd,OAAK;EACnB,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACdN,wCAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,QAAQ,IAAI,+BAA+B,WAC3CC,8BAAO,wBAEDC,gDACA,EAAE,GAAG,MAAM,gBAETM,wBACA,EAAE,UAAU,MAAM,gBAChB,kBAAyB;IACzB,GAAG;IACH;IACA;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;EACAC;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
@@ -3,15 +3,14 @@ import { useEffect } from "preact/hooks";
|
|
|
3
3
|
import { jsx } from "preact/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/editor/ContentSelector.tsx
|
|
6
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
7
6
|
const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
8
7
|
useEffect(() => {
|
|
9
|
-
if (
|
|
8
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !isEnabled || typeof window === "undefined") return;
|
|
10
9
|
import("@intlayer/editor").then(({ defineIntlayerElements }) => {
|
|
11
10
|
defineIntlayerElements();
|
|
12
11
|
});
|
|
13
12
|
}, [isEnabled]);
|
|
14
|
-
if (
|
|
13
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !isEnabled) return children;
|
|
15
14
|
return /* @__PURE__ */ jsx("intlayer-content-selector-wrapper", {
|
|
16
15
|
"key-path": JSON.stringify(keyPath),
|
|
17
16
|
"dictionary-key": dictionaryKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\
|
|
1
|
+
{"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;AAC5C,iBAAgB;AACd,MACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,aACD,OAAO,WAAW,YAElB;AACF,SAAO,oBAAoB,MAAM,EAAE,6BAA6B;AAC9D,2BAAwB;IACxB;IACD,CAAC,UAAU,CAAC;AAEf,KAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,UACzD,QAAO;AAGT,QACE,oBAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
|
|
@@ -3,7 +3,6 @@ import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
|
3
3
|
import { useContext, useEffect, useRef } from "preact/hooks";
|
|
4
4
|
|
|
5
5
|
//#region src/editor/useEditor.tsx
|
|
6
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
7
6
|
/**
|
|
8
7
|
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
9
8
|
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
@@ -13,7 +12,7 @@ const useEditor = () => {
|
|
|
13
12
|
const { locale } = useContext(IntlayerClientContext) ?? {};
|
|
14
13
|
const managerRef = useRef(null);
|
|
15
14
|
useEffect(() => {
|
|
16
|
-
if (
|
|
15
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !isEnabled) return;
|
|
17
16
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
18
17
|
const manager = initEditorClient();
|
|
19
18
|
managerRef.current = manager;
|
|
@@ -27,7 +26,7 @@ const useEditor = () => {
|
|
|
27
26
|
};
|
|
28
27
|
}, []);
|
|
29
28
|
useEffect(() => {
|
|
30
|
-
if (
|
|
29
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !locale || !managerRef.current) return;
|
|
31
30
|
managerRef.current.currentLocale.set(locale);
|
|
32
31
|
}, [locale]);
|
|
33
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAC1D,MAAM,aAAa,OAAkC,KAAK;AAE1D,iBAAgB;AACd,MAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,UACzD;AAEF,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,iBAAgB;AACd,MACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,QAEZ;AAEF,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -10,54 +10,30 @@ import { Suspense, lazy } from "preact/compat";
|
|
|
10
10
|
import { jsx } from "preact/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/plugins.tsx
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const TREE_SHAKE_INTLAYER_NODE = process.env["INTLAYER_NODE_TYPE_INTLAYER_NODE"] === "false";
|
|
17
|
-
/**
|
|
18
|
-
* True when the preact node type is explicitly disabled at build time.
|
|
19
|
-
*/
|
|
20
|
-
const TREE_SHAKE_PREACT_NODE = process.env["INTLAYER_NODE_TYPE_PREACT_NODE"] === "false";
|
|
21
|
-
/**
|
|
22
|
-
* True when the markdown node type is explicitly disabled at build time.
|
|
23
|
-
*/
|
|
24
|
-
const TREE_SHAKE_MARKDOWN = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false";
|
|
25
|
-
/**
|
|
26
|
-
* True when the HTML node type is explicitly disabled at build time.
|
|
27
|
-
*/
|
|
28
|
-
const TREE_SHAKE_HTML = process.env["INTLAYER_NODE_TYPE_HTML"] === "false";
|
|
29
|
-
/**
|
|
30
|
-
* True when the insertion node type is explicitly disabled at build time.
|
|
31
|
-
*/
|
|
32
|
-
const TREE_SHAKE_INSERTION = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false";
|
|
33
|
-
/**
|
|
34
|
-
* True when the editor is explicitly disabled at build time.
|
|
35
|
-
*/
|
|
36
|
-
const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
|
|
37
|
-
const LazyMarkdownMetadataRenderer = TREE_SHAKE_MARKDOWN ? null : lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
38
|
-
const LazyMarkdownRendererPlugin = TREE_SHAKE_MARKDOWN ? null : lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
39
|
-
const LazyHTMLRenderer = TREE_SHAKE_HTML ? null : lazy(() => import("./html/HTMLRenderer.mjs").then((m) => ({ default: m.HTMLRenderer })));
|
|
13
|
+
const LazyMarkdownMetadataRenderer = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
14
|
+
const LazyMarkdownRendererPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
15
|
+
const LazyHTMLRenderer = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? null : lazy(() => import("./html/HTMLRenderer.mjs").then((m) => ({ default: m.HTMLRenderer })));
|
|
40
16
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
41
|
-
const intlayerNodePlugins =
|
|
17
|
+
const intlayerNodePlugins = {
|
|
42
18
|
id: "intlayer-node-plugin",
|
|
43
19
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
44
20
|
transform: (_node, { plugins, ...rest }) => renderIntlayerNode({
|
|
45
21
|
...rest,
|
|
46
22
|
value: rest.children,
|
|
47
|
-
children:
|
|
23
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ createElement(ContentSelector, {
|
|
48
24
|
...rest,
|
|
49
25
|
key: rest.children
|
|
50
26
|
}, rest.children) : rest.children
|
|
51
27
|
})
|
|
52
28
|
};
|
|
53
29
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
54
|
-
const preactNodePlugins =
|
|
30
|
+
const preactNodePlugins = process.env["INTLAYER_NODE_TYPE_PREACT_NODE"] === "false" ? fallbackPlugin : {
|
|
55
31
|
id: "preact-node-plugin",
|
|
56
32
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
57
33
|
transform: (node, { plugins, ...rest }) => renderIntlayerNode({
|
|
58
34
|
...rest,
|
|
59
35
|
value: "[[preact-element]]",
|
|
60
|
-
children:
|
|
36
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
61
37
|
...rest,
|
|
62
38
|
children: renderPreactElement(node)
|
|
63
39
|
}) : renderPreactElement(node)
|
|
@@ -91,7 +67,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
91
67
|
return h(Fragment, null, ...parts.map((part, index) => h(Fragment, { key: index }, part)));
|
|
92
68
|
};
|
|
93
69
|
/** Insertion plugin for Preact. Handles component/node insertion. */
|
|
94
|
-
const insertionPlugin =
|
|
70
|
+
const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false" ? fallbackPlugin : {
|
|
95
71
|
id: "insertion-plugin",
|
|
96
72
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
97
73
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -132,7 +108,7 @@ const insertionPlugin = TREE_SHAKE_INSERTION ? fallbackPlugin : {
|
|
|
132
108
|
}
|
|
133
109
|
};
|
|
134
110
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
135
|
-
const markdownStringPlugin =
|
|
111
|
+
const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? fallbackPlugin : {
|
|
136
112
|
id: "markdown-string-plugin",
|
|
137
113
|
canHandle: (node) => typeof node === "string",
|
|
138
114
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -144,7 +120,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
|
144
120
|
transform: (metadataNode, props) => renderIntlayerNode({
|
|
145
121
|
...props,
|
|
146
122
|
value: metadataNode,
|
|
147
|
-
children:
|
|
123
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
148
124
|
...rest,
|
|
149
125
|
children: /* @__PURE__ */ jsx(Suspense, {
|
|
150
126
|
fallback: node,
|
|
@@ -170,7 +146,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
|
170
146
|
const render = (components) => renderIntlayerNode({
|
|
171
147
|
...props,
|
|
172
148
|
value: node,
|
|
173
|
-
children:
|
|
149
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
174
150
|
...rest,
|
|
175
151
|
children: /* @__PURE__ */ jsx(Suspense, {
|
|
176
152
|
fallback: node,
|
|
@@ -199,7 +175,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
|
199
175
|
} });
|
|
200
176
|
}
|
|
201
177
|
};
|
|
202
|
-
const markdownPlugin =
|
|
178
|
+
const markdownPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? fallbackPlugin : {
|
|
203
179
|
id: "markdown-plugin",
|
|
204
180
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
|
|
205
181
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -214,7 +190,7 @@ const markdownPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
|
214
190
|
}
|
|
215
191
|
};
|
|
216
192
|
/** HTML plugin. Replaces node with a function that takes components => VNode. */
|
|
217
|
-
const htmlPlugin =
|
|
193
|
+
const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? fallbackPlugin : {
|
|
218
194
|
id: "html-plugin",
|
|
219
195
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
220
196
|
transform: (node, props) => {
|
|
@@ -224,7 +200,7 @@ const htmlPlugin = TREE_SHAKE_HTML ? fallbackPlugin : {
|
|
|
224
200
|
const render = (userComponents) => renderIntlayerNode({
|
|
225
201
|
...rest,
|
|
226
202
|
value: html,
|
|
227
|
-
children:
|
|
203
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? h(ContentSelector, { ...rest }, h(Suspense, { fallback: html }, h(LazyHTMLRenderer, {
|
|
228
204
|
...rest,
|
|
229
205
|
html,
|
|
230
206
|
userComponents
|
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\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the intlayer node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INTLAYER_NODE =\n process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';\n\n/**\n * True when the preact node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_PREACT_NODE =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false';\n\n/**\n * True when the markdown node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_MARKDOWN =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';\n\n/**\n * True when the HTML node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';\n\n/**\n * True when the insertion node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_INSERTION =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// Preact lazy for heavy renderer components — creates separate code-split chunks.\n// Guarded by tree-shake constants so bundlers can eliminate the dynamic import()\n// entirely when the feature is disabled at build time.\n// The `!` (non-null assertion) strips `null` from the union for JSX compat and\n// has zero runtime cost — when the guard is `true` the variable is never read.\nconst LazyMarkdownMetadataRenderer = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n TREE_SHAKE_MARKDOWN\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n TREE_SHAKE_HTML\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = TREE_SHAKE_PREACT_NODE\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = TREE_SHAKE_INSERTION\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = TREE_SHAKE_MARKDOWN\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = TREE_SHAKE_HTML\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,yBACJ,QAAQ,IAAI,sCAAsC;;;;AAKpD,MAAM,sBACJ,QAAQ,IAAI,mCAAmC;;;;AAKjD,MAAM,kBAAkB,QAAQ,IAAI,+BAA+B;;;;AAKnE,MAAM,uBACJ,QAAQ,IAAI,oCAAoC;;;;AAKlD,MAAM,o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E,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH,CACF,GACD,EACE,UACA,EAAE,UAAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACR,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,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;AAmCL,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;AAErC,KAAI,aAAa,IAAI,SAAS,CAC5B,QAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;AAED,cAAa,IAAI,UAAU,QAAQ;AAEnC,QAAO"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":["func"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\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,mCA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UAAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH,CACF,GACD,EACE,UACA,EAAE,UAAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACR,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,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,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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useContent.d.ts
|
|
@@ -6,7 +6,7 @@ import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
|
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_types_module_augmentation0.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,sCAAA,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_types_allLocales0 from "@intlayer/types/allLocales";
|
|
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_types_allLocales0.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,6BAAA,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_types_allLocales0 from "@intlayer/types/allLocales";
|
|
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_types_allLocales0.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,6BAAA,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_types_allLocales0 from "@intlayer/types/allLocales";
|
|
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_types_allLocales0.Locale;
|
|
38
|
+
availableLocales: _$_intlayer_types_allLocales0.Locale[];
|
|
39
39
|
setLocale: (locale: LocalesValues) => void;
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
2
|
+
import * as _$_intlayer_types_allLocales0 from "@intlayer/types/allLocales";
|
|
2
3
|
|
|
3
4
|
//#region src/client/useLocaleBase.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* On the client side, hook to get the current locale and all related fields
|
|
6
7
|
*/
|
|
7
8
|
declare const useLocaleBase: () => {
|
|
8
|
-
locale: LocalesValues;
|
|
9
|
-
defaultLocale: Locale;
|
|
10
|
-
availableLocales: Locale[];
|
|
11
|
-
setLocale: (newLocale: LocalesValues) => void;
|
|
9
|
+
locale: _$_intlayer_types_module_augmentation0.LocalesValues;
|
|
10
|
+
defaultLocale: _$_intlayer_types_allLocales0.Locale;
|
|
11
|
+
availableLocales: _$_intlayer_types_allLocales0.Locale[];
|
|
12
|
+
setLocale: (newLocale: _$_intlayer_types_module_augmentation0.LocalesValues) => void;
|
|
12
13
|
};
|
|
13
14
|
//#endregion
|
|
14
15
|
export { useLocaleBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;;;;cASa,aAAA;UASZ,sCAAA,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_types_allLocales0 from "@intlayer/types/allLocales";
|
|
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_types_allLocales0.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_types_allLocales0.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_types_allLocales0.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_types_allLocales0.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,6BAAA,CAAnD,MAAA;;;;;AAM5B;cAAa,YAAA,EAA8B,6BAAA,CAAlB,MAAA;;;;cAKZ,kBAAA,GACX,MAAA,EAAQ,aAAA,EACR,eAAA;;;;;;cAYW,eAAA,GAAe,MAAA,EAblB,aAAA,EAAa,eAAA;;;AAavB;cAKa,gBAAA,GAAoB,eAAA;mBAQ9B,6BAAA,CAAA,MAAA;sBAAA,aAAA;AAAA;;;;;AARH;;;cAiBa,eAAA,GAAe,eAAA;mBAAmB,6BAAA,CAAA,MAAA;sBAAA,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"mappings":";;;;;YAOY,GAAA;IAAA,UACE,iBAAA;MACR,mCAAA,EAAqC,cAAA,CAAe,WAAA;QAClD,UAAA;QACA,gBAAA;MAAA;IAAA;EAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"mappings":";;;;;YAOY,GAAA;IAAA,UACE,iBAAA;MACR,mCAAA,EAAqC,cAAA,CAAe,WAAA;QAClD,UAAA;QACA,gBAAA;MAAA;IAAA;EAAA;AAAA;AAAA,KAMI,2BAAA,GAA8B,SAAA,GACxC,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAET,eAAA,EAAiB,mBAAA,CAC5B,2BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.d.ts","names":[],"sources":["../../../src/editor/useEditor.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useEditor.d.ts","names":[],"sources":["../../../src/editor/useEditor.tsx"],"mappings":";;AAWA;;;;cAAa,SAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
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_types_module_augmentation0.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,sCAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;AAiEA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;;cAIJ,mBAAA,EAAqB,OAAA;;;;KA+BtB,cAAA,MAAoB,CAAA;EAC9B,KAAA;EACA,GAAA;AAAA,IAEE,KAAA;;cAIS,iBAAA,EAAmB,OAAA;;AAvChC;;KA2EY,aAAA,kBAA+B,aAAA,IAAiB,CAAA;EAC1D,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,SAAA;EACX,MAAA;AAAA,uBAEqB,OAAA,CAAQ,CAAA,8BAA+B,KAAA,IACxD,MAAA,EAAQ,CAAA,KACL,CAAA,kBACD,CAAA,OAAQ,CAAA,4BACN,YAAA,WACA,YAAA,CAAa,KAAA,IACf,oBAAA,CAAqB,CAAA,EAAG,CAAA;;cAuEnB,eAAA,EAAiB,OAAA;;;;KAuFlB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAGI,QAAA,EAAU,oBAAA;EACV,GAAA,GAAM,UAAA,GAAa,cAAA,uBAAqC,KAAA;AAAA;;cAMnD,oBAAA,EAAsB,OAAA;AAAA,KA+GvB,YAAA,MAAkB,CAAA;EAC5B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,QAAA;EACX,QAAA;EACA,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,KAAA;EACvD,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAIxB,cAAA,EAAgB,OAAA;;;;KA8BjB,cAAA,MAAoB,CAAA;EAC9B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,YAAA,CAAa,CAAA;AAAA;;cAK7D,UAAA,EAAY,OAAA;;;;UAqER,wBAAA,iBAAyC,aAAA;EACxD,UAAA,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.7.
|
|
3
|
+
"version": "8.7.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@intlayer/api": "8.7.
|
|
104
|
-
"@intlayer/chokidar": "8.7.
|
|
105
|
-
"@intlayer/config": "8.7.
|
|
106
|
-
"@intlayer/core": "8.7.
|
|
107
|
-
"@intlayer/editor": "8.7.
|
|
108
|
-
"@intlayer/types": "8.7.
|
|
103
|
+
"@intlayer/api": "8.7.12",
|
|
104
|
+
"@intlayer/chokidar": "8.7.12",
|
|
105
|
+
"@intlayer/config": "8.7.12",
|
|
106
|
+
"@intlayer/core": "8.7.12",
|
|
107
|
+
"@intlayer/editor": "8.7.12",
|
|
108
|
+
"@intlayer/types": "8.7.12"
|
|
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 };
|