angular-intlayer 6.1.6 → 7.0.0-canary.2

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,80 +1,64 @@
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 focusDictionary_exports = {};
20
- __export(focusDictionary_exports, {
21
- createFocusDictionaryClient: () => createFocusDictionaryClient,
22
- installFocusDictionary: () => installFocusDictionary,
23
- useFocusDictionary: () => useFocusDictionary
24
- });
25
- module.exports = __toCommonJS(focusDictionary_exports);
26
- var import_core = require("@angular/core");
27
- var import_editor = require("@intlayer/editor");
28
- var import_createSharedComposable = require('./createSharedComposable.cjs');
29
- var import_useCrossFrameState = require('./useCrossFrameState.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
+ const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
+ let __angular_core = require("@angular/core");
5
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
6
+ let __intlayer_editor = require("@intlayer/editor");
7
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
8
+
9
+ //#region src/editor/focusDictionary.ts
10
+ /**
11
+ * Singleton instance
12
+ */
30
13
  let instance = null;
14
+ /**
15
+ * Creates a focus dictionary client
16
+ */
31
17
  const createFocusDictionaryClient = () => {
32
- if (instance) return instance;
33
- const focusedContentSignal = (0, import_core.signal)(null);
34
- const setFocusedContent = (focussedContent) => {
35
- focusedContentSignal.set(focussedContent);
36
- };
37
- const setFocusedContentKeyPath = (keyPath) => {
38
- const current = focusedContentSignal();
39
- if (!current) return;
40
- setFocusedContent({ ...current, keyPath });
41
- };
42
- instance = {
43
- focusedContent: focusedContentSignal.asReadonly(),
44
- setFocusedContent,
45
- setFocusedContentKeyPath
46
- };
47
- return instance;
18
+ if (instance) return instance;
19
+ const focusedContentSignal = (0, __angular_core.signal)(null);
20
+ const setFocusedContent = (focussedContent) => {
21
+ focusedContentSignal.set(focussedContent);
22
+ };
23
+ const setFocusedContentKeyPath = (keyPath) => {
24
+ const current = focusedContentSignal();
25
+ if (!current) return;
26
+ setFocusedContent({
27
+ ...current,
28
+ keyPath
29
+ });
30
+ };
31
+ instance = {
32
+ focusedContent: focusedContentSignal.asReadonly(),
33
+ setFocusedContent,
34
+ setFocusedContentKeyPath
35
+ };
36
+ return instance;
48
37
  };
49
- const installFocusDictionary = (injector) => {
50
- const client = createFocusDictionaryClient();
38
+ /**
39
+ * Helper to install the focus dictionary into the injector
40
+ */
41
+ const installFocusDictionary = (_injector) => {
42
+ createFocusDictionaryClient();
51
43
  };
52
- const useFocusDictionary = (0, import_createSharedComposable.createSharedComposable)(() => {
53
- const client = createFocusDictionaryClient();
54
- const [focusedContent, setFocusedContent] = (0, import_useCrossFrameState.useCrossFrameState)(
55
- import_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED
56
- );
57
- if (!client) {
58
- throw new Error("FocusDictionary state not found");
59
- }
60
- (0, import_core.effect)(() => {
61
- const newValue = client.focusedContent();
62
- if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {
63
- setFocusedContent(newValue);
64
- }
65
- });
66
- (0, import_core.effect)(() => {
67
- const newValue = focusedContent();
68
- if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {
69
- client.setFocusedContent(newValue ?? null);
70
- }
71
- });
72
- return client;
73
- });
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- createFocusDictionaryClient,
77
- installFocusDictionary,
78
- useFocusDictionary
44
+ /** consumer */
45
+ const useFocusDictionary = require_editor_createSharedComposable.createSharedComposable(() => {
46
+ const client = createFocusDictionaryClient();
47
+ const [focusedContent, setFocusedContent] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
48
+ if (!client) throw new Error("FocusDictionary state not found");
49
+ (0, __angular_core.effect)(() => {
50
+ const newValue = client.focusedContent();
51
+ if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
52
+ });
53
+ (0, __angular_core.effect)(() => {
54
+ const newValue = focusedContent();
55
+ if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
56
+ });
57
+ return client;
79
58
  });
59
+
60
+ //#endregion
61
+ exports.createFocusDictionaryClient = createFocusDictionaryClient;
62
+ exports.installFocusDictionary = installFocusDictionary;
63
+ exports.useFocusDictionary = useFocusDictionary;
80
64
  //# sourceMappingURL=focusDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { KeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (injector: Injector) => {\n const client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAiBnC,IAAI,WAAyC;AAKtC,MAAM,8BAA8B,MAAM;AAC/C,MAAI,SAAU,QAAO;AAErB,QAAM,2BAAuB,oBAA2B,IAAI;AAE5D,QAAM,oBAAoB,CAAC,oBAAwC;AACjE,yBAAqB,IAAI,eAAe;AAAA,EAC1C;AAEA,QAAM,2BAA2B,CAAC,YAAuB;AACvD,UAAM,UAAU,qBAAqB;AACrC,QAAI,CAAC,QAAS;AACd,sBAAkB,EAAE,GAAG,SAAS,QAAQ,CAAC;AAAA,EAC3C;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,yBAAyB,CAAC,aAAuB;AAC5D,QAAM,SAAS,4BAA4B;AAI7C;AAGO,MAAM,yBAAqB,sDAAuB,MAAM;AAC7D,QAAM,SAAS,4BAA4B;AAC3C,QAAM,CAAC,gBAAgB,iBAAiB,QACtC;AAAA,IACE,yBAAW;AAAA,EACb;AAEF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAIA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,eAAe;AACvC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,eAAe,CAAC,GAAG;AACjE,wBAAkB,QAAQ;AAAA,IAC5B;AAAA,EACF,CAAC;AAGD,0BAAO,MAAM;AACX,UAAM,WAAW,eAAe;AAChC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,OAAO,eAAe,CAAC,GAAG;AACxE,aAAO,kBAAkB,YAAY,IAAI;AAAA,IAC3C;AAAA,EACF,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
1
+ {"version":3,"file":"focusDictionary.cjs","names":["instance: FocusDictionaryClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAIA,WAAyC;;;;AAK7C,MAAa,oCAAoC;AAC/C,KAAI,SAAU,QAAO;CAErB,MAAM,kDAAkD,KAAK;CAE7D,MAAM,qBAAqB,oBAAwC;AACjE,uBAAqB,IAAI,gBAAgB;;CAG3C,MAAM,4BAA4B,YAAuB;EACvD,MAAM,UAAU,sBAAsB;AACtC,MAAI,CAAC,QAAS;AACd,oBAAkB;GAAE,GAAG;GAAS;GAAS,CAAC;;AAG5C,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD;EACA;EACD;AAED,QAAO;;;;;AAMT,MAAa,0BAA0B,cAAwB;AAC7C,8BAA6B;;;AAO/C,MAAa,qBAAqBC,mEAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrBC,qDACEC,6BAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,kCAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,kCAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}
@@ -1,38 +1,9 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var editor_exports = {};
21
- __export(editor_exports, {
22
- ContentSelectorWrapperComponent: () => import_ContentSelectorWrapper.ContentSelectorWrapperComponent,
23
- EditedContentRendererComponent: () => import_EditedContentRenderer.EditedContentRendererComponent,
24
- EditorSelectorRendererComponent: () => import_EditorSelectorRenderer.EditorSelectorRendererComponent
25
- });
26
- module.exports = __toCommonJS(editor_exports);
27
- var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.component.cjs');
28
- var import_EditedContentRenderer = require('./EditedContentRenderer.component.cjs');
29
- var import_EditorSelectorRenderer = require('./EditorSelectorRenderer.component.cjs');
30
- __reExport(editor_exports, require('./installIntlayerEditor.cjs'), module.exports);
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- ContentSelectorWrapperComponent,
34
- EditedContentRendererComponent,
35
- EditorSelectorRendererComponent,
36
- ...require('./installIntlayerEditor.cjs')
37
- });
38
- //# sourceMappingURL=index.cjs.map
1
+ const require_editor_ContentSelectorWrapper_component = require('./ContentSelectorWrapper.component.cjs');
2
+ const require_editor_EditedContentRenderer_component = require('./EditedContentRenderer.component.cjs');
3
+ const require_editor_EditorSelectorRenderer_component = require('./EditorSelectorRenderer.component.cjs');
4
+ const require_editor_installIntlayerEditor = require('./installIntlayerEditor.cjs');
5
+
6
+ exports.ContentSelectorWrapperComponent = require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent;
7
+ exports.EditedContentRendererComponent = require_editor_EditedContentRenderer_component.EditedContentRendererComponent;
8
+ exports.EditorSelectorRendererComponent = require_editor_EditorSelectorRenderer_component.EditorSelectorRendererComponent;
9
+ exports.installIntlayerEditor = require_editor_installIntlayerEditor.installIntlayerEditor;
@@ -1,70 +1,52 @@
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 });
11
- };
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 installIntlayerEditor_exports = {};
30
- __export(installIntlayerEditor_exports, {
31
- installIntlayerEditor: () => installIntlayerEditor
32
- });
33
- module.exports = __toCommonJS(installIntlayerEditor_exports);
34
- var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_communicator = require('./communicator.cjs');
36
- var import_dictionariesRecord = require('./dictionariesRecord.cjs');
37
- var import_editedContent = require('./editedContent.cjs');
38
- var import_editorEnabled = require('./editorEnabled.cjs');
39
- var import_focusDictionary = require('./focusDictionary.cjs');
40
- const { editor } = import_built.default;
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_communicator = require('./communicator.cjs');
3
+ const require_editor_editorEnabled = require('./editorEnabled.cjs');
4
+ const require_editor_focusDictionary = require('./focusDictionary.cjs');
5
+ const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
6
+ const require_editor_editedContent = require('./editedContent.cjs');
7
+ let __intlayer_config_built = require("@intlayer/config/built");
8
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
9
+
10
+ //#region src/editor/installIntlayerEditor.ts
11
+ const { editor } = __intlayer_config_built.default;
41
12
  const { applicationURL, editorURL, cmsURL } = editor ?? {};
