@intlayer/editor 8.4.4 → 8.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +11 -0
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/cjs/compareUrls.cjs +39 -1
  4. package/dist/cjs/compareUrls.cjs.map +1 -1
  5. package/dist/cjs/components/ContentSelector.cjs +168 -1
  6. package/dist/cjs/components/ContentSelector.cjs.map +1 -0
  7. package/dist/cjs/components/ContentSelectorWrapper.cjs +193 -4
  8. package/dist/cjs/components/ContentSelectorWrapper.cjs.map +1 -1
  9. package/dist/cjs/components/EditedContent.cjs +128 -4
  10. package/dist/cjs/components/EditedContent.cjs.map +1 -1
  11. package/dist/cjs/components/IntlayerEditor.cjs +87 -1
  12. package/dist/cjs/components/IntlayerEditor.cjs.map +1 -0
  13. package/dist/cjs/components/index.cjs +14 -1
  14. package/dist/cjs/core/CrossFrameMessenger.cjs +77 -1
  15. package/dist/cjs/core/CrossFrameMessenger.cjs.map +1 -1
  16. package/dist/cjs/core/CrossFrameStateManager.cjs +71 -1
  17. package/dist/cjs/core/CrossFrameStateManager.cjs.map +1 -1
  18. package/dist/cjs/core/EditorStateManager.cjs +258 -1
  19. package/dist/cjs/core/EditorStateManager.cjs.map +1 -1
  20. package/dist/cjs/core/IframeClickInterceptor.cjs +45 -1
  21. package/dist/cjs/core/IframeClickInterceptor.cjs.map +1 -1
  22. package/dist/cjs/core/UrlStateManager.cjs +59 -1
  23. package/dist/cjs/core/UrlStateManager.cjs.map +1 -1
  24. package/dist/cjs/core/globalManager.cjs +82 -1
  25. package/dist/cjs/core/globalManager.cjs.map +1 -1
  26. package/dist/cjs/core/index.cjs +20 -1
  27. package/dist/cjs/core/initEditorClient.cjs +58 -1
  28. package/dist/cjs/core/initEditorClient.cjs.map +1 -0
  29. package/dist/cjs/index.cjs +38 -1
  30. package/dist/cjs/isEnabled.cjs +10 -1
  31. package/dist/cjs/isEnabled.cjs.map +1 -1
  32. package/dist/cjs/mergeIframeClick.cjs +22 -1
  33. package/dist/cjs/mergeIframeClick.cjs.map +1 -1
  34. package/dist/cjs/messageKey.cjs +30 -1
  35. package/dist/cjs/messageKey.cjs.map +1 -1
  36. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +10 -0
  37. package/dist/esm/compareUrls.mjs +37 -1
  38. package/dist/esm/compareUrls.mjs.map +1 -1
  39. package/dist/esm/components/ContentSelector.mjs +165 -1
  40. package/dist/esm/components/ContentSelector.mjs.map +1 -0
  41. package/dist/esm/components/ContentSelectorWrapper.mjs +189 -4
  42. package/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -1
  43. package/dist/esm/components/EditedContent.mjs +125 -4
  44. package/dist/esm/components/EditedContent.mjs.map +1 -1
  45. package/dist/esm/components/IntlayerEditor.mjs +84 -1
  46. package/dist/esm/components/IntlayerEditor.mjs.map +1 -0
  47. package/dist/esm/components/index.mjs +6 -1
  48. package/dist/esm/core/CrossFrameMessenger.mjs +76 -1
  49. package/dist/esm/core/CrossFrameMessenger.mjs.map +1 -1
  50. package/dist/esm/core/CrossFrameStateManager.mjs +69 -1
  51. package/dist/esm/core/CrossFrameStateManager.mjs.map +1 -1
  52. package/dist/esm/core/EditorStateManager.mjs +255 -1
  53. package/dist/esm/core/EditorStateManager.mjs.map +1 -1
  54. package/dist/esm/core/IframeClickInterceptor.mjs +44 -1
  55. package/dist/esm/core/IframeClickInterceptor.mjs.map +1 -1
  56. package/dist/esm/core/UrlStateManager.mjs +58 -1
  57. package/dist/esm/core/UrlStateManager.mjs.map +1 -1
  58. package/dist/esm/core/globalManager.mjs +78 -1
  59. package/dist/esm/core/globalManager.mjs.map +1 -1
  60. package/dist/esm/core/index.mjs +9 -1
  61. package/dist/esm/core/initEditorClient.mjs +53 -1
  62. package/dist/esm/core/initEditorClient.mjs.map +1 -0
  63. package/dist/esm/index.mjs +16 -1
  64. package/dist/esm/isEnabled.mjs +7 -1
  65. package/dist/esm/isEnabled.mjs.map +1 -1
  66. package/dist/esm/mergeIframeClick.mjs +20 -1
  67. package/dist/esm/mergeIframeClick.mjs.map +1 -1
  68. package/dist/esm/messageKey.mjs +28 -1
  69. package/dist/esm/messageKey.mjs.map +1 -1
  70. package/dist/types/components/ContentSelector.d.ts +49 -2
  71. package/dist/types/components/ContentSelector.d.ts.map +1 -0
  72. package/dist/types/components/ContentSelectorWrapper.d.ts +49 -2
  73. package/dist/types/components/ContentSelectorWrapper.d.ts.map +1 -0
  74. package/dist/types/components/EditedContent.d.ts +39 -2
  75. package/dist/types/components/EditedContent.d.ts.map +1 -0
  76. package/dist/types/components/IntlayerEditor.d.ts +40 -2
  77. package/dist/types/components/IntlayerEditor.d.ts.map +1 -0
  78. package/dist/types/components/index.d.ts +4 -4
  79. package/dist/types/core/CrossFrameMessenger.d.ts +51 -2
  80. package/dist/types/core/CrossFrameMessenger.d.ts.map +1 -0
  81. package/dist/types/core/CrossFrameStateManager.d.ts +44 -2
  82. package/dist/types/core/CrossFrameStateManager.d.ts.map +1 -0
  83. package/dist/types/core/EditorStateManager.d.ts +73 -2
  84. package/dist/types/core/EditorStateManager.d.ts.map +1 -0
  85. package/dist/types/core/IframeClickInterceptor.d.ts +26 -2
  86. package/dist/types/core/IframeClickInterceptor.d.ts.map +1 -0
  87. package/dist/types/core/UrlStateManager.d.ts +21 -2
  88. package/dist/types/core/UrlStateManager.d.ts.map +1 -0
  89. package/dist/types/core/globalManager.d.ts +39 -2
  90. package/dist/types/core/globalManager.d.ts.map +1 -0
  91. package/dist/types/core/index.d.ts +7 -7
  92. package/dist/types/core/initEditorClient.d.ts +20 -2
  93. package/dist/types/core/initEditorClient.d.ts.map +1 -0
  94. package/dist/types/index.d.ts +11 -11
  95. package/package.json +5 -5
  96. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  97. package/dist/cjs/components-DWu35JEb.cjs +0 -41
  98. package/dist/cjs/components-DWu35JEb.cjs.map +0 -1
  99. package/dist/cjs/decorate-Bg73f0d3.cjs +0 -1
  100. package/dist/esm/components-RtOXxg9h.mjs +0 -41
  101. package/dist/esm/components-RtOXxg9h.mjs.map +0 -1
  102. package/dist/esm/decorate-BWURH4oJ.mjs +0 -1
  103. package/dist/types/ContentSelector-sIfZu4Dd.d.ts +0 -49
  104. package/dist/types/ContentSelector-sIfZu4Dd.d.ts.map +0 -1
  105. package/dist/types/ContentSelectorWrapper-CID6anMf.d.ts +0 -49
  106. package/dist/types/ContentSelectorWrapper-CID6anMf.d.ts.map +0 -1
  107. package/dist/types/CrossFrameMessenger-CPt3Bu8S.d.ts +0 -51
  108. package/dist/types/CrossFrameMessenger-CPt3Bu8S.d.ts.map +0 -1
  109. package/dist/types/CrossFrameStateManager-CW1DPY_Z.d.ts +0 -44
  110. package/dist/types/CrossFrameStateManager-CW1DPY_Z.d.ts.map +0 -1
  111. package/dist/types/EditedContent-2kq4wk4R.d.ts +0 -39
  112. package/dist/types/EditedContent-2kq4wk4R.d.ts.map +0 -1
  113. package/dist/types/EditorStateManager-Y9j0SYCd.d.ts +0 -73
  114. package/dist/types/EditorStateManager-Y9j0SYCd.d.ts.map +0 -1
  115. package/dist/types/IframeClickInterceptor-Cm89LRcI.d.ts +0 -26
  116. package/dist/types/IframeClickInterceptor-Cm89LRcI.d.ts.map +0 -1
  117. package/dist/types/IntlayerEditor-ePRSIuBI.d.ts +0 -40
  118. package/dist/types/IntlayerEditor-ePRSIuBI.d.ts.map +0 -1
  119. package/dist/types/UrlStateManager-CIOVEeTq.d.ts +0 -21
  120. package/dist/types/UrlStateManager-CIOVEeTq.d.ts.map +0 -1
  121. package/dist/types/globalManager-BD6UaK_1.d.ts +0 -39
  122. package/dist/types/globalManager-BD6UaK_1.d.ts.map +0 -1
  123. package/dist/types/initEditorClient-ovRVUf_n.d.ts +0 -20
  124. package/dist/types/initEditorClient-ovRVUf_n.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"UrlStateManager.mjs","names":[],"sources":["../../../src/core/UrlStateManager.ts"],"sourcesContent":["import { MessageKey } from '../messageKey';\nimport type { CrossFrameMessenger } from './CrossFrameMessenger';\n\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 */\nexport class UrlStateManager {\n private readonly _messenger: CrossFrameMessenger;\n private _originalPushState: typeof history.pushState | null = null;\n private _originalReplaceState: typeof history.replaceState | null = null;\n private _listeners: Array<[string, EventListener]> = [];\n\n constructor(messenger: CrossFrameMessenger) {\n this._messenger = messenger;\n }\n\n start(): void {\n if (typeof window === 'undefined') return;\n\n const updateURLState = () => {\n this._messenger.send(\n `${MessageKey.INTLAYER_URL_CHANGE}/post`,\n window.location.pathname\n );\n };\n\n this._originalPushState = history.pushState;\n this._originalReplaceState = history.replaceState;\n\n const injectLocationChange = (method: typeof history.pushState) =>\n function (\n this: typeof history,\n ...args: Parameters<typeof history.pushState>\n ) {\n method.apply(this, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n history.pushState = injectLocationChange(\n this._originalPushState\n ) as typeof history.pushState;\n history.replaceState = injectLocationChange(\n this._originalReplaceState\n ) as typeof history.replaceState;\n\n for (const eventName of [\n 'locationchange',\n 'popstate',\n 'hashchange',\n 'load',\n ] as const) {\n const listener = updateURLState as EventListener;\n window.addEventListener(eventName, listener);\n this._listeners.push([eventName, listener]);\n }\n\n updateURLState();\n }\n\n stop(): void {\n if (typeof window === 'undefined') return;\n\n for (const [eventName, listener] of this._listeners) {\n window.removeEventListener(eventName, listener);\n }\n this._listeners = [];\n\n if (this._originalPushState) {\n history.pushState = this._originalPushState;\n this._originalPushState = null;\n }\n if (this._originalReplaceState) {\n history.replaceState = this._originalReplaceState;\n this._originalReplaceState = null;\n }\n }\n}\n"],"mappings":"+CASA,IAAa,EAAb,KAA6B,CAM3B,YAAY,EAAgC,yBAJkB,gCACM,qBACf,EAAE,CAGrD,KAAK,WAAa,EAGpB,OAAc,CACZ,GAAI,OAAO,OAAW,IAAa,OAEnC,IAAM,MAAuB,CAC3B,KAAK,WAAW,KACd,GAAG,EAAW,oBAAoB,OAClC,OAAO,SAAS,SACjB,EAGH,KAAK,mBAAqB,QAAQ,UAClC,KAAK,sBAAwB,QAAQ,aAErC,IAAM,EAAwB,GAC5B,SAEE,GAAG,EACH,CACA,EAAO,MAAM,KAAM,EAAK,CACxB,OAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC,EAGrD,QAAQ,UAAY,EAClB,KAAK,mBACN,CACD,QAAQ,aAAe,EACrB,KAAK,sBACN,CAED,IAAK,IAAM,IAAa,CACtB,iBACA,WACA,aACA,OACD,CAAW,CACV,IAAM,EAAW,EACjB,OAAO,iBAAiB,EAAW,EAAS,CAC5C,KAAK,WAAW,KAAK,CAAC,EAAW,EAAS,CAAC,CAG7C,GAAgB,CAGlB,MAAa,CACP,YAAO,OAAW,KAEtB,KAAK,GAAM,CAAC,EAAW,KAAa,KAAK,WACvC,OAAO,oBAAoB,EAAW,EAAS,CAEjD,KAAK,WAAa,EAAE,CAEpB,AAEE,KAAK,sBADL,QAAQ,UAAY,KAAK,mBACC,MAE5B,AAEE,KAAK,yBADL,QAAQ,aAAe,KAAK,sBACC"}
