angular-intlayer 5.5.8 → 5.5.10

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 (262) hide show
  1. package/README.md +42 -9
  2. package/dist/cjs/UI/ContentSelector.component.cjs +141 -0
  3. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -0
  4. package/dist/cjs/client/index.cjs +13 -27
  5. package/dist/cjs/client/index.cjs.map +1 -1
  6. package/dist/cjs/client/installIntlayer.cjs +72 -0
  7. package/dist/cjs/client/installIntlayer.cjs.map +1 -0
  8. package/dist/cjs/client/{getDictionary.cjs → useDictionary.cjs} +15 -19
  9. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  10. package/dist/cjs/client/useDictionaryDynamic.cjs +42 -0
  11. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
  12. package/dist/cjs/client/{getBrowserLocale.cjs → useIntlayer.cjs} +17 -11
  13. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  14. package/dist/cjs/client/{intlayer.service.cjs → useLoadDynamic.cjs} +21 -19
  15. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -0
  16. package/dist/cjs/client/useLocale.cjs +69 -0
  17. package/dist/cjs/client/useLocale.cjs.map +1 -0
  18. package/dist/cjs/client/useLocaleCookie.cjs +60 -0
  19. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
  20. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +73 -0
  21. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -0
  22. package/dist/cjs/editor/EditedContentRenderer.component.cjs +77 -0
  23. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -0
  24. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +58 -0
  25. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -0
  26. package/dist/cjs/editor/changedContent.cjs +62 -0
  27. package/dist/cjs/editor/changedContent.cjs.map +1 -0
  28. package/dist/cjs/editor/communicator.cjs +82 -0
  29. package/dist/cjs/editor/communicator.cjs.map +1 -0
  30. package/dist/cjs/editor/configuration.cjs +57 -0
  31. package/dist/cjs/editor/configuration.cjs.map +1 -0
  32. package/dist/cjs/editor/createSharedComposable.cjs +68 -0
  33. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -0
  34. package/dist/cjs/editor/dictionariesRecord.cjs +83 -0
  35. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -0
  36. package/dist/cjs/editor/editedContent.cjs +77 -0
  37. package/dist/cjs/editor/editedContent.cjs.map +1 -0
  38. package/dist/cjs/editor/editorEnabled.cjs +76 -0
  39. package/dist/cjs/editor/editorEnabled.cjs.map +1 -0
  40. package/dist/cjs/editor/editorLocale.cjs +47 -0
  41. package/dist/cjs/editor/editorLocale.cjs.map +1 -0
  42. package/dist/cjs/editor/focusDictionary.cjs +80 -0
  43. package/dist/cjs/editor/focusDictionary.cjs.map +1 -0
  44. package/dist/cjs/editor/index.cjs +38 -0
  45. package/dist/cjs/editor/index.cjs.map +1 -0
  46. package/dist/cjs/editor/installIntlayerEditor.cjs +72 -0
  47. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -0
  48. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +83 -0
  49. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -0
  50. package/dist/cjs/editor/useCrossFrameState.cjs +95 -0
  51. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -0
  52. package/dist/cjs/editor/useCrossURLPathState.cjs +72 -0
  53. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -0
  54. package/dist/cjs/editor/useEditedContentRenderer.cjs +58 -0
  55. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
  56. package/dist/cjs/editor/useEditor.cjs +46 -0
  57. package/dist/cjs/editor/useEditor.cjs.map +1 -0
  58. package/dist/cjs/editor/useIframeClickInterceptor.cjs +62 -0
  59. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -0
  60. package/dist/cjs/getDictionary.cjs +15 -2
  61. package/dist/cjs/getDictionary.cjs.map +1 -1
  62. package/dist/cjs/getIntlayer.cjs +9 -2
  63. package/dist/cjs/getIntlayer.cjs.map +1 -1
  64. package/dist/cjs/markdown/index.cjs +3 -16
  65. package/dist/cjs/markdown/index.cjs.map +1 -1
  66. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +66 -0
  67. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -0
  68. package/dist/cjs/plugins.cjs +27 -18
  69. package/dist/cjs/plugins.cjs.map +1 -1
  70. package/dist/cjs/renderIntlayerNode.cjs +58 -0
  71. package/dist/cjs/renderIntlayerNode.cjs.map +1 -0
  72. package/dist/cjs/{client/getLocale.cjs → webpack/index.cjs} +6 -14
  73. package/dist/cjs/webpack/index.cjs.map +1 -0
  74. package/dist/cjs/webpack/mergeConfig.cjs +83 -0
  75. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -0
  76. package/dist/esm/UI/ContentSelector.component.mjs +126 -0
  77. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -0
  78. package/dist/esm/client/index.mjs +6 -16
  79. package/dist/esm/client/index.mjs.map +1 -1
  80. package/dist/esm/client/installIntlayer.mjs +35 -0
  81. package/dist/esm/client/installIntlayer.mjs.map +1 -0
  82. package/dist/esm/client/useDictionary.mjs +15 -0
  83. package/dist/esm/client/useDictionary.mjs.map +1 -0
  84. package/dist/esm/client/useDictionaryDynamic.mjs +18 -0
  85. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
  86. package/dist/esm/client/useIntlayer.mjs +15 -0
  87. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  88. package/dist/esm/client/useLoadDynamic.mjs +21 -0
  89. package/dist/esm/client/useLoadDynamic.mjs.map +1 -0
  90. package/dist/esm/client/useLocale.mjs +35 -0
  91. package/dist/esm/client/useLocale.mjs.map +1 -0
  92. package/dist/esm/client/useLocaleCookie.mjs +24 -0
  93. package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
  94. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +49 -0
  95. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -0
  96. package/dist/esm/editor/EditedContentRenderer.component.mjs +53 -0
  97. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -0
  98. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +34 -0
  99. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -0
  100. package/dist/esm/editor/changedContent.mjs +36 -0
  101. package/dist/esm/editor/changedContent.mjs.map +1 -0
  102. package/dist/esm/editor/communicator.mjs +46 -0
  103. package/dist/esm/editor/communicator.mjs.map +1 -0
  104. package/dist/esm/editor/configuration.mjs +23 -0
  105. package/dist/esm/editor/configuration.mjs.map +1 -0
  106. package/dist/esm/editor/createSharedComposable.mjs +43 -0
  107. package/dist/esm/editor/createSharedComposable.mjs.map +1 -0
  108. package/dist/esm/editor/dictionariesRecord.mjs +47 -0
  109. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -0
  110. package/dist/esm/editor/editedContent.mjs +51 -0
  111. package/dist/esm/editor/editedContent.mjs.map +1 -0
  112. package/dist/esm/editor/editorEnabled.mjs +50 -0
  113. package/dist/esm/editor/editorEnabled.mjs.map +1 -0
  114. package/dist/esm/editor/editorLocale.mjs +23 -0
  115. package/dist/esm/editor/editorLocale.mjs.map +1 -0
  116. package/dist/esm/editor/focusDictionary.mjs +54 -0
  117. package/dist/esm/editor/focusDictionary.mjs.map +1 -0
  118. package/dist/esm/editor/index.mjs +10 -0
  119. package/dist/esm/editor/index.mjs.map +1 -0
  120. package/dist/esm/editor/installIntlayerEditor.mjs +38 -0
  121. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -0
  122. package/dist/esm/editor/useCrossFrameMessageListener.mjs +59 -0
  123. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
  124. package/dist/esm/editor/useCrossFrameState.mjs +71 -0
  125. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
  126. package/dist/esm/editor/useCrossURLPathState.mjs +47 -0
  127. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -0
  128. package/dist/esm/editor/useEditedContentRenderer.mjs +37 -0
  129. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
  130. package/dist/esm/editor/useEditor.mjs +22 -0
  131. package/dist/esm/editor/useEditor.mjs.map +1 -0
  132. package/dist/esm/editor/useIframeClickInterceptor.mjs +37 -0
  133. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -0
  134. package/dist/esm/getDictionary.mjs +19 -1
  135. package/dist/esm/getDictionary.mjs.map +1 -1
  136. package/dist/esm/getIntlayer.mjs +14 -2
  137. package/dist/esm/getIntlayer.mjs.map +1 -1
  138. package/dist/esm/markdown/index.mjs +1 -10
  139. package/dist/esm/markdown/index.mjs.map +1 -1
  140. package/dist/esm/markdown/installIntlayerMarkdown.mjs +39 -0
  141. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -0
  142. package/dist/esm/plugins.mjs +27 -17
  143. package/dist/esm/plugins.mjs.map +1 -1
  144. package/dist/esm/renderIntlayerNode.mjs +34 -0
  145. package/dist/esm/renderIntlayerNode.mjs.map +1 -0
  146. package/dist/esm/webpack/index.mjs +2 -0
  147. package/dist/esm/webpack/index.mjs.map +1 -0
  148. package/dist/esm/webpack/mergeConfig.mjs +49 -0
  149. package/dist/esm/webpack/mergeConfig.mjs.map +1 -0
  150. package/dist/types/UI/ContentSelector.component.d.ts +32 -0
  151. package/dist/types/UI/ContentSelector.component.d.ts.map +1 -0
  152. package/dist/types/client/index.d.ts +6 -7
  153. package/dist/types/client/index.d.ts.map +1 -1
  154. package/dist/types/client/installIntlayer.d.ts +17 -0
  155. package/dist/types/client/installIntlayer.d.ts.map +1 -0
  156. package/dist/types/client/useDictionary.d.ts +5 -0
  157. package/dist/types/client/useDictionary.d.ts.map +1 -0
  158. package/dist/types/client/useDictionaryDynamic.d.ts +9 -0
  159. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  160. package/dist/types/client/useIntlayer.d.ts +10 -0
  161. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  162. package/dist/types/client/useLoadDynamic.d.ts +8 -0
  163. package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
  164. package/dist/types/client/useLocale.d.ts +15 -0
  165. package/dist/types/client/useLocale.d.ts.map +1 -0
  166. package/dist/types/client/useLocaleCookie.d.ts +17 -0
  167. package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
  168. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +19 -0
  169. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -0
  170. package/dist/types/editor/EditedContentRenderer.component.d.ts +19 -0
  171. package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -0
  172. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +13 -0
  173. package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -0
  174. package/dist/types/editor/changedContent.d.ts +14 -0
  175. package/dist/types/editor/changedContent.d.ts.map +1 -0
  176. package/dist/types/editor/communicator.d.ts +28 -0
  177. package/dist/types/editor/communicator.d.ts.map +1 -0
  178. package/dist/types/editor/configuration.d.ts +2 -0
  179. package/dist/types/editor/configuration.d.ts.map +1 -0
  180. package/dist/types/editor/createSharedComposable.d.ts +14 -0
  181. package/dist/types/editor/createSharedComposable.d.ts.map +1 -0
  182. package/dist/types/editor/dictionariesRecord.d.ts +16 -0
  183. package/dist/types/editor/dictionariesRecord.d.ts.map +1 -0
  184. package/dist/types/editor/editedContent.d.ts +19 -0
  185. package/dist/types/editor/editedContent.d.ts.map +1 -0
  186. package/dist/types/editor/editorEnabled.d.ts +16 -0
  187. package/dist/types/editor/editorEnabled.d.ts.map +1 -0
  188. package/dist/types/editor/editorLocale.d.ts +3 -0
  189. package/dist/types/editor/editorLocale.d.ts.map +1 -0
  190. package/dist/types/editor/focusDictionary.d.ts +24 -0
  191. package/dist/types/editor/focusDictionary.d.ts.map +1 -0
  192. package/dist/types/editor/index.d.ts +5 -0
  193. package/dist/types/editor/index.d.ts.map +1 -0
  194. package/dist/types/editor/installIntlayerEditor.d.ts +18 -0
  195. package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -0
  196. package/dist/types/editor/useCrossFrameMessageListener.d.ts +11 -0
  197. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -0
  198. package/dist/types/editor/useCrossFrameState.d.ts +24 -0
  199. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -0
  200. package/dist/types/editor/useCrossURLPathState.d.ts +16 -0
  201. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -0
  202. package/dist/types/editor/useEditedContentRenderer.d.ts +17 -0
  203. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
  204. package/dist/types/editor/useEditor.d.ts +2 -0
  205. package/dist/types/editor/useEditor.d.ts.map +1 -0
  206. package/dist/types/editor/useIframeClickInterceptor.d.ts +11 -0
  207. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -0
  208. package/dist/types/getDictionary.d.ts +4 -1
  209. package/dist/types/getDictionary.d.ts.map +1 -1
  210. package/dist/types/getIntlayer.d.ts +4 -6
  211. package/dist/types/getIntlayer.d.ts.map +1 -1
  212. package/dist/types/markdown/index.d.ts +1 -4
  213. package/dist/types/markdown/index.d.ts.map +1 -1
  214. package/dist/types/markdown/installIntlayerMarkdown.d.ts +26 -0
  215. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
  216. package/dist/types/plugins.d.ts +0 -9
  217. package/dist/types/plugins.d.ts.map +1 -1
  218. package/dist/types/renderIntlayerNode.d.ts +13 -0
  219. package/dist/types/renderIntlayerNode.d.ts.map +1 -0
  220. package/dist/types/webpack/index.d.ts +2 -0
  221. package/dist/types/webpack/index.d.ts.map +1 -0
  222. package/dist/types/webpack/mergeConfig.d.ts +3 -0
  223. package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
  224. package/package.json +23 -9
  225. package/dist/cjs/client/dictionary.service.cjs +0 -70
  226. package/dist/cjs/client/dictionary.service.cjs.map +0 -1
  227. package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
  228. package/dist/cjs/client/getDictionary.cjs.map +0 -1
  229. package/dist/cjs/client/getLocale.cjs.map +0 -1
  230. package/dist/cjs/client/intlayer.service.cjs.map +0 -1
  231. package/dist/cjs/client/locale.service.cjs +0 -66
  232. package/dist/cjs/client/locale.service.cjs.map +0 -1
  233. package/dist/cjs/client/t.cjs +0 -32
  234. package/dist/cjs/client/t.cjs.map +0 -1
  235. package/dist/esm/client/dictionary.service.mjs +0 -46
  236. package/dist/esm/client/dictionary.service.mjs.map +0 -1
  237. package/dist/esm/client/getBrowserLocale.mjs +0 -10
  238. package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
  239. package/dist/esm/client/getDictionary.mjs +0 -25
  240. package/dist/esm/client/getDictionary.mjs.map +0 -1
  241. package/dist/esm/client/getLocale.mjs +0 -7
  242. package/dist/esm/client/getLocale.mjs.map +0 -1
  243. package/dist/esm/client/intlayer.service.mjs +0 -19
  244. package/dist/esm/client/intlayer.service.mjs.map +0 -1
  245. package/dist/esm/client/locale.service.mjs +0 -42
  246. package/dist/esm/client/locale.service.mjs.map +0 -1
  247. package/dist/esm/client/t.mjs +0 -8
  248. package/dist/esm/client/t.mjs.map +0 -1
  249. package/dist/types/client/dictionary.service.d.ts +0 -21
  250. package/dist/types/client/dictionary.service.d.ts.map +0 -1
  251. package/dist/types/client/getBrowserLocale.d.ts +0 -6
  252. package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
  253. package/dist/types/client/getDictionary.d.ts +0 -8
  254. package/dist/types/client/getDictionary.d.ts.map +0 -1
  255. package/dist/types/client/getLocale.d.ts +0 -7
  256. package/dist/types/client/getLocale.d.ts.map +0 -1
  257. package/dist/types/client/intlayer.service.d.ts +0 -8
  258. package/dist/types/client/intlayer.service.d.ts.map +0 -1
  259. package/dist/types/client/locale.service.d.ts +0 -12
  260. package/dist/types/client/locale.service.d.ts.map +0 -1
  261. package/dist/types/client/t.d.ts +0 -8
  262. package/dist/types/client/t.d.ts.map +0 -1
