@intlayer/editor 8.3.4 → 8.4.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +1 -0
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/cjs/components/ContentSelector.cjs +41 -1
  4. package/dist/cjs/components/ContentSelector.cjs.map +1 -0
  5. package/dist/cjs/components/ContentSelectorWrapper.cjs +15 -0
  6. package/dist/cjs/components/ContentSelectorWrapper.cjs.map +1 -0
  7. package/dist/cjs/components/EditedContent.cjs +13 -0
  8. package/dist/cjs/components/EditedContent.cjs.map +1 -0
  9. package/dist/cjs/components/IntlayerEditor.cjs +2 -0
  10. package/dist/cjs/components/IntlayerEditor.cjs.map +1 -0
  11. package/dist/cjs/components/index.cjs +1 -1
  12. package/dist/cjs/core/CrossFrameMessenger.cjs +1 -1
  13. package/dist/cjs/core/CrossFrameMessenger.cjs.map +1 -1
  14. package/dist/cjs/core/EditorStateManager.cjs +1 -1
  15. package/dist/cjs/core/EditorStateManager.cjs.map +1 -1
  16. package/dist/cjs/core/IframeClickInterceptor.cjs +1 -1
  17. package/dist/cjs/core/IframeClickInterceptor.cjs.map +1 -1
  18. package/dist/cjs/core/UrlStateManager.cjs +1 -1
  19. package/dist/cjs/core/UrlStateManager.cjs.map +1 -1
  20. package/dist/cjs/core/globalManager.cjs +2 -0
  21. package/dist/cjs/core/globalManager.cjs.map +1 -0
  22. package/dist/cjs/core/index.cjs +1 -1
  23. package/dist/cjs/core/initEditorClient.cjs +2 -0
  24. package/dist/cjs/core/initEditorClient.cjs.map +1 -0
  25. package/dist/cjs/index.cjs +1 -1
  26. package/dist/cjs/isEnabled.cjs +2 -0
  27. package/dist/cjs/isEnabled.cjs.map +1 -0
  28. package/dist/cjs/messageKey.cjs +2 -0
  29. package/dist/cjs/messageKey.cjs.map +1 -0
  30. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +1 -0
  31. package/dist/esm/components/ContentSelector.mjs +41 -1
  32. package/dist/esm/components/ContentSelector.mjs.map +1 -0
  33. package/dist/esm/components/ContentSelectorWrapper.mjs +15 -0
  34. package/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -0
  35. package/dist/esm/components/EditedContent.mjs +13 -0
  36. package/dist/esm/components/EditedContent.mjs.map +1 -0
  37. package/dist/esm/components/IntlayerEditor.mjs +2 -0
  38. package/dist/esm/components/IntlayerEditor.mjs.map +1 -0
  39. package/dist/esm/components/index.mjs +1 -1
  40. package/dist/esm/core/CrossFrameMessenger.mjs +1 -1
  41. package/dist/esm/core/CrossFrameMessenger.mjs.map +1 -1
  42. package/dist/esm/core/EditorStateManager.mjs +1 -1
  43. package/dist/esm/core/EditorStateManager.mjs.map +1 -1
  44. package/dist/esm/core/IframeClickInterceptor.mjs +1 -1
  45. package/dist/esm/core/IframeClickInterceptor.mjs.map +1 -1
  46. package/dist/esm/core/UrlStateManager.mjs +1 -1
  47. package/dist/esm/core/UrlStateManager.mjs.map +1 -1
  48. package/dist/esm/core/globalManager.mjs +2 -0
  49. package/dist/esm/core/globalManager.mjs.map +1 -0
  50. package/dist/esm/core/index.mjs +1 -1
  51. package/dist/esm/core/initEditorClient.mjs +2 -0
  52. package/dist/esm/core/initEditorClient.mjs.map +1 -0
  53. package/dist/esm/index.mjs +1 -1
  54. package/dist/esm/isEnabled.mjs +2 -0
  55. package/dist/esm/isEnabled.mjs.map +1 -0
  56. package/dist/esm/messageKey.mjs +2 -0
  57. package/dist/esm/messageKey.mjs.map +1 -0
  58. package/dist/types/components/ContentSelector.d.ts +49 -2
  59. package/dist/types/components/ContentSelector.d.ts.map +1 -0
  60. package/dist/types/components/ContentSelectorWrapper.d.ts +49 -0
  61. package/dist/types/components/ContentSelectorWrapper.d.ts.map +1 -0
  62. package/dist/types/components/EditedContent.d.ts +39 -0
  63. package/dist/types/components/EditedContent.d.ts.map +1 -0
  64. package/dist/types/components/IntlayerEditor.d.ts +40 -0
  65. package/dist/types/components/IntlayerEditor.d.ts.map +1 -0
  66. package/dist/types/components/index.d.ts +5 -2
  67. package/dist/types/core/CrossFrameMessenger.d.ts +51 -2
  68. package/dist/types/core/CrossFrameMessenger.d.ts.map +1 -0
  69. package/dist/types/core/CrossFrameStateManager.d.ts +44 -2
  70. package/dist/types/core/CrossFrameStateManager.d.ts.map +1 -0
  71. package/dist/types/core/EditorStateManager.d.ts +73 -2
  72. package/dist/types/core/EditorStateManager.d.ts.map +1 -0
  73. package/dist/types/core/IframeClickInterceptor.d.ts +26 -2
  74. package/dist/types/core/IframeClickInterceptor.d.ts.map +1 -0
  75. package/dist/types/core/UrlStateManager.d.ts +21 -2
  76. package/dist/types/core/UrlStateManager.d.ts.map +1 -0
  77. package/dist/types/core/globalManager.d.ts +39 -0
  78. package/dist/types/core/globalManager.d.ts.map +1 -0
  79. package/dist/types/core/index.d.ts +8 -6
  80. package/dist/types/core/initEditorClient.d.ts +20 -0
  81. package/dist/types/core/initEditorClient.d.ts.map +1 -0
  82. package/dist/types/index.d.ts +13 -8
  83. package/dist/types/isEnabled.d.ts +5 -0
  84. package/dist/types/isEnabled.d.ts.map +1 -0
  85. package/dist/types/messageKey.d.ts +27 -0
  86. package/dist/types/messageKey.d.ts.map +1 -0
  87. package/package.json +10 -4
  88. package/dist/cjs/ContentSelector-BXawqqyE.cjs +0 -41
  89. package/dist/cjs/ContentSelector-BXawqqyE.cjs.map +0 -1
  90. package/dist/cjs/messagesKeys.cjs +0 -2
  91. package/dist/cjs/messagesKeys.cjs.map +0 -1
  92. package/dist/esm/ContentSelector-QN8BYkA9.mjs +0 -41
  93. package/dist/esm/ContentSelector-QN8BYkA9.mjs.map +0 -1
  94. package/dist/esm/messagesKeys.mjs +0 -2
  95. package/dist/esm/messagesKeys.mjs.map +0 -1
  96. package/dist/types/ContentSelector-rBO8c1Kp.d.ts +0 -49
  97. package/dist/types/ContentSelector-rBO8c1Kp.d.ts.map +0 -1
  98. package/dist/types/CrossFrameMessenger-CAAHntwS.d.ts +0 -48
  99. package/dist/types/CrossFrameMessenger-CAAHntwS.d.ts.map +0 -1
  100. package/dist/types/CrossFrameStateManager-DxgxsAmo.d.ts +0 -44
  101. package/dist/types/CrossFrameStateManager-DxgxsAmo.d.ts.map +0 -1
  102. package/dist/types/EditorStateManager-Ym8YfMiG.d.ts +0 -57
  103. package/dist/types/EditorStateManager-Ym8YfMiG.d.ts.map +0 -1
  104. package/dist/types/IframeClickInterceptor-Dy1raFvk.d.ts +0 -26
  105. package/dist/types/IframeClickInterceptor-Dy1raFvk.d.ts.map +0 -1
  106. package/dist/types/UrlStateManager-Bq87v4hY.d.ts +0 -21
  107. package/dist/types/UrlStateManager-Bq87v4hY.d.ts.map +0 -1
  108. package/dist/types/messagesKeys.d.ts +0 -16
  109. package/dist/types/messagesKeys.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}exports.__decorate=e;
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1 +1,41 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../ContentSelector-BXawqqyE.cjs`);exports.IntlayerContentSelectorElement=e.t,exports.defineIntlayerElements=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs`),t=require(`./ContentSelectorWrapper.cjs`),n=require(`./EditedContent.cjs`),r=require(`./IntlayerEditor.cjs`);let i=require(`lit`),a=require(`lit/decorators.js`);var o=class extends i.LitElement{constructor(...e){super(...e),this.isSelecting=!1,this.pressDuration=250,this._isHovered=!1,this._isSelectingState=!1,this._pressTimer=null,this._clickOutsideHandler=null}static{this.styles=i.css`
2
+ :host {
3
+ display: contents;
4
+ }
5
+
6
+ .wrapper {
7
+ display: inline-block;
8
+ cursor: pointer;
9
+ user-select: none;
10
+ border-radius: 0.375rem;
11
+ outline-width: 2px;
12
+ outline-offset: 4px;
13
+ outline-style: solid;
14
+ outline-color: transparent;
15
+ transition: all 100ms 50ms ease-in-out;
16
+ }
17
+
18
+ .wrapper[data-active] {
19
+ outline-color: inherit;
20
+ }
21
+ `}connectedCallback(){super.connectedCallback(),this._clickOutsideHandler=e=>{e.composedPath().includes(this)||(this._isSelectingState=!1,this._dispatch(`intlayer:click-outside`))},document.addEventListener(`mousedown`,this._clickOutsideHandler)}disconnectedCallback(){super.disconnectedCallback(),this._clickOutsideHandler&&=(document.removeEventListener(`mousedown`,this._clickOutsideHandler),null),this._clearPressTimer()}_clearPressTimer(){this._pressTimer!==null&&(clearTimeout(this._pressTimer),this._pressTimer=null)}_dispatch(e){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}))}_handleMouseDown(){this._clearPressTimer(),this._pressTimer=setTimeout(()=>{this._isSelectingState=!0,this._dispatch(`intlayer:press`)},this.pressDuration)}_handleMouseEnter(){this._isHovered=!0,this._dispatch(`intlayer:hover`)}_handleMouseUpOrLeave(){this._isHovered&&(this._isHovered=!1,this._dispatch(`intlayer:unhover`)),this._clearPressTimer()}_handleClick(e){(this.isSelecting||this._isSelectingState)&&(e.preventDefault(),e.stopPropagation())}_handleBlur(){this._isSelectingState=!1}render(){return i.html`
22
+ <span
23
+ class="wrapper"
24
+ ?data-active=${this.isSelecting||this._isSelectingState||this._isHovered}
25
+ role="button"
26
+ tabindex="0"
27
+ @mousedown=${this._handleMouseDown}
28
+ @mouseup=${this._handleMouseUpOrLeave}
29
+ @mouseleave=${this._handleMouseUpOrLeave}
30
+ @mouseenter=${this._handleMouseEnter}
31
+ @click=${this._handleClick}
32
+ @touchstart=${this._handleMouseDown}
33
+ @touchend=${this._handleMouseUpOrLeave}
34
+ @touchcancel=${this._handleMouseUpOrLeave}
35
+ @blur=${this._handleBlur}
36
+ @keyup=${()=>{}}
37
+ >
38
+ <slot></slot>
39
+ </span>
40
+ `}};e.__decorate([(0,a.property)({type:Boolean,attribute:`is-selecting`})],o.prototype,`isSelecting`,void 0),e.__decorate([(0,a.property)({type:Number,attribute:`press-duration`})],o.prototype,`pressDuration`,void 0),e.__decorate([(0,a.state)()],o.prototype,`_isHovered`,void 0),e.__decorate([(0,a.state)()],o.prototype,`_isSelectingState`,void 0),e.__decorate([(0,a.query)(`.wrapper`)],o.prototype,`_wrapper`,void 0);const s=()=>{typeof customElements>`u`||(customElements.get(`intlayer-content-selector`)||customElements.define(`intlayer-content-selector`,o),t.defineIntlayerContentSelectorWrapper(),n.defineIntlayerEditedContent(),r.defineIntlayerEditorElement())};exports.IntlayerContentSelectorElement=o,exports.defineIntlayerElements=s;
41
+ //# sourceMappingURL=ContentSelector.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.cjs","names":["LitElement"],"sources":["../../../src/components/ContentSelector.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { defineIntlayerContentSelectorWrapper } from './ContentSelectorWrapper';\nimport { defineIntlayerEditedContent } from './EditedContent';\nimport { defineIntlayerEditorElement } from './IntlayerEditor';\n\nconst DEFAULT_PRESS_DURATION = 250;\n\n/**\n * <intlayer-content-selector>\n *\n * A framework-agnostic web component that wraps content with Intlayer editor\n * selection UI (hover outline, long-press to select, click-outside to deselect).\n *\n * Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).\n *\n * @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.\n * @fires intlayer:hover - Fired on mouseenter. Bubbles.\n * @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.\n * @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.\n *\n * @prop {boolean} isSelecting - Whether this element is currently selected (external state)\n * @prop {number} pressDuration - Long-press threshold in ms. Default: 250\n */\nexport class IntlayerContentSelectorElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n\n .wrapper {\n display: inline-block;\n cursor: pointer;\n user-select: none;\n border-radius: 0.375rem;\n outline-width: 2px;\n outline-offset: 4px;\n outline-style: solid;\n outline-color: transparent;\n transition: all 100ms 50ms ease-in-out;\n }\n\n .wrapper[data-active] {\n outline-color: inherit;\n }\n `;\n\n @property({ type: Boolean, attribute: 'is-selecting' })\n isSelecting = false;\n\n @property({ type: Number, attribute: 'press-duration' })\n pressDuration = DEFAULT_PRESS_DURATION;\n\n @state() private _isHovered = false;\n @state() private _isSelectingState = false;\n\n @query('.wrapper') private _wrapper!: HTMLSpanElement;\n\n private _pressTimer: ReturnType<typeof setTimeout> | null = null;\n private _clickOutsideHandler: ((e: MouseEvent) => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n this._clickOutsideHandler = (e: MouseEvent) => {\n // composedPath() pierces shadow boundaries\n if (!e.composedPath().includes(this)) {\n this._isSelectingState = false;\n this._dispatch('intlayer:click-outside');\n }\n };\n document.addEventListener('mousedown', this._clickOutsideHandler);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._clickOutsideHandler) {\n document.removeEventListener('mousedown', this._clickOutsideHandler);\n this._clickOutsideHandler = null;\n }\n this._clearPressTimer();\n }\n\n private _clearPressTimer(): void {\n if (this._pressTimer !== null) {\n clearTimeout(this._pressTimer);\n this._pressTimer = null;\n }\n }\n\n private _dispatch(eventName: string): void {\n this.dispatchEvent(\n new CustomEvent(eventName, { bubbles: true, composed: true })\n );\n }\n\n private _handleMouseDown(): void {\n this._clearPressTimer();\n this._pressTimer = setTimeout(() => {\n this._isSelectingState = true;\n this._dispatch('intlayer:press');\n }, this.pressDuration);\n }\n\n private _handleMouseEnter(): void {\n this._isHovered = true;\n this._dispatch('intlayer:hover');\n }\n\n private _handleMouseUpOrLeave(): void {\n if (this._isHovered) {\n this._isHovered = false;\n this._dispatch('intlayer:unhover');\n }\n this._clearPressTimer();\n }\n\n private _handleClick(e: MouseEvent): void {\n if (this.isSelecting || this._isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n private _handleBlur(): void {\n this._isSelectingState = false;\n }\n\n render() {\n const isActive =\n this.isSelecting || this._isSelectingState || this._isHovered;\n return html`\n <span\n class=\"wrapper\"\n ?data-active=${isActive}\n role=\"button\"\n tabindex=\"0\"\n @mousedown=${this._handleMouseDown}\n @mouseup=${this._handleMouseUpOrLeave}\n @mouseleave=${this._handleMouseUpOrLeave}\n @mouseenter=${this._handleMouseEnter}\n @click=${this._handleClick}\n @touchstart=${this._handleMouseDown}\n @touchend=${this._handleMouseUpOrLeave}\n @touchcancel=${this._handleMouseUpOrLeave}\n @blur=${this._handleBlur}\n @keyup=${() => {}}\n >\n <slot></slot>\n </span>\n `;\n }\n}\n\n/**\n * Register all Intlayer custom elements.\n * Call this once at application startup (inside IntlayerEditorProvider or similar).\n * Safe to call multiple times — only registers elements that are not yet defined.\n */\nexport const defineIntlayerElements = (): void => {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('intlayer-content-selector')) {\n customElements.define(\n 'intlayer-content-selector',\n IntlayerContentS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ACxB,KAAK,sBAAsB;sBACxB,KAAK,sBAAsB;sBAC3B,KAAK,kBAAkB;iBAC5B,KAAK,aAAa;sBACb,KAAK,iBAAiB;oBACxB,KAAK,sBAAsB;uBACxB,KAAK,sBAAsB;gBAClC,KAAK,YAAY;qBACV,GAAG;;;;qCAlGd,CAAE,KAAM,QAAS,UAAW,eAAgB,CAAC,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,8BAG7C,CAAE,KAAM,OAAQ,UAAW,iBAAkB,CAAC,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,4BAGhD,CAAA,CAAA,EAAA,UAAA,aAAA,IAAA,GAAA,4BACA,CAAA,CAAA,EAAA,UAAA,oBAAA,IAAA,GAAA,2BAED,WAAW,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,CAsGpB,MAAa,MAAqC,CAC5C,OAAO,eAAmB,MACzB,eAAe,IAAI,4BAA4B,EAClD,eAAe,OACb,4BACA,EACD,CAEH,EAAA,sCAAsC,CACtC,EAAA,6BAA6B,CAC7B,EAAA,6BAA6B"}
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../messageKey.cjs`),t=require(`../core/globalManager.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs`);let r=require(`lit`),i=require(`lit/decorators.js`),a=require(`@intlayer/core/utils`),o=require(`@intlayer/types/nodeType`);var s=class extends r.LitElement{constructor(...e){super(...e),this.keyPathJson=`[]`,this.dictionaryKey=``,this._editorEnabled=!1,this._isInIframe=!1,this._isSelected=!1,this._editedValue=void 0,this._unsubManager=null,this._unsubEnabled=null,this._unsubFocused=null,this._unsubEditedContent=null}static{this.styles=r.css`
2
+ :host {
3
+ display: contents;
4
+ }
5
+ `}connectedCallback(){super.connectedCallback(),typeof window<`u`&&(this._isInIframe=window.self!==window.top),this._subscribeToManager()}disconnectedCallback(){super.disconnectedCallback(),this._teardown()}updated(e){if(e.has(`keyPathJson`)||e.has(`dictionaryKey`)){let e=t.getGlobalEditorManager();e&&this._updateEditedValue(e)}}_teardown(){this._unsubManager?.(),this._unsubEnabled?.(),this._unsubFocused?.(),this._unsubEditedContent?.(),this._unsubManager=null,this._unsubEnabled=null,this._unsubFocused=null,this._unsubEditedContent=null}_subscribeToManager(){let e=t.getGlobalEditorManager();e&&this._setupManagerSubscriptions(e),this._unsubManager=t.onGlobalEditorManagerChange(e=>{this._unsubEnabled?.(),this._unsubFocused?.(),this._unsubEditedContent?.(),this._unsubEnabled=null,this._unsubFocused=null,this._unsubEditedContent=null,e?this._setupManagerSubscriptions(e):(this._editorEnabled=!1,this._isSelected=!1,this._editedValue=void 0)})}_setupManagerSubscriptions(e){this._editorEnabled=e.editorEnabled.value??!1,this._updateIsSelected(e.focusedContent.value),this._updateEditedValue(e);let t=e=>{this._editorEnabled=e.detail},n=e=>{this._updateIsSelected(e.detail)},r=()=>{this._updateEditedValue(e)};e.editorEnabled.addEventListener(`change`,t),e.focusedContent.addEventListener(`change`,n),e.editedContent.addEventListener(`change`,r),this._unsubEnabled=()=>e.editorEnabled.removeEventListener(`change`,t),this._unsubFocused=()=>e.focusedContent.removeEventListener(`change`,n),this._unsubEditedContent=()=>e.editedContent.removeEventListener(`change`,r)}_getRawKeyPath(){try{return JSON.parse(this.keyPathJson)}catch{return[]}}_getFilteredKeyPath(){return this._getRawKeyPath().filter(e=>e.type!==o.NodeType.Translation)}_updateEditedValue(e){let t=this._getFilteredKeyPath();if(!this.dictionaryKey||t.length===0){this._editedValue=void 0;return}let n=this._getRawKeyPath(),r=n[n.length-1]?.type;if(r===o.NodeType.Markdown||r===o.NodeType.HTML||r===o.NodeType.Insertion||r===o.NodeType.File){this._editedValue=void 0;return}let i=e.getContentValue(this.dictionaryKey,t);if(typeof i==`object`&&i&&i.nodeType===o.NodeType.Translation){let t=e.currentLocale.value;i=t?i[o.NodeType.Translation][t]:void 0}this._editedValue=i}_updateIsSelected(e){if(!e){this._isSelected=!1;return}let t=this._getFilteredKeyPath();this._isSelected=e.dictionaryKey===this.dictionaryKey&&(e.keyPath?.length??0)>0&&(0,a.isSameKeyPath)(e.keyPath??[],t)}_handlePress(e){e.stopPropagation();let n=t.getGlobalEditorManager();n&&n.focusedContent.set({dictionaryKey:this.dictionaryKey,keyPath:this._getFilteredKeyPath()})}_handleHover(n){n.stopPropagation(),t.getGlobalEditorManager()?.messenger.send(`${e.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,{dictionaryKey:this.dictionaryKey,keyPath:this._getFilteredKeyPath()})}_handleUnhover(n){n.stopPropagation(),t.getGlobalEditorManager()?.messenger.send(`${e.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,null)}render(){if(!this._isInIframe||!this._editorEnabled)return r.html`<slot></slot>`;let e=this._editedValue,t=typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:r.html`<slot></slot>`;return r.html`
6
+ <intlayer-content-selector
7
+ ?is-selecting=${this._isSelected}
8
+ @intlayer:press=${this._handlePress}
9
+ @intlayer:hover=${this._handleHover}
10
+ @intlayer:unhover=${this._handleUnhover}
11
+ >
12
+ ${t}
13
+ </intlayer-content-selector>
14
+ `}};n.__decorate([(0,i.property)({type:String,attribute:`key-path`})],s.prototype,`keyPathJson`,void 0),n.__decorate([(0,i.property)({type:String,attribute:`dictionary-key`})],s.prototype,`dictionaryKey`,void 0),n.__decorate([(0,i.state)()],s.prototype,`_editorEnabled`,void 0),n.__decorate([(0,i.state)()],s.prototype,`_isInIframe`,void 0),n.__decorate([(0,i.state)()],s.prototype,`_isSelected`,void 0),n.__decorate([(0,i.state)()],s.prototype,`_editedValue`,void 0);const c=()=>{typeof customElements>`u`||customElements.get(`intlayer-content-selector-wrapper`)||customElements.define(`intlayer-content-selector-wrapper`,s)};exports.IntlayerContentSelectorWrapperElement=s,exports.defineIntlayerContentSelectorWrapper=c;
15
+ //# sourceMappingURL=ContentSelectorWrapper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelectorWrapper.cjs","names":["LitElement","getGlobalEditorManager","onGlobalEditorManagerChange","NodeType","MessageKey"],"sources":["../../../src/components/ContentSelectorWrapper.ts"],"sourcesContent":["import { isSameKeyPath } from '@intlayer/core/utils';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType, type TypedNodeModel } from '@intlayer/types/nodeType';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport type {\n EditorStateManager,\n FileContent,\n} from '../core/EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { MessageKey } from '../messageKey';\n\n/**\n * <intlayer-content-selector-wrapper>\n *\n * Framework-agnostic Lit element that wraps content with the Intlayer editor\n * selection UI. It replaces the per-framework ContentSelectorWrapper components\n * (Vue, Svelte, Solid, Preact).\n *\n * It reads from the global EditorStateManager singleton (set by initEditorClient)\n * and conditionally renders <intlayer-content-selector> around its slot content\n * when the editor is active and the app is running inside an iframe.\n *\n * @attr {string} key-path - JSON-serialized KeyPath[] for this content node\n * @attr {string} dictionary-key - The dictionary key owning this content node\n */\nexport class IntlayerContentSelectorWrapperElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n `;\n\n @property({ type: String, attribute: 'key-path' }) keyPathJson = '[]';\n @property({ type: String, attribute: 'dictionary-key' }) dictionaryKey = '';\n\n @state() private _editorEnabled = false;\n @state() private _isInIframe = false;\n @state() private _isSelected = false;\n @state() private _editedValue: ContentNode | undefined = undefined;\n\n private _unsubManager: (() => void) | null = null;\n private _unsubEnabled: (() => void) | null = null;\n private _unsubFocused: (() => void) | null = null;\n private _unsubEditedContent: (() => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n if (typeof window !== 'undefined') {\n this._isInIframe = window.self !== window.top;\n }\n this._subscribeToManager();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this._teardown();\n }\n\n updated(changedProperties: Map<string, unknown>): void {\n if (\n changedProperties.has('keyPathJson') ||\n changedProperties.has('dictionaryKey')\n ) {\n const manager = getGlobalEditorManager();\n if (manager) this._updateEditedValue(manager);\n }\n }\n\n private _teardown(): void {\n this._unsubManager?.();\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubManager = null;\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n }\n\n private _subscribeToManager(): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n this._setupManagerSubscriptions(manager);\n }\n // Keep listening for manager changes (handles stop + re-init cycles)\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n this._unsubEnabled?.();\n this._unsubFocused?.();\n this._unsubEditedContent?.();\n this._unsubEnabled = null;\n this._unsubFocused = null;\n this._unsubEditedContent = null;\n if (m) {\n this._setupManagerSubscriptions(m);\n } else {\n this._editorEnabled = false;\n this._isSelected = false;\n this._editedValue = undefined;\n }\n });\n }\n\n private _setupManagerSubscriptions(manager: EditorStateManager): void {\n this._editorEnabled = manager.editorEnabled.value ?? false;\n this._updateIsSelected(manager.focusedContent.value);\n this._updateEditedValue(manager);\n\n const handleEnabledChange = (e: Event) => {\n this._editorEnabled = (e as CustomEvent<boolean>).detail;\n };\n const handleFocusedChange = (e: Event) => {\n this._updateIsSelected((e as CustomEvent<FileContent | null>).detail);\n };\n const handleEditedContentChange = () => {\n this._updateEditedValue(manager);\n };\n\n manager.editorEnabled.addEventListener('change', handleEnabledChange);\n manager.focusedContent.addEventListener('change', handleFocusedChange);\n manager.editedContent.addEventListener('change', handleEditedContentChange);\n\n this._unsubEnabled = () =>\n manager.editorEnabled.removeEventListener('change', handleEnabledChange);\n this._unsubFocused = () =>\n manager.focusedContent.removeEventListener('change', handleFocusedChange);\n this._unsubEditedContent = () =>\n manager.editedContent.removeEventListener(\n 'change',\n handleEditedContentChange\n );\n }\n\n private _getRawKeyPath(): KeyPath[] {\n try {\n return JSON.parse(this.keyPathJson) as KeyPath[];\n } catch {\n return [];\n }\n }\n\n private _getFilteredKeyPath(): KeyPath[] {\n return this._getRawKeyPath().filter((k) => k.type !== NodeType.Translation);\n }\n\n private _updateEditedValue(manager: EditorStateManager): void {\n const filteredKeyPath = this._getFilteredKeyPath();\n if (!this.dictionaryKey || filteredKeyPath.length === 0) {\n this._editedValue = undefined;\n return;\n }\n\n // Node types whose display requires framework-level rendering (markdown,\n // HTML, insertion, file): do not override the slot — the framework handles\n // those. Only plain / translated strings can be substituted here.\n const rawKeyPath = this._getRawKeyPath();\n const lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;\n if (\n lastStepType === NodeType.Markdown ||\n lastStepType === NodeType.HTML ||\n lastStepType === NodeType.Insertion ||\n lastStepType === NodeType.File\n ) {\n this._editedValue = undefined;\n return;\n }\n\n let value = manager.getContentValue(this.dictionaryKey, filteredKeyPath);\n\n // getContentNodeByKeyPath resolves translation nodes only at intermediate\n // steps, not the final leaf. Resolve manually when the returned value is\n // still a translation object (happens when Translation steps are filtered\n // out and the leaf IS the translation object).\n if (\n value !== null &&\n value !== undefined &&\n typeof value === 'object' &&\n value.nodeType === NodeType.Translation\n ) {\n const locale = manager.currentLocale.value as string | undefined;\n // TypedNodeModel<Translation, …> structurally satisfies TypedNode<BaseNode>\n // (both have nodeType), so this narrowing cast is sound.\n const node = value as TypedNodeModel<\n typeof NodeType.Translation,\n Record<string, ContentNode>\n >;\n value = locale ? node[NodeType.Translation][locale] : undefined;\n }\n\n this._editedValue = value;\n }\n\n private _updateIsSelected(\n focusedContent: FileContent | null | undefined\n ): void {\n if (!focusedContent) {\n this._isSelected = false;\n return;\n }\n const keyPath = this._getFilteredKeyPath();\n this._isSelected =\n focusedContent.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], keyPath);\n }\n\n private _handlePress(e: Event): void {\n // Stop propagation so nested wrappers don't also fire (composed + bubbles)\n e.stopPropagation();\n const manager = getGlobalEditorManager();\n if (!manager) return;\n manager.focusedContent.set({\n dictionaryKey: this.dictionaryKey,\n keyPath: this._getFilteredKeyPath(),\n });\n }\n\n private _handleHover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n { dictionaryKey: this.dictionaryKey, keyPath: this._getFilteredKeyPath() }\n );\n }\n\n private _handleUnhover(e: Event): void {\n e.stopPropagation();\n getGlobalEditorManager()?.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n null\n );\n }\n\n render() {\n if (!this._isInIframe || !this._editorEnabled) {\n return html`<slot></slot>`;\n }\n\n const editedValue = this._editedValue;\n const displayedContent =\n typeof editedValue === 'string' ||\n typeof editedValue === 'number' ||\n typeof editedValue === 'boolean'\n ? editedValue\n : html`<slot></slot>`;\n\n return html`\n <intlayer-content-selector\n ?is-selecting=${this._isSelected}\n @intlayer:press=${this._handlePress}\n @intlayer:hover=${this._handleHover}\n @intlayer:unhover=${this._handleUnhover}\n >\n ${displayedContent}\n </intlayer-content-selector>\n `;\n }\n}\n\nexport const defineIntlayerContentSelectorWrapper = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-content-selector-wrapper')) {\n customElements.define(\n 'intlayer-content-selector-wrapper',\n IntlayerContentSelectorWrapperElement\n );\n }\n};\n"],"mappings":"oYA8BA,IAAa,EAAb,cAA2DA,EAAAA,UAAW,gDAOH,wBACQ,uBAEvC,oBACH,oBACA,qBAC0B,IAAA,sBAEZ,wBACA,wBACA,8BACM,wBAjBnC,EAAA,GAAG;;;;IAmBnB,mBAA0B,CACxB,MAAM,mBAAmB,CACrB,OAAO,OAAW,MACpB,KAAK,YAAc,OAAO,OAAS,OAAO,KAE5C,KAAK,qBAAqB,CAG5B,sBAA6B,CAC3B,MAAM,s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B,CACnB,EAAA,wBAAwB,EAAE,UAAU,KAClC,GAAGG,EAAAA,WAAW,iCAAiC,OAC/C,CAAE,cAAe,KAAK,cAAe,QAAS,KAAK,qBAAqB,CAAE,CAC3E,CAGH,eAAuB,EAAgB,CACrC,EAAE,iBAAiB,CACnB,EAAA,wBAAwB,EAAE,UAAU,KAClC,GAAGA,EAAAA,WAAW,iCAAiC,OAC/C,KACD,CAGH,QAAS,CACP,GAAI,CAAC,KAAK,aAAe,CAAC,KAAK,eAC7B,MAAO,GAAA,IAAI,gBAGb,IAAM,EAAc,KAAK,aACnB,EACJ,OAAO,GAAgB,UACvB,OAAO,GAAgB,UACvB,OAAO,GAAgB,UACnB,EACA,EAAA,IAAI,gBAEV,MAAO,GAAA,IAAI;;wBAES,KAAK,YAAY;0BACf,KAAK,aAAa;0BAClB,KAAK,aAAa;4BAChB,KAAK,eAAe;;UAEtC,EAAiB;;qCA5Nf,CAAE,KAAM,OAAQ,UAAW,WAAY,CAAC,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,8BACxC,CAAE,KAAM,OAAQ,UAAW,iBAAkB,CAAC,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,4BAEhD,CAAA,CAAA,EAAA,UAAA,iBAAA,IAAA,GAAA,4BACA,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,4BACA,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,4BACA,CAAA,CAAA,EAAA,UAAA,eAAA,IAAA,GAAA,CA4NV,MAAa,MAAmD,CAC1D,OAAO,eAAmB,KAEzB,eAAe,IAAI,oCAAoC,EAC1D,eAAe,OACb,oCACA,EACD"}
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../core/globalManager.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs`);let n=require(`lit`),r=require(`lit/decorators.js`),i=require(`@intlayer/core/interpreter`);var a=class extends n.LitElement{constructor(...e){super(...e),this.dictionaryKey=``,this.keyPathJson=`[]`,this.locale=``,this._editedText=null,this._unsubManager=null,this._unsubEditedContent=null}static{this.styles=n.css`
2
+ :host {
3
+ display: contents;
4
+ }
5
+ `}connectedCallback(){super.connectedCallback(),this._subscribeToManager()}disconnectedCallback(){super.disconnectedCallback(),this._teardown()}_teardown(){this._unsubManager?.(),this._unsubEditedContent?.(),this._unsubManager=null,this._unsubEditedContent=null}_getKeyPath(){try{return JSON.parse(this.keyPathJson)}catch{return[]}}_resolveEditedText(e){let t=this._getKeyPath(),n=e.getContentValue(this.dictionaryKey,t);if(n==null){this._editedText=null;return}if(typeof n==`string`||typeof n==`number`){this._editedText=String(n);return}if(typeof n==`object`){let e=this.locale||void 0,r=(0,i.getContent)(n,{locale:e,dictionaryKey:this.dictionaryKey,keyPath:t},(0,i.getBasePlugins)(e));typeof r==`string`||typeof r==`number`?this._editedText=String(r):(console.error(`[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(r)}`),this._editedText=null);return}this._editedText=null}_setupManagerSubscriptions(e){this._resolveEditedText(e);let t=()=>this._resolveEditedText(e);e.editedContent.addEventListener(`change`,t),this._unsubEditedContent=()=>e.editedContent.removeEventListener(`change`,t)}_subscribeToManager(){let t=e.getGlobalEditorManager();t&&this._setupManagerSubscriptions(t),this._unsubManager=e.onGlobalEditorManagerChange(e=>{this._unsubEditedContent?.(),this._unsubEditedContent=null,e?this._setupManagerSubscriptions(e):this._editedText=null})}render(){return n.html`
6
+ <intlayer-content-selector-wrapper
7
+ key-path=${this.keyPathJson}
8
+ dictionary-key=${this.dictionaryKey}
9
+ >
10
+ ${this._editedText===null?n.html`<slot></slot>`:this._editedText}
11
+ </intlayer-content-selector-wrapper>
12
+ `}};t.__decorate([(0,r.property)({type:String,attribute:`dictionary-key`})],a.prototype,`dictionaryKey`,void 0),t.__decorate([(0,r.property)({type:String,attribute:`key-path`})],a.prototype,`keyPathJson`,void 0),t.__decorate([(0,r.property)({type:String,attribute:`locale`})],a.prototype,`locale`,void 0),t.__decorate([(0,r.state)()],a.prototype,`_editedText`,void 0);const o=()=>{typeof customElements>`u`||customElements.get(`intlayer-edited-content`)||customElements.define(`intlayer-edited-content`,a)};exports.IntlayerEditedContentElement=a,exports.defineIntlayerEditedContent=o;
13
+ //# sourceMappingURL=EditedContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditedContent.cjs","names":["LitElement","getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../src/components/EditedContent.ts"],"sourcesContent":["import { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport type { EditorStateManager } from '../core/EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\n\n/**\n * <intlayer-edited-content>\n *\n * Framework-agnostic Lit element that displays edited content from the Intlayer\n * editor. When the editor has an edited value for the given dictionary key and\n * key path, it renders the edited value; otherwise it renders the original\n * content via a slot.\n *\n * Always wraps content in <intlayer-content-selector-wrapper> for selection UI.\n *\n * @attr {string} dictionary-key - The dictionary key owning this content node\n * @attr {string} key-path - JSON-serialized KeyPath[] for this content node\n * @attr {string} locale - The current locale string\n */\nexport class IntlayerEditedContentElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n `;\n\n @property({ type: String, attribute: 'dictionary-key' }) dictionaryKey = '';\n @property({ type: String, attribute: 'key-path' }) keyPathJson = '[]';\n @property({ type: String, attribute: 'locale' }) locale = '';\n\n @state() private _editedText: string | null = null;\n\n private _unsubManager: (() => void) | null = null;\n private _unsubEditedContent: (() => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n this._subscribeToManager();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this._teardown();\n }\n\n private _teardown(): void {\n this._unsubManager?.();\n this._unsubEditedContent?.();\n this._unsubManager = null;\n this._unsubEditedContent = null;\n }\n\n private _getKeyPath(): KeyPath[] {\n try {\n return JSON.parse(this.keyPathJson);\n } catch {\n return [];\n }\n }\n\n private _resolveEditedText(manager: EditorStateManager): void {\n const keyPath = this._getKeyPath();\n const editedValue = manager.getContentValue(this.dictionaryKey, keyPath);\n\n if (editedValue === undefined || editedValue === null) {\n this._editedText = null;\n return;\n }\n\n if (typeof editedValue === 'string' || typeof editedValue === 'number') {\n this._editedText = String(editedValue);\n return;\n }\n\n if (typeof editedValue === 'object') {\n const locale = this.locale || undefined;\n const transformed = getContent(\n editedValue,\n {\n locale: locale as any,\n dictionaryKey: this.dictionaryKey,\n keyPath,\n },\n getBasePlugins(locale as any)\n );\n if (typeof transformed === 'string' || typeof transformed === 'number') {\n this._editedText = String(transformed);\n } else {\n console.error(\n `[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`\n );\n this._editedText = null;\n }\n return;\n }\n\n this._editedText = null;\n }\n\n private _setupManagerSubscriptions(manager: EditorStateManager): void {\n this._resolveEditedText(manager);\n\n const handleChange = () => this._resolveEditedText(manager);\n manager.editedContent.addEventListener('change', handleChange);\n\n this._unsubEditedContent = () =>\n manager.editedContent.removeEventListener('change', handleChange);\n }\n\n private _subscribeToManager(): void {\n const manager = getGlobalEditorManager();\n if (manager) {\n this._setupManagerSubscriptions(manager);\n }\n\n this._unsubManager = onGlobalEditorManagerChange((m) => {\n this._unsubEditedContent?.();\n this._unsubEditedContent = null;\n if (m) {\n this._setupManagerSubscriptions(m);\n } else {\n this._editedText = null;\n }\n });\n }\n\n render() {\n return html`\n <intlayer-content-selector-wrapper\n key-path=${this.keyPathJson}\n dictionary-key=${this.dictionaryKey}\n >\n ${this._editedText !== null ? this._editedText : html`<slot></slot>`}\n </intlayer-content-selector-wrapper>\n `;\n }\n}\n\nexport const defineIntlayerEditedContent = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-edited-content')) {\n customElements.define(\n 'intlayer-edited-content',\n IntlayerEditedContentElement\n );\n }\n};\n"],"mappings":"qUAwBA,IAAa,EAAb,cAAkDA,EAAAA,UAAW,kDAOc,oBACR,iBACP,oBAEZ,wBAED,8BACM,wBAbnC,EAAA,GAAG;;;;IAenB,mBAA0B,CACxB,MAAM,mBAAmB,CACzB,KAAK,qBAAqB,CAG5B,sBAA6B,CAC3B,MAAM,sBAAsB,CAC5B,KAAK,WAAW,CAGlB,WAA0B,CACxB,KAAK,iBAAiB,CACtB,KAAK,uBAAuB,CAC5B,KAAK,cAAgB,KACrB,KAAK,oBAAsB,KAG7B,aAAiC,CAC/B,GAAI,CACF,OAAO,KAAK,MAAM,KAAK,YAAY,MAC7B,CACN,MAAO,EAAE,EAIb,mBAA2B,EAAmC,CAC5D,IAAM,EAAU,KAAK,aAAa,CAC5B,EAAc,EAAQ,gBAAgB,KAAK,cAAe,EAAQ,CAExE,GAAI,GAA6C,KAAM,CACrD,KAAK,YAAc,KACnB,OAGF,GAAI,OAAO,GAAgB,UAAY,OAAO,GAAgB,SAAU,CACtE,KAAK,YAAc,OAAO,EAAY,CACtC,OAGF,GAAI,OAAO,GAAgB,SAAU,CACnC,IAAM,EAAS,KAAK,QAAU,IAAA,GACxB,GAAA,EAAA,EAAA,YACJ,EACA,CACU,SACR,cAAe,KAAK,cACpB,UACD,EAAA,EAAA,EAAA,gBACc,EAAc,CAC9B,CACG,OAAO,GAAgB,UAAY,OAAO,GAAgB,SAC5D,KAAK,YAAc,OAAO,EAAY,EAEtC,QAAQ,MACN,sFAAsF,KAAK,UAAU,EAAY,GAClH,CACD,KAAK,YAAc,MAErB,OAGF,KAAK,YAAc,KAGrB,2BAAmC,EAAmC,CACpE,KAAK,mBAAmB,EAAQ,CAEhC,IAAM,MAAqB,KAAK,mBAAmB,EAAQ,CAC3D,EAAQ,cAAc,iBAAiB,SAAU,EAAa,CAE9D,KAAK,wBACH,EAAQ,cAAc,oBAAoB,SAAU,EAAa,CAGrE,qBAAoC,CAClC,IAAM,EAAUC,EAAAA,wBAAwB,CACpC,GACF,KAAK,2BAA2B,EAAQ,CAG1C,KAAK,cAAgBC,EAAAA,4BAA6B,GAAM,CACtD,KAAK,uBAAuB,CAC5B,KAAK,oBAAsB,KACvB,EACF,KAAK,2BAA2B,EAAE,CAElC,KAAK,YAAc,MAErB,CAGJ,QAAS,CACP,MAAO,GAAA,IAAI;;mBAEI,KAAK,YAAY;yBACX,KAAK,cAAc;;UAElC,KAAK,cAAgB,KAA0B,EAAA,IAAI,gBAAvB,KAAK,YAAkC;;qCA1GjE,CAAE,KAAM,OAAQ,UAAW,iBAAkB,CAAC,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,8BAC9C,CAAE,KAAM,OAAQ,UAAW,WAAY,CAAC,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,8BACxC,CAAE,KAAM,OAAQ,UAAW,SAAU,CAAC,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,4BAExC,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,CA4GV,MAAa,MAA0C,CACjD,OAAO,eAAmB,KAEzB,eAAe,IAAI,0BAA0B,EAChD,eAAe,OACb,0BACA,EACD"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../core/globalManager.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs`),n=require(`../core/initEditorClient.cjs`);let r=require(`lit`),i=require(`lit/decorators.js`);var a=class extends r.LitElement{constructor(...e){super(...e),this._initialized=!1,this._unsubManager=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._init()}disconnectedCallback(){super.disconnectedCallback(),this._unsubManager?.(),this._unsubManager=null,this._initialized&&=(n.stopEditorClient(),!1)}updated(e){e.has(`configuration`)&&!this._initialized&&this._init(),e.has(`locale`)&&this.locale&&this._syncLocale(this.locale)}_init(){this._initialized||(n.initEditorClient(),this._initialized=!0,this.locale&&this._syncLocale(this.locale))}_syncLocale(t){let n=e.getGlobalEditorManager();n?n.currentLocale.set(t):(this._unsubManager?.(),this._unsubManager=e.onGlobalEditorManagerChange(e=>{e&&(this._unsubManager?.(),this._unsubManager=null,e.currentLocale.set(t))}))}};t.__decorate([(0,i.property)({attribute:!1})],a.prototype,`configuration`,void 0),t.__decorate([(0,i.property)({type:String})],a.prototype,`locale`,void 0);const o=()=>{typeof customElements>`u`||customElements.get(`intlayer-editor`)||customElements.define(`intlayer-editor`,a)};exports.IntlayerEditorElement=a,exports.defineIntlayerEditorElement=o;
2
+ //# sourceMappingURL=IntlayerEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerEditor.cjs","names":["LitElement","getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../src/components/IntlayerEditor.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from '../core/globalManager';\nimport { initEditorClient, stopEditorClient } from '../core/initEditorClient';\n\n/**\n * <intlayer-editor>\n *\n * A framework-agnostic Lit element that manages the Intlayer editor singleton\n * lifecycle and keeps the current locale in sync with the EditorStateManager.\n *\n * Drop this element once at the root of your application to activate the editor.\n * It renders no UI (display: contents, empty shadow root).\n *\n * @prop {IntlayerConfig} configuration - The Intlayer config (required; set as property, not attribute)\n * @prop {string} locale - The active application locale (attribute/property)\n *\n * @example\n * // Svelte\n * <intlayer-editor .configuration={config} locale={$locale} />\n *\n * // Vue\n * <intlayer-editor :configuration=\"config\" :locale=\"currentLocale\" />\n */\nexport class IntlayerEditorElement extends LitElement {\n /** No visible UI — render nothing into the shadow root */\n createRenderRoot(): this {\n return this;\n }\n\n @property({ attribute: false }) configuration?: IntlayerConfig;\n\n @property({ type: String }) locale?: string;\n\n private _initialized = false;\n private _unsubManager: (() => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n this._init();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this._unsubManager?.();\n this._unsubManager = null;\n\n if (this._initialized) {\n stopEditorClient();\n this._initialized = false;\n }\n }\n\n updated(changedProperties: Map<string | symbol, unknown>): void {\n if (changedProperties.has('configuration') && !this._initialized) {\n this._init();\n }\n\n if (changedProperties.has('locale') && this.locale) {\n this._syncLocale(this.locale);\n }\n }\n\n private _init(): void {\n if (this._initialized) return;\n\n initEditorClient();\n\n this._initialized = true;\n\n // Sync locale immediately after init if it is already set\n if (this.locale) {\n this._syncLocale(this.locale);\n }\n }\n\n private _syncLocale(locale: string): void {\n const manager = getGlobalEditorManager();\n\n if (manager) {\n manager.currentLocale.set(locale as Locale);\n } else {\n // Manager may not be ready yet — wait for it\n this._unsubManager?.();\n this._unsubManager = onGlobalEditorManagerChange((manager) => {\n if (manager) {\n this._unsubManager?.();\n this._unsubManager = null;\n\n manager.currentLocale.set(locale as Locale);\n }\n });\n }\n }\n}\n\nexport const defineIntlayerEditorElement = (): void => {\n if (typeof customElements === 'undefined') return;\n\n if (!customElements.get('intlayer-editor')) {\n customElements.define('intlayer-editor', IntlayerEditorElement);\n }\n};\n"],"mappings":"uUA6BA,IAAa,EAAb,cAA2CA,EAAAA,UAAW,iDAU7B,sBACsB,KAT7C,kBAAyB,CACvB,OAAO,KAUT,mBAA0B,CACxB,MAAM,mBAAmB,CACzB,KAAK,OAAO,CAGd,sBAA6B,CAC3B,MAAM,sBAAsB,CAC5B,KAAK,iBAAiB,CACtB,KAAK,cAAgB,KAErB,AAEE,KAAK,gBADL,EAAA,kBAAkB,CACE,IAIxB,QAAQ,EAAwD,CAC1D,EAAkB,IAAI,gBAAgB,EAAI,CAAC,KAAK,cAClD,KAAK,OAAO,CAGV,EAAkB,IAAI,SAAS,EAAI,KAAK,QAC1C,KAAK,YAAY,KAAK,OAAO,CAIjC,OAAsB,CAChB,KAAK,eAET,EAAA,kBAAkB,CAElB,KAAK,aAAe,GAGhB,KAAK,QACP,KAAK,YAAY,KAAK,OAAO,EAIjC,YAAoB,EAAsB,CACxC,IAAM,EAAUC,EAAAA,wBAAwB,CAEpC,EACF,EAAQ,cAAc,IAAI,EAAiB,EAG3C,KAAK,iBAAiB,CACtB,KAAK,cAAgBC,EAAAA,4BAA6B,GAAY,CACxD,IACF,KAAK,iBAAiB,CACtB,KAAK,cAAgB,KAErB,EAAQ,cAAc,IAAI,EAAiB,GAE7C,iCA7DI,CAAE,UAAW,GAAO,CAAC,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,8BAErB,CAAE,KAAM,OAAQ,CAAC,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,CAgE7B,MAAa,MAA0C,CACjD,OAAO,eAAmB,KAEzB,eAAe,IAAI,kBAAkB,EACxC,eAAe,OAAO,kBAAmB,EAAsB"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../ContentSelector-BXawqqyE.cjs`);exports.IntlayerContentSelectorElement=e.t,exports.defineIntlayerElements=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./ContentSelectorWrapper.cjs`),t=require(`./EditedContent.cjs`),n=require(`./IntlayerEditor.cjs`),r=require(`./ContentSelector.cjs`);exports.IntlayerContentSelectorElement=r.IntlayerContentSelectorElement,exports.IntlayerContentSelectorWrapperElement=e.IntlayerContentSelectorWrapperElement,exports.IntlayerEditedContentElement=t.IntlayerEditedContentElement,exports.IntlayerEditorElement=n.IntlayerEditorElement,exports.defineIntlayerContentSelectorWrapper=e.defineIntlayerContentSelectorWrapper,exports.defineIntlayerEditedContent=t.defineIntlayerEditedContent,exports.defineIntlayerEditorElement=n.defineIntlayerEditorElement,exports.defineIntlayerElements=r.defineIntlayerElements;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../compareUrls.cjs`),t=()=>Math.random().toString(36).slice(2);var n=class{constructor(e){this._subscribers=new Map,this._windowHandler=null,this._config=e,this.senderId=t()}start(){typeof window>`u`||this._windowHandler||(this._windowHandler=e=>{this._handleMessage(e)},window.addEventListener(`message`,this._windowHandler))}stop(){this._windowHandler&&=(window.removeEventListener(`message`,this._windowHandler),null)}send(e,t){let n={type:e,data:t,senderId:this.senderId};for(let e of this._config.allowedOrigins)e&&this._config.postMessageFn(n,e)}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e).add(t),()=>{this._subscribers.get(e)?.delete(t)}}_handleMessage(t){let n=t.data;if(!n||typeof n!=`object`)return;let{type:r,data:i,senderId:a}=n;if(!r||typeof r!=`string`||a===this.senderId)return;let{allowedOrigins:o}=this._config;if(!(!o||o.length===0||o.includes(`*`)||o.filter(e=>!!e&&e!==``).some(n=>e.compareUrls(n,t.origin))))return;let s=this._subscribers.get(r);if(s)for(let e of s)e(i,a)}};exports.CrossFrameMessenger=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../compareUrls.cjs`),t=()=>Math.random().toString(36).slice(2);var n=class{constructor(e){this._subscribers=new Map,this._windowHandler=null,this._seenMessageIds=new Set,this._config=e,this.senderId=t()}start(){typeof window>`u`||this._windowHandler||(this._windowHandler=e=>{this._handleMessage(e)},window.addEventListener(`message`,this._windowHandler))}stop(){this._windowHandler&&=(window.removeEventListener(`message`,this._windowHandler),null)}send(e,n){let r={type:e,data:n,senderId:this.senderId,messageId:t()};for(let e of this._config.allowedOrigins)e&&this._config.postMessageFn(r,e)}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e).add(t),()=>{this._subscribers.get(e)?.delete(t)}}_handleMessage(t){let n=t.data;if(!n||typeof n!=`object`)return;let{type:r,data:i,senderId:a,messageId:o}=n;if(!r||typeof r!=`string`||a===this.senderId)return;if(o){if(this._seenMessageIds.has(o))return;this._seenMessageIds.add(o),this._seenMessageIds.size>200&&this._seenMessageIds.clear()}let{allowedOrigins:s}=this._config;if(!(!s||s.length===0||s.includes(`*`)||s.filter(e=>!!e&&e!==``).some(n=>e.compareUrls(n,t.origin))))return;let c=this._subscribers.get(r);if(c)for(let e of c)e(i,a)}};exports.CrossFrameMessenger=n;
2
2
  //# sourceMappingURL=CrossFrameMessenger.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CrossFrameMessenger.cjs","names":["compareUrls"],"sources":["../../../src/core/CrossFrameMessenger.ts"],"sourcesContent":["import { compareUrls } from '../compareUrls';\n\nconst randomUUID = (): string => Math.random().toString(36).slice(2);\n\nexport type MessagePayload = {\n type: string;\n data?: unknown;\n senderId?: string;\n};\n\nexport type MessengerConfig = {\n /**\n * Origins allowed to send messages to this instance.\n * Use '*' to allow all origins (not recommended for production).\n */\n allowedOrigins: string[];\n /**\n * Function used to send messages to other frames.\n * Injected so the messenger is agnostic to the frame topology.\n */\n postMessageFn: (payload: MessagePayload, origin: string) => void;\n};\n\ntype MessageHandler<T = unknown> = (data: T, senderId?: string) => void;\n\n/**\n * CrossFrameMessenger manages all cross-frame postMessage communication.\n * It owns a single window message listener and routes incoming messages to\n * type-specific subscribers.\n *\n * Replaces CommunicatorContext + useCrossFrameMessageListener across all frameworks.\n */\nexport class CrossFrameMessenger {\n readonly senderId: string;\n private readonly _config: MessengerConfig;\n private readonly _subscribers = new Map<string, Set<MessageHandler>>();\n private _windowHandler: ((event: MessageEvent) => void) | null = null;\n\n constructor(config: MessengerConfig) {\n this._config = config;\n this.senderId = randomUUID();\n }\n\n /** Start listening for incoming messages on window. */\n start(): void {\n if (typeof window === 'undefined') return;\n if (this._windowHandler) return;\n this._windowHandler = (event: MessageEvent<MessagePayload>) => {\n this._handleMessage(event);\n };\n window.addEventListener('message', this._windowHandler);\n }\n\n /** Stop listening and clean up. */\n stop(): void {\n if (this._windowHandler) {\n window.removeEventListener('message', this._windowHandler);\n this._windowHandler = null;\n }\n }\n\n /** Send a message payload to all configured target origins. */\n send(type: string, data?: unknown): void {\n const payload: MessagePayload = { type, data, senderId: this.senderId };\n for (const origin of this._config.allowedOrigins) {\n if (origin) {\n this._config.postMessageFn(payload, origin);\n }\n }\n }\n\n /**\n * Subscribe to messages of a given type.\n * Returns an unsubscribe function.\n */\n subscribe<T = unknown>(type: string, handler: MessageHandler<T>): () => void {\n if (!this._subscribers.has(type)) {\n this._subscribers.set(type, new Set());\n }\n this._subscribers.get(type)!.add(handler as MessageHandler);\n return () => {\n this._subscribers.get(type)?.delete(handler as MessageHandler);\n };\n }\n\n private _handleMessage(event: MessageEvent<MessagePayload>): void {\n const payload = event.data;\n if (!payload || typeof payload !== 'object') return;\n\n const { type, data, senderId: msgSenderId } = payload;\n if (!type || typeof type !== 'string') return;\n\n // Ignore messages originating from this instance\n if (msgSenderId === this.senderId) return;\n\n // Validate message origin\n const { allowedOrigins } = this._config;\n const isAllowed =\n !allowedOrigins ||\n allowedOrigins.length === 0 ||\n allowedOrigins.includes('*') ||\n allowedOrigins\n .filter((url) => Boolean(url) && url !== '')\n .some((url) => compareUrls(url, event.origin));\n\n if (!isAllowed) return;\n\n const handlers = this._subscribers.get(type);\n if (handlers) {\n for (const handler of handlers) {\n handler(data, msgSenderId);\n }\n }\n }\n}\n"],"mappings":"yGAEM,MAA2B,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CA8BpE,IAAa,EAAb,KAAiC,CAM/B,YAAY,EAAyB,mBAHL,IAAI,wBAC6B,KAG/D,KAAK,QAAU,EACf,KAAK,SAAW,GAAY,CAI9B,OAAc,CACR,OAAO,OAAW,KAClB,KAAK,iBACT,KAAK,eAAkB,GAAwC,CAC7D,KAAK,eAAe,EAAM,EAE5B,OAAO,iBAAiB,UAAW,KAAK,eAAe,EAIzD,MAAa,CACX,AAEE,KAAK,kBADL,OAAO,oBAAoB,UAAW,KAAK,eAAe,CACpC,MAK1B,KAAK,EAAc,EAAsB,CACvC,IAAM,EAA0B,CAAE,OAAM,OAAM,SAAU,KAAK,SAAU,CACvE,IAAK,IAAM,KAAU,KAAK,QAAQ,eAC5B,GACF,KAAK,QAAQ,cAAc,EAAS,EAAO,CASjD,UAAuB,EAAc,EAAwC,CAK3E,OAJK,KAAK,aAAa,IAAI,EAAK,EAC9B,KAAK,aAAa,IAAI,EAAM,IAAI,IAAM,CAExC,KAAK,aAAa,IAAI,EAAK,CAAE,IAAI,EAA0B,KAC9C,CACX,KAAK,aAAa,IAAI,EAAK,EAAE,OAAO,EAA0B,EAIlE,eAAuB,EAA2C,CAChE,IAAM,EAAU,EAAM,KACtB,GAAI,CAAC,GAAW,OAAO,GAAY,SAAU,OAE7C,GAAM,CAAE,OAAM,OAAM,SAAU,GAAgB,EAI9C,GAHI,CAAC,GAAQ,OAAO,GAAS,UAGzB,IAAgB,KAAK,SAAU,OAGnC,GAAM,CAAE,kBAAmB,KAAK,QAShC,GAAI,EAPF,CAAC,GACD,EAAe,SAAW,GAC1B,EAAe,SAAS,IAAI,EAC5B,EACG,OAAQ,GAAQ,EAAQ,GAAQ,IAAQ,GAAG,CAC3C,KAAM,GAAQA,EAAAA,YAAY,EAAK,EAAM,OAAO,CAAC,EAElC,OAEhB,IAAM,EAAW,KAAK,aAAa,IAAI,EAAK,CAC5C,GAAI,EACF,IAAK,IAAM,KAAW,EACpB,EAAQ,EAAM,EAAY"}
