@intlayer/next-i18next 8.12.5-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +330 -0
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/cjs/appWithTranslation.cjs +31 -0
  4. package/dist/cjs/appWithTranslation.cjs.map +1 -0
  5. package/dist/cjs/index.cjs +69 -0
  6. package/dist/cjs/index.cjs.map +1 -0
  7. package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +39 -0
  8. package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +1 -0
  9. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs +161 -0
  10. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs.map +1 -0
  11. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs +269 -0
  12. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map +1 -0
  13. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs +161 -0
  14. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs.map +1 -0
  15. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs +88 -0
  16. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map +1 -0
  17. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs +27 -0
  18. package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map +1 -0
  19. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs +80 -0
  20. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs.map +1 -0
  21. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs +75 -0
  22. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs.map +1 -0
  23. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs +383 -0
  24. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs.map +1 -0
  25. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs +45 -0
  26. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs.map +1 -0
  27. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs +59 -0
  28. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs.map +1 -0
  29. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs +36 -0
  30. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs.map +1 -0
  31. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs +42 -0
  32. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs.map +1 -0
  33. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs +82 -0
  34. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs.map +1 -0
  35. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs +55 -0
  36. package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs.map +1 -0
  37. package/dist/cjs/packages/@intlayer/editor/dist/esm/index.cjs +19 -0
  38. package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs +9 -0
  39. package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs.map +1 -0
  40. package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs +22 -0
  41. package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs.map +1 -0
  42. package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs +32 -0
  43. package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs.map +1 -0
  44. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs +25 -0
  45. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs.map +1 -0
  46. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs +78 -0
  47. package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs.map +1 -0
  48. package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs +24 -0
  49. package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs.map +1 -0
  50. package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs +11 -0
  51. package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs.map +1 -0
  52. package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs +39 -0
  53. package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs.map +1 -0
  54. package/dist/cjs/plugin/index.cjs +170 -0
  55. package/dist/cjs/plugin/index.cjs.map +1 -0
  56. package/dist/cjs/serverSideTranslations.cjs +46 -0
  57. package/dist/cjs/serverSideTranslations.cjs.map +1 -0
  58. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  59. package/dist/esm/appWithTranslation.mjs +29 -0
  60. package/dist/esm/appWithTranslation.mjs.map +1 -0
  61. package/dist/esm/index.mjs +11 -0
  62. package/dist/esm/index.mjs.map +1 -0
  63. package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +38 -0
  64. package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +1 -0
  65. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs +160 -0
  66. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs.map +1 -0
  67. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs +266 -0
  68. package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -0
  69. package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs +159 -0
  70. package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs.map +1 -0
  71. package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs +88 -0
  72. package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs.map +1 -0
  73. package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs +26 -0
  74. package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs.map +1 -0
  75. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs +80 -0
  76. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs.map +1 -0
  77. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs +74 -0
  78. package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs.map +1 -0
  79. package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs +381 -0
  80. package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs.map +1 -0
  81. package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs +45 -0
  82. package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs.map +1 -0
  83. package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs +58 -0
  84. package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs.map +1 -0
  85. package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs +33 -0
  86. package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs.map +1 -0
  87. package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs +39 -0
  88. package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs.map +1 -0
  89. package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs +79 -0
  90. package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs.map +1 -0
  91. package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs +52 -0
  92. package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs.map +1 -0
  93. package/dist/esm/packages/@intlayer/editor/dist/esm/index.mjs +18 -0
  94. package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs +8 -0
  95. package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs.map +1 -0
  96. package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs +21 -0
  97. package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs.map +1 -0
  98. package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs +6 -0
  99. package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map +1 -0
  100. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs +23 -0
  101. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs.map +1 -0
  102. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs +77 -0
  103. package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs.map +1 -0
  104. package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs +22 -0
  105. package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  106. package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs +11 -0
  107. package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs.map +1 -0
  108. package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs +38 -0
  109. package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs.map +1 -0
  110. package/dist/esm/plugin/index.mjs +165 -0
  111. package/dist/esm/plugin/index.mjs.map +1 -0
  112. package/dist/esm/serverSideTranslations.mjs +44 -0
  113. package/dist/esm/serverSideTranslations.mjs.map +1 -0
  114. package/dist/types/appWithTranslation.d.ts +18 -0
  115. package/dist/types/appWithTranslation.d.ts.map +1 -0
  116. package/dist/types/index.d.ts +10 -0
  117. package/dist/types/index.d.ts.map +1 -0
  118. package/dist/types/plugin/index.d.ts +23 -0
  119. package/dist/types/plugin/index.d.ts.map +1 -0
  120. package/dist/types/serverSideTranslations.d.ts +33 -0
  121. package/dist/types/serverSideTranslations.d.ts.map +1 -0
  122. package/package.json +116 -0
