Skip to content

@gausszhou/litegraph-core / LiteGraph

Class: LiteGraph ​

Defined in: packages/core/src/LiteGraph.ts:15

Constructors ​

Constructor ​

ts
new LiteGraph(): LiteGraph;

Returns ​

LiteGraph

Properties ​

_installedPlugins ​

ts
static _installedPlugins: any = [];

Defined in: packages/core/src/LiteGraph.ts:17


ts
static ACTION_LINK_COLOR: string = "#86A";

Defined in: packages/core/src/LiteGraph.ts:49


allow_multi_output_for_events ​

ts
static allow_multi_output_for_events: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:122


allow_scripts ​

ts
static allow_scripts: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:62

if set to true some nodes like Formula would be allowed to evaluate code that comes from unsafe sources (like node configuration), which could lead to exploits


alt_drag_do_clone_nodes ​

ts
static alt_drag_do_clone_nodes: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:116


auto_load_slot_types ​

ts
static auto_load_slot_types: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:100


auto_sort_node_types ​

ts
static auto_sort_node_types: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:76


CANVAS_GRID_SIZE ​

ts
static CANVAS_GRID_SIZE: number = 10;

Defined in: packages/core/src/LiteGraph.ts:19


catch_exceptions ​

ts
static catch_exceptions: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:59


ts
static click_do_break_link_to: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:90


ts
static CONNECTING_LINK_COLOR: string = "#AFA";

Defined in: packages/core/src/LiteGraph.ts:50


debug ​

ts
static debug: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:58


DEFAULT_GROUP_FONT_SIZE ​

ts
static DEFAULT_GROUP_FONT_SIZE: number = 24;

Defined in: packages/core/src/LiteGraph.ts:40


DEFAULT_POSITION ​

ts
static DEFAULT_POSITION: Vector2;

Defined in: packages/core/src/LiteGraph.ts:53


DEFAULT_SHADOW_COLOR ​

ts
static DEFAULT_SHADOW_COLOR: string = "rgba(0,0,0,0.5)";

Defined in: packages/core/src/LiteGraph.ts:39


dialog_close_on_mouse_leave ​

ts
static dialog_close_on_mouse_leave: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:84


dialog_close_on_mouse_leave_delay ​

ts
static dialog_close_on_mouse_leave_delay: number = 500;

Defined in: packages/core/src/LiteGraph.ts:85


do_add_triggers_slots ​

ts
static do_add_triggers_slots: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:119


ts
static EVENT_LINK_COLOR: string = "#A86";

Defined in: packages/core/src/LiteGraph.ts:48


Globals ​

ts
static Globals: Record<any, any> = {};

Defined in: packages/core/src/LiteGraph.ts:70

used to store vars between graphs *


graph_inputs_outputs_use_combo_widget ​

ts
static graph_inputs_outputs_use_combo_widget: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:144


ignore_all_widget_events ​

ts
static ignore_all_widget_events: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:131


ts
static LINK_COLOR: string = "#9A9";

Defined in: packages/core/src/LiteGraph.ts:47


MAX_NUMBER_OF_NODES ​

ts
static MAX_NUMBER_OF_NODES: number = 1000;

Defined in: packages/core/src/LiteGraph.ts:52


middle_click_slot_add_default_node ​

ts
static middle_click_slot_add_default_node: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:125


node_box_coloured_by_mode ​

ts
static node_box_coloured_by_mode: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:81


node_box_coloured_when_on ​

ts
static node_box_coloured_when_on: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:79


NODE_BOX_OUTLINE_COLOR ​

ts
static NODE_BOX_OUTLINE_COLOR: string = "#FFF";

Defined in: packages/core/src/LiteGraph.ts:38


NODE_COLLAPSED_RADIUS ​

ts
static NODE_COLLAPSED_RADIUS: number = 10;

Defined in: packages/core/src/LiteGraph.ts:27


NODE_COLLAPSED_WIDTH ​

ts
static NODE_COLLAPSED_WIDTH: number = 80;

Defined in: packages/core/src/LiteGraph.ts:28


NODE_DEFAULT_BGCOLOR ​

ts
static NODE_DEFAULT_BGCOLOR: string = "#353535";

Defined in: packages/core/src/LiteGraph.ts:35


NODE_DEFAULT_BOXCOLOR ​

ts
static NODE_DEFAULT_BOXCOLOR: string = "#666";

Defined in: packages/core/src/LiteGraph.ts:36


NODE_DEFAULT_COLOR ​

ts
static NODE_DEFAULT_COLOR: string = "#333";

