react-intlayer 8.12.5-canary.0 → 9.0.0-canary.1

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 (55) hide show
  1. package/dist/cjs/client/useDictionary.cjs +14 -5
  2. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  3. package/dist/cjs/client/useDictionaryDynamic.cjs +23 -6
  4. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  5. package/dist/cjs/client/useIntlayer.cjs +17 -6
  6. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  7. package/dist/cjs/getDictionary.cjs +8 -1
  8. package/dist/cjs/getDictionary.cjs.map +1 -1
  9. package/dist/cjs/getIntlayer.cjs +8 -1
  10. package/dist/cjs/getIntlayer.cjs.map +1 -1
  11. package/dist/cjs/server/useDictionary.cjs +11 -4
  12. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  13. package/dist/cjs/server/useDictionaryDynamic.cjs +23 -6
  14. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  15. package/dist/cjs/server/useIntlayer.cjs +10 -2
  16. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  17. package/dist/esm/client/useDictionary.mjs +14 -5
  18. package/dist/esm/client/useDictionary.mjs.map +1 -1
  19. package/dist/esm/client/useDictionaryDynamic.mjs +24 -7
  20. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  21. package/dist/esm/client/useIntlayer.mjs +17 -6
  22. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  23. package/dist/esm/getDictionary.mjs +8 -1
  24. package/dist/esm/getDictionary.mjs.map +1 -1
  25. package/dist/esm/getIntlayer.mjs +8 -1
  26. package/dist/esm/getIntlayer.mjs.map +1 -1
  27. package/dist/esm/server/useDictionary.mjs +11 -4
  28. package/dist/esm/server/useDictionary.mjs.map +1 -1
  29. package/dist/esm/server/useDictionaryDynamic.mjs +23 -6
  30. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  31. package/dist/esm/server/useIntlayer.mjs +10 -2
  32. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  33. package/dist/types/client/useDictionary.d.ts +7 -4
  34. package/dist/types/client/useDictionary.d.ts.map +1 -1
  35. package/dist/types/client/useDictionaryDynamic.d.ts +11 -6
  36. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  37. package/dist/types/client/useIntlayer.d.ts +10 -5
  38. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  39. package/dist/types/getDictionary.d.ts +8 -3
  40. package/dist/types/getDictionary.d.ts.map +1 -1
  41. package/dist/types/getIntlayer.d.ts +7 -2
  42. package/dist/types/getIntlayer.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +1 -1
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/markdown/MarkdownRenderer.d.ts +1 -1
  46. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  47. package/dist/types/server/useDictionary.d.ts +7 -4
  48. package/dist/types/server/useDictionary.d.ts.map +1 -1
  49. package/dist/types/server/useDictionaryAsync.d.ts +2 -1
  50. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  51. package/dist/types/server/useDictionaryDynamic.d.ts +11 -6
  52. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  53. package/dist/types/server/useIntlayer.d.ts +5 -2
  54. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  55. package/package.json +10 -10
@@ -5,21 +5,30 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  const require_getDictionary = require('../getDictionary.cjs');
6
6
  const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
7
7
  let react = require("react");
8
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
8
9
 
9
10
  //#region src/client/useDictionary.ts
10
11
  /**
11
- * On the server side, Hook that transform a dictionary and return the content
12
+ * Client-side hook that transforms a dictionary (or qualified dictionary
13
+ * group) and returns the content.
12
14
  *
13
- * If the locale is not provided, it will use the locale from the client context
15
+ * If the locale is not provided (directly or through the selector), it will
16
+ * use the locale from the client context.
14
17
  */
15
- const useDictionary = (dictionary, locale) => {
18
+ const useDictionary = (dictionary, localeOrSelector) => {
16
19
  const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
20
+ const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
21
+ const localeOrSelectorIdentity = isSelector ? `${localeOrSelector.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(localeOrSelector)}` : localeOrSelector;
17
22
  return (0, react.useMemo)(() => {
18
- return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale);
23
+ if (isSelector) return require_getDictionary.getDictionary(dictionary, {
24
+ ...localeOrSelector,
25
+ locale: localeOrSelector.locale ?? currentLocale
26
+ });
27
+ return require_getDictionary.getDictionary(dictionary, localeOrSelector ?? currentLocale);
19
28
  }, [
20
29
  dictionary.key,
21
30
  currentLocale,
22
- locale
31
+ localeOrSelectorIdentity
23
32
  ]);
24
33
  };
25
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;AAEzE,iCAAqB;AAGnB,SAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
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 {\n DeclaredLocales,\n LocalesValues,\n} 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 | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n typeof localeOrSelector === 'object' && 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":";;;;;;;;;;;;;;;;;AAuBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;CAG/D,MAAM,2BAA2B,aAC7B,GAAG,iBAAiB,UAAU,GAAG,2EAAiC,iBAAiB,KACnF;AAEJ,iCAAqB;AACnB,MAAI,WACF,QAAOC,oCAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAKT,SAAOA,oCAAoB,YAFL,oBAAoB,cAEU;IACnD;EAAC,WAAW;EAAK;EAAe;EAAyB,CAAC"}
@@ -3,21 +3,38 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
6
+ const require_getDictionary = require('../getDictionary.cjs');
6
7
  const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
7
- const require_client_useDictionary = require('./useDictionary.cjs');
8
8
  let _intlayer_config_built = require("@intlayer/config/built");
9
9
  let react = require("react");
10
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
10
11
 
11
12
  //#region src/client/useDictionaryDynamic.ts
12
13
  /**
13
- * On the server side, Hook that transform a dictionary and return the content
14
+ * Client-side hook that lazily loads a dictionary and returns its content.
14
15
  *
15
- * If the locale is not provided, it will use the locale from the client context
16
+ * The dictionary entry is either a plain dynamic loader map
17
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
18
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
19
+ * the selector targets are loaded; the resolution mirrors static mode.
20
+ *
21
+ * If the locale is not provided (directly or through the selector), the client
22
+ * context locale is used.
16
23
  */
17
- const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
24
+ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
18
25
  const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
19
- const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.internationalization.defaultLocale, [currentLocale, locale]);
20
- return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
26
+ const { locale: selectorLocale, selector } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector);
27
+ const localeTarget = selectorLocale ?? currentLocale ?? _intlayer_config_built.internationalization.defaultLocale;
28
+ if ((0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(dictionaryPromise)) return (0, _intlayer_core_dictionaryManipulator.resolveQualifiedDynamicContent)({
29
+ loaderMap: dictionaryPromise,
30
+ key: String(key),
31
+ locale: localeTarget,
32
+ selector,
33
+ loadChunk: (cacheKey, promise) => require_client_useLoadDynamic.useLoadDynamic(cacheKey, promise),
34
+ transform: (dictionary) => require_getDictionary.getDictionary(dictionary, localeTarget)
35
+ });
36
+ const plainLoaders = dictionaryPromise;
37
+ return require_getDictionary.getDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, plainLoaders[localeTarget]?.()), localeTarget);
21
38
  };
22
39
 
