react-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.
Files changed (66) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +6 -4
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/client/useDictionaryAsync.cjs +1 -2
  4. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -2
  6. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  7. package/dist/cjs/client/useLocale.cjs +1 -2
  8. package/dist/cjs/client/useLocale.cjs.map +1 -1
  9. package/dist/cjs/client/useLocaleBase.cjs +1 -2
  10. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  11. package/dist/cjs/client/useRewriteURL.cjs +1 -2
  12. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  13. package/dist/cjs/editor/ContentSelector.cjs +6 -2
  14. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  15. package/dist/cjs/editor/useEditor.cjs +2 -1
  16. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  17. package/dist/cjs/plugins.cjs +47 -14
  18. package/dist/cjs/plugins.cjs.map +1 -1
  19. package/dist/cjs/server/IntlayerServerProvider.cjs +1 -2
  20. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  21. package/dist/cjs/server/format/useIntl.cjs +1 -2
  22. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  23. package/dist/cjs/server/useDictionaryAsync.cjs +1 -2
  24. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  25. package/dist/cjs/server/useDictionaryDynamic.cjs +1 -2
  26. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  27. package/dist/cjs/server/useLocale.cjs +1 -2
  28. package/dist/cjs/server/useLocale.cjs.map +1 -1
  29. package/dist/esm/client/IntlayerProvider.mjs +6 -3
  30. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  31. package/dist/esm/client/useDictionaryAsync.mjs +2 -2
  32. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  33. package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
  34. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  35. package/dist/esm/client/useLocale.mjs +2 -2
  36. package/dist/esm/client/useLocale.mjs.map +1 -1
  37. package/dist/esm/client/useLocaleBase.mjs +2 -2
  38. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  39. package/dist/esm/client/useRewriteURL.mjs +2 -2
  40. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  41. package/dist/esm/editor/ContentSelector.mjs +6 -2
  42. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  43. package/dist/esm/editor/useEditor.mjs +2 -1
  44. package/dist/esm/editor/useEditor.mjs.map +1 -1
  45. package/dist/esm/plugins.mjs +48 -14
  46. package/dist/esm/plugins.mjs.map +1 -1
  47. package/dist/esm/server/IntlayerServerProvider.mjs +2 -2
  48. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  49. package/dist/esm/server/format/useIntl.mjs +2 -2
  50. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  51. package/dist/esm/server/useDictionaryAsync.mjs +2 -2
  52. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  53. package/dist/esm/server/useDictionaryDynamic.mjs +2 -2
  54. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  55. package/dist/esm/server/useLocale.mjs +2 -2
  56. package/dist/esm/server/useLocale.mjs.map +1 -1
  57. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  58. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  59. package/dist/types/editor/ContentSelector.d.ts.map +1 -1
  60. package/dist/types/editor/useEditor.d.ts.map +1 -1
  61. package/dist/types/index.d.ts +1 -1
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/dist/types/markdown/MarkdownRenderer.d.ts +1 -1
  64. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  65. package/dist/types/plugins.d.ts.map +1 -1
  66. package/package.json +9 -9
@@ -4,7 +4,6 @@ const require_server_serverContext = require('./serverContext.cjs');
4
4
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
5
  const require_server_useDictionary = require('./useDictionary.cjs');
6
6
  let _intlayer_config_built = require("@intlayer/config/built");
7
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
8
7
 
9
8
  //#region src/server/useDictionaryAsync.ts
10
9
  /**
@@ -13,7 +12,7 @@ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
13
12
  * If the locale is not provided, it will use the locale from the server context
14
13
  */
15
14
  const useDictionaryAsync = async (dictionaryPromise, locale, fallbackLocale) => {
16
- const localeTarget = locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale;
15
+ const localeTarget = locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
17
16
  return require_server_useDictionary.useDictionary(await dictionaryPromise[localeTarget]?.(), localeTarget);
18
17
  };
19
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\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 server context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,gCAAe,qBAAqB;AAItC,QAAOC,2CAFY,MAAO,kBAA0B,iBAAiB,EAE9B,aAAkB"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","internationalization","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\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 server context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAIvB,QAAOC,2CAFY,MAAO,kBAA0B,iBAAiB,EAE9B,aAAkB"}
@@ -5,7 +5,6 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
5
5
  const require_server_useDictionary = require('./useDictionary.cjs');
6
6
  const require_server_useLoadDynamic = require('./useLoadDynamic.cjs');
