react-intlayer 9.1.1 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +2 -1
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/client/useDictionary.cjs +11 -15
  4. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +7 -2
  6. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  7. package/dist/cjs/client/useIntlayer.cjs +12 -13
  8. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  9. package/dist/cjs/server/IntlayerServerProvider.cjs +13 -2
  10. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  11. package/dist/cjs/server/useDictionary.cjs +7 -4
  12. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  13. package/dist/cjs/server/useDictionaryDynamic.cjs +8 -2
  14. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  15. package/dist/cjs/server/useIntlayer.cjs +7 -4
  16. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  17. package/dist/esm/client/IntlayerProvider.mjs +2 -1
  18. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  19. package/dist/esm/client/useDictionary.mjs +12 -16
  20. package/dist/esm/client/useDictionary.mjs.map +1 -1
  21. package/dist/esm/client/useDictionaryDynamic.mjs +8 -3
  22. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  23. package/dist/esm/client/useIntlayer.mjs +13 -14
  24. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  25. package/dist/esm/server/IntlayerServerProvider.mjs +13 -3
  26. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  27. package/dist/esm/server/useDictionary.mjs +8 -5
  28. package/dist/esm/server/useDictionary.mjs.map +1 -1
  29. package/dist/esm/server/useDictionaryDynamic.mjs +10 -4
  30. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  31. package/dist/esm/server/useIntlayer.mjs +8 -5
  32. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  33. package/dist/types/client/IntlayerProvider.d.ts +25 -1
  34. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  35. package/dist/types/client/useDictionary.d.ts +2 -1
  36. package/dist/types/client/useDictionary.d.ts.map +1 -1
  37. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  38. package/dist/types/client/useIntlayer.d.ts +4 -0
  39. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  40. package/dist/types/server/IntlayerServerProvider.d.ts +31 -2
  41. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
  42. package/dist/types/server/useDictionary.d.ts.map +1 -1
  43. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  44. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  45. package/package.json +8 -8
@@ -33,7 +33,7 @@ const useIntlayerContext = () => (0, react.useContext)(IntlayerClientContext) ??
33
33
  * @param props - The provider props.
34
34
  * @returns The provider component.
35
35
  */
36
- const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
36
+ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, variant, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
37
37
  const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = _intlayer_config_built.internationalization ?? {};
38
38
  const [currentLocale, setCurrentLocale] = (0, react.useState)(localeProp ?? require_client_useLocaleStorage.localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
39
39
  (0, react.useEffect)(() => {
@@ -57,6 +57,7 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
57
57
  value: {
58
58
  locale: resolvedLocale,
59
59
  setLocale,
60
+ variant,
60
61
  disableEditor
61
62
  },
62
63
  children
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","internationalization","EditorProvider","AnalyticsProvider"],"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 { AnalyticsProvider } from '../analytics/AnalyticsProvider';\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 <AnalyticsProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAa,iDAAqD;CAChE,QAAQA,mDAAmBC,6CAAsB;CACjD,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,iDAAsC,qBAAqB,KAAK,CAAC;;;;;;;;;AAoC9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChDA,+CAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,wCAFpB,cAAcD,mDAAmB,qBAAqB,mBAGjB;CAGvC,2BAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG,CAAC,UAAU,CAAC;CAEf,2BAAgB;EACd,mDAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mDAAmB,WAAW,eAAe;CAC/C;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iEAAgC,aAAa;CAEnD,OACE,2CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B;EACE,2CAACE,8CAAD,CAAiB;EACjB,2CAACC,uDAAD,CAAoB;EACnB;CACsB"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","internationalization","EditorProvider","AnalyticsProvider"],"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 {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { AnalyticsProvider } from '../analytics/AnalyticsProvider';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n /**\n * Ambient variant applied to every dictionary read below the provider, the\n * same way `locale` is. Overridden per call by an explicit selector.\n */\n variant?: ProviderVariant;\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 * Ambient variant applied to every dictionary read below this provider — for\n * a dimension that is fixed for the whole session (tenant, school type, plan\n * tier…) and that therefore no component should have to pass by hand.\n *\n * Accepts three forms:\n * - `variant=\"school1\"` — one named variant for every key\n * - `variant={['school1', 'default']}` — an ordered preference chain: the\n * first variant the key actually declares wins\n * - `variant={{ key1: 'school1', key2: ['school1', 'default'], default: 'base' }}`\n * — per dictionary key, with `default` covering every key not listed\n *\n * A plain object is always read as the per-key map. To pin a structured\n * variant globally, nest it: `variant={{ default: { id: 'prod_abc' } }}`.\n *\n * A call-site selector always wins: `useIntlayer('key', { variant: 'x' })`\n * replaces this default rather than extending it.\n */\n variant?: ProviderVariant;\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 variant,\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 variant,\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 <AnalyticsProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAa,iDAAqD;CAChE,QAAQA,mDAAmBC,6CAAsB;CACjD,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,iDAAsC,qBAAqB,KAAK,CAAC;;;;;;;;;AAuD9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,SACA,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChDA,+CAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,wCAFpB,cAAcD,mDAAmB,qBAAqB,mBAGjB;CAGvC,2BAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG,CAAC,UAAU,CAAC;CAEf,2BAAgB;EACd,mDAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mDAAmB,WAAW,eAAe;CAC/C;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iEAAgC,aAAa;CAEnD,OACE,2CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B;EACE,2CAACE,8CAAD,CAAiB;EACjB,2CAACC,uDAAD,CAAoB;EACnB;CACsB"}
@@ -12,23 +12,19 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
12
12
  * group) and returns the content.
13
13
  *
14
14
  * If the locale is not provided (directly or through the selector), it will
15
- * use the locale from the client context.
15
+ * use the locale from the client context. The same applies to the variant,
16
+ * which falls back to the provider's ambient `variant`.
16
17
  */
17
18
  const useDictionary = (dictionary, localeOrSelector) => {
18
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
19
- const isSelector = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null;
20
- const localeOrSelectorIdentity = isSelector ? `${localeOrSelector.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(localeOrSelector)}` : localeOrSelector;
21
- return (0, react.useMemo)(() => {
22
- if (isSelector) return require_getDictionary.getDictionary(dictionary, {
23
- ...localeOrSelector,
24
- locale: localeOrSelector.locale ?? currentLocale
25
- });
26
- return require_getDictionary.getDictionary(dictionary, localeOrSelector ?? currentLocale);
27
- }, [
28
- dictionary.key,
29
- currentLocale,
30
- localeOrSelectorIdentity
31
- ]);
19
+ const { locale: currentLocale, variant: contextVariant } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
20
+ const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
21
+ localeOrSelector,
22
+ contextLocale: currentLocale,
23
+ contextVariant,
24
+ dictionaryKey: dictionary.key
25
+ }) : localeOrSelector ?? currentLocale;
26
+ const argumentIdentity = typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument;
27
+ return (0, react.useMemo)(() => require_getDictionary.getDictionary(dictionary, argument), [dictionary.key, argumentIdentity]);
32
28
  };