Defined in: packages/core/src/LiteGraph.ts:34


NODE_DEFAULT_SHAPE ​

ts
static NODE_DEFAULT_SHAPE: string = "box";

Defined in: packages/core/src/LiteGraph.ts:37


node_images_path ​

ts
static node_images_path: string = "";

Defined in: packages/core/src/LiteGraph.ts:56


NODE_MIN_WIDTH ​

ts
static NODE_MIN_WIDTH: number = 50;

Defined in: packages/core/src/LiteGraph.ts:26


NODE_SELECTED_TITLE_COLOR ​

ts
static NODE_SELECTED_TITLE_COLOR: string = "#FFF";

Defined in: packages/core/src/LiteGraph.ts:30


NODE_SLOT_HEIGHT ​

ts
static NODE_SLOT_HEIGHT: number = 20;

Defined in: packages/core/src/LiteGraph.ts:23


NODE_SUBTEXT_SIZE ​

ts
static NODE_SUBTEXT_SIZE: number = 12;

Defined in: packages/core/src/LiteGraph.ts:33


NODE_TEXT_COLOR ​

ts
static NODE_TEXT_COLOR: string = "#AAA";

Defined in: packages/core/src/LiteGraph.ts:32


NODE_TEXT_SIZE ​

ts
static NODE_TEXT_SIZE: number = 14;

Defined in: packages/core/src/LiteGraph.ts:31


NODE_TITLE_COLOR ​

ts
static NODE_TITLE_COLOR: string = "#999";

Defined in: packages/core/src/LiteGraph.ts:29


NODE_TITLE_HEIGHT ​

ts
static NODE_TITLE_HEIGHT: number = 20;

Defined in: packages/core/src/LiteGraph.ts:21


NODE_TITLE_TEXT_Y ​

ts
static NODE_TITLE_TEXT_Y: number = 15;

Defined in: packages/core/src/LiteGraph.ts:22


node_types_by_file_extension ​

ts
static node_types_by_file_extension: Record<string, LGraphNodeConstructor> = {};

Defined in: packages/core/src/LiteGraph.ts:66

used for dropping files in the canvas


NODE_WIDGET_HEIGHT ​

ts
static NODE_WIDGET_HEIGHT: number = 20;

Defined in: packages/core/src/LiteGraph.ts:24


NODE_WIDTH ​

ts
static NODE_WIDTH: number = 140;

Defined in: packages/core/src/LiteGraph.ts:25


Nodes ​

ts
static Nodes: Record<string, LGraphNodeConstructor> = {};

Defined in: packages/core/src/LiteGraph.ts:68

node types by class name


pointerevents_method ​

ts
static pointerevents_method: PointerEventsMethod = "mouse";

Defined in: packages/core/src/LiteGraph.ts:134


proxy ​

ts
static proxy: any = null;

Defined in: packages/core/src/LiteGraph.ts:55


registered_node_types ​

ts
static registered_node_types: Record<string, LGraphNodeConstructor> = {};

Defined in: packages/core/src/LiteGraph.ts:64

node types by string


registered_slot_in_types ​

ts
static registered_slot_in_types: Record<string, {
  nodes: string[];
}> = {};

Defined in: packages/core/src/LiteGraph.ts:103


registered_slot_out_types ​

ts
static registered_slot_out_types: Record<string, {
  nodes: string[];
}> = {};

Defined in: packages/core/src/LiteGraph.ts:105


ts
static release_link_on_empty_shows_menu: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:128


search_box_refresh_interval_ms ​

ts
static search_box_refresh_interval_ms: number = 250;

Defined in: packages/core/src/LiteGraph.ts:141


search_filter_enabled ​

ts
static search_filter_enabled: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:95


search_hide_on_mouse_leave ​

ts
static search_hide_on_mouse_leave: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:93


search_show_all_on_open ​

ts
static search_show_all_on_open: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:97


searchbox_extras ​

ts
static searchbox_extras: Record<string, SearchboxExtra> = {};

Defined in: packages/core/src/LiteGraph.ts:73

used to add extra features to the search box


serialize_slot_data ​

ts
static serialize_slot_data: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:147


ts
static shift_click_do_break_link_from: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:88


slot_types_default_in ​

ts
static slot_types_default_in: Record<string, NodeTypeSpec[]> = {};

Defined in: packages/core/src/LiteGraph.ts:111


slot_types_default_out ​

ts
static slot_types_default_out: Record<string, NodeTypeSpec[]> = {};

Defined in: packages/core/src/LiteGraph.ts:113


slot_types_in ​

