angular-intlayer 9.5.0 → 9.5.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.
@@ -5,6 +5,7 @@ let _intlayer_config_built = require("@intlayer/config/built");
5
5
  let _angular_core = require("@angular/core");
6
6
 
7
7
  //#region src/client/useLocale.ts
8
+ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
8
9
  /**
9
10
  * Angular hook to manage the current locale and related functions.
10
11
  *
@@ -33,7 +34,6 @@ let _angular_core = require("@angular/core");
33
34
  * ```
34
35
  */
35
36
  const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
36
- const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
37
37
  const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
38
38
  const locale = (0, _angular_core.computed)(() => intlayer?.locale() ?? defaultLocale);
39
39
  const isCookieEnabledContext = (0, _angular_core.computed)(() => intlayer?.isCookieEnabled() ?? true);
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","inject","INTLAYER_TOKEN","computed"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (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 = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\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 as DeclaredLocales);\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,CAAC;CAC3B,MAAM,eAAWC,sBAAyBC,2CAAc;CAGxD,MAAM,aAASC,8BACN,UAAU,OAAO,KAAK,aAC/B;CACA,MAAM,6BAAyBA,8BACvB,UAAU,gBAAgB,KAAK,IACvC;CAEA,MAAM,aAAa,cAA6B;EAC9C,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,IAAI,UACF,SAAS,UAAU,SAAS;EAE9B,mDACE,WACA,mBAAmB,uBAAuB,KAAK,IACjD;EACA,iBAAiB,SAA4B;CAC/C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","inject","INTLAYER_TOKEN","computed"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization ?? {};\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 = {}): UseLocaleResult => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\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 as DeclaredLocales);\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;AAqBA,MAAM,EAAE,eAAe,SAAS,qBAAqBA,+CAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B9E,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,eAAWC,sBAAyBC,2CAAc;CAGxD,MAAM,aAASC,8BACN,UAAU,OAAO,KAAK,aAC/B;CACA,MAAM,6BAAyBA,8BACvB,UAAU,gBAAgB,KAAK,IACvC;CAEA,MAAM,aAAa,cAA6B;EAC9C,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,IAAI,UACF,SAAS,UAAU,SAAS;EAE9B,mDACE,WACA,mBAAmB,uBAAuB,KAAK,IACjD;EACA,iBAAiB,SAA4B;CAC/C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let node_fs_promises = require("node:fs/promises");
3
2
  let node_module = require("node:module");
4
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");
6
+ let node_fs_promises = require("node:fs/promises");
5
7
  let _intlayer_config_dictionaryPreload = require("@intlayer/config/dictionaryPreload");
6
8
  let _intlayer_config_envVars = require("@intlayer/config/envVars");
7
9
  let _intlayer_config_logger = require("@intlayer/config/logger");
8
- let _intlayer_config_node = require("@intlayer/config/node");
9
- let _intlayer_config_utils = require("@intlayer/config/utils");
10
10
  let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
11
11
  let _intlayer_engine_build = require("@intlayer/engine/build");
12
12
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
@@ -4,6 +4,7 @@ import { internationalization } from "@intlayer/config/built";
4
4
  import { computed, inject } from "@angular/core";
5
5
 
6
6
  //#region src/client/useLocale.ts
7
+ const { defaultLocale, locales: availableLocales } = internationalization ?? {};
7
8
  /**
8
9
  * Angular hook to manage the current locale and related functions.
9
10
  *
@@ -32,7 +33,6 @@ import { computed, inject } from "@angular/core";
32
33
  * ```
33
34
  */
34
35
  const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
35
- const { defaultLocale, locales: availableLocales } = internationalization ?? {};
36
36
  const intlayer = inject(INTLAYER_TOKEN);
37
37
  const locale = computed(() => intlayer?.locale() ?? defaultLocale);