1
+ {"version":3,"file":"CrossFrameMessenger.cjs","names":["compareUrls"],"sources":["../../../src/core/CrossFrameMessenger.ts"],"sourcesContent":["import { compareUrls } from '../compareUrls';\n\nconst randomUUID = (): string => Math.random().toString(36).slice(2);\n\nexport type MessagePayload = {\n type: string;\n data?: unknown;\n senderId?: string;\n /** Unique ID per send() call — used to deduplicate when the same payload arrives via multiple target origins */\n messageId?: string;\n};\n\nexport type MessengerConfig = {\n /**\n * Origins allowed to send messages to this instance.\n * Use '*' to allow all origins (not recommended for production).\n */\n allowedOrigins: string[];\n /**\n * Function used to send messages to other frames.\n * Injected so the messenger is agnostic to the frame topology.\n */\n postMessageFn: (payload: MessagePayload, origin: string) => void;\n};\n\ntype MessageHandler<T = unknown> = (data: T, senderId?: string) => void;\n\n/**\n * CrossFrameMessenger manages all cross-frame postMessage communication.\n * It owns a single window message listener and routes incoming messages to\n * type-specific subscribers.\n *\n * Replaces CommunicatorContext + useCrossFrameMessageListener across all frameworks.\n */\nexport class CrossFrameMessenger {\n readonly senderId: string;\n private readonly _config: MessengerConfig;\n private readonly _subscribers = new Map<string, Set<MessageHandler>>();\n\n private _windowHandler: ((event: MessageEvent) => void) | null = null;\n /** Tracks recently processed messageIds to discard duplicates (same payload sent to multiple origins) */\n private readonly _seenMessageIds = new Set<string>();\n\n constructor(config: MessengerConfig) {\n this._config = config;\n this.senderId = randomUUID();\n }\n\n /** Start listening for incoming messages on window. */\n start(): void {\n if (typeof window === 'undefined') return;\n if (this._windowHandler) return;\n this._windowHandler = (event: MessageEvent<MessagePayload>) => {\n this._handleMessage(event);\n };\n window.addEventListener('message', this._windowHandler);\n }\n\n /** Stop listening and clean up. */\n stop(): void {\n if (this._windowHandler) {\n window.removeEventListener('message', this._windowHandler);\n this._windowHandler = null;\n }\n }\n\n /** Send a message payload to all configured target origins. */\n send(type: string, data?: unknown): void {\n const payload: MessagePayload = {\n type,\n data,\n senderId: this.senderId,\n messageId: randomUUID(),\n };\n\n for (const origin of this._config.allowedOrigins) {\n if (origin) {\n this._config.postMessageFn(payload, origin);\n }\n }\n }\n\n /**\n * Subscribe to messages of a given type.\n * Returns an unsubscribe function.\n */\n subscribe<T = unknown>(type: string, handler: MessageHandler<T>): () => void {\n if (!this._subscribers.has(type)) {\n this._subscribers.set(type, new Set());\n }\n this._subscribers.get(type)!.add(handler as MessageHandler);\n return () => {\n this._subscribers.get(type)?.delete(handler as MessageHandler);\n };\n }\n\n private _handleMessage(event: MessageEvent<MessagePayload>): void {\n const payload = event.data;\n if (!payload || typeof payload !== 'object') return;\n\n const { type, data, senderId: msgSenderId, messageId } = payload;\n if (!type || typeof type !== 'string') return;\n\n // Ignore messages originating from this instance\n if (msgSenderId === this.senderId) return;\n\n // Deduplicate: same messageId may arrive multiple times when the sender\n // posts to multiple target origins (one per allowedOrigin)\n if (messageId) {\n if (this._seenMessageIds.has(messageId)) return;\n this._seenMessageIds.add(messageId);\n // Keep the set bounded — clear when it exceeds 200 entries\n if (this._seenMessageIds.size > 200) this._seenMessageIds.clear();\n }\n\n // Validate message origin\n const { allowedOrigins } = this._config;\n const isAllowed =\n !allowedOrigins ||\n allowedOrigins.length === 0 ||\n allowedOrigins.includes('*') ||\n allowedOrigins\n .filter((url) => Boolean(url) && url !== '')\n .some((url) => compareUrls(url, event.origin));\n\n if (!isAllowed) return;\n\n const handlers = this._subscribers.get(type);\n\n if (handlers) {\n for (const handler of handlers) {\n handler(data, msgSenderId);\n }\n }\n }\n}\n"],"mappings":"yGAEM,MAA2B,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAgCpE,IAAa,EAAb,KAAiC,CAS/B,YAAY,EAAyB,mBANL,IAAI,wBAE6B,0BAE9B,IAAI,IAGrC,KAAK,QAAU,EACf,KAAK,SAAW,GAAY,CAI9B,OAAc,CACR,OAAO,OAAW,KAClB,KAAK,iBACT,KAAK,eAAkB,GAAwC,CAC7D,KAAK,eAAe,EAAM,EAE5B,OAAO,iBAAiB,UAAW,KAAK,eAAe,EAIzD,MAAa,CACX,AAEE,KAAK,kBADL,OAAO,oBAAoB,UAAW,KAAK,eAAe,CACpC,MAK1B,KAAK,EAAc,EAAsB,CACvC,IAAM,EAA0B,CAC9B,OACA,OACA,SAAU,KAAK,SACf,UAAW,GAAY,CACxB,CAED,IAAK,IAAM,KAAU,KAAK,QAAQ,eAC5B,GACF,KAAK,QAAQ,cAAc,EAAS,EAAO,CASjD,UAAuB,EAAc,EAAwC,CAK3E,OAJK,KAAK,aAAa,IAAI,EAAK,EAC9B,KAAK,aAAa,IAAI,EAAM,IAAI,IAAM,CAExC,KAAK,aAAa,IAAI,EAAK,CAAE,IAAI,EAA0B,KAC9C,CACX,KAAK,aAAa,IAAI,EAAK,EAAE,OAAO,EAA0B,EAIlE,eAAuB,EAA2C,CAChE,IAAM,EAAU,EAAM,KACtB,GAAI,CAAC,GAAW,OAAO,GAAY,SAAU,OAE7C,GAAM,CAAE,OAAM,OAAM,SAAU,EAAa,aAAc,EAIzD,GAHI,CAAC,GAAQ,OAAO,GAAS,UAGzB,IAAgB,KAAK,SAAU,OAInC,GAAI,EAAW,CACb,GAAI,KAAK,gBAAgB,IAAI,EAAU,CAAE,OACzC,KAAK,gBAAgB,IAAI,EAAU,CAE/B,KAAK,gBAAgB,KAAO,KAAK,KAAK,gBAAgB,OAAO,CAInE,GAAM,CAAE,kBAAmB,KAAK,QAShC,GAAI,EAPF,CAAC,GACD,EAAe,SAAW,GAC1B,EAAe,SAAS,IAAI,EAC5B,EACG,OAAQ,GAAQ,EAAQ,GAAQ,IAAQ,GAAG,CAC3C,KAAM,GAAQA,EAAAA,YAAY,EAAK,EAAM,OAAO,CAAC,EAElC,OAEhB,IAAM,EAAW,KAAK,aAAa,IAAI,EAAK,CAE5C,GAAI,EACF,IAAK,IAAM,KAAW,EACpB,EAAQ,EAAM,EAAY"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./CrossFrameMessenger.cjs`),t=require(`./CrossFrameStateManager.cjs`),n=require(`../messagesKeys.cjs`),r=require(`./IframeClickInterceptor.cjs`),i=require(`./UrlStateManager.cjs`);let a=require(`@intlayer/core/dictionaryManipulator`),o=require(`@intlayer/types/nodeType`);var s=class{constructor(a){this._mode=a.mode,this.messenger=new e.CrossFrameMessenger(a.messenger),this.editorEnabled=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_EDITOR_ENABLED,this.messenger,{emit:!1,receive:!0,initialValue:!1}),this.focusedContent=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED,this.messenger,{emit:!0,receive:!0,initialValue:null}),this.localeDictionaries=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,this.messenger),this.editedContent=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,this.messenger),this.configuration=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_CONFIGURATION,this.messenger,{emit:!0,receive:!1,...a.configuration?{initialValue:a.configuration}:{}}),this.currentLocale=new t.CrossFrameStateManager(n.MessageKey.INTLAYER_CURRENT_LOCALE,this.messenger,{emit:!1,receive:!0}),this._urlManager=new i.UrlStateManager(this.messenger),this._iframeInterceptor=new r.IframeClickInterceptor(this.messenger)}start(){this.messenger.start(),this.editorEnabled.start(),this.focusedContent.start(),this.localeDictionaries.start(),this.editedContent.start(),this.configuration.start(),this.currentLocale.start(),this._mode===`client`?(this._urlManager.start(),this._iframeInterceptor.startInterceptor(),this._loadDictionaries(),this.messenger.send(`${n.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`)):this._iframeInterceptor.startMerger()}stop(){this.messenger.stop(),this.editorEnabled.stop(),this.focusedContent.stop(),this.localeDictionaries.stop(),this.editedContent.stop(),this.configuration.stop(),this.currentLocale.stop(),this._urlManager.stop(),this._iframeInterceptor.stopInterceptor(),this._iframeInterceptor.stopMerger()}setFocusedContentKeyPath(e){let t=e.filter(e=>e.type!==o.NodeType.Translation),n=this.focusedContent.value;n&&this.focusedContent.set({...n,keyPath:t})}setLocaleDictionary(e){if(!e.localId)return;let t=this.localeDictionaries.value??{};this.localeDictionaries.set({...t,[e.localId]:e})}setEditedDictionary(e){if(!e.localId){console.error(`setEditedDictionary: missing localId`,e);return}let t=this.editedContent.value??{};this.editedContent.set({...t,[e.localId]:e})}setEditedContent(e,t){let n=this.editedContent.value??{};this.editedContent.set({...n,[e]:{...n[e],content:t}})}addContent(e,t,n=[],r=!0){let i=this.editedContent.value??{},o=(this.localeDictionaries.value??{})[e]?.content,s=structuredClone(i[e]?.content??o),c=n;if(!r){let e=0,t=n.slice(0,-1),r=n[n.length-1],i=r.key;for(;(0,a.getContentNodeByKeyPath)(s,c)!==void 0;)e++,i=e===0?r.key:`${r.key} (${e})`,c=[...t,{...r,key:i}]}let l=(0,a.editDictionaryByKeyPath)(s,c,t);this.editedContent.set({...i,[e]:{...i[e],content:l}})}renameContent(e,t,n=[]){let r=this.editedContent.value??{},i=(this.localeDictionaries.value??{})[e]?.content,o=(0,a.renameContentNodeByKeyPath)(structuredClone(r[e]?.content??i),t,n);this.editedContent.set({...r,[e]:{...r[e],content:o}})}removeContent(e,t){let n=this.editedContent.value??{},r=(this.localeDictionaries.value??{})[e]?.content,i=(0,a.editDictionaryByKeyPath)(structuredClone(n[e]?.content??r),t,(0,a.getContentNodeByKeyPath)(r,t));this.editedContent.set({...n,[e]:{...n[e],content:i}})}restoreContent(e){let t={...this.editedContent.value??{}};delete t[e],this.editedContent.set(t)}clearContent(e){let t={...this.editedContent.value??{}};delete t[e],this.editedContent.set(t)}clearAllContent(){this.editedContent.set({})}getContentValue(e,t){let n=this.editedContent.value;if(!n)return;let r=t.filter(e=>e.type!==o.NodeType.Translation);if(e.includes(`:local:`)||e.includes(`:remote:`))return(0,a.getContentNodeByKeyPath)(n[e]?.content??{},r,this.currentLocale.value);let i=Object.keys(n).filter(t=>t.startsWith(`${e}:`));for(let e of i){let t=(0,a.getContentNodeByKeyPath)(n[e]?.content??{},r,this.currentLocale.value);if(t)return t}}async _loadDictionaries(){try{let e=(await import(`@intlayer/unmerged-dictionaries-entry`)).getUnmergedDictionaries(),t=Object.fromEntries(Object.values(e).flat().map(e=>[e.localId,e]));this.localeDictionaries.set(t)}catch{}}};exports.EditorStateManager=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../messageKey.cjs`),t=require(`./CrossFrameMessenger.cjs`),n=require(`./CrossFrameStateManager.cjs`),r=require(`./IframeClickInterceptor.cjs`),i=require(`./UrlStateManager.cjs`);let a=require(`@intlayer/types/nodeType`),o=require(`@intlayer/core/dictionaryManipulator`);var s=class{constructor(a){this._unsubAreYouThere=null,this._unsubActivate=null,this._unsubClientReady=null,this._mode=a.mode,this._configuration=a.configuration,this.messenger=new t.CrossFrameMessenger(a.messenger),this.editorEnabled=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_EDITOR_ENABLED,this.messenger,{emit:!1,receive:!0,initialValue:!1}),this.focusedContent=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED,this.messenger,{emit:!0,receive:!0,initialValue:null}),this.localeDictionaries=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,this.messenger),this.editedContent=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,this.messenger),this.configuration=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_CONFIGURATION,this.messenger,{emit:!0,receive:!1,...a.configuration?{initialValue:a.configuration}:{}}),this.currentLocale=new n.CrossFrameStateManager(e.MessageKey.INTLAYER_CURRENT_LOCALE,this.messenger,{emit:a.mode===`client`,receive:a.mode===`editor`}),this._urlManager=new i.UrlStateManager(this.messenger),this._iframeInterceptor=new r.IframeClickInterceptor(this.messenger)}start(){this.messenger.start(),this.editorEnabled.start(),this.focusedContent.start(),this.localeDictionaries.start(),this.editedContent.start(),this.configuration.start(),this.currentLocale.start(),this._mode===`client`?(this._urlManager.start(),this._iframeInterceptor.startInterceptor(),this._loadDictionaries(),this.messenger.send(`${e.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`),this._configuration?.editor?.enabled!==!1&&this._setupActivationHandshake()):(this._iframeInterceptor.startMerger(),this._setupEditorHandshake())}stop(){this._unsubAreYouThere?.(),this._unsubActivate?.(),this._unsubClientReady?.(),this._unsubAreYouThere=null,this._unsubActivate=null,this._unsubClientReady=null,this.messenger.stop(),this.editorEnabled.stop(),this.focusedContent.stop(),this.localeDictionaries.stop(),this.editedContent.stop(),this.configuration.stop(),this.currentLocale.stop(),this._urlManager.stop(),this._iframeInterceptor.stopInterceptor(),this._iframeInterceptor.stopMerger()}pingClient(){this._mode===`editor`&&this.messenger.send(e.MessageKey.INTLAYER_ARE_YOU_THERE)}setFocusedContentKeyPath(e){let t=e.filter(e=>e.type!==a.NodeType.Translation),n=this.focusedContent.value;n&&this.focusedContent.set({...n,keyPath:t})}setLocaleDictionary(e){if(!e.localId)return;let t=this.localeDictionaries.value??{};this.localeDictionaries.set({...t,[e.localId]:e})}setEditedDictionary(e){if(!e.localId){console.error(`setEditedDictionary: missing localId`,e);return}let t=this.editedContent.value??{};this.editedContent.set({...t,[e.localId]:e})}setEditedContent(e,t){let n=this.editedContent.value??{};this.editedContent.set({...n,[e]:{...n[e],content:t}})}addContent(e,t,n=[],r=!0){let i=this.editedContent.value??{},a=(this.localeDictionaries.value??{})[e]?.content,s=structuredClone(i[e]?.content??a),c=n;if(!r){let e=0,t=n.slice(0,-1),r=n[n.length-1],i=r.key;for(;(0,o.getContentNodeByKeyPath)(s,c)!==void 0;)e++,i=e===0?r.key:`${r.key} (${e})`,c=[...t,{...r,key:i}]}let l=(0,o.editDictionaryByKeyPath)(s,c,t);this.editedContent.set({...i,[e]:{...i[e],content:l}})}renameContent(e,t,n=[]){let r=this.editedContent.value??{},i=(this.localeDictionaries.value??{})[e]?.content,a=(0,o.renameContentNodeByKeyPath)(structuredClone(r[e]?.content??i),t,n);this.editedContent.set({...r,[e]:{...r[e],content:a}})}removeContent(e,t){let n=this.editedContent.value??{},r=(this.localeDictionaries.value??{})[e]?.content,i=(0,o.editDictionaryByKeyPath)(structuredClone(n[e]?.content??r),t,(0,o.getContentNodeByKeyPath)(r,t));this.editedContent.set({...n,[e]:{...n[e],content:i}})}restoreContent(e){let t={...this.editedContent.value??{}};delete t[e],this.editedContent.set(t)}clearContent(e){let t={...this.editedContent.value??{}};delete t[e],this.editedContent.set(t)}clearAllContent(){this.editedContent.set({})}getContentValue(e,t){let n=this.editedContent.value;if(!n)return;let r=t.filter(e=>e.type!==a.NodeType.Translation),i=this.localeDictionaries.value;if(e.includes(`:local:`)||e.includes(`:remote:`))return i&&!(e in i)?void 0:(0,o.getContentNodeByKeyPath)(n[e]?.content??{},r,this.currentLocale.value);let s=Object.keys(n).filter(t=>t.startsWith(`${e}:`)&&(!i||t in i));for(let e of s){let t=(0,o.getContentNodeByKeyPath)(n[e]?.content??{},r,this.currentLocale.value);if(t)return t}}_setupEditorHandshake(){this._unsubClientReady=this.messenger.subscribe(e.MessageKey.INTLAYER_CLIENT_READY,()=>{this.editorEnabled.set(!0),this.messenger.send(e.MessageKey.INTLAYER_EDITOR_ACTIVATE)}),this.messenger.send(e.MessageKey.INTLAYER_ARE_YOU_THERE)}_setupActivationHandshake(){this.messenger.send(e.MessageKey.INTLAYER_CLIENT_READY),this._unsubAreYouThere=this.messenger.subscribe(e.MessageKey.INTLAYER_ARE_YOU_THERE,()=>{this.messenger.send(e.MessageKey.INTLAYER_CLIENT_READY)}),this._unsubActivate=this.messenger.subscribe(e.MessageKey.INTLAYER_EDITOR_ACTIVATE,()=>{this.editorEnabled.set(!0),this._broadcastData()})}_broadcastData(){let t=this.configuration.value;t&&this.messenger.send(`${e.MessageKey.INTLAYER_CONFIGURATION}/post`,t);let n=this.currentLocale.value;n&&this.messenger.send(`${e.MessageKey.INTLAYER_CURRENT_LOCALE}/post`,n);let r=this.localeDictionaries.value;r&&this.messenger.send(`${e.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED}/post`,r)}async _loadDictionaries(){try{let e=(await import(`@intlayer/unmerged-dictionaries-entry`)).getUnmergedDictionaries(),t=Object.fromEntries(Object.values(e).flat().map(e=>[e.localId,e]));this.localeDictionaries.set(t),this.editorEnabled.value&&this._broadcastData()}catch(e){console.warn(`[intlayer] Failed to load unmerged dictionaries:`,e)}}};exports.EditorStateManager=s;
2
2
  //# sourceMappingURL=EditorStateManager.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorStateManager.cjs","names":["CrossFrameMessenger","CrossFrameStateManager","MessageKey","UrlStateManager","IframeClickInterceptor","NodeType"],"sources":["../../../src/core/EditorStateManager.ts"],"sourcesContent":["import {\n editDictionaryByKeyPath,\n getContentNodeByKeyPath,\n renameContentNodeByKeyPath,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { MessageKey } from '../messagesKeys';\nimport {\n CrossFrameMessenger,\n type MessengerConfig,\n} from './CrossFrameMessenger';\nimport { CrossFrameStateManager } from './CrossFrameStateManager';\nimport { IframeClickInterceptor } from './IframeClickInterceptor';\nimport { UrlStateManager } from './UrlStateManager';\n\nexport type DictionaryContent = Record<LocalDictionaryId, Dictionary>;\n\nexport type FileContent = {\n dictionaryKey: string;\n dictionaryLocalId?: LocalDictionaryId;\n keyPath?: KeyPath[];\n};\n\nexport type EditorStateManagerConfig = {\n /** 'client' = the app running inside the iframe; 'editor' = the editor wrapping the app */\n mode: 'editor' | 'client';\n /** Cross-frame messaging configuration */\n messenger: MessengerConfig;\n /** Optional initial Intlayer configuration to broadcast */\n configuration?: IntlayerConfig;\n};\n\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 */\nexport class EditorStateManager {\n readonly messenger: CrossFrameMessenger;\n readonly editorEnabled: CrossFrameStateManager<boolean>;\n readonly focusedContent: CrossFrameStateManager<FileContent | null>;\n readonly localeDictionaries: CrossFrameStateManager<DictionaryContent>;\n readonly editedContent: CrossFrameStateManager<DictionaryContent>;\n readonly configuration: CrossFrameStateManager<IntlayerConfig>;\n readonly currentLocale: CrossFrameStateManager<Locale>;\n\n private readonly _urlManager: UrlStateManager;\n private readonly _iframeInterceptor: IframeClickInterceptor;\n private readonly _mode: 'editor' | 'client';\n\n constructor(config: EditorStateManagerConfig) {\n this._mode = config.mode;\n\n this.messenger = new CrossFrameMessenger(config.messenger);\n\n this.editorEnabled = new CrossFrameStateManager<boolean>(\n MessageKey.INTLAYER_EDITOR_ENABLED,\n this.messenger,\n { emit: false, receive: true, initialValue: false }\n );\n\n this.focusedContent = new CrossFrameStateManager<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED,\n this.messenger,\n { emit: true, receive: true, initialValue: null }\n );\n\n this.localeDictionaries = new CrossFrameStateManager<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n this.messenger\n );\n\n this.editedContent = new CrossFrameStateManager<DictionaryContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n this.messenger\n );\n\n this.configuration = new CrossFrameStateManager<IntlayerConfig>(\n MessageKey.INTLAYER_CONFIGURATION,\n this.messenger,\n {\n emit: true,\n receive: false,\n ...(config.configuration ? { initialValue: config.configuration } : {}),\n }\n );\n\n this.currentLocale = new CrossFrameStateManager<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n this.messenger,\n { emit: false, receive: true }\n );\n\n this._urlManager = new UrlStateManager(this.messenger);\n this._iframeInterceptor = new IframeClickInterceptor(this.messenger);\n }\n\n start(): void {\n this.messenger.start();\n this.editorEnabled.start();\n this.focusedContent.start();\n this.localeDictionaries.start();\n this.editedContent.start();\n this.configuration.start();\n this.currentLocale.start();\n\n if (this._mode === 'client') {\n this._urlManager.start();\n this._iframeInterceptor.startInterceptor();\n this._loadDictionaries();\n // Request current edited content from the editor\n this.messenger.send(`${MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`);\n } else {\n this._iframeInterceptor.startMerger();\n }\n }\n\n stop(): void {\n this.messenger.stop();\n this.editorEnabled.stop();\n this.focusedContent.stop();\n this.localeDictionaries.stop();\n this.editedContent.stop();\n this.configuration.stop();\n this.currentLocale.stop();\n this._urlManager.stop();\n this._iframeInterceptor.stopInterceptor();\n this._iframeInterceptor.stopMerger();\n }\n\n // ─── Focus helpers ──────────────────────────────────────────────────────────\n\n setFocusedContentKeyPath(keyPath: KeyPath[]): void {\n const filtered = keyPath.filter((key) => key.type !== NodeType.Translation);\n const prev = this.focusedContent.value;\n if (!prev) return;\n this.focusedContent.set({ ...prev, keyPath: filtered });\n }\n\n // ─── Dictionary record helpers ───────────────────────────────────────────\n\n setLocaleDictionary(dictionary: Dictionary): void {\n if (!dictionary.localId) return;\n const current = this.localeDictionaries.value ?? {};\n this.localeDictionaries.set({\n ...current,\n [dictionary.localId as LocalDictionaryId]: dictionary,\n });\n }\n\n // ─── Edited content helpers ───────────────────────────────────────────────\n\n setEditedDictionary(newDict: Dictionary): void {\n if (!newDict.localId) {\n console.error('setEditedDictionary: missing localId', newDict);\n return;\n }\n const current = this.editedContent.value ?? {};\n this.editedContent.set({\n ...current,\n [newDict.localId as LocalDictionaryId]: newDict,\n });\n }\n\n setEditedContent(\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ): void {\n const current = this.editedContent.value ?? {};\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: newValue,\n },\n });\n }\n\n addContent(\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode,\n keyPath: KeyPath[] = [],\n overwrite = true\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n\n let newKeyPath = keyPath;\n if (!overwrite) {\n let index = 0;\n const otherKeyPath = keyPath.slice(0, -1);\n const lastKeyPath = keyPath[keyPath.length - 1];\n let finalKey = lastKeyPath.key;\n while (\n typeof getContentNodeByKeyPath(currentContent, newKeyPath) !==\n 'undefined'\n ) {\n index++;\n finalKey =\n index === 0 ? lastKeyPath.key : `${lastKeyPath.key} (${index})`;\n newKeyPath = [\n ...otherKeyPath,\n { ...lastKeyPath, key: finalKey } as KeyPath,\n ];\n }\n }\n\n const updatedContent = editDictionaryByKeyPath(\n currentContent,\n newKeyPath,\n newValue\n );\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: updatedContent as Dictionary['content'],\n },\n });\n }\n\n renameContent(\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath: KeyPath[] = []\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n const updated = renameContentNodeByKeyPath(currentContent, newKey, keyPath);\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: updated as Dictionary['content'],\n },\n });\n }\n\n removeContent(\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n const initialContent = getContentNodeByKeyPath(originalContent, keyPath);\n const restored = editDictionaryByKeyPath(\n currentContent,\n keyPath,\n initialContent\n );\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: restored as Dictionary['content'],\n },\n });\n }\n\n restoreContent(localDictionaryId: LocalDictionaryId): void {\n const current = this.editedContent.value ?? {};\n const updated = { ...current };\n delete updated[localDictionaryId];\n this.editedContent.set(updated);\n }\n\n clearContent(localDictionaryId: LocalDictionaryId): void {\n const current = this.editedContent.value ?? {};\n const filtered = { ...current };\n delete filtered[localDictionaryId];\n this.editedContent.set(filtered);\n }\n\n clearAllContent(): void {\n this.editedContent.set({});\n }\n\n getContentValue(\n localDictionaryIdOrKey: LocalDictionaryId | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined {\n const edited = this.editedContent.value;\n if (!edited) return undefined;\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const content =\n edited[localDictionaryIdOrKey as LocalDictionaryId]?.content ?? {};\n return getContentNodeByKeyPath(\n content,\n filteredKeyPath,\n this.currentLocale.value\n );\n }\n\n const matchingIds = Object.keys(edited).filter((key) =>\n key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n for (const localId of matchingIds) {\n const content = edited[localId as LocalDictionaryId]?.content ?? {};\n const node = getContentNodeByKeyPath(\n content,\n filteredKeyPath,\n this.currentLocale.value\n );\n if (node) return node;\n }\n\n return undefined;\n }\n\n private async _loadDictionaries(): Promise<void> {\n try {\n const mod = await import('@intlayer/unmerged-dictionaries-entry');\n const unmergedDictionaries = mod.getUnmergedDictionaries();\n const dictionariesList = Object.fromEntries(\n Object.values(unmergedDictionaries)\n .flat()\n .map((dictionary) => [dictionary.localId, dictionary])\n ) as DictionaryContent;\n this.localeDictionaries.set(dictionariesList);\n } catch {\n // Dynamic entry not available (expected in editor mode or when not configured)\n }\n }\n}\n"],"mappings":"oWAgDA,IAAa,EAAb,KAAgC,CAa9B,YAAY,EAAkC,CAC5C,KAAK,MAAQ,EAAO,KAEpB,KAAK,UAAY,IAAIA,EAAAA,oBAAoB,EAAO,UAAU,CAE1D,KAAK,cAAgB,IAAIC,EAAAA,uBACvBC,EAAAA,WAAW,wBACX,KAAK,UACL,CAAE,KAAM,GAAO,QAAS,GAAM,aAAc,GAAO,CACpD,CAED,KAAK,eAAiB,IAAID,EAAAA,uBACx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I,OAASA,EAAAA,SAAS,YAChC,CAMD,GAHE,EAAuB,SAAS,UAAU,EAC1C,EAAuB,SAAS,WAAW,CAK3C,OAAA,EAAA,EAAA,yBADE,EAAO,IAA8C,SAAW,EAAE,CAGlE,EACA,KAAK,cAAc,MACpB,CAGH,IAAM,EAAc,OAAO,KAAK,EAAO,CAAC,OAAQ,GAC9C,EAAI,WAAW,GAAG,EAAuB,GAAG,CAC7C,CACD,IAAK,IAAM,KAAW,EAAa,CAEjC,IAAM,GAAA,EAAA,EAAA,yBADU,EAAO,IAA+B,SAAW,EAAE,CAGjE,EACA,KAAK,cAAc,MACpB,CACD,GAAI,EAAM,OAAO,GAMrB,MAAc,mBAAmC,CAC/C,GAAI,CAEF,IAAM,GADM,MAAM,OAAO,0CACQ,yBAAyB,CACpD,EAAmB,OAAO,YAC9B,OAAO,OAAO,EAAqB,CAChC,MAAM,CACN,IAAK,GAAe,CAAC,EAAW,QAAS,EAAW,CAAC,CACzD,CACD,KAAK,mBAAmB,IAAI,EAAiB,MACvC"}
