react-intlayer 8.6.3 → 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 (53) 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/plugins.cjs +17 -8
  14. package/dist/cjs/plugins.cjs.map +1 -1
  15. package/dist/cjs/server/IntlayerServerProvider.cjs +1 -2
  16. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  17. package/dist/cjs/server/format/useIntl.cjs +1 -2
  18. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  19. package/dist/cjs/server/useDictionaryAsync.cjs +1 -2
  20. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  21. package/dist/cjs/server/useDictionaryDynamic.cjs +1 -2
  22. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  23. package/dist/cjs/server/useLocale.cjs +1 -2
  24. package/dist/cjs/server/useLocale.cjs.map +1 -1
  25. package/dist/esm/client/IntlayerProvider.mjs +6 -3
  26. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  27. package/dist/esm/client/useDictionaryAsync.mjs +2 -2
  28. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  29. package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
  30. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  31. package/dist/esm/client/useLocale.mjs +2 -2
  32. package/dist/esm/client/useLocale.mjs.map +1 -1
  33. package/dist/esm/client/useLocaleBase.mjs +2 -2
  34. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  35. package/dist/esm/client/useRewriteURL.mjs +2 -2
  36. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  37. package/dist/esm/plugins.mjs +18 -8
  38. package/dist/esm/plugins.mjs.map +1 -1
  39. package/dist/esm/server/IntlayerServerProvider.mjs +2 -2
  40. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  41. package/dist/esm/server/format/useIntl.mjs +2 -2
  42. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  43. package/dist/esm/server/useDictionaryAsync.mjs +2 -2
  44. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  45. package/dist/esm/server/useDictionaryDynamic.mjs +2 -2
  46. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  47. package/dist/esm/server/useLocale.mjs +2 -2
  48. package/dist/esm/server/useLocale.mjs.map +1 -1
  49. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  50. package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
  51. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  52. package/dist/types/plugins.d.ts.map +1 -1
  53. package/package.json +9 -9