33
29
 
34
30
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n }, [dictionary.key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,qDAAqB,KAAK,CAAC;CAExE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAGvB,MAAM,2BAA2B,aAC7B,GAAG,iBAAiB,UAAU,GAAG,2EAAiC,gBAAgB,MAClF;CAEJ,gCAAqB;EACnB,IAAI,YACF,OAAOC,oCAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAKR,OAAOA,oCAAoB,YAFL,oBAAoB,aAES;CACrD,GAAG;EAAC,WAAW;EAAK;EAAe;CAAwB,CAAC;AAC9D"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context. The same applies to the variant,\n * which falls back to the provider's ambient `variant`.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // This is the seam the build-time optimize transform lands on: it rewrites\n // `useIntlayer('key', selector)` into `useDictionary(dict, selector)`, so an\n // ambient variant has to be applied here to survive the rewrite.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object' && argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getDictionary<T, A>(dictionary, argument as A),\n [dictionary.key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,yCAC3BA,qDAAqB,KAAK,CAAC;CAMxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,8EACf;EACxB;EACA,eAAe;EACf;EACA,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoB;CAK3B,MAAM,mBACJ,OAAO,aAAa,YAAY,aAAa,OACzC,GAAG,SAAS,UAAU,GAAG,2EAAiC,QAAQ,MAClE;CAEN,gCACQC,oCAAoB,YAAY,QAAa,GACnD,CAAC,WAAW,KAAK,gBAAgB,CACnC;AACF"}
@@ -21,8 +21,13 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
21
21
  * context locale is used.
22
22
  */
23
23
  const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
24
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
25
- const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector) : {
24
+ const { locale: currentLocale, variant: contextVariant } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
25
+ const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)((0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
26
+ localeOrSelector,
27
+ contextLocale: currentLocale,
28
+ contextVariant,
29
+ dictionaryKey: String(key)
30
+ })) : {
26
31
  locale: localeOrSelector,
27
32
  selector: void 0
28
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n// `useLoadDynamic` is a suspender cache, not a React hook — aliased to a\n// non-hook name so it can be invoked in loops / conditionally (e.g. when a\n// collection loads several chunks at once).\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Client-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the client\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAOX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,qDAAqB,KAAK,CAAC;CAExE,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,4EACF,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBAAkB,iBAAiBC,4CAAqB;CAE1D,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAE7C,gFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,OAAO;EACpE,YAAY,eAAeC,oCAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAOA,oCALYD,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n// `useLoadDynamic` is a suspender cache, not a React hook — aliased to a\n// non-hook name so it can be invoked in loops / conditionally (e.g. when a\n// collection loads several chunks at once).\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Client-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the client\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: String(key),\n })\n )\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,wBAOX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,yCAC3BA,qDAAqB,KAAK,CAAC;CAExC,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,gJAIb;EACxB;EACA,eAAe;EACf;EACA,eAAe,OAAO,GAAG;CAC3B,CAAC,CACH,IACA;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBAAkB,iBAAiBC,4CAAqB;CAE1D,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAE7C,gFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,OAAO;EACpE,YAAY,eAAeC,oCAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAOA,oCALYD,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
@@ -13,8 +13,12 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
13
13
  * The second argument is either a locale or a selector object:
14
14
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
15
15
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
16
+ * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain
16
17
  * - `locale` composes with any selector and overrides the context locale
17
18
  *
19
+ * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`
20
+ * when the call does not pin them.
21
+ *
18
22
  * @param key - The unique key of the dictionary to retrieve.
19
23
  * @param localeOrSelector - Optional locale or selector.
20
24
  * @returns The dictionary content for the resolved entry and locale.
@@ -32,19 +36,14 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
32
36
  * ```
33
37
  */
34
38
  const useIntlayer = (key, localeOrSelector) => {
35
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
36
- const isSelector = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null;
37
- return (0, react.useMemo)(() => {
38
- if (isSelector) return require_getIntlayer.getIntlayer(key, {
39
- ...localeOrSelector,
40
- locale: localeOrSelector.locale ?? currentLocale
41
- });
42
- return require_getIntlayer.getIntlayer(key, localeOrSelector ?? currentLocale);
43
- }, [
44
- key,
45
- currentLocale,
46
- isSelector ? `${localeOrSelector.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(localeOrSelector)}` : localeOrSelector
47
- ]);
39
+ const { locale: currentLocale, variant: contextVariant } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
40
+ const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
41
+ localeOrSelector,
42
+ contextLocale: currentLocale,
43
+ contextVariant,
44
+ dictionaryKey: key
45
+ }) : localeOrSelector ?? currentLocale;
46
+ return (0, react.useMemo)(() => require_getIntlayer.getIntlayer(key, argument), [key, typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument]);
48
47
  };
49
48
 
50
49
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `locale` composes with any selector and overrides the context locale\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,eAMX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,qDAAqB,KAAK,CAAC;CAExE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAOvB,gCAAqB;EACnB,IAAI,YACF,OAAOC,gCAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAKR,OAAOA,gCAAkB,KAFH,oBAAoB,aAEA;CAC5C,GAAG;EAAC;EAAK;EAfwB,aAC7B,GAAG,iBAAiB,UAAU,GAAG,2EAAiC,gBAAgB,MAClF;CAa4C,CAAC;AACnD"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain\n * - `locale` composes with any selector and overrides the context locale\n *\n * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`\n * when the call does not pin them.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the merge is dead code and is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object' && argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getIntlayer<T, A>(key, argument as A),\n [key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,eAMX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,yCAC3BA,qDAAqB,KAAK,CAAC;CAKxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,8EACf;EACxB;EACA,eAAe;EACf;EACA,eAAe;CACjB,CAAC,IACA,oBAAoB;CAU3B,gCACQC,gCAAkB,KAAK,QAAa,GAC1C,CAAC,KAND,OAAO,aAAa,YAAY,aAAa,OACzC,GAAG,SAAS,UAAU,GAAG,2EAAiC,QAAQ,MAClE,QAIkB,CACxB;AACF"}
@@ -10,6 +10,13 @@ const { defaultLocale } = _intlayer_config_built.internationalization ?? {};
10
10
  */