ts
static slot_types_in: string[] = [];

Defined in: packages/core/src/LiteGraph.ts:107


slot_types_out ​

ts
static slot_types_out: string[] = [];

Defined in: packages/core/src/LiteGraph.ts:109


throw_errors ​

ts
static throw_errors: boolean = true;

Defined in: packages/core/src/LiteGraph.ts:60


use_uuids ​

ts
static use_uuids: boolean = false;

Defined in: packages/core/src/LiteGraph.ts:138


VERSION ​

ts
static VERSION: number = 10.0;

Defined in: packages/core/src/LiteGraph.ts:16


WIDGET_BGCOLOR ​

ts
static WIDGET_BGCOLOR: string = "#222";

Defined in: packages/core/src/LiteGraph.ts:42


WIDGET_OUTLINE_COLOR ​

ts
static WIDGET_OUTLINE_COLOR: string = "#666";

Defined in: packages/core/src/LiteGraph.ts:43


WIDGET_SECONDARY_TEXT_COLOR ​

ts
static WIDGET_SECONDARY_TEXT_COLOR: string = "#999";

Defined in: packages/core/src/LiteGraph.ts:45


WIDGET_TEXT_COLOR ​

ts
static WIDGET_TEXT_COLOR: string = "#DDD";

Defined in: packages/core/src/LiteGraph.ts:44

Methods ​

clearRegisteredTypes() ​

ts
static clearRegisteredTypes(): void;

Defined in: packages/core/src/LiteGraph.ts:300

Removes all previously registered node's types.

Returns ​

void


cloneObject() ​

ts
static cloneObject<T>(obj?, target?): T;

Defined in: packages/core/src/LiteGraph.ts:537

Type Parameters ​

T ​

T

Parameters ​

obj? ​

T

target? ​

T

Returns ​

T


colorToString() ​

ts
static colorToString(c): string;

Defined in: packages/core/src/LiteGraph.ts:618

Parameters ​

c ​

number[]

Returns ​

string


compareObjects() ​

ts
static compareObjects(a, b): boolean;

Defined in: packages/core/src/LiteGraph.ts:603

Parameters ​

a ​

object

b ​

object

Returns ​

boolean


createNode() ​

ts
static createNode<T>(
   type, 
   title?, 
   options?
): T;

Defined in: packages/core/src/LiteGraph.ts:314

Create a node of a given type with a name. The node is not attached to any graph yet.

Type Parameters ​

T ​

T extends LGraphNode

Parameters ​

type ​

| string | LGraphNodeConstructorFactory<T>

full name of the node class. p.e. "math/sin"

title? ​

string

options? ​

LiteGraphCreateNodeOptions = {}

to set options

Returns ​

T


distance() ​

ts
static distance(a, b): number;

Defined in: packages/core/src/LiteGraph.ts:612

Parameters ​

a ​

Vector2

b ​

Vector2

Returns ​

number


getNodeType() ​

ts
static getNodeType<T>(type): LGraphNodeConstructor<T>;

Defined in: packages/core/src/LiteGraph.ts:428

Returns a registered node type with a given name

Type Parameters ​

T ​

T extends LGraphNode

Parameters ​

type ​

string

full name of the node class. p.e. "math/sin"

Returns ​

LGraphNodeConstructor<T>


getNodeTypesCategories() ​

ts
static getNodeTypesCategories(filter): string[];

Defined in: packages/core/src/LiteGraph.ts:472

Returns a list with all the node type categories

Parameters ​

filter ​

string

only nodes with ctor.filter equal can be shown

Returns ​

string[]

array with all the names of the categories

Method ​

getNodeTypesCategories


getNodeTypesInCategory() ​

ts
static getNodeTypesInCategory(category, filter): LGraphNodeConstructor<LGraphNode>[];

Defined in: packages/core/src/LiteGraph.ts:439

Returns a list of node types matching one category

Parameters ​

category ​

string

category name

filter ​

string

only nodes with ctor.filter equal can be shown

Returns ​

LGraphNodeConstructor<LGraphNode>[]

array with all the node classes

Method ​

getNodeTypesInCategory


getTime() ​

ts
static getTime(): number;

Defined in: packages/core/src/LiteGraph.ts:598

Returns ​

number


growBounding() ​

ts
static growBounding(
   bounding, 
   x, 
   y
): Vector4;

Defined in: packages/core/src/LiteGraph.ts:647

Parameters ​

bounding ​

Vector4

x ​

number

y ​

number

Returns ​

Vector4


hex2num() ​

ts
static hex2num(hex): [number, number, number];

