@elicdavis/node-flow 0.1.11 → 0.1.13
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/README.md +10 -0
- package/dist/index.d.mts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +355 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -95
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +33 -4
- package/src/contextMenu.ts +35 -3
- package/src/graph.ts +93 -37
- package/src/index.ts +14 -2
- package/src/input.ts +183 -74
- package/src/node.ts +19 -18
- package/src/nodes/subsystem.ts +43 -0
- package/src/notes/subsystem.ts +17 -0
- package/src/theme.ts +1 -0
- package/src/utils/string.ts +3 -3
package/README.md
CHANGED
|
@@ -164,6 +164,16 @@ node.addInput({ name: "c", type: "float32" })
|
|
|
164
164
|
node.addOutput({ name: "sum", type: "float32" })
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
### Note API
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
note.setText("...");
|
|
171
|
+
note.setPosition({ x, y });
|
|
172
|
+
graph.removeNote(note);
|
|
173
|
+
graph.removeAllNotes();
|
|
174
|
+
graph.getNotes();
|
|
175
|
+
```
|
|
176
|
+
|
|
167
177
|
## Library Development
|
|
168
178
|
|
|
169
179
|
Just run
|
package/dist/index.d.mts
CHANGED
|
@@ -19,10 +19,21 @@ interface TextStyleConfig {
|
|
|
19
19
|
style?: FontStyle;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
declare enum ContextMenuItemState {
|
|
23
|
+
Enabled = 0,
|
|
24
|
+
Disabled = 1,
|
|
25
|
+
Hidden = 2
|
|
26
|
+
}
|
|
22
27
|
interface ContextMenuItemConfig {
|
|
23
28
|
name?: string;
|
|
24
29
|
textStyle?: TextStyleConfig;
|
|
25
30
|
group?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Evaluated when the menu is opened. Defaults to Enabled when omitted.
|
|
33
|
+
* Hidden items are omitted from the menu; Disabled items are shown muted
|
|
34
|
+
* and are not clickable.
|
|
35
|
+
*/
|
|
36
|
+
enabled?: () => ContextMenuItemState;
|
|
26
37
|
callback?: () => void;
|
|
27
38
|
}
|
|
28
39
|
interface ContextMenuConfig {
|
|
@@ -343,6 +354,11 @@ declare class NodeSubsystem {
|
|
|
343
354
|
clickEnd(): void;
|
|
344
355
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
345
356
|
getNodes(): Array<FlowNode>;
|
|
357
|
+
/**
|
|
358
|
+
* Returns currently selected nodes in stable graph order (same selection
|
|
359
|
+
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
360
|
+
*/
|
|
361
|
+
getSelectedNodes(): Array<FlowNode>;
|
|
346
362
|
/**
|
|
347
363
|
* Returns all nodes who are connected to the inputs of the
|
|
348
364
|
* node in question
|
|
@@ -479,17 +495,30 @@ declare class NodeFlowGraph {
|
|
|
479
495
|
addNoteRemovedListener(callback: NoteRemovedCallback): void;
|
|
480
496
|
addNoteDragStartListener(callback: NoteDragStartCallback): void;
|
|
481
497
|
addNoteDragStopListener(callback: NoteDragStopCallback): void;
|
|
482
|
-
zoom(amount: number): void;
|
|
498
|
+
zoom(amount: number, anchor?: Vector2): void;
|
|
483
499
|
currentView(): GraphView;
|
|
484
500
|
organize(): void;
|
|
485
501
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
486
502
|
getNodes(): Array<FlowNode>;
|
|
503
|
+
/**
|
|
504
|
+
* Returns currently selected nodes in stable graph order (same selection
|
|
505
|
+
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
506
|
+
*/
|
|
507
|
+
getSelectedNodes(): Array<FlowNode>;
|
|
508
|
+
/**
|
|
509
|
+
* Adjusts camera position and zoom so all nodes fit in view (~10% padding).
|
|
510
|
+
* Falls back to camera.reset() when there are no nodes.
|
|
511
|
+
*/
|
|
512
|
+
centerOnGraph(): void;
|
|
487
513
|
connectedInputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
488
514
|
connectedOutputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
489
515
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
490
516
|
addNode(node: FlowNode): void;
|
|
491
517
|
removeNode(node: FlowNode): void;
|
|
492
518
|
addNote(note: FlowNote): void;
|
|
519
|
+
removeNote(note: FlowNote): void;
|
|
520
|
+
removeAllNotes(): void;
|
|
521
|
+
getNotes(): Array<FlowNote>;
|
|
493
522
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
494
523
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
495
524
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
@@ -554,6 +583,7 @@ declare const Theme: {
|
|
|
554
583
|
BackgroundColor: string;
|
|
555
584
|
HighlightColor: string;
|
|
556
585
|
FontColor: string;
|
|
586
|
+
DisabledFontColor: string;
|
|
557
587
|
};
|
|
558
588
|
Note: {
|
|
559
589
|
FontColor: string;
|
|
@@ -798,4 +828,4 @@ declare class WidgetFactory {
|
|
|
798
828
|
}
|
|
799
829
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
800
830
|
|
|
801
|
-
export { ButtonWidget, ColorWidget, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, GlobalWidgetFactory, type GraphRenderer, ImageWidget, MessageType, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, NumberWidget, Publisher, type PublisherConfig, SliderWidget, StringWidget, TextWidget, Theme, ToggleWidget, type WidgetConfig };
|
|
831
|
+
export { ButtonWidget, ColorWidget, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, MessageType, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, Publisher, type PublisherConfig, SliderWidget, StringWidget, TextWidget, Theme, ToggleWidget, type WidgetConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,10 +19,21 @@ interface TextStyleConfig {
|
|
|
19
19
|
style?: FontStyle;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
declare enum ContextMenuItemState {
|
|
23
|
+
Enabled = 0,
|
|
24
|
+
Disabled = 1,
|
|
25
|
+
Hidden = 2
|
|
26
|
+
}
|
|
22
27
|
interface ContextMenuItemConfig {
|
|
23
28
|
name?: string;
|
|
24
29
|
textStyle?: TextStyleConfig;
|
|
25
30
|
group?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Evaluated when the menu is opened. Defaults to Enabled when omitted.
|
|
33
|
+
* Hidden items are omitted from the menu; Disabled items are shown muted
|
|
34
|
+
* and are not clickable.
|
|
35
|
+
*/
|
|
36
|
+
enabled?: () => ContextMenuItemState;
|
|
26
37
|
callback?: () => void;
|
|
27
38
|
}
|
|
28
39
|
interface ContextMenuConfig {
|
|
@@ -343,6 +354,11 @@ declare class NodeSubsystem {
|
|
|
343
354
|
clickEnd(): void;
|
|
344
355
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
345
356
|
getNodes(): Array<FlowNode>;
|
|
357
|
+
/**
|
|
358
|
+
* Returns currently selected nodes in stable graph order (same selection
|
|
359
|
+
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
360
|
+
*/
|
|
361
|
+
getSelectedNodes(): Array<FlowNode>;
|
|
346
362
|
/**
|
|
347
363
|
* Returns all nodes who are connected to the inputs of the
|
|
348
364
|
* node in question
|
|
@@ -479,17 +495,30 @@ declare class NodeFlowGraph {
|
|
|
479
495
|
addNoteRemovedListener(callback: NoteRemovedCallback): void;
|
|
480
496
|
addNoteDragStartListener(callback: NoteDragStartCallback): void;
|
|
481
497
|
addNoteDragStopListener(callback: NoteDragStopCallback): void;
|
|
482
|
-
zoom(amount: number): void;
|
|
498
|
+
zoom(amount: number, anchor?: Vector2): void;
|
|
483
499
|
currentView(): GraphView;
|
|
484
500
|
organize(): void;
|
|
485
501
|
addPublisher(identifier: string, publisher: Publisher): void;
|
|
486
502
|
getNodes(): Array<FlowNode>;
|
|
503
|
+
/**
|
|
504
|
+
* Returns currently selected nodes in stable graph order (same selection
|
|
505
|
+
* state used by Ctrl+click and box-select styling via FlowNode.selected()).
|
|
506
|
+
*/
|
|
507
|
+
getSelectedNodes(): Array<FlowNode>;
|
|
508
|
+
/**
|
|
509
|
+
* Adjusts camera position and zoom so all nodes fit in view (~10% padding).
|
|
510
|
+
* Falls back to camera.reset() when there are no nodes.
|
|
511
|
+
*/
|
|
512
|
+
centerOnGraph(): void;
|
|
487
513
|
connectedInputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
488
514
|
connectedOutputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
489
515
|
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
490
516
|
addNode(node: FlowNode): void;
|
|
491
517
|
removeNode(node: FlowNode): void;
|
|
492
518
|
addNote(note: FlowNote): void;
|
|
519
|
+
removeNote(note: FlowNote): void;
|
|
520
|
+
removeAllNotes(): void;
|
|
521
|
+
getNotes(): Array<FlowNote>;
|
|
493
522
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
494
523
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
495
524
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
@@ -554,6 +583,7 @@ declare const Theme: {
|
|
|
554
583
|
BackgroundColor: string;
|
|
555
584
|
HighlightColor: string;
|
|
556
585
|
FontColor: string;
|
|
586
|
+
DisabledFontColor: string;
|
|
557
587
|
};
|
|
558
588
|
Note: {
|
|
559
589
|
FontColor: string;
|
|
@@ -798,4 +828,4 @@ declare class WidgetFactory {
|
|
|
798
828
|
}
|
|
799
829
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
800
830
|
|
|
801
|
-
export { ButtonWidget, ColorWidget, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, GlobalWidgetFactory, type GraphRenderer, ImageWidget, MessageType, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, NumberWidget, Publisher, type PublisherConfig, SliderWidget, StringWidget, TextWidget, Theme, ToggleWidget, type WidgetConfig };
|
|
831
|
+
export { ButtonWidget, ColorWidget, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, MessageType, NodeFlowGraph, type NodeIntersection, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, Publisher, type PublisherConfig, SliderWidget, StringWidget, TextWidget, Theme, ToggleWidget, type WidgetConfig };
|