11
11
  const IntlayerServerContext = require_server_serverContext.createServerContext(defaultLocale);
12
12
  /**
13
+ * Context that stores the ambient variant on the server side.
14
+ *
15
+ * Kept separate from {@link IntlayerServerContext} so the locale context keeps
16
+ * its plain `LocalesValues` shape for the packages already reading it.
17
+ */
18
+ const IntlayerServerVariantContext = require_server_serverContext.createServerContext(void 0);
19
+ /**
13
20
  * Hook that provides the current locale
14
21
  */
15
22
  const useIntlayer = () => require_server_serverContext.getServerContext(IntlayerServerContext);
@@ -20,14 +27,18 @@ const locale = require_server_serverContext.getServerContext(IntlayerServerConte
20
27
  /**
21
28
  * Provider that store the current locale on the server side
22
29
  */
23
- const IntlayerServerProvider = ({ children, locale = defaultLocale }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerContext.Provider, {
30
+ const IntlayerServerProvider = ({ children, locale = defaultLocale, variant }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerContext.Provider, {
24
31
  value: locale,
25
- children
32
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerVariantContext.Provider, {
33
+ value: variant,
34
+ children
35
+ })
26
36
  });
27
37
 
28
38
  //#endregion
29
39
  exports.IntlayerServerContext = IntlayerServerContext;
30
40
  exports.IntlayerServerProvider = IntlayerServerProvider;
41
+ exports.IntlayerServerVariantContext = IntlayerServerVariantContext;
31
42
  exports.locale = locale;
32
43
  exports.useIntlayer = useIntlayer;
33
44
  //# sourceMappingURL=IntlayerServerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerServerProvider.cjs","names":["internationalization","createServerContext","getServerContext"],"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,kBAAkBA,+CAAwB,CAAC;;;;AAKnD,MAAa,wBACXC,iDAAmC,aAAa;;;;AAKlD,MAAa,oBAAoBC,8CAAiB,qBAAqB;;;;AAKvE,MAAa,SAASA,8CAAiB,qBAAqB;;;;AAS5D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,2CAAC,sBAAsB,UAAvB;CAAgC,OAAO;CACpC;AAC6B"}
1
+ {"version":3,"file":"IntlayerServerProvider.cjs","names":["internationalization","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} 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 * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\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 * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\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 variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;AASA,MAAM,EAAE,kBAAkBA,+CAAwB,CAAC;;;;AAKnD,MAAa,wBACXC,iDAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACXA,iDAAqC,MAAS;;;;AAKhD,MAAa,oBAAoBC,8CAAiB,qBAAqB;;;;AAKvE,MAAa,SAASA,8CAAiB,qBAAqB;;;;AAkB5D,MAAa,0BAA2D,EACtE,UACA,SAAS,eACT,cAEA,2CAAC,sBAAsB,UAAvB;CAAgC,OAAO;WACrC,2CAAC,6BAA6B,UAA9B;EAAuC,OAAO;EAC3C;CACoC;AACT"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_getDictionary = require('../getDictionary.cjs');
3
3
  const require_server_serverContext = require('./serverContext.cjs');
4
4
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
5
6
 
6
7
  //#region src/server/useDictionary.ts
7
8
  /**
@@ -13,10 +14,12 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
13
14
  */
14
15
  const useDictionary = (dictionary, localeOrSelector, fallbackLocale) => {
15
16
  const contextLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale;
16
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return require_getDictionary.getDictionary(dictionary, {
17
- ...localeOrSelector,
18
- locale: localeOrSelector.locale ?? contextLocale
19
- });
17
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return require_getDictionary.getDictionary(dictionary, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
18
+ localeOrSelector,
19
+ contextLocale,
20
+ contextVariant: require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerVariantContext),
21
+ dictionaryKey: dictionary.key
22
+ }));
20
23
  return require_getDictionary.getDictionary(dictionary, localeOrSelector ?? contextLocale);
21
24
  };
22
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["getServerContext","IntlayerServerContext","getDictionary"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAOC,oCAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAOA,oCAAoB,YAFL,oBAAoB,aAES;AACrD"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["getServerContext","IntlayerServerContext","getDictionary","IntlayerServerVariantContext"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const contextVariant = getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n );\n\n return getDictionary<T, A>(\n dictionary,\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n }) as A\n );\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IAAI,QAAQ,IAAI,iCAAiC,SAK/C,OAAOC,oCACL,gFAC0B;EACxB;EACA;EACA,gBATmBF,8CACrBG,kEAQe;EACb,eAAe,WAAW;CAC5B,CAAC,CACH;CAKF,OAAOD,oCAAoB,YAFL,oBAAoB,aAES;AACrD"}
@@ -19,11 +19,17 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
19
19
  * context locale is used.
20
20
  */
21
21
  const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector, fallbackLocale) => {
22
- const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector) : {
22
+ const contextLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
23
+ const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)((0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
24
+ localeOrSelector,
25
+ contextLocale,
26
+ contextVariant: require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerVariantContext),
27
+ dictionaryKey: String(key)
28
+ })) : {
23
29
  locale: localeOrSelector,
24
30
  selector: void 0
25
31
  };
26
- const localeTarget = selectorLocale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
32
+ const localeTarget = selectorLocale ?? contextLocale ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
27
33
  if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && (0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(dictionaryPromise)) return (0, _intlayer_core_dictionaryManipulator.resolveQualifiedDynamicContent)({
28
34
  loaderMap: dictionaryPromise,
29
35
  key: String(key),
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,4EACF,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACAA,8CAAgCC,2DAAqB,KACrD,kBACAC,4CAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAE7C,gFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,OAAO;EACpE,YAAY,eAAeC,oCAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAOA,oCALYD,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","IntlayerServerVariantContext","internationalization","loadDynamicChunk","getDictionary"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n ProviderVariant,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(\n // Layers the request's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant: getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n ),\n dictionaryKey: String(key),\n })\n )\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n contextLocale ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,gBAAgBA,8CAAgCC,2DAAqB;CAE3E,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,gJAIb;EACxB;EACA;EACA,gBAAgBD,8CACdE,kEACF;EACA,eAAe,OAAO,GAAG;CAC3B,CAAC,CACH,IACA;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACA,iBACA,kBACAC,4CAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAE7C,gFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,OAAO;EACpE,YAAY,eAAeC,oCAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAOA,oCALYD,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_getIntlayer = require('../getIntlayer.cjs');
3
3
  const require_server_serverContext = require('./serverContext.cjs');
4
4
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
5
6
 
6
7
  //#region src/server/useIntlayer.ts
7
8
  /**
@@ -14,10 +15,12 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
14
15
  */
15
16
  const useIntlayer = (key, localeOrSelector, fallbackLocale) => {
16
17
  const contextLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale;
17
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return require_getIntlayer.getIntlayer(key, {
18
- ...localeOrSelector,
19
- locale: localeOrSelector.locale ?? contextLocale
20
- });
18
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return require_getIntlayer.getIntlayer(key, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
19
+ localeOrSelector,
20
+ contextLocale,
21
+ contextVariant: require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerVariantContext),
22
+ dictionaryKey: key
23
+ }));
21
24
  return require_getIntlayer.getIntlayer(key, localeOrSelector ?? contextLocale);