1
+ {"version":3,"file":"UrlStateManager.mjs","names":[],"sources":["../../../src/core/UrlStateManager.ts"],"sourcesContent":["import { MessageKey } from '../messageKey';\nimport type { CrossFrameMessenger } from './CrossFrameMessenger';\n\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 */\nexport class UrlStateManager {\n private readonly _messenger: CrossFrameMessenger;\n private _originalPushState: typeof history.pushState | null = null;\n private _originalReplaceState: typeof history.replaceState | null = null;\n private _listeners: Array<[string, EventListener]> = [];\n\n constructor(messenger: CrossFrameMessenger) {\n this._messenger = messenger;\n }\n\n start(): void {\n if (typeof window === 'undefined') return;\n\n const updateURLState = () => {\n this._messenger.send(\n `${MessageKey.INTLAYER_URL_CHANGE}/post`,\n window.location.pathname\n );\n };\n\n this._originalPushState = history.pushState;\n this._originalReplaceState = history.replaceState;\n\n const injectLocationChange = (method: typeof history.pushState) =>\n function (\n this: typeof history,\n ...args: Parameters<typeof history.pushState>\n ) {\n method.apply(this, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n history.pushState = injectLocationChange(\n this._originalPushState\n ) as typeof history.pushState;\n history.replaceState = injectLocationChange(\n this._originalReplaceState\n ) as typeof history.replaceState;\n\n for (const eventName of [\n 'locationchange',\n 'popstate',\n 'hashchange',\n 'load',\n ] as const) {\n const listener = updateURLState as EventListener;\n window.addEventListener(eventName, listener);\n this._listeners.push([eventName, listener]);\n }\n\n updateURLState();\n }\n\n stop(): void {\n if (typeof window === 'undefined') return;\n\n for (const [eventName, listener] of this._listeners) {\n window.removeEventListener(eventName, listener);\n }\n this._listeners = [];\n\n if (this._originalPushState) {\n history.pushState = this._originalPushState;\n this._originalPushState = null;\n }\n if (this._originalReplaceState) {\n history.replaceState = this._originalReplaceState;\n this._originalReplaceState = null;\n }\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAa,kBAAb,MAA6B;CAM3B,YAAY,WAAgC;4BAJkB;+BACM;oBACf,EAAE;AAGrD,OAAK,aAAa;;CAGpB,QAAc;AACZ,MAAI,OAAO,WAAW,YAAa;EAEnC,MAAM,uBAAuB;AAC3B,QAAK,WAAW,KACd,GAAG,WAAW,oBAAoB,QAClC,OAAO,SAAS,SACjB;;AAGH,OAAK,qBAAqB,QAAQ;AAClC,OAAK,wBAAwB,QAAQ;EAErC,MAAM,wBAAwB,WAC5B,SAEE,GAAG,MACH;AACA,UAAO,MAAM,MAAM,KAAK;AACxB,UAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAGrD,UAAQ,YAAY,qBAClB,KAAK,mBACN;AACD,UAAQ,eAAe,qBACrB,KAAK,sBACN;AAED,OAAK,MAAM,aAAa;GACtB;GACA;GACA;GACA;GACD,EAAW;GACV,MAAM,WAAW;AACjB,UAAO,iBAAiB,WAAW,SAAS;AAC5C,QAAK,WAAW,KAAK,CAAC,WAAW,SAAS,CAAC;;AAG7C,kBAAgB;;CAGlB,OAAa;AACX,MAAI,OAAO,WAAW,YAAa;AAEnC,OAAK,MAAM,CAAC,WAAW,aAAa,KAAK,WACvC,QAAO,oBAAoB,WAAW,SAAS;AAEjD,OAAK,aAAa,EAAE;AAEpB,MAAI,KAAK,oBAAoB;AAC3B,WAAQ,YAAY,KAAK;AACzB,QAAK,qBAAqB;;AAE5B,MAAI,KAAK,uBAAuB;AAC9B,WAAQ,eAAe,KAAK;AAC5B,QAAK,wBAAwB"}
@@ -1,2 +1,79 @@
1
- const e=`__intlayer_editor_manager__`,t=`__intlayer_editor_manager_events__`,n=()=>{if(typeof window>`u`)return new EventTarget;let e=window;return e[t]||(e[t]=new EventTarget),e[t]},r=()=>typeof window>`u`?null:window[e]??null,i=t=>{if(typeof window<`u`){let n=window;n[e]=t}n().dispatchEvent(new CustomEvent(`change`,{detail:t}))},a=e=>{let t=n(),r=t=>{e(t.detail)};return t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}};export{r as getGlobalEditorManager,a as onGlobalEditorManagerChange,i as setGlobalEditorManager};
1
+ //#region src/core/globalManager.ts
2
+ /**
3
+ * Keys on window used to share the singleton across multiple module instances.
4
+ * When bundlers include @intlayer/editor more than once (e.g. framework package +
5
+ * app), each copy has its own module-level variables. Using window ensures they
6
+ * all read/write the same manager and event-target.
7
+ */
8
+ const MANAGER_KEY = "__intlayer_editor_manager__";
9
+ const EVENTS_KEY = "__intlayer_editor_manager_events__";
10
+ /**
11
+ * Retrieves or creates a shared EventTarget for global editor manager events.
12
+ * In browser environments, stores the EventTarget on window to ensure sharing
13
+ * across multiple module instances. In SSR environments, creates a fresh
14
+ * EventTarget (no sharing needed on server-side).
15
+ *
16
+ * @returns The shared EventTarget instance for dispatching manager change events
17
+ * @private
18
+ */
19
+ const getEventTarget = () => {
20
+ if (typeof window === "undefined") return new EventTarget();
21
+ const windowGlobals = window;
22
+ if (!windowGlobals[EVENTS_KEY]) windowGlobals[EVENTS_KEY] = new EventTarget();
23
+ return windowGlobals[EVENTS_KEY];
24
+ };
25
+ /**
26
+ * Retrieves the global editor state manager instance.
27
+ * Returns null if no manager has been set or in SSR environments where
28
+ * window is undefined.
29
+ *
30
+ * @returns The global EditorStateManager instance or null if not set
31
+ */
32
+ const getGlobalEditorManager = () => {
33
+ if (typeof window === "undefined") return null;
34
+ return window[MANAGER_KEY] ?? null;
35
+ };
36
+ /**
37
+ * Sets the global editor state manager instance and notifies all listeners
38
+ * of the change through a CustomEvent.
39
+ *
40
+ * @param manager - The EditorStateManager instance to set globally, or null to clear it
41
+ */
42
+ const setGlobalEditorManager = (manager) => {
43
+ if (typeof window !== "undefined") {
44
+ const windowGlobals = window;
45
+ windowGlobals[MANAGER_KEY] = manager;
46
+ }
47
+ getEventTarget().dispatchEvent(new CustomEvent("change", { detail: manager }));
48
+ };
49
+ /**
50
+ * Registers a callback function to be invoked whenever the global editor
51
+ * manager changes. Useful for reactive updates across the application.
52
+ *
53
+ * @param changeCallback - Function to invoke with the new manager state whenever it changes
54
+ * @returns An unsubscribe function that removes the listener when called
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const unsubscribe = onGlobalEditorManagerChange((manager) => {
59
+ * console.log('Manager updated:', manager);
60
+ * });
61
+ *
62
+ * // Later, clean up the listener
63
+ * unsubscribe();
64
+ * ```
65
+ */
66
+ const onGlobalEditorManagerChange = (changeCallback) => {
67
+ const eventTarget = getEventTarget();
68
+ const eventHandler = (event) => {
69
+ changeCallback(event.detail);
70
+ };
71
+ eventTarget.addEventListener("change", eventHandler);
72
+ return () => {
73
+ eventTarget.removeEventListener("change", eventHandler);
74
+ };
75
+ };
76
+
77
+ //#endregion
78
+ export { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager };
2
79
  //# sourceMappingURL=globalManager.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"globalManager.mjs","names":[],"sources":["../../../src/core/globalManager.ts"],"sourcesContent":["import type { EditorStateManager } from './EditorStateManager';\n\n/**\n * Type for storing custom properties on the global window object.\n * Used to safely attach singleton instances across multiple module instances.\n */\ntype WindowWithEditorGlobals = typeof window & {\n [MANAGER_KEY]?: EditorStateManager | null;\n [EVENTS_KEY]?: EventTarget;\n [key: string]: unknown;\n};\n\n/**\n * Keys on window used to share the singleton across multiple module instances.\n * When bundlers include @intlayer/editor more than once (e.g. framework package +\n * app), each copy has its own module-level variables. Using window ensures they\n * all read/write the same manager and event-target.\n */\nconst MANAGER_KEY = '__intlayer_editor_manager__';\nconst EVENTS_KEY = '__intlayer_editor_manager_events__';\n\n/**\n * Retrieves or creates a shared EventTarget for global editor manager events.\n * In browser environments, stores the EventTarget on window to ensure sharing\n * across multiple module instances. In SSR environments, creates a fresh\n * EventTarget (no sharing needed on server-side).\n *\n * @returns The shared EventTarget instance for dispatching manager change events\n * @private\n */\nconst getEventTarget = (): EventTarget => {\n if (typeof window === 'undefined') {\n // SSR fallback — create a fresh one (no sharing needed server-side)\n return new EventTarget();\n }\n\n const windowGlobals = window as WindowWithEditorGlobals;\n if (!windowGlobals[EVENTS_KEY]) {\n windowGlobals[EVENTS_KEY] = new EventTarget();\n }\n\n return windowGlobals[EVENTS_KEY] as EventTarget;\n};\n\n/**\n * Retrieves the global editor state manager instance.\n * Returns null if no manager has been set or in SSR environments where\n * window is undefined.\n *\n * @returns The global EditorStateManager instance or null if not set\n */\nexport const getGlobalEditorManager = (): EditorStateManager | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n const windowGlobals = window as WindowWithEditorGlobals;\n const manager = windowGlobals[MANAGER_KEY];\n\n return manager ?? null;\n};\n\n/**\n * Sets the global editor state manager instance and notifies all listeners\n * of the change through a CustomEvent.\n *\n * @param manager - The EditorStateManager instance to set globally, or null to clear it\n */\nexport const setGlobalEditorManager = (\n manager: EditorStateManager | null\n): void => {\n if (typeof window !== 'undefined') {\n const windowGlobals = window as WindowWithEditorGlobals;\n windowGlobals[MANAGER_KEY] = manager;\n }\n\n const eventTarget = getEventTarget();\n\n eventTarget.dispatchEvent(\n new CustomEvent<EditorStateManager | null>('change', { detail: manager })\n );\n};\n\n/**\n * Registers a callback function to be invoked whenever the global editor\n * manager changes. Useful for reactive updates across the application.\n *\n * @param changeCallback - Function to invoke with the new manager state whenever it changes\n * @returns An unsubscribe function that removes the listener when called\n *\n * @example\n * ```typescript\n * const unsubscribe = onGlobalEditorManagerChange((manager) => {\n * console.log('Manager updated:', manager);\n * });\n *\n * // Later, clean up the listener\n * unsubscribe();\n * ```\n */\nexport const onGlobalEditorManagerChange = (\n changeCallback: (manager: EditorStateManager | null) => void\n): (() => void) => {\n const eventTarget = getEventTarget();\n\n const eventHandler = (event: Event) => {\n const customEvent = event as CustomEvent<EditorStateManager | null>;\n changeCallback(customEvent.detail);\n };\n\n eventTarget.addEventListener('change', eventHandler);\n\n return () => {\n eventTarget.removeEventListener('change', eventHandler);\n };\n};\n"],"mappings":"AAkBA,MAAM,EAAc,8BACd,EAAa,qCAWb,MAAoC,CACxC,GAAI,OAAO,OAAW,IAEpB,OAAO,IAAI,YAGb,IAAM,EAAgB,OAKtB,OAJK,EAAc,KACjB,EAAc,GAAc,IAAI,aAG3B,EAAc,IAUV,MACP,OAAO,OAAW,IACb,KAGa,OACQ,IAEZ,KASP,EACX,GACS,CACT,GAAI,OAAO,OAAW,IAAa,CACjC,IAAM,EAAgB,OACtB,EAAc,GAAe,EAGX,GAAgB,CAExB,cACV,IAAI,YAAuC,SAAU,CAAE,OAAQ,EAAS,CAAC,CAC1E,EAoBU,EACX,GACiB,CACjB,IAAM,EAAc,GAAgB,CAE9B,EAAgB,GAAiB,CAErC,EADoB,EACO,OAAO,EAKpC,OAFA,EAAY,iBAAiB,SAAU,EAAa,KAEvC,CACX,EAAY,oBAAoB,SAAU,EAAa"}
