diff --git a/src/components/selectionbar/SubgraphNode.vue b/src/components/selectionbar/SubgraphNode.vue index c61badf4d..a9723455e 100644 --- a/src/components/selectionbar/SubgraphNode.vue +++ b/src/components/selectionbar/SubgraphNode.vue @@ -1,15 +1,14 @@ diff --git a/src/components/selectionbar/SubgraphNodeWidget.vue b/src/components/selectionbar/SubgraphNodeWidget.vue index 624d1bb68..9aea14b07 100644 --- a/src/components/selectionbar/SubgraphNodeWidget.vue +++ b/src/components/selectionbar/SubgraphNodeWidget.vue @@ -1,40 +1,34 @@ @@ -65,7 +59,7 @@ function onClick(e) { flex-direction: column; justify-content: flex-end; align-self: stretch; - color: var(--color-text-secondary, #9C9EAB); + color: var(--color-text-secondary, #9c9eab); /* heading-text-nav */ font-family: Inter; @@ -75,7 +69,7 @@ function onClick(e) { line-height: normal; } .widget-name { - color: var(--color-text-primary, #FFF); + color: var(--color-text-primary, #fff); /* body-text-small */ font-family: Inter; diff --git a/src/composables/sidebarTabs/useSubgraphNodeTab.ts b/src/composables/sidebarTabs/useSubgraphNodeTab.ts index b575c2b0f..31d19cefc 100644 --- a/src/composables/sidebarTabs/useSubgraphNodeTab.ts +++ b/src/composables/sidebarTabs/useSubgraphNodeTab.ts @@ -1,4 +1,3 @@ - import { markRaw } from 'vue' import SubgraphNode from '@/components/selectionbar/SubgraphNode.vue' diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.ts index e5bdf4dde..11c2bb134 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphNode.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphNode.ts @@ -23,6 +23,7 @@ import type { import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' import type { UUID } from '@/lib/litegraph/src/utils/uuid' import { toConcreteWidget } from '@/lib/litegraph/src/widgets/widgetMap' +import { useDomWidgetStore } from '@/stores/domWidgetStore' import { type ExecutableLGraphNode, @@ -31,8 +32,6 @@ import { } from './ExecutableNodeDTO' import type { SubgraphInput } from './SubgraphInput' -import { useDomWidgetStore } from '@/stores/domWidgetStore' - /** * An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph. */ @@ -313,7 +312,8 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { const proxyWidgets = this.properties.proxyWidgets Object.defineProperty(this.properties, 'proxyWidgets', { get: () => { - return this.widgets.filter((w) => !!w._overlay) + return this.widgets + .filter((w) => !!w._overlay) .map((w) => [w._overlay.nodeId, w._overlay.widgetName]) }, set: (property) => { @@ -325,7 +325,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { //NOTE: This does not apply to pushed entries, only initial load this.widgets = this.widgets.filter((w) => !w._overlay) for (const [nodeId, widgetName] of property) { - const w = this.addProxyWidget(`${nodeId}`, widgetName) + const w = this.addProxyWidget(`${nodeId}`, widgetName) if (w.id && widgetStates.has(w.id)) { const widgetState = widgetStates.get(w.id) widgetState.active = true @@ -608,10 +608,10 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { return super.serialize() } addProxyWidget(nodeId: string, widgetName: string) { - const overlay = {nodeId, widgetName} - return this.addProxyFromOverlay({__proto__:overlay}) + const overlay = { nodeId, widgetName } + return this.addProxyFromOverlay({ __proto__: overlay }) } - addProxyFromOverlay(overlay: Object) { + addProxyFromOverlay(overlay: object) { overlay.label = `${overlay.nodeId}: ${overlay.widgetName}` overlay.graph = this.subgraph overlay.isProxyWidget = true @@ -619,47 +619,59 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { //use a weakref and only trigger recalc on calls when undefined? //TODO: call toConcrete when resolved and hold reference? const subgraphNode = this - function linkedWidget(graph, nodeId="", widgetName) { - let g = graph + function linkedWidget(graph, nodeId = '', widgetName) { + const g = graph let n = undefined - for (let id of nodeId.split(':')) { + for (const id of nodeId.split(':')) { n = g?._nodes_by_id?.[id] graph = n?.subgraph } if (!n) return - return n.widgets.find((w) => w.name === widgetName) + return n.widgets.find((w) => w.name === widgetName) } let lw = undefined - const handler = Object.fromEntries(['get', 'set', 'getPrototypeOf', 'ownKeys', 'has'].map((s) => { - const func = function(t,p,...rest) { - if (s == 'get' && p == '_overlay') - return overlay - if (!lw) { - lw = linkedWidget(overlay.graph, overlay.nodeId, overlay.widgetName) + const handler = Object.fromEntries( + ['get', 'set', 'getPrototypeOf', 'ownKeys', 'has'].map((s) => { + const func = function (t, p, ...rest) { + if (s == 'get' && p == '_overlay') return overlay + if (!lw) { + lw = linkedWidget(overlay.graph, overlay.nodeId, overlay.widgetName) + } + if (s == 'get' && p == 'node') { + return subgraphNode + } + if (s == 'set' && p == 'computedDisabled') { + //ignore setting, calc actual + lw.computedDisabled = + lw.disabled || lw.node.getSlotFromWidget(lw)?.link != null + return true + } + //NOTE: p may be undefined + let r = rest.at(-1) + if ( + [ + 'y', + 'last_y', + 'width', + 'computedHeight', + 'afterQueued', + 'beforeQueued', + 'onRemove', + 'isProxyWidget', + 'label' + ].includes(p) + ) + t = overlay + else { + t = lw + if (!t) t = { __proto__: overlay, draw: drawDisconnected } + if (p == 'value') r = t + } + return Reflect[s](t, p, ...rest.slice(0, -1), r) } - if (s == 'get' && p == 'node') { - return subgraphNode - } - if (s == 'set' && p == 'computedDisabled') { - //ignore setting, calc actual - lw.computedDisabled = lw.disabled || lw.node.getSlotFromWidget(lw)?.link != null - return true - } - //NOTE: p may be undefined - let r = rest.at(-1) - if (['y', 'last_y', 'width', 'computedHeight', 'afterQueued', 'beforeQueued', 'onRemove', 'isProxyWidget', 'label'].includes(p)) - t = overlay - else { - t = lw - if (!t) - t = {__proto__: overlay, draw: drawDisconnected} - if (p == "value") - r = t - } - return Reflect[s](t,p,...rest.slice(0,-1),r) - } - return [s, func] - })) + return [s, func] + }) + ) const w = new Proxy(overlay, handler) this.widgets.push(w) return w diff --git a/src/stores/workspace/sidebarTabStore.ts b/src/stores/workspace/sidebarTabStore.ts index 2bade5782..f5d5bde8c 100644 --- a/src/stores/workspace/sidebarTabStore.ts +++ b/src/stores/workspace/sidebarTabStore.ts @@ -4,8 +4,8 @@ import { computed, ref } from 'vue' import { useModelLibrarySidebarTab } from '@/composables/sidebarTabs/useModelLibrarySidebarTab' import { useNodeLibrarySidebarTab } from '@/composables/sidebarTabs/useNodeLibrarySidebarTab' import { useQueueSidebarTab } from '@/composables/sidebarTabs/useQueueSidebarTab' -import { useWorkflowsSidebarTab } from '@/composables/sidebarTabs/useWorkflowsSidebarTab' import { useSubgraphNodeTab } from '@/composables/sidebarTabs/useSubgraphNodeTab' +import { useWorkflowsSidebarTab } from '@/composables/sidebarTabs/useWorkflowsSidebarTab' import { t, te } from '@/i18n' import { useCommandStore } from '@/stores/commandStore' import { useMenuItemStore } from '@/stores/menuItemStore'