22
25
  };
23
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAMX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAOA,gCAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer","IntlayerServerVariantContext"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const contextVariant = getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n );\n\n return getIntlayer<T, A>(\n key,\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant,\n dictionaryKey: key as string,\n }) as A\n );\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAa,eAMX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,2DAAqB,KAAK;CAE5D,IAAI,QAAQ,IAAI,iCAAiC,SAK/C,OAAOC,gCACL,yEAC0B;EACxB;EACA;EACA,gBATmBF,8CACrBG,kEAQe;EACb,eAAe;CACjB,CAAC,CACH;CAKF,OAAOD,gCAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
@@ -32,7 +32,7 @@ const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};
32
32
  * @param props - The provider props.
33
33
  * @returns The provider component.
34
34
  */
35
- const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
35
+ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, variant, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
36
36
  const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = internationalization ?? {};
37
37
  const [currentLocale, setCurrentLocale] = useState(localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
38
38
  useEffect(() => {
@@ -56,6 +56,7 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
56
56
  value: {
57
57
  locale: resolvedLocale,
58
58
  setLocale,
59
+ variant,
59
60
  disableEditor
60
61
  },
61
62
  children
@@ -1 +1 @@
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 { AnalyticsProvider } from '../analytics/AnalyticsProvider';\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 <AnalyticsProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,2BAA2B,WAAW,qBAAqB,KAAK,CAAC;;;;;;;;;AAoC9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,mBAGjB;CAGvC,gBAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG,CAAC,UAAU,CAAC;CAEf,gBAAgB;EACd,sBAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mBAAmB,WAAW,eAAe;CAC/C;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,aAAa;CAEnD,OACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B;EACE,oBAAC,gBAAD,CAAiB;EACjB,oBAAC,mBAAD,CAAoB;EACnB;CACsB"}
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 {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { AnalyticsProvider } from '../analytics/AnalyticsProvider';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n /**\n * Ambient variant applied to every dictionary read below the provider, the\n * same way `locale` is. Overridden per call by an explicit selector.\n */\n variant?: ProviderVariant;\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 * Ambient variant applied to every dictionary read below this provider — for\n * a dimension that is fixed for the whole session (tenant, school type, plan\n * tier…) and that therefore no component should have to pass by hand.\n *\n * Accepts three forms:\n * - `variant=\"school1\"` — one named variant for every key\n * - `variant={['school1', 'default']}` — an ordered preference chain: the\n * first variant the key actually declares wins\n * - `variant={{ key1: 'school1', key2: ['school1', 'default'], default: 'base' }}`\n * — per dictionary key, with `default` covering every key not listed\n *\n * A plain object is always read as the per-key map. To pin a structured\n * variant globally, nest it: `variant={{ default: { id: 'prod_abc' } }}`.\n *\n * A call-site selector always wins: `useIntlayer('key', { variant: 'x' })`\n * replaces this default rather than extending it.\n */\n variant?: ProviderVariant;\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 variant,\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 variant,\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 <AnalyticsProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,2BAA2B,WAAW,qBAAqB,KAAK,CAAC;;;;;;;;;AAuD9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,SACA,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,oBACpB,SAHA,cAAc,mBAAmB,qBAAqB,mBAGjB;CAGvC,gBAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG,CAAC,UAAU,CAAC;CAEf,gBAAgB;EACd,sBAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mBAAmB,WAAW,eAAe;CAC/C;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iBAAiB,eAAe,aAAa;CAEnD,OACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B;EACE,oBAAC,gBAAD,CAAiB;EACjB,oBAAC,mBAAD,CAAoB;EACnB;CACsB"}
@@ -3,7 +3,7 @@
3
3
  import { getDictionary } from "../getDictionary.mjs";
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  import { useContext, useMemo } from "react";
6
- import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipulator";
6
+ import { getDictionarySelectorCacheKey, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
7
7
 
8
8
  //#region src/client/useDictionary.ts
9
9
  /**
@@ -11,23 +11,19 @@ import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipula
11
11
  * group) and returns the content.
12
12
  *
13
13
  * If the locale is not provided (directly or through the selector), it will
14
- * use the locale from the client context.
14
+ * use the locale from the client context. The same applies to the variant,
15
+ * which falls back to the provider's ambient `variant`.
15
16
  */
16
17
  const useDictionary = (dictionary, localeOrSelector) => {
17
- const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
18
- const isSelector = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null;
19
- const localeOrSelectorIdentity = isSelector ? `${localeOrSelector.locale ?? ""}|${getDictionarySelectorCacheKey(localeOrSelector)}` : localeOrSelector;
20
- return useMemo(() => {
21
- if (isSelector) return getDictionary(dictionary, {
22
- ...localeOrSelector,
23
- locale: localeOrSelector.locale ?? currentLocale
24
- });
25
- return getDictionary(dictionary, localeOrSelector ?? currentLocale);
26
- }, [
27
- dictionary.key,
28
- currentLocale,
29
- localeOrSelectorIdentity
30
- ]);
18
+ const { locale: currentLocale, variant: contextVariant } = useContext(IntlayerClientContext) ?? {};
19
+ const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? resolveDictionaryArgument({
20
+ localeOrSelector,
21
+ contextLocale: currentLocale,
22
+ contextVariant,
23
+ dictionaryKey: dictionary.key
24
+ }) : localeOrSelector ?? currentLocale;
25
+ const argumentIdentity = typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${getDictionarySelectorCacheKey(argument)}` : argument;
26
+ return useMemo(() => getDictionary(dictionary, argument), [dictionary.key, argumentIdentity]);
31
27
  };
32
28
 
33
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n }, [dictionary.key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAGvB,MAAM,2BAA2B,aAC7B,GAAG,iBAAiB,UAAU,GAAG,GAAG,8BAA8B,gBAAgB,MAClF;CAEJ,OAAO,cAAc;EACnB,IAAI,YACF,OAAO,cAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAKR,OAAO,cAAoB,YAFL,oBAAoB,aAES;CACrD,GAAG;EAAC,WAAW;EAAK;EAAe;CAAwB,CAAC;AAC9D"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context. The same applies to the variant,\n * which falls back to the provider's ambient `variant`.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // This is the seam the build-time optimize transform lands on: it rewrites\n // `useIntlayer('key', selector)` into `useDictionary(dict, selector)`, so an\n // ambient variant has to be applied here to survive the rewrite.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object' && argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getDictionary<T, A>(dictionary, argument as A),\n [dictionary.key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,mBACtC,WAAW,qBAAqB,KAAK,CAAC;CAMxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,0BAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoB;CAK3B,MAAM,mBACJ,OAAO,aAAa,YAAY,aAAa,OACzC,GAAG,SAAS,UAAU,GAAG,GAAG,8BAA8B,QAAQ,MAClE;CAEN,OAAO,cACC,cAAoB,YAAY,QAAa,GACnD,CAAC,WAAW,KAAK,gBAAgB,CACnC;AACF"}
@@ -5,7 +5,7 @@ import { getDictionary } from "../getDictionary.mjs";
5
5
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
6
6
  import { internationalization } from "@intlayer/config/built";
7
7
  import { useContext } from "react";
8
- import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
8
+ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
9
9
 
10
10
  //#region src/client/useDictionaryDynamic.ts
11
11
  /**
@@ -20,8 +20,13 @@ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedD
20
20
  * context locale is used.
21
21
  */
22
22
  const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
23
- const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
24
- const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(localeOrSelector) : {
23
+ const { locale: currentLocale, variant: contextVariant } = useContext(IntlayerClientContext) ?? {};
24
+ const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(resolveDictionaryArgument({
25
+ localeOrSelector,
26
+ contextLocale: currentLocale,
27
+ contextVariant,
28
+ dictionaryKey: String(key)
29
+ })) : {
25
30
  locale: localeOrSelector,
26
31
  selector: void 0
27
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n// `useLoadDynamic` is a suspender cache, not a React hook — aliased to a\n// non-hook name so it can be invoked in loops / conditionally (e.g. when a\n// collection loads several chunks at once).\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Client-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the client\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAOX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,UACzC,wBAAuC,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBAAkB,iBAAiB,qBAAqB;CAE1D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAE7C,OAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,OAAO;EACpE,YAAY,eAAe,cAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAO,cALYA,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n// `useLoadDynamic` is a suspender cache, not a React hook — aliased to a\n// non-hook name so it can be invoked in loops / conditionally (e.g. when a\n// collection loads several chunks at once).\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Client-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the client\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(\n // Layers the provider's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: String(key),\n })\n )\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,wBAOX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,mBACtC,WAAW,qBAAqB,KAAK,CAAC;CAExC,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,UACzC,wBAGE,0BAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe,OAAO,GAAG;CAC3B,CAAC,CACH,IACA;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBAAkB,iBAAiB,qBAAqB;CAE1D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAE7C,OAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,OAAO;EACpE,YAAY,eAAe,cAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAO,cALYA,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
@@ -3,7 +3,7 @@
3
3
  import { getIntlayer } from "../getIntlayer.mjs";
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  import { useContext, useMemo } from "react";
6
- import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipulator";
6
+ import { getDictionarySelectorCacheKey, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
7
7
 
8
8
  //#region src/client/useIntlayer.ts
9
9
  /**
@@ -12,8 +12,12 @@ import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipula
12
12
  * The second argument is either a locale or a selector object:
13
13
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
14
14
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
15
+ * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain
15
16
  * - `locale` composes with any selector and overrides the context locale
16
17
  *
18
+ * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`
19
+ * when the call does not pin them.
20
+ *
17
21
  * @param key - The unique key of the dictionary to retrieve.
18
22
  * @param localeOrSelector - Optional locale or selector.
19
23
  * @returns The dictionary content for the resolved entry and locale.
@@ -31,19 +35,14 @@ import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipula
31
35
  * ```
32
36
  */
33
37
  const useIntlayer = (key, localeOrSelector) => {
34
- const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
35
- const isSelector = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null;
36
- return useMemo(() => {
37
- if (isSelector) return getIntlayer(key, {
38
- ...localeOrSelector,
39
- locale: localeOrSelector.locale ?? currentLocale
40
- });
41
- return getIntlayer(key, localeOrSelector ?? currentLocale);
42
- }, [
43
- key,
44
- currentLocale,
45
- isSelector ? `${localeOrSelector.locale ?? ""}|${getDictionarySelectorCacheKey(localeOrSelector)}` : localeOrSelector
46
- ]);
38
+ const { locale: currentLocale, variant: contextVariant } = useContext(IntlayerClientContext) ?? {};
39
+ const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? resolveDictionaryArgument({
40
+ localeOrSelector,
41
+ contextLocale: currentLocale,
42
+ contextVariant,
43
+ dictionaryKey: key
44
+ }) : localeOrSelector ?? currentLocale;
45
+ return useMemo(() => getIntlayer(key, argument), [key, typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${getDictionarySelectorCacheKey(argument)}` : argument]);
47
46
  };
48
47
 
49
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `locale` composes with any selector and overrides the context locale\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,eAMX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAOvB,OAAO,cAAc;EACnB,IAAI,YACF,OAAO,YAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAKR,OAAO,YAAkB,KAFH,oBAAoB,aAEA;CAC5C,GAAG;EAAC;EAAK;EAfwB,aAC7B,GAAG,iBAAiB,UAAU,GAAG,GAAG,8BAA8B,gBAAgB,MAClF;CAa4C,CAAC;AACnD"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain\n * - `locale` composes with any selector and overrides the context locale\n *\n * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`\n * when the call does not pin them.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the merge is dead code and is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object' && argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getIntlayer<T, A>(key, argument as A),\n [key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,eAMX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,mBACtC,WAAW,qBAAqB,KAAK,CAAC;CAKxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,0BAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe;CACjB,CAAC,IACA,oBAAoB;CAU3B,OAAO,cACC,YAAkB,KAAK,QAAa,GAC1C,CAAC,KAND,OAAO,aAAa,YAAY,aAAa,OACzC,GAAG,SAAS,UAAU,GAAG,GAAG,8BAA8B,QAAQ,MAClE,QAIkB,CACxB;AACF"}
@@ -9,6 +9,13 @@ const { defaultLocale } = internationalization ?? {};
9
9
  */
10
10
  const IntlayerServerContext = createServerContext(defaultLocale);
11
11
  /**
12
+ * Context that stores the ambient variant on the server side.
13
+ *
14
+ * Kept separate from {@link IntlayerServerContext} so the locale context keeps
15
+ * its plain `LocalesValues` shape for the packages already reading it.
16
+ */
17
+ const IntlayerServerVariantContext = createServerContext(void 0);
18
+ /**
12
19
  * Hook that provides the current locale
13
20
  */
14
21
  const useIntlayer = () => getServerContext(IntlayerServerContext);
@@ -19,11 +26,14 @@ const locale = getServerContext(IntlayerServerContext);
19
26
  /**
20
27
  * Provider that store the current locale on the server side
21
28
  */
22
- const IntlayerServerProvider = ({ children, locale = defaultLocale }) => /* @__PURE__ */ jsx(IntlayerServerContext.Provider, {
29
+ const IntlayerServerProvider = ({ children, locale = defaultLocale, variant }) => /* @__PURE__ */ jsx(IntlayerServerContext.Provider, {
23
30
  value: locale,
24
- children
31
+ children: /* @__PURE__ */ jsx(IntlayerServerVariantContext.Provider, {
32
+ value: variant,
33
+ children
34
+ })
25
35
  });
26
36
 
27
37
  //#endregion
28
- export { IntlayerServerContext, IntlayerServerProvider, locale, useIntlayer };
38
+ export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerVariantContext, locale, useIntlayer };
29
39
  //# sourceMappingURL=IntlayerServerProvider.mjs.map
@@ -1 +1 @@
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,CAAC;;;;AAKnD,MAAa,wBACX,oBAAmC,aAAa;;;;AAKlD,MAAa,oBAAoB,iBAAiB,qBAAqB;;;;AAKvE,MAAa,SAAS,iBAAiB,qBAAqB;;;;AAS5D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,oBAAC,sBAAsB,UAAvB;CAAgC,OAAO;CACpC;AAC6B"}
1
+ {"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} 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 * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\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 * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\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 variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AASA,MAAM,EAAE,kBAAkB,wBAAwB,CAAC;;;;AAKnD,MAAa,wBACX,oBAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACX,oBAAqC,MAAS;;;;AAKhD,MAAa,oBAAoB,iBAAiB,qBAAqB;;;;AAKvE,MAAa,SAAS,iBAAiB,qBAAqB;;;;AAkB5D,MAAa,0BAA2D,EACtE,UACA,SAAS,eACT,cAEA,oBAAC,sBAAsB,UAAvB;CAAgC,OAAO;WACrC,oBAAC,6BAA6B,UAA9B;EAAuC,OAAO;EAC3C;CACoC;AACT"}
@@ -1,6 +1,7 @@
1
1
  import { getDictionary } from "../getDictionary.mjs";
2
2
  import { getServerContext } from "./serverContext.mjs";
3
- import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { IntlayerServerContext, IntlayerServerVariantContext } from "./IntlayerServerProvider.mjs";
4
+ import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
4
5
 
5
6
  //#region src/server/useDictionary.ts
6
7
  /**
@@ -12,10 +13,12 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
12
13
  */
13
14
  const useDictionary = (dictionary, localeOrSelector, fallbackLocale) => {
14
15
  const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
15
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return getDictionary(dictionary, {
16
- ...localeOrSelector,
17
- locale: localeOrSelector.locale ?? contextLocale
18
- });
16
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return getDictionary(dictionary, resolveDictionaryArgument({
17
+ localeOrSelector,
18
+ contextLocale,
19
+ contextVariant: getServerContext(IntlayerServerVariantContext),
20
+ dictionaryKey: dictionary.key
21
+ }));
19
22
  return getDictionary(dictionary, localeOrSelector ?? contextLocale);
20
23
  };
21
24
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAO,cAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAO,cAAoB,YAFL,oBAAoB,aAES;AACrD"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const contextVariant = getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n );\n\n return getDictionary<T, A>(\n dictionary,\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n }) as A\n );\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IAAI,QAAQ,IAAI,iCAAiC,SAK/C,OAAO,cACL,YACA,0BAA0B;EACxB;EACA;EACA,gBATmB,iBACrB,4BAQe;EACb,eAAe,WAAW;CAC5B,CAAC,CACH;CAKF,OAAO,cAAoB,YAFL,oBAAoB,aAES;AACrD"}
@@ -1,9 +1,9 @@
1
1
  import { getDictionary } from "../getDictionary.mjs";
2
2
  import { getServerContext } from "./serverContext.mjs";
3
- import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { IntlayerServerContext, IntlayerServerVariantContext } from "./IntlayerServerProvider.mjs";
4
4
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
5
5
  import { internationalization } from "@intlayer/config/built";
6
- import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
6
+ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
7
7
 
8
8
  //#region src/server/useDictionaryDynamic.ts
9
9
  /**
@@ -18,11 +18,17 @@ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedD
18
18
  * context locale is used.
19
19
  */
20
20
  const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector, fallbackLocale) => {
21
- const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(localeOrSelector) : {
21
+ const contextLocale = getServerContext(IntlayerServerContext);
22
+ const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(resolveDictionaryArgument({
23
+ localeOrSelector,
24
+ contextLocale,
25
+ contextVariant: getServerContext(IntlayerServerVariantContext),
26
+ dictionaryKey: String(key)
27
+ })) : {
22
28
  locale: localeOrSelector,
23
29
  selector: void 0
24
30
  };
25
- const localeTarget = selectorLocale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
31
+ const localeTarget = selectorLocale ?? contextLocale ?? fallbackLocale ?? internationalization.defaultLocale;
26
32
  if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && isQualifiedDynamicLoaderMap(dictionaryPromise)) return resolveQualifiedDynamicContent({
27
33
  loaderMap: dictionaryPromise,
28
34
  key: String(key),
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,UACzC,wBAAuC,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACA,iBAAgC,qBAAqB,KACrD,kBACA,qBAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAE7C,OAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,OAAO;EACpE,YAAY,eAAe,cAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAO,cALYA,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n ProviderVariant,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(\n // Layers the request's ambient variant under the call-site argument\n // before the chunk walk, so only the targeted chunk is loaded.\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant: getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n ),\n dictionaryKey: String(key),\n })\n )\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n contextLocale ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,gBAAgB,iBAAgC,qBAAqB;CAE3E,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,UACzC,wBAGE,0BAA0B;EACxB;EACA;EACA,gBAAgB,iBACd,4BACF;EACA,eAAe,OAAO,GAAG;CAC3B,CAAC,CACH,IACA;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACA,iBACA,kBACA,qBAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAE7C,OAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,OAAO;EACpE,YAAY,eAAe,cAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAO,cALYA,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
@@ -1,6 +1,7 @@
1
1
  import { getIntlayer } from "../getIntlayer.mjs";
2
2
  import { getServerContext } from "./serverContext.mjs";
3
- import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { IntlayerServerContext, IntlayerServerVariantContext } from "./IntlayerServerProvider.mjs";
4
+ import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
4
5
 
5
6
  //#region src/server/useIntlayer.ts
6
7
  /**
@@ -13,10 +14,12 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
13
14
  */
14
15
  const useIntlayer = (key, localeOrSelector, fallbackLocale) => {
15
16
  const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
16
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return getIntlayer(key, {
17
- ...localeOrSelector,
18
- locale: localeOrSelector.locale ?? contextLocale
19
- });
17
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return getIntlayer(key, resolveDictionaryArgument({
18
+ localeOrSelector,
19
+ contextLocale,
20
+ contextVariant: getServerContext(IntlayerServerVariantContext),
21
+ dictionaryKey: key
22
+ }));
20
23
  return getIntlayer(key, localeOrSelector ?? contextLocale);
21
24
  };
22
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,eAMX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAO,YAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAO,YAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport {\n IntlayerServerContext,\n IntlayerServerVariantContext,\n} from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const contextVariant = getServerContext<ProviderVariant>(\n IntlayerServerVariantContext\n );\n\n return getIntlayer<T, A>(\n key,\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale,\n contextVariant,\n dictionaryKey: key as string,\n }) as A\n );\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAa,eAMX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IAAI,QAAQ,IAAI,iCAAiC,SAK/C,OAAO,YACL,KACA,0BAA0B;EACxB;EACA;EACA,gBATmB,iBACrB,4BAQe;EACb,eAAe;CACjB,CAAC,CACH;CAKF,OAAO,YAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
@@ -1,9 +1,14 @@
1
- import { LocalesValues } from "@intlayer/types/module_augmentation";
1
+ import { LocalesValues, ProviderVariant } from "@intlayer/types/module_augmentation";
2
2
  import { FC, PropsWithChildren } from "react";
3
3
  //#region src/client/IntlayerProvider.d.ts
4
4
  type IntlayerValue = {
5
5
  locale: LocalesValues;
6
6
  setLocale: (newLocale: LocalesValues) => void;
7
+ /**
8
+ * Ambient variant applied to every dictionary read below the provider, the
9
+ * same way `locale` is. Overridden per call by an explicit selector.
10
+ */
11
+ variant?: ProviderVariant;
7
12
  disableEditor?: boolean;
8
13
  isCookieEnabled?: boolean;
9
14
  };
@@ -25,6 +30,25 @@ type IntlayerProviderProps = PropsWithChildren<{
25
30
  * The locale to use. If not provided, it will be detected from storage or configuration.
26
31
  */
27
32
  locale?: LocalesValues;
33
+ /**
34
+ * Ambient variant applied to every dictionary read below this provider — for
35
+ * a dimension that is fixed for the whole session (tenant, school type, plan
36
+ * tier…) and that therefore no component should have to pass by hand.
37
+ *
38
+ * Accepts three forms:
39
+ * - `variant="school1"` — one named variant for every key
40
+ * - `variant={['school1', 'default']}` — an ordered preference chain: the
41
+ * first variant the key actually declares wins
42
+ * - `variant={{ key1: 'school1', key2: ['school1', 'default'], default: 'base' }}`
43
+ * — per dictionary key, with `default` covering every key not listed
44
+ *
45
+ * A plain object is always read as the per-key map. To pin a structured
46
+ * variant globally, nest it: `variant={{ default: { id: 'prod_abc' } }}`.
47
+ *
48
+ * A call-site selector always wins: `useIntlayer('key', { variant: 'x' })`
49
+ * replaces this default rather than extending it.
50
+ */
51
+ variant?: ProviderVariant;
28
52
  /**
29
53
  * The default locale to use as a fallback.
30
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAkBK;EACH,QAAQ;EACR,YAAY,WAAW;EACvB;EACA;;;;;cAMW,uCAAqB,QAAA;;;;;;cAWrB;;;;KAKD,wBAAwB;;;;EAIlC,SAAS;;;;EAIT,gBAAgB;;;;EAIhB,aAAa,QAAQ;;;;EAIrB;;;;EAIA;;;;;;;;;;cAWW,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;cA8E5B,kBAAkB,GAAG"}
1
+ {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAqBK;EACH,QAAQ;EACR,YAAY,WAAW;;;;;EAKvB,UAAU;EACV;EACA;;;;;cAMW,uCAAqB,QAAA;;;;;;cAWrB;;;;KAKD,wBAAwB;;;;EAIlC,SAAS;;;;;;;;;;;;;;;;;;;EAmBT,UAAU;;;;EAIV,gBAAgB;;;;EAIhB,aAAa,QAAQ;;;;EAIrB;;;;EAIA;;;;;;;;;;cAWW,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;cAgF5B,kBAAkB,GAAG"}
@@ -7,7 +7,8 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from
7
7
  * group) and returns the content.
8
8
  *
9
9
  * If the locale is not provided (directly or through the selector), it will
10
- * use the locale from the client context.
10
+ * use the locale from the client context. The same applies to the variant,
11
+ * which falls back to the provider's ambient `variant`.
11
12
  */
12
13
  declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends DeclaredLocales | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
13
14
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;;cAoBa,sBACL,UAAU,aAAa,gCACvB,UACF,kBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,2CAAC,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;;;cAwBa,sBACL,UAAU,aAAa,gCACvB,UACF,kBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,2CAAC,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;cAoCa,6BACL,UAAU,kBACV,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,mBAG7C,0BAA0B,QAAQ,MAClC,2BAAyB,KACxB,GAAC,mBACa"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;cAqCa,6BACL,UAAU,kBACV,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,mBAG7C,0BAA0B,QAAQ,MAClC,2BAAyB,KACxB,GAAC,mBACa"}
@@ -7,8 +7,12 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey } from "@intl
7
7
  * The second argument is either a locale or a selector object:
8
8
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
9
9
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
10
+ * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain
10
11
  * - `locale` composes with any selector and overrides the context locale
11
12
  *
13
+ * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`
14
+ * when the call does not pin them.
15
+ *
12
16
  * @param key - The unique key of the dictionary to retrieve.
13
17
  * @param localeOrSelector - Optional locale or selector.
14
18
  * @returns The dictionary content for the resolved entry and locale.
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCa,oBACL,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,KAE5C,GAAC,mBACa,2CAAC,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}
1
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2Ca,oBACL,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,KAE5C,GAAC,mBACa,2CAAC,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1,4 +1,4 @@
1
- import { LocalesValues } from "@intlayer/types/module_augmentation";
1
+ import { LocalesValues, ProviderVariant } from "@intlayer/types/module_augmentation";
2
2
  import { FC, PropsWithChildren } from "react";
3
3
  //#region src/server/IntlayerServerProvider.d.ts
4
4
  /**
@@ -18,6 +18,26 @@ declare const IntlayerServerContext: FC<PropsWithChildren<{
18
18
  };
19
19
  _defaultValue: LocalesValues;
20
20
  };
21
+ /**
22
+ * Context that stores the ambient variant on the server side.
23
+ *
24
+ * Kept separate from {@link IntlayerServerContext} so the locale context keeps
25
+ * its plain `LocalesValues` shape for the packages already reading it.
26
+ */
27
+ declare const IntlayerServerVariantContext: FC<PropsWithChildren<{
28
+ value?: ProviderVariant;
29
+ }>> & {
30
+ Provider: FC<PropsWithChildren<{
31
+ value?: ProviderVariant;
32
+ }>>;
33
+ Consumer: FC<PropsWithChildren<{
34
+ children: (context: ProviderVariant) => import("react").ReactNode;
35
+ }>>;
36
+ _storage: () => {
37
+ value: ProviderVariant;
38
+ };
39
+ _defaultValue: ProviderVariant;
40
+ };
21
41
  /**
22
42
  * Hook that provides the current locale
23
43
  */
@@ -28,11 +48,20 @@ declare const useIntlayer: () => LocalesValues;
28
48
  declare const locale: LocalesValues;
29
49
  type IntlayerServerProviderProps = PropsWithChildren & {
30
50
  locale?: LocalesValues;
51
+ /**
52
+ * Ambient variant applied to every dictionary read below this provider — for
53
+ * a dimension resolved once per request (tenant, school type, plan tier…).
54
+ *
55
+ * Accepts a name (`'school1'`), an ordered preference chain
56
+ * (`['school1', 'default']`), or a per-key map
57
+ * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.
58
+ */
59
+ variant?: ProviderVariant;
31
60
  };
32
61
  /**
33
62
  * Provider that store the current locale on the server side
34
63
  */
35
64
  declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
36
65
  //#endregion
37
- export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerProviderProps, locale, useIntlayer };
66
+ export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerProviderProps, IntlayerServerVariantContext, locale, useIntlayer };
38
67
  //# sourceMappingURL=IntlayerServerProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerServerProvider.d.ts","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"mappings":";;;;;;cAWa,uBAAqB,GAAA;;;;;;;;;;;;;;;;;cAMrB,mBAAW;;;;cAKX,QAAM;KAEP,8BAA8B;EACxC,SAAS;;;;;cAME,wBAAwB,GAAG"}
1
+ {"version":3,"file":"IntlayerServerProvider.d.ts","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"mappings":";;;;;;cAca,uBAAqB,GAAA;;;;;;;;;;;;;;;;;;;;cASrB,8BAA4B,GAAA;;;;;;;;;;;;;;;;;cAM5B,mBAAW;;;;cAKX,QAAM;KAEP,8BAA8B;EACxC,SAAS;;;;;;;;;EAST,UAAU;;;;;cAMC,wBAAwB,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;;cAoBa,sBACL,UAAU,aAAa,gCACvB,UACF,kBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,GAAC,iBACH,yDAAe,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;;cAyBa,sBACL,UAAU,aAAa,gCACvB,UACF,kBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,GAAC,iBACH,yDAAe,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;cAmCa,6BACL,UAAU,kBACV,UAAU,kBAAkB,qBAAqB,iBAAe,mBAGlE,0BAA0B,QAAQ,MAClC,2BAAyB,aAClB,mBACQ,GAAC,iBACH"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;;;cAwCa,6BACL,UAAU,kBACV,UAAU,kBAAkB,qBAAqB,iBAAe,mBAGlE,0BAA0B,QAAQ,MAClC,2BAAyB,aAClB,mBACQ,GAAC,iBACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;;;;;;;cAkBa,oBACL,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,KAE5C,GAAC,mBACa,GAAC,iBACH,yDAAe,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}
1
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;;;;;;;cAuBa,oBACL,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,KAE5C,GAAC,mBACa,GAAC,iBACH,yDAAe,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "9.1.1",
3
+ "version": "9.1.2",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -132,12 +132,12 @@
132
132
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
133
133
  },
134
134
  "dependencies": {
135
- "@intlayer/api": "9.1.1",
136
- "@intlayer/config": "9.1.1",
137
- "@intlayer/core": "9.1.1",
138
- "@intlayer/dictionaries-entry": "9.1.1",
139
- "@intlayer/editor": "9.1.1",
140
- "@intlayer/types": "9.1.1"
135
+ "@intlayer/api": "9.1.2",
136
+ "@intlayer/config": "9.1.2",
137
+ "@intlayer/core": "9.1.2",
138
+ "@intlayer/dictionaries-entry": "9.1.2",
139
+ "@intlayer/editor": "9.1.2",
140
+ "@intlayer/types": "9.1.2"
141
141
  },
142
142
  "devDependencies": {
143
143
  "@craco/types": "7.1.0",
@@ -158,7 +158,7 @@
158
158
  "react-dom": ">=16.0.0"
159
159
  },
160
160
  "optionalDependencies": {
161
- "@intlayer/analytics": "9.1.1"
161
+ "@intlayer/analytics": "9.1.2"
162
162
  },
163
163
  "engines": {
164
164
  "node": ">=14.18"