1
+ {"version":3,"file":"globalManager.mjs","names":[],"sources":["../../../src/core/globalManager.ts"],"sourcesContent":["import type { EditorStateManager } from './EditorStateManager';\n\n/**\n * Type for storing custom properties on the global window object.\n * Used to safely attach singleton instances across multiple module instances.\n */\ntype WindowWithEditorGlobals = typeof window & {\n [MANAGER_KEY]?: EditorStateManager | null;\n [EVENTS_KEY]?: EventTarget;\n [key: string]: unknown;\n};\n\n/**\n * Keys on window used to share the singleton across multiple module instances.\n * When bundlers include @intlayer/editor more than once (e.g. framework package +\n * app), each copy has its own module-level variables. Using window ensures they\n * all read/write the same manager and event-target.\n */\nconst MANAGER_KEY = '__intlayer_editor_manager__';\nconst EVENTS_KEY = '__intlayer_editor_manager_events__';\n\n/**\n * Retrieves or creates a shared EventTarget for global editor manager events.\n * In browser environments, stores the EventTarget on window to ensure sharing\n * across multiple module instances. In SSR environments, creates a fresh\n * EventTarget (no sharing needed on server-side).\n *\n * @returns The shared EventTarget instance for dispatching manager change events\n * @private\n */\nconst getEventTarget = (): EventTarget => {\n if (typeof window === 'undefined') {\n // SSR fallback — create a fresh one (no sharing needed server-side)\n return new EventTarget();\n }\n\n const windowGlobals = window as WindowWithEditorGlobals;\n if (!windowGlobals[EVENTS_KEY]) {\n windowGlobals[EVENTS_KEY] = new EventTarget();\n }\n\n return windowGlobals[EVENTS_KEY] as EventTarget;\n};\n\n/**\n * Retrieves the global editor state manager instance.\n * Returns null if no manager has been set or in SSR environments where\n * window is undefined.\n *\n * @returns The global EditorStateManager instance or null if not set\n */\nexport const getGlobalEditorManager = (): EditorStateManager | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n const windowGlobals = window as WindowWithEditorGlobals;\n const manager = windowGlobals[MANAGER_KEY];\n\n return manager ?? null;\n};\n\n/**\n * Sets the global editor state manager instance and notifies all listeners\n * of the change through a CustomEvent.\n *\n * @param manager - The EditorStateManager instance to set globally, or null to clear it\n */\nexport const setGlobalEditorManager = (\n manager: EditorStateManager | null\n): void => {\n if (typeof window !== 'undefined') {\n const windowGlobals = window as WindowWithEditorGlobals;\n windowGlobals[MANAGER_KEY] = manager;\n }\n\n const eventTarget = getEventTarget();\n\n eventTarget.dispatchEvent(\n new CustomEvent<EditorStateManager | null>('change', { detail: manager })\n );\n};\n\n/**\n * Registers a callback function to be invoked whenever the global editor\n * manager changes. Useful for reactive updates across the application.\n *\n * @param changeCallback - Function to invoke with the new manager state whenever it changes\n * @returns An unsubscribe function that removes the listener when called\n *\n * @example\n * ```typescript\n * const unsubscribe = onGlobalEditorManagerChange((manager) => {\n * console.log('Manager updated:', manager);\n * });\n *\n * // Later, clean up the listener\n * unsubscribe();\n * ```\n */\nexport const onGlobalEditorManagerChange = (\n changeCallback: (manager: EditorStateManager | null) => void\n): (() => void) => {\n const eventTarget = getEventTarget();\n\n const eventHandler = (event: Event) => {\n const customEvent = event as CustomEvent<EditorStateManager | null>;\n changeCallback(customEvent.detail);\n };\n\n eventTarget.addEventListener('change', eventHandler);\n\n return () => {\n eventTarget.removeEventListener('change', eventHandler);\n };\n};\n"],"mappings":";;;;;;;AAkBA,MAAM,cAAc;AACpB,MAAM,aAAa;;;;;;;;;;AAWnB,MAAM,uBAAoC;AACxC,KAAI,OAAO,WAAW,YAEpB,QAAO,IAAI,aAAa;CAG1B,MAAM,gBAAgB;AACtB,KAAI,CAAC,cAAc,YACjB,eAAc,cAAc,IAAI,aAAa;AAG/C,QAAO,cAAc;;;;;;;;;AAUvB,MAAa,+BAA0D;AACrE,KAAI,OAAO,WAAW,YACpB,QAAO;AAMT,QAHsB,OACQ,gBAEZ;;;;;;;;AASpB,MAAa,0BACX,YACS;AACT,KAAI,OAAO,WAAW,aAAa;EACjC,MAAM,gBAAgB;AACtB,gBAAc,eAAe;;AAK/B,CAFoB,gBAAgB,CAExB,cACV,IAAI,YAAuC,UAAU,EAAE,QAAQ,SAAS,CAAC,CAC1E;;;;;;;;;;;;;;;;;;;AAoBH,MAAa,+BACX,mBACiB;CACjB,MAAM,cAAc,gBAAgB;CAEpC,MAAM,gBAAgB,UAAiB;AAErC,iBADoB,MACO,OAAO;;AAGpC,aAAY,iBAAiB,UAAU,aAAa;AAEpD,cAAa;AACX,cAAY,oBAAoB,UAAU,aAAa"}
@@ -1 +1,9 @@
1
- import{getGlobalEditorManager as e,onGlobalEditorManagerChange as t,setGlobalEditorManager as n}from"./globalManager.mjs";import{CrossFrameMessenger as r}from"./CrossFrameMessenger.mjs";import{CrossFrameStateManager as i}from"./CrossFrameStateManager.mjs";import{IframeClickInterceptor as a}from"./IframeClickInterceptor.mjs";import{UrlStateManager as o}from"./UrlStateManager.mjs";import{EditorStateManager as s}from"./EditorStateManager.mjs";import{a as c,o as l,s as u}from"../components-RtOXxg9h.mjs";export{r as CrossFrameMessenger,i as CrossFrameStateManager,s as EditorStateManager,a as IframeClickInterceptor,o as UrlStateManager,c as buildClientMessengerConfig,e as getGlobalEditorManager,l as initEditorClient,t as onGlobalEditorManagerChange,n as setGlobalEditorManager,u as stopEditorClient};
1
+ import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./globalManager.mjs";
2
+ import { CrossFrameMessenger } from "./CrossFrameMessenger.mjs";
3
+ import { CrossFrameStateManager } from "./CrossFrameStateManager.mjs";
4
+ import { IframeClickInterceptor } from "./IframeClickInterceptor.mjs";
5
+ import { UrlStateManager } from "./UrlStateManager.mjs";
6
+ import { EditorStateManager } from "./EditorStateManager.mjs";
7
+ import { buildClientMessengerConfig, initEditorClient, stopEditorClient } from "./initEditorClient.mjs";
8
+
9
+ export { CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, UrlStateManager, buildClientMessengerConfig, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
@@ -1 +1,53 @@
1
- import{a as e,o as t,s as n}from"../components-RtOXxg9h.mjs";export{e as buildClientMessengerConfig,t as initEditorClient,n as stopEditorClient};
1
+ import { getGlobalEditorManager, setGlobalEditorManager } from "./globalManager.mjs";
2
+ import { EditorStateManager } from "./EditorStateManager.mjs";
3
+ import { defineIntlayerElements } from "../components/ContentSelector.mjs";
4
+ import configuration from "@intlayer/config/built";
5
+
6
+ //#region src/core/initEditorClient.ts
7
+ const buildClientMessengerConfig = () => {
8
+ const { editor } = configuration ?? {};
9
+ return {
10
+ allowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(Boolean),
11
+ postMessageFn: (payload, origin) => {
12
+ if (typeof window === "undefined") return;
13
+ if (!(window.self !== window.top)) return;
14
+ window.parent?.postMessage(payload, origin);
15
+ }
16
+ };
17
+ };
18
+ /** Reference count — tracks how many providers have called initEditorClient. */
19
+ let _clientRefCount = 0;
20
+ /**
21
+ * Initialize the Intlayer editor client singleton.
22
+ * Safe to call multiple times — returns the existing manager if already initialized.
23
+ * Increments a reference counter so nested providers don't destroy the manager
24
+ * prematurely when the inner provider unmounts.
25
+ */
26
+ const initEditorClient = () => {
27
+ _clientRefCount++;
28
+ const existing = getGlobalEditorManager();
29
+ if (existing) return existing;
30
+ const manager = new EditorStateManager({
31
+ mode: "client",
32
+ messenger: buildClientMessengerConfig(),
33
+ configuration
34
+ });
35
+ setGlobalEditorManager(manager);
36
+ defineIntlayerElements();
37
+ manager.start();
38
+ return manager;
39
+ };
40
+ /**
41
+ * Decrement the reference count and stop the global editor client singleton
42
+ * only when the last provider unmounts.
43
+ */
44
+ const stopEditorClient = () => {
45
+ _clientRefCount = Math.max(0, _clientRefCount - 1);
46
+ if (_clientRefCount > 0) return;
47
+ getGlobalEditorManager()?.stop();
48
+ setGlobalEditorManager(null);
49
+ };
50
+
51
+ //#endregion
52
+ export { buildClientMessengerConfig, initEditorClient, stopEditorClient };
53
+ //# sourceMappingURL=initEditorClient.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initEditorClient.mjs","names":[],"sources":["../../../src/core/initEditorClient.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { defineIntlayerElements } from '../components';\nimport type { MessengerConfig } from './CrossFrameMessenger';\nimport { EditorStateManager } from './EditorStateManager';\nimport {\n getGlobalEditorManager,\n setGlobalEditorManager,\n} from './globalManager';\n\nexport const buildClientMessengerConfig = (): MessengerConfig => {\n const { editor } = configuration ?? {};\n\n return {\n allowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(\n Boolean\n ) as string[],\n postMessageFn: (payload: unknown, origin: string) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n window.parent?.postMessage(payload, origin);\n },\n };\n};\n\n/** Reference count — tracks how many providers have called initEditorClient. */\nlet _clientRefCount = 0;\n\n/**\n * Initialize the Intlayer editor client singleton.\n * Safe to call multiple times — returns the existing manager if already initialized.\n * Increments a reference counter so nested providers don't destroy the manager\n * prematurely when the inner provider unmounts.\n */\nexport const initEditorClient = (): EditorStateManager => {\n _clientRefCount++;\n\n const existing = getGlobalEditorManager();\n if (existing) return existing;\n\n const manager = new EditorStateManager({\n mode: 'client',\n messenger: buildClientMessengerConfig(),\n configuration,\n });\n\n setGlobalEditorManager(manager);\n defineIntlayerElements();\n manager.start();\n\n return manager;\n};\n\n/**\n * Decrement the reference count and stop the global editor client singleton\n * only when the last provider unmounts.\n */\nexport const stopEditorClient = (): void => {\n _clientRefCount = Math.max(0, _clientRefCount - 1);\n\n if (_clientRefCount > 0) return;\n\n const manager = getGlobalEditorManager();\n manager?.stop();\n setGlobalEditorManager(null);\n};\n"],"mappings":";;;;;;AASA,MAAa,mCAAoD;CAC/D,MAAM,EAAE,WAAW,iBAAiB,EAAE;AAEtC,QAAO;EACL,gBAAgB,CAAC,QAAQ,WAAW,QAAQ,OAAO,CAAC,OAClD,QACD;EACD,gBAAgB,SAAkB,WAAmB;AACnD,OAAI,OAAO,WAAW,YAAa;AAInC,OAAI,EAFe,OAAO,SAAS,OAAO,KAEzB;AACjB,UAAO,QAAQ,YAAY,SAAS,OAAO;;EAE9C;;;AAIH,IAAI,kBAAkB;;;;;;;AAQtB,MAAa,yBAA6C;AACxD;CAEA,MAAM,WAAW,wBAAwB;AACzC,KAAI,SAAU,QAAO;CAErB,MAAM,UAAU,IAAI,mBAAmB;EACrC,MAAM;EACN,WAAW,4BAA4B;EACvC;EACD,CAAC;AAEF,wBAAuB,QAAQ;AAC/B,yBAAwB;AACxB,SAAQ,OAAO;AAEf,QAAO;;;;;;AAOT,MAAa,yBAA+B;AAC1C,mBAAkB,KAAK,IAAI,GAAG,kBAAkB,EAAE;AAElD,KAAI,kBAAkB,EAAG;AAGzB,CADgB,wBAAwB,EAC/B,MAAM;AACf,wBAAuB,KAAK"}
@@ -1 +1,16 @@
1
- import{compareUrls as e}from"./compareUrls.mjs";import{MessageKey as t}from"./messageKey.mjs";import{mergeIframeClick as n}from"./mergeIframeClick.mjs";import{getGlobalEditorManager as r,onGlobalEditorManagerChange as i,setGlobalEditorManager as a}from"./core/globalManager.mjs";import{IntlayerContentSelectorWrapperElement as o,defineIntlayerContentSelectorWrapper as s}from"./components/ContentSelectorWrapper.mjs";import{IntlayerEditedContentElement as c,defineIntlayerEditedContent as l}from"./components/EditedContent.mjs";import{CrossFrameMessenger as u}from"./core/CrossFrameMessenger.mjs";import{CrossFrameStateManager as d}from"./core/CrossFrameStateManager.mjs";import{IframeClickInterceptor as f}from"./core/IframeClickInterceptor.mjs";import{UrlStateManager as p}from"./core/UrlStateManager.mjs";import{EditorStateManager as m}from"./core/EditorStateManager.mjs";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./components-RtOXxg9h.mjs";import"./core/index.mjs";export{u as CrossFrameMessenger,d as CrossFrameStateManager,m as EditorStateManager,f as IframeClickInterceptor,x as IntlayerContentSelectorElement,o as IntlayerContentSelectorWrapperElement,c as IntlayerEditedContentElement,y as IntlayerEditorElement,t as MessageKey,p as UrlStateManager,h as buildClientMessengerConfig,e as compareUrls,s as defineIntlayerContentSelectorWrapper,l as defineIntlayerEditedContent,g as defineIntlayerEditorElement,_ as defineIntlayerElements,r as getGlobalEditorManager,v as initEditorClient,n as mergeIframeClick,i as onGlobalEditorManagerChange,a as setGlobalEditorManager,b as stopEditorClient};
1
+ import { compareUrls } from "./compareUrls.mjs";
2
+ import { MessageKey } from "./messageKey.mjs";
3
+ import { mergeIframeClick } from "./mergeIframeClick.mjs";
4
+ import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./core/globalManager.mjs";
5
+ import { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper } from "./components/ContentSelectorWrapper.mjs";
6
+ import { IntlayerEditedContentElement, defineIntlayerEditedContent } from "./components/EditedContent.mjs";
7
+ import { CrossFrameMessenger } from "./core/CrossFrameMessenger.mjs";
8
+ import { CrossFrameStateManager } from "./core/CrossFrameStateManager.mjs";
9
+ import { IframeClickInterceptor } from "./core/IframeClickInterceptor.mjs";
10
+ import { UrlStateManager } from "./core/UrlStateManager.mjs";
11
+ import { EditorStateManager } from "./core/EditorStateManager.mjs";
12
+ import { buildClientMessengerConfig, initEditorClient, stopEditorClient } from "./core/initEditorClient.mjs";
13
+ import { IntlayerEditorElement, defineIntlayerEditorElement } from "./components/IntlayerEditor.mjs";
14
+ import { IntlayerContentSelectorElement, defineIntlayerElements } from "./components/ContentSelector.mjs";
15
+
16
+ export { CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, IntlayerEditedContentElement, IntlayerEditorElement, MessageKey, UrlStateManager, buildClientMessengerConfig, compareUrls, defineIntlayerContentSelectorWrapper, defineIntlayerEditedContent, defineIntlayerEditorElement, defineIntlayerElements, getGlobalEditorManager, initEditorClient, mergeIframeClick, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
@@ -1,2 +1,8 @@
1
- import e from"@intlayer/config/built";const t=e.editor?.enabled&&typeof window<`u`&&window.self!==window.top;export{t as isEnabled};
1
+ import configuration from "@intlayer/config/built";
2
+
3
+ //#region src/isEnabled.ts
4
+ const isEnabled = configuration.editor?.enabled && typeof window !== "undefined" && window.self !== window.top;
5
+
6
+ //#endregion
7
+ export { isEnabled };
2
8
  //# sourceMappingURL=isEnabled.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n configuration.editor?.enabled && // Editor enabled in config\n typeof window !== 'undefined' && // Client side\n window.self !== window.top; // Is in iframe\n"],"mappings":"sCAEA,MAAa,EACX,EAAc,QAAQ,SACtB,OAAO,OAAW,KAClB,OAAO,OAAS,OAAO"}
1
+ {"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n configuration.editor?.enabled && // Editor enabled in config\n typeof window !== 'undefined' && // Client side\n window.self !== window.top; // Is in iframe\n"],"mappings":";;;AAEA,MAAa,YACX,cAAc,QAAQ,WACtB,OAAO,WAAW,eAClB,OAAO,SAAS,OAAO"}
@@ -1,2 +1,21 @@
1
- const e=e=>{let t=new MouseEvent(`mousedown`,{bubbles:!0,cancelable:!0,view:window}),n=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window});Object.assign(n,{iframeData:e}),Object.assign(t,{iframeData:e}),window.dispatchEvent(n),window.dispatchEvent(t)};export{e as mergeIframeClick};
1
+ //#region src/mergeIframeClick.ts
2
+ const mergeIframeClick = (event) => {
3
+ const simulatedMouseDownEvent = new MouseEvent("mousedown", {
4
+ bubbles: true,
5
+ cancelable: true,
6
+ view: window
7
+ });
8
+ const simulatedClickEvent = new MouseEvent("click", {
9
+ bubbles: true,
10
+ cancelable: true,
11
+ view: window
12
+ });
13
+ Object.assign(simulatedClickEvent, { iframeData: event });
14
+ Object.assign(simulatedMouseDownEvent, { iframeData: event });
15
+ window.dispatchEvent(simulatedClickEvent);
16
+ window.dispatchEvent(simulatedMouseDownEvent);
17
+ };
18
+
19
+ //#endregion
20
+ export { mergeIframeClick };
2
21
  //# sourceMappingURL=mergeIframeClick.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeIframeClick.mjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":"AACA,MAAa,EAAoB,GAAwB,CAEvD,IAAM,EAA0B,IAAI,WAAW,YAAa,CAC1D,QAAS,GACT,WAAY,GACZ,KAAM,OACP,CAAC,CACI,EAAsB,IAAI,WAAW,QAAS,CAClD,QAAS,GACT,WAAY,GACZ,KAAM,OACP,CAAC,CAGF,OAAO,OAAO,EAAqB,CAAE,WAAY,EAAO,CAAC,CACzD,OAAO,OAAO,EAAyB,CAAE,WAAY,EAAO,CAAC,CAG7D,OAAO,cAAc,EAAoB,CACzC,OAAO,cAAc,EAAwB"}
