angular-intlayer 6.1.6-canary.0 → 7.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +94 -121
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/cjs/client/index.cjs +19 -35
  5. package/dist/cjs/client/installIntlayer.cjs +39 -68
  6. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +13 -36
  8. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryAsync.cjs +23 -48
  10. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +24 -52
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useIntlayer.cjs +16 -36
  14. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  15. package/dist/cjs/client/useLoadDynamic.cjs +26 -42
  16. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  17. package/dist/cjs/client/useLocale.cjs +35 -67
  18. package/dist/cjs/client/useLocale.cjs.map +1 -1
  19. package/dist/cjs/client/useLocaleStorage.cjs +61 -0
  20. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  21. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +41 -63
  22. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  23. package/dist/cjs/editor/EditedContentRenderer.component.cjs +44 -75
  24. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  25. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +25 -45
  26. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  27. package/dist/cjs/editor/communicator.cjs +55 -73
  28. package/dist/cjs/editor/communicator.cjs.map +1 -1
  29. package/dist/cjs/editor/configuration.cjs +21 -54
  30. package/dist/cjs/editor/configuration.cjs.map +1 -1
  31. package/dist/cjs/editor/createSharedComposable.cjs +46 -63
  32. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  33. package/dist/cjs/editor/dictionariesRecord.cjs +47 -77
  34. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  35. package/dist/cjs/editor/editedContent.cjs +58 -71
  36. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  37. package/dist/cjs/editor/editorEnabled.cjs +45 -70
  38. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  39. package/dist/cjs/editor/editorLocale.cjs +21 -45
  40. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  41. package/dist/cjs/editor/focusDictionary.cjs +58 -74
  42. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  43. package/dist/cjs/editor/index.cjs +9 -38
  44. package/dist/cjs/editor/installIntlayerEditor.cjs +46 -64
  45. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
  46. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +63 -72
  47. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  48. package/dist/cjs/editor/useCrossFrameState.cjs +108 -88
  49. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  50. package/dist/cjs/editor/useCrossURLPathState.cjs +64 -69
  51. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  52. package/dist/cjs/editor/useEditedContentRenderer.cjs +25 -54
  53. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  54. package/dist/cjs/editor/useEditor.cjs +22 -44
  55. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  56. package/dist/cjs/editor/useIframeClickInterceptor.cjs +38 -59
  57. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  58. package/dist/cjs/getDictionary.cjs +14 -39
  59. package/dist/cjs/getDictionary.cjs.map +1 -1
  60. package/dist/cjs/getIntlayer.cjs +14 -35
  61. package/dist/cjs/getIntlayer.cjs.map +1 -1
  62. package/dist/cjs/index.cjs +32 -31
  63. package/dist/cjs/markdown/index.cjs +6 -23
  64. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +33 -60
  65. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  66. package/dist/cjs/plugins.cjs +77 -108
  67. package/dist/cjs/plugins.cjs.map +1 -1
  68. package/dist/cjs/renderIntlayerNode.cjs +16 -56
  69. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  70. package/dist/cjs/webpack/index.cjs +3 -23
  71. package/dist/cjs/webpack/mergeConfig.cjs +33 -68
  72. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  73. package/dist/esm/UI/ContentSelector.component.mjs +89 -104
  74. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  75. package/dist/esm/client/index.mjs +9 -8
  76. package/dist/esm/client/installIntlayer.mjs +29 -27
  77. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  78. package/dist/esm/client/useDictionary.mjs +10 -11
  79. package/dist/esm/client/useDictionary.mjs.map +1 -1
  80. package/dist/esm/client/useDictionaryAsync.mjs +18 -12
  81. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  82. package/dist/esm/client/useDictionaryDynamic.mjs +18 -15
  83. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  84. package/dist/esm/client/useIntlayer.mjs +12 -10
  85. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  86. package/dist/esm/client/useLoadDynamic.mjs +23 -17
  87. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  88. package/dist/esm/client/useLocale.mjs +30 -31
  89. package/dist/esm/client/useLocale.mjs.map +1 -1
  90. package/dist/esm/client/useLocaleStorage.mjs +54 -0
  91. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  92. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +32 -34
  93. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  94. package/dist/esm/editor/EditedContentRenderer.component.mjs +38 -49
  95. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  96. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +19 -18
  97. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  98. package/dist/esm/editor/communicator.mjs +48 -35
  99. package/dist/esm/editor/communicator.mjs.map +1 -1
  100. package/dist/esm/editor/configuration.mjs +15 -18
  101. package/dist/esm/editor/configuration.mjs.map +1 -1
  102. package/dist/esm/editor/createSharedComposable.mjs +42 -37
  103. package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
  104. package/dist/esm/editor/dictionariesRecord.mjs +38 -38
  105. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
  106. package/dist/esm/editor/editedContent.mjs +49 -42
  107. package/dist/esm/editor/editedContent.mjs.map +1 -1
  108. package/dist/esm/editor/editorEnabled.mjs +37 -41
  109. package/dist/esm/editor/editorEnabled.mjs.map +1 -1
  110. package/dist/esm/editor/editorLocale.mjs +15 -18
  111. package/dist/esm/editor/editorLocale.mjs.map +1 -1
  112. package/dist/esm/editor/focusDictionary.mjs +50 -45
  113. package/dist/esm/editor/focusDictionary.mjs.map +1 -1
  114. package/dist/esm/editor/index.mjs +3 -7
  115. package/dist/esm/editor/installIntlayerEditor.mjs +40 -26
  116. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
  117. package/dist/esm/editor/useCrossFrameMessageListener.mjs +58 -46
  118. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  119. package/dist/esm/editor/useCrossFrameState.mjs +104 -62
  120. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  121. package/dist/esm/editor/useCrossURLPathState.mjs +57 -41
  122. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  123. package/dist/esm/editor/useEditedContentRenderer.mjs +21 -33
  124. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  125. package/dist/esm/editor/useEditor.mjs +16 -14
  126. package/dist/esm/editor/useEditor.mjs.map +1 -1
  127. package/dist/esm/editor/useIframeClickInterceptor.mjs +30 -30
  128. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  129. package/dist/esm/getDictionary.mjs +12 -20
  130. package/dist/esm/getDictionary.mjs.map +1 -1
  131. package/dist/esm/getIntlayer.mjs +12 -16
  132. package/dist/esm/getIntlayer.mjs.map +1 -1
  133. package/dist/esm/index.mjs +13 -6
  134. package/dist/esm/markdown/index.mjs +3 -2
  135. package/dist/esm/markdown/installIntlayerMarkdown.mjs +27 -32
  136. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  137. package/dist/esm/plugins.mjs +70 -83
  138. package/dist/esm/plugins.mjs.map +1 -1
  139. package/dist/esm/renderIntlayerNode.mjs +15 -32
  140. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  141. package/dist/esm/webpack/index.mjs +3 -2
  142. package/dist/esm/webpack/mergeConfig.mjs +25 -31
  143. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  144. package/dist/types/UI/ContentSelector.component.d.ts +32 -30
  145. package/dist/types/UI/ContentSelector.component.d.ts.map +1 -1
  146. package/dist/types/client/index.d.ts +8 -8
  147. package/dist/types/client/installIntlayer.d.ts +15 -9
  148. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  149. package/dist/types/client/useDictionary.d.ts +7 -4
  150. package/dist/types/client/useDictionary.d.ts.map +1 -1
  151. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  152. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  153. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  154. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  155. package/dist/types/client/useIntlayer.d.ts +9 -7
  156. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  157. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  158. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  159. package/dist/types/client/useLocale.d.ts +17 -8
  160. package/dist/types/client/useLocale.d.ts.map +1 -1
  161. package/dist/types/client/useLocaleStorage.d.ts +49 -0
  162. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  163. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +18 -12
  164. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
  165. package/dist/types/editor/EditedContentRenderer.component.d.ts +20 -16
  166. package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -1
  167. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +11 -6
  168. package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -1
  169. package/dist/types/editor/communicator.d.ts +14 -9
  170. package/dist/types/editor/communicator.d.ts.map +1 -1
  171. package/dist/types/editor/configuration.d.ts +4 -1
  172. package/dist/types/editor/configuration.d.ts.map +1 -1
  173. package/dist/types/editor/createSharedComposable.d.ts +6 -4
  174. package/dist/types/editor/createSharedComposable.d.ts.map +1 -1
  175. package/dist/types/editor/dictionariesRecord.d.ts +13 -10
  176. package/dist/types/editor/dictionariesRecord.d.ts.map +1 -1
  177. package/dist/types/editor/editedContent.d.ts +13 -10
  178. package/dist/types/editor/editedContent.d.ts.map +1 -1
  179. package/dist/types/editor/editorEnabled.d.ts +12 -8
  180. package/dist/types/editor/editorEnabled.d.ts.map +1 -1
  181. package/dist/types/editor/editorLocale.d.ts +6 -2
  182. package/dist/types/editor/editorLocale.d.ts.map +1 -1
  183. package/dist/types/editor/focusDictionary.d.ts +16 -13
  184. package/dist/types/editor/focusDictionary.d.ts.map +1 -1
  185. package/dist/types/editor/index.d.ts +5 -5
  186. package/dist/types/editor/installIntlayerEditor.d.ts +7 -2
  187. package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -1
  188. package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
  189. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
  190. package/dist/types/editor/useCrossFrameState.d.ts +12 -8
  191. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
  192. package/dist/types/editor/useCrossURLPathState.d.ts +9 -3
  193. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
  194. package/dist/types/editor/useEditedContentRenderer.d.ts +15 -11
  195. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  196. package/dist/types/editor/useEditor.d.ts +4 -1
  197. package/dist/types/editor/useEditor.d.ts.map +1 -1
  198. package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
  199. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
  200. package/dist/types/getDictionary.d.ts +8 -4
  201. package/dist/types/getDictionary.d.ts.map +1 -1
  202. package/dist/types/getIntlayer.d.ts +8 -4
  203. package/dist/types/getIntlayer.d.ts.map +1 -1
  204. package/dist/types/index.d.ts +16 -8
  205. package/dist/types/index.d.ts.map +1 -1
  206. package/dist/types/markdown/index.d.ts +2 -2
  207. package/dist/types/markdown/installIntlayerMarkdown.d.ts +15 -12
  208. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  209. package/dist/types/plugins.d.ts +29 -23
  210. package/dist/types/plugins.d.ts.map +1 -1
  211. package/dist/types/renderIntlayerNode.d.ts +16 -10
  212. package/dist/types/renderIntlayerNode.d.ts.map +1 -1
  213. package/dist/types/webpack/index.d.ts +2 -2
  214. package/dist/types/webpack/mergeConfig.d.ts +5 -2
  215. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  216. package/package.json +43 -49
  217. package/LICENSE +0 -202
  218. package/dist/cjs/client/index.cjs.map +0 -1
  219. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  220. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  221. package/dist/cjs/editor/index.cjs.map +0 -1
  222. package/dist/cjs/index.cjs.map +0 -1
  223. package/dist/cjs/markdown/index.cjs.map +0 -1
  224. package/dist/cjs/webpack/index.cjs.map +0 -1
  225. package/dist/esm/client/index.mjs.map +0 -1
  226. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  227. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  228. package/dist/esm/editor/index.mjs.map +0 -1
  229. package/dist/esm/index.mjs.map +0 -1
  230. package/dist/esm/markdown/index.mjs.map +0 -1
  231. package/dist/esm/webpack/index.mjs.map +0 -1
  232. package/dist/types/client/index.d.ts.map +0 -1
  233. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  234. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  235. package/dist/types/editor/index.d.ts.map +0 -1
  236. package/dist/types/markdown/index.d.ts.map +0 -1
  237. package/dist/types/webpack/index.d.ts.map +0 -1
