react-intlayer 9.0.0-canary.7 → 9.0.0-canary.8

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.
@@ -14,7 +14,6 @@ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryMan
14
14
  * The second argument is either a locale or a selector object:
15
15
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
16
16
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
17
- * - `{ id: 'prod_abc', ...metaFields }` — meta record
18
17
  * - `locale` composes with any selector and overrides the context locale
19
18
  *
20
19
  * @param key - The unique key of the dictionary to retrieve.
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n 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 process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAOvB,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"}
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 * - `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 process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAOvB,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"}
@@ -7,7 +7,7 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
7
7
  /**
8
8
  * Transforms a dictionary (or qualified dictionary group) and returns its
9
9
  * content for the given locale or selector (`{ item }`, `{ variant }`,
10
- * `{ id, ...meta }`, optionally combined with `locale`).
10
+ * optionally combined with `locale`).
11
11
  */
12
12
  const getDictionary = (dictionary, localeOrSelector) => {
13
13
  return (0, _intlayer_core_interpreter.getDictionary)(dictionary, localeOrSelector, require_plugins.getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
@@ -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 {\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"}
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 * 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"}
@@ -6,7 +6,7 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
6
6
  //#region src/getIntlayer.ts
7
7
  /**
8
8
  * Picks one dictionary by its key and returns its content for the given
9
- * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
9
+ * locale or selector (`{ item }`, `{ variant }`,
10
10
  * optionally combined with `locale`).
11
11
  */
12
12
  const getIntlayer = (key, localeOrSelector) => {
@@ -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 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"}
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 }`,\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"}
@@ -8,7 +8,7 @@ const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.
8
8
  * On the server side, Hook that picking one dictionary by its key and return the content
9
9
  *
10
10
  * The second argument is either a locale or a selector object
11
- * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
11
+ * (`{ item }`, `{ variant }`, optionally with `locale`).
12
12
  *
13
13
  * If the locale is not provided, it will use the locale from the server context
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, `{ 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 (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,4DAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,gCAAkB,KAFH,oBAAoB,cAEC"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["getServerContext","IntlayerServerContext","getIntlayer"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends 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 (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJA,8CAAgCC,4DAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAOC,gCAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAOA,gCAAkB,KAFH,oBAAoB,cAEC"}
@@ -12,7 +12,6 @@ import { getDictionarySelectorCacheKey } from "@intlayer/core/dictionaryManipula
12
12
  * The second argument is either a locale or a selector object:
13
13
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
14
14
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
15
- * - `{ id: 'prod_abc', ...metaFields }` — meta record
16
15
  * - `locale` composes with any selector and overrides the context locale
17
16
  *
18
17
  * @param key - The unique key of the dictionary to retrieve.
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport { getDictionarySelectorCacheKey } from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n 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 process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAOvB,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"}
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 * - `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 process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n // Stable identity of the second argument for memoization\n const localeOrSelectorIdentity = isSelector\n ? `${localeOrSelector.locale ?? ''}|${getDictionarySelectorCacheKey(localeOrSelector)}`\n : localeOrSelector;\n\n return useMemo(() => {\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? currentLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n }, [key, currentLocale, localeOrSelectorIdentity]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAOvB,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"}
@@ -5,7 +5,7 @@ import { getDictionary as getDictionary$1 } from "@intlayer/core/interpreter";
5
5
  /**
6
6
  * Transforms a dictionary (or qualified dictionary group) and returns its
7
7
  * content for the given locale or selector (`{ item }`, `{ variant }`,
8
- * `{ id, ...meta }`, optionally combined with `locale`).
8
+ * optionally combined with `locale`).
9
9
  */