42
13
  const postMessage = (data) => {
43
- if (typeof window === "undefined") return;
44
- const isInIframe = window.self !== window.top;
45
- if (!isInIframe) return;
46
- if (editor.applicationURL.length > 0) {
47
- window.postMessage(data, editor.applicationURL);
48
- }
49
- if (editor.editorURL.length > 0) {
50
- window.parent.postMessage(data, editor.editorURL);
51
- }
52
- if (editor.cmsURL.length > 0) {
53
- window.parent.postMessage(data, editor.cmsURL);
54
- }
14
+ if (typeof window === "undefined") return;
15
+ if (!(window.self !== window.top)) return;
16
+ if (editor.applicationURL.length > 0) window.postMessage(data, editor.applicationURL);
17
+ if (editor.editorURL.length > 0) window.parent.postMessage(data, editor.editorURL);
18
+ if (editor.cmsURL.length > 0) window.parent.postMessage(data, editor.cmsURL);
55
19
  };
20
+ /**
21
+ * Angular-side replacement for the former <IntlayerEditorProvider> React component.
22
+ *
23
+ * Call **once** in your Angular application's bootstrap function or main module:
24
+ *
25
+ * ```typescript
26
+ * import { bootstrapApplication } from '@angular/platform-browser';
27
+ * import { AppComponent } from './app/app.component';
28
+ * import { installIntlayerEditor } from 'angular-intlayer';
29
+ *
30
+ * bootstrapApplication(AppComponent).then(appRef => {
31
+ * installIntlayerEditor(appRef.injector);
32
+ * });
33
+ * ```
34
+ */
56
35
  const installIntlayerEditor = (injector) => {
57
- (0, import_communicator.installCommunicator)(injector, {
58
- postMessage,
59
- allowedOrigins: [applicationURL, editorURL, cmsURL]
60
- });
61
- (0, import_editorEnabled.installEditorEnabled)(injector);
62
- (0, import_dictionariesRecord.installDictionariesRecord)(injector);
63
- (0, import_editedContent.installEditedContent)(injector);
64
- (0, import_focusDictionary.installFocusDictionary)(injector);
36
+ require_editor_communicator.installCommunicator(injector, {
37
+ postMessage,
38
+ allowedOrigins: [
39
+ applicationURL,
40
+ editorURL,
41
+ cmsURL
42
+ ]
43
+ });
44
+ require_editor_editorEnabled.installEditorEnabled(injector);
45
+ require_editor_dictionariesRecord.installDictionariesRecord(injector);
46
+ require_editor_editedContent.installEditedContent(injector);
47
+ require_editor_focusDictionary.installFocusDictionary(injector);
65
48
  };
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- installIntlayerEditor
69
- });
49
+
50
+ //#endregion
51
+ exports.installIntlayerEditor = installIntlayerEditor;
70
52
  //# sourceMappingURL=installIntlayerEditor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installCommunicator } from './communicator';\nimport { installDictionariesRecord } from './dictionariesRecord';\nimport { installEditedContent } from './editedContent';\nimport { installEditorEnabled } from './editorEnabled';\nimport { installFocusDictionary } from './focusDictionary';\n\nconst { editor } = configuration;\nconst { applicationURL, editorURL, cmsURL } = editor ?? {};\n\nconst postMessage = (data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window.postMessage(data, editor.applicationURL);\n }\n\n if (editor.editorURL.length > 0) {\n window.parent.postMessage(data, editor.editorURL);\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent.postMessage(data, editor.cmsURL);\n }\n};\n\n/**\n * Angular-side replacement for the former <IntlayerEditorProvider> React component.\n *\n * Call **once** in your Angular application's bootstrap function or main module:\n *\n * ```typescript\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { AppComponent } from './app/app.component';\n * import { installIntlayerEditor } from 'angular-intlayer';\n *\n * bootstrapApplication(AppComponent).then(appRef => {\n * installIntlayerEditor(appRef.injector);\n * });\n * ```\n */\nexport const installIntlayerEditor = (injector: Injector): void => {\n /* ---------------------------------------------------------------------\n * 1. Base providers – always on\n * -------------------------------------------------------------------*/\n\n installCommunicator(injector, {\n postMessage,\n allowedOrigins: [applicationURL, editorURL, cmsURL] as string[],\n });\n installEditorEnabled(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0B;AAC1B,0BAAoC;AACpC,gCAA0C;AAC1C,2BAAqC;AACrC,2BAAqC;AACrC,6BAAuC;AAEvC,MAAM,EAAE,OAAO,IAAI,aAAAA;AACnB,MAAM,EAAE,gBAAgB,WAAW,OAAO,IAAI,UAAU,CAAC;AAEzD,MAAM,cAAc,CAAC,SAAc;AACjC,MAAI,OAAO,WAAW,YAAa;AAEnC,QAAM,aAAa,OAAO,SAAS,OAAO;AAE1C,MAAI,CAAC,WAAY;AAEjB,MAAI,OAAO,eAAe,SAAS,GAAG;AACpC,WAAO,YAAY,MAAM,OAAO,cAAc;AAAA,EAChD;AAEA,MAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,WAAO,OAAO,YAAY,MAAM,OAAO,SAAS;AAAA,EAClD;AAEA,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,WAAO,OAAO,YAAY,MAAM,OAAO,MAAM;AAAA,EAC/C;AACF;AAiBO,MAAM,wBAAwB,CAAC,aAA6B;AAKjE,+CAAoB,UAAU;AAAA,IAC5B;AAAA,IACA,gBAAgB,CAAC,gBAAgB,WAAW,MAAM;AAAA,EACpD,CAAC;AACD,iDAAqB,QAAQ;AAC7B,2DAA0B,QAAQ;AAClC,iDAAqB,QAAQ;AAC7B,qDAAuB,QAAQ;AACjC;","names":["configuration"]}