@@ -1,55 +1,27 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var useDictionaryDynamic_exports = {};
31
- __export(useDictionaryDynamic_exports, {
32
- useDictionaryDynamic: () => useDictionaryDynamic
33
- });
34
- module.exports = __toCommonJS(useDictionaryDynamic_exports);
35
- var import_core = require("@angular/core");
36
- var import_built = __toESM(require("@intlayer/config/built"));
37
- var import_installIntlayer = require('./installIntlayer.cjs');
38
- var import_useDictionary = require('./useDictionary.cjs');
39
- var import_useLoadDynamic = require('./useLoadDynamic.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_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 __angular_core = require("@angular/core");
9
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
10
+ let __intlayer_config_built = require("@intlayer/config/built");
11
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
12
+
13
+ //#region src/client/useDictionaryDynamic.ts
14
+ /**
15
+ * On the server side, Hook that transform a dictionary and return the content
16
+ *
17
+ * If the locale is not provided, it will use the locale from the client context
18
+ */
40
19
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
41
- const intlayer = (0, import_core.inject)(import_installIntlayer.INTLAYER_TOKEN);
42
- const localeTarget = (0, import_core.computed)(
43
- () => locale ?? intlayer?.locale() ?? import_built.default?.internationalization.defaultLocale
44
- );
45
- const dictionary = (0, import_useLoadDynamic.useLoadDynamic)(
46
- `${String(key)}.${localeTarget()}`,
47
- dictionaryPromise[localeTarget()]()
48
- );
49
- return (0, import_useDictionary.useDictionary)(dictionary, localeTarget());
20
+ const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
21
+ const localeTarget = (0, __angular_core.computed)(() => locale ?? intlayer?.locale() ?? __intlayer_config_built.default?.internationalization.defaultLocale);
22
+ return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
50
23
  };
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- useDictionaryDynamic
54
- });
24
+
25
+ //#endregion
26
+ exports.useDictionaryDynamic = useDictionaryDynamic;
55
27
  //# sourceMappingURL=useDictionaryDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\nimport { INTLAYER_TOKEN, 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: LanguageContent<() => 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAiC;AACjC,mBAA0B;AAO1B,6BAAiD;AACjD,2BAA8B;AAC9B,4BAA+B;AAOxB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACG;AACH,QAAM,eAAW,oBAAyB,qCAAc;AAExD,QAAM,mBAAe;AAAA,IACnB,MACE,UACA,UAAU,OAAO,KACjB,aAAAA,SAAe,qBAAqB;AAAA,EACxC;AAEA,QAAM,iBAAa;AAAA,IACjB,GAAG,OAAO,GAAG,CAAC,IAAI,aAAa,CAAC;AAAA,IAChC,kBAAkB,aAAa,CAAC,EAAG;AAAA,EACrC;AAEA,aAAO,oCAAc,YAAY,aAAa,CAAQ;AACxD;","names":["configuration"]}
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 {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\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":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,sCAAoCA,8CAAe;CAEzD,MAAM,kDAEF,UACA,UAAU,QAAQ,IAClBC,iCAAe,qBAAqB,cACvC;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
@@ -1,40 +1,20 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useIntlayer_exports = {};
20
- __export(useIntlayer_exports, {
21
- isUpdatableNode: () => isUpdatableNode,
22
- useIntlayer: () => useIntlayer
23
- });
24
- module.exports = __toCommonJS(useIntlayer_exports);
25
- var import_core = require("@angular/core");
26
- var import_getIntlayer = require('../getIntlayer.cjs');
27
- var import_installIntlayer = require('./installIntlayer.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
3
+ const require_getIntlayer = require('../getIntlayer.cjs');
4
+ let __angular_core = require("@angular/core");
5
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
6
+
7
+ //#region src/client/useIntlayer.ts
8
+ /** guard utility - true only for objects generated by `renderIntlayerNode()` */
28
9
  const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
29
10
  const useIntlayer = (key, locale) => {
30
- const intlayer = (0, import_core.inject)(import_installIntlayer.INTLAYER_TOKEN);
31
- const localeTarget = (0, import_core.computed)(() => locale ?? intlayer.locale());
32
- const content = (0, import_core.computed)(() => (0, import_getIntlayer.getIntlayer)(key, localeTarget()));
33
- return content();
11
+ const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
12
+ /** which locale should we use right now? */
13
+ const localeTarget = (0, __angular_core.computed)(() => locale ?? intlayer.locale());
14
+ return (0, __angular_core.computed)(() => require_getIntlayer.getIntlayer(key, localeTarget()))();
34
15
  };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- isUpdatableNode,
38
- useIntlayer
39
- });
16
+
17
+ //#endregion
18
+ exports.isUpdatableNode = isUpdatableNode;
19
+ exports.useIntlayer = useIntlayer;
40
20
  //# sourceMappingURL=useIntlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, 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>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\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 const content = computed(() => getIntlayer(key, localeTarget()));\n\n return content() as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AAKjC,yBAA4B;AAE5B,6BAAiD;AAG1C,MAAM,kBAAkB,CAC7B,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAE5B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,eAAW,oBAAyB,qCAAc;AAGxD,QAAM,mBAAe,sBAAS,MAAM,UAAU,SAAS,OAAO,CAAC;AAG/D,QAAM,cAAU,sBAAS,UAAM,gCAAY,KAAK,aAAa,CAAC,CAAC;AAE/D,SAAO,QAAQ;AAGjB;","names":[]}
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;AAEnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,sCAAoCA,8CAAe;;CAGzD,MAAM,kDAA8B,UAAU,SAAS,QAAQ,CAAC;AAMhE,2CAF+BC,gCAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
@@ -1,45 +1,29 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useLoadDynamic_exports = {};
20
- __export(useLoadDynamic_exports, {
21
- useLoadDynamic: () => useLoadDynamic
22
- });
23
- module.exports = __toCommonJS(useLoadDynamic_exports);
24
- var import_core = require("@angular/core");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __angular_core = require("@angular/core");
3
+ __angular_core = require_rolldown_runtime.__toESM(__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
+ */
25
12
  const useLoadDynamic = (key, promise) => {
26
- const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
27
- const container = (0, import_core.signal)({});
28
- if (!cache.has(key)) {
29
- const p = promise.then((real) => {
30
- container.set(real);
31
- return real;
32
- });
33
- cache.set(key, p);
34
- } else {
35
- cache.get(key).then((real) => {
36
- container.set(real);
37
- });
38
- }
39
- return container();
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();
40
25
  };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- useLoadDynamic
44
- });
26
+
27
+ //#endregion
28
+ exports.useLoadDynamic = useLoadDynamic;
45
29
  //# sourceMappingURL=useLoadDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AAQhB,MAAM,iBAAiB,CAC5B,KACA,YACM;AAEN,QAAM,QAAkC,eAAuB,WAC7D,eAAuB,SAAS,oBAAI,IAAI;AAI1C,QAAM,gBAAY,oBAAO,CAAC,CAAM;AAEhC,MAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AAEnB,UAAM,IAAI,QAAQ,KAAK,CAAC,SAAS;AAE/B,gBAAU,IAAI,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,KAAK,CAAC;AAAA,EAClB,OAAO;AAEL,UAAM,IAAI,GAAG,EAAG,KAAK,CAAC,SAAS;AAC7B,gBAAU,IAAI,IAAI;AAAA,IACpB,CAAC;AAAA,EACH;AAGA,SAAO,UAAU;AACnB;","names":[]}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":["cache: Map<string, Promise<T>>"],"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,MAAMA,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,uCAAmB,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,69 +1,37 @@
