react-intlayer 9.1.1 → 9.1.3

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 (57) 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/getDictionary.cjs.map +1 -1
  10. package/dist/cjs/getIntlayer.cjs.map +1 -1
  11. package/dist/cjs/server/IntlayerServerProvider.cjs +13 -2
  12. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  13. package/dist/cjs/server/useDictionary.cjs +7 -4
  14. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  15. package/dist/cjs/server/useDictionaryDynamic.cjs +8 -2
  16. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  17. package/dist/cjs/server/useIntlayer.cjs +7 -4
  18. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  19. package/dist/esm/client/IntlayerProvider.mjs +2 -1
  20. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  21. package/dist/esm/client/useDictionary.mjs +12 -16
  22. package/dist/esm/client/useDictionary.mjs.map +1 -1
  23. package/dist/esm/client/useDictionaryDynamic.mjs +8 -3
  24. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  25. package/dist/esm/client/useIntlayer.mjs +13 -14
  26. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  27. package/dist/esm/getDictionary.mjs.map +1 -1
  28. package/dist/esm/getIntlayer.mjs.map +1 -1
  29. package/dist/esm/server/IntlayerServerProvider.mjs +13 -3
  30. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  31. package/dist/esm/server/useDictionary.mjs +8 -5
  32. package/dist/esm/server/useDictionary.mjs.map +1 -1
  33. package/dist/esm/server/useDictionaryDynamic.mjs +10 -4
  34. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  35. package/dist/esm/server/useIntlayer.mjs +8 -5
  36. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  37. package/dist/types/client/IntlayerProvider.d.ts +25 -1
  38. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  39. package/dist/types/client/useDictionary.d.ts +4 -3
  40. package/dist/types/client/useDictionary.d.ts.map +1 -1
  41. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  42. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  43. package/dist/types/client/useIntlayer.d.ts +6 -2
  44. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  45. package/dist/types/getDictionary.d.ts +2 -2
  46. package/dist/types/getDictionary.d.ts.map +1 -1
  47. package/dist/types/getIntlayer.d.ts +2 -2
  48. package/dist/types/getIntlayer.d.ts.map +1 -1
  49. package/dist/types/server/IntlayerServerProvider.d.ts +31 -2
  50. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
  51. package/dist/types/server/useDictionary.d.ts +2 -2
  52. package/dist/types/server/useDictionary.d.ts.map +1 -1
  53. package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
  54. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  55. package/dist/types/server/useIntlayer.d.ts +2 -2
  56. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  57. package/package.json +8 -8
@@ -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 LocalesValues,\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 LocalesValues | 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAIX,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getDictionaryCore(\n dictionary,\n localeOrSelector,\n getPlugins(locale)\n ) as any;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,iBAMX,YACA,qBAIG;CAOH,OAAOA,gBACL,YACA,kBACA,WARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,gBAMa,CACnB;AACF"}
1
+ {"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getDictionaryCore(\n dictionary,\n localeOrSelector,\n getPlugins(locale)\n ) as any;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,iBAMX,YACA,qBAIG;CAOH,OAAOA,gBACL,YACA,kBACA,WARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,gBAMa,CACnB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends\n | DeclaredLocales\n | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getIntlayerCore(key, localeOrSelector, getPlugins(locale)) as any;\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,eAMX,KACA,qBAIG;CAOH,OAAOA,cAAgB,KAAK,kBAAkB,WAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,gBAGyD,CAAC;AAClE"}
1
+ {"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getIntlayerCore(key, localeOrSelector, getPlugins(locale)) as any;\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,eAIX,KACA,qBAIG;CAOH,OAAOA,cAAgB,KAAK,kBAAkB,WAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,gBAGyD,CAAC;AAClE"}
@@ -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 | LocalesValues\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 LocalesValues | 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 LocalesValues | 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,eAIX,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"}
@@ -1,5 +1,5 @@
1
1
  import { IInterpreterPluginState } from "../plugins.js";
2
- import { DeclaredLocales } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
4
4
  //#region src/client/useDictionary.d.ts
5
5
  /**
@@ -7,9 +7,10 @@ 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
- 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
+ declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
13
14
  //#endregion
14
15
  export { useDictionary };
15
16
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -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":";;;;;;;;;;;;cA2Ba,sBACL,UAAU,aAAa,gCACvB,UACF,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,2CAAC,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1,4 +1,4 @@
1
- import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
1
+ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
2
2
  import { Dictionary } from "@intlayer/types/dictionary";
3
3
  import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
4
4
  //#region src/client/useDictionaryDynamic.d.ts
@@ -13,7 +13,7 @@ import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator"
13
13
  * If the locale is not provided (directly or through the selector), the client
14
14
  * context locale is used.
15
15
  */
16
- declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends DeclaredLocales | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => any;
16
+ declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => any;
17
17
  //#endregion
18
18
  export { useDictionaryDynamic };
19
19
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -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,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,mBAGzE,0BAA0B,QAAQ,MAClC,2BAAyB,KACxB,GAAC,mBACa"}
@@ -1,5 +1,5 @@
1
1
  import { IInterpreterPluginState } from "../plugins.js";
2
- import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  //#region src/client/useIntlayer.d.ts
4
4
  /**
5
5
  * Client-side hook that picks one dictionary by its key and returns its content.
@@ -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.
@@ -25,7 +29,7 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey } from "@intl
25
29
  * };
26
30
  * ```
27
31
  */
