Skip to content

Commit 121ac4d

Browse files
[fix] Change parentSubgraphNode type to NodeLike
Changed widget's parentSubgraphNode type from LGraphNode to NodeLike to fix TypeScript compilation issues in downstream projects. The private fields in LGraphNode make it impossible to assign plain objects during deserialization.
1 parent c0feaa5 commit 121ac4d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/types/widgets.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { CanvasColour, Point, RequiredProps, Size } from "../interfaces"
22
import type { CanvasPointer, LGraphCanvas, LGraphNode } from "../litegraph"
33
import type { CanvasPointerEvent } from "./events"
4+
import type { NodeLike } from "./NodeLike"
45

56
export interface IWidgetOptions<TValues = unknown[]> {
67
on?: string
@@ -204,8 +205,10 @@ export interface IBaseWidget<
204205
/**
205206
* Reference to the subgraph container node when this widget is promoted from a subgraph.
206207
* This allows the widget to know which SubgraphNode it belongs to in the parent graph.
208+
* @remarks This property is a runtime reference and should not be serialized.
209+
* It will be undefined after deserialization and needs to be reconstructed.
207210
*/
208-
parentSubgraphNode?: LGraphNode
211+
parentSubgraphNode?: NodeLike
209212

210213
// TODO: Confirm this format
211214
callback?(

src/widgets/BaseWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Point } from "@/interfaces"
22
import type { CanvasPointer, LGraphCanvas, LGraphNode, Size } from "@/litegraph"
33
import type { CanvasPointerEvent } from "@/types/events"
4+
import type { NodeLike } from "@/types/NodeLike"
45
import type { IBaseWidget } from "@/types/widgets"
56

67
import { drawTextInArea } from "@/draw"
@@ -60,7 +61,7 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget> impl
6061
* Reference to the subgraph container node when this widget is promoted from a subgraph.
6162
* This allows the widget to know which SubgraphNode it belongs to in the parent graph.
6263
*/
63-
parentSubgraphNode?: LGraphNode
64+
parentSubgraphNode?: NodeLike
6465

6566
linkedWidgets?: IBaseWidget[]
6667
name: string

0 commit comments

Comments
 (0)