@codebolt/litegraph 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +161 -0
- package/dist/CanvasPointer.d.ts +120 -0
- package/dist/ContextMenu.d.ts +41 -0
- package/dist/CurveEditor.d.ts +18 -0
- package/dist/DragAndScale.d.ts +67 -0
- package/dist/LGraph.d.ts +407 -0
- package/dist/LGraphBadge.d.ts +33 -0
- package/dist/LGraphButton.d.ts +27 -0
- package/dist/LGraphCanvas.d.ts +772 -0
- package/dist/LGraphGroup.d.ts +81 -0
- package/dist/LGraphIcon.d.ts +22 -0
- package/dist/LGraphNode.d.ts +883 -0
- package/dist/LLink.d.ts +194 -0
- package/dist/LiteGraphGlobal.d.ts +360 -0
- package/dist/MapProxyHandler.d.ts +13 -0
- package/dist/Reroute.d.ts +185 -0
- package/dist/canvas/FloatingRenderLink.d.ts +55 -0
- package/dist/canvas/InputIndicators.d.ts +45 -0
- package/dist/canvas/LinkConnector.d.ts +165 -0
- package/dist/canvas/MovingInputLink.d.ts +34 -0
- package/dist/canvas/MovingLinkBase.d.ts +55 -0
- package/dist/canvas/MovingOutputLink.d.ts +30 -0
- package/dist/canvas/RenderLink.d.ts +39 -0
- package/dist/canvas/ToInputFromIoNodeLink.d.ts +37 -0
- package/dist/canvas/ToInputRenderLink.d.ts +35 -0
- package/dist/canvas/ToOutputFromIoNodeLink.d.ts +33 -0
- package/dist/canvas/ToOutputFromRerouteLink.d.ts +15 -0
- package/dist/canvas/ToOutputRenderLink.d.ts +32 -0
- package/dist/canvas/measureSlots.d.ts +22 -0
- package/dist/constants.d.ts +9 -0
- package/dist/css/litegraph.css +638 -0
- package/dist/draw.d.ts +65 -0
- package/dist/infrastructure/ConstrainedSize.d.ts +27 -0
- package/dist/infrastructure/CustomEventTarget.d.ts +72 -0
- package/dist/infrastructure/InvalidLinkError.d.ts +3 -0
- package/dist/infrastructure/LGraphCanvasEventMap.d.ts +41 -0
- package/dist/infrastructure/LGraphEventMap.d.ts +43 -0
- package/dist/infrastructure/LinkConnectorEventMap.d.ts +47 -0
- package/dist/infrastructure/NullGraphError.d.ts +3 -0
- package/dist/infrastructure/Rectangle.d.ts +163 -0
- package/dist/infrastructure/RecursionError.d.ts +6 -0
- package/dist/infrastructure/SlotIndexError.d.ts +3 -0
- package/dist/infrastructure/SubgraphEventMap.d.ts +49 -0
- package/dist/infrastructure/SubgraphInputEventMap.d.ts +13 -0
- package/dist/interfaces.d.ts +388 -0
- package/dist/litegraph.d.ts +95 -0
- package/dist/litegraph.es.js +17613 -0
- package/dist/litegraph.es.js.map +1 -0
- package/dist/litegraph.umd.js +3 -0
- package/dist/litegraph.umd.js.map +1 -0
- package/dist/measure.d.ts +168 -0
- package/dist/node/NodeInputSlot.d.ts +20 -0
- package/dist/node/NodeOutputSlot.d.ts +18 -0
- package/dist/node/NodeSlot.d.ts +35 -0
- package/dist/node/SlotBase.d.ts +27 -0
- package/dist/node/slotUtils.d.ts +17 -0
- package/dist/polyfills.d.ts +1 -0
- package/dist/strings.d.ts +22 -0
- package/dist/subgraph/EmptySubgraphInput.d.ts +15 -0
- package/dist/subgraph/EmptySubgraphOutput.d.ts +15 -0
- package/dist/subgraph/ExecutableNodeDTO.d.ts +96 -0
- package/dist/subgraph/Subgraph.d.ts +65 -0
- package/dist/subgraph/SubgraphIONodeBase.d.ts +80 -0
- package/dist/subgraph/SubgraphInput.d.ts +47 -0
- package/dist/subgraph/SubgraphInputNode.d.ts +33 -0
- package/dist/subgraph/SubgraphNode.d.ts +73 -0
- package/dist/subgraph/SubgraphOutput.d.ts +30 -0
- package/dist/subgraph/SubgraphOutputNode.d.ts +31 -0
- package/dist/subgraph/SubgraphSlotBase.d.ts +61 -0
- package/dist/subgraph/subgraphUtils.d.ts +77 -0
- package/dist/types/NodeLike.d.ts +7 -0
- package/dist/types/events.d.ts +64 -0
- package/dist/types/globalEnums.d.ts +130 -0
- package/dist/types/serialisation.d.ts +198 -0
- package/dist/types/utility.d.ts +11 -0
- package/dist/types/widgets.d.ts +209 -0
- package/dist/utils/arrange.d.ts +22 -0
- package/dist/utils/collections.d.ts +38 -0
- package/dist/utils/feedback.d.ts +7 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/spaceDistribution.d.ts +11 -0
- package/dist/utils/textUtils.d.ts +9 -0
- package/dist/utils/type.d.ts +14 -0
- package/dist/utils/uuid.d.ts +13 -0
- package/dist/utils/widget.d.ts +7 -0
- package/dist/widgets/BaseSteppedWidget.d.ts +34 -0
- package/dist/widgets/BaseWidget.d.ts +125 -0
- package/dist/widgets/BooleanWidget.d.ts +9 -0
- package/dist/widgets/ButtonWidget.d.ts +16 -0
- package/dist/widgets/ComboWidget.d.ts +17 -0
- package/dist/widgets/KnobWidget.d.ts +20 -0
- package/dist/widgets/LegacyWidget.d.ts +14 -0
- package/dist/widgets/NumberWidget.d.ts +18 -0
- package/dist/widgets/SliderWidget.d.ts +20 -0
- package/dist/widgets/TextWidget.d.ts +13 -0
- package/dist/widgets/widgetMap.d.ts +50 -0
- package/package.json +76 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { NeverNever, PickNevers } from '../types/utility';
|
|
2
|
+
type EventListeners<T> = {
|
|
3
|
+
readonly [K in keyof T]: ((this: EventTarget, ev: CustomEvent<T[K]>) => any) | EventListenerObject | null;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Has strongly-typed overrides of {@link EventTarget.addEventListener} and {@link EventTarget.removeEventListener}.
|
|
7
|
+
*/
|
|
8
|
+
export interface ICustomEventTarget<EventMap extends Record<Keys, unknown>, Keys extends keyof EventMap & string = keyof EventMap & string> {
|
|
9
|
+
addEventListener<K extends Keys>(type: K, listener: EventListeners<EventMap>[K], options?: boolean | AddEventListenerOptions): void;
|
|
10
|
+
removeEventListener<K extends Keys>(type: K, listener: EventListeners<EventMap>[K], options?: boolean | EventListenerOptions): void;
|
|
11
|
+
/** @deprecated Use {@link dispatch}. */
|
|
12
|
+
dispatchEvent(event: never): boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Capable of dispatching strongly-typed events via {@link dispatch}.
|
|
16
|
+
* Overloads are used to ensure detail param is correctly optional.
|
|
17
|
+
*/
|
|
18
|
+
export interface CustomEventDispatcher<EventMap extends Record<Keys, unknown>, Keys extends keyof EventMap & string = keyof EventMap & string> {
|
|
19
|
+
dispatch<T extends keyof NeverNever<EventMap>>(type: T, detail: EventMap[T]): boolean;
|
|
20
|
+
dispatch<T extends keyof PickNevers<EventMap>>(type: T): boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A strongly-typed, custom {@link EventTarget} that can dispatch and listen for events.
|
|
24
|
+
*
|
|
25
|
+
* 1. Define an event map
|
|
26
|
+
* ```ts
|
|
27
|
+
* export interface CustomEventMap {
|
|
28
|
+
* "my-event": { message: string }
|
|
29
|
+
* "simple-event": never
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* 2. Create an event emitter
|
|
34
|
+
* ```ts
|
|
35
|
+
* // By subclassing
|
|
36
|
+
* class MyClass extends CustomEventTarget<CustomEventMap> {
|
|
37
|
+
* // ...
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // Or simply create an instance:
|
|
41
|
+
* const events = new CustomEventTarget<CustomEventMap>()
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* 3. Dispatch events
|
|
45
|
+
* ```ts
|
|
46
|
+
* // Extended class
|
|
47
|
+
* const myClass = new MyClass()
|
|
48
|
+
* myClass.dispatch("my-event", { message: "Hello, world!" })
|
|
49
|
+
* myClass.dispatch("simple-event")
|
|
50
|
+
*
|
|
51
|
+
* // Instance
|
|
52
|
+
* const events = new CustomEventTarget<CustomEventMap>()
|
|
53
|
+
* events.dispatch("my-event", { message: "Hello, world!" })
|
|
54
|
+
* events.dispatch("simple-event")
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class CustomEventTarget<EventMap extends Record<Keys, unknown>, Keys extends keyof EventMap & string = keyof EventMap & string> extends EventTarget implements ICustomEventTarget<EventMap, Keys> {
|
|
58
|
+
/**
|
|
59
|
+
* Type-safe event dispatching.
|
|
60
|
+
* @see {@link EventTarget.dispatchEvent}
|
|
61
|
+
* @param type Name of the event to dispatch
|
|
62
|
+
* @param detail A custom object to send with the event
|
|
63
|
+
* @returns `true` if the event was dispatched successfully, otherwise `false`.
|
|
64
|
+
*/
|
|
65
|
+
dispatch<T extends keyof NeverNever<EventMap>>(type: T, detail: EventMap[T]): boolean;
|
|
66
|
+
dispatch<T extends keyof PickNevers<EventMap>>(type: T): boolean;
|
|
67
|
+
addEventListener<K extends Keys>(type: K, listener: EventListeners<EventMap>[K], options?: boolean | AddEventListenerOptions): void;
|
|
68
|
+
removeEventListener<K extends Keys>(type: K, listener: EventListeners<EventMap>[K], options?: boolean | EventListenerOptions): void;
|
|
69
|
+
/** @deprecated Use {@link dispatch}. */
|
|
70
|
+
dispatchEvent(event: never): boolean;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConnectingLink } from '../interfaces';
|
|
2
|
+
import { LGraph } from '../LGraph';
|
|
3
|
+
import { LGraphButton } from '../LGraphButton';
|
|
4
|
+
import { LGraphGroup } from '../LGraphGroup';
|
|
5
|
+
import { LGraphNode } from '../LGraphNode';
|
|
6
|
+
import { Subgraph } from '../subgraph/Subgraph';
|
|
7
|
+
import { CanvasPointerEvent } from '../types/events';
|
|
8
|
+
export interface LGraphCanvasEventMap {
|
|
9
|
+
/** The active graph has changed. */
|
|
10
|
+
"litegraph:set-graph": {
|
|
11
|
+
/** The new active graph. */
|
|
12
|
+
newGraph: LGraph | Subgraph;
|
|
13
|
+
/** The old active graph, or `null` if there was no active graph. */
|
|
14
|
+
oldGraph: LGraph | Subgraph | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
"litegraph:canvas": {
|
|
17
|
+
subType: "before-change" | "after-change";
|
|
18
|
+
} | {
|
|
19
|
+
subType: "empty-release";
|
|
20
|
+
originalEvent?: CanvasPointerEvent;
|
|
21
|
+
linkReleaseContext?: {
|
|
22
|
+
links: ConnectingLink[];
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
subType: "group-double-click";
|
|
26
|
+
originalEvent?: CanvasPointerEvent;
|
|
27
|
+
group: LGraphGroup;
|
|
28
|
+
} | {
|
|
29
|
+
subType: "empty-double-click";
|
|
30
|
+
originalEvent?: CanvasPointerEvent;
|
|
31
|
+
} | {
|
|
32
|
+
subType: "node-double-click";
|
|
33
|
+
originalEvent?: CanvasPointerEvent;
|
|
34
|
+
node: LGraphNode;
|
|
35
|
+
};
|
|
36
|
+
/** A title button on a node was clicked. */
|
|
37
|
+
"litegraph:node-title-button-clicked": {
|
|
38
|
+
node: LGraphNode;
|
|
39
|
+
button: LGraphButton;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReadOnlyRect } from '../interfaces';
|
|
2
|
+
import { LGraph } from '../LGraph';
|
|
3
|
+
import { LLink, ResolvedConnection } from '../LLink';
|
|
4
|
+
import { Subgraph } from '../subgraph/Subgraph';
|
|
5
|
+
import { ExportedSubgraph, ISerialisedGraph, SerialisableGraph } from '../types/serialisation';
|
|
6
|
+
export interface LGraphEventMap {
|
|
7
|
+
"configuring": {
|
|
8
|
+
/** The data that was used to configure the graph. */
|
|
9
|
+
data: ISerialisedGraph | SerialisableGraph;
|
|
10
|
+
/** If `true`, the graph will be cleared prior to adding the configuration. */
|
|
11
|
+
clearGraph: boolean;
|
|
12
|
+
};
|
|
13
|
+
"configured": never;
|
|
14
|
+
"subgraph-created": {
|
|
15
|
+
/** The subgraph that was created. */
|
|
16
|
+
subgraph: Subgraph;
|
|
17
|
+
/** The raw data that was used to create the subgraph. */
|
|
18
|
+
data: ExportedSubgraph;
|
|
19
|
+
};
|
|
20
|
+
/** Dispatched when a group of items are converted to a subgraph. */
|
|
21
|
+
"convert-to-subgraph": {
|
|
22
|
+
/** The type of subgraph to create. */
|
|
23
|
+
subgraph: Subgraph;
|
|
24
|
+
/** The boundary around every item that was moved into the subgraph. */
|
|
25
|
+
bounds: ReadOnlyRect;
|
|
26
|
+
/** The raw data that was used to create the subgraph. */
|
|
27
|
+
exportedSubgraph: ExportedSubgraph;
|
|
28
|
+
/** The links that were used to create the subgraph. */
|
|
29
|
+
boundaryLinks: LLink[];
|
|
30
|
+
/** Links that go from outside the subgraph in, via an input on the subgraph node. */
|
|
31
|
+
resolvedInputLinks: ResolvedConnection[];
|
|
32
|
+
/** Links that go from inside the subgraph out, via an output on the subgraph node. */
|
|
33
|
+
resolvedOutputLinks: ResolvedConnection[];
|
|
34
|
+
/** The floating links that were used to create the subgraph. */
|
|
35
|
+
boundaryFloatingLinks: LLink[];
|
|
36
|
+
/** The internal links that were used to create the subgraph. */
|
|
37
|
+
internalLinks: LLink[];
|
|
38
|
+
};
|
|
39
|
+
"open-subgraph": {
|
|
40
|
+
subgraph: Subgraph;
|
|
41
|
+
closingGraph: LGraph | Subgraph;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FloatingRenderLink } from '../canvas/FloatingRenderLink';
|
|
2
|
+
import { MovingInputLink } from '../canvas/MovingInputLink';
|
|
3
|
+
import { MovingOutputLink } from '../canvas/MovingOutputLink';
|
|
4
|
+
import { RenderLink } from '../canvas/RenderLink';
|
|
5
|
+
import { ToInputFromIoNodeLink } from '../canvas/ToInputFromIoNodeLink';
|
|
6
|
+
import { ToInputRenderLink } from '../canvas/ToInputRenderLink';
|
|
7
|
+
import { LGraphNode } from '../LGraphNode';
|
|
8
|
+
import { LLink } from '../LLink';
|
|
9
|
+
import { Reroute } from '../Reroute';
|
|
10
|
+
import { SubgraphInputNode } from '../subgraph/SubgraphInputNode';
|
|
11
|
+
import { SubgraphOutputNode } from '../subgraph/SubgraphOutputNode';
|
|
12
|
+
import { CanvasPointerEvent } from '../types/events';
|
|
13
|
+
import { IWidget } from '../types/widgets';
|
|
14
|
+
export interface LinkConnectorEventMap {
|
|
15
|
+
"reset": boolean;
|
|
16
|
+
"before-drop-links": {
|
|
17
|
+
renderLinks: RenderLink[];
|
|
18
|
+
event: CanvasPointerEvent;
|
|
19
|
+
};
|
|
20
|
+
"after-drop-links": {
|
|
21
|
+
renderLinks: RenderLink[];
|
|
22
|
+
event: CanvasPointerEvent;
|
|
23
|
+
};
|
|
24
|
+
"before-move-input": MovingInputLink | FloatingRenderLink;
|
|
25
|
+
"before-move-output": MovingOutputLink | FloatingRenderLink;
|
|
26
|
+
"input-moved": MovingInputLink | FloatingRenderLink | ToInputFromIoNodeLink;
|
|
27
|
+
"output-moved": MovingOutputLink | FloatingRenderLink;
|
|
28
|
+
"link-created": LLink | null | undefined;
|
|
29
|
+
"dropped-on-reroute": {
|
|
30
|
+
reroute: Reroute;
|
|
31
|
+
event: CanvasPointerEvent;
|
|
32
|
+
};
|
|
33
|
+
"dropped-on-node": {
|
|
34
|
+
node: LGraphNode;
|
|
35
|
+
event: CanvasPointerEvent;
|
|
36
|
+
};
|
|
37
|
+
"dropped-on-io-node": {
|
|
38
|
+
node: SubgraphInputNode | SubgraphOutputNode;
|
|
39
|
+
event: CanvasPointerEvent;
|
|
40
|
+
};
|
|
41
|
+
"dropped-on-canvas": CanvasPointerEvent;
|
|
42
|
+
"dropped-on-widget": {
|
|
43
|
+
link: ToInputRenderLink;
|
|
44
|
+
node: LGraphNode;
|
|
45
|
+
widget: IWidget;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { CompassCorners, Point, ReadOnlyPoint, ReadOnlyRect, ReadOnlySize, ReadOnlyTypedArray, Size } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* A rectangle, represented as a float64 array of 4 numbers: [x, y, width, height].
|
|
4
|
+
*
|
|
5
|
+
* This class is a subclass of Float64Array, and so has all the methods of that class. Notably,
|
|
6
|
+
* {@link Rectangle.from} can be used to convert a {@link ReadOnlyRect}. Typing of this however,
|
|
7
|
+
* is broken due to the base TS lib returning Float64Array rather than `this`.
|
|
8
|
+
*
|
|
9
|
+
* Sub-array properties ({@link Float64Array.subarray}):
|
|
10
|
+
* - {@link pos}: The position of the top-left corner of the rectangle.
|
|
11
|
+
* - {@link size}: The size of the rectangle.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Rectangle extends Float64Array {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
16
|
+
static from([x, y, width, height]: ReadOnlyRect): Rectangle;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new rectangle positioned at the given centre, with the given width/height.
|
|
19
|
+
* @param centre The centre of the rectangle, as an `[x, y]` point
|
|
20
|
+
* @param width The width of the rectangle
|
|
21
|
+
* @param height The height of the rectangle. Default: {@link width}
|
|
22
|
+
* @returns A new rectangle whose centre is at {@link x}
|
|
23
|
+
*/
|
|
24
|
+
static fromCentre([x, y]: ReadOnlyPoint, width: number, height?: number): Rectangle;
|
|
25
|
+
static ensureRect(rect: ReadOnlyRect): Rectangle;
|
|
26
|
+
subarray(begin?: number, end?: number): Float64Array<ArrayBuffer>;
|
|
27
|
+
/**
|
|
28
|
+
* A reference to the position of the top-left corner of this rectangle.
|
|
29
|
+
*
|
|
30
|
+
* Updating the values of the returned object will update this rectangle.
|
|
31
|
+
*/
|
|
32
|
+
get pos(): Point;
|
|
33
|
+
set pos(value: ReadOnlyPoint);
|
|
34
|
+
/**
|
|
35
|
+
* A reference to the size of this rectangle.
|
|
36
|
+
*
|
|
37
|
+
* Updating the values of the returned object will update this rectangle.
|
|
38
|
+
*/
|
|
39
|
+
get size(): Size;
|
|
40
|
+
set size(value: ReadOnlySize);
|
|
41
|
+
/** The x co-ordinate of the top-left corner of this rectangle. */
|
|
42
|
+
get x(): number;
|
|
43
|
+
set x(value: number);
|
|
44
|
+
/** The y co-ordinate of the top-left corner of this rectangle. */
|
|
45
|
+
get y(): number;
|
|
46
|
+
set y(value: number);
|
|
47
|
+
/** The width of this rectangle. */
|
|
48
|
+
get width(): number;
|
|
49
|
+
set width(value: number);
|
|
50
|
+
/** The height of this rectangle. */
|
|
51
|
+
get height(): number;
|
|
52
|
+
set height(value: number);
|
|
53
|
+
/** The x co-ordinate of the left edge of this rectangle. */
|
|
54
|
+
get left(): number;
|
|
55
|
+
set left(value: number);
|
|
56
|
+
/** The y co-ordinate of the top edge of this rectangle. */
|
|
57
|
+
get top(): number;
|
|
58
|
+
set top(value: number);
|
|
59
|
+
/** The x co-ordinate of the right edge of this rectangle. */
|
|
60
|
+
get right(): number;
|
|
61
|
+
set right(value: number);
|
|
62
|
+
/** The y co-ordinate of the bottom edge of this rectangle. */
|
|
63
|
+
get bottom(): number;
|
|
64
|
+
set bottom(value: number);
|
|
65
|
+
/** The x co-ordinate of the centre of this rectangle. */
|
|
66
|
+
get centreX(): number;
|
|
67
|
+
/** The y co-ordinate of the centre of this rectangle. */
|
|
68
|
+
get centreY(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Updates the rectangle to the values of {@link rect}.
|
|
71
|
+
* @param rect The rectangle to update to.
|
|
72
|
+
*/
|
|
73
|
+
updateTo(rect: ReadOnlyRect): void;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if the point [{@link x}, {@link y}] is inside this rectangle.
|
|
76
|
+
* @param x The x-coordinate to check
|
|
77
|
+
* @param y The y-coordinate to check
|
|
78
|
+
* @returns `true` if the point is inside this rectangle, otherwise `false`.
|
|
79
|
+
*/
|
|
80
|
+
containsXy(x: number, y: number): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if {@link point} is inside this rectangle.
|
|
83
|
+
* @param point The point to check
|
|
84
|
+
* @returns `true` if {@link point} is inside this rectangle, otherwise `false`.
|
|
85
|
+
*/
|
|
86
|
+
containsPoint([x, y]: ReadOnlyPoint): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Checks if {@link other} is a smaller rectangle inside this rectangle.
|
|
89
|
+
* One **must** be larger than the other; identical rectangles are not considered to contain each other.
|
|
90
|
+
* @param other The rectangle to check
|
|
91
|
+
* @returns `true` if {@link other} is inside this rectangle, otherwise `false`.
|
|
92
|
+
*/
|
|
93
|
+
containsRect(other: ReadOnlyRect): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if {@link rect} overlaps with this rectangle.
|
|
96
|
+
* @param rect The rectangle to check
|
|
97
|
+
* @returns `true` if {@link rect} overlaps with this rectangle, otherwise `false`.
|
|
98
|
+
*/
|
|
99
|
+
overlaps(rect: ReadOnlyRect): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Finds the corner (if any) of this rectangle that contains the point [{@link x}, {@link y}].
|
|
102
|
+
* @param x The x-coordinate to check
|
|
103
|
+
* @param y The y-coordinate to check
|
|
104
|
+
* @param cornerSize Each corner is treated as an inset square with this width and height.
|
|
105
|
+
* @returns The compass direction of the corner that contains the point, or `undefined` if the point is not in any corner.
|
|
106
|
+
*/
|
|
107
|
+
findContainingCorner(x: number, y: number, cornerSize: number): CompassCorners | undefined;
|
|
108
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the top-left corner of this rectangle, otherwise `false`. */
|
|
109
|
+
isInTopLeftCorner(x: number, y: number, cornerSize: number): boolean;
|
|
110
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the top-right corner of this rectangle, otherwise `false`. */
|
|
111
|
+
isInTopRightCorner(x: number, y: number, cornerSize: number): boolean;
|
|
112
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-left corner of this rectangle, otherwise `false`. */
|
|
113
|
+
isInBottomLeftCorner(x: number, y: number, cornerSize: number): boolean;
|
|
114
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-right corner of this rectangle, otherwise `false`. */
|
|
115
|
+
isInBottomRightCorner(x: number, y: number, cornerSize: number): boolean;
|
|
116
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the top edge of this rectangle, otherwise `false`. */
|
|
117
|
+
isInTopEdge(x: number, y: number, edgeSize: number): boolean;
|
|
118
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the bottom edge of this rectangle, otherwise `false`. */
|
|
119
|
+
isInBottomEdge(x: number, y: number, edgeSize: number): boolean;
|
|
120
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the left edge of this rectangle, otherwise `false`. */
|
|
121
|
+
isInLeftEdge(x: number, y: number, edgeSize: number): boolean;
|
|
122
|
+
/** @returns `true` if the point [{@link x}, {@link y}] is in the right edge of this rectangle, otherwise `false`. */
|
|
123
|
+
isInRightEdge(x: number, y: number, edgeSize: number): boolean;
|
|
124
|
+
/** @returns The centre point of this rectangle, as a new {@link Point}. */
|
|
125
|
+
getCentre(): Point;
|
|
126
|
+
/** @returns The area of this rectangle. */
|
|
127
|
+
getArea(): number;
|
|
128
|
+
/** @returns The perimeter of this rectangle. */
|
|
129
|
+
getPerimeter(): number;
|
|
130
|
+
/** @returns The top-left corner of this rectangle, as a new {@link Point}. */
|
|
131
|
+
getTopLeft(): Point;
|
|
132
|
+
/** @returns The bottom-right corner of this rectangle, as a new {@link Point}. */
|
|
133
|
+
getBottomRight(): Point;
|
|
134
|
+
/** @returns The width and height of this rectangle, as a new {@link Size}. */
|
|
135
|
+
getSize(): Size;
|
|
136
|
+
/** @returns The offset from the top-left of this rectangle to the point [{@link x}, {@link y}], as a new {@link Point}. */
|
|
137
|
+
getOffsetTo([x, y]: ReadOnlyPoint): Point;
|
|
138
|
+
/** @returns The offset from the point [{@link x}, {@link y}] to the top-left of this rectangle, as a new {@link Point}. */
|
|
139
|
+
getOffsetFrom([x, y]: ReadOnlyPoint): Point;
|
|
140
|
+
/** Resizes the rectangle without moving it, setting its top-left corner to [{@link x}, {@link y}]. */
|
|
141
|
+
resizeTopLeft(x1: number, y1: number): void;
|
|
142
|
+
/** Resizes the rectangle without moving it, setting its bottom-left corner to [{@link x}, {@link y}]. */
|
|
143
|
+
resizeBottomLeft(x1: number, y2: number): void;
|
|
144
|
+
/** Resizes the rectangle without moving it, setting its top-right corner to [{@link x}, {@link y}]. */
|
|
145
|
+
resizeTopRight(x2: number, y1: number): void;
|
|
146
|
+
/** Resizes the rectangle without moving it, setting its bottom-right corner to [{@link x}, {@link y}]. */
|
|
147
|
+
resizeBottomRight(x2: number, y2: number): void;
|
|
148
|
+
/** Sets the width without moving the right edge (changes position) */
|
|
149
|
+
setWidthRightAnchored(width: number): void;
|
|
150
|
+
/** Sets the height without moving the bottom edge (changes position) */
|
|
151
|
+
setHeightBottomAnchored(height: number): void;
|
|
152
|
+
clone(): Rectangle;
|
|
153
|
+
/** Alias of {@link export}. */
|
|
154
|
+
toArray(): [number, number, number, number];
|
|
155
|
+
/** @returns A new, untyped array (serializable) containing the values of this rectangle. */
|
|
156
|
+
export(): [number, number, number, number];
|
|
157
|
+
/**
|
|
158
|
+
* Draws a debug outline of this rectangle.
|
|
159
|
+
* @internal Convenience debug/development interface; not for production use.
|
|
160
|
+
*/
|
|
161
|
+
_drawDebug(ctx: CanvasRenderingContext2D, colour?: string): void;
|
|
162
|
+
}
|
|
163
|
+
export type ReadOnlyRectangle = Omit<ReadOnlyTypedArray<Rectangle>, "setHeightBottomAnchored" | "setWidthRightAnchored" | "resizeTopLeft" | "resizeBottomLeft" | "resizeTopRight" | "resizeBottomRight" | "resizeBottomRight" | "updateTo">;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LGraphEventMap } from './LGraphEventMap';
|
|
2
|
+
import { SubgraphInput } from '../subgraph/SubgraphInput';
|
|
3
|
+
import { SubgraphNode } from '../subgraph/SubgraphNode';
|
|
4
|
+
import { SubgraphOutput } from '../subgraph/SubgraphOutput';
|
|
5
|
+
import { IBaseWidget } from '../types/widgets';
|
|
6
|
+
export interface SubgraphEventMap extends LGraphEventMap {
|
|
7
|
+
"adding-input": {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
"adding-output": {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
"input-added": {
|
|
16
|
+
input: SubgraphInput;
|
|
17
|
+
};
|
|
18
|
+
"output-added": {
|
|
19
|
+
output: SubgraphOutput;
|
|
20
|
+
};
|
|
21
|
+
"removing-input": {
|
|
22
|
+
input: SubgraphInput;
|
|
23
|
+
index: number;
|
|
24
|
+
};
|
|
25
|
+
"removing-output": {
|
|
26
|
+
output: SubgraphOutput;
|
|
27
|
+
index: number;
|
|
28
|
+
};
|
|
29
|
+
"renaming-input": {
|
|
30
|
+
input: SubgraphInput;
|
|
31
|
+
index: number;
|
|
32
|
+
oldName: string;
|
|
33
|
+
newName: string;
|
|
34
|
+
};
|
|
35
|
+
"renaming-output": {
|
|
36
|
+
output: SubgraphOutput;
|
|
37
|
+
index: number;
|
|
38
|
+
oldName: string;
|
|
39
|
+
newName: string;
|
|
40
|
+
};
|
|
41
|
+
"widget-promoted": {
|
|
42
|
+
widget: IBaseWidget;
|
|
43
|
+
subgraphNode: SubgraphNode;
|
|
44
|
+
};
|
|
45
|
+
"widget-demoted": {
|
|
46
|
+
widget: IBaseWidget;
|
|
47
|
+
subgraphNode: SubgraphNode;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LGraphEventMap } from './LGraphEventMap';
|
|
2
|
+
import { INodeInputSlot } from '../litegraph';
|
|
3
|
+
import { SubgraphInput } from '../subgraph/SubgraphInput';
|
|
4
|
+
import { IBaseWidget } from '../types/widgets';
|
|
5
|
+
export interface SubgraphInputEventMap extends LGraphEventMap {
|
|
6
|
+
"input-connected": {
|
|
7
|
+
input: INodeInputSlot;
|
|
8
|
+
widget: IBaseWidget;
|
|
9
|
+
};
|
|
10
|
+
"input-disconnected": {
|
|
11
|
+
input: SubgraphInput;
|
|
12
|
+
};
|
|
13
|
+
}
|