angular-intlayer 8.0.0-canary.0 → 8.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/index.cjs +1 -0
- package/dist/cjs/client/installIntlayer.cjs +29 -1
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +25 -0
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +25 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/plugins.cjs +4 -4
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/client/index.mjs +2 -2
- package/dist/esm/client/installIntlayer.mjs +29 -2
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +25 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +25 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/plugins.mjs +4 -4
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/index.d.ts +2 -2
- package/dist/types/client/installIntlayer.d.ts +29 -2
- package/dist/types/client/installIntlayer.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useIntl.d.ts +2 -2
- package/dist/types/client/useIntlayer.d.ts +25 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +30 -6
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/editor/EditedContentRenderer.component.d.ts +2 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins.d.ts +12 -9
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -12,6 +12,7 @@ exports.IntlayerProvider = require_client_installIntlayer.IntlayerProvider;
|
|
|
12
12
|
exports.createIntlayerClient = require_client_installIntlayer.createIntlayerClient;
|
|
13
13
|
exports.installIntlayer = require_client_installIntlayer.installIntlayer;
|
|
14
14
|
exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
|
|
15
|
+
exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
|
|
15
16
|
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
16
17
|
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
17
18
|
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
@@ -28,7 +28,34 @@ const createIntlayerClient = (locale, isCookieEnabled = true) => {
|
|
|
28
28
|
return instance;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Provides Intlayer to your Angular application.
|
|
32
|
+
*
|
|
33
|
+
* This function should be used in your application's provider list (e.g., in `app.config.ts`)
|
|
34
|
+
* to initialize the Intlayer service.
|
|
35
|
+
*
|
|
36
|
+
* @param locale - Initial locale to use.
|
|
37
|
+
* @param isCookieEnabled - Whether to store the locale in cookies.
|
|
38
|
+
* @returns A provider configuration for Intlayer.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // app.config.ts
|
|
43
|
+
* import { ApplicationConfig } from '@angular/core';
|
|
44
|
+
* import { provideIntlayer } from 'angular-intlayer';
|
|
45
|
+
*
|
|
46
|
+
* export const appConfig: ApplicationConfig = {
|
|
47
|
+
* providers: [
|
|
48
|
+
* provideIntlayer({ locale: 'en' }),
|
|
49
|
+
* ],
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
const provideIntlayer = (locale, isCookieEnabled = true) => ({
|
|
54
|
+
provide: INTLAYER_TOKEN,
|
|
55
|
+
useValue: installIntlayer(locale, isCookieEnabled)
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Helper to install the Intlayer provider.
|
|
32
59
|
*/
|
|
33
60
|
const installIntlayer = (locale, isCookieEnabled = true) => {
|
|
34
61
|
return createIntlayerClient(locale, isCookieEnabled);
|
|
@@ -39,4 +66,5 @@ exports.INTLAYER_TOKEN = INTLAYER_TOKEN;
|
|
|
39
66
|
exports.IntlayerProvider = IntlayerProvider;
|
|
40
67
|
exports.createIntlayerClient = createIntlayerClient;
|
|
41
68
|
exports.installIntlayer = installIntlayer;
|
|
69
|
+
exports.provideIntlayer = provideIntlayer;
|
|
42
70
|
//# sourceMappingURL=installIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.cjs","names":["InjectionToken","configuration"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider
|
|
1
|
+
{"version":3,"file":"installIntlayer.cjs","names":["InjectionToken","configuration"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;;;AAIA,MAAa,iBAAiB,IAAIA,6BAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;AAKxC,IAAa,mBAHb,gCAAY,EACV,YAAY,QACb,CAAC,EACF,MAA8B;CAC5B,4CAAyB,KAAK;CAC9B,AAAQ,oCACNC,+BAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;;;;AAO5B,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,mBACX,QACA,kBAAkB,UACd;CACJ,SAAS;CACT,UAAU,gBAAgB,QAAQ,gBAAgB;CACnD;;;;AAKD,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
|
|
@@ -6,6 +6,31 @@ let _angular_core = require("@angular/core");
|
|
|
6
6
|
//#region src/client/useIntlayer.ts
|
|
7
7
|
/** guard utility - true only for objects generated by `renderIntlayerNode()` */
|
|
8
8
|
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
9
|
+
/**
|
|
10
|
+
* Angular hook that picks one dictionary by its key and returns its reactive content.
|
|
11
|
+
*
|
|
12
|
+
* It utilizes Angular signals to provide deep reactivity, ensuring your components
|
|
13
|
+
* update automatically when the locale changes.
|
|
14
|
+
*
|
|
15
|
+
* @param key - The unique key of the dictionary to retrieve.
|
|
16
|
+
* @param locale - Optional locale to override the current context locale.
|
|
17
|
+
* @returns The transformed dictionary content.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Component } from '@angular/core';
|
|
22
|
+
* import { useIntlayer } from 'angular-intlayer';
|
|
23
|
+
*
|
|
24
|
+
* @Component({
|
|
25
|
+
* standalone: true,
|
|
26
|
+
* selector: 'app-my-component',
|
|
27
|
+
* template: `<div>{{ content().myField.value }}</div>`,
|
|
28
|
+
* })
|
|
29
|
+
* export class MyComponent {
|
|
30
|
+
* content = useIntlayer('my-dictionary-key');
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
9
34
|
const useIntlayer = (key, locale) => {
|
|
10
35
|
const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
11
36
|
/** which locale should we use right now? */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\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\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\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 = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,qCAAoCA,8CAAe;;CAGzD,MAAM,iDAA8B,UAAU,SAAS,QAAQ,CAAC;AAMhE,0CAF+BC,gCAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
|
|
@@ -7,7 +7,31 @@ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built
|
|
|
7
7
|
|
|
8
8
|
//#region src/client/useLocale.ts
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Angular hook to manage the current locale and related functions.
|
|
11
|
+
*
|
|
12
|
+
* @param props - Optional configuration for locale management.
|
|
13
|
+
* @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Component } from '@angular/core';
|
|
18
|
+
* import { useLocale } from 'angular-intlayer';
|
|
19
|
+
*
|
|
20
|
+
* @Component({
|
|
21
|
+
* standalone: true,
|
|
22
|
+
* selector: 'app-locale-switcher',
|
|
23
|
+
* template: `
|
|
24
|
+
* <select [value]="locale()" (change)="setLocale($any($event.target).value)">
|
|
25
|
+
* @for (loc of availableLocales; track loc) {
|
|
26
|
+
* <option [value]="loc">{{ loc }}</option>
|
|
27
|
+
* }
|
|
28
|
+
* </select>
|
|
29
|
+
* `,
|
|
30
|
+
* })
|
|
31
|
+
* export class LocaleSwitcher {
|
|
32
|
+
* const { locale, setLocale, availableLocales } = useLocale();
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
11
35
|
*/
|
|
12
36
|
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
13
37
|
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.default?.internationalization ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,gCAAe,wBAAwB,EAAE;CAC3C,MAAM,qCAAoCC,8CAAe;CAGzD,MAAM,2CAAwB,UAAU,QAAQ,IAAI,cAAc;CAClE,MAAM,2DACE,UAAU,iBAAiB,IAAI,KACtC;CAED,MAAM,aAAa,cAA6B;AAC9C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,MAAI,SACF,UAAS,UAAU,UAAU;AAE/B,qDACE,WACA,mBAAmB,wBAAwB,IAAI,KAChD;AACD,mBAAiB,UAAU;;AAG7B,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ exports.intlayerNodePlugins = require_plugins.intlayerNodePlugins;
|
|
|
24
24
|
exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
|
|
25
25
|
exports.markdownPlugin = require_plugins.markdownPlugin;
|
|
26
26
|
exports.markdownStringPlugin = require_plugins.markdownStringPlugin;
|
|
27
|
+
exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
|
|
27
28
|
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
28
29
|
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
29
30
|
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -42,7 +42,7 @@ const markdownStringPlugin = {
|
|
|
42
42
|
dictionaryKey: rest.dictionaryKey,
|
|
43
43
|
keyPath: []
|
|
44
44
|
});
|
|
45
|
-
const render = (
|
|
45
|
+
const render = (components) => require_renderIntlayerNode.renderIntlayerNode({
|
|
46
46
|
...props,
|
|
47
47
|
value: node,
|
|
48
48
|
children: () => ({
|
|
@@ -50,11 +50,11 @@ const markdownStringPlugin = {
|
|
|
50
50
|
props: {
|
|
51
51
|
dictionaryKey: rest.dictionaryKey,
|
|
52
52
|
keyPath: rest.keyPath,
|
|
53
|
-
...
|
|
53
|
+
...components
|
|
54
54
|
},
|
|
55
55
|
children: () => {
|
|
56
56
|
const { renderMarkdown } = require_markdown_installIntlayerMarkdown.useMarkdown();
|
|
57
|
-
return renderMarkdown(node,
|
|
57
|
+
return renderMarkdown(node, components);
|
|
58
58
|
}
|
|
59
59
|
}),
|
|
60
60
|
additionalProps: { metadata: metadataNodes }
|
|
@@ -63,7 +63,7 @@ const markdownStringPlugin = {
|
|
|
63
63
|
return new Proxy(element, { get(target, prop, receiver) {
|
|
64
64
|
if (prop === "value") return node;
|
|
65
65
|
if (prop === "metadata") return metadataNodes;
|
|
66
|
-
if (prop === "use") return (
|
|
66
|
+
if (prop === "use") return (components) => render(components);
|
|
67
67
|
return Reflect.get(target, prop, receiver);
|
|
68
68
|
} });
|
|
69
69
|
}
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","props","useMarkdown","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","props","useMarkdown","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLCond,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? {\n use: (components: any) => any;\n metadata: DeepTransformContent<U>;\n } & any\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T, S, L> = HTMLCond<T, S, L>;\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;;;;AAiCA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChCA,8CAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAWC;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWD,MAAa,uBAAgC;CAC3C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,EACJ,SACA,GAAG,SACD;EAoBJ,MAAM,gBAAgB,0DAlBe,KAAK,EAkBQ;GAChD,SAAS,CAjBsB;IAC/B,IAAI;IACJ,YAAY,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;IACH,YAAY,cAAc,YACxBD,8CAAmB;KACjB,GAAGE;KACH,OAAO;KACP,UAAU;KACX,CAAC;IACL,CAI2B;GAC1B,eAAe,KAAK;GACpB,SAAS,EAAE;GACZ,CAAC;EAEF,MAAM,UAAU,eACdF,8CAAmB;GACjB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WAAWC;IACX,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACd,GAAG;KACJ;IACD,gBAAgB;KACd,MAAM,EAAE,mBAAmBE,sDAAa;AACxC,YAAO,eAAe,MAAM,WAAW;;IAE1C;GACD,iBAAiB,EACf,UAAU,eACX;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAET,OAAI,SAAS,WACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,eAAqB,OAAO,WAAW;AAGjD,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;AAaD,MAAa,iBAA0B;CACrC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaC,yBAAS;CAC1D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAMA,yBAAS,UAChB,CACF;EAED,MAAM,WAAW,KAAKA,yBAAS;AAE/B,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./installIntlayer.mjs";
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer } from "./installIntlayer.mjs";
|
|
2
2
|
import { useDictionary } from "./useDictionary.mjs";
|
|
3
3
|
import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
|
|
4
4
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
@@ -7,4 +7,4 @@ import { useIntl } from "./useIntl.mjs";
|
|
|
7
7
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
|
|
8
8
|
import { useLocale } from "./useLocale.mjs";
|
|
9
9
|
|
|
10
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
10
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -26,12 +26,39 @@ const createIntlayerClient = (locale, isCookieEnabled = true) => {
|
|
|
26
26
|
return instance;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Provides Intlayer to your Angular application.
|
|
30
|
+
*
|
|
31
|
+
* This function should be used in your application's provider list (e.g., in `app.config.ts`)
|
|
32
|
+
* to initialize the Intlayer service.
|
|
33
|
+
*
|
|
34
|
+
* @param locale - Initial locale to use.
|
|
35
|
+
* @param isCookieEnabled - Whether to store the locale in cookies.
|
|
36
|
+
* @returns A provider configuration for Intlayer.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // app.config.ts
|
|
41
|
+
* import { ApplicationConfig } from '@angular/core';
|
|
42
|
+
* import { provideIntlayer } from 'angular-intlayer';
|
|
43
|
+
*
|
|
44
|
+
* export const appConfig: ApplicationConfig = {
|
|
45
|
+
* providers: [
|
|
46
|
+
* provideIntlayer({ locale: 'en' }),
|
|
47
|
+
* ],
|
|
48
|
+
* };
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
const provideIntlayer = (locale, isCookieEnabled = true) => ({
|
|
52
|
+
provide: INTLAYER_TOKEN,
|
|
53
|
+
useValue: installIntlayer(locale, isCookieEnabled)
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Helper to install the Intlayer provider.
|
|
30
57
|
*/
|
|
31
58
|
const installIntlayer = (locale, isCookieEnabled = true) => {
|
|
32
59
|
return createIntlayerClient(locale, isCookieEnabled);
|
|
33
60
|
};
|
|
34
61
|
|
|
35
62
|
//#endregion
|
|
36
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer };
|
|
63
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer };
|
|
37
64
|
//# sourceMappingURL=installIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider
|
|
1
|
+
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;AAKxC,IAAa,mBAHb,CAAC,WAAW,EACV,YAAY,QACb,CAAC,CACF,MAA8B;CAC5B,kBAAkB,OAAO,KAAK;CAC9B,AAAQ,UAAU,OAChB,cAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;;;;AAO5B,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,mBACX,QACA,kBAAkB,UACd;CACJ,SAAS;CACT,UAAU,gBAAgB,QAAQ,gBAAgB;CACnD;;;;AAKD,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
|
|
@@ -5,6 +5,31 @@ import { computed, inject } from "@angular/core";
|
|
|
5
5
|
//#region src/client/useIntlayer.ts
|
|
6
6
|
/** guard utility - true only for objects generated by `renderIntlayerNode()` */
|
|
7
7
|
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
8
|
+
/**
|
|
9
|
+
* Angular hook that picks one dictionary by its key and returns its reactive content.
|
|
10
|
+
*
|
|
11
|
+
* It utilizes Angular signals to provide deep reactivity, ensuring your components
|
|
12
|
+
* update automatically when the locale changes.
|
|
13
|
+
*
|
|
14
|
+
* @param key - The unique key of the dictionary to retrieve.
|
|
15
|
+
* @param locale - Optional locale to override the current context locale.
|
|
16
|
+
* @returns The transformed dictionary content.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Component } from '@angular/core';
|
|
21
|
+
* import { useIntlayer } from 'angular-intlayer';
|
|
22
|
+
*
|
|
23
|
+
* @Component({
|
|
24
|
+
* standalone: true,
|
|
25
|
+
* selector: 'app-my-component',
|
|
26
|
+
* template: `<div>{{ content().myField.value }}</div>`,
|
|
27
|
+
* })
|
|
28
|
+
* export class MyComponent {
|
|
29
|
+
* content = useIntlayer('my-dictionary-key');
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
8
33
|
const useIntlayer = (key, locale) => {
|
|
9
34
|
const intlayer = inject(INTLAYER_TOKEN);
|
|
10
35
|
/** which locale should we use right now? */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\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\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\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 = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
|
|
@@ -5,7 +5,31 @@ import configuration from "@intlayer/config/built";
|
|
|
5
5
|
|
|
6
6
|
//#region src/client/useLocale.ts
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Angular hook to manage the current locale and related functions.
|
|
9
|
+
*
|
|
10
|
+
* @param props - Optional configuration for locale management.
|
|
11
|
+
* @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Component } from '@angular/core';
|
|
16
|
+
* import { useLocale } from 'angular-intlayer';
|
|
17
|
+
*
|
|
18
|
+
* @Component({
|
|
19
|
+
* standalone: true,
|
|
20
|
+
* selector: 'app-locale-switcher',
|
|
21
|
+
* template: `
|
|
22
|
+
* <select [value]="locale()" (change)="setLocale($any($event.target).value)">
|
|
23
|
+
* @for (loc of availableLocales; track loc) {
|
|
24
|
+
* <option [value]="loc">{{ loc }}</option>
|
|
25
|
+
* }
|
|
26
|
+
* </select>
|
|
27
|
+
* `,
|
|
28
|
+
* })
|
|
29
|
+
* export class LocaleSwitcher {
|
|
30
|
+
* const { locale, setLocale, availableLocales } = useLocale();
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
11
35
|
const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9B,eAAe,wBAAwB,EAAE;CAC3C,MAAM,WAAW,OAAyB,eAAe;CAGzD,MAAM,SAAS,eAAe,UAAU,QAAQ,IAAI,cAAc;CAClE,MAAM,yBAAyB,eACvB,UAAU,iBAAiB,IAAI,KACtC;CAED,MAAM,aAAa,cAA6B;AAC9C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,MAAI,SACF,UAAS,UAAU,UAAU;AAE/B,qBACE,WACA,mBAAmB,wBAAwB,IAAI,KAChD;AACD,mBAAiB,UAAU;;AAG7B,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./client/installIntlayer.mjs";
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer } from "./client/installIntlayer.mjs";
|
|
2
2
|
import { useDictionary } from "./client/useDictionary.mjs";
|
|
3
3
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
4
4
|
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
@@ -11,4 +11,4 @@ import { INTLAYER_MARKDOWN_TOKEN, IntlayerMarkdownService, createIntlayerMarkdow
|
|
|
11
11
|
import { intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
|
|
12
12
|
import { getDictionary } from "./getDictionary.mjs";
|
|
13
13
|
|
|
14
|
-
export { INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownService, IntlayerProvider, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
14
|
+
export { INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownService, IntlayerProvider, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -41,7 +41,7 @@ const markdownStringPlugin = {
|
|
|
41
41
|
dictionaryKey: rest.dictionaryKey,
|
|
42
42
|
keyPath: []
|
|
43
43
|
});
|
|
44
|
-
const render = (
|
|
44
|
+
const render = (components) => renderIntlayerNode({
|
|
45
45
|
...props,
|
|
46
46
|
value: node,
|
|
47
47
|
children: () => ({
|
|
@@ -49,11 +49,11 @@ const markdownStringPlugin = {
|
|
|
49
49
|
props: {
|
|
50
50
|
dictionaryKey: rest.dictionaryKey,
|
|
51
51
|
keyPath: rest.keyPath,
|
|
52
|
-
...
|
|
52
|
+
...components
|
|
53
53
|
},
|
|
54
54
|
children: () => {
|
|
55
55
|
const { renderMarkdown } = useMarkdown();
|
|
56
|
-
return renderMarkdown(node,
|
|
56
|
+
return renderMarkdown(node, components);
|
|
57
57
|
}
|
|
58
58
|
}),
|
|
59
59
|
additionalProps: { metadata: metadataNodes }
|
|
@@ -62,7 +62,7 @@ const markdownStringPlugin = {
|
|
|
62
62
|
return new Proxy(element, { get(target, prop, receiver) {
|
|
63
63
|
if (prop === "value") return node;
|
|
64
64
|
if (prop === "metadata") return metadataNodes;
|
|
65
|
-
if (prop === "use") return (
|
|
65
|
+
if (prop === "use") return (components) => render(components);
|
|
66
66
|
return Reflect.get(target, prop, receiver);
|
|
67
67
|
} });
|
|
68
68
|
}
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":["props"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":["props"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLCond,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? {\n use: (components: any) => any;\n metadata: DeepTransformContent<U>;\n } & any\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T, S, L> = HTMLCond<T, S, L>;\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;;;AAiCA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChC,mBAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAW;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWD,MAAa,uBAAgC;CAC3C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,EACJ,SACA,GAAG,SACD;EAoBJ,MAAM,gBAAgB,kBAlBL,oBAAoB,KAAK,EAkBQ;GAChD,SAAS,CAjBsB;IAC/B,IAAI;IACJ,YAAY,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;IACH,YAAY,cAAc,YACxB,mBAAmB;KACjB,GAAGA;KACH,OAAO;KACP,UAAU;KACX,CAAC;IACL,CAI2B;GAC1B,eAAe,KAAK;GACpB,SAAS,EAAE;GACZ,CAAC;EAEF,MAAM,UAAU,eACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WAAW;IACX,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACd,GAAG;KACJ;IACD,gBAAgB;KACd,MAAM,EAAE,mBAAmB,aAAa;AACxC,YAAO,eAAe,MAAM,WAAW;;IAE1C;GACD,iBAAiB,EACf,UAAU,eACX;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAET,OAAI,SAAS,WACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,eAAqB,OAAO,WAAW;AAGjD,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;AAaD,MAAa,iBAA0B;CACrC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;CAC1D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAM,SAAS,UAChB,CACF;EAED,MAAM,WAAW,KAAK,SAAS;AAE/B,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./installIntlayer.js";
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer } from "./installIntlayer.js";
|
|
2
2
|
import { useDictionary } from "./useDictionary.js";
|
|
3
3
|
import { useDictionaryAsync } from "./useDictionaryAsync.js";
|
|
4
4
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
@@ -6,4 +6,4 @@ import { useIntl } from "./useIntl.js";
|
|
|
6
6
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.js";
|
|
7
7
|
import { useLoadDynamic } from "./useLoadDynamic.js";
|
|
8
8
|
import { useLocale } from "./useLocale.js";
|
|
9
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
9
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -15,9 +15,36 @@ declare class IntlayerProvider {
|
|
|
15
15
|
*/
|
|
16
16
|
declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerProvider;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Provides Intlayer to your Angular application.
|
|
19
|
+
*
|
|
20
|
+
* This function should be used in your application's provider list (e.g., in `app.config.ts`)
|
|
21
|
+
* to initialize the Intlayer service.
|
|
22
|
+
*
|
|
23
|
+
* @param locale - Initial locale to use.
|
|
24
|
+
* @param isCookieEnabled - Whether to store the locale in cookies.
|
|
25
|
+
* @returns A provider configuration for Intlayer.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // app.config.ts
|
|
30
|
+
* import { ApplicationConfig } from '@angular/core';
|
|
31
|
+
* import { provideIntlayer } from 'angular-intlayer';
|
|
32
|
+
*
|
|
33
|
+
* export const appConfig: ApplicationConfig = {
|
|
34
|
+
* providers: [
|
|
35
|
+
* provideIntlayer({ locale: 'en' }),
|
|
36
|
+
* ],
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const provideIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => {
|
|
41
|
+
provide: InjectionToken<IntlayerProvider>;
|
|
42
|
+
useValue: IntlayerProvider;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Helper to install the Intlayer provider.
|
|
19
46
|
*/
|
|
20
47
|
declare const installIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerProvider;
|
|
21
48
|
//#endregion
|
|
22
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer };
|
|
49
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer };
|
|
23
50
|
//# sourceMappingURL=installIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":[],"mappings":";;;;;cAIa,gBAAc,eAAA;cAUd,gBAAA;mBAAgB,cAAA,CACZ;EAXJ,QAAA,OAAA;EAUA,SAAA,MAAA,EAMM,MANU,CAMH,aANG,CAAA;EAAA,SAAA,EAAA,CACZ,MAAA,EAOM,aAPN,EAAA,GAAA,IAAA;;;;;AAeJ,cAAA,oBACF,EAAA,CAAA,MAER,CAFQ,EAAA,aAER,EAAA,eAWF,CAAA,EAAA,OAAA,EAAA,GAXE,gBAWF;
|
|
1
|
+
{"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":[],"mappings":";;;;;cAIa,gBAAc,eAAA;cAUd,gBAAA;mBAAgB,cAAA,CACZ;EAXJ,QAAA,OAAA;EAUA,SAAA,MAAA,EAMM,MANU,CAMH,aANG,CAAA;EAAA,SAAA,EAAA,CACZ,MAAA,EAOM,aAPN,EAAA,GAAA,IAAA;;;;;AAeJ,cAAA,oBACF,EAAA,CAAA,MAER,CAFQ,EAAA,aAER,EAAA,eAWF,CAAA,EAAA,OAAA,EAAA,GAXE,gBAWF;AAyBD;;;;;;AAWA;;;;;;;;;;;;;;;;;cAXa,2BACF;;;;;;;cAUE,2BACF,6CACa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
2
|
import "../index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _intlayer_types5 from "@intlayer/types";
|
|
4
4
|
import { Dictionary, DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types";
|
|
5
5
|
import * as _intlayer_core1 from "@intlayer/core";
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ import * as _intlayer_core1 from "@intlayer/core";
|
|
|
10
10
|
*
|
|
11
11
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
12
|
*/
|
|
13
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _intlayer_core1.DeepTransformContent<T["content"], IInterpreterPluginState$1,
|
|
13
|
+
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _intlayer_core1.DeepTransformContent<T["content"], IInterpreterPluginState$1, _intlayer_types5.Locale>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useDictionaryDynamic };
|
|
16
16
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _angular_core0 from "@angular/core";
|
|
2
2
|
import { LocalesValues } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useIntl.d.ts
|
|
@@ -27,7 +27,7 @@ import { LocalesValues } from "@intlayer/types";
|
|
|
27
27
|
* }
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
declare const useIntl: (locale?: LocalesValues) =>
|
|
30
|
+
declare const useIntl: (locale?: LocalesValues) => _angular_core0.Signal<{
|
|
31
31
|
Collator: {
|
|
32
32
|
new (locales?: LocalesValues, options?: Intl.CollatorOptions): Intl.Collator;
|
|
33
33
|
new (options?: Intl.CollatorOptions & {
|
|
@@ -6,6 +6,31 @@ import { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from "@intla
|
|
|
6
6
|
declare const isUpdatableNode: (val: unknown) => val is {
|
|
7
7
|
__update: (n: unknown) => void;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Angular hook that picks one dictionary by its key and returns its reactive content.
|
|
11
|
+
*
|
|
12
|
+
* It utilizes Angular signals to provide deep reactivity, ensuring your components
|
|
13
|
+
* update automatically when the locale changes.
|
|
14
|
+
*
|
|
15
|
+
* @param key - The unique key of the dictionary to retrieve.
|
|
16
|
+
* @param locale - Optional locale to override the current context locale.
|
|
17
|
+
* @returns The transformed dictionary content.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Component } from '@angular/core';
|
|
22
|
+
* import { useIntlayer } from 'angular-intlayer';
|
|
23
|
+
*
|
|
24
|
+
* @Component({
|
|
25
|
+
* standalone: true,
|
|
26
|
+
* selector: 'app-my-component',
|
|
27
|
+
* template: `<div>{{ content().myField.value }}</div>`,
|
|
28
|
+
* })
|
|
29
|
+
* export class MyComponent {
|
|
30
|
+
* content = useIntlayer('my-dictionary-key');
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
9
34
|
declare const useIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: LocalesValues) => DeepTransformContent<DictionaryRegistryContent<T>>;
|
|
10
35
|
//#endregion
|
|
11
36
|
export { isUpdatableNode, useIntlayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":[],"mappings":";;;;;cAWa;EAAA,QAAA,EAAA,CAAA,CAAA,EAAA,OAKgC,EAAA,GAAA,IAAA;
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":[],"mappings":";;;;;cAWa;EAAA,QAAA,EAAA,CAAA,CAAA,EAAA,OAKgC,EAAA,GAAA,IAAA;AA2B7C,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,wBAAyB,0BAA0B,oBACzD,YACI,kBACR,qBAAqB,0BAA0B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as _angular_core2 from "@angular/core";
|
|
2
|
+
import * as _intlayer_types3 from "@intlayer/types";
|
|
3
3
|
import { LocalesValues } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/client/useLocale.d.ts
|
|
@@ -8,15 +8,39 @@ type useLocaleProps = {
|
|
|
8
8
|
onLocaleChange?: (locale: LocalesValues) => void;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Angular hook to manage the current locale and related functions.
|
|
12
|
+
*
|
|
13
|
+
* @param props - Optional configuration for locale management.
|
|
14
|
+
* @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Component } from '@angular/core';
|
|
19
|
+
* import { useLocale } from 'angular-intlayer';
|
|
20
|
+
*
|
|
21
|
+
* @Component({
|
|
22
|
+
* standalone: true,
|
|
23
|
+
* selector: 'app-locale-switcher',
|
|
24
|
+
* template: `
|
|
25
|
+
* <select [value]="locale()" (change)="setLocale($any($event.target).value)">
|
|
26
|
+
* @for (loc of availableLocales; track loc) {
|
|
27
|
+
* <option [value]="loc">{{ loc }}</option>
|
|
28
|
+
* }
|
|
29
|
+
* </select>
|
|
30
|
+
* `,
|
|
31
|
+
* })
|
|
32
|
+
* export class LocaleSwitcher {
|
|
33
|
+
* const { locale, setLocale, availableLocales } = useLocale();
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
12
36
|
*/
|
|
13
37
|
declare const useLocale: ({
|
|
14
38
|
isCookieEnabled,
|
|
15
39
|
onLocaleChange
|
|
16
40
|
}?: useLocaleProps) => {
|
|
17
|
-
locale:
|
|
18
|
-
defaultLocale:
|
|
19
|
-
availableLocales:
|
|
41
|
+
locale: _angular_core2.Signal<"af" | "af-ZA" | "ar" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-OM" | "ar-QA" | "ar-SA" | "ar-SY" | "ar-TN" | "ar-YE" | "az" | "az-AZ" | "be" | "be-BY" | "bg" | "bg-BG" | "bs" | "bs-BA" | "ca" | "ca-ES" | "cs" | "cs-CZ" | "cy" | "cy-GB" | "da" | "da-DK" | "de" | "de-AT" | "de-CH" | "de-DE" | "de-LI" | "de-LU" | "dv" | "dv-MV" | "el" | "el-GR" | "en" | "en-AU" | "en-BZ" | "en-CA" | "en-CB" | "en-GB" | "en-IE" | "en-JM" | "en-NZ" | "en-PH" | "en-TT" | "en-US" | "en-ZA" | "en-ZW" | "eo" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-DO" | "es-EC" | "es-ES" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PE" | "es-PR" | "es-PY" | "es-SV" | "es-UY" | "es-VE" | "et" | "et-EE" | "eu" | "eu-ES" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fo" | "fo-FO" | "fr" | "fr-BE" | "fr-CA" | "fr-CH" | "fr-FR" | "fr-LU" | "fr-MC" | "ga" | "ga-IE" | "gd" | "gd-GB" | "gl" | "gl-ES" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hr" | "hr-BA" | "hr-HR" | "hu" | "hu-HU" | "hy" | "hy-AM" | "id" | "id-ID" | "is" | "is-IS" | "it" | "it-CH" | "it-IT" | "ja" | "ja-JP" | "ka" | "ka-GE" | "kk" | "kk-KZ" | "kn" | "kn-IN" | "ko" | "ko-KR" | "kok" | "kok-IN" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lt" | "lt-LT" | "lv" | "lv-LV" | "mi" | "mi-NZ" | "mk" | "mk-MK" | "mn" | "mn-MN" | "mr" | "mr-IN" | "ms" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "ml" | "ml-IN" | "no" | "nb" | "nb-NO" | "nl" | "nl-BE" | "nl-NL" | "nn" | "nn-NO" | "ns" | "ns-ZA" | "pa" | "pa-IN" | "pl" | "pl-PL" | "ps" | "ps-AR" | "pt" | "pt-BR" | "pt-PT" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-RO" | "ro-MD" | "rm" | "rm-CH" | "ru" | "ru-RU" | "ru-MD" | "sa" | "sa-IN" | "se" | "se-FI" | "se-NO" | "se-SE" | "hsb" | "hsb-DE" | "dsb" | "dsb-DE" | "sk" | "sk-SK" | "sl" | "sl-SI" | "sq" | "sq-AL" | "sr" | "sr-BA" | "sr-SP" | "sv" | "sv-FI" | "sv-SE" | "sw" | "sw-KE" | "syr" | "syr-SY" | "ta" | "ta-IN" | "te" | "te-IN" | "th" | "th-TH" | "tl" | "tl-PH" | "tn" | "tn-ZA" | "tr" | "tr-TR" | "tt" | "tt-RU" | "ts" | "uk" | "uk-UA" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "vi" | "vi-VN" | "ve" | "ve-ZA" | "xh" | "xh-ZA" | "zh" | "zh-Hans" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-SG" | "zh-Hant" | "zu" | "zu-ZA" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "my" | "my-MM" | "km" | "km-KH" | "lo" | "lo-LA" | "yo" | "yo-NG" | "yi" | "yi-001" | "am" | "am-ET" | "ne" | "ne-NP" | "si" | "si-LK" | "sr-Cyrl" | "sr-RS" | "en-IN" | "en-SG" | "en-HK" | "en-NG" | "en-PK" | "en-MY" | "en-BW" | "en-KE" | "en-TZ" | "en-GH" | "en-UG" | "es-CU" | "es-US" | "pt-GW" | "pt-MZ" | "pt-ST" | "pt-CV" | "pt-TL" | "pt-MO" | "zh-TW" | "ar-MR" | "ar-PS" | "ar-SD" | "ar-DJ" | "ar-SO" | "ar-TD" | "ar-KM" | (string & {})>;
|
|
42
|
+
defaultLocale: _intlayer_types3.Locale;
|
|
43
|
+
availableLocales: _intlayer_types3.Locale[];
|
|
20
44
|
setLocale: (newLocale: LocalesValues) => void;
|
|
21
45
|
};
|
|
22
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":[],"mappings":";;;;;KAMK,cAAA;;4BAEuB;;AANyB;
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":[],"mappings":";;;;;KAMK,cAAA;;4BAEuB;;AANyB;AAoCrD;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa;;;IAGV;UAAmB,cAAA,CAAA;;;yBAWU"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
2
2
|
import { LocalesValues } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useLocaleStorage.d.ts
|
|
@@ -9,13 +9,13 @@ import { LocalesValues } from "@intlayer/types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Get the locale cookie
|
|
11
11
|
*/
|
|
12
|
-
declare const localeInStorage:
|
|
12
|
+
declare const localeInStorage: _intlayer_types0.Locale;
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated Use localeInStorage instead
|
|
15
15
|
*
|
|
16
16
|
* Get the locale cookie
|
|
17
17
|
*/
|
|
18
|
-
declare const localeCookie:
|
|
18
|
+
declare const localeCookie: _intlayer_types0.Locale;
|
|
19
19
|
/**
|
|
20
20
|
* Set the locale cookie
|
|
21
21
|
*/
|
|
@@ -30,7 +30,7 @@ declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean)
|
|
|
30
30
|
* Hook that provides the locale storage and a function to set it
|
|
31
31
|
*/
|
|
32
32
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
33
|
-
getLocale: () =>
|
|
33
|
+
getLocale: () => _intlayer_types0.Locale;
|
|
34
34
|
setLocale: (locale: LocalesValues) => void;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
@@ -41,7 +41,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
41
41
|
* Hook that provides the locale cookie and a function to set it
|
|
42
42
|
*/
|
|
43
43
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
44
|
-
localeCookie:
|
|
44
|
+
localeCookie: _intlayer_types0.Locale;
|
|
45
45
|
setLocaleCookie: (locale: LocalesValues) => void;
|
|
46
46
|
};
|
|
47
47
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _angular_core1 from "@angular/core";
|
|
2
2
|
import { KeyPath, Locale } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/editor/EditedContentRenderer.component.d.ts
|
|
@@ -16,7 +16,7 @@ declare class EditedContentRendererComponent {
|
|
|
16
16
|
/**
|
|
17
17
|
* Object → getContent → string, same as the React version.
|
|
18
18
|
*/
|
|
19
|
-
renderedContent:
|
|
19
|
+
renderedContent: _angular_core1.Signal<string>;
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
export { EditedContentRendererComponent, EditedContentRendererProps };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./client/installIntlayer.js";
|
|
2
|
-
import { DeepTransformContent, IInterpreterPluginAngular, IInterpreterPluginState, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.js";
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer } from "./client/installIntlayer.js";
|
|
2
|
+
import { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.js";
|
|
3
3
|
import { useDictionary } from "./client/useDictionary.js";
|
|
4
4
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.js";
|
|
5
5
|
import { getDictionary } from "./getDictionary.js";
|
|
@@ -19,5 +19,5 @@ declare module '@intlayer/core' {
|
|
|
19
19
|
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginAngular<T, S, L> {}
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
|
-
export { DeepTransformContent, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownProvider, IntlayerMarkdownService, IntlayerNode, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
22
|
+
export { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownProvider, IntlayerMarkdownService, IntlayerNode, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LocalesValues, NodeType } from "@intlayer/types";
|
|
2
|
-
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core";
|
|
1
|
+
import { DeclaredLocales, LocalesValues, NodeType } from "@intlayer/types";
|
|
2
|
+
import { DeepTransformContent as DeepTransformContent$1, HTMLCond, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins.d.ts
|
|
5
5
|
|
|
@@ -27,16 +27,18 @@ type MarkdownCond<T, S, L extends LocalesValues> = T extends {
|
|
|
27
27
|
[NodeType.Markdown]: infer M;
|
|
28
28
|
metadata?: infer U;
|
|
29
29
|
} ? {
|
|
30
|
-
use: (
|
|
30
|
+
use: (components: any) => any;
|
|
31
31
|
metadata: DeepTransformContent<U>;
|
|
32
32
|
} & any : never;
|
|
33
33
|
declare const markdownPlugin: Plugins;
|
|
34
34
|
/** ---------------------------------------------
|
|
35
35
|
* PLUGINS RESULT
|
|
36
36
|
* --------------------------------------------- */
|
|
37
|
+
type HTMLPluginCond<T, S, L> = HTMLCond<T, S, L>;
|
|
37
38
|
interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
angularIntlayerNode: IntlayerNodeCond<T>;
|
|
40
|
+
angularMarkdown: MarkdownCond<T, S, L>;
|
|
41
|
+
angularHtml: HTMLPluginCond<T, S, L>;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.
|
|
@@ -44,10 +46,11 @@ interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {
|
|
|
44
46
|
* Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.
|
|
45
47
|
*/
|
|
46
48
|
type IInterpreterPluginState = IInterpreterPluginState$1 & {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
angularIntlayerNode: true;
|
|
50
|
+
angularMarkdown: true;
|
|
51
|
+
angularHtml: true;
|
|
49
52
|
};
|
|
50
|
-
type DeepTransformContent<T> = DeepTransformContent$1<T, IInterpreterPluginState>;
|
|
53
|
+
type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContent$1<T, IInterpreterPluginState, L>;
|
|
51
54
|
//#endregion
|
|
52
|
-
export { DeepTransformContent, IInterpreterPluginAngular, IInterpreterPluginState, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin };
|
|
55
|
+
export { DeepTransformContent, HTMLPluginCond, IInterpreterPluginAngular, IInterpreterPluginState, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin };
|
|
53
56
|
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsBA;AAAkC,KAAtB,gBAAsB,CAAA,CAAA,CAAA,GAAA,CAAA,SAAA,MAAA,GAAA,MAAA,GAC9B,YAD8B,CACjB,CADiB,CAAA,GAAA,KAAA;AACjB,UAGA,YAHA,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;EAAb,KAAA,EAIK,CAJL;EAAY,QAAA,CAAA,EAAA,GAAA;EAGC,eAAY,CAAA,EAGT,CAHS;AAO7B;AAyBA;AAAoC,cAzBvB,mBAyBuB,EAzBF,OAyBE;;;;AAKvB,KALD,kBA8EX,CAAA,CAAA,CAAA,GA9EmC,CA8EnC,SAAA,MAAA,GA7EG,YA6EH,CAAA,MAAA,EAAA;EAEW,QAAA,EA/EyB,oBA+Eb,CAAA,MAAA,CAAA;CAAiB,CAAA,GAAA,KAAA;;AAC7B,cA5EC,oBA4ED,EA5EuB,OA4EvB;AACT,KAFS,YAEA,CAAA,CAAA,EAAA,CAAA,EAAA,UAF6B,aAE7B,CAAA,GAF8C,CAE9C,SAAA;EAKyB,QAAA,EANzB,QAMyB,GAAA,MAAA;EAArB,CALb,QAAA,CAAS,QAAA,CAKI,EAAA,KAAA,EAAA;EAAoB,QAAA,CAAA,EAAA,KAAA,EAAA;AAIpC,CAAA,GAAa;EA2BD,GAAA,EAAA,CAAA,UAAA,EAAc,GAAA,EAAA,GAAA,GAAA;EAAqB,QAAA,EA/B/B,oBA+B+B,CA/BV,CA+BU,CAAA;CAAG,GAAA,GAAA,GAAA,KAAA;AAAG,cA3BxC,cA2BwC,EA3BxB,OA2BwB;;;AAErD;AAA2D,KAF/C,cAE+C,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,GAFrB,QAEqB,CAFZ,CAEY,EAFT,CAES,EAFN,CAEM,CAAA;AACnB,UADvB,yBACuB,CAAA,CAAA,EAAA,CAAA,EAAA,UADmB,aACnB,CAAA,CAAA;EAAjB,mBAAA,EAAA,gBAAA,CAAiB,CAAjB,CAAA;EACS,eAAA,EAAb,YAAa,CAAA,CAAA,EAAG,CAAH,EAAM,CAAN,CAAA;EAAG,WAAA,EACpB,cADoB,CACL,CADK,EACF,CADE,EACC,CADD,CAAA;;;;;;;AACN,KAQjB,uBAAA,GAA0B,yBART,GAAA;EAQjB,mBAAA,EAAA,IAAA;EAMA,eAAA,EAAA,IAAA;EAEA,WAAA,EAAA,IAAA;CAAgB;AACC,KAHjB,oBAGiB,CAAA,CAAA,EAAA,UADjB,aACiB,GADD,eACC,CAAA,GAAzB,sBAAyB,CAAA,CAAA,EAAG,uBAAH,EAA4B,CAA5B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-intlayer",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@intlayer/chokidar": "8.0.0-canary.
|
|
89
|
-
"@intlayer/config": "8.0.0-canary.
|
|
90
|
-
"@intlayer/core": "8.0.0-canary.
|
|
91
|
-
"@intlayer/dictionaries-entry": "8.0.0-canary.
|
|
92
|
-
"@intlayer/editor": "8.0.0-canary.
|
|
93
|
-
"@intlayer/types": "8.0.0-canary.
|
|
94
|
-
"@intlayer/webpack": "8.0.0-canary.
|
|
88
|
+
"@intlayer/chokidar": "8.0.0-canary.1",
|
|
89
|
+
"@intlayer/config": "8.0.0-canary.1",
|
|
90
|
+
"@intlayer/core": "8.0.0-canary.1",
|
|
91
|
+
"@intlayer/dictionaries-entry": "8.0.0-canary.1",
|
|
92
|
+
"@intlayer/editor": "8.0.0-canary.1",
|
|
93
|
+
"@intlayer/types": "8.0.0-canary.1",
|
|
94
|
+
"@intlayer/webpack": "8.0.0-canary.1",
|
|
95
95
|
"defu": "6.1.4"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|