@elicdavis/node-flow 0.1.10 → 0.1.12
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 +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -0
- package/dist/index.mjs.map +1 -1
- package/dist/web/NodeFlow.js +8 -0
- package/dist/web/NodeFlow.js.map +7 -0
- package/package.json +1 -1
- package/src/graph.ts +12 -0
- package/src/index.ts +14 -3
- package/src/node.ts +8 -0
- package/src/notes/subsystem.ts +17 -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
|
@@ -295,6 +295,7 @@ declare class FlowNode {
|
|
|
295
295
|
addInput(config: PortConfig): Port;
|
|
296
296
|
addOutput(config: PortConfig): Port;
|
|
297
297
|
addWidget(widget: Widget): void;
|
|
298
|
+
removeWidget(widget: Widget): void;
|
|
298
299
|
getWidget(index: number): Widget;
|
|
299
300
|
widgetCount(): number;
|
|
300
301
|
translate(delta: Vector2): void;
|
|
@@ -489,6 +490,9 @@ declare class NodeFlowGraph {
|
|
|
489
490
|
addNode(node: FlowNode): void;
|
|
490
491
|
removeNode(node: FlowNode): void;
|
|
491
492
|
addNote(note: FlowNote): void;
|
|
493
|
+
removeNote(note: FlowNote): void;
|
|
494
|
+
removeAllNotes(): void;
|
|
495
|
+
getNotes(): Array<FlowNote>;
|
|
492
496
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
493
497
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
494
498
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
@@ -634,6 +638,22 @@ declare class StringWidget {
|
|
|
634
638
|
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
635
639
|
}
|
|
636
640
|
|
|
641
|
+
interface TextWidgetConfig {
|
|
642
|
+
property?: string;
|
|
643
|
+
value?: string;
|
|
644
|
+
textBoxStyle?: TextStyleConfig;
|
|
645
|
+
callback?: (newString: string) => void;
|
|
646
|
+
}
|
|
647
|
+
declare class TextWidget {
|
|
648
|
+
#private;
|
|
649
|
+
constructor(node: FlowNode, config?: TextWidgetConfig);
|
|
650
|
+
Size(): Vector2;
|
|
651
|
+
Set(value: string): void;
|
|
652
|
+
ClickStart(): void;
|
|
653
|
+
ClickEnd(): void;
|
|
654
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
655
|
+
}
|
|
656
|
+
|
|
637
657
|
interface ButtonWidgetConfig {
|
|
638
658
|
text?: string;
|
|
639
659
|
callback?: () => void;
|
|
@@ -781,4 +801,4 @@ declare class WidgetFactory {
|
|
|
781
801
|
}
|
|
782
802
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
783
803
|
|
|
784
|
-
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, Theme, ToggleWidget, type WidgetConfig };
|
|
804
|
+
export { ButtonWidget, ColorWidget, 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
|
@@ -295,6 +295,7 @@ declare class FlowNode {
|
|
|
295
295
|
addInput(config: PortConfig): Port;
|
|
296
296
|
addOutput(config: PortConfig): Port;
|
|
297
297
|
addWidget(widget: Widget): void;
|
|
298
|
+
removeWidget(widget: Widget): void;
|
|
298
299
|
getWidget(index: number): Widget;
|
|
299
300
|
widgetCount(): number;
|
|
300
301
|
translate(delta: Vector2): void;
|
|
@@ -489,6 +490,9 @@ declare class NodeFlowGraph {
|
|
|
489
490
|
addNode(node: FlowNode): void;
|
|
490
491
|
removeNode(node: FlowNode): void;
|
|
491
492
|
addNote(note: FlowNote): void;
|
|
493
|
+
removeNote(note: FlowNote): void;
|
|
494
|
+
removeAllNotes(): void;
|
|
495
|
+
getNotes(): Array<FlowNote>;
|
|
492
496
|
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
493
497
|
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
494
498
|
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
@@ -634,6 +638,22 @@ declare class StringWidget {
|
|
|
634
638
|
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
635
639
|
}
|
|
636
640
|
|
|
641
|
+
interface TextWidgetConfig {
|
|
642
|
+
property?: string;
|
|
643
|
+
value?: string;
|
|
644
|
+
textBoxStyle?: TextStyleConfig;
|
|
645
|
+
callback?: (newString: string) => void;
|
|
646
|
+
}
|
|
647
|
+
declare class TextWidget {
|
|
648
|
+
#private;
|
|
649
|
+
constructor(node: FlowNode, config?: TextWidgetConfig);
|
|
650
|
+
Size(): Vector2;
|
|
651
|
+
Set(value: string): void;
|
|
652
|
+
ClickStart(): void;
|
|
653
|
+
ClickEnd(): void;
|
|
654
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
655
|
+
}
|
|
656
|
+
|
|
637
657
|
interface ButtonWidgetConfig {
|
|
638
658
|
text?: string;
|
|
639
659
|
callback?: () => void;
|
|
@@ -781,4 +801,4 @@ declare class WidgetFactory {
|
|
|
781
801
|
}
|
|
782
802
|
declare const GlobalWidgetFactory: WidgetFactory;
|
|
783
803
|
|
|
784
|
-
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, Theme, ToggleWidget, type WidgetConfig };
|
|
804
|
+
export { ButtonWidget, ColorWidget, 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.js
CHANGED
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
Publisher: () => Publisher,
|
|
50
50
|
SliderWidget: () => SliderWidget,
|
|
51
51
|
StringWidget: () => StringWidget,
|
|
52
|
+
TextWidget: () => TextWidget,
|
|
52
53
|
Theme: () => Theme,
|
|
53
54
|
ToggleWidget: () => ToggleWidget
|
|
54
55
|
});
|
|
@@ -4422,6 +4423,13 @@ var FlowNode = class {
|
|
|
4422
4423
|
addWidget(widget) {
|
|
4423
4424
|
__privateGet(this, _widgets).push(widget);
|
|
4424
4425
|
}
|
|
4426
|
+
removeWidget(widget) {
|
|
4427
|
+
const index = __privateGet(this, _widgets).indexOf(widget, 0);
|
|
4428
|
+
if (index === -1) {
|
|
4429
|
+
throw new Error("node does not contain widget");
|
|
4430
|
+
}
|
|
4431
|
+
__privateGet(this, _widgets).splice(index, 1);
|
|
4432
|
+
}
|
|
4425
4433
|
getWidget(index) {
|
|
4426
4434
|
return __privateGet(this, _widgets)[index];
|
|
4427
4435
|
}
|
|
@@ -5756,6 +5764,9 @@ var NoteSubsystem = class {
|
|
|
5756
5764
|
__privateGet(this, _onNoteAddedCallbacks)[i](note);
|
|
5757
5765
|
}
|
|
5758
5766
|
}
|
|
5767
|
+
getNotes() {
|
|
5768
|
+
return __privateGet(this, _notes);
|
|
5769
|
+
}
|
|
5759
5770
|
addNoteAddedListener(callback) {
|
|
5760
5771
|
if (callback === null || callback === void 0) {
|
|
5761
5772
|
return;
|
|
@@ -5879,6 +5890,17 @@ var NoteSubsystem = class {
|
|
|
5879
5890
|
console.error("no note found to remove");
|
|
5880
5891
|
}
|
|
5881
5892
|
}
|
|
5893
|
+
removeAllNotes() {
|
|
5894
|
+
const notes = __privateGet(this, _notes);
|
|
5895
|
+
__privateSet(this, _notes, []);
|
|
5896
|
+
__privateSet(this, _noteHovering, null);
|
|
5897
|
+
__privateSet(this, _noteSelected, null);
|
|
5898
|
+
for (let i = 0; i < notes.length; i++) {
|
|
5899
|
+
for (let j = 0; j < __privateGet(this, _onNoteRemovedCallbacks).length; j++) {
|
|
5900
|
+
__privateGet(this, _onNoteRemovedCallbacks)[j](notes[i]);
|
|
5901
|
+
}
|
|
5902
|
+
}
|
|
5903
|
+
}
|
|
5882
5904
|
render(ctx, camera, mousePosition) {
|
|
5883
5905
|
__privateSet(this, _noteHovering, null);
|
|
5884
5906
|
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
@@ -6473,6 +6495,15 @@ var NodeFlowGraph = class {
|
|
|
6473
6495
|
addNote(note) {
|
|
6474
6496
|
__privateGet(this, _mainNoteSubsystem).addNote(note);
|
|
6475
6497
|
}
|
|
6498
|
+
removeNote(note) {
|
|
6499
|
+
__privateGet(this, _mainNoteSubsystem).removeNote(note);
|
|
6500
|
+
}
|
|
6501
|
+
removeAllNotes() {
|
|
6502
|
+
__privateGet(this, _mainNoteSubsystem).removeAllNotes();
|
|
6503
|
+
}
|
|
6504
|
+
getNotes() {
|
|
6505
|
+
return __privateGet(this, _mainNoteSubsystem).getNotes();
|
|
6506
|
+
}
|
|
6476
6507
|
addOnNodeCreatedListener(callback) {
|
|
6477
6508
|
__privateGet(this, _mainNodeSubsystem).addOnNodeCreatedListener(callback);
|
|
6478
6509
|
}
|
|
@@ -6639,6 +6670,7 @@ renderQuickMenu_fn = function() {
|
|
|
6639
6670
|
Publisher,
|
|
6640
6671
|
SliderWidget,
|
|
6641
6672
|
StringWidget,
|
|
6673
|
+
TextWidget,
|
|
6642
6674
|
Theme,
|
|
6643
6675
|
ToggleWidget
|
|
6644
6676
|
});
|