23
40
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","internationalization","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,wCACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
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 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 LocalesValues | DictionarySelectorForKey<K> = LocalesValues,\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 parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\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,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,EAAE,QAAQ,gBAAgB,+EACS,iBAAiB;CAE1D,MAAM,eACJ,kBAAkB,iBAAiBC,4CAAqB;AAE1D,2EAAgC,kBAAkB,CAChD,iFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,IAAI;EAChB,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,QAAQ;EACrE,YAAY,eAAeC,oCAAc,YAAY,aAAa;EACnE,CAAC;CAGJ,MAAM,eAAe;AASrB,QAAOA,oCALYD,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBAClB,aAAa,iBAA8C,CAG9B,EAAE,aAAa"}
@@ -5,16 +5,21 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  const require_getIntlayer = require('../getIntlayer.cjs');
6
6
  const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
7
7
  let react = require("react");
8
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
8
9
 
9
10
  //#region src/client/useIntlayer.ts
10
11
  /**
11
12
  * Client-side hook that picks one dictionary by its key and returns its content.
12
13
  *
13
- * If the locale is not provided, it will use the locale from the client context.
14
+ * The second argument is either a locale or a selector object:
15
+ * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
16
+ * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
17
+ * - `{ id: 'prod_abc', ...metaFields }` — meta record
18
+ * - `locale` composes with any selector and overrides the context locale
14
19
  *
15
20
  * @param key - The unique key of the dictionary to retrieve.
16
- * @param locale - Optional locale to override the current context locale.
17
- * @returns The dictionary content for the specified locale.
21
+ * @param localeOrSelector - Optional locale or selector.
22
+ * @returns The dictionary content for the resolved entry and locale.
18
23
  *
19
24
  * @example
20
25
  * ```tsx
@@ -22,19 +27,25 @@ let react = require("react");
22
27
  *
23
28
  * const MyComponent = () => {
24
29
  * const content = useIntlayer('my-dictionary-key');
30
+ * const faq2 = useIntlayer('faq', { item: 2 });
25
31
  *
26
32
  * return <div>{content.myField.value}</div>;
27
33
  * };
28
34
  * ```
29
35
  */
