From 5a135911663afa8b65aea99c63a836cbc60d34fb Mon Sep 17 00:00:00 2001 From: Mykyta Dniprovskyi Date: Wed, 11 Sep 2024 10:52:01 +0200 Subject: [PATCH] fix: fix NotSupportedError on consequent LitPlugin.constructor & Preset.setup calls --- src/index.tsx | 4 ++-- src/presets/classic/index.tsx | 14 +++++++------- src/presets/context-menu/index.ts | 10 +++++----- src/presets/minimap/index.ts | 8 ++++---- src/presets/reroute/index.ts | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 85e0e1a..4952654 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,6 +9,8 @@ export * as Presets from './presets' export type { ClassicScheme, LitArea2D, RenderEmit } from './presets/classic' export * from './types' +customElements.define('rete-root', RootElement) + /** * Signals that can be emitted by the plugin * @priority 9 @@ -38,8 +40,6 @@ export class LitPlugin> exten this.renderer = getRenderer() - customElements.define('rete-root', RootElement) - this.addPipe(context => { if (!context || typeof context !== 'object' || !('type' in context)) return context if (context.type === 'unmount') { diff --git a/src/presets/classic/index.tsx b/src/presets/classic/index.tsx index d1e3d28..ca9b982 100644 --- a/src/presets/classic/index.tsx +++ b/src/presets/classic/index.tsx @@ -16,6 +16,13 @@ import { NodeElement } from './components/node' import { SocketElement } from './components/socket' import { ClassicScheme, ExtractPayload, LitArea2D, RenderEmit } from './types' +customElements.define('rete-connection-wrapper', ConnectionWrapperElement) +customElements.define('rete-connection', ConnectionElement) +customElements.define('rete-ref', RefElement) +customElements.define('rete-socket', SocketElement) +customElements.define('rete-node', NodeElement) +customElements.define('rete-control', ControlElement) + export type { ClassicScheme, LitArea2D, RenderEmit } from './types' type CustomizationProps = { @@ -44,13 +51,6 @@ export function setup) diff --git a/src/presets/context-menu/index.ts b/src/presets/context-menu/index.ts index 2b9bd00..6eb13a5 100644 --- a/src/presets/context-menu/index.ts +++ b/src/presets/context-menu/index.ts @@ -8,6 +8,11 @@ import { MenuElement } from './components/Menu' import { SearchElement } from './components/Search' import { ContextMenuRender } from './types' +customElements.define('rete-context-menu', MenuElement) +customElements.define('rete-context-menu-block', BlockElement) +customElements.define('rete-context-menu-search', SearchElement) +customElements.define('rete-context-menu-item', ItemElement) + /** * Preset for rendering context menu. */ @@ -16,11 +21,6 @@ export function setup( ? 1000 : props.delay - customElements.define('rete-context-menu', MenuElement) - customElements.define('rete-context-menu-block', BlockElement) - customElements.define('rete-context-menu-search', SearchElement) - customElements.define('rete-context-menu-item', ItemElement) - return { update(context) { if (context.data.type === 'contextmenu') { diff --git a/src/presets/minimap/index.ts b/src/presets/minimap/index.ts index 3db515f..b89dcb1 100644 --- a/src/presets/minimap/index.ts +++ b/src/presets/minimap/index.ts @@ -7,14 +7,14 @@ import { MiniNode } from './components/MiniNode' import { MiniViewport } from './components/MiniViewport' import { MinimapRender } from './types' +customElements.define('rete-minimap', Minimap) +customElements.define('rete-mini-node', MiniNode) +customElements.define('rete-mini-viewport', MiniViewport) + /** * Preset for rendering minimap. */ export function setup(props?: { size?: number }): RenderPreset { - customElements.define('rete-minimap', Minimap) - customElements.define('rete-mini-node', MiniNode) - customElements.define('rete-mini-viewport', MiniViewport) - return { update(context) { if (context.data.type === 'minimap') { diff --git a/src/presets/reroute/index.ts b/src/presets/reroute/index.ts index 49c669a..010d884 100644 --- a/src/presets/reroute/index.ts +++ b/src/presets/reroute/index.ts @@ -7,6 +7,9 @@ import { Pin } from './components/Pin' import { Pins } from './components/Pins' import { PinsRender } from './types' +customElements.define('rete-pins', Pins) +customElements.define('rete-pin', Pin) + type Props = { translate?: (id: string, dx: number, dy: number) => void contextMenu?: (id: string) => void @@ -17,9 +20,6 @@ type Props = { * Preset for rendering pins. */ export function setup(props?: Props): RenderPreset { - customElements.define('rete-pins', Pins) - customElements.define('rete-pin', Pin) - return { update(context) { if (context.data.type === 'reroute-pins') {