angular-intlayer 8.4.3 → 8.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +11 -0
  2. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs +8 -0
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/cjs/client/index.cjs +28 -1
  5. package/dist/cjs/client/installIntlayer.cjs +77 -1
  6. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +15 -1
  8. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryAsync.cjs +24 -1
  10. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +25 -1
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useIntl.cjs +40 -1
  14. package/dist/cjs/client/useIntl.cjs.map +1 -1
  15. package/dist/cjs/client/useIntlayer.cjs +44 -1
  16. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  17. package/dist/cjs/client/useLoadDynamic.cjs +28 -1
  18. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  19. package/dist/cjs/client/useLocale.cjs +60 -1
  20. package/dist/cjs/client/useLocale.cjs.map +1 -1
  21. package/dist/cjs/client/useLocaleStorage.cjs +61 -1
  22. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  23. package/dist/cjs/editor/ContentSelector.component.cjs +38 -1
  24. package/dist/cjs/editor/ContentSelector.component.cjs.map +1 -0
  25. package/dist/cjs/editor/useEditor.cjs +31 -1
  26. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  27. package/dist/cjs/getDictionary.cjs +10 -1
  28. package/dist/cjs/getDictionary.cjs.map +1 -1
  29. package/dist/cjs/getIntlayer.cjs +10 -1
  30. package/dist/cjs/getIntlayer.cjs.map +1 -1
  31. package/dist/cjs/index.cjs +50 -1
  32. package/dist/cjs/markdown/index.cjs +13 -1
  33. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +79 -1
  34. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  35. package/dist/cjs/plugins.cjs +212 -1
  36. package/dist/cjs/plugins.cjs.map +1 -1
  37. package/dist/cjs/renderIntlayerNode.cjs +28 -1
  38. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  39. package/dist/cjs/webpack/index.cjs +4 -1
  40. package/dist/cjs/webpack/mergeConfig.cjs +45 -1
  41. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  42. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +10 -0
  43. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs +7 -0
  44. package/dist/esm/client/index.mjs +10 -1
  45. package/dist/esm/client/installIntlayer.mjs +65 -1
  46. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  47. package/dist/esm/client/useDictionary.mjs +13 -1
  48. package/dist/esm/client/useDictionary.mjs.map +1 -1
  49. package/dist/esm/client/useDictionaryAsync.mjs +21 -1
  50. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  51. package/dist/esm/client/useDictionaryDynamic.mjs +22 -1
  52. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  53. package/dist/esm/client/useIntl.mjs +38 -1
  54. package/dist/esm/client/useIntl.mjs.map +1 -1
  55. package/dist/esm/client/useIntlayer.mjs +41 -1
  56. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  57. package/dist/esm/client/useLoadDynamic.mjs +26 -1
  58. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  59. package/dist/esm/client/useLocale.mjs +57 -1
  60. package/dist/esm/client/useLocale.mjs.map +1 -1
  61. package/dist/esm/client/useLocaleStorage.mjs +54 -1
  62. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  63. package/dist/esm/editor/ContentSelector.component.mjs +31 -1
  64. package/dist/esm/editor/ContentSelector.component.mjs.map +1 -0
  65. package/dist/esm/editor/useEditor.mjs +29 -1
  66. package/dist/esm/editor/useEditor.mjs.map +1 -1
  67. package/dist/esm/getDictionary.mjs +8 -1
  68. package/dist/esm/getDictionary.mjs.map +1 -1
  69. package/dist/esm/getIntlayer.mjs +8 -1
  70. package/dist/esm/getIntlayer.mjs.map +1 -1
  71. package/dist/esm/index.mjs +14 -1
  72. package/dist/esm/markdown/index.mjs +3 -1
  73. package/dist/esm/markdown/installIntlayerMarkdown.mjs +68 -1
  74. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  75. package/dist/esm/plugins.mjs +203 -1
  76. package/dist/esm/plugins.mjs.map +1 -1
  77. package/dist/esm/renderIntlayerNode.mjs +26 -1
  78. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  79. package/dist/esm/webpack/index.mjs +3 -1
  80. package/dist/esm/webpack/mergeConfig.mjs +43 -1
  81. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  82. package/dist/types/client/index.d.ts +8 -8
  83. package/dist/types/client/installIntlayer.d.ts +50 -2
  84. package/dist/types/client/installIntlayer.d.ts.map +1 -0
  85. package/dist/types/client/useDictionary.d.ts +10 -2
  86. package/dist/types/client/useDictionary.d.ts.map +1 -0
  87. package/dist/types/client/useDictionaryAsync.d.ts +14 -2
  88. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -0
  89. package/dist/types/client/useDictionaryDynamic.d.ts +17 -2
  90. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  91. package/dist/types/client/useIntl.d.ts +33 -2
  92. package/dist/types/client/useIntl.d.ts.map +1 -0
  93. package/dist/types/client/useIntlayer.d.ts +38 -2
  94. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  95. package/dist/types/client/useLoadDynamic.d.ts +11 -2
  96. package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
  97. package/dist/types/client/useLocale.d.ts +48 -2
  98. package/dist/types/client/useLocale.d.ts.map +1 -0
  99. package/dist/types/getDictionary.d.ts +9 -2
  100. package/dist/types/getDictionary.d.ts.map +1 -0
  101. package/dist/types/getIntlayer.d.ts +8 -2
  102. package/dist/types/getIntlayer.d.ts.map +1 -0
  103. package/dist/types/index.d.ts +21 -13
  104. package/dist/types/index.d.ts.map +1 -0
  105. package/dist/types/markdown/index.d.ts +1 -1
  106. package/dist/types/markdown/installIntlayerMarkdown.d.ts +36 -2
  107. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
  108. package/dist/types/plugins.d.ts +90 -2
  109. package/dist/types/plugins.d.ts.map +1 -0
  110. package/dist/types/webpack/index.d.ts +2 -5
  111. package/dist/types/webpack/mergeConfig.d.ts +5 -2
  112. package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
  113. package/package.json +8 -8
  114. package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs +0 -9
  115. package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs.map +0 -1
  116. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  117. package/dist/cjs/decorate-B_4qGGx3.cjs +0 -1
  118. package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs +0 -9
  119. package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs.map +0 -1
  120. package/dist/esm/decorate-EVKP5RjP.mjs +0 -1
  121. package/dist/types/getDictionary-DDjZzxAC.d.ts +0 -9
  122. package/dist/types/getDictionary-DDjZzxAC.d.ts.map +0 -1
  123. package/dist/types/getIntlayer-CWM6qsJJ.d.ts +0 -8
  124. package/dist/types/getIntlayer-CWM6qsJJ.d.ts.map +0 -1
  125. package/dist/types/index-Cf8zm5QQ.d.ts +0 -1
  126. package/dist/types/index-D5QAgZ5v.d.ts +0 -22
  127. package/dist/types/index-D5QAgZ5v.d.ts.map +0 -1
  128. package/dist/types/installIntlayer-Ce7kST5N.d.ts +0 -50
  129. package/dist/types/installIntlayer-Ce7kST5N.d.ts.map +0 -1
  130. package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts +0 -36
  131. package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts.map +0 -1
  132. package/dist/types/plugins-C_v3w-vC.d.ts +0 -89
  133. package/dist/types/plugins-C_v3w-vC.d.ts.map +0 -1
  134. package/dist/types/useDictionary-Dq9yu0X_.d.ts +0 -10
  135. package/dist/types/useDictionary-Dq9yu0X_.d.ts.map +0 -1
  136. package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts +0 -14
  137. package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts.map +0 -1
  138. package/dist/types/useIntl-CHizZCR2.d.ts +0 -33
  139. package/dist/types/useIntl-CHizZCR2.d.ts.map +0 -1
  140. package/dist/types/useIntlayer-m3n_upwm.d.ts +0 -38
  141. package/dist/types/useIntlayer-m3n_upwm.d.ts.map +0 -1
  142. package/dist/types/useLoadDynamic-C4pltPcC.d.ts +0 -11
  143. package/dist/types/useLoadDynamic-C4pltPcC.d.ts.map +0 -1
  144. package/dist/types/useLocale-BzfAmXlx.d.ts +0 -48
  145. package/dist/types/useLocale-BzfAmXlx.d.ts.map +0 -1
  146. package/dist/types/webpack/index.d.ts.map +0 -1