1
+ {"version":3,"file":"EditorStateManager.cjs","names":["CrossFrameMessenger","CrossFrameStateManager","MessageKey","UrlStateManager","IframeClickInterceptor","NodeType"],"sources":["../../../src/core/EditorStateManager.ts"],"sourcesContent":["import {\n editDictionaryByKeyPath,\n getContentNodeByKeyPath,\n renameContentNodeByKeyPath,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { MessageKey } from '../messageKey';\nimport {\n CrossFrameMessenger,\n type MessengerConfig,\n} from './CrossFrameMessenger';\nimport { CrossFrameStateManager } from './CrossFrameStateManager';\nimport { IframeClickInterceptor } from './IframeClickInterceptor';\nimport { UrlStateManager } from './UrlStateManager';\n\nexport type DictionaryContent = Record<LocalDictionaryId, Dictionary>;\n\nexport type FileContent = {\n dictionaryKey: string;\n dictionaryLocalId?: LocalDictionaryId;\n keyPath?: KeyPath[];\n};\n\nexport type EditorStateManagerConfig = {\n /** 'client' = the app running inside the iframe; 'editor' = the editor wrapping the app */\n mode: 'editor' | 'client';\n /** Cross-frame messaging configuration */\n messenger: MessengerConfig;\n /** Optional initial Intlayer configuration to broadcast */\n configuration?: IntlayerConfig;\n};\n\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 */\nexport class EditorStateManager {\n readonly messenger: CrossFrameMessenger;\n readonly editorEnabled: CrossFrameStateManager<boolean>;\n readonly focusedContent: CrossFrameStateManager<FileContent | null>;\n readonly localeDictionaries: CrossFrameStateManager<DictionaryContent>;\n readonly editedContent: CrossFrameStateManager<DictionaryContent>;\n readonly configuration: CrossFrameStateManager<IntlayerConfig>;\n readonly currentLocale: CrossFrameStateManager<Locale | undefined>;\n\n private readonly _urlManager: UrlStateManager;\n private readonly _iframeInterceptor: IframeClickInterceptor;\n private readonly _mode: 'editor' | 'client';\n private readonly _configuration: IntlayerConfig | undefined;\n\n // Client-mode handshake subscribers\n private _unsubAreYouThere: (() => void) | null = null;\n private _unsubActivate: (() => void) | null = null;\n // Editor-mode handshake subscriber\n private _unsubClientReady: (() => void) | null = null;\n\n constructor(config: EditorStateManagerConfig) {\n this._mode = config.mode;\n this._configuration = config.configuration;\n\n this.messenger = new CrossFrameMessenger(config.messenger);\n\n this.editorEnabled = new CrossFrameStateManager<boolean>(\n MessageKey.INTLAYER_EDITOR_ENABLED,\n this.messenger,\n { emit: false, receive: true, initialValue: false }\n );\n\n this.focusedContent = new CrossFrameStateManager<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED,\n this.messenger,\n { emit: true, receive: true, initialValue: null }\n );\n\n this.localeDictionaries = new CrossFrameStateManager<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n this.messenger\n );\n\n this.editedContent = new CrossFrameStateManager<DictionaryContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n this.messenger\n );\n\n this.configuration = new CrossFrameStateManager<IntlayerConfig>(\n MessageKey.INTLAYER_CONFIGURATION,\n this.messenger,\n {\n emit: true,\n receive: false,\n ...(config.configuration ? { initialValue: config.configuration } : {}),\n }\n );\n\n // Client emits its locale to the editor; editor receives it.\n this.currentLocale = new CrossFrameStateManager<Locale>(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n this.messenger,\n {\n emit: config.mode === 'client',\n receive: config.mode === 'editor',\n }\n );\n\n this._urlManager = new UrlStateManager(this.messenger);\n this._iframeInterceptor = new IframeClickInterceptor(this.messenger);\n }\n\n start(): void {\n this.messenger.start();\n this.editorEnabled.start();\n this.focusedContent.start();\n this.localeDictionaries.start();\n this.editedContent.start();\n this.configuration.start();\n this.currentLocale.start();\n\n if (this._mode === 'client') {\n this._urlManager.start();\n this._iframeInterceptor.startInterceptor();\n this._loadDictionaries();\n // Request current edited content from the editor\n this.messenger.send(`${MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`);\n // Activation handshake: only participate if editor.enabled !== false\n if (this._configuration?.editor?.enabled !== false) {\n this._setupActivationHandshake();\n }\n } else {\n this._iframeInterceptor.startMerger();\n this._setupEditorHandshake();\n }\n }\n\n stop(): void {\n this._unsubAreYouThere?.();\n this._unsubActivate?.();\n this._unsubClientReady?.();\n this._unsubAreYouThere = null;\n this._unsubActivate = null;\n this._unsubClientReady = null;\n this.messenger.stop();\n this.editorEnabled.stop();\n this.focusedContent.stop();\n this.localeDictionaries.stop();\n this.editedContent.stop();\n this.configuration.stop();\n this.currentLocale.stop();\n this._urlManager.stop();\n this._iframeInterceptor.stopInterceptor();\n this._iframeInterceptor.stopMerger();\n }\n\n // ─── Handshake helpers ───────────────────────────────────────────────────────\n\n /**\n * EDITOR mode: re-send ARE_YOU_THERE to attempt re-connection with the client.\n * Call this when the user clicks \"Enable Editor\" or when the iframe reloads.\n */\n pingClient(): void {\n if (this._mode !== 'editor') return;\n\n this.messenger.send(MessageKey.INTLAYER_ARE_YOU_THERE);\n }\n\n // ─── Focus helpers ──────────────────────────────────────────────────────────\n\n setFocusedContentKeyPath(keyPath: KeyPath[]): void {\n const filtered = keyPath.filter((key) => key.type !== NodeType.Translation);\n const prev = this.focusedContent.value;\n\n if (!prev) return;\n\n this.focusedContent.set({ ...prev, keyPath: filtered });\n }\n\n // ─── Dictionary record helpers ───────────────────────────────────────────\n\n setLocaleDictionary(dictionary: Dictionary): void {\n if (!dictionary.localId) return;\n const current = this.localeDictionaries.value ?? {};\n\n this.localeDictionaries.set({\n ...current,\n [dictionary.localId as LocalDictionaryId]: dictionary,\n });\n }\n\n // ─── Edited content helpers ───────────────────────────────────────────────\n\n setEditedDictionary(newDict: Dictionary): void {\n if (!newDict.localId) {\n console.error('setEditedDictionary: missing localId', newDict);\n return;\n }\n const current = this.editedContent.value ?? {};\n\n this.editedContent.set({\n ...current,\n [newDict.localId as LocalDictionaryId]: newDict,\n });\n }\n\n setEditedContent(\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ): void {\n const current = this.editedContent.value ?? {};\n\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: newValue,\n },\n });\n }\n\n addContent(\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode,\n keyPath: KeyPath[] = [],\n overwrite = true\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n\n let newKeyPath = keyPath;\n if (!overwrite) {\n let index = 0;\n\n const otherKeyPath = keyPath.slice(0, -1);\n const lastKeyPath = keyPath[keyPath.length - 1];\n\n let finalKey = lastKeyPath.key;\n\n while (\n typeof getContentNodeByKeyPath(currentContent, newKeyPath) !==\n 'undefined'\n ) {\n index++;\n finalKey =\n index === 0 ? lastKeyPath.key : `${lastKeyPath.key} (${index})`;\n newKeyPath = [\n ...otherKeyPath,\n { ...lastKeyPath, key: finalKey } as KeyPath,\n ];\n }\n }\n\n const updatedContent = editDictionaryByKeyPath(\n currentContent,\n newKeyPath,\n newValue\n );\n\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: updatedContent as Dictionary['content'],\n },\n });\n }\n\n renameContent(\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath: KeyPath[] = []\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n const updated = renameContentNodeByKeyPath(currentContent, newKey, keyPath);\n\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: updated as Dictionary['content'],\n },\n });\n }\n\n removeContent(\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ): void {\n const current = this.editedContent.value ?? {};\n const localeDicts = this.localeDictionaries.value ?? {};\n const originalContent = localeDicts[localDictionaryId]?.content;\n const currentContent = structuredClone(\n current[localDictionaryId]?.content ?? originalContent\n );\n const initialContent = getContentNodeByKeyPath(originalContent, keyPath);\n const restored = editDictionaryByKeyPath(\n currentContent,\n keyPath,\n initialContent\n );\n\n this.editedContent.set({\n ...current,\n [localDictionaryId]: {\n ...current[localDictionaryId],\n content: restored as Dictionary['content'],\n },\n });\n }\n\n restoreContent(localDictionaryId: LocalDictionaryId): void {\n const current = this.editedContent.value ?? {};\n const updated = { ...current };\n\n delete updated[localDictionaryId];\n\n this.editedContent.set(updated);\n }\n\n clearContent(localDictionaryId: LocalDictionaryId): void {\n const current = this.editedContent.value ?? {};\n const filtered = { ...current };\n\n delete filtered[localDictionaryId];\n\n this.editedContent.set(filtered);\n }\n\n clearAllContent(): void {\n this.editedContent.set({});\n }\n\n getContentValue(\n localDictionaryIdOrKey: LocalDictionaryId | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined {\n const edited = this.editedContent.value;\n if (!edited) return undefined;\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n // Only use edited content entries whose localId is known to this client.\n // This prevents stale edits from other apps (different framework demos) from\n // being applied when the editor sends back its stored editedContent.\n const localeDicts = this.localeDictionaries.value;\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n // If localeDictionaries is loaded, verify this localId belongs to us\n if (localeDicts && !(localDictionaryIdOrKey in localeDicts)) {\n return undefined;\n }\n const content =\n edited[localDictionaryIdOrKey as LocalDictionaryId]?.content ?? {};\n\n return getContentNodeByKeyPath(\n content,\n filteredKeyPath,\n this.currentLocale.value\n );\n }\n\n const matchingIds = Object.keys(edited).filter(\n (key) =>\n key.startsWith(`${localDictionaryIdOrKey}:`) &&\n // If localeDictionaries is loaded, only include known localIds\n (!localeDicts || key in localeDicts)\n );\n\n for (const localId of matchingIds) {\n const content = edited[localId as LocalDictionaryId]?.content ?? {};\n const node = getContentNodeByKeyPath(\n content,\n filteredKeyPath,\n this.currentLocale.value\n );\n if (node) return node;\n }\n\n return undefined;\n }\n\n /**\n * EDITOR mode: listen for CLIENT_READY and respond with EDITOR_ACTIVATE.\n * Also pings the client immediately in case it loaded before the editor.\n */\n private _setupEditorHandshake(): void {\n // When the client announces it is ready, activate it\n this._unsubClientReady = this.messenger.subscribe(\n MessageKey.INTLAYER_CLIENT_READY,\n () => {\n this.editorEnabled.set(true);\n this.messenger.send(MessageKey.INTLAYER_EDITOR_ACTIVATE);\n }\n );\n\n // Ping any already-running client (covers editor-opens-after-client scenario)\n this.messenger.send(MessageKey.INTLAYER_ARE_YOU_THERE);\n }\n\n private _setupActivationHandshake(): void {\n // Announce to the editor that the client is ready\n this.messenger.send(MessageKey.INTLAYER_CLIENT_READY);\n\n // Respond to \"are you there?\" pings from the editor\n this._unsubAreYouThere = this.messenger.subscribe(\n MessageKey.INTLAYER_ARE_YOU_THERE,\n () => {\n this.messenger.send(MessageKey.INTLAYER_CLIENT_READY);\n }\n );\n\n // When the editor activates us, enable the selector and broadcast state\n this._unsubActivate = this.messenger.subscribe(\n MessageKey.INTLAYER_EDITOR_ACTIVATE,\n () => {\n this.editorEnabled.set(true);\n this._broadcastData();\n }\n );\n }\n\n private _broadcastData(): void {\n const configVal = this.configuration.value;\n\n if (configVal) {\n this.messenger.send(\n `${MessageKey.INTLAYER_CONFIGURATION}/post`,\n configVal\n );\n }\n const localeVal = this.currentLocale.value;\n\n if (localeVal) {\n this.messenger.send(\n `${MessageKey.INTLAYER_CURRENT_LOCALE}/post`,\n localeVal\n );\n }\n const dicts = this.localeDictionaries.value;\n\n if (dicts) {\n this.messenger.send(\n `${MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED}/post`,\n dicts\n );\n }\n }\n\n private async _loadDictionaries(): Promise<void> {\n try {\n const mod = await import('@intlayer/unmerged-dictionaries-entry');\n const unmergedDictionaries = mod.getUnmergedDictionaries();\n const dictionariesList = Object.fromEntries(\n Object.values(unmergedDictionaries)\n .flat()\n .map((dictionary) => [dictionary.localId, dictionary])\n ) as DictionaryContent;\n\n this.localeDictionaries.set(dictionariesList);\n\n // If the editor already activated us before dictionaries finished loading,\n // re-broadcast now so the editor receives the dictionaries.\n if (this.editorEnabled.value) {\n this._broadcastData();\n }\n } catch (e) {\n // Dynamic entry not available (expected in editor mode or when not configured)\n console.warn('[intlayer] Failed to load unmerged dictionaries:', e);\n }\n }\n}\n"],"mappings":"+YAgDA,IAAa,EAAb,KAAgC,CAoB9B,YAAY,EAAkC,wBALG,yBACH,4BAEG,KAG/C,K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AK,UAAU,KAAKA,EAAAA,WAAW,uBAAuB,CAGxD,2BAA0C,CAExC,KAAK,UAAU,KAAKA,EAAAA,WAAW,sBAAsB,CAGrD,KAAK,kBAAoB,KAAK,UAAU,UACtCA,EAAAA,WAAW,2BACL,CACJ,KAAK,UAAU,KAAKA,EAAAA,WAAW,sBAAsB,EAExD,CAGD,KAAK,eAAiB,KAAK,UAAU,UACnCA,EAAAA,WAAW,6BACL,CACJ,KAAK,cAAc,IAAI,GAAK,CAC5B,KAAK,gBAAgB,EAExB,CAGH,gBAA+B,CAC7B,IAAM,EAAY,KAAK,cAAc,MAEjC,GACF,KAAK,UAAU,KACb,GAAGA,EAAAA,WAAW,uBAAuB,OACrC,EACD,CAEH,IAAM,EAAY,KAAK,cAAc,MAEjC,GACF,KAAK,UAAU,KACb,GAAGA,EAAAA,WAAW,wBAAwB,OACtC,EACD,CAEH,IAAM,EAAQ,KAAK,mBAAmB,MAElC,GACF,KAAK,UAAU,KACb,GAAGA,EAAAA,WAAW,qCAAqC,OACnD,EACD,CAIL,MAAc,mBAAmC,CAC/C,GAAI,CAEF,IAAM,GADM,MAAM,OAAO,0CACQ,yBAAyB,CACpD,EAAmB,OAAO,YAC9B,OAAO,OAAO,EAAqB,CAChC,MAAM,CACN,IAAK,GAAe,CAAC,EAAW,QAAS,EAAW,CAAC,CACzD,CAED,KAAK,mBAAmB,IAAI,EAAiB,CAIzC,KAAK,cAAc,OACrB,KAAK,gBAAgB,OAEhB,EAAG,CAEV,QAAQ,KAAK,mDAAoD,EAAE"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../mergeIframeClick.cjs`),t=require(`../messagesKeys.cjs`);var n=class{constructor(e){this._mousedownHandler=null,this._unsubscribeMerge=null,this._messenger=e}startInterceptor(){typeof window>`u`||(this._mousedownHandler=()=>{this._messenger.send(t.MessageKey.INTLAYER_IFRAME_CLICKED)},window.addEventListener(`mousedown`,this._mousedownHandler))}startMerger(){this._unsubscribeMerge=this._messenger.subscribe(t.MessageKey.INTLAYER_IFRAME_CLICKED,e.mergeIframeClick)}stopInterceptor(){this._mousedownHandler&&=(window.removeEventListener(`mousedown`,this._mousedownHandler),null)}stopMerger(){this._unsubscribeMerge?.(),this._unsubscribeMerge=null}};exports.IframeClickInterceptor=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../messageKey.cjs`),t=require(`../mergeIframeClick.cjs`);var n=class{constructor(e){this._mousedownHandler=null,this._unsubscribeMerge=null,this._messenger=e}startInterceptor(){typeof window>`u`||(this._mousedownHandler=()=>{this._messenger.send(e.MessageKey.INTLAYER_IFRAME_CLICKED)},window.addEventListener(`mousedown`,this._mousedownHandler))}startMerger(){this._unsubscribeMerge=this._messenger.subscribe(e.MessageKey.INTLAYER_IFRAME_CLICKED,t.mergeIframeClick)}stopInterceptor(){this._mousedownHandler&&=(window.removeEventListener(`mousedown`,this._mousedownHandler),null)}stopMerger(){this._unsubscribeMerge?.(),this._unsubscribeMerge=null}};exports.IframeClickInterceptor=n;
2
2
  //# sourceMappingURL=IframeClickInterceptor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeClickInterceptor.cjs","names":["MessageKey","mergeIframeClick"],"sources":["../../../src/core/IframeClickInterceptor.ts"],"sourcesContent":["import { mergeIframeClick } from '../mergeIframeClick';\nimport { MessageKey } from '../messagesKeys';\nimport type { CrossFrameMessenger } from './CrossFrameMessenger';\n\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 */\nexport class IframeClickInterceptor {\n private readonly _messenger: CrossFrameMessenger;\n private _mousedownHandler: EventListener | null = null;\n private _unsubscribeMerge: (() => void) | null = null;\n\n constructor(messenger: CrossFrameMessenger) {\n this._messenger = messenger;\n }\n\n /** Called on the client side (inside iframe). Broadcasts click events to parent. */\n startInterceptor(): void {\n if (typeof window === 'undefined') return;\n this._mousedownHandler = () => {\n this._messenger.send(MessageKey.INTLAYER_IFRAME_CLICKED);\n };\n window.addEventListener('mousedown', this._mousedownHandler);\n }\n\n /** Called on the editor side (parent frame). Merges incoming iframe clicks into DOM. */\n startMerger(): void {\n this._unsubscribeMerge = this._messenger.subscribe(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick as (data: unknown) => void\n );\n }\n\n stopInterceptor(): void {\n if (this._mousedownHandler) {\n window.removeEventListener('mousedown', this._mousedownHandler);\n this._mousedownHandler = null;\n }\n }\n\n stopMerger(): void {\n this._unsubscribeMerge?.();\n this._unsubscribeMerge = null;\n }\n}\n"],"mappings":"+IAYA,IAAa,EAAb,KAAoC,CAKlC,YAAY,EAAgC,wBAHM,4BACD,KAG/C,KAAK,WAAa,EAIpB,kBAAyB,CACnB,OAAO,OAAW,MACtB,KAAK,sBAA0B,CAC7B,KAAK,WAAW,KAAKA,EAAAA,WAAW,wBAAwB,EAE1D,OAAO,iBAAiB,YAAa,KAAK,kBAAkB,EAI9D,aAAoB,CAClB,KAAK,kBAAoB,KAAK,WAAW,UACvCA,EAAAA,WAAW,wBACXC,EAAAA,iBACD,CAGH,iBAAwB,CACtB,AAEE,KAAK,qBADL,OAAO,oBAAoB,YAAa,KAAK,kBAAkB,CACtC,MAI7B,YAAmB,CACjB,KAAK,qBAAqB,CAC1B,KAAK,kBAAoB"}