1
+ {"version":3,"file":"installIntlayerEditor.cjs","names":["configuration"],"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installCommunicator } from './communicator';\nimport { installDictionariesRecord } from './dictionariesRecord';\nimport { installEditedContent } from './editedContent';\nimport { installEditorEnabled } from './editorEnabled';\nimport { installFocusDictionary } from './focusDictionary';\n\nconst { editor } = configuration;\nconst { applicationURL, editorURL, cmsURL } = editor ?? {};\n\nconst postMessage = (data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window.postMessage(data, editor.applicationURL);\n }\n\n if (editor.editorURL.length > 0) {\n window.parent.postMessage(data, editor.editorURL);\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent.postMessage(data, editor.cmsURL);\n }\n};\n\n/**\n * Angular-side replacement for the former <IntlayerEditorProvider> React component.\n *\n * Call **once** in your Angular application's bootstrap function or main module:\n *\n * ```typescript\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { AppComponent } from './app/app.component';\n * import { installIntlayerEditor } from 'angular-intlayer';\n *\n * bootstrapApplication(AppComponent).then(appRef => {\n * installIntlayerEditor(appRef.injector);\n * });\n * ```\n */\nexport const installIntlayerEditor = (injector: Injector): void => {\n /* ---------------------------------------------------------------------\n * 1. Base providers – always on\n * -------------------------------------------------------------------*/\n\n installCommunicator(injector, {\n postMessage,\n allowedOrigins: [applicationURL, editorURL, cmsURL] as string[],\n });\n installEditorEnabled(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAM,EAAE,WAAWA;AACnB,MAAM,EAAE,gBAAgB,WAAW,WAAW,UAAU,EAAE;AAE1D,MAAM,eAAe,SAAc;AACjC,KAAI,OAAO,WAAW,YAAa;AAInC,KAAI,EAFe,OAAO,SAAS,OAAO,KAEzB;AAEjB,KAAI,OAAO,eAAe,SAAS,EACjC,QAAO,YAAY,MAAM,OAAO,eAAe;AAGjD,KAAI,OAAO,UAAU,SAAS,EAC5B,QAAO,OAAO,YAAY,MAAM,OAAO,UAAU;AAGnD,KAAI,OAAO,OAAO,SAAS,EACzB,QAAO,OAAO,YAAY,MAAM,OAAO,OAAO;;;;;;;;;;;;;;;;;AAmBlD,MAAa,yBAAyB,aAA6B;AAKjE,iDAAoB,UAAU;EAC5B;EACA,gBAAgB;GAAC;GAAgB;GAAW;GAAO;EACpD,CAAC;AACF,mDAAqB,SAAS;AAC9B,6DAA0B,SAAS;AACnC,mDAAqB,SAAS;AAC9B,uDAAuB,SAAS"}
@@ -1,83 +1,74 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useCrossFrameMessageListener_exports = {};
21
- __export(useCrossFrameMessageListener_exports, {
22
- useCrossFrameMessageListener: () => useCrossFrameMessageListener
23
- });
24
- module.exports = __toCommonJS(useCrossFrameMessageListener_exports);
25
- var import_core = require("@angular/core");
26
- var import_editor = require("@intlayer/editor");
27
- var import_communicator = require('./communicator.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_editor_communicator = require('./communicator.cjs');
6
+ let __angular_core = require("@angular/core");
7
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
8
+ let __intlayer_editor = require("@intlayer/editor");
9
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
10
+
11
+ //#region src/editor/useCrossFrameMessageListener.ts
12
+ /** Map<key, Set<callback>> */
28
13
  const subscribers = /* @__PURE__ */ new Map();
14
+ /** True once we've attached the single window listener */
29
15
  let windowListenerAttached = false;
16
+ /** Helper to add/remove a callback for a key */
30
17
  function addSubscriber(key, cb) {
31
- let set = subscribers.get(key);
32
- if (!set) {
33
- set = /* @__PURE__ */ new Set();
34
- subscribers.set(key, set);
35
- }
36
- set.add(cb);
18
+ let set = subscribers.get(key);
19
+ if (!set) {
20
+ set = /* @__PURE__ */ new Set();
21
+ subscribers.set(key, set);
22
+ }
23
+ set.add(cb);
37
24
  }
38
25
  function removeSubscriber(key, cb) {
39
- const set = subscribers.get(key);
40
- if (!set) return;
41
- set.delete(cb);
42
- if (set.size === 0) subscribers.delete(key);
26
+ const set = subscribers.get(key);
27
+ if (!set) return;
28
+ set.delete(cb);
29
+ if (set.size === 0) subscribers.delete(key);
43
30
  }
31
+ /** The one global window listener */
44
32
  function ensureGlobalListener(allowedOrigins, selfId) {
45
- if (windowListenerAttached) return;
46
- window.addEventListener("message", (event) => {
47
- const { type, data, senderId } = event.data ?? {};
48
- if (!type) return;
49
- if (senderId === selfId) return;
50
- if (!allowedOrigins || allowedOrigins.includes("*") || allowedOrigins.some((o) => (0, import_editor.compareUrls)(o, event.origin))) {
51
- subscribers.get(type)?.forEach((cb) => cb(data));
52
- }
53
- });
54
- windowListenerAttached = true;
33
+ if (windowListenerAttached) return;
34
+ window.addEventListener("message", (event) => {
35
+ const { type, data, senderId } = event.data ?? {};
36
+ if (!type) return;
37
+ if (senderId === selfId) return;
38
+ if (!allowedOrigins || allowedOrigins.includes("*") || allowedOrigins.some((o) => (0, __intlayer_editor.compareUrls)(o, event.origin))) subscribers.get(type)?.forEach((cb) => cb(data));
39
+ });
40
+ windowListenerAttached = true;
55
41
  }
42
+ /**
43
+ * useCrossFrameMessageListener
44
+ *
45
+ * @template S - type of the message payload
46
+ * @param key message type we care about
47
+ * @param onEventTriggered optional callback when a matching message arrives
48
+ * @returns postMessage(data?) helper scoped to this key
49
+ */
56
50
  const useCrossFrameMessageListener = (key, onEventTriggered) => {
57
- const { allowedOrigins, postMessage, senderId } = (0, import_communicator.useCommunicator)();
58
- ensureGlobalListener(allowedOrigins, senderId);
59
- if (onEventTriggered) {
60
- addSubscriber(key, onEventTriggered);
61
- try {
62
- const destroyRef = (0, import_core.inject)(import_core.DestroyRef, { optional: true });
63
- if (destroyRef) {
64
- destroyRef.onDestroy(
65
- () => removeSubscriber(key, onEventTriggered)
66
- );
67
- }
68
- } catch {
69
- console.warn(
70
- "useCrossFrameMessageListener called outside injection context; cleanup may not be available."
71
- );
72
- }
73
- }
74
- const postMessageWrapper = (data) => {
75
- postMessage({ type: key, data, senderId });
76
- };
77
- return postMessageWrapper;
51
+ const { allowedOrigins, postMessage, senderId } = require_editor_communicator.useCommunicator();
52
+ ensureGlobalListener(allowedOrigins, senderId);
53
+ if (onEventTriggered) {
54
+ addSubscriber(key, onEventTriggered);
55
+ try {
56
+ const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
57
+ if (destroyRef) destroyRef.onDestroy(() => removeSubscriber(key, onEventTriggered));
58
+ } catch {
59
+ console.warn("useCrossFrameMessageListener called outside injection context; cleanup may not be available.");
60
+ }
61
+ }
62
+ const postMessageWrapper = (data) => {
63
+ postMessage({
64
+ type: key,
65
+ data,
66
+ senderId
67
+ });
68
+ };
69
+ return postMessageWrapper;
78
70
  };
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- useCrossFrameMessageListener
82
- });
71
+
72
+ //#endregion
73
+ exports.useCrossFrameMessageListener = useCrossFrameMessageListener;
83
74
  //# sourceMappingURL=useCrossFrameMessageListener.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { type MessageKey, compareUrls } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nfunction addSubscriber(key: string, cb: AnyFn) {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n}\n\nfunction removeSubscriber(key: string, cb: AnyFn) {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n}\n\n/** The one global window listener */\nfunction ensureGlobalListener(\n allowedOrigins: string[] | undefined,\n selfId: string\n) {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => cb(data));\n }\n });\n windowListenerAttached = true;\n}\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAmC;AACnC,oBAA6C;AAC7C,0BAAgC;AAMhC,MAAM,cAAc,oBAAI,IAAwB;AAGhD,IAAI,yBAAyB;AAG7B,SAAS,cAAc,KAAa,IAAW;AAC7C,MAAI,MAAM,YAAY,IAAI,GAAG;AAC7B,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,gBAAY,IAAI,KAAK,GAAG;AAAA,EAC1B;AACA,MAAI,IAAI,EAAE;AACZ;AAEA,SAAS,iBAAiB,KAAa,IAAW;AAChD,QAAM,MAAM,YAAY,IAAI,GAAG;AAC/B,MAAI,CAAC,IAAK;AACV,MAAI,OAAO,EAAE;AACb,MAAI,IAAI,SAAS,EAAG,aAAY,OAAO,GAAG;AAC5C;AAGA,SAAS,qBACP,gBACA,QACA;AACA,MAAI,uBAAwB;AAC5B,SAAO,iBAAiB,WAAW,CAAC,UAAU;AAC5C,UAAM,EAAE,MAAM,MAAM,SAAS,IAAI,MAAM,QAAQ,CAAC;AAChD,QAAI,CAAC,KAAM;AACX,QAAI,aAAa,OAAQ;AAGzB,QACE,CAAC,kBACD,eAAe,SAAS,GAAG,KAC3B,eAAe,KAAK,CAAC,UAAM,2BAAY,GAAG,MAAM,MAAM,CAAC,GACvD;AAEA,kBAAY,IAAI,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AAAA,IACjD;AAAA,EACF,CAAC;AACD,2BAAyB;AAC3B;AAWO,MAAM,+BAA+B,CAC1C,KACA,qBACG;AAEH,QAAM,EAAE,gBAAgB,aAAa,SAAS,QAAI,qCAAgB;AAGlE,uBAAqB,gBAAgB,QAAQ;AAG7C,MAAI,kBAAkB;AACpB,kBAAc,KAAK,gBAAyB;AAG5C,QAAI;AACF,YAAM,iBAAa,oBAAO,wBAAY,EAAE,UAAU,KAAK,CAAC;AACxD,UAAI,YAAY;AACd,mBAAW;AAAA,UAAU,MACnB,iBAAiB,KAAK,gBAAyB;AAAA,QACjD;AAAA,MACF;AAAA,IACF,QAAQ;AAEN,cAAQ;AAAA,QACN;AAAA,MAEF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,qBAAqB,CAAC,SAAa;AACvC,gBAAY,EAAE,MAAM,KAAK,MAAM,SAAS,CAAC;AAAA,EAC3C;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nfunction addSubscriber(key: string, cb: AnyFn) {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n}\n\nfunction removeSubscriber(key: string, cb: AnyFn) {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n}\n\n/** The one global window listener */\nfunction ensureGlobalListener(\n allowedOrigins: string[] | undefined,\n selfId: string\n) {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => cb(data));\n }\n });\n windowListenerAttached = true;\n}\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,8BAAc,IAAI,KAAyB;;AAGjD,IAAI,yBAAyB;;AAG7B,SAAS,cAAc,KAAa,IAAW;CAC7C,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,CAAC,KAAK;AACR,wBAAM,IAAI,KAAK;AACf,cAAY,IAAI,KAAK,IAAI;;AAE3B,KAAI,IAAI,GAAG;;AAGb,SAAS,iBAAiB,KAAa,IAAW;CAChD,MAAM,MAAM,YAAY,IAAI,IAAI;AAChC,KAAI,CAAC,IAAK;AACV,KAAI,OAAO,GAAG;AACd,KAAI,IAAI,SAAS,EAAG,aAAY,OAAO,IAAI;;;AAI7C,SAAS,qBACP,gBACA,QACA;AACA,KAAI,uBAAwB;AAC5B,QAAO,iBAAiB,YAAY,UAAU;EAC5C,MAAM,EAAE,MAAM,MAAM,aAAa,MAAM,QAAQ,EAAE;AACjD,MAAI,CAAC,KAAM;AACX,MAAI,aAAa,OAAQ;AAGzB,MACE,CAAC,kBACD,eAAe,SAAS,IAAI,IAC5B,eAAe,MAAM,yCAAkB,GAAG,MAAM,OAAO,CAAC,CAGxD,aAAY,IAAI,KAAK,EAAE,SAAS,OAAO,GAAG,KAAK,CAAC;GAElD;AACF,0BAAyB;;;;;;;;;;AAY3B,MAAa,gCACX,KACA,qBACG;CAEH,MAAM,EAAE,gBAAgB,aAAa,aAAaA,6CAAiB;AAGnE,sBAAqB,gBAAgB,SAAS;AAG9C,KAAI,kBAAkB;AACpB,gBAAc,KAAK,iBAA0B;AAG7C,MAAI;GACF,MAAM,wCAAoBC,2BAAY,EAAE,UAAU,MAAM,CAAC;AACzD,OAAI,WACF,YAAW,gBACT,iBAAiB,KAAK,iBAA0B,CACjD;UAEG;AAEN,WAAQ,KACN,+FAED;;;CAKL,MAAM,sBAAsB,SAAa;AACvC,cAAY;GAAE,MAAM;GAAK;GAAM;GAAU,CAAC;;AAG5C,QAAO"}