30
- const useIntlayer = (key, locale) => {
36
+ const useIntlayer = (key, localeOrSelector) => {
31
37
  const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
38
+ const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
32
39
  return (0, react.useMemo)(() => {
33
- return require_getIntlayer.getIntlayer(key, locale ?? currentLocale);
40
+ if (isSelector) return require_getIntlayer.getIntlayer(key, {
41
+ ...localeOrSelector,
42
+ locale: localeOrSelector.locale ?? currentLocale
43
+ });
44
+ return require_getIntlayer.getIntlayer(key, localeOrSelector ?? currentLocale);
34
45
  }, [
35
46
  key,
36
47
  currentLocale,
37
- locale
48
+ isSelector ? `${localeOrSelector.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(localeOrSelector)}` : localeOrSelector
38
49
  ]);
39
50
  };
40
51
 
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\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 * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;AAEzE,iCAAqB;AAGnB,SAAOC,gCAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
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 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 * - `{ id: 'prod_abc', ...metaFields }` — meta record\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 LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n typeof localeOrSelector === 'object' && 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAO/D,iCAAqB;AACnB,MAAI,WACF,QAAOC,gCAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAKT,SAAOA,gCAAkB,KAFH,oBAAoB,cAEC;IAC1C;EAAC;EAAK;EAfwB,aAC7B,GAAG,iBAAiB,UAAU,GAAG,2EAAiC,iBAAiB,KACnF;EAa6C,CAAC"}
@@ -4,7 +4,14 @@ const require_plugins = require('./plugins.cjs');
4
4
  let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
5
5
 
6
6
  //#region src/getDictionary.ts
7
- const getDictionary = (dictionary, locale) => (0, _intlayer_core_interpreter.getDictionary)(dictionary, locale, require_plugins.getPlugins(locale));
7
+ /**
8
+ * Transforms a dictionary (or qualified dictionary group) and returns its
9
+ * content for the given locale or selector (`{ item }`, `{ variant }`,
10
+ * `{ id, ...meta }`, optionally combined with `locale`).
11
+ */
12
+ const getDictionary = (dictionary, localeOrSelector) => {
13
+ return (0, _intlayer_core_interpreter.getDictionary)(dictionary, localeOrSelector, require_plugins.getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
14
+ };
8
15
 
9
16
  //#endregion
10
17
  exports.getDictionary = getDictionary;
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;;AAQA,MAAa,iBAIX,YACA,yDAEkB,YAAY,QAAQA,2BAAW,OAAO,CAAC"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"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 * `{ id, ...meta }`, 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;AAOH,sDACE,YACA,kBACAA,2BARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAMc,CACnB"}
@@ -4,7 +4,14 @@ const require_plugins = require('./plugins.cjs');
4
4
  let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
5
5
 
6
6
  //#region src/getIntlayer.ts
7
- const getIntlayer = (key, locale) => (0, _intlayer_core_interpreter.getIntlayer)(key, locale, require_plugins.getPlugins(locale));
7
+ /**
8
+ * Picks one dictionary by its key and returns its content for the given
9
+ * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
10
+ * optionally combined with `locale`).
11
+ */
12
+ const getIntlayer = (key, localeOrSelector) => {
13
+ return (0, _intlayer_core_interpreter.getIntlayer)(key, localeOrSelector, require_plugins.getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
14
+ };
8
15
 
9
16
  //#endregion
10
17
  exports.getIntlayer = getIntlayer;
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;;AASA,MAAa,eAIX,KACA,uDAEgB,KAAK,QAAQA,2BAAW,OAAO,CAAC"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"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 }`, `{ id, ...meta }`,\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;AAOH,oDAAuB,KAAK,kBAAkBA,2BAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAG0D,CAAC"}
@@ -5,12 +5,19 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
5
5
 
6
6
  //#region src/server/useDictionary.ts
7
7
  /**
8
- * On the server side, Hook that transform a dictionary and return the content
8
+ * On the server side, Hook that transform a dictionary (or qualified
9
+ * dictionary group) and return the content
9
10
  *
10
- * If the locale is not provided, it will use the locale from the server context
11
+ * If the locale is not provided (directly or through the selector), it will
12
+ * use the locale from the server context
11
13
  */
12
- const useDictionary = (dictionary, locale, fallbackLocale) => {
13
- return require_getDictionary.getDictionary(dictionary, locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale);
14
+ const useDictionary = (dictionary, localeOrSelector, fallbackLocale) => {
15
+ const contextLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale;
16
+ if (typeof localeOrSelector === "object" && localeOrSelector !== null) return require_getDictionary.getDictionary(dictionary, {
17
+ ...localeOrSelector,
18
+ locale: localeOrSelector.locale ?? contextLocale
19
+ });
20
+ return require_getDictionary.getDictionary(dictionary, localeOrSelector ?? contextLocale);
14
21
  };
15
22
 
16
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["getDictionary","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } 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 and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,iBAIX,YACA,QACA,mBACG;AAMH,QAAOA,oCAAoB,YAJzB,UACAC,8CAAgCC,4DAAsB,IACtD,eAEuD"}
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 | 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 (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\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,4DAAsB,IAAI;AAE5D,KAAI,OAAO,qBAAqB,YAAY,qBAAqB,KAC/D,QAAOC,oCAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,oCAAoB,YAFL,oBAAoB,cAEU"}
@@ -1,20 +1,37 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_getDictionary = require('../getDictionary.cjs');
3
4
  const require_server_serverContext = require('./serverContext.cjs');
4
5
  const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
5
- const require_server_useDictionary = require('./useDictionary.cjs');
6
6
  const require_server_useLoadDynamic = require('./useLoadDynamic.cjs');
7
7
  let _intlayer_config_built = require("@intlayer/config/built");
8
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
8
9
 
9
10
  //#region src/server/useDictionaryDynamic.ts
10
11
  /**
11
- * On the server side, Hook that transform a dictionary and return the content
12
+ * Server-side hook that lazily loads a dictionary and returns its content.
12
13
  *
13
- * If the locale is not provided, it will use the locale from the server context
14
+ * The dictionary entry is either a plain dynamic loader map
15
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
16
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
17
+ * the selector targets are loaded; the resolution mirrors static mode.
18
+ *
19
+ * If the locale is not provided (directly or through the selector), the server
20
+ * context locale is used.
14
21
  */
15
- const useDictionaryDynamic = (dictionaryPromise, key, locale, fallbackLocale) => {
16
- const localeTarget = locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
17
- return require_server_useDictionary.useDictionary(require_server_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
22
+ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector, fallbackLocale) => {
23
+ const { locale: selectorLocale, selector } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector);
24
+ const localeTarget = selectorLocale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale ?? _intlayer_config_built.internationalization.defaultLocale;
25
+ if ((0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(dictionaryPromise)) return (0, _intlayer_core_dictionaryManipulator.resolveQualifiedDynamicContent)({
26
+ loaderMap: dictionaryPromise,
27
+ key: String(key),
28
+ locale: localeTarget,
29
+ selector,
30
+ loadChunk: (cacheKey, promise) => require_server_useLoadDynamic.useLoadDynamic(cacheKey, promise),
31
+ transform: (dictionary) => require_getDictionary.getDictionary(dictionary, localeTarget)
32
+ });
33
+ const plainLoaders = dictionaryPromise;
34
+ return require_getDictionary.getDictionary(require_server_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, plainLoaders[localeTarget]?.()), localeTarget);
18
35
  };
19
36
 
20
37
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","internationalization","useDictionary","useLoadDynamic"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,wBAIX,mBACA,KACA,QACA,mBACG;CACH,MAAM,eACJ,UACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAOvB,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGT,EAAE,aAAkB"}
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 LocalesValues | DictionarySelector = LocalesValues,\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 parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\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,+EACS,iBAAiB;CAE1D,MAAM,eACJ,kBACAA,8CAAgCC,4DAAsB,IACtD,kBACAC,4CAAqB;AAEvB,2EAAgC,kBAAkB,CAChD,iFAAsC;EACpC,WAAW;EACX,KAAK,OAAO,IAAI;EAChB,QAAQ;EACR;EACA,YAAY,UAAU,YAAYC,6CAAiB,UAAU,QAAQ;EACrE,YAAY,eAAeC,oCAAc,YAAY,aAAa;EACnE,CAAC;CAGJ,MAAM,eAAe;AASrB,QAAOA,oCALYD,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBAClB,aAAa,iBAA8C,CAG9B,EAAE,aAAa"}
@@ -7,10 +7,18 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
7
7
  /**
8
8
  * On the server side, Hook that picking one dictionary by its key and return the content
9
9
  *
10
+ * The second argument is either a locale or a selector object
11
+ * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
12
+ *
10
13
  * If the locale is not provided, it will use the locale from the server context
11
14
  */
12
- const useIntlayer = (key, locale, fallbackLocale) => {
13
- return require_getIntlayer.getIntlayer(key, locale ?? require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale);
15
+ const useIntlayer = (key, localeOrSelector, fallbackLocale) => {
16
+ const contextLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext) ?? fallbackLocale;
17
+ if (typeof localeOrSelector === "object" && localeOrSelector !== null) return require_getIntlayer.getIntlayer(key, {
18
+ ...localeOrSelector,
19
+ locale: localeOrSelector.locale ?? contextLocale
20
+ });
21
+ return require_getIntlayer.getIntlayer(key, localeOrSelector ?? contextLocale);
14
22
  };
15
23
 
16
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["getIntlayer","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\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 * 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 L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getIntlayer<T, L>(key, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,eAIX,KACA,QACA,mBACG;AAMH,QAAOA,gCAAkB,KAJvB,UACAC,8CAAgCC,4DAAsB,IACtD,eAE8C"}
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 }`, `{ id, ...meta }`, 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 (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\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,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,4DAAsB,IAAI;AAE5D,KAAI,OAAO,qBAAqB,YAAY,qBAAqB,KAC/D,QAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,gCAAkB,KAFH,oBAAoB,cAEC"}
@@ -3,21 +3,30 @@
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
7
 
7
8
  //#region src/client/useDictionary.ts
8
9
  /**
9
- * On the server side, Hook that transform a dictionary and return the content
10
+ * Client-side hook that transforms a dictionary (or qualified dictionary
11
+ * group) and returns the content.
10
12
  *
11
- * If the locale is not provided, it will use the locale from the client context
13
+ * If the locale is not provided (directly or through the selector), it will
14
+ * use the locale from the client context.
12
15
  */
13
- const useDictionary = (dictionary, locale) => {
16
+ const useDictionary = (dictionary, localeOrSelector) => {
14
17
  const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
18
+ const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
19
+ const localeOrSelectorIdentity = isSelector ? `${localeOrSelector.locale ?? ""}|${getDictionarySelectorCacheKey(localeOrSelector)}` : localeOrSelector;
15
20
  return useMemo(() => {
16
- return getDictionary(dictionary, locale ?? currentLocale);
21
+ if (isSelector) return getDictionary(dictionary, {
22
+ ...localeOrSelector,
23
+ locale: localeOrSelector.locale ?? currentLocale
24
+ });
25
+ return getDictionary(dictionary, localeOrSelector ?? currentLocale);
17
26
  }, [
18
27
  dictionary.key,
19
28
  currentLocale,
20
- locale
29
+ localeOrSelectorIdentity
21
30
  ]);
22
31
  };
23
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;AAEzE,QAAO,cAAc;AAGnB,SAAO,cAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
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 {\n DeclaredLocales,\n LocalesValues,\n} 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 | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n typeof localeOrSelector === 'object' && 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":";;;;;;;;;;;;;;;AAuBA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;CAG/D,MAAM,2BAA2B,aAC7B,GAAG,iBAAiB,UAAU,GAAG,GAAG,8BAA8B,iBAAiB,KACnF;AAEJ,QAAO,cAAc;AACnB,MAAI,WACF,QAAO,cAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAKT,SAAO,cAAoB,YAFL,oBAAoB,cAEU;IACnD;EAAC,WAAW;EAAK;EAAe;EAAyB,CAAC"}
@@ -1,21 +1,38 @@
1
1
  'use client';
2
2
 
3
3
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
4
+ import { getDictionary } from "../getDictionary.mjs";
4
5
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
- import { useDictionary } from "./useDictionary.mjs";
6
6
  import { internationalization } from "@intlayer/config/built";
7
- import { useContext, useMemo } from "react";
7
+ import { useContext } from "react";
8
+ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
8
9
 
9
10
  //#region src/client/useDictionaryDynamic.ts
10
11
  /**
11
- * On the server side, Hook that transform a dictionary and return the content
12
+ * Client-side hook that lazily loads a dictionary and returns its content.
12
13
  *
13
- * If the locale is not provided, it will use the locale from the client context
14
+ * The dictionary entry is either a plain dynamic loader map
15
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
16
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
17
+ * the selector targets are loaded; the resolution mirrors static mode.
18
+ *
19
+ * If the locale is not provided (directly or through the selector), the client
20
+ * context locale is used.
14
21
  */
15
- const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
22
+ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
16
23
  const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
17
- const localeTarget = useMemo(() => locale ?? currentLocale ?? internationalization.defaultLocale, [currentLocale, locale]);
18
- return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
24
+ const { locale: selectorLocale, selector } = parseDictionarySelector(localeOrSelector);
25
+ const localeTarget = selectorLocale ?? currentLocale ?? internationalization.defaultLocale;
26
+ if (isQualifiedDynamicLoaderMap(dictionaryPromise)) return resolveQualifiedDynamicContent({
27
+ loaderMap: dictionaryPromise,
28
+ key: String(key),
29
+ locale: localeTarget,
30
+ selector,
31
+ loadChunk: (cacheKey, promise) => useLoadDynamic(cacheKey, promise),
32
+ transform: (dictionary) => getDictionary(dictionary, localeTarget)
33
+ });
34
+ const plainLoaders = dictionaryPromise;
35
+ return getDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, plainLoaders[localeTarget]?.()), localeTarget);
19
36
  };
20
37
 
21
38
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
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 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 LocalesValues | DictionarySelectorForKey<K> = LocalesValues,\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 parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ?? currentLocale ?? internationalization.defaultLocale;\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\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,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,wBAAuC,iBAAiB;CAE1D,MAAM,eACJ,kBAAkB,iBAAiB,qBAAqB;AAE1D,KAAI,4BAA4B,kBAAkB,CAChD,QAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,IAAI;EAChB,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,QAAQ;EACrE,YAAY,eAAe,cAAc,YAAY,aAAa;EACnE,CAAC;CAGJ,MAAM,eAAe;AASrB,QAAO,cALYA,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBAClB,aAAa,iBAA8C,CAG9B,EAAE,aAAa"}
@@ -3,16 +3,21 @@
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
7
 
7
8
  //#region src/client/useIntlayer.ts
8
9
  /**
9
10
  * Client-side hook that picks one dictionary by its key and returns its content.
10
11
  *
11
- * If the locale is not provided, it will use the locale from the client context.
12
+ * The second argument is either a locale or a selector object:
13
+ * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
14
+ * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
15
+ * - `{ id: 'prod_abc', ...metaFields }` — meta record
16
+ * - `locale` composes with any selector and overrides the context locale
12
17
  *
13
18
  * @param key - The unique key of the dictionary to retrieve.
14
- * @param locale - Optional locale to override the current context locale.
15
- * @returns The dictionary content for the specified locale.
19
+ * @param localeOrSelector - Optional locale or selector.
20
+ * @returns The dictionary content for the resolved entry and locale.
16
21
  *
17
22
  * @example
18
23
  * ```tsx
@@ -20,19 +25,25 @@ import { useContext, useMemo } from "react";
20
25
  *
21
26
  * const MyComponent = () => {
22
27
  * const content = useIntlayer('my-dictionary-key');
28
+ * const faq2 = useIntlayer('faq', { item: 2 });
23
29
  *
24
30
  * return <div>{content.myField.value}</div>;
25
31
  * };
26
32
  * ```
27
33
  */
28
- const useIntlayer = (key, locale) => {
34
+ const useIntlayer = (key, localeOrSelector) => {
29
35
  const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
36
+ const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
30
37
  return useMemo(() => {
31
- return getIntlayer(key, locale ?? currentLocale);
38
+ if (isSelector) return getIntlayer(key, {
39
+ ...localeOrSelector,
40
+ locale: localeOrSelector.locale ?? currentLocale
41
+ });
42
+ return getIntlayer(key, localeOrSelector ?? currentLocale);
32
43
  }, [
33
44
  key,
34
45
  currentLocale,
35
- locale
46
+ isSelector ? `${localeOrSelector.locale ?? ""}|${getDictionarySelectorCacheKey(localeOrSelector)}` : localeOrSelector
36
47
  ]);
37
48
  };
38
49
 
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\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 * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;AAEzE,QAAO,cAAc;AAGnB,SAAO,YAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
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 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 * - `{ id: 'prod_abc', ...metaFields }` — meta record\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 LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const isSelector =\n typeof localeOrSelector === 'object' && 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAO/D,QAAO,cAAc;AACnB,MAAI,WACF,QAAO,YAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAKT,SAAO,YAAkB,KAFH,oBAAoB,cAEC;IAC1C;EAAC;EAAK;EAfwB,aAC7B,GAAG,iBAAiB,UAAU,GAAG,GAAG,8BAA8B,iBAAiB,KACnF;EAa6C,CAAC"}
@@ -2,7 +2,14 @@ import { getPlugins } from "./plugins.mjs";
2
2
  import { getDictionary as getDictionary$1 } from "@intlayer/core/interpreter";
3
3
 
4
4
  //#region src/getDictionary.ts
5
- const getDictionary = (dictionary, locale) => getDictionary$1(dictionary, locale, getPlugins(locale));
5
+ /**
6
+ * Transforms a dictionary (or qualified dictionary group) and returns its
7
+ * content for the given locale or selector (`{ item }`, `{ variant }`,
8
+ * `{ id, ...meta }`, optionally combined with `locale`).
9
+ */
10
+ const getDictionary = (dictionary, localeOrSelector) => {
11
+ return getDictionary$1(dictionary, localeOrSelector, getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
12
+ };
6
13
 
7
14
  //#endregion
8
15
  export { getDictionary };
@@ -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 { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AAQA,MAAa,iBAIX,YACA,WAEAA,gBAAkB,YAAY,QAAQ,WAAW,OAAO,CAAC"}
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 * `{ id, ...meta }`, 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;AAOH,QAAOA,gBACL,YACA,kBACA,WARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAMc,CACnB"}
@@ -2,7 +2,14 @@ import { getPlugins } from "./plugins.mjs";
2
2
  import { getIntlayer as getIntlayer$1 } from "@intlayer/core/interpreter";
3
3
 
4
4
  //#region src/getIntlayer.ts
5
- const getIntlayer = (key, locale) => getIntlayer$1(key, locale, getPlugins(locale));
5
+ /**
6
+ * Picks one dictionary by its key and returns its content for the given
7
+ * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
8
+ * optionally combined with `locale`).
9
+ */
10
+ const getIntlayer = (key, localeOrSelector) => {
11
+ return getIntlayer$1(key, localeOrSelector, getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
12
+ };
6
13
 
7
14
  //#endregion
8
15
  export { getIntlayer };
@@ -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 DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AASA,MAAa,eAIX,KACA,WAEAA,cAAgB,KAAK,QAAQ,WAAW,OAAO,CAAC"}
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 }`, `{ id, ...meta }`,\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;AAOH,QAAOA,cAAgB,KAAK,kBAAkB,WAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAG0D,CAAC"}
@@ -4,12 +4,19 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
4
4
 
5
5
  //#region src/server/useDictionary.ts
6
6
  /**
7
- * On the server side, Hook that transform a dictionary and return the content
7
+ * On the server side, Hook that transform a dictionary (or qualified
8
+ * dictionary group) and return the content
8
9
  *
9
- * If the locale is not provided, it will use the locale from the server context
10
+ * If the locale is not provided (directly or through the selector), it will
11
+ * use the locale from the server context
10
12
  */
11
- const useDictionary = (dictionary, locale, fallbackLocale) => {
12
- return getDictionary(dictionary, locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale);
13
+ const useDictionary = (dictionary, localeOrSelector, fallbackLocale) => {
14
+ const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
15
+ if (typeof localeOrSelector === "object" && localeOrSelector !== null) return getDictionary(dictionary, {
16
+ ...localeOrSelector,
17
+ locale: localeOrSelector.locale ?? contextLocale
18
+ });
19
+ return getDictionary(dictionary, localeOrSelector ?? contextLocale);
13
20
  };
14
21
 
15
22
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } 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 and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,iBAIX,YACA,QACA,mBACG;AAMH,QAAO,cAAoB,YAJzB,UACA,iBAAgC,sBAAsB,IACtD,eAEuD"}
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 | 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 (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\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,sBAAsB,IAAI;AAE5D,KAAI,OAAO,qBAAqB,YAAY,qBAAqB,KAC/D,QAAO,cAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAO,cAAoB,YAFL,oBAAoB,cAEU"}
@@ -1,18 +1,35 @@
1
+ import { getDictionary } from "../getDictionary.mjs";
1
2
  import { getServerContext } from "./serverContext.mjs";
2
3
  import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
- import { useDictionary } from "./useDictionary.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
7
 
7
8
  //#region src/server/useDictionaryDynamic.ts
8
9
  /**
9
- * On the server side, Hook that transform a dictionary and return the content
10
+ * Server-side hook that lazily loads a dictionary and returns its content.
10
11
  *
11
- * If the locale is not provided, it will use the locale from the server context
12
+ * The dictionary entry is either a plain dynamic loader map
13
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
14
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
15
+ * the selector targets are loaded; the resolution mirrors static mode.
16
+ *
17
+ * If the locale is not provided (directly or through the selector), the server
18
+ * context locale is used.
12
19
  */
13
- const useDictionaryDynamic = (dictionaryPromise, key, locale, fallbackLocale) => {
14
- const localeTarget = locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
15
- return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
20
+ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector, fallbackLocale) => {
21
+ const { locale: selectorLocale, selector } = parseDictionarySelector(localeOrSelector);
22
+ const localeTarget = selectorLocale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
23
+ if (isQualifiedDynamicLoaderMap(dictionaryPromise)) return resolveQualifiedDynamicContent({
24
+ loaderMap: dictionaryPromise,
25
+ key: String(key),
26
+ locale: localeTarget,
27
+ selector,
28
+ loadChunk: (cacheKey, promise) => useLoadDynamic(cacheKey, promise),
29
+ transform: (dictionary) => getDictionary(dictionary, localeTarget)
30
+ });
31
+ const plainLoaders = dictionaryPromise;
32
+ return getDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, plainLoaders[localeTarget]?.()), localeTarget);
16
33
  };
17
34
 
18
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,wBAIX,mBACA,KACA,QACA,mBACG;CACH,MAAM,eACJ,UACA,iBAAgC,sBAAsB,IACtD,kBACA,qBAAqB;AAOvB,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGT,EAAE,aAAkB"}
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 LocalesValues | DictionarySelector = LocalesValues,\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 parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\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,wBAAuC,iBAAiB;CAE1D,MAAM,eACJ,kBACA,iBAAgC,sBAAsB,IACtD,kBACA,qBAAqB;AAEvB,KAAI,4BAA4B,kBAAkB,CAChD,QAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,IAAI;EAChB,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,QAAQ;EACrE,YAAY,eAAe,cAAc,YAAY,aAAa;EACnE,CAAC;CAGJ,MAAM,eAAe;AASrB,QAAO,cALYA,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBAClB,aAAa,iBAA8C,CAG9B,EAAE,aAAa"}
@@ -6,10 +6,18 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
6
6
  /**
7
7
  * On the server side, Hook that picking one dictionary by its key and return the content
8
8
  *
9
+ * The second argument is either a locale or a selector object
10
+ * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
11
+ *
9
12
  * If the locale is not provided, it will use the locale from the server context
10
13
  */
11
- const useIntlayer = (key, locale, fallbackLocale) => {
12
- return getIntlayer(key, locale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale);
14
+ const useIntlayer = (key, localeOrSelector, fallbackLocale) => {
15
+ const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
16
+ if (typeof localeOrSelector === "object" && localeOrSelector !== null) return getIntlayer(key, {
17
+ ...localeOrSelector,
18
+ locale: localeOrSelector.locale ?? contextLocale
19
+ });
20
+ return getIntlayer(key, localeOrSelector ?? contextLocale);
13
21
  };
14
22
 
15
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\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 * 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 L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getIntlayer<T, L>(key, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,eAIX,KACA,QACA,mBACG;AAMH,QAAO,YAAkB,KAJvB,UACA,iBAAgC,sBAAsB,IACtD,eAE8C"}
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 }`, `{ id, ...meta }`, 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 (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\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,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,sBAAsB,IAAI;AAE5D,KAAI,OAAO,qBAAqB,YAAY,qBAAqB,KAC/D,QAAO,YAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAO,YAAkB,KAFH,oBAAoB,cAEC"}
@@ -1,15 +1,18 @@
1
1
  import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
2
  import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
3
  import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
4
- import { Dictionary } from "@intlayer/types/dictionary";
4
+ import * as _$_intlayer_types0 from "@intlayer/types";
5
+ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
5
6
 
6
7
  //#region src/client/useDictionary.d.ts
7
8
  /**
8
- * On the server side, Hook that transform a dictionary and return the content
9
+ * Client-side hook that transforms a dictionary (or qualified dictionary
10
+ * group) and returns the content.
9
11
  *
10
- * If the locale is not provided, it will use the locale from the client context
12
+ * If the locale is not provided (directly or through the selector), it will
13
+ * use the locale from the client context.
11
14
  */
12
- declare const useDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, L>;
15
+ declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState$1, _$_intlayer_types0.ExtractSelectorLocale<A>>;
13
16
  //#endregion
14
17
  export { useDictionary };
15
18
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;AAgBA;cAAa,aAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;;;;;AAuBA;;cAAa,aAAA,mBACK,UAAA,GAAa,wBAAA,kBAEzB,aAAA,GACA,0BAAA,CAA2B,CAAA,IAAK,eAAA,EAEpC,UAAA,EAAY,CAAA,EACZ,gBAAA,GAAmB,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,iCAAA,CAAA,CAAA,EAAA,CAAA,GAAA,yBAAA,EAAA,kBAAA,CAAA,qBAAA,CAAA,CAAA"}
@@ -1,15 +1,20 @@
1
- import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
- import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
- import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
1
+ import { DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
4
2
  import { Dictionary } from "@intlayer/types/dictionary";
3
+ import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
5
4
 
6
5
  //#region src/client/useDictionaryDynamic.d.ts
7
6
  /**
8
- * On the server side, Hook that transform a dictionary and return the content
7
+ * Client-side hook that lazily loads a dictionary and returns its content.
9
8
  *
10
- * If the locale is not provided, it will use the locale from the client context
9
+ * The dictionary entry is either a plain dynamic loader map
10
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
11
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
12
+ * the selector targets are loaded; the resolution mirrors static mode.
13
+ *
14
+ * If the locale is not provided (directly or through the selector), the client
15
+ * context locale is used.
11
16
  */
12
- declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, any>;
17
+ declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = LocalesValues>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => any;
13
18
  //#endregion
14
19
  export { useDictionaryDynamic };
15
20
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;AAmBA;cAAa,oBAAA,mBACK,UAAA,kBACA,cAAA,EAEhB,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KAAa,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;AAmCA;;;;;;;;;cAAa,oBAAA,mBACK,UAAA,kBACA,cAAA,kBACA,aAAA,GAAgB,wBAAA,CAAyB,CAAA,IAAK,aAAA,EAE9D,iBAAA,EACI,mBAAA,OAA0B,OAAA,CAAQ,CAAA,KAClC,yBAAA,EACJ,GAAA,EAAK,CAAA,EACL,gBAAA,GAAmB,CAAA"}
@@ -1,17 +1,21 @@
1
1
  import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
2
  import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
- import { DeclaredLocales, DictionaryKeys, LocalesValues } from "@intlayer/types/module_augmentation";
3
+ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues } from "@intlayer/types/module_augmentation";
4
4
  import * as _$_intlayer_types0 from "@intlayer/types";
5
5
 
6
6
  //#region src/client/useIntlayer.d.ts
7
7
  /**
8
8
  * Client-side hook that picks one dictionary by its key and returns its content.
9
9
  *
10
- * If the locale is not provided, it will use the locale from the client context.
10
+ * The second argument is either a locale or a selector object:
11
+ * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
12
+ * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
13
+ * - `{ id: 'prod_abc', ...metaFields }` — meta record
14
+ * - `locale` composes with any selector and overrides the context locale
11
15
  *
12
16
  * @param key - The unique key of the dictionary to retrieve.
13
- * @param locale - Optional locale to override the current context locale.
14
- * @returns The dictionary content for the specified locale.
17
+ * @param localeOrSelector - Optional locale or selector.
18
+ * @returns The dictionary content for the resolved entry and locale.
15
19
  *
16
20
  * @example
17
21
  * ```tsx
@@ -19,12 +23,13 @@ import * as _$_intlayer_types0 from "@intlayer/types";
19
23
  *
20
24
  * const MyComponent = () => {
21
25
  * const content = useIntlayer('my-dictionary-key');
26
+ * const faq2 = useIntlayer('faq', { item: 2 });
22
27
  *
23
28
  * return <div>{content.myField.value}</div>;
24
29
  * };
25
30
  * ```
26
31
  */
27
- declare const useIntlayer: <const T extends DictionaryKeys, const L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.DictionaryRegistryContent<T>, IInterpreterPluginState$1, L>;
32
+ declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.DictionaryRegistryResult<T, A>, IInterpreterPluginState$1, _$_intlayer_types0.ExtractSelectorLocale<A>>;
28
33
  //#endregion
29
34
  export { useIntlayer };
30
35
  //# sourceMappingURL=useIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;AA+BA;;;;;;;;;;;;;;;cAAa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,yBAAA,CAAA,CAAA,GAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;AAsCA;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,wBAAA,CAAyB,CAAA,IAAK,eAAA,EAE9D,GAAA,EAAK,CAAA,EACL,gBAAA,GAAmB,CAAA,KAAC,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,wBAAA,CAAA,CAAA,EAAA,CAAA,GAAA,yBAAA,EAAA,kBAAA,CAAA,qBAAA,CAAA,CAAA"}
@@ -1,9 +1,14 @@
1
1
  import { DeepTransformContent } from "./plugins.js";
2
- import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
3
- import { Dictionary } from "@intlayer/types/dictionary";
2
+ import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
+ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
4
4
 
5
5
  //#region src/getDictionary.d.ts
6
- declare const getDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"], L>;
6
+ /**
7
+ * Transforms a dictionary (or qualified dictionary group) and returns its
8
+ * content for the given locale or selector (`{ item }`, `{ variant }`,
9
+ * `{ id, ...meta }`, optionally combined with `locale`).
10
+ */
11
+ 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>>;
7
12
  //#endregion
8
13
  export { getDictionary };
9
14
  //# sourceMappingURL=getDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;cAQa,aAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KACR,oBAAA,CAAqB,CAAA,aAAc,CAAA"}
1
+ {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;;;AAmBA;;;cAAa,aAAA,mBACK,UAAA,GAAa,wBAAA,kBAEzB,aAAA,GACA,0BAAA,CAA2B,CAAA,IAAK,eAAA,EAEpC,UAAA,EAAY,CAAA,EACZ,gBAAA,GAAmB,CAAA,KAClB,oBAAA,CACD,iCAAA,CAAkC,CAAA,EAAG,CAAA,GACrC,qBAAA,CAAsB,CAAA"}
@@ -1,8 +1,13 @@
1
1
  import { DeepTransformContent } from "./plugins.js";
2
- import { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent, LocalesValues } from "@intlayer/types/module_augmentation";
2
+ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
3
 
4
4
  //#region src/getIntlayer.d.ts
5
- declare const getIntlayer: <const T extends DictionaryKeys, const L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>, L>;
5
+ /**
6
+ * Picks one dictionary by its key and returns its content for the given
7
+ * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
8
+ * optionally combined with `locale`).
9
+ */
10
+ declare const getIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
6
11
  //#endregion
7
12
  export { getIntlayer };
8
13
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;cASa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KACR,oBAAA,CAAqB,yBAAA,CAA0B,CAAA,GAAI,CAAA"}
1
+ {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;;;AAgBA;;;cAAa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,wBAAA,CAAyB,CAAA,IAAK,eAAA,EAE9D,GAAA,EAAK,CAAA,EACL,gBAAA,GAAmB,CAAA,KAClB,oBAAA,CACD,wBAAA,CAAyB,CAAA,EAAG,CAAA,GAC5B,qBAAA,CAAsB,CAAA"}
@@ -71,7 +71,7 @@ declare const useMarkdownRenderer: ({
71
71
  forceInline,
72
72
  preserveFrontmatter,
73
73
  tagfilter
74
- }?: RenderMarkdownProps$1) => (content: string | _$_intlayer_core_markdown0.ParsedMarkdown) => string | number | bigint | boolean | Iterable<_$react.ReactNode> | Promise<_$react.ReactNode> | _$react.JSX.Element;
74
+ }?: RenderMarkdownProps$1) => (content: string | _$_intlayer_core_markdown0.ParsedMarkdown) => string | number | bigint | boolean | Iterable<_$react.ReactNode> | _$react.JSX.Element | Promise<_$react.ReactNode>;
75
75
  /**
76
76
  * @deprecated import from react-intlayer/markdown instead
77
77
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,uBAAA,CAAwB,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;;;;;;;cAqD7B,gBAAA,UAAgB,EAAA,CAAA,yBAAA;eAAA,cAAA;;4FAxBlB,yBAAA,EAAA,UAAA,GAAA,cAAA,oBAEG,OAAA,GAEN,OAAA,CAAA,EAAA,CAAA,OAAA,CAAA,cAAA,CAAA,WAAA,OAAA,OAAA,CAAA,SAAA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;AAAA;aAAA,OAAA,CAAA,SAAA;AAAA;;;;cAwBK,kBAAA;eAAwC,cAAA;2FAvCG,yBAAA,EAAA,UAAA,GAAA,cAAA,oBAC5B,OAAA,GACI,OAAA,CAAA,EAAA,CAAA,OAAA,CAAA,cAAA,CAAA,WAAA,OAAA,OAAA,CAAA,SAAA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;AAAA;;;;KAyCpB,uBAAA,GAA0B,yBAAA;AARtC;;;AAAA,cAYa,cAAA,GAAc,OAAA,WAAkB,0BAAA,CAAlB,cAAA;EAAA,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,KAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;;;cAId,mBAAA;EAAmB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,MAak1C,OAAA,WAbl1C,0BAAA,CAak1C,cAAA,0CAAgC,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;;;cATr4C,gBAAA,EAAgB,OAAA,CAAA,EAAA,CAAA,uBAAA;;;;KAIjB,mBAAA,GAAsB,qBAAA;;;;KAItB,qBAAA,GAAwB,uBAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAIY,kBAAA,iBAAmC,aAAA,UACnC,uBAAA,CAAwB,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;;;;;;;cAqD7B,gBAAA,UAAgB,EAAA,CAAA,yBAAA;eAAA,cAAA;;4FAxBlB,yBAAA,EAAA,UAAA,GAAA,cAAA,oBAEG,OAAA,GAEN,OAAA,CAAA,EAAA,CAAA,OAAA,CAAA,cAAA,CAAA,WAAA,OAAA,OAAA,CAAA,SAAA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;AAAA;aAAA,OAAA,CAAA,SAAA;AAAA;;;;cAwBK,kBAAA;eAAwC,cAAA;2FAvCG,yBAAA,EAAA,UAAA,GAAA,cAAA,oBAC5B,OAAA,GACI,OAAA,CAAA,EAAA,CAAA,OAAA,CAAA,cAAA,CAAA,WAAA,OAAA,OAAA,CAAA,SAAA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;AAAA;;;;KAyCpB,uBAAA,GAA0B,yBAAA;AARtC;;;AAAA,cAYa,cAAA,GAAc,OAAA,WAAkB,0BAAA,CAAlB,cAAA;EAAA,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,KAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;;;cAId,mBAAA;EAAmB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAAA,qBAAA,MAak1C,OAAA,WAbl1C,0BAAA,CAak1C,cAAA,0CAAgC,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,CAAA,GAAA,CAAA,OAAA,GAAA,OAAA,CAAA,OAAA,CAAA,SAAA;;;;cATr4C,gBAAA,EAAgB,OAAA,CAAA,EAAA,CAAA,uBAAA;;;;KAIjB,mBAAA,GAAsB,qBAAA;;;;KAItB,qBAAA,GAAwB,uBAAA"}
@@ -134,7 +134,7 @@ declare const useMarkdownRenderer: ({
134
134
  forceInline,
135
135
  preserveFrontmatter,
136
136
  tagfilter
137
- }?: RenderMarkdownProps) => (content: string | ParsedMarkdown) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<ReactNode> | JSX.Element;
137
+ }?: RenderMarkdownProps) => (content: string | ParsedMarkdown) => string | number | bigint | boolean | Iterable<ReactNode> | JSX.Element | Promise<ReactNode>;
138
138
  /**
139
139
  * Props for the MarkdownRenderer component.
140
140
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;;AAiCA;;;;;;;;;;;;;;;;;KAAY,mBAAA,GAAsB,uBAAA;EAwBO;AA4BzC;;;;;;;;;;;;EAtCE,UAAA,GAAa,cAAA;EA6Dd;;;;;;;;;EAnDC,OAAA,GAAU,EAAA,CAAG,cAAA,CAAe,WAAA;AAAA;;;;;;;;;;AAkG9B;;;;;;;;;;;;;;;;cAtEa,cAAA,GACX,OAAA,WAAkB,cAAA;EAClB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOG,mBAAA,KACF,GAAA,CAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;AA+GP;;;;;;;;;;;;;;;;;;;;;cAnDa,mBAAA;EAAuB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOjC,mBAAA,MAGO,OAAA,WAAkB,cAAA,0CAAc,QAAA,CAAA,SAAA,IAAA,OAAA,CAAA,SAAA,IAAA,GAAA,CAAA,OAAA;;;;;;;;;;;;AAmJ1C;;;;KA1GY,qBAAA,GAAwB,mBAAA;;;;;;;;;;;EAWlC,QAAA,WAAmB,cAAA;;;;;;;;;;;;;;;;;;;;;EAqBnB,cAAA,IACE,QAAA,WAAmB,cAAA,EACnB,OAAA;IACE,UAAA,GAAa,cAAA;IACb,OAAA,GAAU,EAAA;IACV,UAAA;IACA,WAAA;IACA,mBAAA;IACA,SAAA;EAAA,MAEC,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgEd,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
1
+ {"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;;AAiCA;;;;;;;;;;;;;;;;;KAAY,mBAAA,GAAsB,uBAAA;EAwBO;AA4BzC;;;;;;;;;;;;EAtCE,UAAA,GAAa,cAAA;EA6Dd;;;;;;;;;EAnDC,OAAA,GAAU,EAAA,CAAG,cAAA,CAAe,WAAA;AAAA;;;;;;;;;;AAkG9B;;;;;;;;;;;;;;;;cAtEa,cAAA,GACX,OAAA,WAAkB,cAAA;EAClB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOG,mBAAA,KACF,GAAA,CAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;AA+GP;;;;;;;;;;;;;;;;;;;;;cAnDa,mBAAA;EAAuB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOjC,mBAAA,MAGO,OAAA,WAAkB,cAAA,0CAAc,QAAA,CAAA,SAAA,IAAA,GAAA,CAAA,OAAA,GAAA,OAAA,CAAA,SAAA;;;;;;;;;;;;AAmJ1C;;;;KA1GY,qBAAA,GAAwB,mBAAA;;;;;;;;;;;EAWlC,QAAA,WAAmB,cAAA;;;;;;;;;;;;;;;;;;;;;EAqBnB,cAAA,IACE,QAAA,WAAmB,cAAA,EACnB,OAAA;IACE,UAAA,GAAa,cAAA;IACb,OAAA,GAAU,EAAA;IACV,UAAA;IACA,WAAA;IACA,mBAAA;IACA,SAAA;EAAA,MAEC,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgEd,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
@@ -1,15 +1,18 @@
1
1
  import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
2
  import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
3
  import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
4
- import { Dictionary } from "@intlayer/types/dictionary";
4
+ import * as _$_intlayer_types0 from "@intlayer/types";
5
+ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
5
6
 
6
7
  //#region src/server/useDictionary.d.ts
7
8
  /**
8
- * On the server side, Hook that transform a dictionary and return the content
9
+ * On the server side, Hook that transform a dictionary (or qualified
10
+ * dictionary group) and return the content
9
11
  *
10
- * If the locale is not provided, it will use the locale from the server context
12
+ * If the locale is not provided (directly or through the selector), it will
13
+ * use the locale from the server context
11
14
  */
12
- declare const useDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L, fallbackLocale?: DeclaredLocales) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, L>;
15
+ declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState$1, _$_intlayer_types0.ExtractSelectorLocale<A>>;
13
16
  //#endregion
14
17
  export { useDictionary };
15
18
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;AAcA;cAAa,aAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;;;AAoBA;;cAAa,aAAA,mBACK,UAAA,GAAa,wBAAA,kBAEzB,aAAA,GACA,0BAAA,CAA2B,CAAA,IAAK,eAAA,EAEpC,UAAA,EAAY,CAAA,EACZ,gBAAA,GAAmB,CAAA,EACnB,cAAA,GAAiB,eAAA,KAAe,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,iCAAA,CAAA,CAAA,EAAA,CAAA,GAAA,yBAAA,EAAA,kBAAA,CAAA,qBAAA,CAAA,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
2
  import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
3
  import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
4
+ import * as _$_intlayer_types0 from "@intlayer/types";
4
5
  import { Dictionary } from "@intlayer/types/dictionary";
5
6
 
6
7
  //#region src/server/useDictionaryAsync.d.ts
@@ -9,7 +10,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
9
10
  *
10
11
  * If the locale is not provided, it will use the locale from the server context
11
12
  */
12
- declare const useDictionaryAsync: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L, fallbackLocale?: DeclaredLocales) => Promise<_$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, L>>;
13
+ declare const useDictionaryAsync: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L, fallbackLocale?: DeclaredLocales) => Promise<_$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.ResolveQualifiedDictionaryContent<T, L>, IInterpreterPluginState$1, _$_intlayer_types0.ExtractSelectorLocale<L>>>;
13
14
  //#endregion
14
15
  export { useDictionaryAsync };
15
16
  //# sourceMappingURL=useDictionaryAsync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;;;;AAgBA;cAAa,kBAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,OAAA,CAAA,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;;;;;;cAgBa,kBAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,OAAA,CAAA,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,iCAAA,CAAA,CAAA,EAAA,CAAA,GAAA,yBAAA,EAAA,kBAAA,CAAA,qBAAA,CAAA,CAAA"}
@@ -1,15 +1,20 @@
1
- import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
- import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
1
  import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
4
- import { Dictionary } from "@intlayer/types/dictionary";
2
+ import { Dictionary, DictionarySelector } from "@intlayer/types/dictionary";
3
+ import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
5
4
 
6
5
  //#region src/server/useDictionaryDynamic.d.ts
7
6
  /**
8
- * On the server side, Hook that transform a dictionary and return the content
7
+ * Server-side hook that lazily loads a dictionary and returns its content.
9
8
  *
10
- * If the locale is not provided, it will use the locale from the server context
9
+ * The dictionary entry is either a plain dynamic loader map
10
+ * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,
11
+ * tagged with the qualifier dimension). For qualified maps, only the chunk(s)
12
+ * the selector targets are loaded; the resolution mirrors static mode.
13
+ *
14
+ * If the locale is not provided (directly or through the selector), the server
15
+ * context locale is used.
11
16
  */
12
- declare const useDictionaryDynamic: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: string, locale?: L, fallbackLocale?: DeclaredLocales) => _$_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, L>;
17
+ declare const useDictionaryDynamic: <const T extends Dictionary, const A extends LocalesValues | DictionarySelector = LocalesValues>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: string, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => any;
13
18
  //#endregion
14
19
  export { useDictionaryDynamic };
15
20
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;AAiBA;cAAa,oBAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,UACA,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,6BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;AAmCA;;;;;;;;;cAAa,oBAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,kBAAA,GAAqB,aAAA,EAErD,iBAAA,EACI,mBAAA,OAA0B,OAAA,CAAQ,CAAA,KAClC,yBAAA,EACJ,GAAA,UACA,gBAAA,GAAmB,CAAA,EACnB,cAAA,GAAiB,eAAA"}
@@ -1,15 +1,18 @@
1
1
  import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
2
2
  import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
3
- import { DeclaredLocales, DictionaryKeys, LocalesValues } from "@intlayer/types/module_augmentation";
3
+ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValues } from "@intlayer/types/module_augmentation";
4
4
  import * as _$_intlayer_types0 from "@intlayer/types";