1
- "use strict";
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 __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_client_installIntlayer = require('./installIntlayer.cjs');
3
+ const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
4
+ let __angular_core = require("@angular/core");
5
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
6
+ let __intlayer_config_built = require("@intlayer/config/built");
7
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
8
+
9
+ //#region src/client/useLocale.ts
10
+ /**
11
+ * On the client side, composable to get the current locale and all related fields
12
+ */
13
+ const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
14
+ const { defaultLocale, locales: availableLocales } = __intlayer_config_built.default?.internationalization ?? {};
15
+ const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
16
+ const locale = (0, __angular_core.computed)(() => intlayer?.locale() ?? defaultLocale);
17
+ const isCookieEnabledContext = (0, __angular_core.computed)(() => intlayer?.isCookieEnabled() ?? true);
18
+ const setLocale = (newLocale) => {
19
+ if (!availableLocales?.map(String).includes(newLocale)) {
20
+ console.error(`Locale ${newLocale} is not available`);
21
+ return;
22
+ }
23
+ if (intlayer) intlayer.setLocale(newLocale);
24
+ require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled ?? isCookieEnabledContext() ?? true);
25
+ onLocaleChange?.(newLocale);
26
+ };
27
+ return {
28
+ locale,
29
+ defaultLocale,
30
+ availableLocales,
31
+ setLocale
32
+ };
11
33
  };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var useLocale_exports = {};
