mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-03 12:42:01 +00:00
## Summary Continues the TypeScript strict typing improvements by removing `any` types from core scripts and dialog components. ### Changes **api.ts (6 instances)** - Define `V1RawPrompt` and `CloudRawPrompt` tuple types for queue prompt formats - Export `QueueIndex`, `PromptInputs`, `ExtraData`, `OutputsToExecute` from apiSchema - Type `#postItem` body, `storeUserData` data, and `getCustomNodesI18n` return **groupNodeManage.ts (all @ts-expect-error removed)** - Add `GroupNodeConfigEntry` interface to LGraph.ts - Extend `GroupNodeWorkflowData` with `title`, `widgets_values`, and typed `config` - Type all class properties with definite assignment assertions - Type all method parameters and event handlers - Fix save button callback with proper generic types for node ordering **changeTracker.ts (4 instances)** - Type `nodeOutputs` as `Record<string, ExecutedWsMessage['output']>` - Type prompt callback with `CanvasPointerEvent` and proper value types **asyncDialog.ts and dialog.ts** - Make `ComfyAsyncDialog` generic with `DialogAction<T>` type - Type `ComfyDialog` constructor and show method parameters - Update `ManageGroupDialog.show` signature to match base class ## Test plan - [x] `pnpm typecheck` passes - [x] `pnpm lint` passes - [x] Sourcegraph checks for external usage --- Related: Continues from #8083 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8092-Road-to-No-Explicit-Any-Part-7-Scripts-and-Dialog-Cleanup-2ea6d73d365081fbb890e73646a6ad16) by [Unito](https://www.unito.io)
172 lines
5.1 KiB
TypeScript
172 lines
5.1 KiB
TypeScript
import type { ContextMenu } from './ContextMenu'
|
|
import type { LGraphNode } from './LGraphNode'
|
|
import { LiteGraphGlobal } from './LiteGraphGlobal'
|
|
import type {
|
|
ConnectingLink,
|
|
IContextMenuOptions,
|
|
Point,
|
|
Size
|
|
} from './interfaces'
|
|
import { loadPolyfills } from './polyfills'
|
|
import type { CanvasEventDetail } from './types/events'
|
|
import type { RenderShape, TitleMode } from './types/globalEnums'
|
|
|
|
// Must remain above LiteGraphGlobal (circular dependency due to abstract factory behaviour in `configure`)
|
|
export { Subgraph } from './subgraph/Subgraph'
|
|
|
|
export const LiteGraph = new LiteGraphGlobal()
|
|
|
|
// Load legacy polyfills
|
|
loadPolyfills()
|
|
|
|
// Backwards compat
|
|
|
|
// Type definitions for litegraph.js 0.7.0
|
|
// Project: litegraph.js
|
|
// Definitions by: NateScarlet <https://github.com/NateScarlet>
|
|
/** @deprecated Use {@link Point} instead. */
|
|
export type Vector2 = Point
|
|
|
|
interface IContextMenuItem {
|
|
content: string
|
|
callback?: ContextMenuEventListener
|
|
/** Used as innerHTML for extra child element */
|
|
title?: string
|
|
disabled?: boolean
|
|
has_submenu?: boolean
|
|
submenu?: {
|
|
options: IContextMenuItem[]
|
|
} & IContextMenuOptions
|
|
className?: string
|
|
}
|
|
|
|
type ContextMenuEventListener = (
|
|
value: IContextMenuItem,
|
|
options: IContextMenuOptions,
|
|
event: MouseEvent,
|
|
parentMenu: ContextMenu<unknown> | undefined,
|
|
node: LGraphNode
|
|
) => boolean | void
|
|
|
|
export interface LinkReleaseContextExtended {
|
|
links: ConnectingLink[]
|
|
}
|
|
|
|
export interface LiteGraphCanvasEvent extends CustomEvent<CanvasEventDetail> {}
|
|
|
|
export interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
|
|
new (title: string, type?: string): T
|
|
|
|
title: string
|
|
type?: string // TODO: to be, or not to be--that is the question
|
|
size?: Size
|
|
min_height?: number
|
|
slot_start_y?: number
|
|
widgets_info?: Record<string, unknown>
|
|
collapsable?: boolean
|
|
color?: string
|
|
bgcolor?: string
|
|
shape?: RenderShape
|
|
title_mode?: TitleMode
|
|
title_color?: string
|
|
title_text_color?: string
|
|
keepAllLinksOnBypass: boolean
|
|
resizeHandleSize?: number
|
|
resizeEdgeSize?: number
|
|
}
|
|
|
|
// End backwards compat
|
|
|
|
export { LinkConnector } from './canvas/LinkConnector'
|
|
export { isOverNodeInput, isOverNodeOutput } from './canvas/measureSlots'
|
|
export { CanvasPointer } from './CanvasPointer'
|
|
export * as Constants from './constants'
|
|
export { SUBGRAPH_INPUT_ID } from './constants'
|
|
export { ContextMenu } from './ContextMenu'
|
|
|
|
export { DragAndScale } from './DragAndScale'
|
|
|
|
export { Rectangle } from './infrastructure/Rectangle'
|
|
export { RecursionError } from './infrastructure/RecursionError'
|
|
export type {
|
|
CanvasColour,
|
|
ColorOption,
|
|
IContextMenuOptions,
|
|
IContextMenuValue,
|
|
INodeInputSlot,
|
|
INodeOutputSlot,
|
|
INodeSlot,
|
|
ISlotType,
|
|
LinkNetwork,
|
|
Point,
|
|
Positionable,
|
|
Size
|
|
} from './interfaces'
|
|
export {
|
|
LGraph,
|
|
type GroupNodeConfigEntry,
|
|
type GroupNodeWorkflowData,
|
|
type LGraphTriggerAction,
|
|
type LGraphTriggerParam
|
|
} from './LGraph'
|
|
export type { LGraphTriggerEvent } from './types/graphTriggers'
|
|
export { BadgePosition, LGraphBadge } from './LGraphBadge'
|
|
export { LGraphCanvas } from './LGraphCanvas'
|
|
export { LGraphGroup } from './LGraphGroup'
|
|
export { LGraphNode, type NodeId } from './LGraphNode'
|
|
export { LLink } from './LLink'
|
|
export { createBounds } from './measure'
|
|
export { Reroute, type RerouteId } from './Reroute'
|
|
export {
|
|
type ExecutableLGraphNode,
|
|
ExecutableNodeDTO,
|
|
type ExecutionId
|
|
} from './subgraph/ExecutableNodeDTO'
|
|
export { SubgraphNode } from './subgraph/SubgraphNode'
|
|
export type { CanvasPointerEvent } from './types/events'
|
|
export {
|
|
EaseFunction,
|
|
LGraphEventMode,
|
|
LinkDirection,
|
|
LinkMarkerShape,
|
|
RenderShape
|
|
} from './types/globalEnums'
|
|
export type {
|
|
ExportedSubgraph,
|
|
ExportedSubgraphInstance,
|
|
ISerialisedGraph,
|
|
ISerialisedNode,
|
|
SerialisableGraph
|
|
} from './types/serialisation'
|
|
export type { IWidget } from './types/widgets'
|
|
export { isColorable } from './utils/type'
|
|
export { createUuidv4 } from './utils/uuid'
|
|
export type { UUID } from './utils/uuid'
|
|
export { truncateText } from './utils/textUtils'
|
|
export { getWidgetStep } from './utils/widget'
|
|
export { distributeSpace, type SpaceRequest } from './utils/spaceDistribution'
|
|
|
|
export { BaseWidget } from './widgets/BaseWidget'
|
|
|
|
export { LegacyWidget } from './widgets/LegacyWidget'
|
|
|
|
export { isComboWidget, isAssetWidget } from './widgets/widgetMap'
|
|
// Additional test-specific exports
|
|
export { LGraphButton } from './LGraphButton'
|
|
export { MovingOutputLink } from './canvas/MovingOutputLink'
|
|
export { ToOutputRenderLink } from './canvas/ToOutputRenderLink'
|
|
export { ToInputFromIoNodeLink } from './canvas/ToInputFromIoNodeLink'
|
|
export type { TWidgetType, TWidgetValue, IWidgetOptions } from './types/widgets'
|
|
export {
|
|
findUsedSubgraphIds,
|
|
getDirectSubgraphIds,
|
|
isSubgraphInput,
|
|
isSubgraphOutput
|
|
} from './subgraph/subgraphUtils'
|
|
export { NodeInputSlot } from './node/NodeInputSlot'
|
|
export { NodeOutputSlot } from './node/NodeOutputSlot'
|
|
export { inputAsSerialisable, outputAsSerialisable } from './node/slotUtils'
|
|
export { MovingInputLink } from './canvas/MovingInputLink'
|
|
export { ToInputRenderLink } from './canvas/ToInputRenderLink'
|
|
export { LiteGraphGlobal } from './LiteGraphGlobal'
|