@intlayer/next-i18next 9.5.2 → 9.5.4-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.
- package/README.md +9 -9
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/package.json +13 -12
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +0 -39
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs +0 -161
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs +0 -269
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs +0 -161
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs +0 -88
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs +0 -27
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs +0 -80
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs +0 -75
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs +0 -383
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs +0 -45
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs +0 -59
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs +0 -36
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs +0 -42
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs +0 -82
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs +0 -55
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/index.cjs +0 -19
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs +0 -9
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs +0 -22
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs.map +0 -1
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs +0 -32
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs +0 -25
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs +0 -78
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs +0 -24
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs +0 -11
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs.map +0 -1
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs +0 -39
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs.map +0 -1
- package/dist/cjs/warnUnsupported.cjs +0 -28
- package/dist/cjs/warnUnsupported.cjs.map +0 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +0 -38
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs +0 -160
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs +0 -266
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs +0 -159
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs +0 -88
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs +0 -26
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs +0 -80
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs +0 -74
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs +0 -381
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs +0 -45
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs +0 -58
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs +0 -33
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs +0 -39
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs +0 -79
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs +0 -52
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/index.mjs +0 -18
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs +0 -8
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs +0 -21
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs.map +0 -1
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs +0 -6
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs +0 -23
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs +0 -77
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs +0 -22
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs +0 -11
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs.map +0 -1
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs +0 -38
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs.map +0 -1
- package/dist/esm/warnUnsupported.mjs +0 -27
- package/dist/esm/warnUnsupported.mjs.map +0 -1
- package/dist/types/warnUnsupported.d.ts +0 -18
- package/dist/types/warnUnsupported.d.ts.map +0 -1
package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.cjs","names":["getGlobalEditorManager","NodeTypes","onGlobalEditorManagerChange"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\nimport { getGlobalEditorManager, onGlobalEditorManagerChange } from \"../core/globalManager.mjs\";\nimport { isSameKeyPath } from \"@intlayer/core/utils\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/components/ContentSelectorWrapper.ts\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-content-selector-wrapper>\n*\n* Framework-agnostic web component 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*/\nvar IntlayerContentSelectorWrapperElement = class extends _HTMLElement {\n\t_keyPathJson = \"[]\";\n\t_dictionaryKey = \"\";\n\t_editorEnabled = false;\n\t_isInIframe = false;\n\t_isSelected = false;\n\t_editedValue = void 0;\n\t_renderState = null;\n\t_selector = null;\n\t_unsubManager = null;\n\t_unsubEnabled = null;\n\t_unsubFocused = null;\n\t_unsubEditedContent = null;\n\tstatic get observedAttributes() {\n\t\treturn [\"key-path\", \"dictionary-key\"];\n\t}\n\tget keyPathJson() {\n\t\treturn this._keyPathJson;\n\t}\n\tset keyPathJson(v) {\n\t\tthis._keyPathJson = v;\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._updateEditedValue(manager);\n\t}\n\tget dictionaryKey() {\n\t\treturn this._dictionaryKey;\n\t}\n\tset dictionaryKey(v) {\n\t\tthis._dictionaryKey = v;\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._updateEditedValue(manager);\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = \":host { display: contents; }\";\n\t\tshadow.appendChild(style);\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tif (name === \"key-path\") {\n\t\t\tthis._keyPathJson = newVal ?? \"[]\";\n\t\t\tconst manager = getGlobalEditorManager();\n\t\t\tif (manager) this._updateEditedValue(manager);\n\t\t} else if (name === \"dictionary-key\") {\n\t\t\tthis._dictionaryKey = newVal ?? \"\";\n\t\t\tconst manager = getGlobalEditorManager();\n\t\t\tif (manager) this._updateEditedValue(manager);\n\t\t}\n\t}\n\tconnectedCallback() {\n\t\tif (typeof window !== \"undefined\") this._isInIframe = window.self !== window.top;\n\t\tthis._subscribeToManager();\n\t\tthis._render();\n\t}\n\tdisconnectedCallback() {\n\t\tthis._teardown();\n\t}\n\t_teardown() {\n\t\tthis._unsubManager?.();\n\t\tthis._unsubEnabled?.();\n\t\tthis._unsubFocused?.();\n\t\tthis._unsubEditedContent?.();\n\t\tthis._unsubManager = null;\n\t\tthis._unsubEnabled = null;\n\t\tthis._unsubFocused = null;\n\t\tthis._unsubEditedContent = null;\n\t}\n\t_getRawKeyPath() {\n\t\ttry {\n\t\t\treturn JSON.parse(this._keyPathJson);\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\t_getFilteredKeyPath() {\n\t\treturn this._getRawKeyPath().filter((keyPath) => keyPath.type !== NodeTypes.TRANSLATION);\n\t}\n\t_updateEditedValue(manager) {\n\t\tconst filteredKeyPath = this._getFilteredKeyPath();\n\t\tif (!this._dictionaryKey || filteredKeyPath.length === 0) {\n\t\t\tthis._editedValue = void 0;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tconst rawKeyPath = this._getRawKeyPath();\n\t\tconst lastStepType = rawKeyPath[rawKeyPath.length - 1]?.type;\n\t\tif (lastStepType === NodeTypes.MARKDOWN || lastStepType === NodeTypes.HTML || lastStepType === NodeTypes.INSERTION || lastStepType === NodeTypes.FILE) {\n\t\t\tthis._editedValue = void 0;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tlet value = manager.getContentValue(this._dictionaryKey, filteredKeyPath);\n\t\tif (value !== null && value !== void 0 && typeof value === \"object\" && value.nodeType === NodeTypes.TRANSLATION) {\n\t\t\tconst locale = manager.currentLocale.value;\n\t\t\tvalue = locale ? value[NodeTypes.TRANSLATION][locale] : void 0;\n\t\t}\n\t\tthis._editedValue = value;\n\t\tthis._render();\n\t}\n\t_updateIsSelected(focusedContent) {\n\t\tif (!focusedContent) {\n\t\t\tthis._isSelected = false;\n\t\t\tthis._updateSelectorAttr();\n\t\t\treturn;\n\t\t}\n\t\tconst keyPath = this._getFilteredKeyPath();\n\t\tconst wasSelected = this._isSelected;\n\t\tthis._isSelected = focusedContent.dictionaryKey === this._dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent.keyPath ?? [], keyPath);\n\t\tthis._updateSelectorAttr();\n\t\tif (this._isSelected && !wasSelected) this._scrollIntoViewIfNeeded();\n\t}\n\t_scrollIntoViewIfNeeded() {\n\t\ttry {\n\t\t\tlet rect;\n\t\t\tif (this._selector) {\n\t\t\t\tconst innerWrapper = this._selector.shadowRoot?.querySelector(\".wrapper\");\n\t\t\t\tif (innerWrapper) {\n\t\t\t\t\tconst r = innerWrapper.getBoundingClientRect();\n\t\t\t\t\tif (r.width > 0 || r.height > 0) rect = r;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!rect && this.childNodes.length > 0) {\n\t\t\t\tconst range = document.createRange();\n\t\t\t\trange.selectNodeContents(this);\n\t\t\t\tconst r = range.getBoundingClientRect();\n\t\t\t\tif (r.width > 0 || r.height > 0) rect = r;\n\t\t\t}\n\t\t\tif (!rect) rect = this.getBoundingClientRect();\n\t\t\tconst viewportHeight = window.innerHeight || document.documentElement.clientHeight;\n\t\t\tconst viewportWidth = window.innerWidth || document.documentElement.clientWidth;\n\t\t\tif (!(rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth)) {\n\t\t\t\tconst scrollY = window.scrollY ?? document.documentElement.scrollTop;\n\t\t\t\tconst targetScrollY = rect.top + scrollY - viewportHeight * .25;\n\t\t\t\twindow.scrollTo({\n\t\t\t\t\ttop: Math.max(0, targetScrollY),\n\t\t\t\t\tbehavior: \"smooth\"\n\t\t\t\t});\n\t\t\t}\n\t\t} catch {}\n\t}\n\t_updateSelectorAttr() {\n\t\tif (!this._selector) return;\n\t\tif (this._isSelected) this._selector.setAttribute(\"is-selecting\", \"\");\n\t\telse this._selector.removeAttribute(\"is-selecting\");\n\t}\n\t_subscribeToManager() {\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._setupManagerSubscriptions(manager);\n\t\tthis._unsubManager = onGlobalEditorManagerChange((m) => {\n\t\t\tthis._unsubEnabled?.();\n\t\t\tthis._unsubFocused?.();\n\t\t\tthis._unsubEditedContent?.();\n\t\t\tthis._unsubEnabled = null;\n\t\t\tthis._unsubFocused = null;\n\t\t\tthis._unsubEditedContent = null;\n\t\t\tif (m) this._setupManagerSubscriptions(m);\n\t\t\telse {\n\t\t\t\tthis._editorEnabled = false;\n\t\t\t\tthis._isSelected = false;\n\t\t\t\tthis._editedValue = void 0;\n\t\t\t\tthis._render();\n\t\t\t}\n\t\t});\n\t}\n\t_setupManagerSubscriptions(manager) {\n\t\tthis._editorEnabled = manager.editorEnabled.value ?? false;\n\t\tthis._updateIsSelected(manager.focusedContent.value);\n\t\tthis._updateEditedValue(manager);\n\t\tconst handleEnabledChange = (e) => {\n\t\t\tthis._editorEnabled = e.detail;\n\t\t\tthis._render();\n\t\t};\n\t\tconst handleFocusedChange = (e) => {\n\t\t\tthis._updateIsSelected(e.detail);\n\t\t};\n\t\tconst handleEditedContentChange = () => {\n\t\t\tthis._updateEditedValue(manager);\n\t\t};\n\t\tmanager.editorEnabled.addEventListener(\"change\", handleEnabledChange);\n\t\tmanager.focusedContent.addEventListener(\"change\", handleFocusedChange);\n\t\tmanager.editedContent.addEventListener(\"change\", handleEditedContentChange);\n\t\tthis._unsubEnabled = () => manager.editorEnabled.removeEventListener(\"change\", handleEnabledChange);\n\t\tthis._unsubFocused = () => manager.focusedContent.removeEventListener(\"change\", handleFocusedChange);\n\t\tthis._unsubEditedContent = () => manager.editedContent.removeEventListener(\"change\", handleEditedContentChange);\n\t}\n\t_handlePress(e) {\n\t\te.stopPropagation();\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (!manager) return;\n\t\tmanager.focusedContent.set({\n\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\tkeyPath: this._getFilteredKeyPath()\n\t\t});\n\t}\n\t_handleHover(e) {\n\t\te.stopPropagation();\n\t\tgetGlobalEditorManager()?.messenger.send(`${\"INTLAYER_HOVERED_CONTENT_CHANGED\"}/post`, {\n\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\tkeyPath: this._getFilteredKeyPath()\n\t\t});\n\t}\n\t_handleUnhover(e) {\n\t\te.stopPropagation();\n\t\tgetGlobalEditorManager()?.messenger.send(`${\"INTLAYER_HOVERED_CONTENT_CHANGED\"}/post`, null);\n\t}\n\t_render() {\n\t\tconst useWrapper = this._isInIframe && this._editorEnabled;\n\t\tconst editedValue = this._editedValue;\n\t\tconst newState = !useWrapper ? \"simple\" : typeof editedValue === \"string\" || typeof editedValue === \"number\" || typeof editedValue === \"boolean\" ? \"wrapped-text\" : \"wrapped-slot\";\n\t\tif (this._renderState !== newState) {\n\t\t\tthis._rebuildContent(newState);\n\t\t\treturn;\n\t\t}\n\t\tif (newState !== \"simple\" && this._selector) {\n\t\t\tthis._updateSelectorAttr();\n\t\t\tif (newState === \"wrapped-text\" && this._selector.firstChild?.nodeType === Node.TEXT_NODE) this._selector.firstChild.data = String(editedValue);\n\t\t}\n\t}\n\t_rebuildContent(state) {\n\t\tconst shadow = this.shadowRoot;\n\t\twhile (shadow.childNodes.length > 1) shadow.removeChild(shadow.lastChild);\n\t\tthis._selector = null;\n\t\tif (state === \"simple\") shadow.appendChild(document.createElement(\"slot\"));\n\t\telse {\n\t\t\tconst selector = document.createElement(\"intlayer-content-selector\");\n\t\t\tthis._selector = selector;\n\t\t\tif (this._isSelected) selector.setAttribute(\"is-selecting\", \"\");\n\t\t\tselector.addEventListener(\"intlayer:press\", (e) => this._handlePress(e));\n\t\t\tselector.addEventListener(\"intlayer:hover\", (e) => this._handleHover(e));\n\t\t\tselector.addEventListener(\"intlayer:unhover\", (e) => this._handleUnhover(e));\n\t\t\tif (state === \"wrapped-text\") selector.appendChild(document.createTextNode(String(this._editedValue)));\n\t\t\telse selector.appendChild(document.createElement(\"slot\"));\n\t\t\tshadow.appendChild(selector);\n\t\t}\n\t\tthis._renderState = state;\n\t}\n};\nconst defineIntlayerContentSelectorWrapper = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-content-selector-wrapper\")) customElements.define(\"intlayer-content-selector-wrapper\", IntlayerContentSelectorWrapperElement);\n};\n\n//#endregion\nexport { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper };\n//# sourceMappingURL=ContentSelectorWrapper.mjs.map"],"mappings":";;;;;;;AAMA,MAAM,eAAe,OAAO,gBAAgB,cAAc,cAAc,MAAM;;;;;;;;;;;;;;;AAe9E,IAAI,wCAAwC,cAAc,aAAa;CACtE,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,cAAc;CACd,eAAe,KAAK;CACpB,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,sBAAsB;CACtB,WAAW,qBAAqB;AAC/B,SAAO,CAAC,YAAY,iBAAiB;;CAEtC,IAAI,cAAc;AACjB,SAAO,KAAK;;CAEb,IAAI,YAAY,GAAG;AAClB,OAAK,eAAe;EACpB,MAAM,UAAUA,8CAAwB;AACxC,MAAI,QAAS,MAAK,mBAAmB,QAAQ;;CAE9C,IAAI,gBAAgB;AACnB,SAAO,KAAK;;CAEb,IAAI,cAAc,GAAG;AACpB,OAAK,iBAAiB;EACtB,MAAM,UAAUA,8CAAwB;AACxC,MAAI,QAAS,MAAK,mBAAmB,QAAQ;;CAE9C,cAAc;AACb,SAAO;EACP,MAAM,SAAS,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC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,gBAAgB,GAAG;AAC/D,YAAS,iBAAiB,mBAAmB,MAAM,KAAK,aAAa,EAAE,CAAC;AACxE,YAAS,iBAAiB,mBAAmB,MAAM,KAAK,aAAa,EAAE,CAAC;AACxE,YAAS,iBAAiB,qBAAqB,MAAM,KAAK,eAAe,EAAE,CAAC;AAC5E,OAAI,UAAU,eAAgB,UAAS,YAAY,SAAS,eAAe,OAAO,KAAK,aAAa,CAAC,CAAC;OACjG,UAAS,YAAY,SAAS,cAAc,OAAO,CAAC;AACzD,UAAO,YAAY,SAAS;;AAE7B,OAAK,eAAe;;;AAGtB,MAAM,6CAA6C;AAClD,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,oCAAoC,CAAE,gBAAe,OAAO,qCAAqC,sCAAsC"}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_globalManager = require('../core/globalManager.cjs');
|
|
3
|
-
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
4
|
-
|
|
5
|
-
//#region ../../packages/@intlayer/editor/dist/esm/components/EditedContent.mjs
|
|
6
|
-
const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
|
|
7
|
-
/**
|
|
8
|
-
* <intlayer-edited-content>
|
|
9
|
-
*
|
|
10
|
-
* Framework-agnostic web component that displays edited content from the Intlayer
|
|
11
|
-
* editor. When the editor has an edited value for the given dictionary key and
|
|
12
|
-
* key path, it renders the edited value; otherwise it renders the original
|
|
13
|
-
* content via a slot.
|
|
14
|
-
*
|
|
15
|
-
* Always wraps content in <intlayer-content-selector-wrapper> for selection UI.
|
|
16
|
-
*
|
|
17
|
-
* @attr {string} dictionary-key - The dictionary key owning this content node
|
|
18
|
-
* @attr {string} key-path - JSON-serialized KeyPath[] for this content node
|
|
19
|
-
* @attr {string} locale - The current locale string
|
|
20
|
-
*/
|
|
21
|
-
var IntlayerEditedContentElement = class extends _HTMLElement {
|
|
22
|
-
_dictionaryKey = "";
|
|
23
|
-
_keyPathJson = "[]";
|
|
24
|
-
_locale = "";
|
|
25
|
-
_editedText = null;
|
|
26
|
-
_unsubManager = null;
|
|
27
|
-
_unsubEditedContent = null;
|
|
28
|
-
_selectorWrapper;
|
|
29
|
-
_slot;
|
|
30
|
-
static get observedAttributes() {
|
|
31
|
-
return [
|
|
32
|
-
"dictionary-key",
|
|
33
|
-
"key-path",
|
|
34
|
-
"locale"
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
get dictionaryKey() {
|
|
38
|
-
return this._dictionaryKey;
|
|
39
|
-
}
|
|
40
|
-
set dictionaryKey(v) {
|
|
41
|
-
this._dictionaryKey = v;
|
|
42
|
-
this._selectorWrapper.setAttribute("dictionary-key", v);
|
|
43
|
-
}
|
|
44
|
-
get keyPathJson() {
|
|
45
|
-
return this._keyPathJson;
|
|
46
|
-
}
|
|
47
|
-
set keyPathJson(v) {
|
|
48
|
-
this._keyPathJson = v;
|
|
49
|
-
this._selectorWrapper.setAttribute("key-path", v);
|
|
50
|
-
}
|
|
51
|
-
get locale() {
|
|
52
|
-
return this._locale;
|
|
53
|
-
}
|
|
54
|
-
set locale(v) {
|
|
55
|
-
this._locale = v;
|
|
56
|
-
}
|
|
57
|
-
constructor() {
|
|
58
|
-
super();
|
|
59
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
60
|
-
const style = document.createElement("style");
|
|
61
|
-
style.textContent = ":host { display: contents; }";
|
|
62
|
-
shadow.appendChild(style);
|
|
63
|
-
this._selectorWrapper = document.createElement("intlayer-content-selector-wrapper");
|
|
64
|
-
this._slot = document.createElement("slot");
|
|
65
|
-
this._selectorWrapper.appendChild(this._slot);
|
|
66
|
-
shadow.appendChild(this._selectorWrapper);
|
|
67
|
-
}
|
|
68
|
-
attributeChangedCallback(name, _oldVal, newVal) {
|
|
69
|
-
const val = newVal ?? "";
|
|
70
|
-
if (name === "dictionary-key") {
|
|
71
|
-
this._dictionaryKey = val;
|
|
72
|
-
this._selectorWrapper.setAttribute("dictionary-key", val);
|
|
73
|
-
} else if (name === "key-path") {
|
|
74
|
-
this._keyPathJson = val || "[]";
|
|
75
|
-
this._selectorWrapper.setAttribute("key-path", this._keyPathJson);
|
|
76
|
-
} else if (name === "locale") this._locale = val;
|
|
77
|
-
}
|
|
78
|
-
connectedCallback() {
|
|
79
|
-
this._subscribeToManager();
|
|
80
|
-
}
|
|
81
|
-
disconnectedCallback() {
|
|
82
|
-
this._teardown();
|
|
83
|
-
}
|
|
84
|
-
_teardown() {
|
|
85
|
-
this._unsubManager?.();
|
|
86
|
-
this._unsubEditedContent?.();
|
|
87
|
-
this._unsubManager = null;
|
|
88
|
-
this._unsubEditedContent = null;
|
|
89
|
-
}
|
|
90
|
-
_getKeyPath() {
|
|
91
|
-
try {
|
|
92
|
-
return JSON.parse(this._keyPathJson);
|
|
93
|
-
} catch {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
_render() {
|
|
98
|
-
while (this._selectorWrapper.firstChild) this._selectorWrapper.removeChild(this._selectorWrapper.firstChild);
|
|
99
|
-
if (this._editedText !== null) this._selectorWrapper.appendChild(document.createTextNode(this._editedText));
|
|
100
|
-
else this._selectorWrapper.appendChild(this._slot);
|
|
101
|
-
}
|
|
102
|
-
_resolveEditedText(manager) {
|
|
103
|
-
const keyPath = this._getKeyPath();
|
|
104
|
-
const editedValue = manager.getContentValue(this._dictionaryKey, keyPath);
|
|
105
|
-
if (editedValue === void 0 || editedValue === null) {
|
|
106
|
-
this._editedText = null;
|
|
107
|
-
this._render();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (typeof editedValue === "string" || typeof editedValue === "number") {
|
|
111
|
-
this._editedText = String(editedValue);
|
|
112
|
-
this._render();
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (typeof editedValue === "object") {
|
|
116
|
-
const locale = this._locale || void 0;
|
|
117
|
-
const transformed = (0, _intlayer_core_interpreter.getContent)(editedValue, {
|
|
118
|
-
locale,
|
|
119
|
-
dictionaryKey: this._dictionaryKey,
|
|
120
|
-
keyPath
|
|
121
|
-
}, (0, _intlayer_core_interpreter.getBasePlugins)(locale));
|
|
122
|
-
if (typeof transformed === "string" || typeof transformed === "number") this._editedText = String(transformed);
|
|
123
|
-
else {
|
|
124
|
-
console.error(`[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`);
|
|
125
|
-
this._editedText = null;
|
|
126
|
-
}
|
|
127
|
-
this._render();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
this._editedText = null;
|
|
131
|
-
this._render();
|
|
132
|
-
}
|
|
133
|
-
_setupManagerSubscriptions(manager) {
|
|
134
|
-
this._resolveEditedText(manager);
|
|
135
|
-
const handleChange = () => this._resolveEditedText(manager);
|
|
136
|
-
manager.editedContent.addEventListener("change", handleChange);
|
|
137
|
-
this._unsubEditedContent = () => manager.editedContent.removeEventListener("change", handleChange);
|
|
138
|
-
}
|
|
139
|
-
_subscribeToManager() {
|
|
140
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
141
|
-
if (manager) this._setupManagerSubscriptions(manager);
|
|
142
|
-
this._unsubManager = require_globalManager.onGlobalEditorManagerChange((m) => {
|
|
143
|
-
this._unsubEditedContent?.();
|
|
144
|
-
this._unsubEditedContent = null;
|
|
145
|
-
if (m) this._setupManagerSubscriptions(m);
|
|
146
|
-
else {
|
|
147
|
-
this._editedText = null;
|
|
148
|
-
this._render();
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
const defineIntlayerEditedContent = () => {
|
|
154
|
-
if (typeof customElements === "undefined") return;
|
|
155
|
-
if (!customElements.get("intlayer-edited-content")) customElements.define("intlayer-edited-content", IntlayerEditedContentElement);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
//#endregion
|
|
159
|
-
exports.IntlayerEditedContentElement = IntlayerEditedContentElement;
|
|
160
|
-
exports.defineIntlayerEditedContent = defineIntlayerEditedContent;
|
|
161
|
-
//# sourceMappingURL=EditedContent.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContent.cjs","names":["getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/EditedContent.mjs"],"sourcesContent":["import { getGlobalEditorManager, onGlobalEditorManagerChange } from \"../core/globalManager.mjs\";\nimport { getBasePlugins, getContent } from \"@intlayer/core/interpreter\";\n\n//#region src/components/EditedContent.ts\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-edited-content>\n*\n* Framework-agnostic web component 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*/\nvar IntlayerEditedContentElement = class extends _HTMLElement {\n\t_dictionaryKey = \"\";\n\t_keyPathJson = \"[]\";\n\t_locale = \"\";\n\t_editedText = null;\n\t_unsubManager = null;\n\t_unsubEditedContent = null;\n\t_selectorWrapper;\n\t_slot;\n\tstatic get observedAttributes() {\n\t\treturn [\n\t\t\t\"dictionary-key\",\n\t\t\t\"key-path\",\n\t\t\t\"locale\"\n\t\t];\n\t}\n\tget dictionaryKey() {\n\t\treturn this._dictionaryKey;\n\t}\n\tset dictionaryKey(v) {\n\t\tthis._dictionaryKey = v;\n\t\tthis._selectorWrapper.setAttribute(\"dictionary-key\", v);\n\t}\n\tget keyPathJson() {\n\t\treturn this._keyPathJson;\n\t}\n\tset keyPathJson(v) {\n\t\tthis._keyPathJson = v;\n\t\tthis._selectorWrapper.setAttribute(\"key-path\", v);\n\t}\n\tget locale() {\n\t\treturn this._locale;\n\t}\n\tset locale(v) {\n\t\tthis._locale = v;\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tconst shadow = this.attachShadow({ mode: \"open\" });\n\t\tconst style = document.createElement(\"style\");\n\t\tstyle.textContent = \":host { display: contents; }\";\n\t\tshadow.appendChild(style);\n\t\tthis._selectorWrapper = document.createElement(\"intlayer-content-selector-wrapper\");\n\t\tthis._slot = document.createElement(\"slot\");\n\t\tthis._selectorWrapper.appendChild(this._slot);\n\t\tshadow.appendChild(this._selectorWrapper);\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tconst val = newVal ?? \"\";\n\t\tif (name === \"dictionary-key\") {\n\t\t\tthis._dictionaryKey = val;\n\t\t\tthis._selectorWrapper.setAttribute(\"dictionary-key\", val);\n\t\t} else if (name === \"key-path\") {\n\t\t\tthis._keyPathJson = val || \"[]\";\n\t\t\tthis._selectorWrapper.setAttribute(\"key-path\", this._keyPathJson);\n\t\t} else if (name === \"locale\") this._locale = val;\n\t}\n\tconnectedCallback() {\n\t\tthis._subscribeToManager();\n\t}\n\tdisconnectedCallback() {\n\t\tthis._teardown();\n\t}\n\t_teardown() {\n\t\tthis._unsubManager?.();\n\t\tthis._unsubEditedContent?.();\n\t\tthis._unsubManager = null;\n\t\tthis._unsubEditedContent = null;\n\t}\n\t_getKeyPath() {\n\t\ttry {\n\t\t\treturn JSON.parse(this._keyPathJson);\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\t_render() {\n\t\twhile (this._selectorWrapper.firstChild) this._selectorWrapper.removeChild(this._selectorWrapper.firstChild);\n\t\tif (this._editedText !== null) this._selectorWrapper.appendChild(document.createTextNode(this._editedText));\n\t\telse this._selectorWrapper.appendChild(this._slot);\n\t}\n\t_resolveEditedText(manager) {\n\t\tconst keyPath = this._getKeyPath();\n\t\tconst editedValue = manager.getContentValue(this._dictionaryKey, keyPath);\n\t\tif (editedValue === void 0 || editedValue === null) {\n\t\t\tthis._editedText = null;\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tif (typeof editedValue === \"string\" || typeof editedValue === \"number\") {\n\t\t\tthis._editedText = String(editedValue);\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tif (typeof editedValue === \"object\") {\n\t\t\tconst locale = this._locale || void 0;\n\t\t\tconst transformed = getContent(editedValue, {\n\t\t\t\tlocale,\n\t\t\t\tdictionaryKey: this._dictionaryKey,\n\t\t\t\tkeyPath\n\t\t\t}, getBasePlugins(locale));\n\t\t\tif (typeof transformed === \"string\" || typeof transformed === \"number\") this._editedText = String(transformed);\n\t\t\telse {\n\t\t\t\tconsole.error(`[intlayer-edited-content] Incorrect edited content format. Expected string. Value: ${JSON.stringify(transformed)}`);\n\t\t\t\tthis._editedText = null;\n\t\t\t}\n\t\t\tthis._render();\n\t\t\treturn;\n\t\t}\n\t\tthis._editedText = null;\n\t\tthis._render();\n\t}\n\t_setupManagerSubscriptions(manager) {\n\t\tthis._resolveEditedText(manager);\n\t\tconst handleChange = () => this._resolveEditedText(manager);\n\t\tmanager.editedContent.addEventListener(\"change\", handleChange);\n\t\tthis._unsubEditedContent = () => manager.editedContent.removeEventListener(\"change\", handleChange);\n\t}\n\t_subscribeToManager() {\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) this._setupManagerSubscriptions(manager);\n\t\tthis._unsubManager = onGlobalEditorManagerChange((m) => {\n\t\t\tthis._unsubEditedContent?.();\n\t\t\tthis._unsubEditedContent = null;\n\t\t\tif (m) this._setupManagerSubscriptions(m);\n\t\t\telse {\n\t\t\t\tthis._editedText = null;\n\t\t\t\tthis._render();\n\t\t\t}\n\t\t});\n\t}\n};\nconst defineIntlayerEditedContent = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-edited-content\")) customElements.define(\"intlayer-edited-content\", IntlayerEditedContentElement);\n};\n\n//#endregion\nexport { IntlayerEditedContentElement, defineIntlayerEditedContent };\n//# sourceMapping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,QAAQ,cAAc,oBAAoB,UAAU,aAAa;;CAEnG,sBAAsB;EACrB,MAAM,UAAUA,8CAAwB;AACxC,MAAI,QAAS,MAAK,2BAA2B,QAAQ;AACrD,OAAK,gBAAgBC,mDAA6B,MAAM;AACvD,QAAK,uBAAuB;AAC5B,QAAK,sBAAsB;AAC3B,OAAI,EAAG,MAAK,2BAA2B,EAAE;QACpC;AACJ,SAAK,cAAc;AACnB,SAAK,SAAS;;IAEd;;;AAGJ,MAAM,oCAAoC;AACzC,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,0BAA0B,CAAE,gBAAe,OAAO,2BAA2B,6BAA6B"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const require_globalManager = require('../core/globalManager.cjs');
|
|
2
|
-
const require_initEditorClient = require('../core/initEditorClient.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs
|
|
5
|
-
const _HTMLElement = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
|
|
6
|
-
/**
|
|
7
|
-
* <intlayer-editor>
|
|
8
|
-
*
|
|
9
|
-
* A framework-agnostic web component that manages the Intlayer editor singleton
|
|
10
|
-
* lifecycle and keeps the current locale in sync with the EditorStateManager.
|
|
11
|
-
*
|
|
12
|
-
* Drop this element once at the root of your application to activate the editor.
|
|
13
|
-
* It renders no UI.
|
|
14
|
-
*
|
|
15
|
-
* @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS property, not attribute)
|
|
16
|
-
* @prop {string} locale - The active application locale (attribute/property)
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Svelte
|
|
20
|
-
* <intlayer-editor .configuration={config} locale={$locale} />
|
|
21
|
-
*
|
|
22
|
-
* // Vue
|
|
23
|
-
* <intlayer-editor :configuration="config" :locale="currentLocale" />
|
|
24
|
-
*/
|
|
25
|
-
var IntlayerEditorElement = class extends _HTMLElement {
|
|
26
|
-
_configuration = void 0;
|
|
27
|
-
_locale = void 0;
|
|
28
|
-
_initialized = false;
|
|
29
|
-
_unsubManager = null;
|
|
30
|
-
static get observedAttributes() {
|
|
31
|
-
return ["locale"];
|
|
32
|
-
}
|
|
33
|
-
get configuration() {
|
|
34
|
-
return this._configuration;
|
|
35
|
-
}
|
|
36
|
-
set configuration(v) {
|
|
37
|
-
this._configuration = v;
|
|
38
|
-
if (!this._initialized) this._init();
|
|
39
|
-
}
|
|
40
|
-
get locale() {
|
|
41
|
-
return this._locale;
|
|
42
|
-
}
|
|
43
|
-
set locale(v) {
|
|
44
|
-
this._locale = v;
|
|
45
|
-
if (v && this._initialized) this._syncLocale(v);
|
|
46
|
-
}
|
|
47
|
-
attributeChangedCallback(name, _oldVal, newVal) {
|
|
48
|
-
if (name === "locale" && newVal !== null) {
|
|
49
|
-
this._locale = newVal;
|
|
50
|
-
if (this._initialized) this._syncLocale(newVal);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
connectedCallback() {
|
|
54
|
-
this._init();
|
|
55
|
-
}
|
|
56
|
-
disconnectedCallback() {
|
|
57
|
-
this._unsubManager?.();
|
|
58
|
-
this._unsubManager = null;
|
|
59
|
-
if (this._initialized) {
|
|
60
|
-
require_initEditorClient.stopEditorClient();
|
|
61
|
-
this._initialized = false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
_init() {
|
|
65
|
-
if (this._initialized) return;
|
|
66
|
-
require_initEditorClient.initEditorClient();
|
|
67
|
-
this._initialized = true;
|
|
68
|
-
if (this._locale) this._syncLocale(this._locale);
|
|
69
|
-
}
|
|
70
|
-
_syncLocale(locale) {
|
|
71
|
-
const manager = require_globalManager.getGlobalEditorManager();
|
|
72
|
-
if (manager) manager.currentLocale.set(locale);
|
|
73
|
-
else {
|
|
74
|
-
this._unsubManager?.();
|
|
75
|
-
this._unsubManager = require_globalManager.onGlobalEditorManagerChange((m) => {
|
|
76
|
-
if (m) {
|
|
77
|
-
this._unsubManager?.();
|
|
78
|
-
this._unsubManager = null;
|
|
79
|
-
m.currentLocale.set(locale);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
|
-
exports.IntlayerEditorElement = IntlayerEditorElement;
|
|
88
|
-
//# sourceMappingURL=IntlayerEditorElement.cjs.map
|
package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEditorElement.cjs","names":["getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs"],"sourcesContent":["import { getGlobalEditorManager, onGlobalEditorManagerChange } from \"../core/globalManager.mjs\";\nimport { initEditorClient, stopEditorClient } from \"../core/initEditorClient.mjs\";\n\n//#region src/components/IntlayerEditorElement.ts\nconst _HTMLElement = typeof HTMLElement !== \"undefined\" ? HTMLElement : class {};\n/**\n* <intlayer-editor>\n*\n* A framework-agnostic web component 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.\n*\n* @prop {IntlayerConfig} configuration - The Intlayer config (required; set as JS 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*/\nvar IntlayerEditorElement = class extends _HTMLElement {\n\t_configuration = void 0;\n\t_locale = void 0;\n\t_initialized = false;\n\t_unsubManager = null;\n\tstatic get observedAttributes() {\n\t\treturn [\"locale\"];\n\t}\n\tget configuration() {\n\t\treturn this._configuration;\n\t}\n\tset configuration(v) {\n\t\tthis._configuration = v;\n\t\tif (!this._initialized) this._init();\n\t}\n\tget locale() {\n\t\treturn this._locale;\n\t}\n\tset locale(v) {\n\t\tthis._locale = v;\n\t\tif (v && this._initialized) this._syncLocale(v);\n\t}\n\tattributeChangedCallback(name, _oldVal, newVal) {\n\t\tif (name === \"locale\" && newVal !== null) {\n\t\t\tthis._locale = newVal;\n\t\t\tif (this._initialized) this._syncLocale(newVal);\n\t\t}\n\t}\n\tconnectedCallback() {\n\t\tthis._init();\n\t}\n\tdisconnectedCallback() {\n\t\tthis._unsubManager?.();\n\t\tthis._unsubManager = null;\n\t\tif (this._initialized) {\n\t\t\tstopEditorClient();\n\t\t\tthis._initialized = false;\n\t\t}\n\t}\n\t_init() {\n\t\tif (this._initialized) return;\n\t\tinitEditorClient();\n\t\tthis._initialized = true;\n\t\tif (this._locale) this._syncLocale(this._locale);\n\t}\n\t_syncLocale(locale) {\n\t\tconst manager = getGlobalEditorManager();\n\t\tif (manager) manager.currentLocale.set(locale);\n\t\telse {\n\t\t\tthis._unsubManager?.();\n\t\t\tthis._unsubManager = onGlobalEditorManagerChange((m) => {\n\t\t\t\tif (m) {\n\t\t\t\t\tthis._unsubManager?.();\n\t\t\t\t\tthis._unsubManager = null;\n\t\t\t\t\tm.currentLocale.set(locale);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n};\n\n//#endregion\nexport { IntlayerEditorElement };\n//# sourceMappingURL=IntlayerEditorElement.mjs.map"],"mappings":";;;;AAIA,MAAM,eAAe,OAAO,gBAAgB,cAAc,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;AAoB9E,IAAI,wBAAwB,cAAc,aAAa;CACtD,iBAAiB,KAAK;CACtB,UAAU,KAAK;CACf,eAAe;CACf,gBAAgB;CAChB,WAAW,qBAAqB;AAC/B,SAAO,CAAC,SAAS;;CAElB,IAAI,gBAAgB;AACnB,SAAO,KAAK;;CAEb,IAAI,cAAc,GAAG;AACpB,OAAK,iBAAiB;AACtB,MAAI,CAAC,KAAK,aAAc,MAAK,OAAO;;CAErC,IAAI,SAAS;AACZ,SAAO,KAAK;;CAEb,IAAI,OAAO,GAAG;AACb,OAAK,UAAU;AACf,MAAI,KAAK,KAAK,aAAc,MAAK,YAAY,EAAE;;CAEhD,yBAAyB,MAAM,SAAS,QAAQ;AAC/C,MAAI,SAAS,YAAY,WAAW,MAAM;AACzC,QAAK,UAAU;AACf,OAAI,KAAK,aAAc,MAAK,YAAY,OAAO;;;CAGjD,oBAAoB;AACnB,OAAK,OAAO;;CAEb,uBAAuB;AACtB,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;AACrB,MAAI,KAAK,cAAc;AACtB,8CAAkB;AAClB,QAAK,eAAe;;;CAGtB,QAAQ;AACP,MAAI,KAAK,aAAc;AACvB,6CAAkB;AAClB,OAAK,eAAe;AACpB,MAAI,KAAK,QAAS,MAAK,YAAY,KAAK,QAAQ;;CAEjD,YAAY,QAAQ;EACnB,MAAM,UAAUA,8CAAwB;AACxC,MAAI,QAAS,SAAQ,cAAc,IAAI,OAAO;OACzC;AACJ,QAAK,iBAAiB;AACtB,QAAK,gBAAgBC,mDAA6B,MAAM;AACvD,QAAI,GAAG;AACN,UAAK,iBAAiB;AACtB,UAAK,gBAAgB;AACrB,OAAE,cAAc,IAAI,OAAO;;KAE3B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const require_ContentSelector = require('./ContentSelector.cjs');
|
|
2
|
-
const require_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
|
|
3
|
-
const require_EditedContent = require('./EditedContent.cjs');
|
|
4
|
-
const require_IntlayerEditorElement = require('./IntlayerEditorElement.cjs');
|
|
5
|
-
|
|
6
|
-
//#region ../../packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs
|
|
7
|
-
const defineIntlayerEditorElement = () => {
|
|
8
|
-
if (typeof customElements === "undefined") return;
|
|
9
|
-
if (!customElements.get("intlayer-editor")) customElements.define("intlayer-editor", require_IntlayerEditorElement.IntlayerEditorElement);
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Register all Intlayer custom elements.
|
|
13
|
-
* Call this once at application startup (inside IntlayerEditorProvider or similar).
|
|
14
|
-
* Safe to call multiple times — only registers elements that are not yet defined.
|
|
15
|
-
*/
|
|
16
|
-
const defineIntlayerElements = () => {
|
|
17
|
-
if (typeof customElements === "undefined") return;
|
|
18
|
-
if (!customElements.get("intlayer-content-selector")) customElements.define("intlayer-content-selector", require_ContentSelector.IntlayerContentSelectorElement);
|
|
19
|
-
require_ContentSelectorWrapper.defineIntlayerContentSelectorWrapper();
|
|
20
|
-
require_EditedContent.defineIntlayerEditedContent();
|
|
21
|
-
defineIntlayerEditorElement();
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.defineIntlayerEditorElement = defineIntlayerEditorElement;
|
|
26
|
-
exports.defineIntlayerElements = defineIntlayerElements;
|
|
27
|
-
//# sourceMappingURL=defineIntlayerElements.cjs.map
|
package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineIntlayerElements.cjs","names":["IntlayerEditorElement","IntlayerContentSelectorElement"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs"],"sourcesContent":["import { IntlayerContentSelectorElement } from \"./ContentSelector.mjs\";\nimport { defineIntlayerContentSelectorWrapper } from \"./ContentSelectorWrapper.mjs\";\nimport { defineIntlayerEditedContent } from \"./EditedContent.mjs\";\nimport { IntlayerEditorElement } from \"./IntlayerEditorElement.mjs\";\n\n//#region src/components/defineIntlayerElements.ts\nconst defineIntlayerEditorElement = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-editor\")) customElements.define(\"intlayer-editor\", IntlayerEditorElement);\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*/\nconst defineIntlayerElements = () => {\n\tif (typeof customElements === \"undefined\") return;\n\tif (!customElements.get(\"intlayer-content-selector\")) customElements.define(\"intlayer-content-selector\", IntlayerContentSelectorElement);\n\tdefineIntlayerContentSelectorWrapper();\n\tdefineIntlayerEditedContent();\n\tdefineIntlayerEditorElement();\n};\n\n//#endregion\nexport { defineIntlayerEditorElement, defineIntlayerElements };\n//# sourceMappingURL=defineIntlayerElements.mjs.map"],"mappings":";;;;;;AAMA,MAAM,oCAAoC;AACzC,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,kBAAkB,CAAE,gBAAe,OAAO,mBAAmBA,oDAAsB;;;;;;;AAO5G,MAAM,+BAA+B;AACpC,KAAI,OAAO,mBAAmB,YAAa;AAC3C,KAAI,CAAC,eAAe,IAAI,4BAA4B,CAAE,gBAAe,OAAO,6BAA6BC,uDAA+B;AACxI,sEAAsC;AACtC,oDAA6B;AAC7B,8BAA6B"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const require_compareUrls = require('../compareUrls.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs
|
|
4
|
-
const randomUUID = () => Math.random().toString(36).slice(2);
|
|
5
|
-
/**
|
|
6
|
-
* CrossFrameMessenger manages all cross-frame postMessage communication.
|
|
7
|
-
* It owns a single window message listener and routes incoming messages to
|
|
8
|
-
* type-specific subscribers.
|
|
9
|
-
*
|
|
10
|
-
* Replaces CommunicatorContext + useCrossFrameMessageListener across all frameworks.
|
|
11
|
-
*/
|
|
12
|
-
var CrossFrameMessenger = class {
|
|
13
|
-
senderId;
|
|
14
|
-
_config;
|
|
15
|
-
_subscribers = /* @__PURE__ */ new Map();
|
|
16
|
-
_windowHandler = null;
|
|
17
|
-
/** Tracks recently processed messageIds to discard duplicates (same payload sent to multiple origins) */
|
|
18
|
-
_seenMessageIds = /* @__PURE__ */ new Set();
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this._config = config;
|
|
21
|
-
this.senderId = randomUUID();
|
|
22
|
-
}
|
|
23
|
-
/** Start listening for incoming messages on window. */
|
|
24
|
-
start() {
|
|
25
|
-
if (typeof window === "undefined") return;
|
|
26
|
-
if (this._windowHandler) return;
|
|
27
|
-
this._windowHandler = (event) => {
|
|
28
|
-
this._handleMessage(event);
|
|
29
|
-
};
|
|
30
|
-
window.addEventListener("message", this._windowHandler);
|
|
31
|
-
}
|
|
32
|
-
/** Stop listening and clean up. */
|
|
33
|
-
stop() {
|
|
34
|
-
if (this._windowHandler) {
|
|
35
|
-
window.removeEventListener("message", this._windowHandler);
|
|
36
|
-
this._windowHandler = null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/** Send a message payload to all configured target origins. */
|
|
40
|
-
send(type, data) {
|
|
41
|
-
const payload = {
|
|
42
|
-
type,
|
|
43
|
-
data,
|
|
44
|
-
senderId: this.senderId,
|
|
45
|
-
messageId: randomUUID()
|
|
46
|
-
};
|
|
47
|
-
for (const origin of this._config.allowedOrigins) if (origin) this._config.postMessageFn(payload, origin);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Subscribe to messages of a given type.
|
|
51
|
-
* Returns an unsubscribe function.
|
|
52
|
-
*/
|
|
53
|
-
subscribe(type, handler) {
|
|
54
|
-
if (!this._subscribers.has(type)) this._subscribers.set(type, /* @__PURE__ */ new Set());
|
|
55
|
-
this._subscribers.get(type).add(handler);
|
|
56
|
-
return () => {
|
|
57
|
-
this._subscribers.get(type)?.delete(handler);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
_handleMessage(event) {
|
|
61
|
-
const payload = event.data;
|
|
62
|
-
if (!payload || typeof payload !== "object") return;
|
|
63
|
-
const { type, data, senderId: msgSenderId, messageId } = payload;
|
|
64
|
-
if (!type || typeof type !== "string") return;
|
|
65
|
-
if (msgSenderId === this.senderId) return;
|
|
66
|
-
if (messageId) {
|
|
67
|
-
if (this._seenMessageIds.has(messageId)) return;
|
|
68
|
-
this._seenMessageIds.add(messageId);
|
|
69
|
-
if (this._seenMessageIds.size > 200) this._seenMessageIds.clear();
|
|
70
|
-
}
|
|
71
|
-
const { allowedOrigins } = this._config;
|
|
72
|
-
if (!(!allowedOrigins || allowedOrigins.length === 0 || allowedOrigins.includes("*") || allowedOrigins.filter((url) => Boolean(url) && url !== "").some((url) => require_compareUrls.compareUrls(url, event.origin)))) return;
|
|
73
|
-
const handlers = this._subscribers.get(type);
|
|
74
|
-
if (handlers) for (const handler of handlers) handler(data, msgSenderId);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
exports.CrossFrameMessenger = CrossFrameMessenger;
|
|
80
|
-
//# sourceMappingURL=CrossFrameMessenger.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrossFrameMessenger.cjs","names":["compareUrls"],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs"],"sourcesContent":["import { compareUrls } from \"../compareUrls.mjs\";\n\n//#region src/core/CrossFrameMessenger.ts\nconst randomUUID = () => Math.random().toString(36).slice(2);\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*/\nvar CrossFrameMessenger = class {\n\tsenderId;\n\t_config;\n\t_subscribers = /* @__PURE__ */ new Map();\n\t_windowHandler = null;\n\t/** Tracks recently processed messageIds to discard duplicates (same payload sent to multiple origins) */\n\t_seenMessageIds = /* @__PURE__ */ new Set();\n\tconstructor(config) {\n\t\tthis._config = config;\n\t\tthis.senderId = randomUUID();\n\t}\n\t/** Start listening for incoming messages on window. */\n\tstart() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tif (this._windowHandler) return;\n\t\tthis._windowHandler = (event) => {\n\t\t\tthis._handleMessage(event);\n\t\t};\n\t\twindow.addEventListener(\"message\", this._windowHandler);\n\t}\n\t/** Stop listening and clean up. */\n\tstop() {\n\t\tif (this._windowHandler) {\n\t\t\twindow.removeEventListener(\"message\", this._windowHandler);\n\t\t\tthis._windowHandler = null;\n\t\t}\n\t}\n\t/** Send a message payload to all configured target origins. */\n\tsend(type, data) {\n\t\tconst payload = {\n\t\t\ttype,\n\t\t\tdata,\n\t\t\tsenderId: this.senderId,\n\t\t\tmessageId: randomUUID()\n\t\t};\n\t\tfor (const origin of this._config.allowedOrigins) if (origin) this._config.postMessageFn(payload, origin);\n\t}\n\t/**\n\t* Subscribe to messages of a given type.\n\t* Returns an unsubscribe function.\n\t*/\n\tsubscribe(type, handler) {\n\t\tif (!this._subscribers.has(type)) this._subscribers.set(type, /* @__PURE__ */ new Set());\n\t\tthis._subscribers.get(type).add(handler);\n\t\treturn () => {\n\t\t\tthis._subscribers.get(type)?.delete(handler);\n\t\t};\n\t}\n\t_handleMessage(event) {\n\t\tconst payload = event.data;\n\t\tif (!payload || typeof payload !== \"object\") return;\n\t\tconst { type, data, senderId: msgSenderId, messageId } = payload;\n\t\tif (!type || typeof type !== \"string\") return;\n\t\tif (msgSenderId === this.senderId) return;\n\t\tif (messageId) {\n\t\t\tif (this._seenMessageIds.has(messageId)) return;\n\t\t\tthis._seenMessageIds.add(messageId);\n\t\t\tif (this._seenMessageIds.size > 200) this._seenMessageIds.clear();\n\t\t}\n\t\tconst { allowedOrigins } = this._config;\n\t\tif (!(!allowedOrigins || allowedOrigins.length === 0 || allowedOrigins.includes(\"*\") || allowedOrigins.filter((url) => Boolean(url) && url !== \"\").some((url) => compareUrls(url, event.origin)))) return;\n\t\tconst handlers = this._subscribers.get(type);\n\t\tif (handlers) for (const handler of handlers) handler(data, msgSenderId);\n\t}\n};\n\n//#endregion\nexport { CrossFrameMessenger };\n//# sourceMappingURL=CrossFrameMessenger.mjs.map"],"mappings":";;;AAGA,MAAM,mBAAmB,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAA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AElE,MAAM,EAAE,mBAAmB,KAAK;AAChC,MAAI,EAAE,CAAC,kBAAkB,eAAe,WAAW,KAAK,eAAe,SAAS,IAAI,IAAI,eAAe,QAAQ,QAAQ,QAAQ,IAAI,IAAI,QAAQ,GAAG,CAAC,MAAM,QAAQA,gCAAY,KAAK,MAAM,OAAO,CAAC,EAAG;EACnM,MAAM,WAAW,KAAK,aAAa,IAAI,KAAK;AAC5C,MAAI,SAAU,MAAK,MAAM,WAAW,SAAU,SAAQ,MAAM,YAAY"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs
|
|
3
|
-
/**
|
|
4
|
-
* CrossFrameStateManager synchronizes a single named value across frames using
|
|
5
|
-
* the postMessage API via CrossFrameMessenger.
|
|
6
|
-
*
|
|
7
|
-
* Protocol:
|
|
8
|
-
* `{key}/post` — broadcast a new value
|
|
9
|
-
* `{key}/get` — request the current value from other frames
|
|
10
|
-
*
|
|
11
|
-
* Replaces useCrossFrameState across all frameworks.
|
|
12
|
-
*
|
|
13
|
-
* @fires change — CustomEvent<T> dispatched whenever the value changes (local set or received)
|
|
14
|
-
*/
|
|
15
|
-
var CrossFrameStateManager = class extends EventTarget {
|
|
16
|
-
_value;
|
|
17
|
-
_key;
|
|
18
|
-
_messenger;
|
|
19
|
-
_options;
|
|
20
|
-
_unsubscribers = [];
|
|
21
|
-
constructor(key, messenger, options = {}) {
|
|
22
|
-
super();
|
|
23
|
-
this._key = key;
|
|
24
|
-
this._messenger = messenger;
|
|
25
|
-
this._options = {
|
|
26
|
-
emit: options.emit ?? true,
|
|
27
|
-
receive: options.receive ?? true
|
|
28
|
-
};
|
|
29
|
-
if (options.initialValue !== void 0) this._value = options.initialValue;
|
|
30
|
-
}
|
|
31
|
-
get value() {
|
|
32
|
-
return this._value;
|
|
33
|
-
}
|
|
34
|
-
/** Update the value locally and broadcast it to other frames if emit is enabled. */
|
|
35
|
-
set(newValue) {
|
|
36
|
-
this._value = newValue;
|
|
37
|
-
this.dispatchEvent(new CustomEvent("change", { detail: newValue }));
|
|
38
|
-
if (this._options.emit) this._messenger.send(`${this._key}/post`, newValue);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Start listening for incoming state updates and responding to /get requests.
|
|
42
|
-
* If receive=true and no initial value is set, sends a /get to request the current value.
|
|
43
|
-
*/
|
|
44
|
-
start() {
|
|
45
|
-
if (this._options.receive) {
|
|
46
|
-
const unsub = this._messenger.subscribe(`${this._key}/post`, (data) => {
|
|
47
|
-
this._value = data;
|
|
48
|
-
this.dispatchEvent(new CustomEvent("change", { detail: data }));
|
|
49
|
-
});
|
|
50
|
-
this._unsubscribers.push(unsub);
|
|
51
|
-
}
|
|
52
|
-
if (this._options.emit) {
|
|
53
|
-
const unsub = this._messenger.subscribe(`${this._key}/get`, (_, originSenderId) => {
|
|
54
|
-
if (originSenderId === this._messenger.senderId) return;
|
|
55
|
-
if (this._value === void 0) return;
|
|
56
|
-
this._messenger.send(`${this._key}/post`, this._value);
|
|
57
|
-
});
|
|
58
|
-
this._unsubscribers.push(unsub);
|
|
59
|
-
}
|
|
60
|
-
if (this._options.receive && this._value === void 0) this._messenger.send(`${this._key}/get`);
|
|
61
|
-
}
|
|
62
|
-
/** Stop all listeners. */
|
|
63
|
-
stop() {
|
|
64
|
-
for (const unsub of this._unsubscribers) unsub();
|
|
65
|
-
this._unsubscribers.length = 0;
|
|
66
|
-
}
|
|
67
|
-
/** Broadcast the current value to all frames (useful after reconnect). */
|
|
68
|
-
postCurrentValue() {
|
|
69
|
-
if (this._value !== void 0) this._messenger.send(`${this._key}/post`, this._value);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
//#endregion
|
|
74
|
-
exports.CrossFrameStateManager = CrossFrameStateManager;
|
|
75
|
-
//# sourceMappingURL=CrossFrameStateManager.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrossFrameStateManager.cjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs"],"sourcesContent":["//#region src/core/CrossFrameStateManager.ts\n/**\n* CrossFrameStateManager synchronizes a single named value across frames using\n* the postMessage API via CrossFrameMessenger.\n*\n* Protocol:\n* `{key}/post` — broadcast a new value\n* `{key}/get` — request the current value from other frames\n*\n* Replaces useCrossFrameState across all frameworks.\n*\n* @fires change — CustomEvent<T> dispatched whenever the value changes (local set or received)\n*/\nvar CrossFrameStateManager = class extends EventTarget {\n\t_value;\n\t_key;\n\t_messenger;\n\t_options;\n\t_unsubscribers = [];\n\tconstructor(key, messenger, options = {}) {\n\t\tsuper();\n\t\tthis._key = key;\n\t\tthis._messenger = messenger;\n\t\tthis._options = {\n\t\t\temit: options.emit ?? true,\n\t\t\treceive: options.receive ?? true\n\t\t};\n\t\tif (options.initialValue !== void 0) this._value = options.initialValue;\n\t}\n\tget value() {\n\t\treturn this._value;\n\t}\n\t/** Update the value locally and broadcast it to other frames if emit is enabled. */\n\tset(newValue) {\n\t\tthis._value = newValue;\n\t\tthis.dispatchEvent(new CustomEvent(\"change\", { detail: newValue }));\n\t\tif (this._options.emit) this._messenger.send(`${this._key}/post`, newValue);\n\t}\n\t/**\n\t* Start listening for incoming state updates and responding to /get requests.\n\t* If receive=true and no initial value is set, sends a /get to request the current value.\n\t*/\n\tstart() {\n\t\tif (this._options.receive) {\n\t\t\tconst unsub = this._messenger.subscribe(`${this._key}/post`, (data) => {\n\t\t\t\tthis._value = data;\n\t\t\t\tthis.dispatchEvent(new CustomEvent(\"change\", { detail: data }));\n\t\t\t});\n\t\t\tthis._unsubscribers.push(unsub);\n\t\t}\n\t\tif (this._options.emit) {\n\t\t\tconst unsub = this._messenger.subscribe(`${this._key}/get`, (_, originSenderId) => {\n\t\t\t\tif (originSenderId === this._messenger.senderId) return;\n\t\t\t\tif (this._value === void 0) return;\n\t\t\t\tthis._messenger.send(`${this._key}/post`, this._value);\n\t\t\t});\n\t\t\tthis._unsubscribers.push(unsub);\n\t\t}\n\t\tif (this._options.receive && this._value === void 0) this._messenger.send(`${this._key}/get`);\n\t}\n\t/** Stop all listeners. */\n\tstop() {\n\t\tfor (const unsub of this._unsubscribers) unsub();\n\t\tthis._unsubscribers.length = 0;\n\t}\n\t/** Broadcast the current value to all frames (useful after reconnect). */\n\tpostCurrentValue() {\n\t\tif (this._value !== void 0) this._messenger.send(`${this._key}/post`, this._value);\n\t}\n};\n\n//#endregion\nexport { CrossFrameStateManager };\n//# sourceMappingURL=CrossFrameStateManager.mjs.map"],"mappings":";;;;;;;;;;;;;;AAaA,IAAI,yBAAyB,cAAc,YAAY;CACtD;CACA;CACA;CACA;CACA,iBAAiB,EAAE;CACnB,YAAY,KAAK,WAAW,UAAU,EAAE,EAAE;AACzC,SAAO;AACP,OAAK,OAAO;AACZ,OAAK,aAAa;AAClB,OAAK,WAAW;GACf,MAAM,QAAQ,QAAQ;GACtB,SAAS,QAAQ,WAAW;GAC5B;AACD,MAAI,QAAQ,iBAAiB,KAAK,EAAG,MAAK,SAAS,QAAQ;;CAE5D,IAAI,QAAQ;AACX,SAAO,KAAK;;;CAGb,IAAI,UAAU;AACb,OAAK,SAAS;AACd,OAAK,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ,UAAU,CAAC,CAAC;AACnE,MAAI,KAAK,SAAS,KAAM,MAAK,WAAW,KAAK,GAAG,KAAK,KAAK,QAAQ,SAAS;;;;;;CAM5E,QAAQ;AACP,MAAI,KAAK,SAAS,SAAS;GAC1B,MAAM,QAAQ,KAAK,WAAW,UAAU,GAAG,KAAK,KAAK,SAAS,SAAS;AACtE,SAAK,SAAS;AACd,SAAK,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ,MAAM,CAAC,CAAC;KAC9D;AACF,QAAK,eAAe,KAAK,MAAM;;AAEhC,MAAI,KAAK,SAAS,MAAM;GACvB,MAAM,QAAQ,KAAK,WAAW,UAAU,GAAG,KA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