@@ -0,0 +1,11 @@
1
+
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
3
+ function __decorate(decorators, target, key, desc) {
4
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
8
+ }
9
+
10
+ //#endregion
11
+ exports.__decorate = __decorate;
@@ -0,0 +1,8 @@
1
+
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
3
+ function __decorateMetadata(k, v) {
4
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5
+ }
6
+
7
+ //#endregion
8
+ exports.__decorateMetadata = __decorateMetadata;
@@ -0,0 +1,29 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1 +1,28 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./installIntlayer.cjs`),t=require(`./useDictionary.cjs`),n=require(`./useDictionaryAsync.cjs`),r=require(`./useLoadDynamic.cjs`),i=require(`./useDictionaryDynamic.cjs`),a=require(`./useIntl.cjs`),o=require(`./useIntlayer.cjs`),s=require(`./useLocale.cjs`);exports.INTLAYER_TOKEN=e.INTLAYER_TOKEN,Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return e.IntlayerProvider}}),exports.createIntlayerClient=e.createIntlayerClient,exports.installIntlayer=e.installIntlayer,exports.isUpdatableNode=o.isUpdatableNode,exports.provideIntlayer=e.provideIntlayer,exports.useDictionary=t.useDictionary,exports.useDictionaryAsync=n.useDictionaryAsync,exports.useDictionaryDynamic=i.useDictionaryDynamic,exports.useIntl=a.useIntl,exports.useIntlayer=o.useIntlayer,exports.useLoadDynamic=r.useLoadDynamic,exports.useLocale=s.useLocale;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
3
+ const require_client_useDictionary = require('./useDictionary.cjs');
4
+ const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
5
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
6
+ const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
7
+ const require_client_useIntl = require('./useIntl.cjs');
8
+ const require_client_useIntlayer = require('./useIntlayer.cjs');
9
+ const require_client_useLocale = require('./useLocale.cjs');
10
+
11
+ exports.INTLAYER_TOKEN = require_client_installIntlayer.INTLAYER_TOKEN;
12
+ Object.defineProperty(exports, 'IntlayerProvider', {
13
+ enumerable: true,
14
+ get: function () {
15
+ return require_client_installIntlayer.IntlayerProvider;
16
+ }
17
+ });
18
+ exports.createIntlayerClient = require_client_installIntlayer.createIntlayerClient;
19
+ exports.installIntlayer = require_client_installIntlayer.installIntlayer;
20
+ exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
21
+ exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
22
+ exports.useDictionary = require_client_useDictionary.useDictionary;
23
+ exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
24
+ exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
25
+ exports.useIntl = require_client_useIntl.useIntl;
26
+ exports.useIntlayer = require_client_useIntlayer.useIntlayer;
27
+ exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
28
+ exports.useLocale = require_client_useLocale.useLocale;
@@ -1,2 +1,78 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`../decorate-B_4qGGx3.cjs`);let n=require(`@intlayer/config/built`);n=e.t(n);let r=require(`@angular/core`);const i=new r.InjectionToken(`intlayer`);let a=null,o=class{isCookieEnabled=(0,r.signal)(!0);_locale=(0,r.signal)(n.default.internationalization?.defaultLocale);locale=this._locale.asReadonly();setLocale=e=>{this._locale.set(e)}};o=t.t([(0,r.Injectable)({providedIn:`root`})],o);const s=(e,t=!0)=>a||(a=new o,e&&a.setLocale(e),a.isCookieEnabled.set(t),a),c=(e,t=!0)=>({provide:i,useValue:l(e,t)}),l=(e,t=!0)=>s(e,t);exports.INTLAYER_TOKEN=i,Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return o}}),exports.createIntlayerClient=s,exports.installIntlayer=l,exports.provideIntlayer=c;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
+ let _angular_core = require("@angular/core");
7
+
8
+ //#region src/client/installIntlayer.ts
9
+ const INTLAYER_TOKEN = new _angular_core.InjectionToken("intlayer");
10
+ /**
11
+ * Singleton instance
12
+ */
13
+ let instance = null;
14
+ let IntlayerProvider = class IntlayerProvider {
15
+ isCookieEnabled = (0, _angular_core.signal)(true);
16
+ _locale = (0, _angular_core.signal)(_intlayer_config_built.default.internationalization?.defaultLocale);
17
+ locale = this._locale.asReadonly();
18
+ setLocale = (locale) => {
19
+ this._locale.set(locale);
20
+ };
21
+ };
22
+ IntlayerProvider = require_decorate.__decorate([(0, _angular_core.Injectable)({ providedIn: "root" })], IntlayerProvider);
23
+ /**
24
+ * Create and return a single IntlayerProvider instance
25
+ */
26
+ const createIntlayerClient = (locale, isCookieEnabled = true) => {
27
+ if (instance) return instance;
28
+ instance = new IntlayerProvider();
29
+ if (locale) instance.setLocale(locale);
30
+ instance.isCookieEnabled.set(isCookieEnabled);
31
+ return instance;
32
+ };
33
+ /**
34
+ * Provides Intlayer to your Angular application.
35
+ *
36
+ * This function should be used in your application's provider list (e.g., in `app.config.ts`)
37
+ * to initialize the Intlayer service.
38
+ *
39
+ * @param locale - Initial locale to use.
40
+ * @param isCookieEnabled - Whether to store the locale in cookies.
41
+ * @returns A provider configuration for Intlayer.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * // app.config.ts
46
+ * import { ApplicationConfig } from '@angular/core';
47
+ * import { provideIntlayer } from 'angular-intlayer';
48
+ *
49
+ * export const appConfig: ApplicationConfig = {
50
+ * providers: [
51
+ * provideIntlayer({ locale: 'en' }),
52
+ * ],
53
+ * };
54
+ * ```
55
+ */
56
+ const provideIntlayer = (locale, isCookieEnabled = true) => ({
57
+ provide: INTLAYER_TOKEN,
58
+ useValue: installIntlayer(locale, isCookieEnabled)
59
+ });
60
+ /**
61
+ * Helper to install the Intlayer provider.
62
+ */
63
+ const installIntlayer = (locale, isCookieEnabled = true) => {
64
+ return createIntlayerClient(locale, isCookieEnabled);
65
+ };
66
+
67
+ //#endregion
68
+ exports.INTLAYER_TOKEN = INTLAYER_TOKEN;
69
+ Object.defineProperty(exports, 'IntlayerProvider', {
70
+ enumerable: true,
71
+ get: function () {
72
+ return IntlayerProvider;
73
+ }
74
+ });
75
+ exports.createIntlayerClient = createIntlayerClient;
76
+ exports.installIntlayer = installIntlayer;
77
+ exports.provideIntlayer = provideIntlayer;
2
78
  //# 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/module_augmentation';\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":"kOAIA,MAAa,EAAiB,IAAIA,EAAAA,eAAiC,WAAW,CAK9E,IAAI,EAAoC,KAKjC,EAAA,KAAuB,CAC5B,iBAAA,EAAA,EAAA,QAAyB,GAAK,CAC9B,SAAQ,EAAA,EAAA,QACNC,EAAAA,QAAc,sBAAsB,cACrC,CAED,OAAyC,KAAK,QAAQ,YAAY,CAElE,UAAa,GAA0B,CACrC,KAAK,QAAQ,IAAI,EAAO,2BAZhB,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,GACX,EACA,EAAkB,KAEd,IAEJ,EAAW,IAAI,EAEX,GACF,EAAS,UAAU,EAAO,CAE5B,EAAS,gBAAgB,IAAI,EAAgB,CAEtC,GA0BI,GACX,EACA,EAAkB,MACd,CACJ,QAAS,EACT,SAAU,EAAgB,EAAQ,EAAgB,CACnD,EAKY,GACX,EACA,EAAkB,KAEH,EAAqB,EAAQ,EAAgB"}
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/module_augmentation';\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;AAKjC,6BAAM,iBAAiB;CAC5B,4CAAyB,KAAK;CAC9B,AAAQ,oCACNC,+BAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;8EAZhB,EACV,YAAY,QACb,CAAC;;;;AAiBF,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"}
@@ -1,2 +1,16 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../getDictionary.cjs`),t=require(`./installIntlayer.cjs`);let n=require(`@angular/core`);const r=(r,i)=>{let a=(0,n.inject)(t.INTLAYER_TOKEN),o=(0,n.computed)(()=>i??a?.locale());return(0,n.computed)(()=>e.getDictionary(r,o()))};exports.useDictionary=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_getDictionary = require('../getDictionary.cjs');
4
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
5
+ let _angular_core = require("@angular/core");
6
+
7
+ //#region src/client/useDictionary.ts
8
+ const useDictionary = (dictionary, locale) => {
9
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
10
+ const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer?.locale());
11
+ return (0, _angular_core.computed)(() => require_getDictionary.getDictionary(dictionary, localeTarget()));
12
+ };
13
+
14
+ //#endregion
15
+ exports.useDictionary = useDictionary;
2
16
  //# sourceMappingURL=useDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"8MAOA,MAAa,GACX,EACA,IAC+C,CAC/C,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAA8B,GAAU,GAAU,QAAQ,CAAC,CAOjE,OAAA,EAAA,EAAA,cAHEC,EAAAA,cAAgC,EAAY,GAAc,CAAC,CAC5D"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;AAOA,MAAa,iBACX,YACA,WAC+C;CAC/C,MAAM,qCAAoCA,8CAAe;CAEzD,MAAM,iDAA8B,UAAU,UAAU,QAAQ,CAAC;AAOjE,0CAHEC,oCAAgC,YAAY,cAAc,CAAC,CAC5D"}
@@ -1,2 +1,25 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useDictionary.cjs`);let r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@angular/core`);const a=async(e,a)=>{let o=(0,i.inject)(t.INTLAYER_TOKEN),s=(0,i.computed)(()=>a??o?.locale()??r.default?.internationalization.defaultLocale);return n.useDictionary(await e[s()]?.(),s())};exports.useDictionaryAsync=a;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
6
+ const require_client_useDictionary = require('./useDictionary.cjs');
7
+ let _intlayer_config_built = require("@intlayer/config/built");
8
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
9
+ let _angular_core = require("@angular/core");
10
+
11
+ //#region src/client/useDictionaryAsync.ts
12
+ /**
13
+ * On the server side, Hook that transform a dictionary and return the content
14
+ *
15
+ * If the locale is not provided, it will use the locale from the client context
16
+ */
17
+ const useDictionaryAsync = async (dictionaryPromise, locale) => {
18
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
19
+ const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer?.locale() ?? _intlayer_config_built.default?.internationalization.defaultLocale);
20
+ return require_client_useDictionary.useDictionary(await dictionaryPromise[localeTarget()]?.(), localeTarget());
21
+ };
22
+
23
+ //#endregion
24
+ exports.useDictionaryAsync = useDictionaryAsync;
2
25
  //# sourceMappingURL=useDictionaryAsync.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"6QAcA,MAAa,EAAqB,MAChC,EACA,IACG,CACH,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAEF,GACA,GAAU,QAAQ,EAClBC,EAAAA,SAAe,qBAAqB,cACvC,CAID,OAAOC,EAAAA,cAFY,MAAM,EAAkB,GAAc,KAAK,CAE7B,GAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,qCAAoCA,8CAAe;CAEzD,MAAM,iDAEF,UACA,UAAU,QAAQ,IAClBC,gCAAe,qBAAqB,cACvC;AAID,QAAOC,2CAFY,MAAM,kBAAkB,cAAc,KAAK,EAE7B,cAAc,CAAQ"}
@@ -1,2 +1,26 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useDictionary.cjs`),r=require(`./useLoadDynamic.cjs`);let i=require(`@intlayer/config/built`);i=e.t(i);let a=require(`@angular/core`);const o=(e,o,s)=>{let c=(0,a.inject)(t.INTLAYER_TOKEN),l=(0,a.computed)(()=>s??c?.locale()??i.default?.internationalization.defaultLocale);return n.useDictionary(r.useLoadDynamic(`${String(o)}.${l()}`,e[l()]?.()),l())};exports.useDictionaryDynamic=o;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
6
+ const require_client_useDictionary = require('./useDictionary.cjs');
7
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
8
+ let _intlayer_config_built = require("@intlayer/config/built");
9
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
10
+ let _angular_core = require("@angular/core");
11
+
12
+ //#region src/client/useDictionaryDynamic.ts
13
+ /**
14
+ * On the server side, Hook that transform a dictionary and return the content
15
+ *
16
+ * If the locale is not provided, it will use the locale from the client context
17
+ */
18
+ const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
19
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
20
+ const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer?.locale() ?? _intlayer_config_built.default?.internationalization.defaultLocale);
21
+ return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
22
+ };
23
+
24
+ //#endregion
25
+ exports.useDictionaryDynamic = useDictionaryDynamic;
2
26
  //# sourceMappingURL=useDictionaryDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"+SAeA,MAAa,GAIX,EACA,EACA,IACG,CACH,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAEF,GACA,GAAU,QAAQ,EAClBC,EAAAA,SAAe,qBAAqB,cACvC,CAOD,OAAOC,EAAAA,cALYC,EAAAA,eACjB,GAAG,OAAO,EAAI,CAAC,GAAG,GAAc,GAChC,EAAkB,GAAc,KAAK,CACtC,CAEgC,GAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,qCAAoCA,8CAAe;CAEzD,MAAM,iDAEF,UACA,UAAU,QAAQ,IAClBC,gCAAe,qBAAqB,cACvC;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