@@ -0,0 +1,83 @@
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 dictionariesRecord_exports = {};
30
+ __export(dictionariesRecord_exports, {
31
+ createDictionaryRecordClient: () => createDictionaryRecordClient,
32
+ installDictionariesRecord: () => installDictionariesRecord,
33
+ useDictionariesRecord: () => useDictionariesRecord
34
+ });
35
+ module.exports = __toCommonJS(dictionariesRecord_exports);
36
+ var import_core = require("@angular/core");
37
+ var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
38
+ var import_editor = require("@intlayer/editor");
39
+ var import_createSharedComposable = require('./createSharedComposable.cjs');
40
+ var import_useCrossFrameState = require('./useCrossFrameState.cjs');
41
+ let instance = null;
42
+ const createDictionaryRecordClient = () => {
43
+ if (instance) return instance;
44
+ const localeDictionariesSignal = (0, import_core.signal)(import_dictionaries_entry.default);
45
+ instance = {
46
+ localeDictionaries: localeDictionariesSignal.asReadonly(),
47
+ setLocaleDictionaries: (newValue) => {
48
+ localeDictionariesSignal.set(newValue ?? {});
49
+ },
50
+ setLocaleDictionary(dictionary) {
51
+ const current = localeDictionariesSignal();
52
+ localeDictionariesSignal.set({
53
+ ...current,
54
+ [dictionary.key]: dictionary
55
+ });
56
+ }
57
+ };
58
+ return instance;
59
+ };
60
+ const installDictionariesRecord = (injector) => {
61
+ const client = createDictionaryRecordClient();
62
+ };
63
+ const useDictionariesRecord = (0, import_createSharedComposable.createSharedComposable)(() => {
64
+ const client = createDictionaryRecordClient();
65
+ if (!client) {
66
+ throw new Error("DictionariesRecord state not found");
67
+ }
68
+ const [_dictionariesRecord, setDictionariesRecord] = (0, import_useCrossFrameState.useCrossFrameState)(
69
+ import_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,
70
+ void 0
71
+ );
72
+ (0, import_core.effect)(() => {
73
+ const newValue = client.localeDictionaries();
74
+ setDictionariesRecord(newValue);
75
+ });
76
+ });
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ createDictionaryRecordClient,
80
+ installDictionariesRecord,
81
+ useDictionariesRecord
82
+ });
83
+ //# sourceMappingURL=dictionariesRecord.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Singleton instance\n */\nlet instance: DictionariesRecordClient | null = null;\n\nexport type DictionaryContent = Record<Dictionary['key'], Dictionary>;\n\ntype DictionariesRecordClient = {\n localeDictionaries: Signal<DictionaryContent>;\n setLocaleDictionaries: (newValue: DictionaryContent) => void;\n setLocaleDictionary: (d: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent>(dictionaries);\n\n instance = {\n localeDictionaries: localeDictionariesSignal.asReadonly(),\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.key]: dictionary,\n });\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the provider into the injector\n */\nexport const installDictionariesRecord = (injector: Injector) => {\n const client = createDictionaryRecordClient();\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 createDictionaryRecordClient\n};\n\nexport const useDictionariesRecord = createSharedComposable(() => {\n const client = createDictionaryRecordClient();\n\n if (!client) {\n throw new Error('DictionariesRecord state not found');\n }\n\n const [_dictionariesRecord, setDictionariesRecord] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n undefined\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.localeDictionaries();\n setDictionariesRecord(newValue); // its undefined but shouldnt\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,gCAAyB;AACzB,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAKnC,IAAI,WAA4C;AAUzC,MAAM,+BAA+B,MAAM;AAChD,MAAI,SAAU,QAAO;AAErB,QAAM,+BAA2B,oBAA0B,0BAAAA,OAAY;AAEvE,aAAW;AAAA,IACT,oBAAoB,yBAAyB,WAAW;AAAA,IAExD,uBAAuB,CAAC,aAAa;AACnC,+BAAyB,IAAI,YAAY,CAAC,CAAC;AAAA,IAC7C;AAAA,IAEA,oBAAoB,YAAY;AAC9B,YAAM,UAAU,yBAAyB;AACzC,+BAAyB,IAAI;AAAA,QAC3B,GAAG;AAAA,QACH,CAAC,WAAW,GAAG,GAAG;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,4BAA4B,CAAC,aAAuB;AAC/D,QAAM,SAAS,6BAA6B;AAI9C;AAEO,MAAM,4BAAwB,sDAAuB,MAAM;AAChE,QAAM,SAAS,6BAA6B;AAE5C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAEA,QAAM,CAAC,qBAAqB,qBAAqB,QAC/C;AAAA,IACE,yBAAW;AAAA,IACX;AAAA,EACF;AAGF,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,mBAAmB;AAC3C,0BAAsB,QAAQ;AAAA,EAChC,CAAC;AACH,CAAC;","names":["dictionaries"]}
@@ -0,0 +1,77 @@
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 editedContent_exports = {};
20
+ __export(editedContent_exports, {
21
+ createEditedContentClient: () => createEditedContentClient,
22
+ installEditedContent: () => installEditedContent,
23
+ useEditedContent: () => useEditedContent
24
+ });
25
+ module.exports = __toCommonJS(editedContent_exports);
26
+ var import_core = require("@angular/core");
27
+ var import_core2 = require("@intlayer/core");
28
+ var import_editor = require("@intlayer/editor");
29
+ var import_createSharedComposable = require('./createSharedComposable.cjs');
30
+ var import_useCrossFrameState = require('./useCrossFrameState.cjs');
31
+ let instance = null;
32
+ const INTLAYER_EDITED_CONTENT_SYMBOL = Symbol("EditedContent");
33
+ const createEditedContentClient = () => {
34
+ if (instance) return instance;
35
+ const editedContentSignal = (0, import_core.signal)({});
36
+ instance = {
37
+ editedContent: editedContentSignal.asReadonly(),
38
+ getEditedContentValue: (dictionaryKey, keyPath) => {
39
+ const content = editedContentSignal()?.[dictionaryKey]?.content;
40
+ if (!content) return void 0;
41
+ return (0, import_core2.getContentNodeByKeyPath)(content, keyPath);
42
+ },
43
+ setEditedContent: (editedContent) => {
44
+ editedContentSignal.set(editedContent);
45
+ }
46
+ };
47
+ return instance;
48
+ };
49
+ const installEditedContent = (injector) => {
50
+ const client = createEditedContentClient();
51
+ };
52
+ const useEditedContent = (0, import_createSharedComposable.createSharedComposable)(() => {
53
+ const client = createEditedContentClient();
54
+ if (!client) {
55
+ throw new Error("EditedContent state not found");
56
+ }
57
+ const [edited, setEdited] = (0, import_useCrossFrameState.useCrossFrameState)(
58
+ import_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,
59
+ {}
60
+ );
61
+ (0, import_core.effect)(() => {
62
+ const newValue = edited();
63
+ client.setEditedContent(newValue ?? {});
64
+ });
65
+ (0, import_core.effect)(() => {
66
+ const newValue = client.editedContent();
67
+ setEdited(newValue);
68
+ });
69
+ return client;
70
+ });
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ createEditedContentClient,
74
+ installEditedContent,
75
+ useEditedContent
76
+ });
77
+ //# sourceMappingURL=editedContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { ContentNode, Dictionary, KeyPath } from '@intlayer/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type EditedContent = Record<Dictionary['key'], Dictionary>;\n\ntype EditedContentClient = {\n editedContent: Signal<EditedContent>;\n setEditedContent: (editedContent: EditedContent) => void;\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditedContentClient | null = null;\n\nconst INTLAYER_EDITED_CONTENT_SYMBOL = Symbol('EditedContent');\n\n/**\n * Creates an edited content client\n */\nexport const createEditedContentClient = () => {\n if (instance) return instance;\n\n const editedContentSignal = signal<EditedContent>({});\n\n instance = {\n editedContent: editedContentSignal.asReadonly(),\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const content = editedContentSignal()?.[dictionaryKey]?.content;\n if (!content) return undefined;\n\n return getContentNodeByKeyPath(content, keyPath);\n },\n setEditedContent: (editedContent: EditedContent) => {\n editedContentSignal.set(editedContent);\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the edited content into the injector\n */\nexport const installEditedContent = (injector: Injector) => {\n const client = createEditedContentClient();\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 createEditedContentClient\n};\n\nexport const useEditedContent = createSharedComposable(() => {\n const client = createEditedContentClient();\n\n if (!client) {\n throw new Error('EditedContent state not found');\n }\n\n const [edited, setEdited] = useCrossFrameState<EditedContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n {}\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = edited();\n client.setEditedContent(newValue ?? {});\n });\n\n effect(() => {\n const newValue = client.editedContent();\n setEdited(newValue);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,IAAAA,eAAwC;AACxC,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAgBnC,IAAI,WAAuC;AAE3C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,0BAAsB,oBAAsB,CAAC,CAAC;AAEpD,aAAW;AAAA,IACT,eAAe,oBAAoB,WAAW;AAAA,IAC9C,uBAAuB,CACrB,eACA,YAC4B;AAC5B,YAAM,UAAU,oBAAoB,IAAI,aAAa,GAAG;AACxD,UAAI,CAAC,QAAS,QAAO;AAErB,iBAAO,sCAAwB,SAAS,OAAO;AAAA,IACjD;AAAA,IACA,kBAAkB,CAAC,kBAAiC;AAClD,0BAAoB,IAAI,aAAa;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,CAAC,QAAQ,SAAS,QAAI;AAAA,IAC1B,yBAAW;AAAA,IACX,CAAC;AAAA,EACH;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO;AACxB,WAAO,iBAAiB,YAAY,CAAC,CAAC;AAAA,EACxC,CAAC;AAED,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,cAAc;AACtC,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT,CAAC;","names":["import_core"]}
@@ -0,0 +1,76 @@
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 editorEnabled_exports = {};
20
+ __export(editorEnabled_exports, {
21
+ createEditorEnabledClient: () => createEditorEnabledClient,
22
+ installEditorEnabled: () => installEditorEnabled,
23
+ useEditorEnabled: () => useEditorEnabled
24
+ });
25
+ module.exports = __toCommonJS(editorEnabled_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_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
30
+ let instance = null;
31
+ const INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol("EditorEnabled");
32
+ const createEditorEnabledClient = () => {
33
+ if (instance) return instance;
34
+ const wrapperEnabledSignal = (0, import_core.signal)(false);
35
+ const isInIframeSignal = (0, import_core.signal)(false);
36
+ const enabledSignal = (0, import_core.computed)(
37
+ () => wrapperEnabledSignal() && isInIframeSignal()
38
+ );
39
+ instance = {
40
+ wrapperEnabled: wrapperEnabledSignal.asReadonly(),
41
+ isInIframe: isInIframeSignal.asReadonly(),
42
+ enabled: enabledSignal
43
+ };
44
+ return instance;
45
+ };
46
+ const installEditorEnabled = (injector) => {
47
+ const client = createEditorEnabledClient();
48
+ };
49
+ const useEditorEnabled = (0, import_createSharedComposable.createSharedComposable)(() => {
50
+ const client = createEditorEnabledClient();
51
+ if (!client) {
52
+ throw new Error("EditorEnabled state not found");
53
+ }
54
+ (0, import_useCrossFrameMessageListener.useCrossFrameMessageListener)(
55
+ `${import_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`,
56
+ (data) => {
57
+ client.wrapperEnabled.set(data);
58
+ }
59
+ );
60
+ (0, import_core.effect)(
61
+ () => {
62
+ if (typeof window !== "undefined") {
63
+ client.isInIframe.set(window.self !== window.top);
64
+ }
65
+ },
66
+ { allowSignalWrites: true }
67
+ );
68
+ return client;
69
+ });
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ createEditorEnabledClient,
73
+ installEditorEnabled,
74
+ useEditorEnabled
75
+ });
76
+ //# sourceMappingURL=editorEnabled.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import { computed, effect, Injector, signal, Signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ------------------------------------------------------------------ */\n/* public type – identical to the React version */\n/* ------------------------------------------------------------------ */\nexport type EditorEnabledStateProps = {\n wrapperEnabled: Signal<boolean>;\n isInIframe: Signal<boolean>;\n enabled: Signal<boolean>;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditorEnabledStateProps | null = null;\n\nconst INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol('EditorEnabled');\n\n/**\n * Creates an editor wrapperEnabled client\n */\nexport const createEditorEnabledClient = () => {\n if (instance) return instance;\n\n const wrapperEnabledSignal = signal(false);\n const isInIframeSignal = signal(false);\n const enabledSignal = computed(\n () => wrapperEnabledSignal() && isInIframeSignal()\n );\n\n instance = {\n wrapperEnabled: wrapperEnabledSignal.asReadonly(),\n isInIframe: isInIframeSignal.asReadonly(),\n enabled: enabledSignal,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the editor wrapperEnabled state into the injector\n */\nexport const installEditorEnabled = (injector: Injector) => {\n const client = createEditorEnabledClient();\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 createEditorEnabledClient\n};\n\nexport const useEditorEnabled = createSharedComposable(() => {\n const client = createEditorEnabledClient();\n\n if (!client) {\n throw new Error('EditorEnabled state not found');\n }\n\n // Listen for the iframe parent if the editor send a message `INTLAYER_EDITOR_ENABLED`\n useCrossFrameMessageListener<boolean>(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,\n (data) => {\n (client.wrapperEnabled as any).set(data);\n }\n );\n\n // Use effect to set up the iframe check immediately\n effect(\n () => {\n if (typeof window !== 'undefined') {\n (client.isInIframe as any).set(window.self !== window.top);\n }\n },\n { allowSignalWrites: true }\n );\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2D;AAC3D,oBAA2B;AAC3B,oCAAuC;AACvC,0CAA6C;AAc7C,IAAI,WAA2C;AAE/C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,2BAAuB,oBAAO,KAAK;AACzC,QAAM,uBAAmB,oBAAO,KAAK;AACrC,QAAM,oBAAgB;AAAA,IACpB,MAAM,qBAAqB,KAAK,iBAAiB;AAAA,EACnD;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD,YAAY,iBAAiB,WAAW;AAAA,IACxC,SAAS;AAAA,EACX;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAGA;AAAA,IACE,GAAG,yBAAW,uBAAuB;AAAA,IACrC,CAAC,SAAS;AACR,MAAC,OAAO,eAAuB,IAAI,IAAI;AAAA,IACzC;AAAA,EACF;AAGA;AAAA,IACE,MAAM;AACJ,UAAI,OAAO,WAAW,aAAa;AACjC,QAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,GAAG;AAAA,MAC3D;AAAA,IACF;AAAA,IACA,EAAE,mBAAmB,KAAK;AAAA,EAC5B;AAEA,SAAO;AACT,CAAC;","names":[]}
@@ -0,0 +1,47 @@
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 editorLocale_exports = {};
20
+ __export(editorLocale_exports, {
21
+ useEditorLocale: () => useEditorLocale
22
+ });
23
+ module.exports = __toCommonJS(editorLocale_exports);
24
+ var import_core = require("@angular/core");
25
+ var import_editor = require("@intlayer/editor");
26
+ var import_client = require('../client/index.cjs');
27
+ var import_createSharedComposable = require('./createSharedComposable.cjs');
28
+ var import_useCrossFrameState = require('./useCrossFrameState.cjs');
29
+ const useEditorLocale = (0, import_createSharedComposable.createSharedComposable)(() => {
30
+ const client = (0, import_core.inject)(import_client.INTLAYER_TOKEN);
31
+ if (!client) {
32
+ throw new Error("IntlayerEditor state not found");
33
+ }
34
+ const [_data, setData] = (0, import_useCrossFrameState.useCrossFrameState)(
35
+ import_editor.MessageKey.INTLAYER_CURRENT_LOCALE
36
+ );
37
+ (0, import_core.effect)(() => {
38
+ const newValue = client.locale();
39
+ setData(newValue);
40
+ });
41
+ return client;
42
+ });
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ useEditorLocale
46
+ });
47
+ //# sourceMappingURL=editorLocale.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport type { Locales } from '@intlayer/config/client';\nimport { MessageKey } from '@intlayer/editor';\nimport { INTLAYER_TOKEN, IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<Locales>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAE/B,oBAA2B;AAC3B,oBAAiD;AACjD,oCAAuC;AACvC,gCAAmC;AAE5B,MAAM,sBAAkB,sDAAuB,MAAM;AAC1D,QAAM,aAAS,oBAAyB,4BAAc;AAEtD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,QAAM,CAAC,OAAO,OAAO,QAAI;AAAA,IACvB,yBAAW;AAAA,EACb;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,OAAO;AAC/B,YAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
@@ -0,0 +1,80 @@
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');
30
+ let instance = null;
31
+ 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;
48
+ };
49
+ const installFocusDictionary = (injector) => {
50
+ const client = createFocusDictionaryClient();
51
+ };
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
79
+ });
80
+ //# sourceMappingURL=focusDictionary.cjs.map
@@ -0,0 +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":[]}
@@ -0,0 +1,38 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nexport { EditedContentRendererComponent } from './EditedContentRenderer.component';\nexport { EditorSelectorRendererComponent } from './EditorSelectorRenderer.component';\nexport * from './installIntlayerEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAgD;AAChD,mCAA+C;AAC/C,oCAAgD;AAChD,2BAAc,oCAHd;","names":[]}
@@ -0,0 +1,72 @@
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_changedContent = require('./changedContent.cjs');
36
+ var import_communicator = require('./communicator.cjs');
37
+ var import_dictionariesRecord = require('./dictionariesRecord.cjs');
38
+ var import_editedContent = require('./editedContent.cjs');
39
+ var import_editorEnabled = require('./editorEnabled.cjs');
40
+ var import_focusDictionary = require('./focusDictionary.cjs');
41
+ const { editor } = import_built.default;
42
+ const { applicationURL, editorURL, cmsURL } = editor ?? {};
43
+ const postMessage = (data) => {
44
+ if (typeof window === "undefined") return;
45
+ const isInIframe = window.self !== window.top;
46
+ if (!isInIframe) return;
47
+ if (editor.applicationURL.length > 0) {
48
+ window.postMessage(data, editor.applicationURL);
49
+ }
50
+ if (editor.editorURL.length > 0) {
51
+ window.parent.postMessage(data, editor.editorURL);
52
+ }
53
+ if (editor.cmsURL.length > 0) {
54
+ window.parent.postMessage(data, editor.cmsURL);
55
+ }
56
+ };
57
+ const installIntlayerEditor = (injector) => {
58
+ (0, import_communicator.installCommunicator)(injector, {
59
+ postMessage,
60
+ allowedOrigins: [applicationURL, editorURL, cmsURL]
61
+ });
62
+ (0, import_editorEnabled.installEditorEnabled)(injector);
63
+ (0, import_changedContent.installChangedContent)(injector);
64
+ (0, import_dictionariesRecord.installDictionariesRecord)(injector);
65
+ (0, import_editedContent.installEditedContent)(injector);
66
+ (0, import_focusDictionary.installFocusDictionary)(injector);
67
+ };
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ installIntlayerEditor
71
+ });
72
+ //# sourceMappingURL=installIntlayerEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installChangedContent } from './changedContent';\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 installChangedContent(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0B;AAC1B,4BAAsC;AACtC,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,mDAAsB,QAAQ;AAC9B,2DAA0B,QAAQ;AAClC,iDAAqB,QAAQ;AAC7B,qDAAuB,QAAQ;AACjC;","names":["configuration"]}
@@ -0,0 +1,83 @@
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');
28
+ const subscribers = /* @__PURE__ */ new Map();
29
+ let windowListenerAttached = false;
30
+ 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);
37
+ }
38
+ 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);
43
+ }
44
+ 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;
55
+ }
56
+ 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;
78
+ };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ useCrossFrameMessageListener
82
+ });
83
+ //# sourceMappingURL=useCrossFrameMessageListener.cjs.map
@@ -0,0 +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":[]}