preact-intlayer 9.7.0 → 9.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerNode.cjs +1 -2
- package/dist/cjs/UI/ContentSelector.cjs +1 -2
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/analytics/AnalyticsProvider.cjs +2 -3
- package/dist/cjs/analytics/exposureSink.cjs +1 -2
- package/dist/cjs/analytics/index.cjs +4 -4
- package/dist/cjs/analytics/useAnalytics.cjs +4 -5
- package/dist/cjs/analytics/useConversion.cjs +2 -3
- package/dist/cjs/analytics/useExperiment.cjs +2 -3
- package/dist/cjs/client/IntlayerProvider.cjs +7 -8
- package/dist/cjs/client/index.cjs +11 -11
- package/dist/cjs/client/t.cjs +3 -4
- package/dist/cjs/client/useContent.cjs +3 -4
- package/dist/cjs/client/useDictionary.cjs +3 -4
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +4 -5
- package/dist/cjs/client/useDictionaryDynamic.cjs +5 -6
- package/dist/cjs/client/useIntlayer.cjs +3 -4
- package/dist/cjs/client/useLoadDynamic.cjs +1 -2
- package/dist/cjs/client/useLocale.cjs +4 -5
- package/dist/cjs/client/useLocaleBase.cjs +3 -4
- package/dist/cjs/client/useLocaleStorage.cjs +1 -2
- package/dist/cjs/client/usePathname.cjs +1 -2
- package/dist/cjs/client/useTraduction.cjs +3 -4
- package/dist/cjs/editor/ContentSelector.cjs +2 -3
- package/dist/cjs/editor/EditorProvider.cjs +2 -3
- package/dist/cjs/editor/useEditor.cjs +3 -4
- package/dist/cjs/format/index.cjs +9 -9
- package/dist/cjs/format/useCompact.cjs +2 -3
- package/dist/cjs/format/useCurrency.cjs +2 -3
- package/dist/cjs/format/useDate.cjs +2 -3
- package/dist/cjs/format/useIntl.cjs +2 -3
- package/dist/cjs/format/useList.cjs +2 -3
- package/dist/cjs/format/useNumber.cjs +2 -3
- package/dist/cjs/format/usePercentage.cjs +2 -3
- package/dist/cjs/format/useRelativeTime.cjs +2 -3
- package/dist/cjs/format/useUnit.cjs +2 -3
- package/dist/cjs/getDictionary.cjs +2 -3
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -3
- package/dist/cjs/html/HTMLProvider.cjs +2 -3
- package/dist/cjs/html/HTMLRenderer.cjs +3 -4
- package/dist/cjs/html/index.cjs +2 -2
- package/dist/cjs/index.cjs +17 -17
- package/dist/cjs/markdown/MarkdownProvider.cjs +3 -4
- package/dist/cjs/markdown/MarkdownRenderer.cjs +3 -4
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +4 -5
- package/dist/cjs/markdown/compiler.cjs +2 -3
- package/dist/cjs/markdown/index.cjs +3 -3
- package/dist/cjs/markdown/runtime.cjs +1 -2
- package/dist/cjs/plugins.cjs +10 -11
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/preactElement/renderPreactElement.cjs +1 -2
- package/dist/esm/IntlayerNode.mjs +1 -2
- package/dist/esm/UI/ContentSelector.mjs +1 -2
- package/dist/esm/analytics/AnalyticsProvider.mjs +1 -2
- package/dist/esm/analytics/exposureSink.mjs +1 -2
- package/dist/esm/analytics/index.mjs +1 -1
- package/dist/esm/analytics/useAnalytics.mjs +3 -4
- package/dist/esm/analytics/useConversion.mjs +2 -3
- package/dist/esm/analytics/useExperiment.mjs +2 -3
- package/dist/esm/client/IntlayerProvider.mjs +5 -6
- package/dist/esm/client/index.mjs +2 -2
- package/dist/esm/client/t.mjs +2 -3
- package/dist/esm/client/useContent.mjs +1 -2
- package/dist/esm/client/useDictionary.mjs +1 -2
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +2 -3
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -3
- package/dist/esm/client/useIntlayer.mjs +1 -2
- package/dist/esm/client/useLoadDynamic.mjs +1 -2
- package/dist/esm/client/useLocale.mjs +3 -4
- package/dist/esm/client/useLocaleBase.mjs +2 -3
- package/dist/esm/client/useLocaleStorage.mjs +1 -2
- package/dist/esm/client/usePathname.mjs +1 -2
- package/dist/esm/client/useTraduction.mjs +2 -3
- package/dist/esm/editor/ContentSelector.mjs +2 -3
- package/dist/esm/editor/EditorProvider.mjs +1 -2
- package/dist/esm/editor/useEditor.mjs +2 -3
- package/dist/esm/format/index.mjs +5 -5
- package/dist/esm/format/useCompact.mjs +1 -2
- package/dist/esm/format/useCurrency.mjs +1 -2
- package/dist/esm/format/useDate.mjs +1 -2
- package/dist/esm/format/useIntl.mjs +1 -2
- package/dist/esm/format/useList.mjs +1 -2
- package/dist/esm/format/useNumber.mjs +1 -2
- package/dist/esm/format/usePercentage.mjs +1 -2
- package/dist/esm/format/useRelativeTime.mjs +1 -2
- package/dist/esm/format/useUnit.mjs +1 -2
- package/dist/esm/getDictionary.mjs +1 -2
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -2
- package/dist/esm/html/HTMLProvider.mjs +2 -3
- package/dist/esm/html/HTMLRenderer.mjs +2 -3
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/markdown/MarkdownProvider.mjs +2 -3
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -2
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs +2 -3
- package/dist/esm/markdown/compiler.mjs +1 -2
- package/dist/esm/markdown/runtime.mjs +1 -2
- package/dist/esm/plugins.mjs +5 -6
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/preactElement/renderPreactElement.mjs +1 -2
- package/dist/types/IntlayerNode.d.ts +2 -3
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +1 -2
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/analytics/AnalyticsProvider.d.ts +0 -2
- package/dist/types/analytics/AnalyticsProvider.d.ts.map +1 -1
- package/dist/types/analytics/exposureSink.d.ts +0 -2
- package/dist/types/analytics/exposureSink.d.ts.map +1 -1
- package/dist/types/analytics/useAnalytics.d.ts +0 -2
- package/dist/types/analytics/useAnalytics.d.ts.map +1 -1
- package/dist/types/analytics/useConversion.d.ts +0 -2
- package/dist/types/analytics/useConversion.d.ts.map +1 -1
- package/dist/types/analytics/useExperiment.d.ts +0 -2
- package/dist/types/analytics/useExperiment.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +1 -2
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +0 -2
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +0 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +0 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +0 -2
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +0 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +0 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +0 -2
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +1 -2
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +0 -2
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +0 -2
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/usePathname.d.ts +0 -2
- package/dist/types/client/usePathname.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +0 -2
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts +0 -2
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts +0 -2
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts +0 -2
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +0 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +0 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +0 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts +0 -2
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +0 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +0 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +0 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +0 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +0 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +0 -2
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +0 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts +1 -2
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts +0 -2
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/html/index.d.ts +1 -1
- package/dist/types/html/types.d.ts +1 -2
- package/dist/types/html/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +1 -2
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +0 -2
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts +1 -2
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +3 -2
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts +3 -2
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +3 -5
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/preactElement/renderPreactElement.d.ts +0 -2
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
- package/package.json +50 -50
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createContext } from "preact";
|
|
2
1
|
import { useContext } from "preact/hooks";
|
|
2
|
+
import { createContext } from "preact";
|
|
3
3
|
import { jsx } from "preact/jsx-runtime";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/html/HTMLProvider.tsx
|
|
6
6
|
const HTMLContext = createContext(void 0);
|
|
7
7
|
const useHTMLContext = () => useContext(HTMLContext);
|
|
8
8
|
const HTMLProvider = ({ children, components }) => /* @__PURE__ */ jsx(HTMLContext.Provider, {
|
|
@@ -10,6 +10,5 @@ const HTMLProvider = ({ children, components }) => /* @__PURE__ */ jsx(HTMLConte
|
|
|
10
10
|
children
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { HTMLProvider, useHTMLContext };
|
|
15
14
|
//# sourceMappingURL=HTMLProvider.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useHTMLContext } from "./HTMLProvider.mjs";
|
|
2
|
-
import { getHTML } from "@intlayer/core/interpreter";
|
|
3
2
|
import { Fragment, h } from "preact";
|
|
3
|
+
import { getHTML } from "@intlayer/core/interpreter";
|
|
4
4
|
import { VOID_HTML_ELEMENTS } from "@intlayer/core/transpiler";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/html/HTMLRenderer.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Renders HTML-like content to JSX with the provided components.
|
|
9
9
|
*
|
|
@@ -43,6 +43,5 @@ const HTMLRenderer = ({ children = "", html, components }) => {
|
|
|
43
43
|
return useHTMLRenderer({ components })(children || html || "");
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
//#endregion
|
|
47
46
|
export { HTMLRenderer, renderHTML, useHTMLRenderer };
|
|
48
47
|
//# sourceMappingURL=HTMLRenderer.mjs.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { getDictionary } from "./getDictionary.mjs";
|
|
2
|
-
import { getIntlayer } from "./getIntlayer.mjs";
|
|
3
|
-
import { localeCookie, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.mjs";
|
|
4
|
-
import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext } from "./client/IntlayerProvider.mjs";
|
|
5
|
-
import { useAnalytics } from "./analytics/useAnalytics.mjs";
|
|
6
1
|
import { AnalyticsProvider } from "./analytics/AnalyticsProvider.mjs";
|
|
2
|
+
import { useAnalytics } from "./analytics/useAnalytics.mjs";
|
|
7
3
|
import { useConversion } from "./analytics/useConversion.mjs";
|
|
8
4
|
import { useExperiment } from "./analytics/useExperiment.mjs";
|
|
5
|
+
import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext } from "./client/IntlayerProvider.mjs";
|
|
6
|
+
import { localeCookie, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.mjs";
|
|
9
7
|
import { t } from "./client/t.mjs";
|
|
10
8
|
import { useDictionary } from "./client/useDictionary.mjs";
|
|
11
9
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
12
|
-
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
13
10
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
14
11
|
import { useIntlayer } from "./client/useIntlayer.mjs";
|
|
12
|
+
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
15
13
|
import { useLocale } from "./client/useLocale.mjs";
|
|
16
14
|
import { useLocaleBase } from "./client/useLocaleBase.mjs";
|
|
17
15
|
import { usePathname } from "./client/usePathname.mjs";
|
|
16
|
+
import { getDictionary } from "./getDictionary.mjs";
|
|
17
|
+
import { getIntlayer } from "./getIntlayer.mjs";
|
|
18
18
|
|
|
19
19
|
export { AnalyticsProvider, IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, getDictionary, getIntlayer, localeCookie, setLocaleCookie, setLocaleInStorage, t, useAnalytics, useConversion, useDictionary, useDictionaryAsync, useDictionaryDynamic, useExperiment, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage, usePathname };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { compileMarkdown } from "./compiler.mjs";
|
|
2
|
-
import { createContext } from "preact";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
3
|
+
import { createContext } from "preact";
|
|
4
4
|
import { jsx } from "preact/jsx-runtime";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/markdown/MarkdownProvider.tsx
|
|
7
7
|
const MarkdownContext = createContext(void 0);
|
|
8
8
|
const useMarkdownContext = () => useContext(MarkdownContext);
|
|
9
9
|
const mergeOptions = (baseComponents, baseOptions, options = {}, components = {}, wrapper) => {
|
|
@@ -48,6 +48,5 @@ const MarkdownProvider = ({ children, components, wrapper, forceBlock, forceInli
|
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
//#endregion
|
|
52
51
|
export { MarkdownProvider, useMarkdownContext };
|
|
53
52
|
//# sourceMappingURL=MarkdownProvider.mjs.map
|
|
@@ -2,7 +2,7 @@ import { compileMarkdown } from "./compiler.mjs";
|
|
|
2
2
|
import { useMarkdownContext } from "./MarkdownProvider.mjs";
|
|
3
3
|
import { Fragment, jsx } from "preact/jsx-runtime";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/markdown/MarkdownRenderer.tsx
|
|
6
6
|
const renderMarkdown = (content, { components, wrapper, forceBlock, forceInline, preserveFrontmatter, tagfilter } = {}) => {
|
|
7
7
|
return compileMarkdown(content, {
|
|
8
8
|
components,
|
|
@@ -65,6 +65,5 @@ const MarkdownRenderer = ({ children = "", components, wrapper, forceBlock, forc
|
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
//#endregion
|
|
69
68
|
export { MarkdownRenderer, renderMarkdown, useMarkdownRenderer };
|
|
70
69
|
//# sourceMappingURL=MarkdownRenderer.mjs.map
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { useLocale } from "../client/useLocale.mjs";
|
|
4
4
|
import { useMarkdownContext } from "./MarkdownProvider.mjs";
|
|
5
|
-
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
6
5
|
import { getContentNodeByKeyPath } from "@intlayer/core/dictionaryManipulator";
|
|
6
|
+
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/markdown/MarkdownRendererPlugin.tsx
|
|
9
9
|
const MarkdownRendererPlugin = (props) => {
|
|
10
10
|
const { children, options, components } = props;
|
|
11
11
|
const context = useMarkdownContext();
|
|
@@ -20,6 +20,5 @@ const MarkdownMetadataRenderer = ({ children, metadataKeyPath }) => {
|
|
|
20
20
|
return getContentNodeByKeyPath(metadata, metadataKeyPath, currentLocale);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
export { MarkdownMetadataRenderer, MarkdownRendererPlugin };
|
|
25
24
|
//# sourceMappingURL=MarkdownRendererPlugin.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import preactRuntime from "./runtime.mjs";
|
|
2
2
|
import { compileWithOptions, parseMarkdown as parseMarkdown$1, renderMarkdownAst } from "@intlayer/core/markdown";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/markdown/compiler.ts
|
|
5
5
|
/**
|
|
6
6
|
* Preact adapter for the framework-agnostic markdown processor.
|
|
7
7
|
*/
|
|
@@ -60,6 +60,5 @@ const compileMarkdown = (input = "", options = {}) => {
|
|
|
60
60
|
}, compilerOptions);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
//#endregion
|
|
64
63
|
export { compileMarkdown, parseMarkdown };
|
|
65
64
|
//# sourceMappingURL=compiler.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, cloneElement, createElement } from "preact";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/markdown/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* Preact-specific runtime for the markdown processor.
|
|
6
6
|
*/
|
|
@@ -11,6 +11,5 @@ const preactRuntime = {
|
|
|
11
11
|
normalizeProps: (_tag, props) => props
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
export { preactRuntime as default, preactRuntime };
|
|
16
15
|
//# sourceMappingURL=runtime.mjs.map
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -2,15 +2,15 @@ import { reportExposure } from "./analytics/exposureSink.mjs";
|
|
|
2
2
|
import { ContentSelector } from "./editor/ContentSelector.mjs";
|
|
3
3
|
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
4
4
|
import { renderPreactElement } from "./preactElement/renderPreactElement.mjs";
|
|
5
|
-
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInsertedSelector, resolveInterpreterLocale, selectPlugin, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
|
|
6
5
|
import { editor, internationalization } from "@intlayer/config/built";
|
|
6
|
+
import { Fragment, createElement, h } from "preact";
|
|
7
|
+
import { jsx } from "preact/jsx-runtime";
|
|
8
|
+
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInsertedSelector, resolveInterpreterLocale, selectPlugin, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
|
|
7
9
|
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
8
10
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
9
|
-
import { Fragment, createElement, h } from "preact";
|
|
10
11
|
import { lazy } from "preact/compat";
|
|
11
|
-
import { jsx } from "preact/jsx-runtime";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// src/plugins.tsx
|
|
14
14
|
const markdownRendererModulePromise = process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" ? import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({
|
|
15
15
|
MarkdownRendererPlugin: m.MarkdownRendererPlugin,
|
|
16
16
|
MarkdownMetadataRenderer: m.MarkdownMetadataRenderer
|
|
@@ -110,7 +110,7 @@ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? f
|
|
|
110
110
|
const transformedResult = deepTransformNode(node, {
|
|
111
111
|
...subProps,
|
|
112
112
|
children: node,
|
|
113
|
-
plugins:
|
|
113
|
+
plugins: (props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")
|
|
114
114
|
});
|
|
115
115
|
return (values) => {
|
|
116
116
|
const result = splitAndJoinInsertion(transformedResult, values);
|
|
@@ -260,6 +260,5 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
260
260
|
return enabledPlugins;
|
|
261
261
|
};
|
|
262
262
|
|
|
263
|
-
//#endregion
|
|
264
263
|
export { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, preactNodePlugins };
|
|
265
264
|
//# sourceMappingURL=plugins.mjs.map
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n resolveInterpreterLocale,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { lazy } from 'preact/compat';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n// These preloads are read later by `useLoadDynamic`, so the rejection must stay\n// on the promise: a `.catch()` chained into it would resolve with `undefined`\n// and be mistaken for a loaded module. Handle it on the side instead, so an\n// aborted chunk load never escapes as an unhandled rejection.\nmarkdownRendererModulePromise?.catch(() => {});\nhtmlRendererModulePromise?.catch(() => {});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, props) => {\n // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: props.dictionaryKey,\n keyPath: props.keyPath,\n locale: props.locale,\n nodeType: 'text',\n });\n }\n\n // Props are only forwarded to the editor selector: copying them for every\n // leaf would cost an allocation per rendered string\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n return renderIntlayerNode({\n value: rest.children,\n children: (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ),\n });\n }\n\n return renderIntlayerNode({\n value: props.children,\n children: props.children,\n });\n },\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_PREACT_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'preact-node',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n });\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1]?.trim();\n const value = key && values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n // VNodes cannot be injected into a raw markup string, so string\n // interpolation (not `splitAndJoinInsertion`) is used here.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/**\n * Code-split renderers are loaded with `lazy` rather than a hand-rolled\n * suspender. A node that suspended on the hand-rolled one never recovered once\n * the chunk landed, so every markdown node present on the first paint stayed\n * blank forever; `lazy` implements the suspend/retry handshake correctly.\n */\nconst MarkdownSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownRendererPlugin as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\nconst MarkdownMetadataSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownMetadataRenderer as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n use: render,\n },\n });\n\n return render() as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer = lazy(() =>\n htmlRendererModulePromise!.then((HTMLRenderer) => ({\n default: HTMLRenderer as FunctionComponent<Record<string, any>>,\n }))\n);\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n // `children` is dropped deliberately: `HTMLRenderer` resolves its\n // content as `children || html`, so forwarding the raw node here would\n // shadow the HTML string and render nothing.\n const { plugins, children: _nodeChildren, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n })\n )\n : h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n }),\n additionalProps: { use: render },\n }) as any;\n\n return render();\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = resolveInterpreterLocale(locale);\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\n translationPlugin(\n currentLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(currentLocale),\n conditionPlugin,\n nestedPlugin(currentLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n // Always include: handle plain strings/numbers and React elements\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return enabledPlugins;\n};\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,gCACJ,QAAQ,IAAI,gCAAgC,UACxC,OAAO,wCAAoC,CAAC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B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AU;EAC/C,MAAM,OAAO,KAAK,UAAU;EACd,KAAK;EAInB,MAAM,EAAE,SAAS,UAAU,eAAe,GAAG,SAAS;EAGtD,MAAM,UAAU,mBACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,QAAQ,IAAI,4BAA4B,WACxC,OAAO,UACH,EACE,iBACA,EAAE,GAAG,KAAK,GACV,EAAE,sBAAsB;IACtB,GAAG;IACH;IACA,YAAY;GACd,CAAC,CACH,IACA,EAAE,sBAAsB;IACtB,GAAG;IACH;IACA,YAAY;GACd,CAAC;GACP,iBAAiB,EAAE,KAAK,OAAO;EACjC,CAAC;EAEH,OAAO,OAAO;CAChB;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CACd,MAAM,gBAAgB,yBAAyB,MAAM;CACrD,MAAM,WAAW,GAAG,cAAc,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAyBlC,MAAM,iBAAiB;EApBrB;EACA,kBACE,eACA,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,aAAa;EAC1B;EACA,aAAa,aAAa;EAC1B;EACA;EACA;EAEA;EACA;EACA;EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAW,cAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n resolveInterpreterLocale,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { lazy } from 'preact/compat';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n// These preloads are read later by `useLoadDynamic`, so the rejection must stay\n// on the promise: a `.catch()` chained into it would resolve with `undefined`\n// and be mistaken for a loaded module. Handle it on the side instead, so an\n// aborted chunk load never escapes as an unhandled rejection.\nmarkdownRendererModulePromise?.catch(() => {});\nhtmlRendererModulePromise?.catch(() => {});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, props) => {\n // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: props.dictionaryKey,\n keyPath: props.keyPath,\n locale: props.locale,\n nodeType: 'text',\n });\n }\n\n // Props are only forwarded to the editor selector: copying them for every\n // leaf would cost an allocation per rendered string\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n return renderIntlayerNode({\n value: rest.children,\n children: (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ),\n });\n }\n\n return renderIntlayerNode({\n value: props.children,\n children: props.children,\n });\n },\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_PREACT_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'preact-node',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n });\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1]?.trim();\n const value = key && values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n // VNodes cannot be injected into a raw markup string, so string\n // interpolation (not `splitAndJoinInsertion`) is used here.\n if (isInterpolableWrapperNode(node)) {\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/**\n * Code-split renderers are loaded with `lazy` rather than a hand-rolled\n * suspender. A node that suspended on the hand-rolled one never recovered once\n * the chunk landed, so every markdown node present on the first paint stayed\n * blank forever; `lazy` implements the suspend/retry handshake correctly.\n */\nconst MarkdownSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownRendererPlugin as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\nconst MarkdownMetadataSuspenseRenderer = lazy(() =>\n markdownRendererModulePromise!.then((modules) => ({\n default: modules.MarkdownMetadataRenderer as FunctionComponent<\n Record<string, any>\n >,\n }))\n);\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n use: render,\n },\n });\n\n return render() as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer = lazy(() =>\n htmlRendererModulePromise!.then((HTMLRenderer) => ({\n default: HTMLRenderer as FunctionComponent<Record<string, any>>,\n }))\n);\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n // `children` is dropped deliberately: `HTMLRenderer` resolves its\n // content as `children || html`, so forwarding the raw node here would\n // shadow the HTML string and render nothing.\n const { plugins, children: _nodeChildren, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n })\n )\n : h(HTMLSuspenseRenderer, {\n ...rest,\n html,\n components: userComponents,\n }),\n additionalProps: { use: render },\n }) as any;\n\n return render();\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = resolveInterpreterLocale(locale);\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\n translationPlugin(\n currentLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(currentLocale),\n conditionPlugin,\n nestedPlugin(currentLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n // Always include: handle plain strings/numbers and React elements\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return enabledPlugins;\n};\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,gCACJ,QAAQ,IAAI,gCAAgC,UACxC,OAAO,wCAAoC,CAAC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;AAC9B,EAAE,IACF;AAEN,MAAM,4BACJ,QAAQ,IAAI,4BAA4B,UACpC,OAAO,0BAAsB,CAAC,MAAM,MAAM,EAAE,YAAY,IACxD;AAMN,+BAA+B,YAAY,CAAC,CAAC;AAC7C,2BAA2B,YAAY,CAAC,CAAC;;AAWzC,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,UAAU;EAG3B,IAAI,QAAQ,IAAI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GACP,iBAAiB,EAAE,KAAK,OAAO;EACjC,CAAC;EAEH,OAAO,OAAO;CAChB;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CACd,MAAM,gBAAgB,yBAAyB,MAAM;CACrD,MAAM,WAAW,GAAG,cAAc,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAyBlC,MAAM,iBAAiB;EApBrB;EACA,kBACE,eACA,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,aAAa;EAC1B;EACA,aAAa,aAAa;EAC1B;EACA;EACA;EAEA;EACA;EACA;EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAW,cAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement } from "preact";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/preactElement/renderPreactElement.ts
|
|
4
4
|
const renderPreactElement = (element) => {
|
|
5
5
|
if (element === null || typeof element !== "object") return element;
|
|
6
6
|
const convertChildrenAsArray = (element) => {
|
|
@@ -36,6 +36,5 @@ const renderPreactElement = (element) => {
|
|
|
36
36
|
return createElement(type ?? "span", props, ...props.children);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
export { renderPreactElement };
|
|
41
40
|
//# sourceMappingURL=renderPreactElement.mjs.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NodeProps } from "@intlayer/core/interpreter";
|
|
2
1
|
import { ResolvedEditor } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { NodeProps } from "@intlayer/core/interpreter";
|
|
3
3
|
import { ComponentChildren, VNode } from "preact";
|
|
4
|
-
//#region src/IntlayerNode.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Content node returned by `useIntlayer`.
|
|
7
6
|
*
|
|
@@ -33,5 +32,5 @@ type RenderIntlayerNodeProps<T> = {
|
|
|
33
32
|
* @returns The renderable node.
|
|
34
33
|
*/
|
|
35
34
|
export declare const renderIntlayerNode: <T>({ children, value, additionalProps }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
36
|
-
|
|
35
|
+
export {};
|
|
37
36
|
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;;;;;;;;YAmBY,aACV,IAAI,uBACJ,6BACE,eACF;EAAM,OAAO;IAAM,iBACnB;EAAU,OAAO;IAAM;KAGpB,wBAAwB;EAC3B,OAAO;EACP,UAAU;EACV;KAAqB;;;;;;;;;;;;;qBAaV,qBACX,KAAC,UAAA,OAAA,mBAKA,wBAAwB,OAAK,aAAa"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FunctionalComponent, JSX } from "preact";
|
|
2
|
-
//#region src/UI/ContentSelector.d.ts
|
|
3
2
|
type ContentSelectorProps = {
|
|
4
3
|
onPress: () => void;
|
|
5
4
|
onHover?: () => void;
|
|
@@ -9,5 +8,5 @@ type ContentSelectorProps = {
|
|
|
9
8
|
isSelecting?: boolean;
|
|
10
9
|
} & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
11
10
|
export declare const ContentSelector: FunctionalComponent<ContentSelectorProps>;
|
|
12
|
-
|
|
11
|
+
export {};
|
|
13
12
|
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";KAKK;EACH;EACA;EACA;EACA;EACA;EACA;IACE,KAAK,IAAI,eAAe;qBAEf,iBAAiB,oBAAoB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentChildren, FunctionComponent } from "preact";
|
|
2
|
-
//#region src/analytics/AnalyticsProvider.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
|
|
5
4
|
* {@link IntlayerProvider} alongside `EditorProvider`.
|
|
@@ -7,5 +6,4 @@ import { ComponentChildren, FunctionComponent } from "preact";
|
|
|
7
6
|
export declare const AnalyticsProvider: FunctionComponent<{
|
|
8
7
|
children?: ComponentChildren;
|
|
9
8
|
}>;
|
|
10
|
-
//#endregion
|
|
11
9
|
//# sourceMappingURL=AnalyticsProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsProvider.d.ts","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnalyticsProvider.d.ts","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"mappings":";;;;;qBAOa,mBAAmB;EAC9B,WAAW"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
2
|
-
//#region src/analytics/exposureSink.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Node metadata reported for a content exposure. Kept dependency-free (types
|
|
5
4
|
* only) so the interpreter hot path in `plugins.tsx` never statically imports
|
|
@@ -27,5 +26,4 @@ export declare const setExposureSink: (next: ExposureSink | null) => void;
|
|
|
27
26
|
* @param input - The node metadata to report.
|
|
28
27
|
*/
|
|
29
28
|
export declare const reportExposure: (input: ExposureInput) => void;
|
|
30
|
-
//#endregion
|
|
31
29
|
//# sourceMappingURL=exposureSink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":";;;;;;YAOY;EACV;EACA,SAAS;EACT;EACA;;;YAIU,gBAAgB,OAAO;;;;;;;qBAUtB,kBAAe,MAAU;;;;;;;qBAUzB,iBAAc,OAAW"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/analytics/useAnalytics.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Initializes the Intlayer analytics client singleton when analytics is enabled
|
|
4
3
|
* and keeps it aware of the current locale.
|
|
@@ -10,5 +9,4 @@
|
|
|
10
9
|
* time.
|
|
11
10
|
*/
|
|
12
11
|
export declare const useAnalytics: () => void;
|
|
13
|
-
//#endregion
|
|
14
12
|
//# sourceMappingURL=useAnalytics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"mappings":";;;;;;;;;;qBAgBa"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/analytics/useConversion.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Parameters describing a conversion to record.
|
|
4
3
|
*/
|
|
@@ -26,5 +25,4 @@ export type ConversionParams = {
|
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
27
|
export declare const useConversion: () => (params: ConversionParams) => void;
|
|
29
|
-
//#endregion
|
|
30
28
|
//# sourceMappingURL=useConversion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.ts"],"mappings":";;;YAMY;;EAEV;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;qBAgBW,sBAAa,QACI"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/analytics/useExperiment.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The state of an A/B experiment for the current session.
|
|
4
3
|
*/
|
|
@@ -36,5 +35,4 @@ export type ExperimentState = {
|
|
|
36
35
|
* ```
|
|
37
36
|
*/
|
|
38
37
|
export declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
|
|
39
|
-
//#endregion
|
|
40
38
|
//# sourceMappingURL=useExperiment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.ts"],"mappings":";;;YAMY;;;;;;EAMV;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;qBAsBW,gBAAa,uBACH,oBACH,uBAEjB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LocalesValues, ProviderVariant } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { ComponentChild, FunctionComponent } from "preact";
|
|
3
|
-
//#region src/client/IntlayerProvider.d.ts
|
|
4
3
|
type IntlayerValue = {
|
|
5
4
|
locale: LocalesValues;
|
|
6
5
|
setLocale: (newLocale: LocalesValues) => void;
|
|
@@ -69,5 +68,5 @@ export declare const IntlayerProviderContent: FunctionComponent<IntlayerProvider
|
|
|
69
68
|
* ```
|
|
70
69
|
*/
|
|
71
70
|
export declare const IntlayerProvider: FunctionComponent<IntlayerProviderProps>;
|
|
72
|
-
|
|
71
|
+
export {};
|
|
73
72
|
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;KAuBK;EACH,QAAQ;EACR,YAAY,WAAW;;;;;EAKvB,UAAU;EACV;;;;;qBAMW,wCAAqB,QAAA;;;;qBAWrB;YAED;EACV,WAAW;EACX,SAAS;EACT,gBAAgB;;;;;;;;;;;;;;;;;;EAkBhB,UAAU;EACV,aAAa,QAAQ;EACrB;;;;;qBAMW,yBAAyB,kBACpC;;;;;;;;;;;;;;;;;;;;;qBAsFW,kBAAkB,kBAAkB"}
|
package/dist/types/client/t.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { Locale } from "@intlayer/types/allLocales";
|
|
3
|
-
//#region src/client/t.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* On the client side, this function returns the translation of the provided multilang content.
|
|
6
5
|
*
|
|
7
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
8
7
|
*/
|
|
9
8
|
export declare const t: <Content = string>(multilangContent: StrictModeLocaleMap<Content>, locale?: Locale) => Content;
|
|
10
|
-
//#endregion
|
|
11
9
|
//# sourceMappingURL=t.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"t.d.ts","names":[],"sources":["../../../src/client/t.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"t.d.ts","names":[],"sources":["../../../src/client/t.ts"],"mappings":";;;;;;;qBAWa,IAAK,kBAAgB,kBACd,oBAAoB,UAAQ,SACrC,WAAM"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useTranslation } from "./useTraduction.js";
|
|
2
2
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
3
|
-
//#region src/client/useContent.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* On the client side, hook to get the translation content based on the locale
|
|
6
5
|
*/
|
|
@@ -9,5 +8,4 @@ export declare const useContent: <Content>(languageContent: StrictModeLocaleMap<
|
|
|
9
8
|
content: Content;
|
|
10
9
|
t: typeof useTranslation;
|
|
11
10
|
};
|
|
12
|
-
//#endregion
|
|
13
11
|
//# sourceMappingURL=useContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;qBAOa,aAAc,SAAO,iBACf,oBAAoB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IInterpreterPluginState } from "../plugins.js";
|
|
2
2
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
|
|
4
|
-
//#region src/client/useDictionary.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Preact hook that transforms a dictionary (or qualified dictionary group) and
|
|
7
6
|
* returns the content.
|
|
@@ -10,5 +9,4 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from
|
|
|
10
9
|
* the locale from the client context.
|
|
11
10
|
*/
|
|
12
11
|
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
|
|
13
|
-
//#endregion
|
|
14
12
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":["_$___plugins0.IInterpreterPluginState"],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;qBAwBa,sBACL,UAAU,aAAa,gCACvB,UAAU,gBAAgB,2BAA2B,KACzD,iBAAe,YAEL,GAAC,mBACM,2CAAC,+CAAA,kCAAA,GAAA,IAAAA,mDAAA,sBAAA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
-
//#region src/client/useDictionaryAsync.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* On the server side, Hook that transform a dictionary and return the content
|
|
6
5
|
*
|
|
7
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
8
7
|
*/
|
|
9
8
|
export declare const useDictionaryAsync: <const T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: LocalesValues) => Promise<T>;
|
|
10
|
-
//#endregion
|
|
11
9
|
//# sourceMappingURL=useDictionaryAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":";;;;;;;qBAea,2BAAkC,UAAU,YAAU,mBAC9C,0BAA0B,QAAQ,KAAG,SAC/C,kBACR,QAAQ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
3
|
import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
|
|
4
|
-
//#region src/client/useDictionaryDynamic.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Preact hook that lazily loads a dictionary and returns its content.
|
|
7
6
|
*
|
|
@@ -14,5 +13,4 @@ import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator"
|
|
|
14
13
|
* context locale is used.
|
|
15
14
|
*/
|
|
16
15
|
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => any;
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;qBAmCa,6BACL,UAAU,kBACV,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,mBAGzE,0BAA0B,QAAQ,MAClC,2BAAyB,KACxB,GAAC,mBACa"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IInterpreterPluginState } from "../plugins.js";
|
|
2
2
|
import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
-
//#region src/client/useIntlayer.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Preact hook that picks one dictionary by its key and returns its content.
|
|
6
5
|
*
|
|
@@ -26,5 +25,4 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValue
|
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
27
|
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").DictionaryRegistryResult<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
|
|
29
|
-
//#endregion
|
|
30
28
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":["_$___plugins0.IInterpreterPluginState"],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBAsCa,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,2CAAC,+CAAA,yBAAA,GAAA,IAAAA,mDAAA,sBAAA"}
|