1
+ {"version":3,"file":"IframeClickInterceptor.cjs","names":["MessageKey","mergeIframeClick"],"sources":["../../../src/core/IframeClickInterceptor.ts"],"sourcesContent":["import { mergeIframeClick } from '../mergeIframeClick';\nimport { MessageKey } from '../messageKey';\nimport type { CrossFrameMessenger } from './CrossFrameMessenger';\n\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 */\nexport class IframeClickInterceptor {\n private readonly _messenger: CrossFrameMessenger;\n private _mousedownHandler: EventListener | null = null;\n private _unsubscribeMerge: (() => void) | null = null;\n\n constructor(messenger: CrossFrameMessenger) {\n this._messenger = messenger;\n }\n\n /** Called on the client side (inside iframe). Broadcasts click events to parent. */\n startInterceptor(): void {\n if (typeof window === 'undefined') return;\n this._mousedownHandler = () => {\n this._messenger.send(MessageKey.INTLAYER_IFRAME_CLICKED);\n };\n window.addEventListener('mousedown', this._mousedownHandler);\n }\n\n /** Called on the editor side (parent frame). Merges incoming iframe clicks into DOM. */\n startMerger(): void {\n this._unsubscribeMerge = this._messenger.subscribe(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick as (data: unknown) => void\n );\n }\n\n stopInterceptor(): void {\n if (this._mousedownHandler) {\n window.removeEventListener('mousedown', this._mousedownHandler);\n this._mousedownHandler = null;\n }\n }\n\n stopMerger(): void {\n this._unsubscribeMerge?.();\n this._unsubscribeMerge = null;\n }\n}\n"],"mappings":"6IAYA,IAAa,EAAb,KAAoC,CAKlC,YAAY,EAAgC,wBAHM,4BACD,KAG/C,KAAK,WAAa,EAIpB,kBAAyB,CACnB,OAAO,OAAW,MACtB,KAAK,sBAA0B,CAC7B,KAAK,WAAW,KAAKA,EAAAA,WAAW,wBAAwB,EAE1D,OAAO,iBAAiB,YAAa,KAAK,kBAAkB,EAI9D,aAAoB,CAClB,KAAK,kBAAoB,KAAK,WAAW,UACvCA,EAAAA,WAAW,wBACXC,EAAAA,iBACD,CAGH,iBAAwB,CACtB,AAEE,KAAK,qBADL,OAAO,oBAAoB,YAAa,KAAK,kBAAkB,CACtC,MAI7B,YAAmB,CACjB,KAAK,qBAAqB,CAC1B,KAAK,kBAAoB"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../messagesKeys.cjs`);var t=class{constructor(e){this._originalPushState=null,this._originalReplaceState=null,this._listeners=[],this._messenger=e}start(){if(typeof window>`u`)return;let t=()=>{this._messenger.send(`${e.MessageKey.INTLAYER_URL_CHANGE}/post`,window.location.pathname)};this._originalPushState=history.pushState,this._originalReplaceState=history.replaceState;let n=e=>function(...t){e.apply(this,t),window.dispatchEvent(new Event(`locationchange`))};history.pushState=n(this._originalPushState),history.replaceState=n(this._originalReplaceState);for(let e of[`locationchange`,`popstate`,`hashchange`,`load`]){let n=t;window.addEventListener(e,n),this._listeners.push([e,n])}t()}stop(){if(!(typeof window>`u`)){for(let[e,t]of this._listeners)window.removeEventListener(e,t);this._listeners=[],this._originalPushState&&=(history.pushState=this._originalPushState,null),this._originalReplaceState&&=(history.replaceState=this._originalReplaceState,null)}}};exports.UrlStateManager=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../messageKey.cjs`);var t=class{constructor(e){this._originalPushState=null,this._originalReplaceState=null,this._listeners=[],this._messenger=e}start(){if(typeof window>`u`)return;let t=()=>{this._messenger.send(`${e.MessageKey.INTLAYER_URL_CHANGE}/post`,window.location.pathname)};this._originalPushState=history.pushState,this._originalReplaceState=history.replaceState;let n=e=>function(...t){e.apply(this,t),window.dispatchEvent(new Event(`locationchange`))};history.pushState=n(this._originalPushState),history.replaceState=n(this._originalReplaceState);for(let e of[`locationchange`,`popstate`,`hashchange`,`load`]){let n=t;window.addEventListener(e,n),this._listeners.push([e,n])}t()}stop(){if(!(typeof window>`u`)){for(let[e,t]of this._listeners)window.removeEventListener(e,t);this._listeners=[],this._originalPushState&&=(history.pushState=this._originalPushState,null),this._originalReplaceState&&=(history.replaceState=this._originalReplaceState,null)}}};exports.UrlStateManager=t;
2
2
  //# sourceMappingURL=UrlStateManager.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"UrlStateManager.cjs","names":["MessageKey"],"sources":["../../../src/core/UrlStateManager.ts"],"sourcesContent":["import { MessageKey } from '../messagesKeys';\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":"0GASA,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,GAAGA,EAAAA,WAAW,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.cjs","names":["MessageKey"],"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":"wGASA,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,GAAGA,EAAAA,WAAW,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"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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)}};exports.getGlobalEditorManager=r,exports.onGlobalEditorManagerChange=a,exports.setGlobalEditorManager=i;