@@ -1,2 +1,41 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./installIntlayer.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/core/formatters`);const r=r=>{let i=(0,t.inject)(e.IntlayerProvider);return(0,t.computed)(()=>(0,n.bindIntl)(r??i.locale()))};exports.useIntl=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
6
+
7
+ //#region src/client/useIntl.ts
8
+ /**
9
+ * Angular composable that provides a locale-bound `Intl` object.
10
+ *
11
+ * It acts exactly like the native `Intl` object, but acts as a proxy to:
12
+ * 1. Inject the current locale automatically if none is provided.
13
+ * 2. Use the performance-optimized `CachedIntl` under the hood.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { Component, computed } from '@angular/core';
18
+ * import { useIntl } from 'angular-intlayer';
19
+ *
20
+ * @Component({ ... })
21
+ * export class MyComponent {
22
+ * intl = useIntl();
23
+ * formattedPrice = computed(() =>
24
+ * new this.intl().NumberFormat({
25
+ * style: 'currency',
26
+ * currency: 'USD'
27
+ * }).format(123.45)
28
+ * );
29
+ * }
30
+ * ```
31
+ */
32
+ const useIntl = (locale) => {
33
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.IntlayerProvider);
34
+ return (0, _angular_core.computed)(() => {
35
+ return (0, _intlayer_core_formatters.bindIntl)(locale ?? intlayer.locale());
36
+ });
37
+ };
38
+
39
+ //#endregion
40
+ exports.useIntl = useIntl;
2
41
  //# sourceMappingURL=useIntl.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mNA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,GAAA,EAAA,EAAA,QAAkBA,EAAAA,iBAAiB,CAEzC,OAAA,EAAA,EAAA,eAGE,EAAA,EAAA,UAFsB,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