10
10
  const getDictionary = (dictionary, localeOrSelector) => {
11
11
  return getDictionary$1(dictionary, localeOrSelector, getPlugins(typeof localeOrSelector === "object" && localeOrSelector !== null ? localeOrSelector.locale : localeOrSelector));
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * `{ 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"}
1
+ {"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getDictionaryCore(\n dictionary,\n localeOrSelector,\n getPlugins(locale)\n ) as any;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,iBAMX,YACA,qBAIG;AAOH,QAAOA,gBACL,YACA,kBACA,WARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAMc,CACnB"}
@@ -4,7 +4,7 @@ import { getIntlayer as getIntlayer$1 } from "@intlayer/core/interpreter";
4
4
  //#region src/getIntlayer.ts
5
5
  /**
6
6
  * Picks one dictionary by its key and returns its content for the given
7
- * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
7
+ * locale or selector (`{ item }`, `{ variant }`,
8
8
  * optionally combined with `locale`).
9
9
  */
10
10
  const getIntlayer = (key, localeOrSelector) => {
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector (`{ item }`, `{ variant }`, `{ 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"}
1
+ {"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getIntlayerCore(key, localeOrSelector, getPlugins(locale)) as any;\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,eAIX,KACA,qBAIG;AAOH,QAAOA,cAAgB,KAAK,kBAAkB,WAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAG0D,CAAC"}
@@ -7,7 +7,7 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
7
7
  * On the server side, Hook that picking one dictionary by its key and return the content
8
8
  *
9
9
  * The second argument is either a locale or a selector object
10
- * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
10
+ * (`{ item }`, `{ variant }`, optionally with `locale`).
11
11
  *
12
12
  * If the locale is not provided, it will use the locale from the server context
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, `{ 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 (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,sBAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAO,YAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAO,YAAkB,KAFH,oBAAoB,cAEC"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends 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 (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,sBAAsB,IAAI;AAE5D,KACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,KAErB,QAAO,YAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;EACpC,CAAM;AAKT,QAAO,YAAkB,KAFH,oBAAoB,cAEC"}
@@ -10,7 +10,6 @@ import * as _$_intlayer_types0 from "@intlayer/types";
10
10
  * The second argument is either a locale or a selector object:
11
11
  * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
12
12
  * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
13
- * - `{ id: 'prod_abc', ...metaFields }` — meta record
14
13
  * - `locale` composes with any selector and overrides the context locale
15
14
  *
16
15
  * @param key - The unique key of the dictionary to retrieve.
@@ -1 +1 @@
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
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;AAqCA;;;;;;;;;;;;;;;;;;;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"}
@@ -6,7 +6,7 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, Resol
6
6
  /**
7
7
  * Transforms a dictionary (or qualified dictionary group) and returns its
8
8
  * content for the given locale or selector (`{ item }`, `{ variant }`,
9
- * `{ id, ...meta }`, optionally combined with `locale`).
9
+ * optionally combined with `locale`).
10
10
  */
11
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>>;
12
12
  //#endregion
@@ -4,7 +4,7 @@ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySe
4
4
  //#region src/getIntlayer.d.ts
5
5
  /**
6
6
  * Picks one dictionary by its key and returns its content for the given
7
- * locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
7
+ * locale or selector (`{ item }`, `{ variant }`,
8
8
  * optionally combined with `locale`).
9
9
  */
10
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>>;
@@ -8,7 +8,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
8
8
  * On the server side, Hook that picking one dictionary by its key and return the content
9
9
  *
10
10
  * The second argument is either a locale or a selector object
11
- * (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
11
+ * (`{ item }`, `{ variant }`, optionally with `locale`).
12
12
  *
13
13
  * If the locale is not provided, it will use the locale from the server context
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "9.0.0-canary.7",
3
+ "version": "9.0.0-canary.8",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -124,13 +124,13 @@
124
124
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
125
125
  },
126
126
  "dependencies": {
127
- "@intlayer/api": "9.0.0-canary.7",
128
- "@intlayer/config": "9.0.0-canary.7",
129
- "@intlayer/core": "9.0.0-canary.7",
130
- "@intlayer/dictionaries-entry": "9.0.0-canary.7",
131
- "@intlayer/editor": "9.0.0-canary.7",
132
- "@intlayer/editor-react": "9.0.0-canary.7",
133
- "@intlayer/types": "9.0.0-canary.7"
127
+ "@intlayer/api": "9.0.0-canary.8",
128
+ "@intlayer/config": "9.0.0-canary.8",
129
+ "@intlayer/core": "9.0.0-canary.8",
130
+ "@intlayer/dictionaries-entry": "9.0.0-canary.8",
131
+ "@intlayer/editor": "9.0.0-canary.8",
132
+ "@intlayer/editor-react": "9.0.0-canary.8",
133
+ "@intlayer/types": "9.0.0-canary.8"
134
134
  },
135
135
  "devDependencies": {
136
136
  "@craco/types": "7.1.0",