1
+ {"version":3,"file":"mergeIframeClick.mjs","names":[],"sources":["../../src/mergeIframeClick.ts"],"sourcesContent":["// Listener for messages from the iframe\nexport const mergeIframeClick = (event: MessageEvent) => {\n // Simulate or merge the iframe message with a click event\n const simulatedMouseDownEvent = new MouseEvent('mousedown', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n const simulatedClickEvent = new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n });\n\n // Optionally attach additional properties from the iframe message\n Object.assign(simulatedClickEvent, { iframeData: event });\n Object.assign(simulatedMouseDownEvent, { iframeData: event });\n\n // Dispatch the simulated click event on the window or a specific element\n window.dispatchEvent(simulatedClickEvent);\n window.dispatchEvent(simulatedMouseDownEvent);\n};\n"],"mappings":";AACA,MAAa,oBAAoB,UAAwB;CAEvD,MAAM,0BAA0B,IAAI,WAAW,aAAa;EAC1D,SAAS;EACT,YAAY;EACZ,MAAM;EACP,CAAC;CACF,MAAM,sBAAsB,IAAI,WAAW,SAAS;EAClD,SAAS;EACT,YAAY;EACZ,MAAM;EACP,CAAC;AAGF,QAAO,OAAO,qBAAqB,EAAE,YAAY,OAAO,CAAC;AACzD,QAAO,OAAO,yBAAyB,EAAE,YAAY,OAAO,CAAC;AAG7D,QAAO,cAAc,oBAAoB;AACzC,QAAO,cAAc,wBAAwB"}
@@ -1,2 +1,29 @@
1
- let e=function(e){return e.INTLAYER_CLIENT_READY=`INTLAYER_CLIENT_READY`,e.INTLAYER_ARE_YOU_THERE=`INTLAYER_ARE_YOU_THERE`,e.INTLAYER_EDITOR_ACTIVATE=`INTLAYER_EDITOR_ACTIVATE`,e.INTLAYER_EDITOR_ENABLED=`INTLAYER_EDITOR_ENABLED`,e.INTLAYER_CONFIGURATION=`INTLAYER_CONFIGURATION`,e.INTLAYER_CURRENT_LOCALE=`INTLAYER_CURRENT_LOCALE`,e.INTLAYER_URL_CHANGE=`INTLAYER_URL_CHANGE`,e.INTLAYER_LOCALE_DICTIONARIES_CHANGED=`INTLAYER_LOCALE_DICTIONARIES_CHANGED`,e.INTLAYER_DISTANT_DICTIONARIES_CHANGED=`INTLAYER_DISTANT_DICTIONARIES_CHANGED`,e.INTLAYER_HOVERED_CONTENT_CHANGED=`INTLAYER_HOVERED_CONTENT_CHANGED`,e.INTLAYER_FOCUSED_CONTENT_CHANGED=`INTLAYER_FOCUSED_CONTENT_CHANGED`,e.INTLAYER_EDITED_CONTENT_CHANGED=`INTLAYER_EDITED_CONTENT_CHANGED`,e.INTLAYER_IFRAME_CLICKED=`INTLAYER_IFRAME_CLICKED`,e}({});export{e as MessageKey};
1
+ //#region src/messageKey.ts
2
+ let MessageKey = /* @__PURE__ */ function(MessageKey) {
3
+ /** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */
4
+ MessageKey["INTLAYER_CLIENT_READY"] = "INTLAYER_CLIENT_READY";
5
+ /** Editor → client: asks if the client is still alive */
6
+ MessageKey["INTLAYER_ARE_YOU_THERE"] = "INTLAYER_ARE_YOU_THERE";
7
+ /** Editor → client: instructs the client to activate the editor selector */
8
+ MessageKey["INTLAYER_EDITOR_ACTIVATE"] = "INTLAYER_EDITOR_ACTIVATE";
9
+ /** Client → editor: instructs the editor that the client is enabled */
10
+ MessageKey["INTLAYER_EDITOR_ENABLED"] = "INTLAYER_EDITOR_ENABLED";
11
+ /** Client → editor: send information related the app */
12
+ MessageKey["INTLAYER_CONFIGURATION"] = "INTLAYER_CONFIGURATION";
13
+ MessageKey["INTLAYER_CURRENT_LOCALE"] = "INTLAYER_CURRENT_LOCALE";
14
+ MessageKey["INTLAYER_URL_CHANGE"] = "INTLAYER_URL_CHANGE";
15
+ /** Client → editor: load and update content */
16
+ MessageKey["INTLAYER_LOCALE_DICTIONARIES_CHANGED"] = "INTLAYER_LOCALE_DICTIONARIES_CHANGED";
17
+ MessageKey["INTLAYER_DISTANT_DICTIONARIES_CHANGED"] = "INTLAYER_DISTANT_DICTIONARIES_CHANGED";
18
+ /** Client → editor & Editor → client: Update focus and changed content */
19
+ MessageKey["INTLAYER_HOVERED_CONTENT_CHANGED"] = "INTLAYER_HOVERED_CONTENT_CHANGED";
20
+ MessageKey["INTLAYER_FOCUSED_CONTENT_CHANGED"] = "INTLAYER_FOCUSED_CONTENT_CHANGED";
21
+ MessageKey["INTLAYER_EDITED_CONTENT_CHANGED"] = "INTLAYER_EDITED_CONTENT_CHANGED";
22
+ /** Client → editor: Helper to sync iframe client reactivity on click client */
23
+ MessageKey["INTLAYER_IFRAME_CLICKED"] = "INTLAYER_IFRAME_CLICKED";
24
+ return MessageKey;
25
+ }({});
26
+
27
+ //#endregion
28
+ export { MessageKey };
2
29
  //# sourceMappingURL=messageKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageKey.mjs","names":[],"sources":["../../src/messageKey.ts"],"sourcesContent":["export enum MessageKey {\n /** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */\n INTLAYER_CLIENT_READY = 'INTLAYER_CLIENT_READY',\n /** Editor → client: asks if the client is still alive */\n INTLAYER_ARE_YOU_THERE = 'INTLAYER_ARE_YOU_THERE',\n /** Editor → client: instructs the client to activate the editor selector */\n INTLAYER_EDITOR_ACTIVATE = 'INTLAYER_EDITOR_ACTIVATE',\n /** Client → editor: instructs the editor that the client is enabled */\n INTLAYER_EDITOR_ENABLED = 'INTLAYER_EDITOR_ENABLED',\n\n /** Client → editor: send information related the app */\n INTLAYER_CONFIGURATION = 'INTLAYER_CONFIGURATION',\n INTLAYER_CURRENT_LOCALE = 'INTLAYER_CURRENT_LOCALE',\n INTLAYER_URL_CHANGE = 'INTLAYER_URL_CHANGE',\n\n /** Client → editor: load and update content */\n INTLAYER_LOCALE_DICTIONARIES_CHANGED = 'INTLAYER_LOCALE_DICTIONARIES_CHANGED',\n INTLAYER_DISTANT_DICTIONARIES_CHANGED = 'INTLAYER_DISTANT_DICTIONARIES_CHANGED',\n\n /** Client → editor & Editor → client: Update focus and changed content */\n INTLAYER_HOVERED_CONTENT_CHANGED = 'INTLAYER_HOVERED_CONTENT_CHANGED',\n INTLAYER_FOCUSED_CONTENT_CHANGED = 'INTLAYER_FOCUSED_CONTENT_CHANGED',\n INTLAYER_EDITED_CONTENT_CHANGED = 'INTLAYER_EDITED_CONTENT_CHANGED',\n\n /** Client → editor: Helper to sync iframe client reactivity on click client */\n INTLAYER_IFRAME_CLICKED = 'INTLAYER_IFRAME_CLICKED',\n}\n"],"mappings":"AAAA,IAAY,EAAL,SAAA,EAAA,OAEL,GAAA,sBAAA,wBAEA,EAAA,uBAAA,yBAEA,EAAA,yBAAA,2BAEA,EAAA,wBAAA,0BAGA,EAAA,uBAAA,yBACA,EAAA,wBAAA,0BACA,EAAA,oBAAA,sBAGA,EAAA,qCAAA,uCACA,EAAA,sCAAA,wCAGA,EAAA,iCAAA,mCACA,EAAA,iCAAA,mCACA,EAAA,gCAAA,kCAGA,EAAA,wBAAA,gCACD"}