1
+ {"version":3,"file":"useIntl.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WAAW,WAA2B;CACjD,MAAM,qCAAkBA,gDAAiB;AAEzC,0CAAmC;AAGjC,iDAFsB,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
@@ -1,2 +1,45 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../getIntlayer.cjs`),t=require(`./installIntlayer.cjs`);let n=require(`@angular/core`);const r=e=>!!e&&typeof e==`object`&&typeof e.__update==`function`,i=(r,i)=>{let a=(0,n.inject)(t.INTLAYER_TOKEN),o=(0,n.computed)(()=>i??a.locale());return(0,n.computed)(()=>e.getIntlayer(r,o()))};exports.isUpdatableNode=r,exports.useIntlayer=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_getIntlayer = require('../getIntlayer.cjs');
4
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
5
+ let _angular_core = require("@angular/core");
6
+
7
+ //#region src/client/useIntlayer.ts
8
+ /** guard utility - true only for objects generated by `renderIntlayerNode()` */
9
+ const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
10
+ /**
11
+ * Angular hook that picks one dictionary by its key and returns its reactive content.
12
+ *
13
+ * It utilizes Angular signals to provide deep reactivity, ensuring your components
14
+ * update automatically when the locale changes.
15
+ *
16
+ * @param key - The unique key of the dictionary to retrieve.
17
+ * @param locale - Optional locale to override the current context locale.
18
+ * @returns The transformed dictionary content.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Component } from '@angular/core';
23
+ * import { useIntlayer } from 'angular-intlayer';
24
+ *
25
+ * @Component({
26
+ * standalone: true,
27
+ * selector: 'app-my-component',
28
+ * template: `<div>{{ content().myField.value }}</div>`,
29
+ * })
30
+ * export class MyComponent {
31
+ * content = useIntlayer('my-dictionary-key');
32
+ * }
33
+ * ```
34
+ */
35
+ const useIntlayer = (key, locale) => {
36
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
37
+ /** which locale should we use right now? */
38
+ const localeTarget = (0, _angular_core.computed)(() => locale ?? intlayer.locale());
39
+ return (0, _angular_core.computed)(() => require_getIntlayer.getIntlayer(key, localeTarget()));
40
+ };
41
+
42
+ //#endregion
43
+ exports.isUpdatableNode = isUpdatableNode;
44
+ exports.useIntlayer = useIntlayer;
2
45
  //# sourceMappingURL=useIntlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<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; // all consumers keep full reactivity\n};\n"],"mappings":"4MAOA,MAAa,EACX,GAEA,CAAC,CAAC,GACF,OAAO,GAAQ,UACf,OAAQ,EAAY,UAAa,WA2BtB,GACX,EACA,IAC+D,CAC/D,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAGnD,GAAA,EAAA,EAAA,cAA8B,GAAU,EAAS,QAAQ,CAAC,CAMhE,OAAA,EAAA,EAAA,cAF+BC,EAAAA,YAAkB,EAAK,GAAc,CAAM,CAAC"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<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; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WAC+D;CAC/D,MAAM,qCAAoCA,8CAAe;;CAGzD,MAAM,iDAA8B,UAAU,SAAS,QAAQ,CAAC;AAMhE,0CAF+BC,gCAAkB,KAAK,cAAc,CAAM,CAAC"}
@@ -1,2 +1,29 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`@angular/core`);const t=(n,r)=>{let i=t._cache||=new Map,a=(0,e.signal)({});if(i.has(n))i.get(n)?.then(e=>{a.set(e)});else{let e=r.then(e=>(a.set(e),e));i.set(n,e)}return a()};exports.useLoadDynamic=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _angular_core = require("@angular/core");
4
+
5
+ //#region src/client/useLoadDynamic.ts
6
+ /**
7
+ * A "synchronous" loader for a dynamically‐imported JSON (or anything).
8
+ *
9
+ * - Immediately returns a reactive signal so that Angular can properly track changes.
10
+ * - When the Promise resolves, it replaces the signal's value with the real data.
11
+ */
12
+ const useLoadDynamic = (key, promise) => {
13
+ const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
14
+ const container = (0, _angular_core.signal)({});
15
+ if (!cache.has(key)) {
16
+ const p = promise.then((real) => {
17
+ container.set(real);
18
+ return real;
19
+ });
20
+ cache.set(key, p);
21
+ } else cache.get(key)?.then((real) => {
22
+ container.set(real);
23
+ });
24
+ return container();
25
+ };
26
+
27
+ //#endregion
28
+ exports.useLoadDynamic = useLoadDynamic;
2
29
  //# sourceMappingURL=useLoadDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"mIAQA,MAAa,GACX,EACA,IACM,CAEN,IAAM,EAAkC,AACvC,EAAwB,SAAS,IAAI,IAIhC,GAAA,EAAA,EAAA,QAAmB,EAAE,CAAM,CAEjC,GAAK,EAAM,IAAI,EAAI,CAUjB,EAAM,IAAI,EAAI,EAAE,KAAM,GAAS,CAC7B,EAAU,IAAI,EAAK,EACnB,KAZiB,CAEnB,IAAM,EAAI,EAAQ,KAAM,IAEtB,EAAU,IAAI,EAAK,CACZ,GACP,CACF,EAAM,IAAI,EAAK,EAAE,CASnB,OAAO,GAAW"}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAM,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,sCAAmB,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}