5
5
 
6
6
  //#region src/server/useIntlayer.d.ts
7
7
  /**
8
8
  * On the server side, Hook that picking one dictionary by its key and return the content
9
9
  *
10
+ * The second argument is either a locale or a selector object
11
+ * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
12
+ *
10
13
  * If the locale is not provided, it will use the locale from the server context
11
14
  */
12
- declare const useIntlayer: <const T extends DictionaryKeys, const L extends LocalesValues = DeclaredLocales>(key: T, locale?: L, fallbackLocale?: DeclaredLocales) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.DictionaryRegistryContent<T>, IInterpreterPluginState$1, L>;
15
+ declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A, fallbackLocale?: DeclaredLocales) => _$_intlayer_core_interpreter0.DeepTransformContent<_$_intlayer_types0.DictionaryRegistryResult<T, A>, IInterpreterPluginState$1, _$_intlayer_types0.ExtractSelectorLocale<A>>;
13
16
  //#endregion
14
17
  export { useIntlayer };
15
18
  //# sourceMappingURL=useIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;;;;;;;cAca,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,yBAAA,CAAA,CAAA,GAAA,yBAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;;;;;;;AAkBA;;;cAAa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,wBAAA,CAAyB,CAAA,IAAK,eAAA,EAE9D,GAAA,EAAK,CAAA,EACL,gBAAA,GAAmB,CAAA,EACnB,cAAA,GAAiB,eAAA,KAAe,6BAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,wBAAA,CAAA,CAAA,EAAA,CAAA,GAAA,yBAAA,EAAA,kBAAA,CAAA,qBAAA,CAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "8.12.5-canary.0",
