preact-intlayer 8.6.2 → 8.6.4
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/client/IntlayerProvider.cjs +6 -4
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -2
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -2
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +1 -2
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelector.cjs +3 -2
- package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +3 -2
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +41 -14
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +6 -3
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +2 -2
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +2 -2
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs +2 -2
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/editor/ContentSelector.mjs +3 -2
- package/dist/esm/editor/ContentSelector.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +3 -2
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/plugins.mjs +42 -14
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.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/plugins.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -3,10 +3,10 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_editor_EditorProvider = require('../editor/EditorProvider.cjs');
|
|
4
4
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
5
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
6
|
let preact = require("preact");
|
|
8
7
|
let preact_hooks = require("preact/hooks");
|
|
9
8
|
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
9
|
+
let _intlayer_config_client = require("@intlayer/config/client");
|
|
10
10
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
11
11
|
|
|
12
12
|
//#region src/client/IntlayerProvider.tsx
|
|
@@ -14,7 +14,7 @@ let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
|
14
14
|
* Context that store the current locale on the client side
|
|
15
15
|
*/
|
|
16
16
|
const IntlayerClientContext = (0, preact.createContext)({
|
|
17
|
-
locale: require_client_useLocaleStorage.localeInStorage ?? _intlayer_config_built.
|
|
17
|
+
locale: require_client_useLocaleStorage.localeInStorage ?? _intlayer_config_built.internationalization?.defaultLocale,
|
|
18
18
|
setLocale: () => null
|
|
19
19
|
});
|
|
20
20
|
/**
|
|
@@ -25,8 +25,7 @@ const useIntlayerContext = () => (0, preact_hooks.useContext)(IntlayerClientCont
|
|
|
25
25
|
* Provider that store the current locale on the client side
|
|
26
26
|
*/
|
|
27
27
|
const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, isCookieEnabled }) => {
|
|
28
|
-
const {
|
|
29
|
-
const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = internationalization ?? {};
|
|
28
|
+
const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
|
|
30
29
|
const [currentLocale, setCurrentLocale] = (0, preact_hooks.useState)(localeProp ?? require_client_useLocaleStorage.localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
|
|
31
30
|
(0, preact_hooks.useEffect)(() => {
|
|
32
31
|
if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
|
|
@@ -35,6 +34,9 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
|
|
|
35
34
|
currentLocale,
|
|
36
35
|
setCurrentLocale
|
|
37
36
|
]);
|
|
37
|
+
(0, preact_hooks.useEffect)(() => {
|
|
38
|
+
(0, _intlayer_config_client.setIntlayerIdentifier)();
|
|
39
|
+
}, []);
|
|
38
40
|
const setLocaleBase = (newLocale) => {
|
|
39
41
|
if (currentLocale.toString() === newLocale.toString()) return;
|
|
40
42
|
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","internationalization","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,kDAAqD;CAChE,QAAQA,mDAAmBC,6CAAsB;CACjD,iBAAiB;CAClB,CAAC;;;;AAKF,MAAa,wDAAsC,sBAAsB,IAAI,EAAE;;;;AAa/E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnDA,+CAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,+CAFpB,cAAcD,mDAAmB,qBAAqB,oBAIvD;AAED,mCAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B;EAAC;EAAY;EAAe;EAAiB,CAAC;AAEjD,mCAAgB;AACd,sDAAuB;IACtB,EAAE,CAAC;CAEN,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qDAAmB,WAAW,mBAAmB,KAAK;;CAGxD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iEAAgC,cAAc,cAAc;AAElE,QACE,4CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,6CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,4CAACE,8CAAD,EAAkB,GACjB,SACuB"}
|
|
@@ -3,7 +3,6 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
4
4
|
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
5
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
6
|
let preact_hooks = require("preact/hooks");
|
|
8
7
|
|
|
9
8
|
//#region src/client/useDictionaryAsync.ts
|
|
@@ -14,7 +13,7 @@ let preact_hooks = require("preact/hooks");
|
|
|
14
13
|
*/
|
|
15
14
|
const useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
16
15
|
const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
17
|
-
const localeTarget = (0, preact_hooks.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.
|
|
16
|
+
const localeTarget = (0, preact_hooks.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.internationalization.defaultLocale, [currentLocale, locale]);
|
|
18
17
|
return require_client_useDictionary.useDictionary(await (0, preact_hooks.useMemo)(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
|
|
19
18
|
};
|
|
20
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,+CACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,gCACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
|
|
@@ -3,7 +3,6 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
4
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
6
|
let preact_hooks = require("preact/hooks");
|
|
8
7
|
|
|
9
8
|
//#region src/client/useLocale.ts
|
|
@@ -31,7 +30,7 @@ let preact_hooks = require("preact/hooks");
|
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
32
|
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
34
|
-
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.
|
|
33
|
+
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
|
|
35
34
|
const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
36
35
|
const setLocale = (locale) => {
|
|
37
36
|
if (!availableLocales?.map(String).includes(locale)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,sDAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;AAC3C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,WAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,iBAAe,OAAO;AAEtB,qDACE,QACA,mBAAmB,0BAA0B,KAC9C;AAED,mBAAiB,OAAO;;AAG1B,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -2,11 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
6
5
|
let preact_hooks = require("preact/hooks");
|
|
7
6
|
|
|
8
7
|
//#region src/client/useLocaleBase.ts
|
|
9
|
-
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.
|
|
8
|
+
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization;
|
|
10
9
|
/**
|
|
11
10
|
* On the client side, hook to get the current locale and all related fields
|
|
12
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useLocaleBase.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqBA;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,2CAAyBC,sDAAsB,IAAI,EAAE;AAErE,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -5,14 +5,15 @@ 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";
|
|
8
9
|
const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
9
10
|
(0, preact_hooks.useEffect)(() => {
|
|
10
|
-
if (!_intlayer_editor_isEnabled.isEnabled || typeof window === "undefined") return;
|
|
11
|
+
if (TREE_SHAKE_EDITOR || !_intlayer_editor_isEnabled.isEnabled || typeof window === "undefined") return;
|
|
11
12
|
import("@intlayer/editor").then(({ defineIntlayerElements }) => {
|
|
12
13
|
defineIntlayerElements();
|
|
13
14
|
});
|
|
14
15
|
}, [_intlayer_editor_isEnabled.isEnabled]);
|
|
15
|
-
if (!_intlayer_editor_isEnabled.isEnabled) return children;
|
|
16
|
+
if (TREE_SHAKE_EDITOR || !_intlayer_editor_isEnabled.isEnabled) return children;
|
|
16
17
|
return /* @__PURE__ */ (0, preact_jsx_runtime.jsx)("intlayer-content-selector-wrapper", {
|
|
17
18
|
"key-path": JSON.stringify(keyPath),
|
|
18
19
|
"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\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (!isEnabled || typeof window === 'undefined')
|
|
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\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\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 (TREE_SHAKE_EDITOR || !isEnabled || typeof window === 'undefined')\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (TREE_SHAKE_EDITOR || !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":";;;;;;;AAiBA,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAKrE,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;AAC5C,mCAAgB;AACd,MAAI,qBAAqB,CAACA,wCAAa,OAAO,WAAW,YACvD;AACF,SAAO,oBAAoB,MAAM,EAAE,6BAA6B;AAC9D,2BAAwB;IACxB;IACD,CAACA,qCAAU,CAAC;AAEf,KAAI,qBAAqB,CAACA,qCACxB,QAAO;AAGT,QACE,4CAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
|
|
@@ -5,6 +5,7 @@ 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";
|
|
8
9
|
/**
|
|
9
10
|
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
10
11
|
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
@@ -14,7 +15,7 @@ const useEditor = () => {
|
|
|
14
15
|
const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
15
16
|
const managerRef = (0, preact_hooks.useRef)(null);
|
|
16
17
|
(0, preact_hooks.useEffect)(() => {
|
|
17
|
-
if (!_intlayer_editor_isEnabled.isEnabled) return;
|
|
18
|
+
if (TREE_SHAKE_EDITOR || !_intlayer_editor_isEnabled.isEnabled) return;
|
|
18
19
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
19
20
|
const manager = initEditorClient();
|
|
20
21
|
managerRef.current = manager;
|
|
@@ -28,7 +29,7 @@ const useEditor = () => {
|
|
|
28
29
|
};
|
|
29
30
|
}, []);
|
|
30
31
|
(0, preact_hooks.useEffect)(() => {
|
|
31
|
-
if (!locale || !managerRef.current) return;
|
|
32
|
+
if (TREE_SHAKE_EDITOR || !locale || !managerRef.current) return;
|
|
32
33
|
managerRef.current.currentLocale.set(locale);
|
|
33
34
|
}, [locale]);
|
|
34
35
|
};
|
|
@@ -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\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 (!isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":"
|
|
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\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\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 (TREE_SHAKE_EDITOR || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (TREE_SHAKE_EDITOR || !locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;AAMA,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;;;;;;AAOrE,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAC1D,MAAM,sCAA+C,KAAK;AAE1D,mCAAgB;AACd,MAAI,qBAAqB,CAACC,qCAAW;AAErC,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,MAAI,qBAAqB,CAAC,UAAU,CAAC,WAAW,QAAS;AAEzD,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -4,7 +4,6 @@ const require_editor_ContentSelector = require('./editor/ContentSelector.cjs');
|
|
|
4
4
|
const require_IntlayerNode = require('./IntlayerNode.cjs');
|
|
5
5
|
const require_preactElement_renderPreactElement = require('./preactElement/renderPreactElement.cjs');
|
|
6
6
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
8
7
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
9
8
|
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
10
9
|
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
@@ -14,30 +13,54 @@ let preact_compat = require("preact/compat");
|
|
|
14
13
|
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
15
14
|
|
|
16
15
|
//#region src/plugins.tsx
|
|
16
|
+
/**
|
|
17
|
+
* True when the intlayer node type is explicitly disabled at build time.
|
|
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";
|
|
17
40
|
const LazyMarkdownMetadataRenderer = (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
18
41
|
const LazyMarkdownRendererPlugin = (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
19
42
|
const LazyHTMLRenderer = (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./html/HTMLRenderer.cjs")).then((m) => ({ default: m.HTMLRenderer })));
|
|
20
43
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
21
|
-
const intlayerNodePlugins =
|
|
44
|
+
const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
22
45
|
id: "intlayer-node-plugin",
|
|
23
46
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
24
47
|
transform: (_node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
25
48
|
...rest,
|
|
26
49
|
value: rest.children,
|
|
27
|
-
children: _intlayer_config_built.
|
|
50
|
+
children: !TREE_SHAKE_EDITOR && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact.createElement)(require_editor_ContentSelector.ContentSelector, {
|
|
28
51
|
...rest,
|
|
29
52
|
key: rest.children
|
|
30
53
|
}, rest.children) : rest.children
|
|
31
54
|
})
|
|
32
55
|
};
|
|
33
56
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
34
|
-
const preactNodePlugins =
|
|
57
|
+
const preactNodePlugins = TREE_SHAKE_PREACT_NODE ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
35
58
|
id: "preact-node-plugin",
|
|
36
59
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
37
60
|
transform: (node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
|
|
38
61
|
...rest,
|
|
39
62
|
value: "[[preact-element]]",
|
|
40
|
-
children: _intlayer_config_built.
|
|
63
|
+
children: !TREE_SHAKE_EDITOR && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
41
64
|
...rest,
|
|
42
65
|
children: require_preactElement_renderPreactElement.renderPreactElement(node)
|
|
43
66
|
}) : require_preactElement_renderPreactElement.renderPreactElement(node)
|
|
@@ -71,7 +94,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
71
94
|
return (0, preact.h)(preact.Fragment, null, ...parts.map((part, index) => (0, preact.h)(preact.Fragment, { key: index }, part)));
|
|
72
95
|
};
|
|
73
96
|
/** Insertion plugin for Preact. Handles component/node insertion. */
|
|
74
|
-
const insertionPlugin =
|
|
97
|
+
const insertionPlugin = TREE_SHAKE_INSERTION ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
75
98
|
id: "insertion-plugin",
|
|
76
99
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
|
|
77
100
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -112,7 +135,7 @@ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? _
|
|
|
112
135
|
}
|
|
113
136
|
};
|
|
114
137
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
115
|
-
const markdownStringPlugin =
|
|
138
|
+
const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
116
139
|
id: "markdown-string-plugin",
|
|
117
140
|
canHandle: (node) => typeof node === "string",
|
|
118
141
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -124,7 +147,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
124
147
|
transform: (metadataNode, props) => require_IntlayerNode.renderIntlayerNode({
|
|
125
148
|
...props,
|
|
126
149
|
value: metadataNode,
|
|
127
|
-
children: _intlayer_config_built.
|
|
150
|
+
children: !TREE_SHAKE_EDITOR && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
128
151
|
...rest,
|
|
129
152
|
children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
|
|
130
153
|
fallback: node,
|
|
@@ -150,7 +173,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
150
173
|
const render = (components) => require_IntlayerNode.renderIntlayerNode({
|
|
151
174
|
...props,
|
|
152
175
|
value: node,
|
|
153
|
-
children: _intlayer_config_built.
|
|
176
|
+
children: !TREE_SHAKE_EDITOR && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
|
|
154
177
|
...rest,
|
|
155
178
|
children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
|
|
156
179
|
fallback: node,
|
|
@@ -179,7 +202,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
179
202
|
} });
|
|
180
203
|
}
|
|
181
204
|
};
|
|
182
|
-
const markdownPlugin =
|
|
205
|
+
const markdownPlugin = TREE_SHAKE_MARKDOWN ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
183
206
|
id: "markdown-plugin",
|
|
184
207
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
|
|
185
208
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -194,7 +217,7 @@ const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? _in
|
|
|
194
217
|
}
|
|
195
218
|
};
|
|
196
219
|
/** HTML plugin. Replaces node with a function that takes components => VNode. */
|
|
197
|
-
const htmlPlugin =
|
|
220
|
+
const htmlPlugin = TREE_SHAKE_HTML ? _intlayer_core_interpreter.fallbackPlugin : {
|
|
198
221
|
id: "html-plugin",
|
|
199
222
|
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
|
|
200
223
|
transform: (node, props) => {
|
|
@@ -204,7 +227,11 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? _intlayer_c
|
|
|
204
227
|
const render = (userComponents) => require_IntlayerNode.renderIntlayerNode({
|
|
205
228
|
...rest,
|
|
206
229
|
value: html,
|
|
207
|
-
children: (0, preact.h)(preact_compat.Suspense, { fallback: html }, (0, preact.h)(LazyHTMLRenderer, {
|
|
230
|
+
children: !TREE_SHAKE_EDITOR && _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
|
+
...rest,
|
|
232
|
+
html,
|
|
233
|
+
userComponents
|
|
234
|
+
}))) : (0, preact.h)(preact_compat.Suspense, { fallback: html }, (0, preact.h)(LazyHTMLRenderer, {
|
|
208
235
|
...rest,
|
|
209
236
|
html,
|
|
210
237
|
userComponents
|
|
@@ -223,10 +250,10 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? _intlayer_c
|
|
|
223
250
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
224
251
|
*/
|
|
225
252
|
const getPlugins = (locale, fallback = true) => [
|
|
226
|
-
(0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.
|
|
253
|
+
(0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale, fallback ? _intlayer_config_built.internationalization.defaultLocale : void 0),
|
|
227
254
|
_intlayer_core_interpreter.enumerationPlugin,
|
|
228
255
|
_intlayer_core_interpreter.conditionPlugin,
|
|
229
|
-
(0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.
|
|
256
|
+
(0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale),
|
|
230
257
|
_intlayer_core_interpreter.filePlugin,
|
|
231
258
|
_intlayer_core_interpreter.genderPlugin,
|
|
232
259
|
intlayerNodePlugins,
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","configuration","ContentSelector","renderPreactElement","Fragment","NodeTypes","Suspense","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n 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// preact lazy for heavy renderer components — creates separate code-split chunks\nconst LazyMarkdownMetadataRenderer = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n);\n\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRenderer = lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest} 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: configuration.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: configuration.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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as 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: 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\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 [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,MAAM,kGACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAED,MAAM,gGACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,sFACJ,4BAA8B,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAWD,MAAa,sBACX,QAAQ,IAAI,qCAAqC,UAC7CA,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UAAUC,+BAAc,OAAO,UAC7B,0CAACC,gDAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAER,CAAC;CACL;;AAcP,MAAa,oBACX,QAAQ,IAAI,mCAAmC,UAC3CH,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO;EACP,UAAUC,+BAAc,OAAO,UAC7B,4CAACC,gDAAD;GAAiB,GAAI;aAClBC,8DAAoB,KAAK;GACV,IAElBA,8DAAoB,KAAK;EAE5B,CAAC;CACL;;;;AAuBP,MAAM,WAAW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ACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaM,yBAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAKA,yBAAU;AACd,OAAK;EACnB,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACdL,wCAAmB;GACjB,GAAG;GACH,OAAO;GACP,wBACEM,wBACA,EAAE,UAAU,MAAM,gBAChB,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,SAfc,IAAI,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,CAAC;;CAIL;;;;;AAuCP,MAAa,cACX,QACA,WAAoB,SAEpB;mDAEI,UAAUL,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDM;CACAC;8CACa,UAAUP,+BAAc,qBAAqB,cAAc;CACxEQ;CACAC;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","editor","ContentSelector","renderPreactElement","Fragment","NodeTypes","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\nconst LazyMarkdownMetadataRenderer = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n);\n\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRenderer = lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\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\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 [\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 ].filter(Boolean) as Plugins[];\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,oBAAoB,QAAQ,IAAI,+BAA+B;AAGrE,MAAM,kGACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAED,MAAM,gGACJ,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,sFACJ,4BAA8B,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAWD,MAAa,sBAA+B,2BACxCA,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,CAAC,qBAAqBC,8BAAO,UAC3B,0CAACC,gDAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAEV,CAAC;CACL;;AAcL,MAAa,oBAA6B,yBACtCH,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLC,wCAAmB;EACjB,GAAG;EACH,OAAO;EACP,UACE,CAAC,qBAAqBC,8BAAO,UAC3B,4CAACC,gDAAD;G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iBL,MAAa,aAAsB,kBAC/BN,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaM,yBAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAKA,yBAAU;AACd,OAAK;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,gBAETI,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,SAfc,IAAI,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,CAAC;;CAIL;;;;;AAuCL,MAAa,cACX,QACA,WAAoB,SAEpB;mDAEI,UAAUC,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;CACDC;CACAC;8CACa,UAAUF,4CAAqB,cAAc;CAC1DG;CACAC;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EditorProvider } from "../editor/EditorProvider.mjs";
|
|
2
2
|
import { localeInStorage, setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
import { createContext } from "preact";
|
|
5
5
|
import { useContext, useEffect, useState } from "preact/hooks";
|
|
6
6
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
7
|
+
import { setIntlayerIdentifier } from "@intlayer/config/client";
|
|
7
8
|
import { localeResolver } from "@intlayer/core/localization";
|
|
8
9
|
|
|
9
10
|
//#region src/client/IntlayerProvider.tsx
|
|
@@ -11,7 +12,7 @@ import { localeResolver } from "@intlayer/core/localization";
|
|
|
11
12
|
* Context that store the current locale on the client side
|
|
12
13
|
*/
|
|
13
14
|
const IntlayerClientContext = createContext({
|
|
14
|
-
locale: localeInStorage ??
|
|
15
|
+
locale: localeInStorage ?? internationalization?.defaultLocale,
|
|
15
16
|
setLocale: () => null
|
|
16
17
|
});
|
|
17
18
|
/**
|
|
@@ -22,7 +23,6 @@ const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};
|
|
|
22
23
|
* Provider that store the current locale on the client side
|
|
23
24
|
*/
|
|
24
25
|
const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, isCookieEnabled }) => {
|
|
25
|
-
const { internationalization } = configuration ?? {};
|
|
26
26
|
const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = internationalization ?? {};
|
|
27
27
|
const [currentLocale, setCurrentLocale] = useState(localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
|
|
28
28
|
useEffect(() => {
|
|
@@ -32,6 +32,9 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
|
|
|
32
32
|
currentLocale,
|
|
33
33
|
setCurrentLocale
|
|
34
34
|
]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setIntlayerIdentifier();
|
|
37
|
+
}, []);
|
|
35
38
|
const setLocaleBase = (newLocale) => {
|
|
36
39
|
if (currentLocale.toString() === newLocale.toString()) return;
|
|
37
40
|
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CAClB,CAAC;;;;AAKF,MAAa,2BAA2B,WAAW,sBAAsB,IAAI,EAAE;;;;AAa/E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,oBAAoB,SAFxC,cAAc,mBAAmB,qBAAqB,oBAIvD;AAED,iBAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B;EAAC;EAAY;EAAe;EAAiB,CAAC;AAEjD,iBAAgB;AACd,yBAAuB;IACtB,EAAE,CAAC;CAEN,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qBAAmB,WAAW,mBAAmB,KAAK;;CAGxD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iBAAiB,eAAe,cAAc,cAAc;AAElE,QACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,EAAkB,GACjB,SACuB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
2
|
import { useDictionary } from "./useDictionary.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
import { useContext, useMemo } from "preact/hooks";
|
|
5
5
|
|
|
6
6
|
//#region src/client/useDictionaryAsync.ts
|
|
@@ -11,7 +11,7 @@ import { useContext, useMemo } from "preact/hooks";
|
|
|
11
11
|
*/
|
|
12
12
|
const useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
13
13
|
const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
|
|
14
|
-
const localeTarget = useMemo(() => locale ?? currentLocale ??
|
|
14
|
+
const localeTarget = useMemo(() => locale ?? currentLocale ?? internationalization.defaultLocale, [currentLocale, locale]);
|
|
15
15
|
return useDictionary(await useMemo(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cARY,MAAM,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
2
2
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
import { useContext } from "preact/hooks";
|
|
5
5
|
|
|
6
6
|
//#region src/client/useLocale.ts
|
|
@@ -28,7 +28,7 @@ import { useContext } from "preact/hooks";
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
31
|
-
const { defaultLocale, locales: availableLocales } =
|
|
31
|
+
const { defaultLocale, locales: availableLocales } = internationalization ?? {};
|
|
32
32
|
const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = useContext(IntlayerClientContext) ?? {};
|
|
33
33
|
const setLocale = (locale) => {
|
|
34
34
|
if (!availableLocales?.map(String).includes(locale)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;AAC3C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,WAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,iBAAe,OAAO;AAEtB,qBACE,QACA,mBAAmB,0BAA0B,KAC9C;AAED,mBAAiB,OAAO;;AAG1B,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
|
-
import
|
|
2
|
+
import { internationalization } from "@intlayer/config/built";
|
|
3
3
|
import { useContext } from "preact/hooks";
|
|
4
4
|
|
|
5
5
|
//#region src/client/useLocaleBase.ts
|
|
6
|
-
const { defaultLocale, locales: availableLocales } =
|
|
6
|
+
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
7
7
|
/**
|
|
8
8
|
* On the client side, hook to get the current locale and all related fields
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqB;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,sBAAsB,IAAI,EAAE;AAErE,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -3,14 +3,15 @@ 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";
|
|
6
7
|
const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
7
8
|
useEffect(() => {
|
|
8
|
-
if (!isEnabled || typeof window === "undefined") return;
|
|
9
|
+
if (TREE_SHAKE_EDITOR || !isEnabled || typeof window === "undefined") return;
|
|
9
10
|
import("@intlayer/editor").then(({ defineIntlayerElements }) => {
|
|
10
11
|
defineIntlayerElements();
|
|
11
12
|
});
|
|
12
13
|
}, [isEnabled]);
|
|
13
|
-
if (!isEnabled) return children;
|
|
14
|
+
if (TREE_SHAKE_EDITOR || !isEnabled) return children;
|
|
14
15
|
return /* @__PURE__ */ jsx("intlayer-content-selector-wrapper", {
|
|
15
16
|
"key-path": JSON.stringify(keyPath),
|
|
16
17
|
"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\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (!isEnabled || typeof window === 'undefined')
|
|
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\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\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 (TREE_SHAKE_EDITOR || !isEnabled || typeof window === 'undefined')\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (TREE_SHAKE_EDITOR || !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":";;;;;AAiBA,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAKrE,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;AAC5C,iBAAgB;AACd,MAAI,qBAAqB,CAAC,aAAa,OAAO,WAAW,YACvD;AACF,SAAO,oBAAoB,MAAM,EAAE,6BAA6B;AAC9D,2BAAwB;IACxB;IACD,CAAC,UAAU,CAAC;AAEf,KAAI,qBAAqB,CAAC,UACxB,QAAO;AAGT,QACE,oBAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
|
|
@@ -3,6 +3,7 @@ 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";
|
|
6
7
|
/**
|
|
7
8
|
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
8
9
|
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
@@ -12,7 +13,7 @@ const useEditor = () => {
|
|
|
12
13
|
const { locale } = useContext(IntlayerClientContext) ?? {};
|
|
13
14
|
const managerRef = useRef(null);
|
|
14
15
|
useEffect(() => {
|
|
15
|
-
if (!isEnabled) return;
|
|
16
|
+
if (TREE_SHAKE_EDITOR || !isEnabled) return;
|
|
16
17
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
17
18
|
const manager = initEditorClient();
|
|
18
19
|
managerRef.current = manager;
|
|
@@ -26,7 +27,7 @@ const useEditor = () => {
|
|
|
26
27
|
};
|
|
27
28
|
}, []);
|
|
28
29
|
useEffect(() => {
|
|
29
|
-
if (!locale || !managerRef.current) return;
|
|
30
|
+
if (TREE_SHAKE_EDITOR || !locale || !managerRef.current) return;
|
|
30
31
|
managerRef.current.currentLocale.set(locale);
|
|
31
32
|
}, [locale]);
|
|
32
33
|
};
|
|
@@ -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\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 (!isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":"
|
|
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\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\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 (TREE_SHAKE_EDITOR || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (TREE_SHAKE_EDITOR || !locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;AAMA,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;;;;;;AAOrE,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAC1D,MAAM,aAAa,OAAkC,KAAK;AAE1D,iBAAgB;AACd,MAAI,qBAAqB,CAAC,UAAW;AAErC,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,iBAAgB;AACd,MAAI,qBAAqB,CAAC,UAAU,CAAC,WAAW,QAAS;AAEzD,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContentSelector } from "./editor/ContentSelector.mjs";
|
|
2
2
|
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
3
3
|
import { renderPreactElement } from "./preactElement/renderPreactElement.mjs";
|
|
4
|
-
import
|
|
4
|
+
import { editor, internationalization } from "@intlayer/config/built";
|
|
5
5
|
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin } from "@intlayer/core/interpreter";
|
|
6
6
|
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
7
7
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
@@ -10,30 +10,54 @@ import { Suspense, lazy } from "preact/compat";
|
|
|
10
10
|
import { jsx } from "preact/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/plugins.tsx
|
|
13
|
+
/**
|
|
14
|
+
* True when the intlayer node type is explicitly disabled at build time.
|
|
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";
|
|
13
37
|
const LazyMarkdownMetadataRenderer = lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownMetadataRenderer })));
|
|
14
38
|
const LazyMarkdownRendererPlugin = lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownRendererPlugin })));
|
|
15
39
|
const LazyHTMLRenderer = lazy(() => import("./html/HTMLRenderer.mjs").then((m) => ({ default: m.HTMLRenderer })));
|
|
16
40
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
17
|
-
const intlayerNodePlugins =
|
|
41
|
+
const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE ? fallbackPlugin : {
|
|
18
42
|
id: "intlayer-node-plugin",
|
|
19
43
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
20
44
|
transform: (_node, { plugins, ...rest }) => renderIntlayerNode({
|
|
21
45
|
...rest,
|
|
22
46
|
value: rest.children,
|
|
23
|
-
children:
|
|
47
|
+
children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ createElement(ContentSelector, {
|
|
24
48
|
...rest,
|
|
25
49
|
key: rest.children
|
|
26
50
|
}, rest.children) : rest.children
|
|
27
51
|
})
|
|
28
52
|
};
|
|
29
53
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
30
|
-
const preactNodePlugins =
|
|
54
|
+
const preactNodePlugins = TREE_SHAKE_PREACT_NODE ? fallbackPlugin : {
|
|
31
55
|
id: "preact-node-plugin",
|
|
32
56
|
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
33
57
|
transform: (node, { plugins, ...rest }) => renderIntlayerNode({
|
|
34
58
|
...rest,
|
|
35
59
|
value: "[[preact-element]]",
|
|
36
|
-
children:
|
|
60
|
+
children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
37
61
|
...rest,
|
|
38
62
|
children: renderPreactElement(node)
|
|
39
63
|
}) : renderPreactElement(node)
|
|
@@ -67,7 +91,7 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
67
91
|
return h(Fragment, null, ...parts.map((part, index) => h(Fragment, { key: index }, part)));
|
|
68
92
|
};
|
|
69
93
|
/** Insertion plugin for Preact. Handles component/node insertion. */
|
|
70
|
-
const insertionPlugin =
|
|
94
|
+
const insertionPlugin = TREE_SHAKE_INSERTION ? fallbackPlugin : {
|
|
71
95
|
id: "insertion-plugin",
|
|
72
96
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
|
|
73
97
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -108,7 +132,7 @@ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? f
|
|
|
108
132
|
}
|
|
109
133
|
};
|
|
110
134
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
111
|
-
const markdownStringPlugin =
|
|
135
|
+
const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
112
136
|
id: "markdown-string-plugin",
|
|
113
137
|
canHandle: (node) => typeof node === "string",
|
|
114
138
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -120,7 +144,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
120
144
|
transform: (metadataNode, props) => renderIntlayerNode({
|
|
121
145
|
...props,
|
|
122
146
|
value: metadataNode,
|
|
123
|
-
children:
|
|
147
|
+
children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
124
148
|
...rest,
|
|
125
149
|
children: /* @__PURE__ */ jsx(Suspense, {
|
|
126
150
|
fallback: node,
|
|
@@ -146,7 +170,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
146
170
|
const render = (components) => renderIntlayerNode({
|
|
147
171
|
...props,
|
|
148
172
|
value: node,
|
|
149
|
-
children:
|
|
173
|
+
children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
150
174
|
...rest,
|
|
151
175
|
children: /* @__PURE__ */ jsx(Suspense, {
|
|
152
176
|
fallback: node,
|
|
@@ -175,7 +199,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
|
|
|
175
199
|
} });
|
|
176
200
|
}
|
|
177
201
|
};
|
|
178
|
-
const markdownPlugin =
|
|
202
|
+
const markdownPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
|
|
179
203
|
id: "markdown-plugin",
|
|
180
204
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
|
|
181
205
|
transform: (node, props, deepTransformNode) => {
|
|
@@ -190,7 +214,7 @@ const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fal
|
|
|
190
214
|
}
|
|
191
215
|
};
|
|
192
216
|
/** HTML plugin. Replaces node with a function that takes components => VNode. */
|
|
193
|
-
const htmlPlugin =
|
|
217
|
+
const htmlPlugin = TREE_SHAKE_HTML ? fallbackPlugin : {
|
|
194
218
|
id: "html-plugin",
|
|
195
219
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
196
220
|
transform: (node, props) => {
|
|
@@ -200,7 +224,11 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
|
|
|
200
224
|
const render = (userComponents) => renderIntlayerNode({
|
|
201
225
|
...rest,
|
|
202
226
|
value: html,
|
|
203
|
-
children: h(Suspense, { fallback: html }, h(LazyHTMLRenderer, {
|
|
227
|
+
children: !TREE_SHAKE_EDITOR && editor.enabled ? h(ContentSelector, { ...rest }, h(Suspense, { fallback: html }, h(LazyHTMLRenderer, {
|
|
228
|
+
...rest,
|
|
229
|
+
html,
|
|
230
|
+
userComponents
|
|
231
|
+
}))) : h(Suspense, { fallback: html }, h(LazyHTMLRenderer, {
|
|
204
232
|
...rest,
|
|
205
233
|
html,
|
|
206
234
|
userComponents
|
|
@@ -219,10 +247,10 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
|
|
|
219
247
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
220
248
|
*/
|
|
221
249
|
const getPlugins = (locale, fallback = true) => [
|
|
222
|
-
translationPlugin(locale ??
|
|
250
|
+
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
|
|
223
251
|
enumerationPlugin,
|
|
224
252
|
conditionPlugin,
|
|
225
|
-
nestedPlugin(locale ??
|
|
253
|
+
nestedPlugin(locale ?? internationalization.defaultLocale),
|
|
226
254
|
filePlugin,
|
|
227
255
|
genderPlugin,
|
|
228
256
|
intlayerNodePlugins,
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n 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// preact lazy for heavy renderer components — creates separate code-split chunks\nconst LazyMarkdownMetadataRenderer = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n);\n\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRenderer = lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration.editor.enabled ? (\n <ContentSelector {...rest} 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: configuration.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: configuration.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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin {...rest} components={components}>\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as 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: 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\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 [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,+BAA+B,WACnC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAED,MAAM,6BAA6B,WACjC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,mBAAmB,WACvB,OAAO,2BAAuB,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAWD,MAAa,sBACX,QAAQ,IAAI,qCAAqC,UAC7C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UAAU,cAAc,OAAO,UAC7B,8BAAC,iBAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAER,CAAC;CACL;;AAcP,MAAa,oBACX,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GA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GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL;;AAiBP,MAAa,aACX,QAAQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAK,UAAU;AACd,OAAK;EACnB,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,UAAU,EACR,UACA,EAAE,UAAU,MAAM,EAClB,EAAE,kBAAyB;IACzB,GAAG;IACH;IACA;IACD,CAAC,CACH;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAiBxB,SAfc,IAAI,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,CAAC;;CAIL;;;;;AAuCP,MAAa,cACX,QACA,WAAoB,SAEpB;CACE,kBACE,UAAU,cAAc,qBAAqB,eAC7C,WAAW,cAAc,qBAAqB,gBAAgB,OAC/D;CACD;CACA;CACA,aAAa,UAAU,cAAc,qBAAqB,cAAc;CACxE;CACA;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
|
|
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 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\nconst LazyMarkdownMetadataRenderer = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n);\n\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRenderer = lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\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\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 [\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 ].filter(Boolean) as Plugins[];\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,oBAAoB,QAAQ,IAAI,+BAA+B;AAGrE,MAAM,+BAA+B,WACnC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAED,MAAM,6BAA6B,WACjC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,mBAAmB,WACvB,OAAO,2BAAuB,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAWD,MAAa,sBAA+B,2BACxC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGL,mBAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,CAAC,qBAAqB,OAAO,UAC3B,8BAAC,iBAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAEV,CAAC;CACL;;AAcL,MAAa,oBAA6B,yBACtC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGL,mBAAm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,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL;;AAiBL,MAAa,aAAsB,kBAC/B,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAK,UAAU;AACd,OAAK;EACnB,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,CAAC,qBAAqB,OAAO,UACzB,EACE,iBACA,EAAE,GAAG,MAAM,EACX,EACE,UACA,EAAE,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,SAfc,IAAI,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,CAAC;;CAIL;;;;;AAuCL,MAAa,cACX,QACA,WAAoB,SAEpB;CACE,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;CACD;CACA;CACA,aAAa,UAAU,qBAAqB,cAAc;CAC1D;CACA;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
|
|
@@ -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":";;;;;KAaK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAA;EACvB,eAAA;AAAA;;;;cAMW,qBAAA,EAAqB,QAAA,CAAA,OAAA,CAAA,aAAA;;;;cAQrB,kBAAA;AAAA,KAED,qBAAA;EACV,QAAA,GAAW,cAAA;EACX,MAAA,GAAS,aAAA;EACT,aAAA,GAAgB,aAAA;EAChB,SAAA,IAAa,MAAA,EAAQ,aAAA;EACrB,eAAA;AAAA;AAPF;;;AAAA,cAaa,uBAAA,EAAyB,iBAAA,CACpC,qBAAA;;AAZF;;;;;;;;;;;;;;;;;;;cAyFa,gBAAA,EAAkB,iBAAA,CAAkB,qBAAA"}
|
|
@@ -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 +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,KAQI,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":";;AAaA;;;;cAAa,SAAA"}
|
|
@@ -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":";;;;;;;;;;;AA4FA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;;cAIJ,mBAAA,EAAqB,OAAA;;;;KAiCtB,cAAA,MAAoB,CAAA;EAC9B,KAAA;EACA,GAAA;AAAA,IAEE,KAAA;;cAIS,iBAAA,EAAmB,OAAA;;AAzChC;;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;;;;KAsFlB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAGI,QAAA,EAAU,oBAAA;EACV,GAAA,GAAM,UAAA,GAAa,cAAA,uBAAqC,KAAA;AAAA;;cAMnD,oBAAA,EAAsB,OAAA;AAAA,KAyGvB,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;;;;KA6BjB,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;;;;UAmER,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;;;;;cAM5C,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.6.
|
|
3
|
+
"version": "8.6.4",
|
|
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.6.
|
|
104
|
-
"@intlayer/chokidar": "8.6.
|
|
105
|
-
"@intlayer/config": "8.6.
|
|
106
|
-
"@intlayer/core": "8.6.
|
|
107
|
-
"@intlayer/editor": "8.6.
|
|
108
|
-
"@intlayer/types": "8.6.
|
|
103
|
+
"@intlayer/api": "8.6.4",
|
|
104
|
+
"@intlayer/chokidar": "8.6.4",
|
|
105
|
+
"@intlayer/config": "8.6.4",
|
|
106
|
+
"@intlayer/core": "8.6.4",
|
|
107
|
+
"@intlayer/editor": "8.6.4",
|
|
108
|
+
"@intlayer/types": "8.6.4"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/node": "25.5.0",
|