@@ -1,2 +1,61 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useLocaleStorage.cjs`);let r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@angular/core`);const a=({isCookieEnabled:e,onLocaleChange:a}={})=>{let{defaultLocale:o,locales:s}=r.default?.internationalization??{},c=(0,i.inject)(t.INTLAYER_TOKEN),l=(0,i.computed)(()=>c?.locale()??o),u=(0,i.computed)(()=>c?.isCookieEnabled()??!0);return{locale:l,defaultLocale:o,availableLocales:s,setLocale:t=>{if(!s?.map(String).includes(t)){console.error(`Locale ${t} is not available`);return}c&&c.setLocale(t),n.setLocaleInStorage(t,e??u()??!0),a?.(t)}}};exports.useLocale=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
4
+ const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
5
+ let _intlayer_config_built = require("@intlayer/config/built");
6
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
+ let _angular_core = require("@angular/core");
8
+
9
+ //#region src/client/useLocale.ts
10
+ /**
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
+ * ```
36
+ */
37
+ const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
38
+ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.default?.internationalization ?? {};
39
+ const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
40
+ const locale = (0, _angular_core.computed)(() => intlayer?.locale() ?? defaultLocale);
41
+ const isCookieEnabledContext = (0, _angular_core.computed)(() => intlayer?.isCookieEnabled() ?? true);
42
+ const setLocale = (newLocale) => {
43
+ if (!availableLocales?.map(String).includes(newLocale)) {
44
+ console.error(`Locale ${newLocale} is not available`);
45
+ return;
46
+ }
47
+ if (intlayer) intlayer.setLocale(newLocale);
48
+ require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled ?? isCookieEnabledContext() ?? true);
49
+ onLocaleChange?.(newLocale);
50
+ };
51
+ return {
52
+ locale,
53
+ defaultLocale,
54
+ availableLocales,
55
+ setLocale
56
+ };
57
+ };
58
+
59
+ //#endregion
60
+ exports.useLocale = useLocale;
2
61
  //# sourceMappingURL=useLocale.cjs.map