1
+ {"version":3,"file":"messageKey.mjs","names":[],"sources":["../../src/messageKey.ts"],"sourcesContent":["export enum MessageKey {\n /** Client → editor: announces the client is ready (also used as response to ARE_YOU_THERE) */\n INTLAYER_CLIENT_READY = 'INTLAYER_CLIENT_READY',\n /** Editor → client: asks if the client is still alive */\n INTLAYER_ARE_YOU_THERE = 'INTLAYER_ARE_YOU_THERE',\n /** Editor → client: instructs the client to activate the editor selector */\n INTLAYER_EDITOR_ACTIVATE = 'INTLAYER_EDITOR_ACTIVATE',\n /** Client → editor: instructs the editor that the client is enabled */\n INTLAYER_EDITOR_ENABLED = 'INTLAYER_EDITOR_ENABLED',\n\n /** Client → editor: send information related the app */\n INTLAYER_CONFIGURATION = 'INTLAYER_CONFIGURATION',\n INTLAYER_CURRENT_LOCALE = 'INTLAYER_CURRENT_LOCALE',\n INTLAYER_URL_CHANGE = 'INTLAYER_URL_CHANGE',\n\n /** Client → editor: load and update content */\n INTLAYER_LOCALE_DICTIONARIES_CHANGED = 'INTLAYER_LOCALE_DICTIONARIES_CHANGED',\n INTLAYER_DISTANT_DICTIONARIES_CHANGED = 'INTLAYER_DISTANT_DICTIONARIES_CHANGED',\n\n /** Client → editor & Editor → client: Update focus and changed content */\n INTLAYER_HOVERED_CONTENT_CHANGED = 'INTLAYER_HOVERED_CONTENT_CHANGED',\n INTLAYER_FOCUSED_CONTENT_CHANGED = 'INTLAYER_FOCUSED_CONTENT_CHANGED',\n INTLAYER_EDITED_CONTENT_CHANGED = 'INTLAYER_EDITED_CONTENT_CHANGED',\n\n /** Client → editor: Helper to sync iframe client reactivity on click client */\n INTLAYER_IFRAME_CLICKED = 'INTLAYER_IFRAME_CLICKED',\n}\n"],"mappings":";AAAA,IAAY,aAAL;;AAEL;;AAEA;;AAEA;;AAEA;;AAGA;AACA;AACA;;AAGA;AACA;;AAGA;AACA;AACA;;AAGA;;KACD"}
@@ -1,2 +1,49 @@
1
- import { n as defineIntlayerElements, t as IntlayerContentSelectorElement } from "../ContentSelector-sIfZu4Dd.js";
2
- export { IntlayerContentSelectorElement, defineIntlayerElements };
1
+ import * as lit from "lit";
2
+ import { LitElement } from "lit";
3
+
4
+ //#region src/components/ContentSelector.d.ts
5
+ /**
6
+ * <intlayer-content-selector>
7
+ *
8
+ * A framework-agnostic web component that wraps content with Intlayer editor
9
+ * selection UI (hover outline, long-press to select, click-outside to deselect).
10
+ *
11
+ * Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).
12
+ *
13
+ * @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.
14
+ * @fires intlayer:hover - Fired on mouseenter. Bubbles.
15
+ * @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.
16
+ * @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.
17
+ *
18
+ * @prop {boolean} isSelecting - Whether this element is currently selected (external state)
19
+ * @prop {number} pressDuration - Long-press threshold in ms. Default: 250
20
+ */
21
+ declare class IntlayerContentSelectorElement extends LitElement {
22
+ static styles: lit.CSSResult;
23
+ isSelecting: boolean;
24
+ pressDuration: number;
25
+ private _isHovered;
26
+ private _isSelectingState;
27
+ private _wrapper;
28
+ private _pressTimer;
29
+ private _clickOutsideHandler;
30
+ connectedCallback(): void;
31
+ disconnectedCallback(): void;
32
+ private _clearPressTimer;
33
+ private _dispatch;
34
+ private _handleMouseDown;
35
+ private _handleMouseEnter;
36
+ private _handleMouseUpOrLeave;
37
+ private _handleClick;
38
+ private _handleBlur;
39
+ render(): lit.TemplateResult<1>;
40
+ }
41
+ /**
42
+ * Register all Intlayer custom elements.
43
+ * Call this once at application startup (inside IntlayerEditorProvider or similar).
44
+ * Safe to call multiple times — only registers elements that are not yet defined.
45
+ */
46
+ declare const defineIntlayerElements: () => void;
47
+ //#endregion
48
+ export { IntlayerContentSelectorElement, defineIntlayerElements };
49
+ //# sourceMappingURL=ContentSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/components/ContentSelector.ts"],"mappings":";;;;;;;AAwBA;;;;;;;;;;;;;cAAa,8BAAA,SAAuC,UAAA;EAAA,OAC3C,MAAA,EADmC,GAAA,CAC7B,SAAA;EAuBb,WAAA;EAGA,aAAA;EAAA,QAEiB,UAAA;EAAA,QACA,iBAAA;EAAA,QAEU,QAAA;EAAA,QAEnB,WAAA;EAAA,QACA,oBAAA;EAER,iBAAA,CAAA;EAYA,oBAAA,CAAA;EAAA,QASQ,gBAAA;EAAA,QAOA,SAAA;EAAA,QAMA,gBAAA;EAAA,QAQA,iBAAA;EAAA,QAKA,qBAAA;EAAA,QAQA,YAAA;EAAA,QAOA,WAAA;EAIR,MAAA,CAAA,GAtGa,GAAA,CAsGP,cAAA;AAAA;;;;;;cA+BK,sBAAA"}
@@ -1,2 +1,49 @@
1
- import { n as defineIntlayerContentSelectorWrapper, t as IntlayerContentSelectorWrapperElement } from "../ContentSelectorWrapper-CID6anMf.js";
2
- export { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper };
1
+ import * as lit from "lit";
2
+ import { LitElement } from "lit";
3
+
4
+ //#region src/components/ContentSelectorWrapper.d.ts
5
+ /**
6
+ * <intlayer-content-selector-wrapper>
7
+ *
8
+ * Framework-agnostic Lit element that wraps content with the Intlayer editor
9
+ * selection UI. It replaces the per-framework ContentSelectorWrapper components
10
+ * (Vue, Svelte, Solid, Preact).
11
+ *
12
+ * It reads from the global EditorStateManager singleton (set by initEditorClient)
13
+ * and conditionally renders <intlayer-content-selector> around its slot content
14
+ * when the editor is active and the app is running inside an iframe.
15
+ *
16
+ * @attr {string} key-path - JSON-serialized KeyPath[] for this content node
17
+ * @attr {string} dictionary-key - The dictionary key owning this content node
18
+ */
19
+ declare class IntlayerContentSelectorWrapperElement extends LitElement {
20
+ static styles: lit.CSSResult;
21
+ keyPathJson: string;
22
+ dictionaryKey: string;
23
+ private _editorEnabled;
24
+ private _isInIframe;
25
+ private _isSelected;
26
+ private _editedValue;
27
+ private _unsubManager;
28
+ private _unsubEnabled;
29
+ private _unsubFocused;
30
+ private _unsubEditedContent;
31
+ connectedCallback(): void;
32
+ disconnectedCallback(): void;
33
+ updated(changedProperties: Map<string, unknown>): void;
34
+ private _teardown;
35
+ private _subscribeToManager;
36
+ private _setupManagerSubscriptions;
37
+ private _getRawKeyPath;
38
+ private _getFilteredKeyPath;
39
+ private _updateEditedValue;
40
+ private _updateIsSelected;
41
+ private _handlePress;
42
+ private _handleHover;
43
+ private _handleUnhover;
44
+ render(): lit.TemplateResult<1>;
45
+ }
46
+ declare const defineIntlayerContentSelectorWrapper: () => void;
47
+ //#endregion
48
+ export { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper };
49
+ //# sourceMappingURL=ContentSelectorWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","names":[],"sources":["../../../src/components/ContentSelectorWrapper.ts"],"mappings":";;;;;;;AA+BA;;;;;;;;;;;cAAa,qCAAA,SAA8C,UAAA;EAAA,OAClD,MAAA,EAD0C,GAAA,CACpC,SAAA;EAMsC,WAAA;EACM,aAAA;EAAA,QAExC,cAAA;EAAA,QACA,WAAA;EAAA,QACA,WAAA;EAAA,QACA,YAAA;EAAA,QAET,aAAA;EAAA,QACA,aAAA;EAAA,QACA,aAAA;EAAA,QACA,mBAAA;EAER,iBAAA,CAAA;EAQA,oBAAA,CAAA;EAKA,OAAA,CAAQ,iBAAA,EAAmB,GAAA;EAAA,QAUnB,SAAA;EAAA,QAWA,mBAAA;EAAA,QAuBA,0BAAA;EAAA,QA8BA,cAAA;EAAA,QAQA,mBAAA;EAAA,QAMA,kBAAA;EAAA,QA+CA,iBAAA;EAAA,QAcA,YAAA;EAAA,QAWA,YAAA;EAAA,QAQA,cAAA;EAQR,MAAA,CAAA,GAhL8B,GAAA,CAgLxB,cAAA;AAAA;AAAA,cA0BK,oCAAA"}
@@ -1,2 +1,39 @@
1
- import { n as defineIntlayerEditedContent, t as IntlayerEditedContentElement } from "../EditedContent-2kq4wk4R.js";
2
- export { IntlayerEditedContentElement, defineIntlayerEditedContent };
1
+ import * as lit from "lit";
2
+ import { LitElement } from "lit";
3
+
4
+ //#region src/components/EditedContent.d.ts
5
+ /**
6
+ * <intlayer-edited-content>
7
+ *
8
+ * Framework-agnostic Lit element that displays edited content from the Intlayer
9
+ * editor. When the editor has an edited value for the given dictionary key and
10
+ * key path, it renders the edited value; otherwise it renders the original
11
+ * content via a slot.
12
+ *
13
+ * Always wraps content in <intlayer-content-selector-wrapper> for selection UI.
14
+ *
15
+ * @attr {string} dictionary-key - The dictionary key owning this content node
16
+ * @attr {string} key-path - JSON-serialized KeyPath[] for this content node
17
+ * @attr {string} locale - The current locale string
18
+ */
19
+ declare class IntlayerEditedContentElement extends LitElement {
20
+ static styles: lit.CSSResult;
21
+ dictionaryKey: string;
22
+ keyPathJson: string;
23
+ locale: string;
24
+ private _editedText;
25
+ private _unsubManager;
26
+ private _unsubEditedContent;
27
+ connectedCallback(): void;
28
+ disconnectedCallback(): void;
29
+ private _teardown;
30
+ private _getKeyPath;
31
+ private _resolveEditedText;
32
+ private _setupManagerSubscriptions;
33
+ private _subscribeToManager;
34
+ render(): lit.TemplateResult<1>;
35
+ }
36
+ declare const defineIntlayerEditedContent: () => void;
37
+ //#endregion
38
+ export { IntlayerEditedContentElement, defineIntlayerEditedContent };
39
+ //# sourceMappingURL=EditedContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditedContent.d.ts","names":[],"sources":["../../../src/components/EditedContent.ts"],"mappings":";;;;;;;AAwBA;;;;;;;;;;;cAAa,4BAAA,SAAqC,UAAA;EAAA,OACzC,MAAA,EADiC,GAAA,CAC3B,SAAA;EAM4C,aAAA;EACN,WAAA;EACF,MAAA;EAAA,QAEhC,WAAA;EAAA,QAET,aAAA;EAAA,QACA,mBAAA;EAER,iBAAA,CAAA;EAKA,oBAAA,CAAA;EAAA,QAKQ,SAAA;EAAA,QAOA,WAAA;EAAA,QAQA,kBAAA;EAAA,QAuCA,0BAAA;EAAA,QAUA,mBAAA;EAiBR,MAAA,CAAA,GA1Ga,GAAA,CA0GP,cAAA;AAAA;AAAA,cAYK,2BAAA"}
@@ -1,2 +1,40 @@
1
- import { n as defineIntlayerEditorElement, t as IntlayerEditorElement } from "../IntlayerEditor-ePRSIuBI.js";
2
- export { IntlayerEditorElement, defineIntlayerEditorElement };
1
+ import { LitElement } from "lit";
2
+ import { IntlayerConfig } from "@intlayer/types/config";
3
+
4
+ //#region src/components/IntlayerEditor.d.ts
5
+ /**
6
+ * <intlayer-editor>
7
+ *
8
+ * A framework-agnostic Lit element that manages the Intlayer editor singleton
9
+ * lifecycle and keeps the current locale in sync with the EditorStateManager.
10
+ *
11
+ * Drop this element once at the root of your application to activate the editor.
12
+ * It renders no UI (display: contents, empty shadow root).
13
+ *
14
+ * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as property, not attribute)
15
+ * @prop {string} locale - The active application locale (attribute/property)
16
+ *
17
+ * @example
18
+ * // Svelte
19
+ * <intlayer-editor .configuration={config} locale={$locale} />
20
+ *
21
+ * // Vue
22
+ * <intlayer-editor :configuration="config" :locale="currentLocale" />
23
+ */
24
+ declare class IntlayerEditorElement extends LitElement {
25
+ /** No visible UI — render nothing into the shadow root */
26
+ createRenderRoot(): this;
27
+ configuration?: IntlayerConfig;
28
+ locale?: string;
29
+ private _initialized;
30
+ private _unsubManager;
31
+ connectedCallback(): void;
32
+ disconnectedCallback(): void;
33
+ updated(changedProperties: Map<string | symbol, unknown>): void;
34
+ private _init;
35
+ private _syncLocale;
36
+ }
37
+ declare const defineIntlayerEditorElement: () => void;
38
+ //#endregion
39
+ export { IntlayerEditorElement, defineIntlayerEditorElement };
40
+ //# sourceMappingURL=IntlayerEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerEditor.d.ts","names":[],"sources":["../../../src/components/IntlayerEditor.ts"],"mappings":";;;;;;AA6BA;;;;;;;;;;;;;;;;;cAAa,qBAAA,SAA8B,UAAA;EA6Bd;EA3B3B,gBAAA,CAAA;EAIgC,aAAA,GAAgB,cAAA;EAEpB,MAAA;EAAA,QAEpB,YAAA;EAAA,QACA,aAAA;EAER,iBAAA,CAAA;EAKA,oBAAA,CAAA;EAWA,OAAA,CAAQ,iBAAA,EAAmB,GAAA;EAAA,QAUnB,KAAA;EAAA,QAaA,WAAA;AAAA;AAAA,cAoBG,2BAAA"}
@@ -1,5 +1,5 @@
1
- import { n as defineIntlayerElements, t as IntlayerContentSelectorElement } from "../ContentSelector-sIfZu4Dd.js";
2
- import { n as defineIntlayerContentSelectorWrapper, t as IntlayerContentSelectorWrapperElement } from "../ContentSelectorWrapper-CID6anMf.js";
3
- import { n as defineIntlayerEditedContent, t as IntlayerEditedContentElement } from "../EditedContent-2kq4wk4R.js";
4
- import { n as defineIntlayerEditorElement, t as IntlayerEditorElement } from "../IntlayerEditor-ePRSIuBI.js";
1
+ import { IntlayerContentSelectorElement, defineIntlayerElements } from "./ContentSelector.js";
2
+ import { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper } from "./ContentSelectorWrapper.js";
3
+ import { IntlayerEditedContentElement, defineIntlayerEditedContent } from "./EditedContent.js";
4
+ import { IntlayerEditorElement, defineIntlayerEditorElement } from "./IntlayerEditor.js";
5
5
  export { IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, IntlayerEditedContentElement, IntlayerEditorElement, defineIntlayerContentSelectorWrapper, defineIntlayerEditedContent, defineIntlayerEditorElement, defineIntlayerElements };
