Skip to content

Commit

Permalink
fix: fix NotSupportedError on consequent LitPlugin.constructor & Pres…
Browse files Browse the repository at this point in the history
…et.setup calls
  • Loading branch information
Mykyta Dniprovskyi committed Sep 11, 2024
1 parent c740245 commit 5a13591
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,8 +40,6 @@ export class LitPlugin<Schemes extends BaseSchemes, T = Requires<Schemes>> 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') {
Expand Down
14 changes: 7 additions & 7 deletions src/presets/classic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schemes extends ClassicScheme> = {
Expand Down Expand Up @@ -44,13 +51,6 @@ export function setup<Schemes extends ClassicScheme, K extends LitArea2D<Schemes
: props.socketPositionWatcher
const { node, connection, socket, control } = props?.customize || {}

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)

return {
attach(plugin) {
positionWatcher.attach(plugin as unknown as Scope<never, [K]>)
Expand Down
10 changes: 5 additions & 5 deletions src/presets/context-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -16,11 +21,6 @@ export function setup<Schemes extends BaseSchemes, K extends ContextMenuRender>(
? 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') {
Expand Down
8 changes: 4 additions & 4 deletions src/presets/minimap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schemes extends BaseSchemes, K extends MinimapRender>(props?: { size?: number }): RenderPreset<Schemes, K> {
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') {
Expand Down
6 changes: 3 additions & 3 deletions src/presets/reroute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,9 +20,6 @@ type Props = {
* Preset for rendering pins.
*/
export function setup<Schemes extends BaseSchemes, K extends PinsRender>(props?: Props): RenderPreset<Schemes, K> {
customElements.define('rete-pins', Pins)
customElements.define('rete-pin', Pin)

return {
update(context) {
if (context.data.type === 'reroute-pins') {
Expand Down

0 comments on commit 5a13591

Please sign in to comment.