@@ -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"}
@@ -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";
@@ -42,7 +42,7 @@ const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE ? fallbackPlugin : {
42
42
  transform: (_node, { plugins, ...rest }) => renderIntlayerNode({
43
43
  ...rest,
44
44
  value: rest.children,
45
- children: !TREE_SHAKE_EDITOR && configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
45
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
46
46
  ...rest,
47
47
  children: rest.children
48
48
  }) : rest.children
@@ -55,7 +55,7 @@ const reactNodePlugins = TREE_SHAKE_REACT_NODE ? fallbackPlugin : {
55
55
  transform: (node, { plugins, ...rest }) => renderIntlayerNode({
56
56
  ...rest,
57
57
  value: "[[react-element]]",
58
- children: !TREE_SHAKE_EDITOR && configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
58
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
59
59
  ...rest,
60
60
  children: renderReactElement(node)
61
61
  }) : renderReactElement(node)
@@ -123,7 +123,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
123
123
  transform: (metadataNode, props) => renderIntlayerNode({
124
124
  ...props,
125
125
  value: metadataNode,
126
- children: !TREE_SHAKE_EDITOR && configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
126
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
127
127
  ...rest,
128
128
  children: node
129
129
  }) : node
@@ -135,7 +135,7 @@ const markdownStringPlugin = TREE_SHAKE_MARKDOWN ? fallbackPlugin : {
135
135
  const render = (components) => renderIntlayerNode({
136
136
  ...props,
137
137
  value: node,
138
- children: !TREE_SHAKE_EDITOR && configuration.editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
138
+ children: !TREE_SHAKE_EDITOR && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
139
139
  ...rest,
140
140
  children: /* @__PURE__ */ jsx(Suspense, {
141
141
  fallback: node,
@@ -188,7 +188,17 @@ const htmlPlugin = TREE_SHAKE_HTML ? fallbackPlugin : {
188
188
  const render = (userComponents) => renderIntlayerNode({
189
189
  ...rest,
190
190
  value: html,
191
- 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, {
192
202
  fallback: html,
193
203
  children: /* @__PURE__ */ jsx(LazyHTMLRendererPlugin, {
194
204
  ...rest,
@@ -210,10 +220,10 @@ const htmlPlugin = TREE_SHAKE_HTML ? fallbackPlugin : {
210
220
  * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
211
221
  */
212
222
  const getPlugins = (locale, fallback = true) => [
213
- translationPlugin(locale ?? configuration.internationalization.defaultLocale, fallback ? configuration.internationalization.defaultLocale : void 0),
223
+ translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
214
224
  enumerationPlugin,
215
225
  conditionPlugin,
216
- nestedPlugin(locale ?? configuration.internationalization.defaultLocale),
226
+ nestedPlugin(locale ?? internationalization.defaultLocale),
217
227
  filePlugin,
218
228
  genderPlugin,
219
229
  intlayerNodePlugins,
@@ -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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\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 react node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_REACT_NODE =\n process.env['INTLAYER_NODE_TYPE_REACT_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// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n !TREE_SHAKE_EDITOR && configuration.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = TREE_SHAKE_REACT_NODE\n ? fallbackPlugin\n : {\n id: 'react-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: '[[react-element]]',\n children:\n !TREE_SHAKE_EDITOR && configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n {renderReactElement(node)}\n </ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\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', {}>) => ReactNode;\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 && configuration.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\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?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n !TREE_SHAKE_EDITOR && 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 unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\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\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 // Env var allows the bundler to to remove the plugin if not used to make the bundle smaller\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 reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;;;AA+CA,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,UAAU;AAEhC,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL;;AA4BL,MAAa,aAAsB,kBAC/B,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAE3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAK,UAAU;EAC5B,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,mBACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,UACE,oBAAC,UAAD;IAAU,UAAU;cAClB,oBAAC,wBAAD;KACE,GAAI;KACE;KACU;KAChB;IACO;GAEd,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MAEX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;;;;;AAuCL,MAAa,cACX,QACA,WAAoB,SAEpB;CAEE,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 splitInsertionTemplate,\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 {\n createElement,\n Fragment,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\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 react node type is explicitly disabled at build time.\n */\nconst TREE_SHAKE_REACT_NODE =\n process.env['INTLAYER_NODE_TYPE_REACT_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// React.lazy for heavy renderer components — creates separate code-split chunks\n// and properly suspends until the module is loaded\nconst LazyMarkdownRendererPlugin = lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n);\n\nconst LazyHTMLRendererPlugin = lazy(() =>\n import('./html/HTMLRendererPlugin').then((m) => ({\n default: m.HTMLRendererPlugin,\n }))\n);\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = TREE_SHAKE_INTLAYER_NODE\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\n ),\n }),\n };\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = TREE_SHAKE_REACT_NODE\n ? fallbackPlugin\n : {\n id: 'react-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: '[[react-element]]',\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n {renderReactElement(node)}\n </ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. 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 | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\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', {}>) => ReactNode;\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}>{node}</ContentSelector>\n ) : (\n node\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?: HTMLComponents) =>\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 unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\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\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n !TREE_SHAKE_EDITOR && editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={html}>\n <LazyHTMLRendererPlugin\n {...rest}\n html={html}\n userComponents={userComponents}\n />\n </Suspense>\n ),\n });\n\n const element = render() as unknown as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-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 reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: 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 React 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 // Env var allows the bundler to to remove the plugin if not used to make the bundle smaller\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;;;AA+CA,MAAM,2BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,wBACJ,QAAQ,IAAI,qCAAqC;;;;AAKnD,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;AAIrE,MAAM,6BAA6B,WACjC,OAAO,yCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,MAAM,yBAAyB,WAC7B,OAAO,iCAA6B,MAAM,OAAO,EAC/C,SAAS,EAAE,oBACZ,EAAE,CACJ;;AAWD,MAAa,sBAA+B,2BACxC,iBACA;CACE,IAAI;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AI;MACE;MACU;MAChB;KACO;IACK,IAElB,oBAAC,UAAD;IAAU,UAAU;cAClB,oBAAC,wBAAD;KACE,GAAI;KACE;KACU;KAChB;IACO;GAEhB,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MAEX,SAAQ,mBACN,OAAO,eAAe;AAG1B,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;;;;;AAuCL,MAAa,cACX,QACA,WAAoB,SAEpB;CAEE,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;CACD;CACA;CACA,aAAa,UAAU,qBAAqB,cAAc;CAE1D;CACA;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
@@ -1,9 +1,9 @@
1
1
  import { createServerContext, getServerContext } from "./serverContext.mjs";
2
- import configuration from "@intlayer/config/built";
2
+ import { internationalization } from "@intlayer/config/built";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/server/IntlayerServerProvider.tsx
6
- const { defaultLocale } = configuration?.internationalization ?? {};
6
+ const { defaultLocale } = internationalization ?? {};
7
7
  /**
8
8
  * Context that store the current locale on the server side
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AAMA,MAAM,EAAE,kBAAkB,eAAe,wBAAwB,EAAE;;;;AAKnE,MAAa,wBACX,oBAAmC,cAAc;;;;AAKnD,MAAa,oBAAoB,iBAAiB,sBAAsB;;;;AAKxE,MAAa,SAAS,iBAAiB,sBAAsB;;;;AAS7D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,oBAAC,sBAAsB,UAAvB;CAAgC,OAAO;CACpC;CAC8B"}
1
+ {"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AAMA,MAAM,EAAE,kBAAkB,wBAAwB,EAAE;;;;AAKpD,MAAa,wBACX,oBAAmC,cAAc;;;;AAKnD,MAAa,oBAAoB,iBAAiB,sBAAsB;;;;AAKxE,MAAa,SAAS,iBAAiB,sBAAsB;;;;AAS7D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,oBAAC,sBAAsB,UAAvB;CAAgC,OAAO;CACpC;CAC8B"}
@@ -1,6 +1,6 @@
1
1
  import { getServerContext } from "../serverContext.mjs";
2
2
  import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import configuration from "@intlayer/config/built";
3
+ import { internationalization } from "@intlayer/config/built";
4
4
  import { bindIntl } from "@intlayer/core/formatters";
5
5
 
6
6
  //#region src/server/format/useIntl.ts
@@ -34,7 +34,7 @@ import { bindIntl } from "@intlayer/core/formatters";
34
34
  */
35
35
  const useIntl = (locale) => {
36
36
  const currentLocale = getServerContext(IntlayerServerContext);
37
- return bindIntl(locale ?? currentLocale ?? configuration?.internationalization?.defaultLocale);
37
+ return bindIntl(locale ?? currentLocale ?? internationalization?.defaultLocale);
38
38
  };
39
39
 
40
40
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,WAAW,WAAwC;CAC9D,MAAM,gBAAgB,iBAAgC,sBAAsB;AAE5E,QAAO,SACL,UACE,iBACA,eAAe,sBAAsB,cACxC"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ?? currentLocale ?? internationalization?.defaultLocale\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,WAAW,WAAwC;CAC9D,MAAM,gBAAgB,iBAAgC,sBAAsB;AAE5E,QAAO,SACL,UAAU,iBAAiB,sBAAsB,cAClD"}
@@ -1,7 +1,7 @@
1
1
  import { getServerContext } from "./serverContext.mjs";
2
2
  import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
3
  import { useDictionary } from "./useDictionary.mjs";
4
- import configuration from "@intlayer/config/built";
4
+ import { internationalization } from "@intlayer/config/built";
5
5
 
6
6
  //#region src/server/useDictionaryAsync.ts
7
7
  /**
@@ -10,7 +10,7 @@ import configuration from "@intlayer/config/built";
10
10
  * If the locale is not provided, it will use the locale from the server context
11
11
  */
12
12
  const useDictionaryAsync = async (dictionaryPromise, locale, fallbackLocale) => {
13
- const localeTarget = locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? configuration?.internationalization.defaultLocale;
13
+ const localeTarget = locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
14
14
  return useDictionary(await dictionaryPromise[localeTarget]?.(), localeTarget);
15
15
  };
16
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"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,UACA,iBAAgC,sBAAsB,IACtD,kBACA,eAAe,qBAAqB;AAItC,QAAO,cAFY,MAAO,kBAA0B,iBAAiB,EAE9B,aAAkB"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"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,UACA,iBAAgC,sBAAsB,IACtD,kBACA,qBAAqB;AAIvB,QAAO,cAFY,MAAO,kBAA0B,iBAAiB,EAE9B,aAAkB"}
@@ -2,7 +2,7 @@ import { getServerContext } from "./serverContext.mjs";
2
2
  import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
3
  import { useDictionary } from "./useDictionary.mjs";
4
4
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
5
- import configuration from "@intlayer/config/built";
5
+ import { internationalization } from "@intlayer/config/built";
6
6
 
7
7
  //#region src/server/useDictionaryDynamic.ts
8
8
  /**
@@ -11,7 +11,7 @@ import configuration from "@intlayer/config/built";
11
11
  * If the locale is not provided, it will use the locale from the server context
12
12
  */
13
13
  const useDictionaryDynamic = (dictionaryPromise, key, locale, fallbackLocale) => {
14
- const localeTarget = locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? configuration?.internationalization.defaultLocale;
14
+ const localeTarget = locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
15
15
  return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
16
16
  };
17
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"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,UACA,iBAAgC,sBAAsB,IACtD,kBACA,eAAe,qBAAqB;AAOtC,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEsC,aAAkB"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"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,UACA,iBAAgC,sBAAsB,IACtD,kBACA,qBAAqB;AAOvB,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEsC,aAAkB"}
@@ -1,6 +1,6 @@
1
1
  import { getServerContext } from "./serverContext.mjs";
2
2
  import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
- import configuration from "@intlayer/config/built";
3
+ import { internationalization } from "@intlayer/config/built";
4
4
 
5
5
  //#region src/server/useLocale.ts
6
6
  /**
@@ -9,7 +9,7 @@ import configuration from "@intlayer/config/built";
9
9
  * If the locale is not provided, it will use the locale from the server context
10
10
  */
11
11
  const useLocale = () => {
12
- const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
12
+ const { defaultLocale, locales: availableLocales } = internationalization ?? {};
13
13
  return {
14
14
  locale: getServerContext(IntlayerServerContext) ?? defaultLocale,
15
15
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"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,qBAC9B,eAAe,wBAAwB,EAAE;AAK3C,QAAO;EAAE,QAHO,iBAAiB,sBAAsB,IACrD;EAEe;EAAe;EAAkB"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"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,qBAC9B,wBAAwB,EAAE;AAK5B,QAAO;EAAE,QAHO,iBAAiB,sBAAsB,IACrD;EAEe;EAAe;EAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;;KAgBK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAA;EACvB,aAAA;EACA,eAAA;AAAA;;;;cAMW,qBAAA,EAAqB,OAAA,CAAA,OAAA,CAAA,aAAA;;;;;;cAWrB,kBAAA;AAXb;;;AAAA,KAgBY,qBAAA,GAAwB,iBAAA;EAhBF;AAWlC;;EASE,MAAA,GAAS,aAAA;EAToE;;AAK/E;EAQE,aAAA,GAAgB,aAAA;;;;EAIhB,SAAA,IAAa,MAAA,EAAQ,aAAA;EAZa;;;EAgBlC,aAAA;EAZA;;;EAgBA,eAAA;AAAA;;;;;;;AAWF;;cAAa,uBAAA,EAAyB,EAAA,CAAG,qBAAA;;;AA2EzC;;;;;;;;;;;;;;;;;;cAAa,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
1
+ {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;;KAiBK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAA;EACvB,aAAA;EACA,eAAA;AAAA;;;;cAMW,qBAAA,EAAqB,OAAA,CAAA,OAAA,CAAA,aAAA;;;;;;cAWrB,kBAAA;AAXb;;;AAAA,KAgBY,qBAAA,GAAwB,iBAAA;EAhBF;AAWlC;;EASE,MAAA,GAAS,aAAA;EAToE;;AAK/E;EAQE,aAAA,GAAgB,aAAA;;;;EAIhB,SAAA,IAAa,MAAA,EAAQ,aAAA;EAZa;;;EAgBlC,aAAA;EAZA;;;EAgBA,eAAA;AAAA;;;;;;;AAWF;;cAAa,uBAAA,EAAyB,EAAA,CAAG,qBAAA;;;AA8EzC;;;;;;;;;;;;;;;;;;cAAa,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
@@ -9,7 +9,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
9
9
  *
10
10
  * If the locale is not provided, it will use the locale from the client context
11
11
  */
12
- declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, "tr" | "th" | "hr" | "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "id" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ms" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi" | "mi-NZ" | "mr" | "mr-IN" | "mn" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA" | (string & {})>;
12
+ declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "id" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ms" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi" | "mi-NZ" | "mr" | "mr-IN" | "mn" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA" | (string & {})>;
13
13
  //#endregion
14
14
  export { useDictionaryDynamic };
15
15
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;;;cAYa,aAAA;UASZ,UAAA,CAAA,aAAA"}
1
+ {"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;;;cAWa,aAAA;UASZ,UAAA,CAAA,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;;;;AAgGA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;;cAIJ,mBAAA,EAAqB,OAAA;;;;KA+BtB,aAAA,MAAmB,CAAA;EAC7B,KAAA;EACA,GAAA;AAAA,IAEE,SAAA;;cAIS,gBAAA,EAAkB,OAAA;;AAvC/B;;KAyEY,aAAA,MAAmB,CAAA;EAC7B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,SAAA;EACX,MAAA;AAAA,uBAEqB,CAAA,qBAAsB,SAAA,IACvC,MAAA,EAAQ,CAAA,KACL,CAAA,OAAQ,CAAA,4BACT,YAAA,WACA,YAAA,CAAa,SAAA;;cA4BR,eAAA,EAAiB,OAAA;;;;KAsFlB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAGI,QAAA,EAAU,oBAAA;EACV,GAAA,GAAM,UAAA,EAAY,cAAA,uBAAqC,SAAA;AAAA;;cAMlD,oBAAA,EAAsB,OAAA;AAAA,KAyFvB,YAAA,MAAkB,CAAA;EAC5B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,QAAA;EACX,IAAA;EACA,QAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,SAAA;EACvD,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAK1B,cAAA,EAAgB,OAAA;;;;;;;;;;;;KAqCjB,cAAA,MAAoB,CAAA;EAC9B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IAAA;AAAA,IAEE,YAAA,CACE,CAAA;EAEE,GAAA,GAAM,UAAA,GA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