28
- declare const useIntlayer: <const T extends DictionaryKeys, const A extends DeclaredLocales | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").DictionaryRegistryResult<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
32
+ declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").DictionaryRegistryResult<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
29
33
  //#endregion
30
34
  export { useIntlayer };
31
35
  //# sourceMappingURL=useIntlayer.d.ts.map
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4Ca,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,2CAAC,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1,5 +1,5 @@
1
1
  import { DeepTransformContent } from "./plugins.js";
2
- import { DeclaredLocales, ExtractSelectorLocale } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
4
4
  //#region src/getDictionary.d.ts
5
5
  /**
@@ -7,7 +7,7 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, Resol
7
7
  * content for the given locale or selector (`{ item }`, `{ variant }`,
8
8
  * optionally combined with `locale`).
9
9
  */
10
- declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends DeclaredLocales | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
10
+ declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
11
11
  //#endregion
12
12
  export { getDictionary };
13
13
  //# sourceMappingURL=getDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;;;;;cAmBa,sBACL,UAAU,aAAa,gCACvB,UACF,kBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,MAClB,qBACD,kCAAkC,GAAG,IACrC,sBAAsB"}
1
+ {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;;;;;cAmBa,sBACL,UAAU,aAAa,gCACvB,UACF,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,MAClB,qBACD,kCAAkC,GAAG,IACrC,sBAAsB"}
@@ -1,12 +1,12 @@
1
1
  import { DeepTransformContent } from "./plugins.js";
2
- import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  //#region src/getIntlayer.d.ts
4
4
  /**
5
5
  * Picks one dictionary by its key and returns its content for the given
6
6
  * locale or selector (`{ item }`, `{ variant }`,
7
7
  * optionally combined with `locale`).
8
8
  */
9
- declare const getIntlayer: <const T extends DictionaryKeys, const A extends DeclaredLocales | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
9
+ declare const getIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
10
10
  //#endregion
11
11
  export { getIntlayer };
12
12
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;;;;;cAgBa,oBACL,UAAU,sBACV,UACF,kBACA,yBAAyB,KAAK,iBAAe,KAE5C,GAAC,mBACa,MAClB,qBACD,yBAAyB,GAAG,IAC5B,sBAAsB"}
1
+ {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;;;;;cAgBa,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,MAClB,qBACD,yBAAyB,GAAG,IAC5B,sBAAsB"}
@@ -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,5 +1,5 @@
1
1
  import { IInterpreterPluginState } from "../plugins.js";
2
- import { DeclaredLocales } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
4
4
  //#region src/server/useDictionary.d.ts
5
5
  /**
@@ -9,7 +9,7 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from
9
9
  * If the locale is not provided (directly or through the selector), it will
10
10
  * use the locale from the server context
11
11
  */
12
- declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends DeclaredLocales | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
12
+ declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
13
13
  //#endregion
14
14
  export { useDictionary };
15
15
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -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,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,GAAC,iBACH,yDAAe,+CAAA,kCAAA,GAAA,IAAA,mDAAA,sBAAA"}
@@ -1,4 +1,4 @@
1
- import { DeclaredLocales, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
1
+ import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
2
2
  import { Dictionary, DictionarySelector } from "@intlayer/types/dictionary";
3
3
  import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
4
4
  //#region src/server/useDictionaryDynamic.d.ts
@@ -13,7 +13,7 @@ import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator"
13
13
  * If the locale is not provided (directly or through the selector), the server
14
14
  * context locale is used.
15
15
  */
16
- declare const useDictionaryDynamic: <const T extends Dictionary, const A extends DeclaredLocales | DictionarySelector = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: string, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => any;
16
+ declare const useDictionaryDynamic: <const T extends Dictionary, const A extends LocalesValues | DictionarySelector = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: string, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => any;
17
17
  //#endregion
18
18
  export { useDictionaryDynamic };
19
19
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -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,gBAAgB,qBAAqB,iBAAe,mBAGhE,0BAA0B,QAAQ,MAClC,2BAAyB,aAClB,mBACQ,GAAC,iBACH"}
@@ -1,5 +1,5 @@
1
1
  import { IInterpreterPluginState } from "../plugins.js";
2
- import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
  //#region src/server/useIntlayer.d.ts
4
4
  /**
5
5
  * On the server side, Hook that picking one dictionary by its key and return the content
@@ -9,7 +9,7 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey } from "@intl
9
9
  *
10
10
  * If the locale is not provided, it will use the locale from the server context
11
11
  */
12
- declare const useIntlayer: <const T extends DictionaryKeys, const A extends DeclaredLocales | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").DictionaryRegistryResult<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
12
+ declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => import("@intlayer/core/interpreter").DeepTransformContent<import("@intlayer/types").DictionaryRegistryResult<T, A>, IInterpreterPluginState, import("@intlayer/types").ExtractSelectorLocale<A>>;
13
13
  //#endregion
14
14
  export { useIntlayer };
15
15
  //# sourceMappingURL=useIntlayer.d.ts.map
@@ -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,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,GAAC,iBACH,yDAAe,+CAAA,yBAAA,GAAA,IAAA,mDAAA,sBAAA"}