@@ -0,0 +1,383 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_CrossFrameMessenger = require('./CrossFrameMessenger.cjs');
3
+ const require_CrossFrameStateManager = require('./CrossFrameStateManager.cjs');
4
+ const require_editedContentBus = require('./editedContentBus.cjs');
5
+ const require_focusedContentBus = require('./focusedContentBus.cjs');
6
+ const require_IframeClickInterceptor = require('./IframeClickInterceptor.cjs');
7
+ const require_UrlStateManager = require('./UrlStateManager.cjs');
8
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
9
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
10
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
11
+
12
+ //#region ../../packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs
13
+ /**
14
+ * EditorStateManager is the single entry point for all Intlayer editor state.
15
+ * It is framework-agnostic: instantiate one instance at the root of the application
16
+ * and subscribe to its EventTarget-based events from any framework adapter.
17
+ *
18
+ * Replaces all context providers, hooks and store files across React, Preact,
19
+ * Solid, Svelte, and Vue integrations.
20
+ */
21
+ var EditorStateManager = class {
22
+ messenger;
23
+ editorEnabled;
24
+ focusedContent;
25
+ localeDictionaries;
26
+ editedContent;
27
+ configuration;
28
+ currentLocale;
29
+ displayedDictionaryKeys;
30
+ _urlManager;
31
+ _iframeInterceptor;
32
+ _mode;
33
+ _configuration;
34
+ _unsubAreYouThere = null;
35
+ _unsubActivate = null;
36
+ _unsubClientReady = null;
37
+ _displayedKeysObserver = null;
38
+ _displayedKeysTimer = null;
39
+ _displayedKeysListeners = [];
40
+ _editedContentFromBus = false;
41
+ _unsubGlobalEditedContent = null;
42
+ _editedContentBusHandler = null;
43
+ _focusedContentFromBus = false;
44
+ _unsubGlobalFocusedContent = null;
45
+ _focusedContentBusHandler = null;
46
+ constructor(config) {
47
+ this._mode = config.mode;
48
+ this._configuration = config.configuration;
49
+ this.messenger = new require_CrossFrameMessenger.CrossFrameMessenger(config.messenger);
50
+ this.editorEnabled = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_EDITOR_ENABLED", this.messenger, {
51
+ emit: false,
52
+ receive: true,
53
+ initialValue: false
54
+ });
55
+ this.focusedContent = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_FOCUSED_CONTENT_CHANGED", this.messenger, {
56
+ emit: true,
57
+ receive: true,
58
+ initialValue: null
59
+ });
60
+ this.localeDictionaries = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_LOCALE_DICTIONARIES_CHANGED", this.messenger);
61
+ this.editedContent = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_EDITED_CONTENT_CHANGED", this.messenger);
62
+ this.configuration = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_CONFIGURATION", this.messenger, {
63
+ emit: true,
64
+ receive: false,
65
+ ...config.configuration ? { initialValue: config.configuration } : {}
66
+ });
67
+ this.currentLocale = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_CURRENT_LOCALE", this.messenger, {
68
+ emit: config.mode === "client",
69
+ receive: config.mode === "editor"
70
+ });
71
+ this.displayedDictionaryKeys = new require_CrossFrameStateManager.CrossFrameStateManager("INTLAYER_DISPLAYED_DICTIONARY_KEYS", this.messenger, {
72
+ emit: config.mode === "client",
73
+ receive: config.mode === "editor",
74
+ initialValue: []
75
+ });
76
+ this._urlManager = new require_UrlStateManager.UrlStateManager(this.messenger);
77
+ this._iframeInterceptor = new require_IframeClickInterceptor.IframeClickInterceptor(this.messenger);
78
+ }
79
+ start() {
80
+ this.messenger.start();
81
+ this.editorEnabled.start();
82
+ this.focusedContent.start();
83
+ this.localeDictionaries.start();
84
+ this.editedContent.start();
85
+ this.configuration.start();
86
+ this.currentLocale.start();
87
+ this.displayedDictionaryKeys.start();
88
+ this._startEditedContentBusSync();
89
+ this._startFocusedContentBusSync();
90
+ if (this._mode === "client") {
91
+ this._urlManager.start();
92
+ this._iframeInterceptor.startInterceptor();
93
+ this._loadDictionaries();
94
+ this._startDisplayedDictionariesTracking();
95
+ this.messenger.send(`INTLAYER_EDITED_CONTENT_CHANGED/get`);
96
+ if (this._configuration?.editor?.enabled !== false) this._setupActivationHandshake();
97
+ } else {
98
+ this._iframeInterceptor.startMerger();
99
+ this._setupEditorHandshake();
100
+ }
101
+ }
102
+ stop() {
103
+ this._unsubAreYouThere?.();
104
+ this._unsubActivate?.();
105
+ this._unsubClientReady?.();
106
+ this._unsubAreYouThere = null;
107
+ this._unsubActivate = null;
108
+ this._unsubClientReady = null;
109
+ this.messenger.stop();
110
+ this.editorEnabled.stop();
111
+ this.focusedContent.stop();
112
+ this.localeDictionaries.stop();
113
+ this.editedContent.stop();
114
+ this.configuration.stop();
115
+ this.currentLocale.stop();
116
+ this.displayedDictionaryKeys.stop();
117
+ this._stopDisplayedDictionariesTracking();
118
+ this._stopEditedContentBusSync();
119
+ this._stopFocusedContentBusSync();
120
+ this._urlManager.stop();
121
+ this._iframeInterceptor.stopInterceptor();
122
+ this._iframeInterceptor.stopMerger();
123
+ }
124
+ /**
125
+ * EDITOR mode: re-send ARE_YOU_THERE to attempt re-connection with the client.
126
+ * Call this when the user clicks "Enable Editor" or when the iframe reloads.
127
+ */
128
+ pingClient() {
129
+ if (this._mode !== "editor") return;
130
+ this.messenger.send("INTLAYER_ARE_YOU_THERE");
131
+ }
132
+ setFocusedContentKeyPath(keyPath) {
133
+ const filtered = keyPath.filter((key) => key.type !== _intlayer_types_nodeType.TRANSLATION);
134
+ const prev = this.focusedContent.value;
135
+ if (!prev) return;
136
+ this.focusedContent.set({
137
+ ...prev,
138
+ keyPath: filtered
139
+ });
140
+ }
141
+ setLocaleDictionary(dictionary) {
142
+ if (!dictionary.localId) return;
143
+ const current = this.localeDictionaries.value ?? {};
144
+ this.localeDictionaries.set({
145
+ ...current,
146
+ [dictionary.localId]: dictionary
147
+ });
148
+ }
149
+ setEditedDictionary(newDict) {
150
+ if (!newDict.localId) {
151
+ console.error("setEditedDictionary: missing localId", newDict);
152
+ return;
153
+ }
154
+ const current = this.editedContent.value ?? {};
155
+ this.editedContent.set({
156
+ ...current,
157
+ [newDict.localId]: newDict
158
+ });
159
+ }
160
+ setEditedContent(localDictionaryId, newValue) {
161
+ const current = this.editedContent.value ?? {};
162
+ this.editedContent.set({
163
+ ...current,
164
+ [localDictionaryId]: {
165
+ ...current[localDictionaryId],
166
+ content: newValue
167
+ }
168
+ });
169
+ }
170
+ addContent(localDictionaryId, newValue, keyPath = [], overwrite = true) {
171
+ const current = this.editedContent.value ?? {};
172
+ const originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;
173
+ const currentContent = structuredClone(current[localDictionaryId]?.content ?? originalContent);
174
+ let newKeyPath = keyPath;
175
+ if (!overwrite) {
176
+ let index = 0;
177
+ const otherKeyPath = keyPath.slice(0, -1);
178
+ const lastKeyPath = keyPath[keyPath.length - 1];
179
+ let finalKey = lastKeyPath.key;
180
+ while (typeof (0, _intlayer_core_dictionaryManipulator.getContentNodeByKeyPath)(currentContent, newKeyPath) !== "undefined") {
181
+ index++;
182
+ finalKey = index === 0 ? lastKeyPath.key : `${lastKeyPath.key} (${index})`;
183
+ newKeyPath = [...otherKeyPath, {
184
+ ...lastKeyPath,
185
+ key: finalKey
186
+ }];
187
+ }
188
+ }
189
+ const updatedContent = (0, _intlayer_core_dictionaryManipulator.editDictionaryByKeyPath)(currentContent, newKeyPath, newValue);
190
+ this.editedContent.set({
191
+ ...current,
192
+ [localDictionaryId]: {
193
+ ...current[localDictionaryId],
194
+ content: updatedContent
195
+ }
196
+ });
197
+ }
198
+ renameContent(localDictionaryId, newKey, keyPath = []) {
199
+ const current = this.editedContent.value ?? {};
200
+ const originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;
201
+ const updated = (0, _intlayer_core_dictionaryManipulator.renameContentNodeByKeyPath)(structuredClone(current[localDictionaryId]?.content ?? originalContent), newKey, keyPath);
202
+ this.editedContent.set({
203
+ ...current,
204
+ [localDictionaryId]: {
205
+ ...current[localDictionaryId],
206
+ content: updated
207
+ }
208
+ });
209
+ }
210
+ removeContent(localDictionaryId, keyPath) {
211
+ const current = this.editedContent.value ?? {};
212
+ const originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;
213
+ const restored = (0, _intlayer_core_dictionaryManipulator.editDictionaryByKeyPath)(structuredClone(current[localDictionaryId]?.content ?? originalContent), keyPath, (0, _intlayer_core_dictionaryManipulator.getContentNodeByKeyPath)(originalContent, keyPath));
214
+ this.editedContent.set({
215
+ ...current,
216
+ [localDictionaryId]: {
217
+ ...current[localDictionaryId],
218
+ content: restored
219
+ }
220
+ });
221
+ }
222
+ restoreContent(localDictionaryId) {
223
+ const updated = { ...this.editedContent.value ?? {} };
224
+ delete updated[localDictionaryId];
225
+ this.editedContent.set(updated);
226
+ }
227
+ clearContent(localDictionaryId) {
228
+ const filtered = { ...this.editedContent.value ?? {} };
229
+ delete filtered[localDictionaryId];
230
+ this.editedContent.set(filtered);
231
+ }
232
+ clearAllContent() {
233
+ this.editedContent.set({});
234
+ }
235
+ getContentValue(localDictionaryIdOrKey, keyPath) {
236
+ const edited = this.editedContent.value;
237
+ if (!edited) return void 0;
238
+ const filteredKeyPath = keyPath.filter((key) => key.type !== _intlayer_types_nodeType.TRANSLATION);
239
+ const localeDicts = this.localeDictionaries.value;
240
+ if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) {
241
+ if (localeDicts && !(localDictionaryIdOrKey in localeDicts)) return;
242
+ return (0, _intlayer_core_dictionaryManipulator.getContentNodeByKeyPath)(edited[localDictionaryIdOrKey]?.content ?? {}, filteredKeyPath, this.currentLocale.value);
243
+ }
244
+ const matchingIds = Object.keys(edited).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`) && (!localeDicts || key in localeDicts));
245
+ for (const localId of matchingIds) {
246
+ const node = (0, _intlayer_core_dictionaryManipulator.getContentNodeByKeyPath)(edited[localId]?.content ?? {}, filteredKeyPath, this.currentLocale.value);
247
+ if (node) return node;
248
+ }
249
+ }
250
+ _startEditedContentBusSync() {
251
+ this._editedContentBusHandler = (e) => {
252
+ if (this._editedContentFromBus) return;
253
+ const content = e.detail;
254
+ require_editedContentBus.setGlobalEditedContent(content, this.messenger.senderId);
255
+ };
256
+ this.editedContent.addEventListener("change", this._editedContentBusHandler);
257
+ this._unsubGlobalEditedContent = require_editedContentBus.subscribeToGlobalEditedContent((content, sourceId) => {
258
+ if (sourceId === this.messenger.senderId) return;
259
+ this._editedContentFromBus = true;
260
+ this.editedContent.set(content);
261
+ this._editedContentFromBus = false;
262
+ });
263
+ const existing = require_editedContentBus.getGlobalEditedContent();
264
+ if (Object.keys(existing).length > 0) {
265
+ this._editedContentFromBus = true;
266
+ this.editedContent.set(existing);
267
+ this._editedContentFromBus = false;
268
+ }
269
+ }
270
+ _stopEditedContentBusSync() {
271
+ if (this._editedContentBusHandler) {
272
+ this.editedContent.removeEventListener("change", this._editedContentBusHandler);
273
+ this._editedContentBusHandler = null;
274
+ }
275
+ this._unsubGlobalEditedContent?.();
276
+ this._unsubGlobalEditedContent = null;
277
+ }
278
+ _startFocusedContentBusSync() {
279
+ this._focusedContentBusHandler = (e) => {
280
+ if (this._focusedContentFromBus) return;
281
+ const content = e.detail;
282
+ require_focusedContentBus.setGlobalFocusedContent(content, this.messenger.senderId);
283
+ };
284
+ this.focusedContent.addEventListener("change", this._focusedContentBusHandler);
285
+ this._unsubGlobalFocusedContent = require_focusedContentBus.subscribeToGlobalFocusedContent((content, sourceId) => {
286
+ if (sourceId === this.messenger.senderId) return;
287
+ this._focusedContentFromBus = true;
288
+ this.focusedContent.set(content);
289
+ this._focusedContentFromBus = false;
290
+ });
291
+ const existing = require_focusedContentBus.getGlobalFocusedContent();
292
+ if (existing !== void 0) {
293
+ this._focusedContentFromBus = true;
294
+ this.focusedContent.set(existing);
295
+ this._focusedContentFromBus = false;
296
+ }
297
+ }
298
+ _stopFocusedContentBusSync() {
299
+ if (this._focusedContentBusHandler) {
300
+ this.focusedContent.removeEventListener("change", this._focusedContentBusHandler);
301
+ this._focusedContentBusHandler = null;
302
+ }
303
+ this._unsubGlobalFocusedContent?.();
304
+ this._unsubGlobalFocusedContent = null;
305
+ }
306
+ _scanDisplayedDictionaryKeys() {
307
+ if (typeof document === "undefined") return;
308
+ const elements = document.querySelectorAll("intlayer-content-selector-wrapper[dictionary-key]");
309
+ const keys = Array.from(new Set(Array.from(elements).map((el) => el.getAttribute("dictionary-key") ?? "").filter(Boolean)));
310
+ this.displayedDictionaryKeys.set(keys);
311
+ }
312
+ _startDisplayedDictionariesTracking() {
313
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
314
+ const schedule = () => {
315
+ if (this._displayedKeysTimer) clearTimeout(this._displayedKeysTimer);
316
+ this._displayedKeysTimer = setTimeout(() => this._scanDisplayedDictionaryKeys(), 100);
317
+ };
318
+ this._displayedKeysObserver = new MutationObserver(schedule);
319
+ this._displayedKeysObserver.observe(document.body, {
320
+ childList: true,
321
+ subtree: true
322
+ });
323
+ for (const evt of ["locationchange", "popstate"]) {
324
+ const listener = schedule;
325
+ window.addEventListener(evt, listener);
326
+ this._displayedKeysListeners.push([evt, listener]);
327
+ }
328
+ this._scanDisplayedDictionaryKeys();
329
+ }
330
+ _stopDisplayedDictionariesTracking() {
331
+ this._displayedKeysObserver?.disconnect();
332
+ this._displayedKeysObserver = null;
333
+ if (this._displayedKeysTimer) {
334
+ clearTimeout(this._displayedKeysTimer);
335
+ this._displayedKeysTimer = null;
336
+ }
337
+ for (const [evt, listener] of this._displayedKeysListeners) window.removeEventListener(evt, listener);
338
+ this._displayedKeysListeners = [];
339
+ }
340
+ /**
341
+ * EDITOR mode: listen for CLIENT_READY and respond with EDITOR_ACTIVATE.
342
+ * Also pings the client immediately in case it loaded before the editor.
343
+ */
344
+ _setupEditorHandshake() {
345
+ this._unsubClientReady = this.messenger.subscribe("INTLAYER_CLIENT_READY", () => {
346
+ this.editorEnabled.set(true);
347
+ this.messenger.send("INTLAYER_EDITOR_ACTIVATE");
348
+ });
349
+ this.messenger.send("INTLAYER_ARE_YOU_THERE");
350
+ }
351
+ _setupActivationHandshake() {
352
+ this.messenger.send("INTLAYER_CLIENT_READY");
353
+ this._unsubAreYouThere = this.messenger.subscribe("INTLAYER_ARE_YOU_THERE", () => {
354
+ this.messenger.send("INTLAYER_CLIENT_READY");
355
+ });
356
+ this._unsubActivate = this.messenger.subscribe("INTLAYER_EDITOR_ACTIVATE", () => {
357
+ this.editorEnabled.set(true);
358
+ this._broadcastData();
359
+ });
360
+ }
361
+ _broadcastData() {
362
+ const configVal = this.configuration.value;
363
+ if (configVal) this.messenger.send(`INTLAYER_CONFIGURATION/post`, configVal);
364
+ const localeVal = this.currentLocale.value;
365
+ if (localeVal) this.messenger.send(`INTLAYER_CURRENT_LOCALE/post`, localeVal);
366
+ const dicts = this.localeDictionaries.value;
367
+ if (dicts) this.messenger.send(`INTLAYER_LOCALE_DICTIONARIES_CHANGED/post`, dicts);
368
+ }
369
+ async _loadDictionaries() {
370
+ try {
371
+ const unmergedDictionaries = (await Promise.resolve().then(() => require("../../../../unmerged-dictionaries-entry/dist/esm/index.cjs"))).getUnmergedDictionaries();
372
+ const dictionariesList = Object.fromEntries(Object.values(unmergedDictionaries).flat().map((dictionary) => [dictionary.localId, dictionary]));
373
+ this.localeDictionaries.set(dictionariesList);
374
+ if (this.editorEnabled.value) this._broadcastData();
375
+ } catch (e) {
376
+ console.warn("[intlayer] Failed to load unmerged dictionaries:", e);
377
+ }
378
+ }
379
+ };
380
+
381
+ //#endregion
382
+ exports.EditorStateManager = EditorStateManager;
383
+ //# sourceMappingURL=EditorStateManager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorStateManager.cjs","names":["CrossFrameMessenger","CrossFrameStateManager","UrlStateManager","IframeClickInterceptor","NodeTypes","subscribeToGlobalEditedContent","getGlobalEditedContent","subscribeToGlobalFocusedContent","getGlobalFocusedContent"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\nimport { CrossFrameMessenger } from \"./CrossFrameMessenger.mjs\";\nimport { CrossFrameStateManager } from \"./CrossFrameStateManager.mjs\";\nimport { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent } from \"./editedContentBus.mjs\";\nimport { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent } from \"./focusedContentBus.mjs\";\nimport { IframeClickInterceptor } from \"./IframeClickInterceptor.mjs\";\nimport { UrlStateManager } from \"./UrlStateManager.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\nimport { editDictionaryByKeyPath, getContentNodeByKeyPath, renameContentNodeByKeyPath } from \"@intlayer/core/dictionaryManipulator\";\n\n//#region src/core/EditorStateManager.ts\n/**\n* EditorStateManager is the single entry point for all Intlayer editor state.\n* It is framework-agnostic: instantiate one instance at the root of the application\n* and subscribe to its EventTarget-based events from any framework adapter.\n*\n* Replaces all context providers, hooks and store files across React, Preact,\n* Solid, Svelte, and Vue integrations.\n*/\nvar EditorStateManager = class {\n\tmessenger;\n\teditorEnabled;\n\tfocusedContent;\n\tlocaleDictionaries;\n\teditedContent;\n\tconfiguration;\n\tcurrentLocale;\n\tdisplayedDictionaryKeys;\n\t_urlManager;\n\t_iframeInterceptor;\n\t_mode;\n\t_configuration;\n\t_unsubAreYouThere = null;\n\t_unsubActivate = null;\n\t_unsubClientReady = null;\n\t_displayedKeysObserver = null;\n\t_displayedKeysTimer = null;\n\t_displayedKeysListeners = [];\n\t_editedContentFromBus = false;\n\t_unsubGlobalEditedContent = null;\n\t_editedContentBusHandler = null;\n\t_focusedContentFromBus = false;\n\t_unsubGlobalFocusedContent = null;\n\t_focusedContentBusHandler = null;\n\tconstructor(config) {\n\t\tthis._mode = config.mode;\n\t\tthis._configuration = config.configuration;\n\t\tthis.messenger = new CrossFrameMessenger(config.messenger);\n\t\tthis.editorEnabled = new CrossFrameStateManager(\"INTLAYER_EDITOR_ENABLED\", this.messenger, {\n\t\t\temit: false,\n\t\t\treceive: true,\n\t\t\tinitialValue: false\n\t\t});\n\t\tthis.focusedContent = new CrossFrameStateManager(\"INTLAYER_FOCUSED_CONTENT_CHANGED\", this.messenger, {\n\t\t\temit: true,\n\t\t\treceive: true,\n\t\t\tinitialValue: null\n\t\t});\n\t\tthis.localeDictionaries = new CrossFrameStateManager(\"INTLAYER_LOCALE_DICTIONARIES_CHANGED\", this.messenger);\n\t\tthis.editedContent = new CrossFrameStateManager(\"INTLAYER_EDITED_CONTENT_CHANGED\", this.messenger);\n\t\tthis.configuration = new CrossFrameStateManager(\"INTLAYER_CONFIGURATION\", this.messenger, {\n\t\t\temit: true,\n\t\t\treceive: false,\n\t\t\t...config.configuration ? { initialValue: config.configuration } : {}\n\t\t});\n\t\tthis.currentLocale = new CrossFrameStateManager(\"INTLAYER_CURRENT_LOCALE\", this.messenger, {\n\t\t\temit: config.mode === \"client\",\n\t\t\treceive: config.mode === \"editor\"\n\t\t});\n\t\tthis.displayedDictionaryKeys = new CrossFrameStateManager(\"INTLAYER_DISPLAYED_DICTIONARY_KEYS\", this.messenger, {\n\t\t\temit: config.mode === \"client\",\n\t\t\treceive: config.mode === \"editor\",\n\t\t\tinitialValue: []\n\t\t});\n\t\tthis._urlManager = new UrlStateManager(this.messenger);\n\t\tthis._iframeInterceptor = new IframeClickInterceptor(this.messenger);\n\t}\n\tstart() {\n\t\tthis.messenger.start();\n\t\tthis.editorEnabled.start();\n\t\tthis.focusedContent.start();\n\t\tthis.localeDictionaries.start();\n\t\tthis.editedContent.start();\n\t\tthis.configuration.start();\n\t\tthis.currentLocale.start();\n\t\tthis.displayedDictionaryKeys.start();\n\t\tthis._startEditedContentBusSync();\n\t\tthis._startFocusedContentBusSync();\n\t\tif (this._mode === \"client\") {\n\t\t\tthis._urlManager.start();\n\t\t\tthis._iframeInterceptor.startInterceptor();\n\t\t\tthis._loadDictionaries();\n\t\t\tthis._startDisplayedDictionariesTracking();\n\t\t\tthis.messenger.send(`${\"INTLAYER_EDITED_CONTENT_CHANGED\"}/get`);\n\t\t\tif (this._configuration?.editor?.enabled !== false) this._setupActivationHandshake();\n\t\t} else {\n\t\t\tthis._iframeInterceptor.startMerger();\n\t\t\tthis._setupEditorHandshake();\n\t\t}\n\t}\n\tstop() {\n\t\tthis._unsubAreYouThere?.();\n\t\tthis._unsubActivate?.();\n\t\tthis._unsubClientReady?.();\n\t\tthis._unsubAreYouThere = null;\n\t\tthis._unsubActivate = null;\n\t\tthis._unsubClientReady = null;\n\t\tthis.messenger.stop();\n\t\tthis.editorEnabled.stop();\n\t\tthis.focusedContent.stop();\n\t\tthis.localeDictionaries.stop();\n\t\tthis.editedContent.stop();\n\t\tthis.configuration.stop();\n\t\tthis.currentLocale.stop();\n\t\tthis.displayedDictionaryKeys.stop();\n\t\tthis._stopDisplayedDictionariesTracking();\n\t\tthis._stopEditedContentBusSync();\n\t\tthis._stopFocusedContentBusSync();\n\t\tthis._urlManager.stop();\n\t\tthis._iframeInterceptor.stopInterceptor();\n\t\tthis._iframeInterceptor.stopMerger();\n\t}\n\t/**\n\t* EDITOR mode: re-send ARE_YOU_THERE to attempt re-connection with the client.\n\t* Call this when the user clicks \"Enable Editor\" or when the iframe reloads.\n\t*/\n\tpingClient() {\n\t\tif (this._mode !== \"editor\") return;\n\t\tthis.messenger.send(\"INTLAYER_ARE_YOU_THERE\");\n\t}\n\tsetFocusedContentKeyPath(keyPath) {\n\t\tconst filtered = keyPath.filter((key) => key.type !== NodeTypes.TRANSLATION);\n\t\tconst prev = this.focusedContent.value;\n\t\tif (!prev) return;\n\t\tthis.focusedContent.set({\n\t\t\t...prev,\n\t\t\tkeyPath: filtered\n\t\t});\n\t}\n\tsetLocaleDictionary(dictionary) {\n\t\tif (!dictionary.localId) return;\n\t\tconst current = this.localeDictionaries.value ?? {};\n\t\tthis.localeDictionaries.set({\n\t\t\t...current,\n\t\t\t[dictionary.localId]: dictionary\n\t\t});\n\t}\n\tsetEditedDictionary(newDict) {\n\t\tif (!newDict.localId) {\n\t\t\tconsole.error(\"setEditedDictionary: missing localId\", newDict);\n\t\t\treturn;\n\t\t}\n\t\tconst current = this.editedContent.value ?? {};\n\t\tthis.editedContent.set({\n\t\t\t...current,\n\t\t\t[newDict.localId]: newDict\n\t\t});\n\t}\n\tsetEditedContent(localDictionaryId, newValue) {\n\t\tconst current = this.editedContent.value ?? {};\n\t\tthis.editedContent.set({\n\t\t\t...current,\n\t\t\t[localDictionaryId]: {\n\t\t\t\t...current[localDictionaryId],\n\t\t\t\tcontent: newValue\n\t\t\t}\n\t\t});\n\t}\n\taddContent(localDictionaryId, newValue, keyPath = [], overwrite = true) {\n\t\tconst current = this.editedContent.value ?? {};\n\t\tconst originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;\n\t\tconst currentContent = structuredClone(current[localDictionaryId]?.content ?? originalContent);\n\t\tlet newKeyPath = keyPath;\n\t\tif (!overwrite) {\n\t\t\tlet index = 0;\n\t\t\tconst otherKeyPath = keyPath.slice(0, -1);\n\t\t\tconst lastKeyPath = keyPath[keyPath.length - 1];\n\t\t\tlet finalKey = lastKeyPath.key;\n\t\t\twhile (typeof getContentNodeByKeyPath(currentContent, newKeyPath) !== \"undefined\") {\n\t\t\t\tindex++;\n\t\t\t\tfinalKey = index === 0 ? lastKeyPath.key : `${lastKeyPath.key} (${index})`;\n\t\t\t\tnewKeyPath = [...otherKeyPath, {\n\t\t\t\t\t...lastKeyPath,\n\t\t\t\t\tkey: finalKey\n\t\t\t\t}];\n\t\t\t}\n\t\t}\n\t\tconst updatedContent = editDictionaryByKeyPath(currentContent, newKeyPath, newValue);\n\t\tthis.editedContent.set({\n\t\t\t...current,\n\t\t\t[localDictionaryId]: {\n\t\t\t\t...current[localDictionaryId],\n\t\t\t\tcontent: updatedContent\n\t\t\t}\n\t\t});\n\t}\n\trenameContent(localDictionaryId, newKey, keyPath = []) {\n\t\tconst current = this.editedContent.value ?? {};\n\t\tconst originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;\n\t\tconst updated = renameContentNodeByKeyPath(structuredClone(current[localDictionaryId]?.content ?? originalContent), newKey, keyPath);\n\t\tthis.editedContent.set({\n\t\t\t...current,\n\t\t\t[localDictionaryId]: {\n\t\t\t\t...current[localDictionaryId],\n\t\t\t\tcontent: updated\n\t\t\t}\n\t\t});\n\t}\n\tremoveContent(localDictionaryId, keyPath) {\n\t\tconst current = this.editedContent.value ?? {};\n\t\tconst originalContent = (this.localeDictionaries.value ?? {})[localDictionaryId]?.content;\n\t\tconst restored = editDictionaryByKeyPath(structuredClone(current[localDictionaryId]?.content ?? originalContent), keyPath, getContentNodeByKeyPath(originalContent, keyPath));\n\t\tthis.editedContent.set({\n\t\t\t...current,\n\t\t\t[localDictionaryId]: {\n\t\t\t\t...current[localDictionaryId],\n\t\t\t\tcontent: restored\n\t\t\t}\n\t\t});\n\t}\n\trestoreContent(localDictionaryId) {\n\t\tconst updated = { ...this.editedContent.value ?? {} };\n\t\tdelete updated[localDictionaryId];\n\t\tthis.editedContent.set(updated);\n\t}\n\tclearContent(localDictionaryId) {\n\t\tconst filtered = { ...this.editedContent.value ?? {} };\n\t\tdelete filtered[localDictionaryId];\n\t\tthis.editedContent.set(filtered);\n\t}\n\tclearAllContent() {\n\t\tthis.editedContent.set({});\n\t}\n\tgetContentValue(localDictionaryIdOrKey, keyPath) {\n\t\tconst edited = this.editedContent.value;\n\t\tif (!edited) return void 0;\n\t\tconst filteredKeyPath = keyPath.filter((key) => key.type !== NodeTypes.TRANSLATION);\n\t\tconst localeDicts = this.localeDictionaries.value;\n\t\tif (localDictionaryIdOrKey.includes(\":local:\") || localDictionaryIdOrKey.includes(\":remote:\")) {\n\t\t\tif (localeDicts && !(localDictionaryIdOrKey in localeDicts)) return;\n\t\t\treturn getContentNodeByKeyPath(edited[localDictionaryIdOrKey]?.content ?? {}, filteredKeyPath, this.currentLocale.value);\n\t\t}\n\t\tconst matchingIds = Object.keys(edited).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`) && (!localeDicts || key in localeDicts));\n\t\tfor (const localId of matchingIds) {\n\t\t\tconst node = getContentNodeByKeyPath(edited[localId]?.content ?? {}, filteredKeyPath, this.currentLocale.value);\n\t\t\tif (node) return node;\n\t\t}\n\t}\n\t_startEditedContentBusSync() {\n\t\tthis._editedContentBusHandler = (e) => {\n\t\t\tif (this._editedContentFromBus) return;\n\t\t\tconst content = e.detail;\n\t\t\tsetGlobalEditedContent(content, this.messenger.senderId);\n\t\t};\n\t\tthis.editedContent.addEventListener(\"change\", this._editedContentBusHandler);\n\t\tthis._unsubGlobalEditedContent = subscribeToGlobalEditedContent((content, sourceId) => {\n\t\t\tif (sourceId === this.messenger.senderId) return;\n\t\t\tthis._editedContentFromBus = true;\n\t\t\tthis.editedContent.set(content);\n\t\t\tthis._editedContentFromBus = false;\n\t\t});\n\t\tconst existing = getGlobalEditedContent();\n\t\tif (Object.keys(existing).length > 0) {\n\t\t\tthis._editedContentFromBus = true;\n\t\t\tthis.editedContent.set(existing);\n\t\t\tthis._editedContentFromBus = false;\n\t\t}\n\t}\n\t_stopEditedContentBusSync() {\n\t\tif (this._editedContentBusHandler) {\n\t\t\tthis.editedContent.removeEventListener(\"change\", this._editedContentBusHandler);\n\t\t\tthis._editedContentBusHandler = null;\n\t\t}\n\t\tthis._unsubGlobalEditedContent?.();\n\t\tthis._unsubGlobalEditedContent = null;\n\t}\n\t_startFocusedContentBusSync() {\n\t\tthis._focusedContentBusHandler = (e) => {\n\t\t\tif (this._focusedContentFromBus) return;\n\t\t\tconst content = e.detail;\n\t\t\tsetGlobalFocusedContent(content, this.messenger.senderId);\n\t\t};\n\t\tthis.focusedContent.addEventListener(\"change\", this._focusedContentBusHandler);\n\t\tthis._unsubGlobalFocusedContent = subscribeToGlobalFocusedContent((content, sourceId) => {\n\t\t\tif (sourceId === this.messenger.senderId) return;\n\t\t\tthis._focusedContentFromBus = true;\n\t\t\tthis.focusedContent.set(content);\n\t\t\tthis._focusedContentFromBus = false;\n\t\t});\n\t\tconst existing = getGlobalFocusedContent();\n\t\tif (existing !== void 0) {\n\t\t\tthis._focusedContentFromBus = true;\n\t\t\tthis.focusedContent.set(existing);\n\t\t\tthis._focusedContentFromBus = false;\n\t\t}\n\t}\n\t_stopFocusedContentBusSync() {\n\t\tif (this._focusedContentBusHandler) {\n\t\t\tthis.focusedContent.removeEventListener(\"change\", this._focusedContentBusHandler);\n\t\t\tthis._focusedContentBusHandler = null;\n\t\t}\n\t\tthis._unsubGlobalFocusedContent?.();\n\t\tthis._unsubGlobalFocusedContent = null;\n\t}\n\t_scanDisplayedDictionaryKeys() {\n\t\tif (typeof document === \"undefined\") return;\n\t\tconst elements = document.querySelectorAll(\"intlayer-content-selector-wrapper[dictionary-key]\");\n\t\tconst keys = Array.from(new Set(Array.from(elements).map((el) => el.getAttribute(\"dictionary-key\") ?? \"\").filter(Boolean)));\n\t\tthis.displayedDictionaryKeys.set(keys);\n\t}\n\t_startDisplayedDictionariesTracking() {\n\t\tif (typeof document === \"undefined\" || typeof MutationObserver === \"undefined\") return;\n\t\tconst schedule = () => {\n\t\t\tif (this._displayedKeysTimer) clearTimeout(this._displayedKeysTimer);\n\t\t\tthis._displayedKeysTimer = setTimeout(() => this._scanDisplayedDictionaryKeys(), 100);\n\t\t};\n\t\tthis._displayedKeysObserver = new MutationObserver(schedule);\n\t\tthis._displayedKeysObserver.observe(document.body, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true\n\t\t});\n\t\tfor (const evt of [\"locationchange\", \"popstate\"]) {\n\t\t\tconst listener = schedule;\n\t\t\twindow.addEventListener(evt, listener);\n\t\t\tthis._displayedKeysListeners.push([evt, listener]);\n\t\t}\n\t\tthis._scanDisplayedDictionaryKeys();\n\t}\n\t_stopDisplayedDictionariesTracking() {\n\t\tthis._displayedKeysObserver?.disconnect();\n\t\tthis._displayedKeysObserver = null;\n\t\tif (this._displayedKeysTimer) {\n\t\t\tclearTimeout(this._displayedKeysTimer);\n\t\t\tthis._displayedKeysTimer = null;\n\t\t}\n\t\tfor (const [evt, listener] of this._displayedKeysListeners) window.removeEventListener(evt, listener);\n\t\tthis._displayedKeysListeners = [];\n\t}\n\t/**\n\t* EDITOR mode: listen for CLIENT_READY and respond with EDITOR_ACTIVATE.\n\t* Also pings the client immediately in case it loaded before the editor.\n\t*/\n\t_setupEditorHandshake() {\n\t\tthis._unsubClientReady = this.messenger.subscribe(\"INTLAYER_CLIENT_READY\", () => {\n\t\t\tthis.editorEnabled.set(true);\n\t\t\tthis.messenger.send(\"INTLAYER_EDITOR_ACTIVATE\");\n\t\t});\n\t\tthis.messenger.send(\"INTLAYER_ARE_YOU_THERE\");\n\t}\n\t_setupActivationHandshake() {\n\t\tthis.messenger.send(\"INTLAYER_CLIENT_READY\");\n\t\tthis._unsubAreYouThere = this.messenger.subscribe(\"INTLAYER_ARE_YOU_THERE\", () => {\n\t\t\tthis.messenger.send(\"INTLAYER_CLIENT_READY\");\n\t\t});\n\t\tthis._unsubActivate = this.messenger.subscribe(\"INTLAYER_EDITOR_ACTIVATE\", () => {\n\t\t\tthis.editorEnabled.set(true);\n\t\t\tthis._broadcastData();\n\t\t});\n\t}\n\t_broadcastData() {\n\t\tconst configVal = this.configuration.value;\n\t\tif (configVal) this.messenger.send(`${\"INTLAYER_CONFIGURATION\"}/post`, configVal);\n\t\tconst localeVal = this.currentLocale.value;\n\t\tif (localeVal) this.messenger.send(`${\"INTLAYER_CURRENT_LOCALE\"}/post`, localeVal);\n\t\tconst dicts = this.localeDictionaries.value;\n\t\tif (dicts) this.messenger.send(`${\"INTLAYER_LOCALE_DICTIONARIES_CHANGED\"}/post`, dicts);\n\t}\n\tasync _loadDictionaries() {\n\t\ttry {\n\t\t\tconst unmergedDictionaries = (await import(\"@intlayer/unmerged-dictionaries-entry\")).getUnmergedDictionaries();\n\t\t\tconst dictionariesList = Object.fromEntries(Object.values(unmergedDictionaries).flat().map((dictionary) => [dictionary.localId, dictionary]));\n\t\t\tthis.localeDictionaries.set(dictionariesList);\n\t\t\tif (this.editorEnabled.value) this._broadcastData();\n\t\t} catch (e) {\n\t\t\tconsole.warn(\"[intlayer] Failed to load unmerged dictionaries:\", e);\n\t\t}\n\t}\n};\n\n//#endregion\nexport { EditorStateManager };\n//# sourceMappingURL=EditorStateManager.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,IAAI,qBAAqB,MAAM;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,yBAAyB;CACzB,sBAAsB;CACtB,0BAA0B,EAAE;CAC5B,wBAAwB;CACxB,4BAA4B;CAC5B,2BAA2B;CAC3B,yBAAyB;CACzB,6BAA6B;CAC7B,4BAA4B;CAC5B,YAAY,QAAQ;AACnB,OAAK,QAAQ,OAAO;AACpB,OAAK,iBAAiB,OAAO;AAC7B,OAAK,YAAY,IAAIA,gDAAoB,OAAO,UAAU;AAC1D,OAAK,gBAAgB,IAAIC,sDAAuB,2BAA2B,KAAK,WAAW;GAC1F,MAAM;GACN,SAAS;GACT,cAAc;GACd,CAAC;AACF,OAAK,iBAAiB,IAAIA,sDAAuB,oCAAoC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B;IAC3C;AACF,OAAK,iBAAiB,KAAK,UAAU,UAAU,kCAAkC;AAChF,QAAK,cAAc,IAAI,KAAK;AAC5B,QAAK,gBAAgB;IACpB;;CAEH,iBAAiB;EAChB,MAAM,YAAY,KAAK,cAAc;AACrC,MAAI,UAAW,MAAK,UAAU,KAAK,+BAAoC,UAAU;EACjF,MAAM,YAAY,KAAK,cAAc;AACrC,MAAI,UAAW,MAAK,UAAU,KAAK,gCAAqC,UAAU;EAClF,MAAM,QAAQ,KAAK,mBAAmB;AACtC,MAAI,MAAO,MAAK,UAAU,KAAK,6CAAkD,MAAM;;CAExF,MAAM,oBAAoB;AACzB,MAAI;GACH,MAAM,wBAAwB,2CAAM,gEAAiD,yBAAyB;GAC9G,MAAM,mBAAmB,OAAO,YAAY,OAAO,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,eAAe,CAAC,WAAW,SAAS,WAAW,CAAC,CAAC;AAC7I,QAAK,mBAAmB,IAAI,iBAAiB;AAC7C,OAAI,KAAK,cAAc,MAAO,MAAK,gBAAgB;WAC3C,GAAG;AACX,WAAQ,KAAK,oDAAoD,EAAE"}
@@ -0,0 +1,45 @@
1
+ const require_mergeIframeClick = require('../mergeIframeClick.cjs');
2
+
3
+ //#region ../../packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs
4
+ /**
5
+ * IframeClickInterceptor handles click events across iframe boundaries.
6
+ *
7
+ * - startInterceptor(): called in the client (iframe) — broadcasts mousedown to parent
8
+ * - startMerger(): called in the editor (parent) — merges received clicks into DOM events
9
+ *
10
+ * Replaces useIframeClickInterceptor / useIframeClickMerger across all frameworks.
11
+ */
12
+ var IframeClickInterceptor = class {
13
+ _messenger;
14
+ _mousedownHandler = null;
15
+ _unsubscribeMerge = null;
16
+ constructor(messenger) {
17
+ this._messenger = messenger;
18
+ }
19
+ /** Called on the client side (inside iframe). Broadcasts click events to parent. */
20
+ startInterceptor() {
21
+ if (typeof window === "undefined") return;
22
+ this._mousedownHandler = () => {
23
+ this._messenger.send("INTLAYER_IFRAME_CLICKED");
24
+ };
25
+ window.addEventListener("mousedown", this._mousedownHandler);
26
+ }
27
+ /** Called on the editor side (parent frame). Merges incoming iframe clicks into DOM. */
28
+ startMerger() {
29
+ this._unsubscribeMerge = this._messenger.subscribe("INTLAYER_IFRAME_CLICKED", require_mergeIframeClick.mergeIframeClick);
30
+ }
31
+ stopInterceptor() {
32
+ if (this._mousedownHandler) {
33
+ window.removeEventListener("mousedown", this._mousedownHandler);
34
+ this._mousedownHandler = null;
35
+ }
36
+ }
37
+ stopMerger() {
38
+ this._unsubscribeMerge?.();
39
+ this._unsubscribeMerge = null;
40
+ }
41
+ };
42
+
43
+ //#endregion
44
+ exports.IframeClickInterceptor = IframeClickInterceptor;
45
+ //# sourceMappingURL=IframeClickInterceptor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IframeClickInterceptor.cjs","names":["mergeIframeClick"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\nimport { mergeIframeClick } from \"../mergeIframeClick.mjs\";\n\n//#region src/core/IframeClickInterceptor.ts\n/**\n* IframeClickInterceptor handles click events across iframe boundaries.\n*\n* - startInterceptor(): called in the client (iframe) — broadcasts mousedown to parent\n* - startMerger(): called in the editor (parent) — merges received clicks into DOM events\n*\n* Replaces useIframeClickInterceptor / useIframeClickMerger across all frameworks.\n*/\nvar IframeClickInterceptor = class {\n\t_messenger;\n\t_mousedownHandler = null;\n\t_unsubscribeMerge = null;\n\tconstructor(messenger) {\n\t\tthis._messenger = messenger;\n\t}\n\t/** Called on the client side (inside iframe). Broadcasts click events to parent. */\n\tstartInterceptor() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tthis._mousedownHandler = () => {\n\t\t\tthis._messenger.send(\"INTLAYER_IFRAME_CLICKED\");\n\t\t};\n\t\twindow.addEventListener(\"mousedown\", this._mousedownHandler);\n\t}\n\t/** Called on the editor side (parent frame). Merges incoming iframe clicks into DOM. */\n\tstartMerger() {\n\t\tthis._unsubscribeMerge = this._messenger.subscribe(\"INTLAYER_IFRAME_CLICKED\", mergeIframeClick);\n\t}\n\tstopInterceptor() {\n\t\tif (this._mousedownHandler) {\n\t\t\twindow.removeEventListener(\"mousedown\", this._mousedownHandler);\n\t\t\tthis._mousedownHandler = null;\n\t\t}\n\t}\n\tstopMerger() {\n\t\tthis._unsubscribeMerge?.();\n\t\tthis._unsubscribeMerge = null;\n\t}\n};\n\n//#endregion\nexport { IframeClickInterceptor };\n//# sourceMappingURL=IframeClickInterceptor.mjs.map"],"mappings":";;;;;;;;;;;AAYA,IAAI,yBAAyB,MAAM;CAClC;CACA,oBAAoB;CACpB,oBAAoB;CACpB,YAAY,WAAW;AACtB,OAAK,aAAa;;;CAGnB,mBAAmB;AAClB,MAAI,OAAO,WAAW,YAAa;AACnC,OAAK,0BAA0B;AAC9B,QAAK,WAAW,KAAK,0BAA0B;;AAEhD,SAAO,iBAAiB,aAAa,KAAK,kBAAkB;;;CAG7D,cAAc;AACb,OAAK,oBAAoB,KAAK,WAAW,UAAU,2BAA2BA,0CAAiB;;CAEhG,kBAAkB;AACjB,MAAI,KAAK,mBAAmB;AAC3B,UAAO,oBAAoB,aAAa,KAAK,kBAAkB;AAC/D,QAAK,oBAAoB;;;CAG3B,aAAa;AACZ,OAAK,qBAAqB;AAC1B,OAAK,oBAAoB"}
@@ -0,0 +1,59 @@
1
+
2
+ //#region ../../packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs
3
+ /**
4
+ * UrlStateManager patches window.history and broadcasts URL path changes
5
+ * across frames via postMessage.
6
+ *
7
+ * Replaces useCrossURLPathSetter / useCrossURLPathState across all frameworks.
8
+ */
9
+ var UrlStateManager = class {
10
+ _messenger;
11
+ _originalPushState = null;
12
+ _originalReplaceState = null;
13
+ _listeners = [];
14
+ constructor(messenger) {
15
+ this._messenger = messenger;
16
+ }
17
+ start() {
18
+ if (typeof window === "undefined") return;
19
+ const updateURLState = () => {
20
+ this._messenger.send(`INTLAYER_URL_CHANGE/post`, window.location.pathname);
21
+ };
22
+ this._originalPushState = history.pushState;
23
+ this._originalReplaceState = history.replaceState;
24
+ const injectLocationChange = (method) => function(...args) {
25
+ method.apply(this, args);
26
+ window.dispatchEvent(new Event("locationchange"));
27
+ };
28
+ history.pushState = injectLocationChange(this._originalPushState);
29
+ history.replaceState = injectLocationChange(this._originalReplaceState);
30
+ for (const eventName of [
31
+ "locationchange",
32
+ "popstate",
33
+ "hashchange",
34
+ "load"
35
+ ]) {
36
+ const listener = updateURLState;
37
+ window.addEventListener(eventName, listener);
38
+ this._listeners.push([eventName, listener]);
39
+ }
40
+ updateURLState();
41
+ }
42
+ stop() {
43
+ if (typeof window === "undefined") return;
44
+ for (const [eventName, listener] of this._listeners) window.removeEventListener(eventName, listener);
45
+ this._listeners = [];
46
+ if (this._originalPushState) {
47
+ history.pushState = this._originalPushState;
48
+ this._originalPushState = null;
49
+ }
50
+ if (this._originalReplaceState) {
51
+ history.replaceState = this._originalReplaceState;
52
+ this._originalReplaceState = null;
53
+ }
54
+ }
55
+ };
56
+
57
+ //#endregion
58
+ exports.UrlStateManager = UrlStateManager;
59
+ //# sourceMappingURL=UrlStateManager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UrlStateManager.cjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\n\n//#region src/core/UrlStateManager.ts\n/**\n* UrlStateManager patches window.history and broadcasts URL path changes\n* across frames via postMessage.\n*\n* Replaces useCrossURLPathSetter / useCrossURLPathState across all frameworks.\n*/\nvar UrlStateManager = class {\n\t_messenger;\n\t_originalPushState = null;\n\t_originalReplaceState = null;\n\t_listeners = [];\n\tconstructor(messenger) {\n\t\tthis._messenger = messenger;\n\t}\n\tstart() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tconst updateURLState = () => {\n\t\t\tthis._messenger.send(`${\"INTLAYER_URL_CHANGE\"}/post`, window.location.pathname);\n\t\t};\n\t\tthis._originalPushState = history.pushState;\n\t\tthis._originalReplaceState = history.replaceState;\n\t\tconst injectLocationChange = (method) => function(...args) {\n\t\t\tmethod.apply(this, args);\n\t\t\twindow.dispatchEvent(new Event(\"locationchange\"));\n\t\t};\n\t\thistory.pushState = injectLocationChange(this._originalPushState);\n\t\thistory.replaceState = injectLocationChange(this._originalReplaceState);\n\t\tfor (const eventName of [\n\t\t\t\"locationchange\",\n\t\t\t\"popstate\",\n\t\t\t\"hashchange\",\n\t\t\t\"load\"\n\t\t]) {\n\t\t\tconst listener = updateURLState;\n\t\t\twindow.addEventListener(eventName, listener);\n\t\t\tthis._listeners.push([eventName, listener]);\n\t\t}\n\t\tupdateURLState();\n\t}\n\tstop() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tfor (const [eventName, listener] of this._listeners) window.removeEventListener(eventName, listener);\n\t\tthis._listeners = [];\n\t\tif (this._originalPushState) {\n\t\t\thistory.pushState = this._originalPushState;\n\t\t\tthis._originalPushState = null;\n\t\t}\n\t\tif (this._originalReplaceState) {\n\t\t\thistory.replaceState = this._originalReplaceState;\n\t\t\tthis._originalReplaceState = null;\n\t\t}\n\t}\n};\n\n//#endregion\nexport { UrlStateManager };\n//# sourceMappingURL=UrlStateManager.mjs.map"],"mappings":";;;;;;;;AASA,IAAI,kBAAkB,MAAM;CAC3B;CACA,qBAAqB;CACrB,wBAAwB;CACxB,aAAa,EAAE;CACf,YAAY,WAAW;AACtB,OAAK,aAAa;;CAEnB,QAAQ;AACP,MAAI,OAAO,WAAW,YAAa;EACnC,MAAM,uBAAuB;AAC5B,QAAK,WAAW,KAAK,4BAAiC,OAAO,SAAS,SAAS;;AAEhF,OAAK,qBAAqB,QAAQ;AAClC,OAAK,wBAAwB,QAAQ;EACrC,MAAM,wBAAwB,WAAW,SAAS,GAAG,MAAM;AAC1D,UAAO,MAAM,MAAM,KAAK;AACxB,UAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAElD,UAAQ,YAAY,qBAAqB,KAAK,mBAAmB;AACjE,UAAQ,eAAe,qBAAqB,KAAK,sBAAsB;AACvE,OAAK,MAAM,aAAa;GACvB;GACA;GACA;GACA;GACA,EAAE;GACF,MAAM,WAAW;AACjB,UAAO,iBAAiB,WAAW,SAAS;AAC5C,QAAK,WAAW,KAAK,CAAC,WAAW,SAAS,CAAC;;AAE5C,kBAAgB;;CAEjB,OAAO;AACN,MAAI,OAAO,WAAW,YAAa;AACnC,OAAK,MAAM,CAAC,WAAW,aAAa,KAAK,WAAY,QAAO,oBAAoB,WAAW,SAAS;AACpG,OAAK,aAAa,EAAE;AACpB,MAAI,KAAK,oBAAoB;AAC5B,WAAQ,YAAY,KAAK;AACzB,QAAK,qBAAqB;;AAE3B,MAAI,KAAK,uBAAuB;AAC/B,WAAQ,eAAe,KAAK;AAC5B,QAAK,wBAAwB"}
@@ -0,0 +1,36 @@
1
+
2
+ //#region ../../packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs
3
+ const BUS_KEY = "__intlayer_edited_content_bus__";
4
+ const BUS_EVENTS_KEY = "__intlayer_edited_content_bus_events__";
5
+ const getBusTarget = () => {
6
+ if (typeof window === "undefined") return new EventTarget();
7
+ const w = window;
8
+ if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
9
+ return w[BUS_EVENTS_KEY];
10
+ };
11
+ const getGlobalEditedContent = () => {
12
+ if (typeof window === "undefined") return {};
13
+ return window[BUS_KEY] ?? {};
14
+ };
15
+ const setGlobalEditedContent = (content, sourceId) => {
16
+ if (typeof window !== "undefined") window[BUS_KEY] = content;
17
+ getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
18
+ content,
19
+ sourceId
20
+ } }));
21
+ };
22
+ const subscribeToGlobalEditedContent = (cb) => {
23
+ const handler = (e) => {
24
+ const { content, sourceId } = e.detail;
25
+ cb(content, sourceId);
26
+ };
27
+ const target = getBusTarget();
28
+ target.addEventListener("change", handler);
29
+ return () => target.removeEventListener("change", handler);
30
+ };
31
+
32
+ //#endregion
33
+ exports.getGlobalEditedContent = getGlobalEditedContent;
34
+ exports.setGlobalEditedContent = setGlobalEditedContent;
35
+ exports.subscribeToGlobalEditedContent = subscribeToGlobalEditedContent;
36
+ //# sourceMappingURL=editedContentBus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editedContentBus.cjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs"],"sourcesContent":["//#region src/core/editedContentBus.ts\nconst BUS_KEY = \"__intlayer_edited_content_bus__\";\nconst BUS_EVENTS_KEY = \"__intlayer_edited_content_bus_events__\";\nconst getBusTarget = () => {\n\tif (typeof window === \"undefined\") return new EventTarget();\n\tconst w = window;\n\tif (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n\treturn w[BUS_EVENTS_KEY];\n};\nconst getGlobalEditedContent = () => {\n\tif (typeof window === \"undefined\") return {};\n\treturn window[BUS_KEY] ?? {};\n};\nconst setGlobalEditedContent = (content, sourceId) => {\n\tif (typeof window !== \"undefined\") window[BUS_KEY] = content;\n\tgetBusTarget().dispatchEvent(new CustomEvent(\"change\", { detail: {\n\t\tcontent,\n\t\tsourceId\n\t} }));\n};\nconst subscribeToGlobalEditedContent = (cb) => {\n\tconst handler = (e) => {\n\t\tconst { content, sourceId } = e.detail;\n\t\tcb(content, sourceId);\n\t};\n\tconst target = getBusTarget();\n\ttarget.addEventListener(\"change\", handler);\n\treturn () => target.removeEventListener(\"change\", handler);\n};\n\n//#endregion\nexport { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent };\n//# sourceMappingURL=editedContentBus.mjs.map"],"mappings":";;AACA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC1B,KAAI,OAAO,WAAW,YAAa,QAAO,IAAI,aAAa;CAC3D,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,gBAAiB,GAAE,kBAAkB,IAAI,aAAa;AAC7D,QAAO,EAAE;;AAEV,MAAM,+BAA+B;AACpC,KAAI,OAAO,WAAW,YAAa,QAAO,EAAE;AAC5C,QAAO,OAAO,YAAY,EAAE;;AAE7B,MAAM,0BAA0B,SAAS,aAAa;AACrD,KAAI,OAAO,WAAW,YAAa,QAAO,WAAW;AACrD,eAAc,CAAC,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ;EAChE;EACA;EACA,EAAE,CAAC,CAAC;;AAEN,MAAM,kCAAkC,OAAO;CAC9C,MAAM,WAAW,MAAM;EACtB,MAAM,EAAE,SAAS,aAAa,EAAE;AAChC,KAAG,SAAS,SAAS;;CAEtB,MAAM,SAAS,cAAc;AAC7B,QAAO,iBAAiB,UAAU,QAAQ;AAC1C,cAAa,OAAO,oBAAoB,UAAU,QAAQ"}
@@ -0,0 +1,42 @@
1
+
2
+ //#region ../../packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs
3
+ const BUS_KEY = "__intlayer_focused_content_bus__";
4
+ const BUS_EVENTS_KEY = "__intlayer_focused_content_bus_events__";
5
+ const getBusTarget = () => {
6
+ if (typeof window === "undefined") return new EventTarget();
7
+ const w = window;
8
+ if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
9
+ return w[BUS_EVENTS_KEY];
10
+ };
11
+ const getGlobalFocusedContent = () => {
12
+ if (typeof window === "undefined") return void 0;
13
+ const w = window;
14
+ if (!w.__intlayer_focused_content_bus_set__) return void 0;
15
+ return w[BUS_KEY] ?? null;
16
+ };
17
+ const setGlobalFocusedContent = (content, sourceId) => {
18
+ if (typeof window !== "undefined") {
19
+ const w = window;
20
+ w[BUS_KEY] = content;
21
+ w.__intlayer_focused_content_bus_set__ = true;
22
+ }
23
+ getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
24
+ content,
25
+ sourceId
26
+ } }));
27
+ };
28
+ const subscribeToGlobalFocusedContent = (cb) => {
29
+ const handler = (e) => {
30
+ const { content, sourceId } = e.detail;
31
+ cb(content, sourceId);
32
+ };
33
+ const target = getBusTarget();
34
+ target.addEventListener("change", handler);
35
+ return () => target.removeEventListener("change", handler);
36
+ };
37
+
38
+ //#endregion
39
+ exports.getGlobalFocusedContent = getGlobalFocusedContent;
40
+ exports.setGlobalFocusedContent = setGlobalFocusedContent;
41
+ exports.subscribeToGlobalFocusedContent = subscribeToGlobalFocusedContent;
42
+ //# sourceMappingURL=focusedContentBus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusedContentBus.cjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs"],"sourcesContent":["//#region src/core/focusedContentBus.ts\nconst BUS_KEY = \"__intlayer_focused_content_bus__\";\nconst BUS_EVENTS_KEY = \"__intlayer_focused_content_bus_events__\";\nconst getBusTarget = () => {\n\tif (typeof window === \"undefined\") return new EventTarget();\n\tconst w = window;\n\tif (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n\treturn w[BUS_EVENTS_KEY];\n};\nconst getGlobalFocusedContent = () => {\n\tif (typeof window === \"undefined\") return void 0;\n\tconst w = window;\n\tif (!w.__intlayer_focused_content_bus_set__) return void 0;\n\treturn w[BUS_KEY] ?? null;\n};\nconst setGlobalFocusedContent = (content, sourceId) => {\n\tif (typeof window !== \"undefined\") {\n\t\tconst w = window;\n\t\tw[BUS_KEY] = content;\n\t\tw.__intlayer_focused_content_bus_set__ = true;\n\t}\n\tgetBusTarget().dispatchEvent(new CustomEvent(\"change\", { detail: {\n\t\tcontent,\n\t\tsourceId\n\t} }));\n};\nconst subscribeToGlobalFocusedContent = (cb) => {\n\tconst handler = (e) => {\n\t\tconst { content, sourceId } = e.detail;\n\t\tcb(content, sourceId);\n\t};\n\tconst target = getBusTarget();\n\ttarget.addEventListener(\"change\", handler);\n\treturn () => target.removeEventListener(\"change\", handler);\n};\n\n//#endregion\nexport { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent };\n//# sourceMappingURL=focusedContentBus.mjs.map"],"mappings":";;AACA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC1B,KAAI,OAAO,WAAW,YAAa,QAAO,IAAI,aAAa;CAC3D,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,gBAAiB,GAAE,kBAAkB,IAAI,aAAa;AAC7D,QAAO,EAAE;;AAEV,MAAM,gCAAgC;AACrC,KAAI,OAAO,WAAW,YAAa,QAAO,KAAK;CAC/C,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,qCAAsC,QAAO,KAAK;AACzD,QAAO,EAAE,YAAY;;AAEtB,MAAM,2BAA2B,SAAS,aAAa;AACtD,KAAI,OAAO,WAAW,aAAa;EAClC,MAAM,IAAI;AACV,IAAE,WAAW;AACb,IAAE,uCAAuC;;AAE1C,eAAc,CAAC,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ;EAChE;EACA;EACA,EAAE,CAAC,CAAC;;AAEN,MAAM,mCAAmC,OAAO;CAC/C,MAAM,WAAW,MAAM;EACtB,MAAM,EAAE,SAAS,aAAa,EAAE;AAChC,KAAG,SAAS,SAAS;;CAEtB,MAAM,SAAS,cAAc;AAC7B,QAAO,iBAAiB,UAAU,QAAQ;AAC1C,cAAa,OAAO,oBAAoB,UAAU,QAAQ"}