38
38
  const isCookieEnabledContext = computed(() => intlayer?.isCookieEnabled() ?? true);
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (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 = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\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 as DeclaredLocales);\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,CAAC;CAC3B,MAAM,WAAW,OAAyB,cAAc;CAGxD,MAAM,SAAS,eACN,UAAU,OAAO,KAAK,aAC/B;CACA,MAAM,yBAAyB,eACvB,UAAU,gBAAgB,KAAK,IACvC;CAEA,MAAM,aAAa,cAA6B;EAC9C,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,IAAI,UACF,SAAS,UAAU,SAAS;EAE9B,mBACE,WACA,mBAAmB,uBAAuB,KAAK,IACjD;EACA,iBAAiB,SAA4B;CAC/C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization ?? {};\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 = {}): UseLocaleResult => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\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 as DeclaredLocales);\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 } as UseLocaleResult;\n};\n"],"mappings":";;;;;;AAqBA,MAAM,EAAE,eAAe,SAAS,qBAAqB,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B9E,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,WAAW,OAAyB,cAAc;CAGxD,MAAM,SAAS,eACN,UAAU,OAAO,KAAK,aAC/B;CACA,MAAM,yBAAyB,eACvB,UAAU,gBAAgB,KAAK,IACvC;CAEA,MAAM,aAAa,cAA6B;EAC9C,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,IAAI,UACF,SAAS,UAAU,SAAS;EAE9B,mBACE,WACA,mBAAmB,uBAAuB,KAAK,IACjD;EACA,iBAAiB,SAA4B;CAC/C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1,12 +1,12 @@
1
1
  import { __require } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { readFile } from "node:fs/promises";
2
3
  import { createRequire } from "node:module";
3
4
  import { join } from "node:path";
4
- import { getConfiguration } from "@intlayer/config/node";
5
- import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync, normalizePath } from "@intlayer/config/utils";
6
- import { readFile } from "node:fs/promises";
7
5
  import { addDynamicEntryPreload, createDynamicEntryFilter, resolvePreloadModuleId } from "@intlayer/config/dictionaryPreload";
8
6
  import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
9
7
  import { getAppLogger } from "@intlayer/config/logger";
8
+ import { getConfiguration } from "@intlayer/config/node";
9
+ import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync, normalizePath } from "@intlayer/config/utils";
10
10
  import { getDictionaries } from "@intlayer/dictionaries-entry";
11
11
  import { prepareIntlayer } from "@intlayer/engine/build";
12
12
  import { logConfigDetails } from "@intlayer/engine/cli";
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;YASY;EACV;EACA,kBAAkB,QAAQ;;YAGhB;EACV,QAAQ,OAAO;EACf,eAAe;EACf,kBAAkB;EAClB,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8BT,cAAS,iBAAA,mBAGnB,mBAAsB"}
1
+ {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;YASY;EACV;EACA,kBAAkB,QAAQ;;YAGhB;EACV,QAAQ,OAAO;EACf,eAAe;EACf,kBAAkB;EAClB,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCT,cAAS,iBAAA,mBAGnB,mBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-intlayer",
3
- "version": "9.5.0",
3
+ "version": "9.5.1",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -119,13 +119,13 @@
119
119
  "@babel/core": "^8.0.1",
120
120
  "@babel/plugin-syntax-import-attributes": "7.29.7",
121
121
  "@babel/preset-env": "8.0.2",
122
- "@intlayer/config": "9.5.0",
123
- "@intlayer/core": "9.5.0",
124
- "@intlayer/dictionaries-entry": "9.5.0",
125
- "@intlayer/editor": "9.5.0",
126
- "@intlayer/engine": "9.5.0",
127
- "@intlayer/types": "9.5.0",
128
- "@intlayer/webpack": "9.5.0",
122
+ "@intlayer/config": "9.5.1",
123
+ "@intlayer/core": "9.5.1",
124
+ "@intlayer/dictionaries-entry": "9.5.1",
125
+ "@intlayer/editor": "9.5.1",
126
+ "@intlayer/engine": "9.5.1",
127
+ "@intlayer/types": "9.5.1",
128
+ "@intlayer/webpack": "9.5.1",
129
129
  "babel-loader": "10.1.1",
130
130
  "defu": "6.1.7"
131
131
  },
@@ -155,7 +155,7 @@
155
155
  }
156
156
  },
157
157
  "optionalDependencies": {
158
- "@intlayer/analytics": "9.5.0"
158
+ "@intlayer/analytics": "9.5.1"
159
159
  },
160
160
  "engines": {
161
161
  "node": ">=14.18"