mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
[fix] Remove TypeScript declare modifiers from class properties
This commit is contained in:
@@ -11,7 +11,7 @@ const nodeDefsPath = './src/locales/en/nodeDefs.json'
|
|||||||
|
|
||||||
test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||||
// Mock view route
|
// Mock view route
|
||||||
comfyPage.page.route('**/view**', async (route) => {
|
await comfyPage.page.route('**/view**', async (route) => {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
body: JSON.stringify({})
|
body: JSON.stringify({})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -404,8 +404,8 @@ export class LGraphNode
|
|||||||
selected?: boolean
|
selected?: boolean
|
||||||
showAdvanced?: boolean
|
showAdvanced?: boolean
|
||||||
|
|
||||||
declare comfyClass?: string
|
comfyClass?: string
|
||||||
declare isVirtualNode?: boolean
|
isVirtualNode?: boolean
|
||||||
applyToGraph?(extraLinks?: LLink[]): void
|
applyToGraph?(extraLinks?: LLink[]): void
|
||||||
|
|
||||||
isSubgraphNode(): this is SubgraphNode {
|
isSubgraphNode(): this is SubgraphNode {
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ import type {
|
|||||||
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
|
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
|
||||||
import type { Point } from '@/lib/litegraph/src/interfaces'
|
import type { Point } from '@/lib/litegraph/src/interfaces'
|
||||||
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
|
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
|
||||||
|
import type { SubgraphInputNode } from '@/lib/litegraph/src/subgraph/SubgraphInputNode'
|
||||||
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
|
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
|
||||||
|
import type { SubgraphOutputNode } from '@/lib/litegraph/src/subgraph/SubgraphOutputNode'
|
||||||
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
|
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
|
||||||
|
|
||||||
import type { RenderLink } from './RenderLink'
|
import type { RenderLink } from './RenderLink'
|
||||||
@@ -175,7 +177,9 @@ export class FloatingRenderLink implements RenderLink {
|
|||||||
): void {
|
): void {
|
||||||
const floatingLink = this.link
|
const floatingLink = this.link
|
||||||
floatingLink.origin_id = SUBGRAPH_INPUT_ID
|
floatingLink.origin_id = SUBGRAPH_INPUT_ID
|
||||||
floatingLink.origin_slot = input.parent.slots.indexOf(input)
|
floatingLink.origin_slot = (
|
||||||
|
input.parent as SubgraphInputNode
|
||||||
|
).slots.indexOf(input)
|
||||||
|
|
||||||
this.fromSlot._floatingLinks?.delete(floatingLink)
|
this.fromSlot._floatingLinks?.delete(floatingLink)
|
||||||
input._floatingLinks ??= new Set()
|
input._floatingLinks ??= new Set()
|
||||||
@@ -188,7 +192,9 @@ export class FloatingRenderLink implements RenderLink {
|
|||||||
): void {
|
): void {
|
||||||
const floatingLink = this.link
|
const floatingLink = this.link
|
||||||
floatingLink.origin_id = SUBGRAPH_OUTPUT_ID
|
floatingLink.origin_id = SUBGRAPH_OUTPUT_ID
|
||||||
floatingLink.origin_slot = output.parent.slots.indexOf(output)
|
floatingLink.origin_slot = (
|
||||||
|
output.parent as SubgraphOutputNode
|
||||||
|
).slots.indexOf(output)
|
||||||
|
|
||||||
this.fromSlot._floatingLinks?.delete(floatingLink)
|
this.fromSlot._floatingLinks?.delete(floatingLink)
|
||||||
output._floatingLinks ??= new Set()
|
output._floatingLinks ??= new Set()
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import type { SubgraphInputNode } from './SubgraphInputNode'
|
|||||||
* A virtual slot that simply creates a new input slot when connected to.
|
* A virtual slot that simply creates a new input slot when connected to.
|
||||||
*/
|
*/
|
||||||
export class EmptySubgraphInput extends SubgraphInput {
|
export class EmptySubgraphInput extends SubgraphInput {
|
||||||
declare parent: SubgraphInputNode
|
|
||||||
|
|
||||||
constructor(parent: SubgraphInputNode) {
|
constructor(parent: SubgraphInputNode) {
|
||||||
super(
|
super(
|
||||||
{
|
{
|
||||||
@@ -30,7 +28,7 @@ export class EmptySubgraphInput extends SubgraphInput {
|
|||||||
node: LGraphNode,
|
node: LGraphNode,
|
||||||
afterRerouteId?: RerouteId
|
afterRerouteId?: RerouteId
|
||||||
): LLink | undefined {
|
): LLink | undefined {
|
||||||
const { subgraph } = this.parent
|
const { subgraph } = this.parent as SubgraphInputNode
|
||||||
const existingNames = subgraph.inputs.map((x) => x.name)
|
const existingNames = subgraph.inputs.map((x) => x.name)
|
||||||
|
|
||||||
const name = nextUniqueName(slot.name, existingNames)
|
const name = nextUniqueName(slot.name, existingNames)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import type { SubgraphOutputNode } from './SubgraphOutputNode'
|
|||||||
* A virtual slot that simply creates a new output slot when connected to.
|
* A virtual slot that simply creates a new output slot when connected to.
|
||||||
*/
|
*/
|
||||||
export class EmptySubgraphOutput extends SubgraphOutput {
|
export class EmptySubgraphOutput extends SubgraphOutput {
|
||||||
declare parent: SubgraphOutputNode
|
|
||||||
|
|
||||||
constructor(parent: SubgraphOutputNode) {
|
constructor(parent: SubgraphOutputNode) {
|
||||||
super(
|
super(
|
||||||
{
|
{
|
||||||
@@ -30,7 +28,7 @@ export class EmptySubgraphOutput extends SubgraphOutput {
|
|||||||
node: LGraphNode,
|
node: LGraphNode,
|
||||||
afterRerouteId?: RerouteId
|
afterRerouteId?: RerouteId
|
||||||
): LLink | undefined {
|
): LLink | undefined {
|
||||||
const { subgraph } = this.parent
|
const { subgraph } = this.parent as SubgraphOutputNode
|
||||||
const existingNames = subgraph.outputs.map((x) => x.name)
|
const existingNames = subgraph.outputs.map((x) => x.name)
|
||||||
|
|
||||||
const name = nextUniqueName(slot.name, existingNames)
|
const name = nextUniqueName(slot.name, existingNames)
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ import { isNodeSlot, isSubgraphOutput } from './subgraphUtils'
|
|||||||
* Functionally, however, when editing a subgraph, that "subgraph input" is the "origin" or "output side" of a link.
|
* Functionally, however, when editing a subgraph, that "subgraph input" is the "origin" or "output side" of a link.
|
||||||
*/
|
*/
|
||||||
export class SubgraphInput extends SubgraphSlot {
|
export class SubgraphInput extends SubgraphSlot {
|
||||||
declare parent: SubgraphInputNode
|
|
||||||
|
|
||||||
events = new CustomEventTarget<SubgraphInputEventMap>()
|
events = new CustomEventTarget<SubgraphInputEventMap>()
|
||||||
|
|
||||||
/** The linked widget that this slot is connected to. */
|
/** The linked widget that this slot is connected to. */
|
||||||
@@ -50,13 +48,13 @@ export class SubgraphInput extends SubgraphSlot {
|
|||||||
node: LGraphNode,
|
node: LGraphNode,
|
||||||
afterRerouteId?: RerouteId
|
afterRerouteId?: RerouteId
|
||||||
): LLink | undefined {
|
): LLink | undefined {
|
||||||
const { subgraph } = this.parent
|
const parent = this.parent as SubgraphInputNode
|
||||||
|
const { subgraph } = parent
|
||||||
|
|
||||||
// Allow nodes to block connection
|
// Allow nodes to block connection
|
||||||
const inputIndex = node.inputs.indexOf(slot)
|
const inputIndex = node.inputs.indexOf(slot)
|
||||||
if (
|
if (
|
||||||
node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) ===
|
node.onConnectInput?.(inputIndex, this.type, this, parent, -1) === false
|
||||||
false
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ export class SubgraphInput extends SubgraphSlot {
|
|||||||
if (slot.link != null) {
|
if (slot.link != null) {
|
||||||
subgraph.beforeChange()
|
subgraph.beforeChange()
|
||||||
const link = subgraph.getLink(slot.link)
|
const link = subgraph.getLink(slot.link)
|
||||||
this.parent._disconnectNodeInput(node, slot, link)
|
parent._disconnectNodeInput(node, slot, link)
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputWidget = node.getWidgetFromSlot(slot)
|
const inputWidget = node.getWidgetFromSlot(slot)
|
||||||
@@ -97,8 +95,8 @@ export class SubgraphInput extends SubgraphSlot {
|
|||||||
const link = new LLink(
|
const link = new LLink(
|
||||||
++subgraph.state.lastLinkId,
|
++subgraph.state.lastLinkId,
|
||||||
slot.type,
|
slot.type,
|
||||||
this.parent.id,
|
parent.id,
|
||||||
this.parent.slots.indexOf(this),
|
parent.slots.indexOf(this),
|
||||||
node.id,
|
node.id,
|
||||||
inputIndex,
|
inputIndex,
|
||||||
afterRerouteId
|
afterRerouteId
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ import type { SubgraphInput } from './SubgraphInput'
|
|||||||
* An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph.
|
* An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph.
|
||||||
*/
|
*/
|
||||||
export class SubgraphNode extends LGraphNode implements BaseLGraph {
|
export class SubgraphNode extends LGraphNode implements BaseLGraph {
|
||||||
declare inputs: (INodeInputSlot & Partial<ISubgraphInput>)[]
|
// Override inputs with proper typing for subgraph inputs
|
||||||
|
override inputs: (INodeInputSlot & Partial<ISubgraphInput>)[] = []
|
||||||
|
|
||||||
override readonly type: UUID
|
override readonly type: UUID
|
||||||
override readonly isVirtualNode = true as const
|
override readonly isVirtualNode = true as const
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ import { isNodeSlot, isSubgraphInput } from './subgraphUtils'
|
|||||||
* Functionally, however, when editing a subgraph, that "subgraph output" is the "target" or "input side" of a link.
|
* Functionally, however, when editing a subgraph, that "subgraph output" is the "target" or "input side" of a link.
|
||||||
*/
|
*/
|
||||||
export class SubgraphOutput extends SubgraphSlot {
|
export class SubgraphOutput extends SubgraphSlot {
|
||||||
declare parent: SubgraphOutputNode
|
|
||||||
|
|
||||||
override connect(
|
override connect(
|
||||||
slot: INodeOutputSlot,
|
slot: INodeOutputSlot,
|
||||||
node: LGraphNode,
|
node: LGraphNode,
|
||||||
afterRerouteId?: RerouteId
|
afterRerouteId?: RerouteId
|
||||||
): LLink | undefined {
|
): LLink | undefined {
|
||||||
const { subgraph } = this.parent
|
const parent = this.parent as SubgraphOutputNode
|
||||||
|
const { subgraph } = parent
|
||||||
|
|
||||||
// Validate type compatibility
|
// Validate type compatibility
|
||||||
if (!LiteGraph.isValidConnection(slot.type, this.type)) return
|
if (!LiteGraph.isValidConnection(slot.type, this.type)) return
|
||||||
@@ -47,8 +46,7 @@ export class SubgraphOutput extends SubgraphSlot {
|
|||||||
throw new Error('Slot is not an output of the given node')
|
throw new Error('Slot is not an output of the given node')
|
||||||
|
|
||||||
if (
|
if (
|
||||||
node.onConnectOutput?.(outputIndex, this.type, this, this.parent, -1) ===
|
node.onConnectOutput?.(outputIndex, this.type, this, parent, -1) === false
|
||||||
false
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -68,8 +66,8 @@ export class SubgraphOutput extends SubgraphSlot {
|
|||||||
slot.type,
|
slot.type,
|
||||||
node.id,
|
node.id,
|
||||||
outputIndex,
|
outputIndex,
|
||||||
this.parent.id,
|
parent.id,
|
||||||
this.parent.slots.indexOf(this),
|
parent.slots.indexOf(this),
|
||||||
afterRerouteId
|
afterRerouteId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
|
|||||||
/** Minimum gap between label and value */
|
/** Minimum gap between label and value */
|
||||||
static labelValueGap = 5
|
static labelValueGap = 5
|
||||||
|
|
||||||
declare computedHeight?: number
|
computedHeight?: number
|
||||||
declare serialize?: boolean
|
serialize?: boolean
|
||||||
computeLayoutSize?(node: LGraphNode): {
|
computeLayoutSize?(node: LGraphNode): {
|
||||||
minHeight: number
|
minHeight: number
|
||||||
maxHeight?: number
|
maxHeight?: number
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ LGraph {
|
|||||||
"clip_area": undefined,
|
"clip_area": undefined,
|
||||||
"clonable": undefined,
|
"clonable": undefined,
|
||||||
"color": undefined,
|
"color": undefined,
|
||||||
|
"comfyClass": undefined,
|
||||||
"console": undefined,
|
"console": undefined,
|
||||||
"exec_version": undefined,
|
"exec_version": undefined,
|
||||||
"execute_triggered": undefined,
|
"execute_triggered": undefined,
|
||||||
@@ -77,6 +78,7 @@ LGraph {
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"ignore_remove": undefined,
|
"ignore_remove": undefined,
|
||||||
"inputs": [],
|
"inputs": [],
|
||||||
|
"isVirtualNode": undefined,
|
||||||
"last_serialization": {
|
"last_serialization": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
},
|
},
|
||||||
@@ -138,6 +140,7 @@ LGraph {
|
|||||||
"clip_area": undefined,
|
"clip_area": undefined,
|
||||||
"clonable": undefined,
|
"clonable": undefined,
|
||||||
"color": undefined,
|
"color": undefined,
|
||||||
|
"comfyClass": undefined,
|
||||||
"console": undefined,
|
"console": undefined,
|
||||||
"exec_version": undefined,
|
"exec_version": undefined,
|
||||||
"execute_triggered": undefined,
|
"execute_triggered": undefined,
|
||||||
@@ -149,6 +152,7 @@ LGraph {
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"ignore_remove": undefined,
|
"ignore_remove": undefined,
|
||||||
"inputs": [],
|
"inputs": [],
|
||||||
|
"isVirtualNode": undefined,
|
||||||
"last_serialization": {
|
"last_serialization": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
},
|
},
|
||||||
@@ -211,6 +215,7 @@ LGraph {
|
|||||||
"clip_area": undefined,
|
"clip_area": undefined,
|
||||||
"clonable": undefined,
|
"clonable": undefined,
|
||||||
"color": undefined,
|
"color": undefined,
|
||||||
|
"comfyClass": undefined,
|
||||||
"console": undefined,
|
"console": undefined,
|
||||||
"exec_version": undefined,
|
"exec_version": undefined,
|
||||||
"execute_triggered": undefined,
|
"execute_triggered": undefined,
|
||||||
@@ -222,6 +227,7 @@ LGraph {
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"ignore_remove": undefined,
|
"ignore_remove": undefined,
|
||||||
"inputs": [],
|
"inputs": [],
|
||||||
|
"isVirtualNode": undefined,
|
||||||
"last_serialization": {
|
"last_serialization": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user