3
+ "version": "9.0.0-canary.1",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -124,18 +124,18 @@
124
124
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
125
125
  },
126
126
  "dependencies": {
127
- "@intlayer/api": "8.12.5-canary.0",
128
- "@intlayer/config": "8.12.5-canary.0",
129
- "@intlayer/core": "8.12.5-canary.0",
130
- "@intlayer/dictionaries-entry": "8.12.5-canary.0",
131
- "@intlayer/editor": "8.12.5-canary.0",
132
- "@intlayer/editor-react": "8.12.5-canary.0",
133
- "@intlayer/types": "8.12.5-canary.0"
127
+ "@intlayer/api": "9.0.0-canary.1",
128
+ "@intlayer/config": "9.0.0-canary.1",
129
+ "@intlayer/core": "9.0.0-canary.1",
130
+ "@intlayer/dictionaries-entry": "9.0.0-canary.1",
131
+ "@intlayer/editor": "9.0.0-canary.1",
132
+ "@intlayer/editor-react": "9.0.0-canary.1",
133
+ "@intlayer/types": "9.0.0-canary.1"
134
134
  },
135
135
  "devDependencies": {
136
136
  "@craco/types": "7.1.0",
137
137
  "@testing-library/react": "16.3.2",
138
- "@types/node": "25.9.2",
138
+ "@types/node": "25.9.3",
139
139
  "@types/react": ">=16.0.0",
140
140
  "@types/react-dom": ">=16.0.0",
141
141
  "@utils/ts-config": "1.0.4",
@@ -144,7 +144,7 @@
144
144
  "rimraf": "6.1.3",
145
145
  "tsdown": "0.21.10",
146
146
  "typescript": "6.0.3",
147
- "vitest": "4.1.8"
147
+ "vitest": "4.1.9"
148
148
  },
149
149
  "peerDependencies": {
150
150
  "react": ">=16.0.0",