@@ -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/module_augmentation';\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":"mQAsCA,MAAa,GAAa,CACxB,kBACA,kBACkB,EAAE,GAAK,CACzB,GAAM,CAAE,gBAAe,QAAS,GAC9BA,EAAAA,SAAe,sBAAwB,EAAE,CACrC,GAAA,EAAA,EAAA,QAAoCC,EAAAA,eAAe,CAGnD,GAAA,EAAA,EAAA,cAAwB,GAAU,QAAQ,EAAI,EAAc,CAC5D,GAAA,EAAA,EAAA,cACE,GAAU,iBAAiB,EAAI,GACtC,CAkBD,MAAO,CACL,SACA,gBACA,mBACA,UApBiB,GAA6B,CAC9C,GAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGE,GACF,EAAS,UAAU,EAAU,CAE/B,EAAA,mBACE,EACA,GAAmB,GAAwB,EAAI,GAChD,CACD,IAAiB,EAAU,EAQ5B"}
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/module_augmentation';\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"}
@@ -1,2 +1,62 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/core/localization`),t=require(`@intlayer/core/utils`);const n=(0,t.getLocaleFromStorage)(e.localeStorageOptions),r=n,i=(n,r)=>(0,t.setLocaleInStorage)(n,{...e.localeStorageOptions,isCookieEnabled:r}),a=i,o=n=>(0,t.LocaleStorage)({...e.localeStorageOptions,isCookieEnabled:n}),s=e=>{let t=o(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};exports.localeCookie=r,exports.localeInStorage=n,exports.setLocaleCookie=a,exports.setLocaleInStorage=i,exports.useLocaleCookie=s,exports.useLocaleStorage=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_core_localization = require("@intlayer/core/localization");
4
+ let _intlayer_core_utils = require("@intlayer/core/utils");
5
+
6
+ //#region src/client/useLocaleStorage.ts
7
+ /**
8
+ * Get the locale cookie
9
+ */
10
+ /**
11
+ * Get the locale cookie
12
+ */
13
+ const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorage)(_intlayer_core_localization.localeStorageOptions);
14
+ /**
15
+ * @deprecated Use localeInStorage instead
16
+ *
17
+ * Get the locale cookie
18
+ */
19
+ const localeCookie = localeInStorage;
20
+ /**
21
+ * Set the locale cookie
22
+ */
23
+ const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorage)(locale, {
24
+ ..._intlayer_core_localization.localeStorageOptions,
25
+ isCookieEnabled
26
+ });
27
+ /**
28
+ * @deprecated Use setLocaleInStorage instead
29
+ *
30
+ * Set the locale cookie
31
+ */
32
+ const setLocaleCookie = setLocaleInStorage;
33
+ /**
34
+ * Hook that provides the locale storage and a function to set it
35
+ */
36
+ const useLocaleStorage = (isCookieEnabled) => (0, _intlayer_core_utils.LocaleStorage)({
37
+ ..._intlayer_core_localization.localeStorageOptions,
38
+ isCookieEnabled
39
+ });
40
+ /**
41
+ * @deprecated Use useLocaleStorage instead
42
+ *
43
+ * For GDPR compliance, use useLocaleStorage instead
44
+ *
45
+ * Hook that provides the locale cookie and a function to set it
46
+ */
47
+ const useLocaleCookie = (isCookieEnabled) => {
48
+ const storage = useLocaleStorage(isCookieEnabled);
49
+ return {
50
+ localeCookie: storage.getLocale(),
51
+ setLocaleCookie: storage.setLocale
52
+ };
53
+ };
54
+
55
+ //#endregion
56
+ exports.localeCookie = localeCookie;
57
+ exports.localeInStorage = localeInStorage;
58
+ exports.setLocaleCookie = setLocaleCookie;
59
+ exports.setLocaleInStorage = setLocaleInStorage;
60
+ exports.useLocaleCookie = useLocaleCookie;
61
+ exports.useLocaleStorage = useLocaleStorage;
2
62
  //# sourceMappingURL=useLocaleStorage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":"mLAcA,MAAa,GAAA,EAAA,EAAA,sBAAuCA,EAAAA,qBAAqB,CAM5D,EAAe,EAKf,GACX,EACA,KAAA,EAAA,EAAA,oBAEuB,EAAQ,CAC7B,GAAGA,EAAAA,qBACH,kBACD,CAAC,CAOS,EAAkB,EAKlB,EAAoB,IAAA,EAAA,EAAA,eACjB,CACZ,GAAGA,EAAAA,qBACH,kBACD,CAAC,CASS,EAAmB,GAA8B,CAC5D,IAAM,EAAU,EAAiB,EAAgB,CAEjD,MAAO,CACL,aAAc,EAAQ,WAAW,CACjC,gBAAiB,EAAQ,UAC1B"}
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,iEAAuCA,iDAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,iEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,4DACjB;CACZ,GAAGA;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}