30
- __export(useLocale_exports, {
31
- useLocale: () => useLocale
32
- });
33
- module.exports = __toCommonJS(useLocale_exports);
34
- var import_core = require("@angular/core");
35
- var import_built = __toESM(require("@intlayer/config/built"));
36
- var import_installIntlayer = require('./installIntlayer.cjs');
37
- var import_useLocaleCookie = require('./useLocaleCookie.cjs');
38
- const useLocale = ({ onLocaleChange } = {}) => {
39
- const { defaultLocale, locales: availableLocales } = import_built.default?.internationalization ?? {};
40
- const intlayer = (0, import_core.inject)(import_installIntlayer.INTLAYER_TOKEN);
41
- const { setLocaleCookie } = (0, import_useLocaleCookie.useLocaleCookie)();
42
- const locale = (0, import_core.computed)(() => intlayer?.locale() ?? defaultLocale);
43
- const setLocale = (newLocale) => {
44
- if (!availableLocales?.map(String).includes(newLocale)) {
45
- console.error(`Locale ${newLocale} is not available`);
46
- return;
47
- }
48
- if (intlayer) {
49
- intlayer.setLocale(newLocale);
50
- }
51
- setLocaleCookie(newLocale);
52
- onLocaleChange?.(newLocale);
53
- };
54
- return {
55
- locale,
56
- // Current locale
57
- defaultLocale,
58
- // Principal locale defined in config
59
- availableLocales,
60
- // List of the available locales defined in config
61
- setLocale
62
- // Function to set the locale
63
- };
64
- };
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- useLocale
68
- });
34
+
35
+ //#endregion
36
+ exports.useLocale = useLocale;
69
37
  //# sourceMappingURL=useLocale.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, composable to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n const { setLocaleCookie } = useLocaleCookie();\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\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 setLocaleCookie(newLocale);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,mBAA0B;AAE1B,6BAAiD;AACjD,6BAAgC;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,aAAAA,SAAe,wBAAwB,CAAC;AAC1C,QAAM,eAAW,oBAAyB,qCAAc;AACxD,QAAM,EAAE,gBAAgB,QAAI,wCAAgB;AAG5C,QAAM,aAAS,sBAAS,MAAM,UAAU,OAAO,KAAK,aAAa;AAEjE,QAAM,YAAY,CAAC,cAA6B;AAC9C,QAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;AACtD,cAAQ,MAAM,UAAU,SAAS,mBAAmB;AACpD;AAAA,IACF;AAEA,QAAI,UAAU;AACZ,eAAS,UAAU,SAAS;AAAA,IAC9B;AACA,oBAAgB,SAAS;AACzB,qBAAiB,SAAS;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["configuration"]}
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 * On the client side, composable to get the current locale and all related fields\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":";;;;;;;;;;;;AAcA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,iCAAe,wBAAwB,EAAE;CAC3C,MAAM,sCAAoCC,8CAAe;CAGzD,MAAM,4CAAwB,UAAU,QAAQ,IAAI,cAAc;CAClE,MAAM,4DACE,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"}
@@ -0,0 +1,61 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __intlayer_core = require("@intlayer/core");
3
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
4
+
5
+ //#region src/client/useLocaleStorage.ts
6
+ /**
7
+ * Get the locale cookie
8
+ */
9
+ /**
10
+ * Get the locale cookie
11
+ */
12
+ const localeInStorage = (0, __intlayer_core.getLocaleFromStorage)(__intlayer_core.localeStorageOptions);
13
+ /**
14
+ * @deprecated Use localeInStorage instead
15
+ *
16
+ * Get the locale cookie
17
+ */
18
+ const localeCookie = localeInStorage;
19
+ /**
20
+ * Set the locale cookie
21
+ */
22
+ const setLocaleInStorage = (locale, isCookieEnabled) => (0, __intlayer_core.setLocaleInStorage)(locale, {
23
+ ...__intlayer_core.localeStorageOptions,
24
+ isCookieEnabled
25
+ });
26
+ /**
27
+ * @deprecated Use setLocaleInStorage instead
28
+ *
29
+ * Set the locale cookie
30
+ */
31
+ const setLocaleCookie = setLocaleInStorage;
32
+ /**
33
+ * Hook that provides the locale storage and a function to set it
34
+ */
35
+ const useLocaleStorage = (isCookieEnabled) => (0, __intlayer_core.LocaleStorage)({
36
+ ...__intlayer_core.localeStorageOptions,
37
+ isCookieEnabled
38
+ });
39
+ /**
40
+ * @deprecated Use useLocaleStorage instead
41
+ *
42
+ * For GDPR compliance, use useLocaleStorage instead
43
+ *
44
+ * Hook that provides the locale cookie and a function to set it
45
+ */
46
+ const useLocaleCookie = (isCookieEnabled) => {
47
+ const storage = useLocaleStorage(isCookieEnabled);
48
+ return {
49
+ localeCookie: storage.getLocale(),
50
+ setLocaleCookie: storage.setLocale
51
+ };
52
+ };
53
+
54
+ //#endregion
55
+ exports.localeCookie = localeCookie;
56
+ exports.localeInStorage = localeInStorage;
57
+ exports.setLocaleCookie = setLocaleCookie;
58
+ exports.setLocaleInStorage = setLocaleInStorage;
59
+ exports.useLocaleCookie = useLocaleCookie;
60
+ exports.useLocaleStorage = useLocaleStorage;
61
+ //# sourceMappingURL=useLocaleStorage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorage,\n LocaleStorage,\n localeStorageOptions,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\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,4DAAuCA,qCAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,4DAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,uDACjB;CACZ,GAAGA;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
@@ -1,38 +1,21 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var ContentSelectorWrapper_component_exports = {};
20
- __export(ContentSelectorWrapper_component_exports, {
21
- ContentSelectorWrapperComponent: () => ContentSelectorWrapperComponent
22
- });
23
- module.exports = __toCommonJS(ContentSelectorWrapper_component_exports);
24
- var import_common = require("@angular/common");
25
- var import_core = require("@angular/core");
26
- var import_core2 = require("@intlayer/core");
27
- var import_ContentSelector = require('../UI/ContentSelector.component.cjs');
28
- var import_editorEnabled = require('./editorEnabled.cjs');
29
- var import_focusDictionary = require('./focusDictionary.cjs');
30
- var import_useEditor = require('./useEditor.cjs');
31
- @((0, import_core.Component)({
32
- selector: "app-content-selector-wrapper",
33
- standalone: true,
34
- imports: [import_common.CommonModule, import_ContentSelector.ContentSelectorComponent],
35
- template: `
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_UI_ContentSelector_component = require('../UI/ContentSelector.component.cjs');
3
+ const require_editor_editorEnabled = require('./editorEnabled.cjs');
4
+ const require_editor_focusDictionary = require('./focusDictionary.cjs');
5
+ const require_editor_useEditor = require('./useEditor.cjs');
6
+ let __intlayer_core = require("@intlayer/core");
7
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
8
+ let __angular_common = require("@angular/common");
9
+ __angular_common = require_rolldown_runtime.__toESM(__angular_common);
10
+ let __angular_core = require("@angular/core");
11
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
12
+
13
+ //#region src/editor/ContentSelectorWrapper.component.ts
14
+ var ContentSelectorWrapperComponent = @((0, __angular_core.Component)({
15
+ selector: "app-content-selector-wrapper",
16
+ standalone: true,
17
+ imports: [__angular_common.CommonModule, require_UI_ContentSelector_component.ContentSelectorComponent],
18
+ template: `
36
19
  <app-content-selector
37
20
  *ngIf="enabled()"
38
21
  (press)="handleSelect()"
@@ -42,32 +25,27 @@ var import_useEditor = require('./useEditor.cjs');
42
25
  </app-content-selector>
43
26
  <ng-content *ngIf="!enabled()"></ng-content>
44
27
  `
45
- }))
46
- class ContentSelectorWrapperComponent {
47
- @((0, import_core.Input)()) dictionaryKey;
48
- @((0, import_core.Input)()) keyPath;
49
- // pull in the editor state & focus API
50
- focusDictionary = (0, import_focusDictionary.useFocusDictionary)();
51
- editorEnabled = (0, import_editorEnabled.useEditorEnabled)();
52
- constructor() {
53
- (0, import_useEditor.useEditor)();
54
- }
55
- // compute whether this node is the current focus
56
- isSelected = (0, import_core.computed)(() => {
57
- const focusedContent = this.focusDictionary.focusedContent();
58
- return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, import_core2.isSameKeyPath)(focusedContent.keyPath ?? [], this.keyPath);
59
- });
60
- enabled = (0, import_core.computed)(() => this.editorEnabled.enabled());
61
- // when the selector is clicked, update focus
62
- handleSelect() {
63
- this.focusDictionary.setFocusedContent({
64
- dictionaryKey: this.dictionaryKey,
65
- keyPath: this.keyPath
66
- });
67
- }
68
- }
69
- // Annotate the CommonJS export names for ESM import in node:
70
- 0 && (module.exports = {
71
- ContentSelectorWrapperComponent
72
- });
28
+ })) class {
29
+ @((0, __angular_core.Input)()) dictionaryKey;
30
+ @((0, __angular_core.Input)()) keyPath;
31
+ focusDictionary = require_editor_focusDictionary.useFocusDictionary();
32
+ editorEnabled = require_editor_editorEnabled.useEditorEnabled();
33
+ constructor() {
34
+ require_editor_useEditor.useEditor();
35
+ }
36
+ isSelected = (0, __angular_core.computed)(() => {
37
+ const focusedContent = this.focusDictionary.focusedContent();
38
+ return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, __intlayer_core.isSameKeyPath)(focusedContent.keyPath ?? [], this.keyPath);
39
+ });
40
+ enabled = (0, __angular_core.computed)(() => this.editorEnabled.enabled());
41
+ handleSelect() {
42
+ this.focusDictionary.setFocusedContent({
43
+ dictionaryKey: this.dictionaryKey,
44
+ keyPath: this.keyPath
45
+ });
46
+ }
47
+ };
48
+
49
+ //#endregion
50
+ exports.ContentSelectorWrapperComponent = ContentSelectorWrapperComponent;
73
51
  //# sourceMappingURL=ContentSelectorWrapper.component.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input, computed } from '@angular/core';\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,kBAA2C;AAC3C,IAAAA,eAA8C;AAC9C,6BAAyC;AACzC,2BAAiC;AACjC,6BAAmC;AACnC,uBAA0B;AAU1B,MAAC,uBAAU;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS,CAAC,4BAAc,+CAAwB;AAAA,EAChD,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUZ,CAAC;AACM,MAAM,gCAAgC;AAC3C,QAAC,mBAAM,GAAE;AACT,QAAC,mBAAM,GAAE;AAAA;AAAA,EAGD,sBAAkB,2CAAmB;AAAA,EACrC,oBAAgB,uCAAiB;AAAA,EAEzC,cAAc;AACZ,oCAAU;AAAA,EACZ;AAAA;AAAA,EAGA,iBAAa,sBAAS,MAAM;AAC1B,UAAM,iBAAiB,KAAK,gBAAgB,eAAe;AAC3D,WACE,gBAAgB,kBAAkB,KAAK,kBACtC,eAAe,SAAS,UAAU,KAAK,SACxC,4BAAc,eAAe,WAAW,CAAC,GAAG,KAAK,OAAO;AAAA,EAE5D,CAAC;AAAA,EAED,cAAU,sBAAS,MAAM,KAAK,cAAc,QAAQ,CAAC;AAAA;AAAA,EAGrD,eAAe;AACb,SAAK,gBAAgB,kBAAkB;AAAA,MACrC,eAAe,KAAK;AAAA,MACpB,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH;AACF;","names":["import_core"]}
1
+ {"version":3,"file":"ContentSelectorWrapper.component.cjs","names":["CommonModule","ContentSelectorComponent","useFocusDictionary","useEditorEnabled"],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,IAAa,kCAfb,gCAAW;CACT,UAAU;CACV,YAAY;CACZ,SAAS,CAACA,+BAAcC,8DAAyB;CACjD,UAAU;;;;;;;;;;CAUX,CAAC,EACF,MAA6C;CAC3C,6BAAQ,EAAC;CACT,6BAAQ,EAAC;CAGT,AAAQ,kBAAkBC,mDAAoB;CAC9C,AAAQ,gBAAgBC,+CAAkB;CAE1C,cAAc;AACZ,sCAAW;;CAIb,gDAA4B;EAC1B,MAAM,iBAAiB,KAAK,gBAAgB,gBAAgB;AAC5D,SACE,gBAAgB,kBAAkB,KAAK,kBACtC,eAAe,SAAS,UAAU,KAAK,wCAC1B,eAAe,WAAW,EAAE,EAAE,KAAK,QAAQ;GAE3D;CAEF,6CAAyB,KAAK,cAAc,SAAS,CAAC;CAGtD,eAAe;AACb,OAAK,gBAAgB,kBAAkB;GACrC,eAAe,KAAK;GACpB,SAAS,KAAK;GACf,CAAC"}