Defined in: packages/core/src/LiteGraph.ts:696

Parameters ​

hex ​

string

Returns ​

[number, number, number]


isInsideBounding() ​

ts
static isInsideBounding(p, bb): boolean;

Defined in: packages/core/src/LiteGraph.ts:663

Parameters ​

p ​

Vector2

bb ​

[Vector2, Vector2]

Returns ​

boolean


isInsideRectangle() ​

ts
static isInsideRectangle(
   x, 
   y, 
   left, 
   top, 
   width, 
   height
): boolean;

Defined in: packages/core/src/LiteGraph.ts:632

Parameters ​

x ​

number

y ​

number

left ​

number

top ​

number

width ​

number

height ​

number

Returns ​

boolean


isValidConnection() ​

ts
static isValidConnection(type_a, type_b): boolean;

Defined in: packages/core/src/LiteGraph.ts:559

Returns if the types of two slots are compatible (taking into account wildcards, etc)

Parameters ​

type_a ​

SlotType

type_b ​

SlotType

Returns ​

boolean

true if they can be connected

Method ​

isValidConnection


num2hex() ​

ts
static num2hex(triplet): string;

Defined in: packages/core/src/LiteGraph.ts:716

Parameters ​

triplet ​

[number, number, number]

Returns ​

string


onNodeTypeRegistered()? ​

ts
static onNodeTypeRegistered?(type, regConfig): void;

Defined in: packages/core/src/LiteGraph.ts:219

Parameters ​

type ​

string

regConfig ​

LGraphNodeConstructor

Returns ​

void


onNodeTypeReplaced()? ​

ts
static onNodeTypeReplaced?(
   type, 
   regConfig, 
   prev
): void;

Defined in: packages/core/src/LiteGraph.ts:220

Parameters ​

type ​

string

regConfig ​

LGraphNodeConstructor

prev ​

LGraphNodeConstructor

Returns ​

void


overlapBounding() ​

ts
static overlapBounding(a, b): boolean;

Defined in: packages/core/src/LiteGraph.ts:676

Parameters ​

a ​

Float32Array

b ​

Float32Array

Returns ​

boolean


pointerListenerAdd() ​

ts
static pointerListenerAdd(
   oDOM, 
   sEvIn, 
   fCall, 
   capture?
): void;

Defined in: packages/core/src/LiteGraph.ts:736

Parameters ​

oDOM ​

Node

sEvIn ​

string

fCall ​

(e) => any

capture? ​

boolean = false

Returns ​

void


pointerListenerRemove() ​

ts
static pointerListenerRemove(
   oDOM, 
   sEvent, 
   fCall, 
   capture?
): any;

Defined in: packages/core/src/LiteGraph.ts:799

Parameters ​

oDOM ​

any

sEvent ​

string

fCall ​

any

capture? ​

boolean = false

Returns ​

any


registerNodeAndSlotType() ​

ts
static registerNodeAndSlotType(
   type, 
   slot_type, 
   out?
): void;

Defined in: packages/core/src/LiteGraph.ts:244

Save a slot type and his node

Parameters ​

type ​

| string | LGraphNode | LGraphNodeConstructor<LGraphNode>

name of the node or the node constructor itself

slot_type ​

SlotType

name of the slot type (variable type), eg. string, number, array, boolean, ..

out? ​

boolean = false

Returns ​

void

Method ​

registerSlotType


registerNodeType() ​

ts
static registerNodeType<T>(config, nodeClass?): void;

Defined in: packages/core/src/LiteGraph.ts:150

Register a node class so it can be listed when the user wants to create a new one

Type Parameters ​

T ​

T extends LGraphNode

Parameters ​

config ​

| string | LGraphNodeConstructor<LGraphNode>

nodeClass? ​

LGraphNodeConstructorFactory<T>

Returns ​

void


reloadNodes() ​

ts
static reloadNodes(folder_wildcard): void;

Defined in: packages/core/src/LiteGraph.ts:490

debug purposes: reloads all the js scripts that matches a wildcard

Parameters ​

folder_wildcard ​

string

Returns ​

void


unregisterNodeType() ​

ts
static unregisterNodeType(type): void;

Defined in: packages/core/src/LiteGraph.ts:223

removes a node type from the system

Parameters ​

type ​

| string | LGraphNodeConstructor<LGraphNode>

Returns ​

void


use() ​

ts
static use(plugin): typeof default;

Defined in: packages/core/src/LiteGraph.ts:823

Parameters ​

plugin ​

any

Returns ​

typeof default

Released under the MIT License.