2
+ //# sourceMappingURL=globalManager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalManager.cjs","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":"mEAkBA,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 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./CrossFrameMessenger.cjs`),t=require(`./CrossFrameStateManager.cjs`),n=require(`./IframeClickInterceptor.cjs`),r=require(`./UrlStateManager.cjs`),i=require(`./EditorStateManager.cjs`);exports.CrossFrameMessenger=e.CrossFrameMessenger,exports.CrossFrameStateManager=t.CrossFrameStateManager,exports.EditorStateManager=i.EditorStateManager,exports.IframeClickInterceptor=n.IframeClickInterceptor,exports.UrlStateManager=r.UrlStateManager;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./globalManager.cjs`),t=require(`./CrossFrameMessenger.cjs`),n=require(`./CrossFrameStateManager.cjs`),r=require(`./IframeClickInterceptor.cjs`),i=require(`./UrlStateManager.cjs`),a=require(`./EditorStateManager.cjs`),o=require(`./initEditorClient.cjs`);exports.CrossFrameMessenger=t.CrossFrameMessenger,exports.CrossFrameStateManager=n.CrossFrameStateManager,exports.EditorStateManager=a.EditorStateManager,exports.IframeClickInterceptor=r.IframeClickInterceptor,exports.UrlStateManager=i.UrlStateManager,exports.buildClientMessengerConfig=o.buildClientMessengerConfig,exports.getGlobalEditorManager=e.getGlobalEditorManager,exports.initEditorClient=o.initEditorClient,exports.onGlobalEditorManagerChange=e.onGlobalEditorManagerChange,exports.setGlobalEditorManager=e.setGlobalEditorManager,exports.stopEditorClient=o.stopEditorClient;
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./globalManager.cjs`),n=require(`./EditorStateManager.cjs`),r=require(`../components/ContentSelector.cjs`);let i=require(`@intlayer/config/built`);i=e.__toESM(i);const a=()=>{let{editor:e}=i.default??{};return{allowedOrigins:[e?.editorURL,e?.cmsURL].filter(Boolean),postMessageFn:(e,t)=>{typeof window>`u`||window.self!==window.top&&window.parent?.postMessage(e,t)}}};let o=0;const s=()=>{o++;let e=t.getGlobalEditorManager();if(e)return e;let s=new n.EditorStateManager({mode:`client`,messenger:a(),configuration:i.default});return t.setGlobalEditorManager(s),r.defineIntlayerElements(),s.start(),s},c=()=>{o=Math.max(0,o-1),!(o>0)&&(t.getGlobalEditorManager()?.stop(),t.setGlobalEditorManager(null))};exports.buildClientMessengerConfig=a,exports.initEditorClient=s,exports.stopEditorClient=c;
2
+ //# sourceMappingURL=initEditorClient.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initEditorClient.cjs","names":["configuration","getGlobalEditorManager","EditorStateManager"],"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":"qSASA,MAAa,MAAoD,CAC/D,GAAM,CAAE,UAAWA,EAAAA,SAAiB,EAAE,CAEtC,MAAO,CACL,eAAgB,CAAC,GAAQ,UAAW,GAAQ,OAAO,CAAC,OAClD,QACD,CACD,eAAgB,EAAkB,IAAmB,CAC/C,OAAO,OAAW,KAEH,OAAO,OAAS,OAAO,KAG1C,OAAO,QAAQ,YAAY,EAAS,EAAO,EAE9C,EAIH,IAAI,EAAkB,EAQtB,MAAa,MAA6C,CACxD,IAEA,IAAM,EAAWC,EAAAA,wBAAwB,CACzC,GAAI,EAAU,OAAO,EAErB,IAAM,EAAU,IAAIC,EAAAA,mBAAmB,CACrC,KAAM,SACN,UAAW,GAA4B,CACvC,cAAA,EAAA,QACD,CAAC,CAMF,OAJA,EAAA,uBAAuB,EAAQ,CAC/B,EAAA,wBAAwB,CACxB,EAAQ,OAAO,CAER,GAOI,MAA+B,CAC1C,EAAkB,KAAK,IAAI,EAAG,EAAkB,EAAE,CAE9C,IAAkB,KAEND,EAAAA,wBAAwB,EAC/B,MAAM,CACf,EAAA,uBAAuB,KAAK"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./compareUrls.cjs`),t=require(`./mergeIframeClick.cjs`),n=require(`./ContentSelector-BXawqqyE.cjs`);require(`./components/index.cjs`);const r=require(`./core/CrossFrameMessenger.cjs`),i=require(`./core/CrossFrameStateManager.cjs`),a=require(`./messagesKeys.cjs`),o=require(`./core/IframeClickInterceptor.cjs`),s=require(`./core/UrlStateManager.cjs`),c=require(`./core/EditorStateManager.cjs`);require(`./core/index.cjs`),exports.CrossFrameMessenger=r.CrossFrameMessenger,exports.CrossFrameStateManager=i.CrossFrameStateManager,exports.EditorStateManager=c.EditorStateManager,exports.IframeClickInterceptor=o.IframeClickInterceptor,exports.IntlayerContentSelectorElement=n.t,exports.MessageKey=a.MessageKey,exports.UrlStateManager=s.UrlStateManager,exports.compareUrls=e.compareUrls,exports.defineIntlayerElements=n.n,exports.mergeIframeClick=t.mergeIframeClick;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./compareUrls.cjs`),t=require(`./messageKey.cjs`),n=require(`./mergeIframeClick.cjs`),r=require(`./core/globalManager.cjs`),i=require(`./components/ContentSelectorWrapper.cjs`),a=require(`./components/EditedContent.cjs`),o=require(`./core/CrossFrameMessenger.cjs`),s=require(`./core/CrossFrameStateManager.cjs`),c=require(`./core/IframeClickInterceptor.cjs`),l=require(`./core/UrlStateManager.cjs`),u=require(`./core/EditorStateManager.cjs`),d=require(`./core/initEditorClient.cjs`),f=require(`./components/IntlayerEditor.cjs`),p=require(`./components/ContentSelector.cjs`);exports.CrossFrameMessenger=o.CrossFrameMessenger,exports.CrossFrameStateManager=s.CrossFrameStateManager,exports.EditorStateManager=u.EditorStateManager,exports.IframeClickInterceptor=c.IframeClickInterceptor,exports.IntlayerContentSelectorElement=p.IntlayerContentSelectorElement,exports.IntlayerContentSelectorWrapperElement=i.IntlayerContentSelectorWrapperElement,exports.IntlayerEditedContentElement=a.IntlayerEditedContentElement,exports.IntlayerEditorElement=f.IntlayerEditorElement,exports.MessageKey=t.MessageKey,exports.UrlStateManager=l.UrlStateManager,exports.buildClientMessengerConfig=d.buildClientMessengerConfig,exports.compareUrls=e.compareUrls,exports.defineIntlayerContentSelectorWrapper=i.defineIntlayerContentSelectorWrapper,exports.defineIntlayerEditedContent=a.defineIntlayerEditedContent,exports.defineIntlayerEditorElement=f.defineIntlayerEditorElement,exports.defineIntlayerElements=p.defineIntlayerElements,exports.getGlobalEditorManager=r.getGlobalEditorManager,exports.initEditorClient=d.initEditorClient,exports.mergeIframeClick=n.mergeIframeClick,exports.onGlobalEditorManagerChange=r.onGlobalEditorManagerChange,exports.setGlobalEditorManager=r.setGlobalEditorManager,exports.stopEditorClient=d.stopEditorClient;
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@intlayer/config/built`);t=e.__toESM(t);const n=t.default.editor?.enabled&&typeof window<`u`&&window.self!==window.top;exports.isEnabled=n;
2
+ //# sourceMappingURL=isEnabled.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEnabled.cjs","names":["configuration"],"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":"8KAEA,MAAa,EACXA,EAAAA,QAAc,QAAQ,SACtB,OAAO,OAAW,KAClB,OAAO,OAAS,OAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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}({});exports.MessageKey=e;
2
+ //# sourceMappingURL=messageKey.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageKey.cjs","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":"mEAAA,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"}
@@ -0,0 +1 @@
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}export{e as __decorate};
@@ -1 +1,41 @@
1
- import{n as e,t}from"../ContentSelector-QN8BYkA9.mjs";export{t as IntlayerContentSelectorElement,e as defineIntlayerElements};
1
+ import{__decorate as e}from"../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";import{defineIntlayerContentSelectorWrapper as t}from"./ContentSelectorWrapper.mjs";import{defineIntlayerEditedContent as n}from"./EditedContent.mjs";import{defineIntlayerEditorElement as r}from"./IntlayerEditor.mjs";import{LitElement as i,css as a,html as o}from"lit";import{property as s,query as c,state as l}from"lit/decorators.js";var u=class extends i{constructor(...e){super(...e),this.isSelecting=!1,this.pressDuration=250,this._isHovered=!1,this._isSelectingState=!1,this._pressTimer=null,this._clickOutsideHandler=null}static{this.styles=a`
2
+ :host {
3
+ display: contents;
4
+ }
5
+
6
+ .wrapper {
7
+ display: inline-block;
8
+ cursor: pointer;
9
+ user-select: none;
10
+ border-radius: 0.375rem;
11
+ outline-width: 2px;
12
+ outline-offset: 4px;
13
+ outline-style: solid;
14
+ outline-color: transparent;
15
+ transition: all 100ms 50ms ease-in-out;
16
+ }
17
+
18
+ .wrapper[data-active] {
19
+ outline-color: inherit;
20
+ }
21
+ `}connectedCallback(){super.connectedCallback(),this._clickOutsideHandler=e=>{e.composedPath().includes(this)||(this._isSelectingState=!1,this._dispatch(`intlayer:click-outside`))},document.addEventListener(`mousedown`,this._clickOutsideHandler)}disconnectedCallback(){super.disconnectedCallback(),this._clickOutsideHandler&&=(document.removeEventListener(`mousedown`,this._clickOutsideHandler),null),this._clearPressTimer()}_clearPressTimer(){this._pressTimer!==null&&(clearTimeout(this._pressTimer),this._pressTimer=null)}_dispatch(e){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}))}_handleMouseDown(){this._clearPressTimer(),this._pressTimer=setTimeout(()=>{this._isSelectingState=!0,this._dispatch(`intlayer:press`)},this.pressDuration)}_handleMouseEnter(){this._isHovered=!0,this._dispatch(`intlayer:hover`)}_handleMouseUpOrLeave(){this._isHovered&&(this._isHovered=!1,this._dispatch(`intlayer:unhover`)),this._clearPressTimer()}_handleClick(e){(this.isSelecting||this._isSelectingState)&&(e.preventDefault(),e.stopPropagation())}_handleBlur(){this._isSelectingState=!1}render(){return o`
22
+ <span
23
+ class="wrapper"
24
+ ?data-active=${this.isSelecting||this._isSelectingState||this._isHovered}
25
+ role="button"
26
+ tabindex="0"
27
+ @mousedown=${this._handleMouseDown}
28
+ @mouseup=${this._handleMouseUpOrLeave}
29
+ @mouseleave=${this._handleMouseUpOrLeave}
30
+ @mouseenter=${this._handleMouseEnter}
31
+ @click=${this._handleClick}
32
+ @touchstart=${this._handleMouseDown}
33
+ @touchend=${this._handleMouseUpOrLeave}
34
+ @touchcancel=${this._handleMouseUpOrLeave}
35
+ @blur=${this._handleBlur}
36
+ @keyup=${()=>{}}
37
+ >
38
+ <slot></slot>
39
+ </span>
40
+ `}};e([s({type:Boolean,attribute:`is-selecting`})],u.prototype,`isSelecting`,void 0),e([s({type:Number,attribute:`press-duration`})],u.prototype,`pressDuration`,void 0),e([l()],u.prototype,`_isHovered`,void 0),e([l()],u.prototype,`_isSelectingState`,void 0),e([c(`.wrapper`)],u.prototype,`_wrapper`,void 0);const d=()=>{typeof customElements>`u`||(customElements.get(`intlayer-content-selector`)||customElements.define(`intlayer-content-selector`,u),t(),n(),r())};export{u as IntlayerContentSelectorElement,d as defineIntlayerElements};
41
+ //# sourceMappingURL=ContentSelector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/components/ContentSelector.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { defineIntlayerContentSelectorWrapper } from './ContentSelectorWrapper';\nimport { defineIntlayerEditedContent } from './EditedContent';\nimport { defineIntlayerEditorElement } from './IntlayerEditor';\n\nconst DEFAULT_PRESS_DURATION = 250;\n\n/**\n * <intlayer-content-selector>\n *\n * A framework-agnostic web component that wraps content with Intlayer editor\n * selection UI (hover outline, long-press to select, click-outside to deselect).\n *\n * Replaces the per-framework ContentSelector components (React, Svelte, Vue, Solid).\n *\n * @fires intlayer:press - Fired after a long press (pressDuration ms). Bubbles.\n * @fires intlayer:hover - Fired on mouseenter. Bubbles.\n * @fires intlayer:unhover - Fired on mouseleave / mouseup. Bubbles.\n * @fires intlayer:click-outside - Fired when a click occurs outside the element. Bubbles.\n *\n * @prop {boolean} isSelecting - Whether this element is currently selected (external state)\n * @prop {number} pressDuration - Long-press threshold in ms. Default: 250\n */\nexport class IntlayerContentSelectorElement extends LitElement {\n static styles = css`\n :host {\n display: contents;\n }\n\n .wrapper {\n display: inline-block;\n cursor: pointer;\n user-select: none;\n border-radius: 0.375rem;\n outline-width: 2px;\n outline-offset: 4px;\n outline-style: solid;\n outline-color: transparent;\n transition: all 100ms 50ms ease-in-out;\n }\n\n .wrapper[data-active] {\n outline-color: inherit;\n }\n `;\n\n @property({ type: Boolean, attribute: 'is-selecting' })\n isSelecting = false;\n\n @property({ type: Number, attribute: 'press-duration' })\n pressDuration = DEFAULT_PRESS_DURATION;\n\n @state() private _isHovered = false;\n @state() private _isSelectingState = false;\n\n @query('.wrapper') private _wrapper!: HTMLSpanElement;\n\n private _pressTimer: ReturnType<typeof setTimeout> | null = null;\n private _clickOutsideHandler: ((e: MouseEvent) => void) | null = null;\n\n connectedCallback(): void {\n super.connectedCallback();\n this._clickOutsideHandler = (e: MouseEvent) => {\n // composedPath() pierces shadow boundaries\n if (!e.composedPath().includes(this)) {\n this._isSelectingState = false;\n this._dispatch('intlayer:click-outside');\n }\n };\n document.addEventListener('mousedown', this._clickOutsideHandler);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._clickOutsideHandler) {\n document.removeEventListener('mousedown', this._clickOutsideHandler);\n this._clickOutsideHandler = null;\n }\n this._clearPressTimer();\n }\n\n private _clearPressTimer(): void {\n if (this._pressTimer !== null) {\n clearTimeout(this._pressTimer);\n this._pressTimer = null;\n }\n }\n\n private _dispatch(eventName: string): void {\n this.dispatchEvent(\n new CustomEvent(eventName, { bubbles: true, composed: true })\n );\n }\n\n private _handleMouseDown(): void {\n this._clearPressTimer();\n this._pressTimer = setTimeout(() => {\n this._isSelectingState = true;\n this._dispatch('intlayer:press');\n }, this.pressDuration);\n }\n\n private _handleMouseEnter(): void {\n this._isHovered = true;\n this._dispatch('intlayer:hover');\n }\n\n private _handleMouseUpOrLeave(): void {\n if (this._isHovered) {\n this._isHovered = false;\n this._dispatch('intlayer:unhover');\n }\n this._clearPressTimer();\n }\n\n private _handleClick(e: MouseEvent): void {\n if (this.isSelecting || this._isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n private _handleBlur(): void {\n this._isSelectingState = false;\n }\n\n render() {\n const isActive =\n this.isSelecting || this._isSelectingState || this._isHovered;\n return html`\n <span\n class=\"wrapper\"\n ?data-active=${isActive}\n role=\"button\"\n tabindex=\"0\"\n @mousedown=${this._handleMouseDown}\n @mouseup=${this._handleMouseUpOrLeave}\n @mouseleave=${this._handleMouseUpOrLeave}\n @mouseenter=${this._handleMouseEnter}\n @click=${this._handleClick}\n @touchstart=${this._handleMouseDown}\n @touchend=${this._handleMouseUpOrLeave}\n @touchcancel=${this._handleMouseUpOrLeave}\n @blur=${this._handleBlur}\n @keyup=${() => {}}\n >\n <slot></slot>\n </span>\n `;\n }\n}\n\n/**\n * Register all Intlayer custom elements.\n * Call this once at application startup (inside IntlayerEditorProvider or similar).\n * Safe to call multiple times — only registers elements that are not yet defined.\n */\nexport const defineIntlayerElements = (): void => {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('intlayer-content-selector')) {\n customElements.define(\n 'intlayer-content-selector',\n IntlayerContentSelectorElement\n );\n }\n defineIntlayerContentSelectorWrapper();\n defineIntlayerEditedContent();\n defineIntlayerEditorElement();\n};\n"],"mappings":"4aAwBA,IAAa,EAAb,cAAoD,CAAW,gDAwB/C,sBAGE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