@@ -1,2 +1,51 @@
1
- import { n as MessagePayload, r as MessengerConfig, t as CrossFrameMessenger } from "../CrossFrameMessenger-CPt3Bu8S.js";
2
- export { CrossFrameMessenger, MessagePayload, MessengerConfig };
1
+ //#region src/core/CrossFrameMessenger.d.ts
2
+ type MessagePayload = {
3
+ type: string;
4
+ data?: unknown;
5
+ senderId?: string; /** Unique ID per send() call — used to deduplicate when the same payload arrives via multiple target origins */
6
+ messageId?: string;
7
+ };
8
+ type MessengerConfig = {
9
+ /**
10
+ * Origins allowed to send messages to this instance.
11
+ * Use '*' to allow all origins (not recommended for production).
12
+ */
13
+ allowedOrigins: string[];
14
+ /**
15
+ * Function used to send messages to other frames.
16
+ * Injected so the messenger is agnostic to the frame topology.
17
+ */
18
+ postMessageFn: (payload: MessagePayload, origin: string) => void;
19
+ };
20
+ type MessageHandler<T = unknown> = (data: T, senderId?: string) => void;
21
+ /**
22
+ * CrossFrameMessenger manages all cross-frame postMessage communication.
23
+ * It owns a single window message listener and routes incoming messages to
24
+ * type-specific subscribers.
25
+ *
26
+ * Replaces CommunicatorContext + useCrossFrameMessageListener across all frameworks.
27
+ */
28
+ declare class CrossFrameMessenger {
29
+ readonly senderId: string;
30
+ private readonly _config;
31
+ private readonly _subscribers;
32
+ private _windowHandler;
33
+ /** Tracks recently processed messageIds to discard duplicates (same payload sent to multiple origins) */
34
+ private readonly _seenMessageIds;
35
+ constructor(config: MessengerConfig);
36
+ /** Start listening for incoming messages on window. */
37
+ start(): void;
38
+ /** Stop listening and clean up. */
39
+ stop(): void;
40
+ /** Send a message payload to all configured target origins. */
41
+ send(type: string, data?: unknown): void;
42
+ /**
43
+ * Subscribe to messages of a given type.
44
+ * Returns an unsubscribe function.
45
+ */
46
+ subscribe<T = unknown>(type: string, handler: MessageHandler<T>): () => void;
47
+ private _handleMessage;
48
+ }
49
+ //#endregion
50
+ export { CrossFrameMessenger, MessagePayload, MessengerConfig };
51
+ //# sourceMappingURL=CrossFrameMessenger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CrossFrameMessenger.d.ts","names":[],"sources":["../../../src/core/CrossFrameMessenger.ts"],"mappings":";KAIY,cAAA;EACV,IAAA;EACA,IAAA;EACA,QAAA,WAHwB;EAKxB,SAAA;AAAA;AAAA,KAGU,eAAA;EAHV;;;AAGF;EAKE,cAAA;;;;;EAKA,aAAA,GAAgB,OAAA,EAAS,cAAA,EAAgB,MAAA;AAAA;AAAA,KAGtC,cAAA,iBAA+B,IAAA,EAAM,CAAA,EAAG,QAAA;;;AAF3C;;;;;cAWW,mBAAA;EAAA,SACF,QAAA;EAAA,iBACQ,OAAA;EAAA,iBACA,YAAA;EAAA,QAET,cAAA;EALG;EAAA,iBAOM,eAAA;cAEL,MAAA,EAAQ,eAAA;EAAA;EAMpB,KAAA,CAAA;EAqC8C;EA3B9C,IAAA,CAAA;EA2B4D;EAnB5D,IAAA,CAAK,IAAA,UAAc,IAAA;EA/BF;;;;EAkDjB,SAAA,aAAA,CAAuB,IAAA,UAAc,OAAA,EAAS,cAAA,CAAe,CAAA;EAAA,QAUrD,cAAA;AAAA"}