7
7
  let _intlayer_config_built = require("@intlayer/config/built");
8
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
9
8
 
10
9
  //#region src/server/useDictionaryDynamic.ts
11
10
  /**
@@ -14,7 +13,7 @@ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
14
13
  * If the locale is not provided, it will use the locale from the server context
15
14
  */
16
15
  const useDictionaryDynamic = (dictionaryPromise, key, locale, fallbackLocale) => {
17
- const localeTarget = locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale;
16
+ const localeTarget = locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
18
17
  return require_server_useDictionary.useDictionary(require_server_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
19
18
  };
20
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 server context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAa,wBAIX,mBACA,KACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,gCAAe,qBAAqB;AAOtC,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEsC,aAAkB"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","internationalization","useDictionary","useLoadDynamic"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 server context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,wBAIX,mBACA,KACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAOvB,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEsC,aAAkB"}
@@ -3,7 +3,6 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_server_serverContext = require('./serverContext.cjs');
4
4
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
5
  let _intlayer_config_built = require("@intlayer/config/built");
6
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
6
 
8
7
  //#region src/server/useLocale.ts
9
8
  /**
@@ -12,7 +11,7 @@ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
12
11
  * If the locale is not provided, it will use the locale from the server context
13
12
  */
14
13
  const useLocale = () => {
15
- const { defaultLocale, locales: availableLocales } = _intlayer_config_built.default?.internationalization ?? {};
14
+ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
16
15
  return {
17
16
  locale: require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? defaultLocale,
18
17
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["configuration","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,gCAAe,wBAAwB,EAAE;AAK3C,QAAO;EAAE,QAHOC,8CAAiBC,4DAAsB,IACrD;EAEe;EAAe;EAAkB"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;AAK5B,QAAO;EAAE,QAHOC,8CAAiBC,4DAAsB,IACrD;EAEe;EAAe;EAAkB"}
@@ -2,9 +2,10 @@
2
2
 
3
3
  import { EditorProvider } from "../editor/EditorProvider.mjs";
4
4
  import { localeInStorage, setLocaleInStorage } from "./useLocaleStorage.mjs";
5
- import configuration from "@intlayer/config/built";
5
+ import { internationalization } from "@intlayer/config/built";
6
6
  import { createContext, useContext, useEffect, useState } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { setIntlayerIdentifier } from "@intlayer/config/client";
8
9
  import { localeResolver } from "@intlayer/core/localization";
9
10
 
10
11
  //#region src/client/IntlayerProvider.tsx
@@ -12,7 +13,7 @@ import { localeResolver } from "@intlayer/core/localization";
12
13
  * Context that stores the current locale on the client side.
13
14
  */
14
15
  const IntlayerClientContext = createContext({
15
- locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,
16
+ locale: localeInStorage ?? internationalization?.defaultLocale,
16
17
  setLocale: () => null,
17
18
  isCookieEnabled: true
18
19
  });
@@ -31,12 +32,14 @@ const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};
31
32
  * @returns The provider component.
32
33
  */
33
34
  const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
34
- const { internationalization } = configuration ?? {};
35
35
  const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = internationalization ?? {};
36
36
  const [currentLocale, setCurrentLocale] = useState(localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
37
37
  useEffect(() => {
38
38
  if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
39
39
  }, [localeProp]);
40
+ useEffect(() => {
41
+ setIntlayerIdentifier();
42
+ }, []);
40
43
  const setLocaleBase = (newLocale) => {
41
44
  if (currentLocale.toString() === newLocale.toString()) return;
42
45
  if (!availableLocales?.map(String).includes(newLocale)) {
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\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);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,eAAe,sBAAsB;CAChE,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,2BAA2B,WAAW,sBAAsB,IAAI,EAAE;;;;;;;;;AAoC/E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyB,iBAAiB,EAAE;CACpD,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,oBAGhB;AAGxC,iBAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;CAEhB,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,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,cAAc;AAEpD,QACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,EAAkB,GACjB,SACuB"}
1
+ {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { 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 createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\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);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,2BAA2B,WAAW,sBAAsB,IAAI,EAAE;;;;;;;;;AAoC/E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,oBAGhB;AAGxC,iBAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;AAEhB,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,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,cAAc;AAEpD,QACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,EAAkB,GACjB,SACuB"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
4
  import { useDictionary } from "./useDictionary.mjs";
5
- import configuration from "@intlayer/config/built";
5
+ import { internationalization } from "@intlayer/config/built";
6
6
  import { useContext, useMemo } from "react";
7
7
 
8
8
  //#region src/client/useDictionaryAsync.ts
@@ -13,7 +13,7 @@ import { useContext, useMemo } from "react";
13
13
  */
14
14
  const useDictionaryAsync = async (dictionaryPromise, locale) => {
15
15
  const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
16
- const localeTarget = useMemo(() => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale, [currentLocale, locale]);
16
+ const localeTarget = useMemo(() => locale ?? currentLocale ?? internationalization.defaultLocale, [currentLocale, locale]);
17
17
  return useDictionary(await useMemo(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
18
18
  };
19
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\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 <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.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<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,qBAAqB,OAIhC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cARY,MAAM,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEsC,aAAkB"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\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 <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\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<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,qBAAqB,OAIhC,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,EAEsC,aAAkB"}
@@ -3,7 +3,7 @@
3
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
4
  import { useDictionary } from "./useDictionary.mjs";
5
5
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
6
- import configuration from "@intlayer/config/built";
6
+ import { internationalization } from "@intlayer/config/built";
7
7
  import { useContext, useMemo } from "react";
8
8
 
9
9
  //#region src/client/useDictionaryDynamic.ts
@@ -14,7 +14,7 @@ import { useContext, useMemo } from "react";
14
14
  */
15
15
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
16
16
  const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
17
- const localeTarget = useMemo(() => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale, [currentLocale, locale]);
17
+ const localeTarget = useMemo(() => locale ?? currentLocale ?? internationalization.defaultLocale, [currentLocale, locale]);
18
18
  return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
19
19
  };
20
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { setLocaleInStorage } from "./useLocaleStorage.mjs";
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
- import configuration from "@intlayer/config/built";
5
+ import { internationalization } from "@intlayer/config/built";
6
6
  import { useCallback, useContext } from "react";
7
7
 
8
8
  //#region src/client/useLocale.ts
@@ -30,7 +30,7 @@ import { useCallback, useContext } from "react";
30
30
  * ```
31
31
  */
32
32
  const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
33
- const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
33
+ const { defaultLocale, locales: availableLocales } = internationalization ?? {};
34
34
  const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = useContext(IntlayerClientContext) ?? {};
35
35
  return {
36
36
  locale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: LocalesValues;\n defaultLocale: LocalesValues;\n availableLocales: LocalesValues[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Client-side 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 'react-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 = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = useCallback(\n (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 setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [availableLocales, onLocaleChange, setLocaleState, isCookieEnabled]\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,eAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;AAmB3C,QAAO;EACL;EACA;EACA;EACA,WArBgB,aACf,WAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,YAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,kBAAe,OAAO;AACtB,sBACE,QACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiB,OAA0B;KAE7C;GAAC;GAAkB;GAAgB;GAAgB;GAAgB,CACpE;EAOA"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: LocalesValues;\n defaultLocale: LocalesValues;\n availableLocales: LocalesValues[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Client-side 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 'react-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 = {}): UseLocaleResult => {\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 = useCallback(\n (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 setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [availableLocales, onLocaleChange, setLocaleState, isCookieEnabled]\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;AAmB3C,QAAO;EACL;EACA;EACA;EACA,WArBgB,aACf,WAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,YAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,kBAAe,OAAO;AACtB,sBACE,QACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiB,OAA0B;KAE7C;GAAC;GAAkB;GAAgB;GAAgB;GAAgB,CACpE;EAOA"}
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
- import configuration from "@intlayer/config/built";
4
+ import { internationalization } from "@intlayer/config/built";
5
5
  import { useContext } from "react";
6
6
 
7
7
  //#region src/client/useLocaleBase.ts
8
- const { defaultLocale, locales: availableLocales } = configuration.internationalization;
8
+ const { defaultLocale, locales: availableLocales } = internationalization;
9
9
  /**
10
10
  * On the client side, hook to get the current locale and all related fields
11
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.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":";;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAC9B,cAAc;;;;AAKhB,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,sBAAsB,IAAI,EAAE;AAErE,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'react';\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":";;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAAqB;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,sBAAsB,IAAI,EAAE;AAErE,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { useLocale } from "./useLocale.mjs";
4
- import configuration from "@intlayer/config/built";
4
+ import { routing } from "@intlayer/config/built";
5
5
  import { useEffect } from "react";
6
6
  import { getRewritePath } from "@intlayer/core/localization";
7
7
 
@@ -26,7 +26,7 @@ import { getRewritePath } from "@intlayer/core/localization";
26
26
  */
27
27
  const useRewriteURL = () => {
28
28
  const { locale } = useLocale();
29
- const rewrite = configuration?.routing?.rewrite;
29
+ const rewrite = routing?.rewrite;
30
30
  useEffect(() => {
31
31
  if (typeof window === "undefined" || !rewrite) return;
32
32
  const pathname = window.location.pathname;
@@ -1 +1 @@
1
- {"version":3,"file":"useRewriteURL.mjs","names":[],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = configuration?.routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale as Locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,sBAA4B;CACvC,MAAM,EAAE,WAAW,WAAW;CAC9B,MAAM,UAAU,eAAe,SAAS;AAExC,iBAAgB;AACd,MAAI,OAAO,WAAW,eAAe,CAAC,QAAS;EAE/C,MAAM,WAAW,OAAO,SAAS;EACjC,MAAM,aAAa,eAAe,UAAU,QAAkB,QAAQ;AAEtE,MAAI,cAAc,eAAe,SAC/B,QAAO,QAAQ,aACb,OAAO,QAAQ,OACf,IACA,aAAa,OAAO,SAAS,SAAS,OAAO,SAAS,KACvD;IAEF,CAAC,QAAQ,QAAQ,CAAC"}
1
+ {"version":3,"file":"useRewriteURL.mjs","names":[],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["'use client';\n\nimport { routing } from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useEffect } from 'react';\nimport { useLocale } from './useLocale';\n\n/**\n * Client-side hook to manage URL rewrites without triggering a router navigation.\n * It uses `window.history.replaceState` to update the URL in the address bar.\n *\n * This hook is useful to \"prettify\" the URL when the user lands on a canonical path\n * that has a localized alias defined in `intlayer.config.ts`.\n *\n * @example\n * ```tsx\n * import { useRewriteURL } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * useRewriteURL();\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport const useRewriteURL = (): void => {\n const { locale } = useLocale();\n const rewrite = routing?.rewrite;\n\n useEffect(() => {\n if (typeof window === 'undefined' || !rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(pathname, locale as Locale, rewrite);\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n }, [locale, rewrite]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,sBAA4B;CACvC,MAAM,EAAE,WAAW,WAAW;CAC9B,MAAM,UAAU,SAAS;AAEzB,iBAAgB;AACd,MAAI,OAAO,WAAW,eAAe,CAAC,QAAS;EAE/C,MAAM,WAAW,OAAO,SAAS;EACjC,MAAM,aAAa,eAAe,UAAU,QAAkB,QAAQ;AAEtE,MAAI,cAAc,eAAe,SAC/B,QAAO,QAAQ,aACb,OAAO,QAAQ,OACf,IACA,aAAa,OAAO,SAAS,SAAS,OAAO,SAAS,KACvD;IAEF,CAAC,QAAQ,QAAQ,CAAC"}
@@ -4,12 +4,16 @@ import { createElement } from "react";
4
4
  import { isEnabled } from "@intlayer/editor/isEnabled";
5
5
 
6
6
  //#region src/editor/ContentSelector.tsx
7
+ /**
8
+ * True when the editor is explicitly disabled at build time.
9
+ */
10
+ const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
7
11
  const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
8
- if (isEnabled) return createElement("intlayer-content-selector-wrapper", {
12
+ if (TREE_SHAKE_EDITOR || !isEnabled) return children;
13
+ return createElement("intlayer-content-selector-wrapper", {
9
14
  "key-path": JSON.stringify(keyPath),
10
15
  "dictionary-key": dictionaryKey
11
16
  }, children);
12
- return children;
13
17
  };
14
18
 
15
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport { createElement, type FC, type HTMLAttributes } from 'react';\n\nexport type ContentSelectorProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n if (isEnabled) {\n return createElement(\n 'intlayer-content-selector-wrapper',\n {\n 'key-path': JSON.stringify(keyPath),\n 'dictionary-key': dictionaryKey,\n },\n children\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;AASA,MAAa,mBAA6C,EACxD,UACA,eACA,cACI;AACJ,KAAI,UACF,QAAO,cACL,qCACA;EACE,YAAY,KAAK,UAAU,QAAQ;EACnC,kBAAkB;EACnB,EACD,SACD;AAGH,QAAO"}
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport { createElement, type FC, type HTMLAttributes } from 'react';\n\nexport type ContentSelectorProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\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 editor is explicitly disabled at build time.\n */\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n if (TREE_SHAKE_EDITOR || !isEnabled) {\n return children;\n }\n\n return createElement(\n 'intlayer-content-selector-wrapper',\n {\n 'key-path': JSON.stringify(keyPath),\n 'dictionary-key': dictionaryKey,\n },\n children\n );\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAM,oBAAoB,QAAQ,IAAI,+BAA+B;AAErE,MAAa,mBAA6C,EACxD,UACA,eACA,cACI;AACJ,KAAI,qBAAqB,CAAC,UACxB,QAAO;AAGT,QAAO,cACL,qCACA;EACE,YAAY,KAAK,UAAU,QAAQ;EACnC,kBAAkB;EACnB,EACD,SACD"}
@@ -5,6 +5,7 @@ import { useContext, useEffect, useRef } from "react";
5
5
  import { isEnabled } from "@intlayer/editor/isEnabled";
6
6
 
7
7
  //#region src/editor/useEditor.tsx
8
+ const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
8
9
  /**
9
10
  * Initializes 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 } = useContext(IntlayerClientContext) ?? {};
15
16
  const managerRef = useRef(null);
16
17
  useEffect(() => {
17
- if (!isEnabled) return;
18
+ if (TREE_SHAKE_EDITOR || !isEnabled) return;
18
19
  import("@intlayer/editor").then(({ initEditorClient }) => {
19
20
  const manager = initEditorClient();
20
21
  managerRef.current = manager;
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes 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":";;;;;;;;;;;;AAaA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAC1D,MAAM,aAAa,OAAkC,KAAK;AAE1D,iBAAgB;AACd,MAAI,CAAC,UAAW;AAEhB,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,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\nconst TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n/**\n * Initializes 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 (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;AAQA,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,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { ContentSelector } from "./editor/ContentSelector.mjs";
2
2
  import { renderIntlayerNode } from "./IntlayerNode.mjs";
3
3
  import { renderReactElement } from "./reactElement/renderReactElement.mjs";
4
- import configuration from "@intlayer/config/built";
4
+ import { editor, internationalization } from "@intlayer/config/built";
5
5
  import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, splitInsertionTemplate, translationPlugin } from "@intlayer/core/interpreter";
6
6
  import { getMarkdownMetadata } from "@intlayer/core/markdown";
7
7
  import * as NodeTypes from "@intlayer/types/nodeType";
@@ -9,29 +9,53 @@ import { Fragment, Suspense, createElement, lazy } from "react";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
 
11
11
  //#region src/plugins.tsx
12
+ /**
13
+ * True when the intlayer node type is explicitly disabled at build time.
14
+ */
15
+ const TREE_SHAKE_INTLAYER_NODE = process.env["INTLAYER_NODE_TYPE_INTLAYER_NODE"] === "false";
16
+ /**
17
+ * True when the react node type is explicitly disabled at build time.
18
+ */
19
+ const TREE_SHAKE_REACT_NODE = process.env["INTLAYER_NODE_TYPE_REACT_NODE"] === "false";
20
+ /**
21
+ * True when the markdown node type is explicitly disabled at build time.
22
+ */
23
+ const TREE_SHAKE_MARKDOWN = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false";
24
+ /**
25
+ * True when the HTML node type is explicitly disabled at build time.
26
+ */
27
+ const TREE_SHAKE_HTML = process.env["INTLAYER_NODE_TYPE_HTML"] === "false";
28
+ /**
29
+ * True when the insertion node type is explicitly disabled at build time.
30
+ */
31
+ const TREE_SHAKE_INSERTION = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false";
32
+ /**
33
+ * True when the editor is explicitly disabled at build time.
34
+ */
35
+ const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
12
36
  const LazyMarkdownRendererPlugin = lazy(() => import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({ default: m.MarkdownRendererPlugin })));
13
37
  const LazyHTMLRendererPlugin = lazy(() => import("./html/HTMLRendererPlugin.mjs").then((m) => ({ default: m.HTMLRendererPlugin })));
14
38
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
15
- const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? fallbackPlugin : {
39
+ const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE ? fallbackPlugin : {
16
40
  id: "intlayer-node-plugin",
17
41
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
18
42
  transform: (_node, { plugins, ...rest }) => renderIntlayerNode({
19
43
  ...rest,
20
44
  value: rest.children,
21
- children: configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
45
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
22
46
  ...rest,
23
47
  children: rest.children
24
48
  }) : rest.children
25
49
  })
26
50
  };
27
51
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
28
- const reactNodePlugins = process.env.INTLAYER_NODE_TYPE_REACT_NODE === "false" ? fallbackPlugin : {
52
+ const reactNodePlugins = TREE_SHAKE_REACT_NODE ? fallbackPlugin : {
29
53
  id: "react-node-plugin",
30
54
  canHandle: (node) => typeof node === "object" && typeof node?.props !== "undefined" && typeof node.key !== "undefined",
31
55
  transform: (node, { plugins, ...rest }) => renderIntlayerNode({
32
56
  ...rest,
33
57
  value: "[[react-element]]",
34
- children: configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
58
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
35
59
  ...rest,
36
60
  children: renderReactElement(node)
37
61
  }) : renderReactElement(node)
@@ -46,7 +70,7 @@ const splitAndJoinInsertion = (template, values) => {
46
70
  return createElement(Fragment, null, ...result.parts.map((part, index) => createElement(Fragment, { key: index }, part)));
47
71
  };
48
72
  /** Insertion plugin for React. Handles component/node insertion. */
49
- const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? fallbackPlugin : {
73
+ const insertionPlugin = TREE_SHAKE_INSERTION ? fallbackPlugin : {
50
74
  id: "insertion-plugin",
51
75
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
52
76
  transform: (node, props, deepTransformNode) => {
@@ -87,7 +111,7 @@ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? f
87
111
  }
88
112
  };
89
113
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
90
- const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
114
+ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
91
115
  id: "markdown-string-plugin",
92
116
  canHandle: (node) => typeof node === "string",
93
117
  transform: (node, props, deepTransformNode) => {
@@ -99,7 +123,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
99
123
  transform: (metadataNode, props) => renderIntlayerNode({
100
124
  ...props,
101
125
  value: metadataNode,
102
- children: configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
126
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
103
127
  ...rest,
104
128
  children: node
105
129
  }) : node
@@ -111,7 +135,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
111
135
  const render = (components) => renderIntlayerNode({
112
136
  ...props,
113
137
  value: node,
114
- children: configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
138
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
115
139
  ...rest,
116
140
  children: /* @__PURE__ */ jsx(Suspense, {
117
141
  fallback: node,
@@ -140,7 +164,7 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
140
164
  } });
141
165
  }
142
166
  };
143
- const markdownPlugin = {
167
+ const markdownPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
144
168
  id: "markdown-plugin",
145
169
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
146
170
  transform: (node, props, deepTransformNode) => {
@@ -155,7 +179,7 @@ const markdownPlugin = {
155
179
  }
156
180
  };
157
181
  /** HTML plugin. Replaces node with a function that takes components => ReactNode. */
158
- const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
182
+ const htmlPlugin = TREE_SHAKE_HTML ? fallbackPlugin : {
159
183
  id: "html-plugin",
160
184
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
161
185
  transform: (node, props) => {
@@ -164,7 +188,17 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
164
188
  const render = (userComponents) => renderIntlayerNode({
165
189
  ...rest,
166
190
  value: html,
167
- children: /* @__PURE__ */ jsx(Suspense, {
191
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
192
+ ...rest,
193
+ children: /* @__PURE__ */ jsx(Suspense, {
194
+ fallback: html,
195
+ children: /* @__PURE__ */ jsx(LazyHTMLRendererPlugin, {
196
+ ...rest,
197
+ html,
198
+ userComponents
199
+ })
200
+ })
201
+ }) : /* @__PURE__ */ jsx(Suspense, {
168
202
  fallback: html,
169
203
  children: /* @__PURE__ */ jsx(LazyHTMLRendererPlugin, {
170
204
  ...rest,
@@ -186,10 +220,10 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
186
220
  * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
187
221
  */
188
222
  const getPlugins = (locale, fallback = true) => [
189
- translationPlugin(locale ?? configuration.internationalization.defaultLocale, fallback ? configuration.internationalization.defaultLocale : void 0),
223
+ translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
190
224
  enumerationPlugin,
191
225
  conditionPlugin,
192
- nestedPlugin(locale ?? configuration.internationalization.defaultLocale),
226
+ nestedPlugin(locale ?? internationalization.defaultLocale),
193
227
  filePlugin,
194
228
  genderPlugin,
195
229
  intlayerNodePlugins,