mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-11 00:10:40 +00:00
Road to No Explicit Any Part 3: Litegraph (#7935)
## Summary - Replace `any` types with proper TypeScript types in litegraph core files - Focused on `LGraphCanvas.ts`, `LGraphNode.ts`, and `LGraph.ts` ## Changes **LGraphCanvas.ts:** - `ICreatePanelOptions` interface: `closable`, `window`, `width`, `height` - `options` property: `skip_events`, `viewport`, `skip_render`, `autoresize` - `prompt` function: `value` and `callback` parameters - `onSearchBox` return type: `string[] | void` - `onSearchBoxSelection` callback: `name: string`, `event: MouseEvent` - `onDrawBackground` / `onDrawForeground` callbacks: `visible_area: Rectangle` - Properties Panel callback parameters **LGraphNode.ts:** - `onDropFile` / `onDropData`: `file: File`, `filename: string` - `action_call` option: `string` (5 occurrences) - `onSerialize` return type: `void` - `onDrawTitleBar.fgcolor`: `string` **LGraph.ts:** - `LGraphConfig`: `align_to_grid`, `links_ontop` as `boolean` - `triggerInput`: `value: unknown` - `setCallback`: `func: (() => void) | undefined` ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7935-Road-to-No-Explicit-Any-Part-3-Litegraph-2e36d73d3650819eb9f9ec9c16ebc3b9) by [Unito](https://www.unito.io)
This commit is contained in:
committed by
GitHub
parent
05f1dfe921
commit
965ab674d5
@@ -224,12 +224,12 @@ interface IPasteFromClipboardOptions {
|
||||
}
|
||||
|
||||
interface ICreatePanelOptions {
|
||||
closable?: any
|
||||
window?: any
|
||||
closable?: boolean
|
||||
window?: Window
|
||||
onOpen?: () => void
|
||||
onClose?: () => void
|
||||
width?: any
|
||||
height?: any
|
||||
width?: number | string
|
||||
height?: number | string
|
||||
}
|
||||
|
||||
const cursors = {
|
||||
@@ -495,10 +495,10 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
}
|
||||
|
||||
options: {
|
||||
skip_events?: any
|
||||
viewport?: any
|
||||
skip_render?: any
|
||||
autoresize?: any
|
||||
skip_events?: boolean
|
||||
viewport?: Rect
|
||||
skip_render?: boolean
|
||||
autoresize?: boolean
|
||||
}
|
||||
|
||||
background_image: string
|
||||
@@ -584,13 +584,27 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
/** @deprecated LEGACY: REMOVE THIS, USE {@link graph_mouse} INSTEAD */
|
||||
canvas_mouse: Point
|
||||
/** to personalize the search box */
|
||||
onSearchBox?: (helper: Element, str: string, canvas: LGraphCanvas) => any
|
||||
onSearchBoxSelection?: (name: any, event: any, canvas: LGraphCanvas) => void
|
||||
onSearchBox?: (
|
||||
helper: HTMLDivElement,
|
||||
str: string,
|
||||
canvas: LGraphCanvas
|
||||
) => string[] | undefined
|
||||
onSearchBoxSelection?: (
|
||||
name: string,
|
||||
event: MouseEvent,
|
||||
canvas: LGraphCanvas
|
||||
) => void
|
||||
onMouse?: (e: CanvasPointerEvent) => boolean
|
||||
/** to render background objects (behind nodes and connections) in the canvas affected by transform */
|
||||
onDrawBackground?: (ctx: CanvasRenderingContext2D, visible_area: any) => void
|
||||
onDrawBackground?: (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
visible_area: Rectangle
|
||||
) => void
|
||||
/** to render foreground objects (above nodes and connections) in the canvas affected by transform */
|
||||
onDrawForeground?: (arg0: CanvasRenderingContext2D, arg1: any) => void
|
||||
onDrawForeground?: (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
visible_area: Rectangle
|
||||
) => void
|
||||
connections_width: number
|
||||
/** The current node being drawn by {@link drawNode}. This should NOT be used to determine the currently selected node. See {@link selectedItems} */
|
||||
current_node: LGraphNode | null
|
||||
@@ -931,7 +945,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
this.connecting_links = null
|
||||
|
||||
// to constraint render area to a portion of the canvas
|
||||
this.viewport = options.viewport || null
|
||||
this.viewport = options.viewport
|
||||
|
||||
// link canvas and graph
|
||||
this.graph = graph
|
||||
@@ -963,7 +977,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
this.startRendering()
|
||||
}
|
||||
|
||||
this.autoresize = options.autoresize
|
||||
this.autoresize = options.autoresize ?? false
|
||||
|
||||
this.updateLowQualityThreshold()
|
||||
}
|
||||
@@ -6668,8 +6682,8 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
// refactor: there are different dialogs, some uses createDialog some dont
|
||||
prompt(
|
||||
title: string,
|
||||
value: any,
|
||||
callback: (arg0: any) => void,
|
||||
value: string | number,
|
||||
callback: (value: string) => void,
|
||||
event: CanvasPointerEvent,
|
||||
multiline?: boolean
|
||||
): HTMLDivElement {
|
||||
@@ -6746,7 +6760,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
dialog.querySelector('.value')
|
||||
if (!value_element) throw new TypeError('value_element was null')
|
||||
|
||||
value_element.value = value
|
||||
value_element.value = String(value)
|
||||
value_element.select()
|
||||
|
||||
const input = value_element
|
||||
@@ -8119,10 +8133,10 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
|
||||
{
|
||||
content: 'Properties Panel',
|
||||
callback: function (
|
||||
_item: any,
|
||||
_options: any,
|
||||
_e: any,
|
||||
_menu: any,
|
||||
_item: Positionable,
|
||||
_options: IContextMenuOptions | undefined,
|
||||
_e: MouseEvent | undefined,
|
||||
_menu: ContextMenu<unknown> | undefined,
|
||||
node: LGraphNode
|
||||
) {
|
||||
LGraphCanvas.active_canvas.showShowNodePanel(node)
|
||||
|
||||
Reference in New Issue
Block a user