@elicdavis/node-flow 0.1.16 → 0.1.18
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/dist/index.d.mts +97 -4
- package/dist/index.d.ts +97 -4
- package/dist/index.js +674 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +668 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graph.ts +234 -41
- package/src/index.ts +16 -0
- package/src/input.ts +22 -14
- package/src/markdown/entry.ts +6 -2
- package/src/minimap.ts +178 -0
- package/src/node.ts +83 -1
- package/src/nodes/factory.ts +9 -5
- package/src/nodes/publisher.ts +39 -4
- package/src/nodes/subsystem.ts +214 -2
- package/src/notes/subsystem.ts +3 -0
- package/src/popup.ts +27 -6
- package/src/port.ts +17 -4
- package/src/render_scheduler.ts +49 -0
- package/src/theme.ts +8 -0
- package/src/types/text.ts +2 -0
- package/src/widgets/image.ts +2 -0
- package/src/widgets/number.ts +2 -1
- package/src/widgets/string.ts +3 -1
- package/src/widgets/toggle.ts +3 -1
- package/test/minimap.test.ts +103 -0
- package/test/node_menu_filter.test.ts +119 -0
- package/test/popup.test.ts +104 -0
- package/test/render_scheduler.test.ts +119 -0
- package/test/widget_click.test.ts +126 -0
- package/test/widget_construction.test.ts +48 -0
package/dist/index.d.mts
CHANGED
|
@@ -199,6 +199,8 @@ interface PortConfig {
|
|
|
199
199
|
* anything. They connect when those sets overlap.
|
|
200
200
|
*/
|
|
201
201
|
declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
|
|
202
|
+
declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
|
|
203
|
+
declare function portConfigTypes(config: PortConfig): Array<string>;
|
|
202
204
|
declare class Port {
|
|
203
205
|
#private;
|
|
204
206
|
constructor(node: FlowNode, portType: PortType, config?: PortConfig);
|
|
@@ -373,11 +375,36 @@ declare class FlowNode {
|
|
|
373
375
|
outputs(): number;
|
|
374
376
|
addMessage(message: NodeMessageConfig): void;
|
|
375
377
|
clearMessages(): void;
|
|
378
|
+
hasBeenLaidOut(): boolean;
|
|
376
379
|
render(ctx: CanvasRenderingContext2D, camera: Camera, state: NodeState, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): void;
|
|
380
|
+
layoutPortsWithoutDrawing(bounds: Box, zoom: number): boolean;
|
|
377
381
|
}
|
|
378
382
|
|
|
379
383
|
type NodeAddedCallback = (node: FlowNode) => void;
|
|
380
384
|
type NodeRemovedCallback = (node: FlowNode) => void;
|
|
385
|
+
/**
|
|
386
|
+
* A connection between two nodes of a copied set, by their position in that
|
|
387
|
+
* set rather than by node, so it can be rebuilt against the copies.
|
|
388
|
+
*/
|
|
389
|
+
interface InternalConnection {
|
|
390
|
+
fromNode: number;
|
|
391
|
+
fromPort: number;
|
|
392
|
+
toNode: number;
|
|
393
|
+
toPort: number;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* A connection that was dragged out and dropped on empty canvas. Describes
|
|
397
|
+
* what a node would have to offer to finish it, and joins the two up once
|
|
398
|
+
* one has been made.
|
|
399
|
+
*/
|
|
400
|
+
interface DanglingConnection {
|
|
401
|
+
/** The side the new node has to offer. */
|
|
402
|
+
needs: PortType;
|
|
403
|
+
/** The types that side has to accept. Empty takes anything. */
|
|
404
|
+
types: Array<string>;
|
|
405
|
+
/** Wires the new node to the port the drag started from. */
|
|
406
|
+
connectTo: (node: FlowNode) => void;
|
|
407
|
+
}
|
|
381
408
|
interface ConnectionRendererConfiguration {
|
|
382
409
|
size?: number;
|
|
383
410
|
color?: string;
|
|
@@ -400,6 +427,8 @@ declare class NodeSubsystem {
|
|
|
400
427
|
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
|
|
401
428
|
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
402
429
|
clearNodeInputConnection(node: FlowNode, index: number): void;
|
|
430
|
+
connectionsWithin(nodes: Array<FlowNode>): Array<InternalConnection>;
|
|
431
|
+
setConnectionReleasedHandler(handler: (dangling: DanglingConnection) => void): void;
|
|
403
432
|
clickEnd(): void;
|
|
404
433
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
405
434
|
getNodes(): Array<FlowNode>;
|
|
@@ -422,9 +451,26 @@ declare class NodeSubsystem {
|
|
|
422
451
|
removeNode(node: FlowNode): void;
|
|
423
452
|
organize(ctx: CanvasRenderingContext2D): void;
|
|
424
453
|
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig | null;
|
|
454
|
+
/** Drops the selection entirely. */
|
|
455
|
+
unselectAllNodes(): void;
|
|
456
|
+
/**
|
|
457
|
+
* Removes every selected node, and the connections that touched them.
|
|
458
|
+
*/
|
|
459
|
+
removeSelectedNodes(): Array<FlowNode>;
|
|
425
460
|
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined;
|
|
426
461
|
}
|
|
427
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Narrows a "new node" menu to the nodes that could actually be wired to a
|
|
465
|
+
* particular port.
|
|
466
|
+
*/
|
|
467
|
+
interface NodeMenuFilter {
|
|
468
|
+
/** Which side the new node has to offer. */
|
|
469
|
+
needs: PortType;
|
|
470
|
+
/** Types that side has to accept. An empty list takes anything. */
|
|
471
|
+
types: Array<string>;
|
|
472
|
+
onCreated?: (node: FlowNode) => void;
|
|
473
|
+
}
|
|
428
474
|
interface PublisherNodes {
|
|
429
475
|
[name: string]: FlowNodeConfig;
|
|
430
476
|
}
|
|
@@ -440,7 +486,7 @@ declare class Publisher {
|
|
|
440
486
|
nodes(): Map<string, FlowNodeConfig>;
|
|
441
487
|
register(nodeType: string, config: FlowNodeConfig): void;
|
|
442
488
|
unregister(nodeType: string): boolean;
|
|
443
|
-
contextMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
489
|
+
contextMenu(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): ContextMenuConfig;
|
|
444
490
|
create(nodeType: string): FlowNode;
|
|
445
491
|
}
|
|
446
492
|
|
|
@@ -458,8 +504,8 @@ declare class NodeFactory {
|
|
|
458
504
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
459
505
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
460
506
|
create(publisher: string, nodeType: string): FlowNode;
|
|
461
|
-
newNodeSubmenus(graph: NodeSubsystem, position: Vector2): Array<ContextMenuConfig>;
|
|
462
|
-
openMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
507
|
+
newNodeSubmenus(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): Array<ContextMenuConfig>;
|
|
508
|
+
openMenu(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): ContextMenuConfig;
|
|
463
509
|
}
|
|
464
510
|
|
|
465
511
|
type NoteContentChangeCallback = (node: FlowNote, newContents: string) => void;
|
|
@@ -518,7 +564,33 @@ interface NoteSubsystemConfig {
|
|
|
518
564
|
notes?: Array<FlowNoteConfig>;
|
|
519
565
|
}
|
|
520
566
|
|
|
567
|
+
interface MinimapConfig {
|
|
568
|
+
enabled?: boolean;
|
|
569
|
+
width?: number;
|
|
570
|
+
height?: number;
|
|
571
|
+
margin?: number;
|
|
572
|
+
/** Overrides Theme.Minimap.BackgroundColor for this minimap alone. */
|
|
573
|
+
backgroundColor?: string;
|
|
574
|
+
/** Overrides Theme.Minimap.BorderColor for this minimap alone. */
|
|
575
|
+
borderColor?: string;
|
|
576
|
+
/** Overrides Theme.Minimap.NodeColor for this minimap alone. */
|
|
577
|
+
nodeColor?: string;
|
|
578
|
+
/** Overrides Theme.Minimap.ViewportColor for this minimap alone. */
|
|
579
|
+
viewportColor?: string;
|
|
580
|
+
}
|
|
581
|
+
declare class Minimap {
|
|
582
|
+
#private;
|
|
583
|
+
constructor(config?: MinimapConfig);
|
|
584
|
+
enabled(): boolean;
|
|
585
|
+
setEnabled(enabled: boolean): void;
|
|
586
|
+
contains(position: Vector2): boolean;
|
|
587
|
+
graphPositionOf(position: Vector2, out: Vector2): void;
|
|
588
|
+
render(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement, camera: Camera, nodes: Array<FlowNode>): void;
|
|
589
|
+
}
|
|
590
|
+
|
|
521
591
|
type GraphRenderer = (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, position: Vector2, scale: number) => void;
|
|
592
|
+
type CopyCallback = (nodes: Array<FlowNode>, connections: Array<InternalConnection>) => void;
|
|
593
|
+
type PasteCallback = (position: Vector2) => void;
|
|
522
594
|
interface FlowNodeGraphConfiguration {
|
|
523
595
|
backgroundRenderer?: GraphRenderer;
|
|
524
596
|
backgroundColor?: string;
|
|
@@ -526,6 +598,7 @@ interface FlowNodeGraphConfiguration {
|
|
|
526
598
|
contextMenu?: ContextMenuConfig;
|
|
527
599
|
nodes?: NodeFactoryConfig;
|
|
528
600
|
board?: NoteSubsystemConfig;
|
|
601
|
+
minimap?: MinimapConfig;
|
|
529
602
|
}
|
|
530
603
|
declare class GraphView {
|
|
531
604
|
#private;
|
|
@@ -540,11 +613,15 @@ declare class GraphView {
|
|
|
540
613
|
declare class NodeFlowGraph {
|
|
541
614
|
#private;
|
|
542
615
|
constructor(canvas: HTMLCanvasElement, config?: FlowNodeGraphConfiguration);
|
|
616
|
+
addCopyListener(callback: CopyCallback): void;
|
|
617
|
+
addPasteListener(callback: PasteCallback): void;
|
|
543
618
|
addNoteAddedListener(callback: NoteAddedCallback): void;
|
|
544
619
|
addNoteRemovedListener(callback: NoteRemovedCallback): void;
|
|
545
620
|
addNoteDragStartListener(callback: NoteDragStartCallback): void;
|
|
546
621
|
addNoteDragStopListener(callback: NoteDragStopCallback): void;
|
|
547
622
|
zoom(amount: number, anchor?: Vector2): void;
|
|
623
|
+
/** The minimap, so it can be turned on and sized by the host. */
|
|
624
|
+
minimap(): Minimap;
|
|
548
625
|
currentView(): GraphView;
|
|
549
626
|
organize(): void;
|
|
550
627
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
@@ -554,6 +631,8 @@ declare class NodeFlowGraph {
|
|
|
554
631
|
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
555
632
|
*/
|
|
556
633
|
getSelectedNodes(): Array<FlowNode>;
|
|
634
|
+
unselectAllNodes(): void;
|
|
635
|
+
removeSelectedNodes(): Array<FlowNode>;
|
|
557
636
|
/**
|
|
558
637
|
* Returns a copy of the current camera orientation (screen-space pan + zoom).
|
|
559
638
|
*/
|
|
@@ -583,6 +662,9 @@ declare class NodeFlowGraph {
|
|
|
583
662
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
584
663
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
585
664
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
665
|
+
requestRender(): void;
|
|
666
|
+
renderContinuously(): () => void;
|
|
667
|
+
dispose(): void;
|
|
586
668
|
}
|
|
587
669
|
|
|
588
670
|
declare const Theme: {
|
|
@@ -646,6 +728,14 @@ declare const Theme: {
|
|
|
646
728
|
FontColor: string;
|
|
647
729
|
DisabledFontColor: string;
|
|
648
730
|
};
|
|
731
|
+
Minimap: {
|
|
732
|
+
BackgroundColor: string;
|
|
733
|
+
BorderColor: string;
|
|
734
|
+
BorderRadius: number;
|
|
735
|
+
Padding: number;
|
|
736
|
+
NodeColor: string;
|
|
737
|
+
ViewportColor: string;
|
|
738
|
+
};
|
|
649
739
|
Note: {
|
|
650
740
|
FontColor: string;
|
|
651
741
|
FontSize: number;
|
|
@@ -670,6 +760,9 @@ declare const Theme: {
|
|
|
670
760
|
};
|
|
671
761
|
};
|
|
672
762
|
|
|
763
|
+
declare function requestRender(): void;
|
|
764
|
+
declare function renderContinuously(): () => void;
|
|
765
|
+
|
|
673
766
|
interface TextBoxStyleConfig {
|
|
674
767
|
box?: BoxStyleConfig;
|
|
675
768
|
text?: TextStyleConfig;
|
|
@@ -889,4 +982,4 @@ declare class WidgetFactory {
|
|
|
889
982
|
}
|
|
890
983
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
891
984
|
|
|
892
|
-
export { type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, DefaultConnectionRenderer, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, type ImageWidgetConfig, MessageType, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ToggleStyleConfig, ToggleWidget, type ToggleWidgetConfig, type Vector2, type Widget, type WidgetBuilder, type WidgetConfig, WidgetFactory, portsCompatible };
|
|
985
|
+
export { type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, type DanglingConnection, DefaultConnectionRenderer, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, type ImageWidgetConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ToggleStyleConfig, ToggleWidget, type ToggleWidgetConfig, type Vector2, type Widget, type WidgetBuilder, type WidgetConfig, WidgetFactory, portConfigTypes, portsCompatible, renderContinuously, requestRender, typeSetsCompatible };
|
package/dist/index.d.ts
CHANGED
|
@@ -199,6 +199,8 @@ interface PortConfig {
|
|
|
199
199
|
* anything. They connect when those sets overlap.
|
|
200
200
|
*/
|
|
201
201
|
declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
|
|
202
|
+
declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
|
|
203
|
+
declare function portConfigTypes(config: PortConfig): Array<string>;
|
|
202
204
|
declare class Port {
|
|
203
205
|
#private;
|
|
204
206
|
constructor(node: FlowNode, portType: PortType, config?: PortConfig);
|
|
@@ -373,11 +375,36 @@ declare class FlowNode {
|
|
|
373
375
|
outputs(): number;
|
|
374
376
|
addMessage(message: NodeMessageConfig): void;
|
|
375
377
|
clearMessages(): void;
|
|
378
|
+
hasBeenLaidOut(): boolean;
|
|
376
379
|
render(ctx: CanvasRenderingContext2D, camera: Camera, state: NodeState, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): void;
|
|
380
|
+
layoutPortsWithoutDrawing(bounds: Box, zoom: number): boolean;
|
|
377
381
|
}
|
|
378
382
|
|
|
379
383
|
type NodeAddedCallback = (node: FlowNode) => void;
|
|
380
384
|
type NodeRemovedCallback = (node: FlowNode) => void;
|
|
385
|
+
/**
|
|
386
|
+
* A connection between two nodes of a copied set, by their position in that
|
|
387
|
+
* set rather than by node, so it can be rebuilt against the copies.
|
|
388
|
+
*/
|
|
389
|
+
interface InternalConnection {
|
|
390
|
+
fromNode: number;
|
|
391
|
+
fromPort: number;
|
|
392
|
+
toNode: number;
|
|
393
|
+
toPort: number;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* A connection that was dragged out and dropped on empty canvas. Describes
|
|
397
|
+
* what a node would have to offer to finish it, and joins the two up once
|
|
398
|
+
* one has been made.
|
|
399
|
+
*/
|
|
400
|
+
interface DanglingConnection {
|
|
401
|
+
/** The side the new node has to offer. */
|
|
402
|
+
needs: PortType;
|
|
403
|
+
/** The types that side has to accept. Empty takes anything. */
|
|
404
|
+
types: Array<string>;
|
|
405
|
+
/** Wires the new node to the port the drag started from. */
|
|
406
|
+
connectTo: (node: FlowNode) => void;
|
|
407
|
+
}
|
|
381
408
|
interface ConnectionRendererConfiguration {
|
|
382
409
|
size?: number;
|
|
383
410
|
color?: string;
|
|
@@ -400,6 +427,8 @@ declare class NodeSubsystem {
|
|
|
400
427
|
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
|
|
401
428
|
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
402
429
|
clearNodeInputConnection(node: FlowNode, index: number): void;
|
|
430
|
+
connectionsWithin(nodes: Array<FlowNode>): Array<InternalConnection>;
|
|
431
|
+
setConnectionReleasedHandler(handler: (dangling: DanglingConnection) => void): void;
|
|
403
432
|
clickEnd(): void;
|
|
404
433
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
405
434
|
getNodes(): Array<FlowNode>;
|
|
@@ -422,9 +451,26 @@ declare class NodeSubsystem {
|
|
|
422
451
|
removeNode(node: FlowNode): void;
|
|
423
452
|
organize(ctx: CanvasRenderingContext2D): void;
|
|
424
453
|
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig | null;
|
|
454
|
+
/** Drops the selection entirely. */
|
|
455
|
+
unselectAllNodes(): void;
|
|
456
|
+
/**
|
|
457
|
+
* Removes every selected node, and the connections that touched them.
|
|
458
|
+
*/
|
|
459
|
+
removeSelectedNodes(): Array<FlowNode>;
|
|
425
460
|
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined;
|
|
426
461
|
}
|
|
427
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Narrows a "new node" menu to the nodes that could actually be wired to a
|
|
465
|
+
* particular port.
|
|
466
|
+
*/
|
|
467
|
+
interface NodeMenuFilter {
|
|
468
|
+
/** Which side the new node has to offer. */
|
|
469
|
+
needs: PortType;
|
|
470
|
+
/** Types that side has to accept. An empty list takes anything. */
|
|
471
|
+
types: Array<string>;
|
|
472
|
+
onCreated?: (node: FlowNode) => void;
|
|
473
|
+
}
|
|
428
474
|
interface PublisherNodes {
|
|
429
475
|
[name: string]: FlowNodeConfig;
|
|
430
476
|
}
|
|
@@ -440,7 +486,7 @@ declare class Publisher {
|
|
|
440
486
|
nodes(): Map<string, FlowNodeConfig>;
|
|
441
487
|
register(nodeType: string, config: FlowNodeConfig): void;
|
|
442
488
|
unregister(nodeType: string): boolean;
|
|
443
|
-
contextMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
489
|
+
contextMenu(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): ContextMenuConfig;
|
|
444
490
|
create(nodeType: string): FlowNode;
|
|
445
491
|
}
|
|
446
492
|
|
|
@@ -458,8 +504,8 @@ declare class NodeFactory {
|
|
|
458
504
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
459
505
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
460
506
|
create(publisher: string, nodeType: string): FlowNode;
|
|
461
|
-
newNodeSubmenus(graph: NodeSubsystem, position: Vector2): Array<ContextMenuConfig>;
|
|
462
|
-
openMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
507
|
+
newNodeSubmenus(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): Array<ContextMenuConfig>;
|
|
508
|
+
openMenu(graph: NodeSubsystem, position: Vector2, filter?: NodeMenuFilter): ContextMenuConfig;
|
|
463
509
|
}
|
|
464
510
|
|
|
465
511
|
type NoteContentChangeCallback = (node: FlowNote, newContents: string) => void;
|
|
@@ -518,7 +564,33 @@ interface NoteSubsystemConfig {
|
|
|
518
564
|
notes?: Array<FlowNoteConfig>;
|
|
519
565
|
}
|
|
520
566
|
|
|
567
|
+
interface MinimapConfig {
|
|
568
|
+
enabled?: boolean;
|
|
569
|
+
width?: number;
|
|
570
|
+
height?: number;
|
|
571
|
+
margin?: number;
|
|
572
|
+
/** Overrides Theme.Minimap.BackgroundColor for this minimap alone. */
|
|
573
|
+
backgroundColor?: string;
|
|
574
|
+
/** Overrides Theme.Minimap.BorderColor for this minimap alone. */
|
|
575
|
+
borderColor?: string;
|
|
576
|
+
/** Overrides Theme.Minimap.NodeColor for this minimap alone. */
|
|
577
|
+
nodeColor?: string;
|
|
578
|
+
/** Overrides Theme.Minimap.ViewportColor for this minimap alone. */
|
|
579
|
+
viewportColor?: string;
|
|
580
|
+
}
|
|
581
|
+
declare class Minimap {
|
|
582
|
+
#private;
|
|
583
|
+
constructor(config?: MinimapConfig);
|
|
584
|
+
enabled(): boolean;
|
|
585
|
+
setEnabled(enabled: boolean): void;
|
|
586
|
+
contains(position: Vector2): boolean;
|
|
587
|
+
graphPositionOf(position: Vector2, out: Vector2): void;
|
|
588
|
+
render(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement, camera: Camera, nodes: Array<FlowNode>): void;
|
|
589
|
+
}
|
|
590
|
+
|
|
521
591
|
type GraphRenderer = (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, position: Vector2, scale: number) => void;
|
|
592
|
+
type CopyCallback = (nodes: Array<FlowNode>, connections: Array<InternalConnection>) => void;
|
|
593
|
+
type PasteCallback = (position: Vector2) => void;
|
|
522
594
|
interface FlowNodeGraphConfiguration {
|
|
523
595
|
backgroundRenderer?: GraphRenderer;
|
|
524
596
|
backgroundColor?: string;
|
|
@@ -526,6 +598,7 @@ interface FlowNodeGraphConfiguration {
|
|
|
526
598
|
contextMenu?: ContextMenuConfig;
|
|
527
599
|
nodes?: NodeFactoryConfig;
|
|
528
600
|
board?: NoteSubsystemConfig;
|
|
601
|
+
minimap?: MinimapConfig;
|
|
529
602
|
}
|
|
530
603
|
declare class GraphView {
|
|
531
604
|
#private;
|
|
@@ -540,11 +613,15 @@ declare class GraphView {
|
|
|
540
613
|
declare class NodeFlowGraph {
|
|
541
614
|
#private;
|
|
542
615
|
constructor(canvas: HTMLCanvasElement, config?: FlowNodeGraphConfiguration);
|
|
616
|
+
addCopyListener(callback: CopyCallback): void;
|
|
617
|
+
addPasteListener(callback: PasteCallback): void;
|
|
543
618
|
addNoteAddedListener(callback: NoteAddedCallback): void;
|
|
544
619
|
addNoteRemovedListener(callback: NoteRemovedCallback): void;
|
|
545
620
|
addNoteDragStartListener(callback: NoteDragStartCallback): void;
|
|
546
621
|
addNoteDragStopListener(callback: NoteDragStopCallback): void;
|
|
547
622
|
zoom(amount: number, anchor?: Vector2): void;
|
|
623
|
+
/** The minimap, so it can be turned on and sized by the host. */
|
|
624
|
+
minimap(): Minimap;
|
|
548
625
|
currentView(): GraphView;
|
|
549
626
|
organize(): void;
|
|
550
627
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
@@ -554,6 +631,8 @@ declare class NodeFlowGraph {
|
|
|
554
631
|
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
555
632
|
*/
|
|
556
633
|
getSelectedNodes(): Array<FlowNode>;
|
|
634
|
+
unselectAllNodes(): void;
|
|
635
|
+
removeSelectedNodes(): Array<FlowNode>;
|
|
557
636
|
/**
|
|
558
637
|
* Returns a copy of the current camera orientation (screen-space pan + zoom).
|
|
559
638
|
*/
|
|
@@ -583,6 +662,9 @@ declare class NodeFlowGraph {
|
|
|
583
662
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
584
663
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
585
664
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
665
|
+
requestRender(): void;
|
|
666
|
+
renderContinuously(): () => void;
|
|
667
|
+
dispose(): void;
|
|
586
668
|
}
|
|
587
669
|
|
|
588
670
|
declare const Theme: {
|
|
@@ -646,6 +728,14 @@ declare const Theme: {
|
|
|
646
728
|
FontColor: string;
|
|
647
729
|
DisabledFontColor: string;
|
|
648
730
|
};
|
|
731
|
+
Minimap: {
|
|
732
|
+
BackgroundColor: string;
|
|
733
|
+
BorderColor: string;
|
|
734
|
+
BorderRadius: number;
|
|
735
|
+
Padding: number;
|
|
736
|
+
NodeColor: string;
|
|
737
|
+
ViewportColor: string;
|
|
738
|
+
};
|
|
649
739
|
Note: {
|
|
650
740
|
FontColor: string;
|
|
651
741
|
FontSize: number;
|
|
@@ -670,6 +760,9 @@ declare const Theme: {
|
|
|
670
760
|
};
|
|
671
761
|
};
|
|
672
762
|
|
|
763
|
+
declare function requestRender(): void;
|
|
764
|
+
declare function renderContinuously(): () => void;
|
|
765
|
+
|
|
673
766
|
interface TextBoxStyleConfig {
|
|
674
767
|
box?: BoxStyleConfig;
|
|
675
768
|
text?: TextStyleConfig;
|
|
@@ -889,4 +982,4 @@ declare class WidgetFactory {
|
|
|
889
982
|
}
|
|
890
983
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
891
984
|
|
|
892
|
-
export { type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, DefaultConnectionRenderer, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, type ImageWidgetConfig, MessageType, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ToggleStyleConfig, ToggleWidget, type ToggleWidgetConfig, type Vector2, type Widget, type WidgetBuilder, type WidgetConfig, WidgetFactory, portsCompatible };
|
|
985
|
+
export { type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, type DanglingConnection, DefaultConnectionRenderer, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, type ImageWidgetConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ToggleStyleConfig, ToggleWidget, type ToggleWidgetConfig, type Vector2, type Widget, type WidgetBuilder, type WidgetConfig, WidgetFactory, portConfigTypes, portsCompatible, renderContinuously, requestRender, typeSetsCompatible };
|