angular-intlayer 8.12.5-canary.0 → 9.0.0-canary.0
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.
- package/dist/cjs/client/useDictionary.cjs +14 -3
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +25 -3
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +10 -4
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/esbuild/plugin.cjs +2 -2
- package/dist/cjs/getDictionary.cjs +8 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +8 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +14 -3
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +26 -4
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +10 -4
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/esbuild/plugin.mjs +2 -2
- package/dist/esm/getDictionary.mjs +8 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +8 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/types/client/useDictionary.d.ts +7 -3
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +11 -7
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +2 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +2 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +9 -4
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +7 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +9 -9
|
@@ -5,10 +5,21 @@ const require_client_intlayerToken = require('./intlayerToken.cjs');
|
|
|
5
5
|
let _angular_core = require("@angular/core");
|
|
6
6
|
|
|
7
7
|
//#region src/client/useDictionary.ts
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Angular hook that transforms a dictionary (or qualified dictionary group)
|
|
10
|
+
* and returns its reactive content for the given locale or selector.
|
|
11
|
+
*/
|
|
12
|
+
const useDictionary = (dictionary, localeOrSelector) => {
|
|
9
13
|
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
-
const
|
|
11
|
-
return (0, _angular_core.computed)(() =>
|
|
14
|
+
const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
|
|
15
|
+
return (0, _angular_core.computed)(() => {
|
|
16
|
+
const currentLocale = intlayer?.locale();
|
|
17
|
+
if (isSelector) return require_getDictionary.getDictionary(dictionary, {
|
|
18
|
+
...localeOrSelector,
|
|
19
|
+
locale: localeOrSelector.locale ?? currentLocale
|
|
20
|
+
});
|
|
21
|
+
return require_getDictionary.getDictionary(dictionary, localeOrSelector ?? currentLocale);
|
|
22
|
+
});
|
|
12
23
|
};
|
|
13
24
|
|
|
14
25
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n Dictionary,\n DictionarySelector,\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 { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular hook that transforms a dictionary (or qualified dictionary group)\n * and returns its reactive content for the given locale or selector.\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): Signal<\n DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const isSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => {\n const currentLocale = intlayer?.locale();\n\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getDictionary(\n dictionary,\n (localeOrSelector ?? currentLocale) as A\n ) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,iBAMX,YACA,qBAMG;CACH,MAAM,qCAAoCA,4CAAe;CAEzD,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAmB/D,0CAhB+B;EAC7B,MAAM,gBAAgB,UAAU,QAAQ;AAExC,MAAI,WACF,QAAOC,oCAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAOA,oCACL,YACC,oBAAoB,cACtB;GAGW"}
|
|
@@ -2,20 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
|
+
const require_getDictionary = require('../getDictionary.cjs');
|
|
5
6
|
const require_client_intlayerToken = require('./intlayerToken.cjs');
|
|
6
7
|
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
7
8
|
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
8
9
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
9
10
|
let _angular_core = require("@angular/core");
|
|
11
|
+
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
10
12
|
|
|
11
13
|
//#region src/client/useDictionaryDynamic.ts
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* Lazily loads a dictionary (plain or qualified) and returns its reactive
|
|
16
|
+
* content.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
18
|
+
* For a qualified loader map (collection / variant / meta record, possibly
|
|
19
|
+
* combined), only the chunk(s) the selector targets are loaded. For a plain
|
|
20
|
+
* loader map, the locale chunk is loaded.
|
|
21
|
+
*
|
|
22
|
+
* If the locale is not provided (directly or through the selector), it will use
|
|
23
|
+
* the locale from the client context.
|
|
16
24
|
*/
|
|
17
|
-
const useDictionaryDynamic = (dictionaryPromise, key,
|
|
25
|
+
const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
18
26
|
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
27
|
+
if ((0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(dictionaryPromise)) {
|
|
28
|
+
const { locale: selectorLocale, selector } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector);
|
|
29
|
+
const localeTarget = selectorLocale ?? intlayer?.locale() ?? _intlayer_config_built.internationalization.defaultLocale;
|
|
30
|
+
const container = (0, _angular_core.signal)(void 0);
|
|
31
|
+
(0, _intlayer_core_dictionaryManipulator.resolveQualifiedDynamicContentAsync)({
|
|
32
|
+
loaderMap: dictionaryPromise,
|
|
33
|
+
key: String(key),
|
|
34
|
+
locale: localeTarget,
|
|
35
|
+
selector,
|
|
36
|
+
transform: (dictionary) => require_getDictionary.getDictionary(dictionary, localeTarget)
|
|
37
|
+
}).then((resolved) => container.set(resolved));
|
|
38
|
+
return (0, _angular_core.computed)(() => container());
|
|
39
|
+
}
|
|
40
|
+
const locale = typeof localeOrSelector === "string" ? localeOrSelector : void 0;
|
|
19
41
|
const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer?.locale() ?? _intlayer_config_built.internationalization.defaultLocale);
|
|
20
42
|
return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
|
|
21
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","internationalization","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","internationalization","getDictionary","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant / meta record, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\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 intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n intlayer?.locale() ??\n internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\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() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,qCAAoCA,4CAAe;AAEzD,2EAAgC,kBAAkB,EAAE;EAClD,MAAM,EAAE,QAAQ,gBAAgB,+EACS,iBAAiB;EAE1D,MAAM,eACJ,kBACA,UAAU,QAAQ,IAClBC,4CAAqB;EAEvB,MAAM,sCAA4B,OAAU;AAE5C,gFAAoC;GAClC,WAAW;GACX,KAAK,OAAO,IAAI;GAChB,QAAQ;GACR;GACA,YAAY,eAAeC,oCAAc,YAAY,aAAa;GACnE,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,SAAS,CAAC;AAE9C,2CAAsB,WAAW,CAAQ;;CAG3C,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,iDACE,UAAU,UAAU,QAAQ,IAAID,4CAAqB,cAC5D;AAOD,QAAOE,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAC/B,kBAA0B,cAAc,KAAK,CAGjB,EAAE,cAAc,CAAQ"}
|
|
@@ -32,11 +32,17 @@ const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.
|
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
const useIntlayer = (key,
|
|
35
|
+
const useIntlayer = (key, localeOrSelector) => {
|
|
36
36
|
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
|
|
38
|
+
return (0, _angular_core.computed)(() => {
|
|
39
|
+
const currentLocale = intlayer.locale();
|
|
40
|
+
if (isSelector) return require_getIntlayer.getIntlayer(key, {
|
|
41
|
+
...localeOrSelector,
|
|
42
|
+
locale: localeOrSelector.locale ?? currentLocale
|
|
43
|
+
});
|
|
44
|
+
return require_getIntlayer.getIntlayer(key, localeOrSelector ?? currentLocale);
|
|
45
|
+
});
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n DictionaryKeys,\n
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\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): Signal<\n DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n const isSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => {\n const currentLocale = intlayer.locale();\n\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getIntlayer(key, (localeOrSelector ?? currentLocale) as A) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eAIX,KACA,qBAGG;CACH,MAAM,qCAAoCA,4CAAe;CAEzD,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAiB/D,0CAb+B;EAC7B,MAAM,gBAAgB,SAAS,QAAQ;AAEvC,MAAI,WACF,QAAOC,gCAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAOA,gCAAY,KAAM,oBAAoB,cAAoB;GAGrD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
5
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
4
6
|
let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
|
|
5
7
|
let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
|
|
6
8
|
let _intlayer_chokidar_watcher = require("@intlayer/chokidar/watcher");
|
|
7
9
|
let _intlayer_config_envVars = require("@intlayer/config/envVars");
|
|
8
10
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
9
|
-
let _intlayer_config_node = require("@intlayer/config/node");
|
|
10
|
-
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
11
11
|
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
12
12
|
|
|
13
13
|
//#region src/esbuild/plugin.ts
|
|
@@ -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
|
-
|
|
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 {
|
|
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 DictionarySelector,\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":";;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,qBAIG;AAOH,sDACE,YACA,kBACAA,2BARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAMc,CACnB"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\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":";;;;;;;;;;;AAiBA,MAAa,eAIX,KACA,qBAIG;AAOH,oDAAuB,KAAK,kBAAkBA,2BAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAG0D,CAAC"}
|
|
@@ -3,10 +3,21 @@ import { INTLAYER_TOKEN } from "./intlayerToken.mjs";
|
|
|
3
3
|
import { computed, inject } from "@angular/core";
|
|
4
4
|
|
|
5
5
|
//#region src/client/useDictionary.ts
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Angular hook that transforms a dictionary (or qualified dictionary group)
|
|
8
|
+
* and returns its reactive content for the given locale or selector.
|
|
9
|
+
*/
|
|
10
|
+
const useDictionary = (dictionary, localeOrSelector) => {
|
|
7
11
|
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
-
const
|
|
9
|
-
return computed(() =>
|
|
12
|
+
const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
|
|
13
|
+
return computed(() => {
|
|
14
|
+
const currentLocale = intlayer?.locale();
|
|
15
|
+
if (isSelector) return getDictionary(dictionary, {
|
|
16
|
+
...localeOrSelector,
|
|
17
|
+
locale: localeOrSelector.locale ?? currentLocale
|
|
18
|
+
});
|
|
19
|
+
return getDictionary(dictionary, localeOrSelector ?? currentLocale);
|
|
20
|
+
});
|
|
10
21
|
};
|
|
11
22
|
|
|
12
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n Dictionary,\n DictionarySelector,\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 { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular hook that transforms a dictionary (or qualified dictionary group)\n * and returns its reactive content for the given locale or selector.\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): Signal<\n DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const isSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => {\n const currentLocale = intlayer?.locale();\n\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getDictionary(\n dictionary,\n (localeOrSelector ?? currentLocale) as A\n ) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;;AAqBA,MAAa,iBAMX,YACA,qBAMG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAmB/D,QAhBgB,eAAe;EAC7B,MAAM,gBAAgB,UAAU,QAAQ;AAExC,MAAI,WACF,QAAO,cAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAO,cACL,YACC,oBAAoB,cACtB;GAGW"}
|
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
3
4
|
import { INTLAYER_TOKEN } from "./intlayerToken.mjs";
|
|
4
5
|
import { useDictionary } from "./useDictionary.mjs";
|
|
5
6
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
6
7
|
import { internationalization } from "@intlayer/config/built";
|
|
7
|
-
import { computed, inject } from "@angular/core";
|
|
8
|
+
import { computed, inject, signal } from "@angular/core";
|
|
9
|
+
import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedDynamicContentAsync } from "@intlayer/core/dictionaryManipulator";
|
|
8
10
|
|
|
9
11
|
//#region src/client/useDictionaryDynamic.ts
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* Lazily loads a dictionary (plain or qualified) and returns its reactive
|
|
14
|
+
* content.
|
|
12
15
|
*
|
|
13
|
-
*
|
|
16
|
+
* For a qualified loader map (collection / variant / meta record, possibly
|
|
17
|
+
* combined), only the chunk(s) the selector targets are loaded. For a plain
|
|
18
|
+
* loader map, the locale chunk is loaded.
|
|
19
|
+
*
|
|
20
|
+
* If the locale is not provided (directly or through the selector), it will use
|
|
21
|
+
* the locale from the client context.
|
|
14
22
|
*/
|
|
15
|
-
const useDictionaryDynamic = (dictionaryPromise, key,
|
|
23
|
+
const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
16
24
|
const intlayer = inject(INTLAYER_TOKEN);
|
|
25
|
+
if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {
|
|
26
|
+
const { locale: selectorLocale, selector } = parseDictionarySelector(localeOrSelector);
|
|
27
|
+
const localeTarget = selectorLocale ?? intlayer?.locale() ?? internationalization.defaultLocale;
|
|
28
|
+
const container = signal(void 0);
|
|
29
|
+
resolveQualifiedDynamicContentAsync({
|
|
30
|
+
loaderMap: dictionaryPromise,
|
|
31
|
+
key: String(key),
|
|
32
|
+
locale: localeTarget,
|
|
33
|
+
selector,
|
|
34
|
+
transform: (dictionary) => getDictionary(dictionary, localeTarget)
|
|
35
|
+
}).then((resolved) => container.set(resolved));
|
|
36
|
+
return computed(() => container());
|
|
37
|
+
}
|
|
38
|
+
const locale = typeof localeOrSelector === "string" ? localeOrSelector : void 0;
|
|
17
39
|
const localeTarget = computed(() => locale ?? intlayer?.locale() ?? internationalization.defaultLocale);
|
|
18
40
|
return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
|
|
19
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant / meta record, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\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 intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (isQualifiedDynamicLoaderMap(dictionaryPromise)) {\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n intlayer?.locale() ??\n internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\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() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,WAAW,OAAyB,eAAe;AAEzD,KAAI,4BAA4B,kBAAkB,EAAE;EAClD,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,wBAAuC,iBAAiB;EAE1D,MAAM,eACJ,kBACA,UAAU,QAAQ,IAClB,qBAAqB;EAEvB,MAAM,YAAY,OAAgB,OAAU;AAE5C,sCAAoC;GAClC,WAAW;GACX,KAAK,OAAO,IAAI;GAChB,QAAQ;GACR;GACA,YAAY,eAAe,cAAc,YAAY,aAAa;GACnE,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,SAAS,CAAC;AAE9C,SAAO,eAAe,WAAW,CAAQ;;CAG3C,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,eAAe,eACb,UAAU,UAAU,QAAQ,IAAI,qBAAqB,cAC5D;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAC/B,kBAA0B,cAAc,KAAK,CAGjB,EAAE,cAAc,CAAQ"}
|
|
@@ -30,11 +30,17 @@ const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.
|
|
|
30
30
|
* }
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
const useIntlayer = (key,
|
|
33
|
+
const useIntlayer = (key, localeOrSelector) => {
|
|
34
34
|
const intlayer = inject(INTLAYER_TOKEN);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const isSelector = typeof localeOrSelector === "object" && localeOrSelector !== null;
|
|
36
|
+
return computed(() => {
|
|
37
|
+
const currentLocale = intlayer.locale();
|
|
38
|
+
if (isSelector) return getIntlayer(key, {
|
|
39
|
+
...localeOrSelector,
|
|
40
|
+
locale: localeOrSelector.locale ?? currentLocale
|
|
41
|
+
});
|
|
42
|
+
return getIntlayer(key, localeOrSelector ?? currentLocale);
|
|
43
|
+
});
|
|
38
44
|
};
|
|
39
45
|
|
|
40
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n DictionaryKeys,\n
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\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): Signal<\n DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n const isSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => {\n const currentLocale = intlayer.locale();\n\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getIntlayer(key, (localeOrSelector ?? currentLocale) as A) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAeA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eAIX,KACA,qBAGG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,aACJ,OAAO,qBAAqB,YAAY,qBAAqB;AAiB/D,QAbgB,eAAe;EAC7B,MAAM,gBAAgB,SAAS,QAAQ;AAEvC,MAAI,WACF,QAAO,YAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAO,YAAY,KAAM,oBAAoB,cAAoB;GAGrD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
+
import { getAlias, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
2
4
|
import { prepareIntlayer } from "@intlayer/chokidar/build";
|
|
3
5
|
import { logConfigDetails } from "@intlayer/chokidar/cli";
|
|
4
6
|
import { watch } from "@intlayer/chokidar/watcher";
|
|
5
7
|
import { formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
6
8
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
7
|
-
import { getConfiguration } from "@intlayer/config/node";
|
|
8
|
-
import { getAlias, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
9
9
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
10
10
|
|
|
11
11
|
//#region src/esbuild/plugin.ts
|
|
@@ -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
|
-
|
|
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 {
|
|
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 DictionarySelector,\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":";;;;;;;;;AAoBA,MAAa,iBAMX,YACA,qBAIG;AAOH,QAAOA,gBACL,YACA,kBACA,WARA,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAMc,CACnB"}
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\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":";;;;;;;;;AAiBA,MAAa,eAIX,KACA,qBAIG;AAOH,QAAOA,cAAgB,KAAK,kBAAkB,WAL5C,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB,iBAG0D,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { DeepTransformContent } from "../plugins.js";
|
|
2
2
|
import { Signal } from "@angular/core";
|
|
3
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
|
|
5
5
|
|
|
6
6
|
//#region src/client/useDictionary.d.ts
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Angular hook that transforms a dictionary (or qualified dictionary group)
|
|
9
|
+
* and returns its reactive content for the given locale or selector.
|
|
10
|
+
*/
|
|
11
|
+
declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => Signal<DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>>;
|
|
8
12
|
//#endregion
|
|
9
13
|
export { useDictionary };
|
|
10
14
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;AAqBA;;cAAa,aAAA,mBACK,UAAA,GAAa,wBAAA,kBAEzB,aAAA,GACA,0BAAA,CAA2B,CAAA,IAAK,eAAA,EAEpC,UAAA,EAAY,CAAA,EACZ,gBAAA,GAAmB,CAAA,KAClB,MAAA,CACD,oBAAA,CACE,iCAAA,CAAkC,CAAA,EAAG,CAAA,GACrC,qBAAA,CAAsB,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
10
10
|
*/
|
|
11
|
-
declare const useDictionaryAsync: <const T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: LocalesValues) => Promise<_$_angular_core0.Signal<
|
|
11
|
+
declare const useDictionaryAsync: <const T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: LocalesValues) => Promise<_$_angular_core0.Signal<unknown>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { useDictionaryAsync };
|
|
14
14
|
//# sourceMappingURL=useDictionaryAsync.d.ts.map
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
3
1
|
import * as _$_angular_core0 from "@angular/core";
|
|
4
|
-
import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
5
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
|
-
import
|
|
4
|
+
import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
|
|
7
5
|
|
|
8
6
|
//#region src/client/useDictionaryDynamic.d.ts
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
8
|
+
* Lazily loads a dictionary (plain or qualified) and returns its reactive
|
|
9
|
+
* content.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
11
|
+
* For a qualified loader map (collection / variant / meta record, possibly
|
|
12
|
+
* combined), only the chunk(s) the selector targets are loaded. For a plain
|
|
13
|
+
* loader map, the locale chunk is loaded.
|
|
14
|
+
*
|
|
15
|
+
* If the locale is not provided (directly or through the selector), it will use
|
|
16
|
+
* the locale from the client context.
|
|
13
17
|
*/
|
|
14
|
-
declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T
|
|
18
|
+
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) => _$_angular_core0.Signal<any>;
|
|
15
19
|
//#endregion
|
|
16
20
|
export { useDictionaryDynamic };
|
|
17
21
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;AAoCA;;;;;;;;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,KAAC,gBAAA,CAAA,MAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeepTransformContent } from "../plugins.js";
|
|
2
2
|
import { Signal } from "@angular/core";
|
|
3
|
-
import { DictionaryKeys,
|
|
3
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
4
|
|
|
5
5
|
//#region src/client/useIntlayer.d.ts
|
|
6
6
|
/** guard utility - true only for objects generated by `renderIntlayerNode()` */
|
|
@@ -32,7 +32,7 @@ declare const isUpdatableNode: (val: unknown) => val is {
|
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
declare const useIntlayer: <const T extends DictionaryKeys, const
|
|
35
|
+
declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => Signal<DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>>;
|
|
36
36
|
//#endregion
|
|
37
37
|
export { isUpdatableNode, useIntlayer };
|
|
38
38
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;cAea,eAAA,GACX,GAAA,cACC,GAAA;EAAS,QAAA,GAAW,CAAA;AAAA;;;;;;;;;AA8BvB;;;;;;;;;;;;;;;;;cAAa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,wBAAA,CAAyB,CAAA,IAAK,eAAA,EAE9D,GAAA,EAAK,CAAA,EACL,gBAAA,GAAmB,CAAA,KAClB,MAAA,CACD,oBAAA,CAAqB,wBAAA,CAAyB,CAAA,EAAG,CAAA,GAAI,qBAAA,CAAsB,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
1
2
|
import * as _$_angular_core0 from "@angular/core";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/format/useRelativeTime.d.ts
|
|
5
5
|
declare const useRelativeTime: () => _$_angular_core0.Signal<(from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
6
|
-
locale?:
|
|
6
|
+
locale?: LocalesValues;
|
|
7
7
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
8
8
|
}) => string>;
|
|
9
9
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";;;;cAIa,eAAA,yBAAe,MAAA,EAAA,IAAA,oBAAA,IAAA,EAAA,EAAA,qBAAA,IAAA,EAAA,OAAA,GAAA,IAAA,CAAA,yBAAA;WAAA,
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";;;;cAIa,eAAA,yBAAe,MAAA,EAAA,IAAA,oBAAA,IAAA,EAAA,EAAA,qBAAA,IAAA,EAAA,OAAA,GAAA,IAAA,CAAA,yBAAA;WAAA,aAAA"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { DeepTransformContent } from "./plugins.js";
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.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,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,
|
|
2
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
3
|
|
|
4
4
|
//#region src/getIntlayer.d.ts
|
|
5
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;;;AAiBA;;;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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { installIntlayer, provideIntlayer } from "./client/installIntlayer.js";
|
|
|
4
4
|
import { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, InsertionPluginCond, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.js";
|
|
5
5
|
import { useDictionary } from "./client/useDictionary.js";
|
|
6
6
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.js";
|
|
7
|
-
import { getDictionary } from "./getDictionary.js";
|
|
8
|
-
import { getIntlayer } from "./getIntlayer.js";
|
|
9
7
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.js";
|
|
10
8
|
import { isUpdatableNode, useIntlayer } from "./client/useIntlayer.js";
|
|
11
9
|
import { useLoadDynamic } from "./client/useLoadDynamic.js";
|
|
12
10
|
import { UseLocaleProps, UseLocaleResult, useLocale } from "./client/useLocale.js";
|
|
11
|
+
import { getDictionary } from "./getDictionary.js";
|
|
12
|
+
import { getIntlayer } from "./getIntlayer.js";
|
|
13
13
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
14
14
|
|
|
15
15
|
//#region src/index.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-intlayer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -118,18 +118,18 @@
|
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@babel/plugin-syntax-import-attributes": "7.28.6",
|
|
120
120
|
"@babel/preset-env": "7.29.2",
|
|
121
|
-
"@intlayer/chokidar": "
|
|
122
|
-
"@intlayer/config": "
|
|
123
|
-
"@intlayer/core": "
|
|
124
|
-
"@intlayer/dictionaries-entry": "
|
|
125
|
-
"@intlayer/editor": "
|
|
126
|
-
"@intlayer/types": "
|
|
127
|
-
"@intlayer/webpack": "
|
|
121
|
+
"@intlayer/chokidar": "9.0.0-canary.0",
|
|
122
|
+
"@intlayer/config": "9.0.0-canary.0",
|
|
123
|
+
"@intlayer/core": "9.0.0-canary.0",
|
|
124
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.0",
|
|
125
|
+
"@intlayer/editor": "9.0.0-canary.0",
|
|
126
|
+
"@intlayer/types": "9.0.0-canary.0",
|
|
127
|
+
"@intlayer/webpack": "9.0.0-canary.0",
|
|
128
128
|
"babel-loader": "10.1.1",
|
|
129
129
|
"defu": "6.1.7"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"@types/node": "25.9.
|
|
132
|
+
"@types/node": "25.9.3",
|
|
133
133
|
"@types/webpack": "5.28.5",
|
|
134
134
|
"@utils/ts-config": "1.0.4",
|
|
135
135
|
"@utils/ts-config-types": "1.0.4",
|