@elicdavis/node-flow 0.2.3 → 0.2.4
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 +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +146 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -19
- package/dist/index.mjs.map +1 -1
- package/dist/web/NodeFlow.js +8 -0
- package/dist/web/NodeFlow.js.map +7 -0
- package/index.html +2 -1
- package/package.json +1 -1
- package/src/contextMenu.ts +3 -3
- package/src/graph.ts +39 -5
- package/src/index.ts +6 -6
- package/src/input.ts +16 -0
- package/src/markdown/syntaxParser.ts +2 -2
- package/src/node.ts +29 -0
- package/src/nodes/publisher.ts +6 -8
- package/src/nodes/subsystem.ts +43 -5
- package/src/port.ts +31 -0
- package/src/quickMenu.ts +11 -0
- package/src/theme.ts +3 -1
- package/test/markdown.test.ts +11 -0
- package/test/markdown_code_block.test.ts +21 -1
- package/test/mouse_leave.test.ts +70 -0
- package/test/node_hover.test.ts +69 -0
- package/test/node_menu_filter.test.ts +24 -0
- package/test/port.test.ts +49 -1
package/dist/index.mjs
CHANGED
|
@@ -55,7 +55,8 @@ var defaults = {
|
|
|
55
55
|
Idle: "#1c1c1c",
|
|
56
56
|
MouseOver: "#8e8e8e",
|
|
57
57
|
Grabbed: "white",
|
|
58
|
-
Selected: "#6e6e6e"
|
|
58
|
+
Selected: "#6e6e6e",
|
|
59
|
+
Highlighted: "#ffc95c"
|
|
59
60
|
},
|
|
60
61
|
Bevel: null,
|
|
61
62
|
Port: {
|
|
@@ -142,6 +143,7 @@ var defaults = {
|
|
|
142
143
|
H3: {
|
|
143
144
|
FontSize: 16
|
|
144
145
|
},
|
|
146
|
+
CodeFontFamily: null,
|
|
145
147
|
CodeBlock: {
|
|
146
148
|
BackgroundColor: "#0c2b35",
|
|
147
149
|
FontColor: "#afb9bb",
|
|
@@ -591,11 +593,11 @@ var ContextMenu = class _ContextMenu {
|
|
|
591
593
|
#tempBox = { Position: Zero(), Size: Zero() };
|
|
592
594
|
#openSubMenu;
|
|
593
595
|
#bounds = null;
|
|
594
|
-
|
|
596
|
+
contains(point) {
|
|
595
597
|
if (this.#bounds !== null && InBox(this.#bounds, point)) {
|
|
596
598
|
return true;
|
|
597
599
|
}
|
|
598
|
-
return this.#openSubMenu !== void 0 && this.#openSubMenu
|
|
600
|
+
return this.#openSubMenu !== void 0 && this.#openSubMenu.contains(point);
|
|
599
601
|
}
|
|
600
602
|
/**
|
|
601
603
|
* A submenu is anchored to its parent's left edge and told the parent's
|
|
@@ -638,7 +640,7 @@ var ContextMenu = class _ContextMenu {
|
|
|
638
640
|
Position: { x: position.x, y: position.y },
|
|
639
641
|
Size: { x: scaledEntryWidth, y: totalScaledHeight }
|
|
640
642
|
};
|
|
641
|
-
const pointer = mousePosition !== void 0 && this.#openSubMenu !== void 0 && this.#openSubMenu
|
|
643
|
+
const pointer = mousePosition !== void 0 && this.#openSubMenu !== void 0 && this.#openSubMenu.contains(mousePosition) ? void 0 : mousePosition;
|
|
642
644
|
this.#tempBox.Size.x = scaledEntryWidth;
|
|
643
645
|
this.#tempBox.Size.y = scaledEntryHeight;
|
|
644
646
|
CopyVector2(this.#tempBox.Position, position);
|
|
@@ -748,12 +750,14 @@ var MouseObserver = class {
|
|
|
748
750
|
#clickStop;
|
|
749
751
|
#contextMenu;
|
|
750
752
|
#zoomCallback;
|
|
753
|
+
#leaveCallback;
|
|
754
|
+
#inside = false;
|
|
751
755
|
#longPressTimer = null;
|
|
752
756
|
#longPressOrigin = Zero();
|
|
753
757
|
#longPressFired = false;
|
|
754
758
|
#pinchDist = 0;
|
|
755
759
|
#lastTouchAt = 0;
|
|
756
|
-
constructor(ele, dragCallback, moveCallback, clickStart, clickStop, contextMenu, fileDrop, zoomCallback) {
|
|
760
|
+
constructor(ele, dragCallback, moveCallback, clickStart, clickStop, contextMenu, fileDrop, zoomCallback, leaveCallback) {
|
|
757
761
|
this.#ele = ele;
|
|
758
762
|
this.#dragCallback = dragCallback;
|
|
759
763
|
this.#moveCallback = moveCallback;
|
|
@@ -761,6 +765,7 @@ var MouseObserver = class {
|
|
|
761
765
|
this.#clickStop = clickStop;
|
|
762
766
|
this.#contextMenu = contextMenu;
|
|
763
767
|
this.#zoomCallback = zoomCallback;
|
|
768
|
+
this.#leaveCallback = leaveCallback;
|
|
764
769
|
this.#clicked = false;
|
|
765
770
|
this.#lastTouch = Zero();
|
|
766
771
|
this.#lastMousePosition = Zero();
|
|
@@ -775,6 +780,12 @@ var MouseObserver = class {
|
|
|
775
780
|
document.addEventListener("touchend", redraws(this.#touchEnd.bind(this)), false);
|
|
776
781
|
document.addEventListener("touchcancel", redraws(this.#touchEnd.bind(this)), false);
|
|
777
782
|
ele.addEventListener("mousemove", redraws(this.#move.bind(this)), false);
|
|
783
|
+
ele.addEventListener("mouseleave", redraws(() => {
|
|
784
|
+
this.#inside = false;
|
|
785
|
+
if (!this.#clicked) {
|
|
786
|
+
this.#leaveCallback?.();
|
|
787
|
+
}
|
|
788
|
+
}), false);
|
|
778
789
|
ele.addEventListener("touchmove", redraws(this.#touchMove.bind(this)), { passive: false });
|
|
779
790
|
ele.addEventListener("wheel", redraws(this.#wheel.bind(this)), { passive: false });
|
|
780
791
|
ele.addEventListener("drop", redraws((ev) => {
|
|
@@ -844,6 +855,7 @@ var MouseObserver = class {
|
|
|
844
855
|
if (this.#fromTouch()) {
|
|
845
856
|
return;
|
|
846
857
|
}
|
|
858
|
+
this.#inside = true;
|
|
847
859
|
const pos = this.#mousePos(event);
|
|
848
860
|
if (this.#clicked) {
|
|
849
861
|
const delta = Zero();
|
|
@@ -857,6 +869,7 @@ var MouseObserver = class {
|
|
|
857
869
|
if (event.button !== 0 || this.#fromTouch()) {
|
|
858
870
|
return;
|
|
859
871
|
}
|
|
872
|
+
this.#inside = true;
|
|
860
873
|
this.#clicked = true;
|
|
861
874
|
this.#clickStart(this.#mousePos(event), event.ctrlKey || event.shiftKey);
|
|
862
875
|
}
|
|
@@ -864,8 +877,12 @@ var MouseObserver = class {
|
|
|
864
877
|
if (event.button !== 0 || this.#fromTouch()) {
|
|
865
878
|
return;
|
|
866
879
|
}
|
|
880
|
+
const wasClicked = this.#clicked;
|
|
867
881
|
this.#clicked = false;
|
|
868
882
|
this.#clickStop();
|
|
883
|
+
if (wasClicked && !this.#inside) {
|
|
884
|
+
this.#leaveCallback?.();
|
|
885
|
+
}
|
|
869
886
|
}
|
|
870
887
|
#touchStart(event) {
|
|
871
888
|
this.#lastTouchAt = Date.now();
|
|
@@ -1555,6 +1572,18 @@ function typeSetsCompatible(a, b) {
|
|
|
1555
1572
|
}
|
|
1556
1573
|
return a.some((type) => b.includes(type));
|
|
1557
1574
|
}
|
|
1575
|
+
function portsConnect(output, input, casts) {
|
|
1576
|
+
if (!output || !input) {
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1579
|
+
return typeSetsConnect(output.acceptedTypes(), input.acceptedTypes(), casts);
|
|
1580
|
+
}
|
|
1581
|
+
function typeSetsConnect(output, input, casts) {
|
|
1582
|
+
if (typeSetsCompatible(output, input)) {
|
|
1583
|
+
return true;
|
|
1584
|
+
}
|
|
1585
|
+
return (casts ?? []).some((cast) => output.includes(cast.from) && input.includes(cast.to));
|
|
1586
|
+
}
|
|
1558
1587
|
function portConfigTypes(config) {
|
|
1559
1588
|
if (config.anyType === true) {
|
|
1560
1589
|
return [];
|
|
@@ -1591,6 +1620,9 @@ function fallbackColor(type, s) {
|
|
|
1591
1620
|
HSV2RGB(hsv, color);
|
|
1592
1621
|
return RgbToHex(color);
|
|
1593
1622
|
}
|
|
1623
|
+
function portTypeColor(type) {
|
|
1624
|
+
return fallbackColor(type, 1);
|
|
1625
|
+
}
|
|
1594
1626
|
var Port = class {
|
|
1595
1627
|
#node;
|
|
1596
1628
|
#displayName;
|
|
@@ -3899,11 +3931,10 @@ function TimeExecution(name, callback) {
|
|
|
3899
3931
|
|
|
3900
3932
|
// src/nodes/publisher.ts
|
|
3901
3933
|
function offersMatchingPort(config, filter) {
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
return false;
|
|
3934
|
+
if (filter.needs === "INPUT" /* Input */) {
|
|
3935
|
+
return (config.inputs ?? []).some((port) => typeSetsConnect(filter.types, portConfigTypes(port), filter.casts));
|
|
3905
3936
|
}
|
|
3906
|
-
return
|
|
3937
|
+
return (config.outputs ?? []).some((port) => typeSetsConnect(portConfigTypes(port), filter.types, filter.casts));
|
|
3907
3938
|
}
|
|
3908
3939
|
var Publisher = class {
|
|
3909
3940
|
#name;
|
|
@@ -4084,11 +4115,14 @@ var NodeSubsystem2 = class {
|
|
|
4084
4115
|
#boxSelectStart_graphSpace;
|
|
4085
4116
|
#boxSelectEnd_graphSpace;
|
|
4086
4117
|
#boxSelectionNodes;
|
|
4118
|
+
#casts;
|
|
4087
4119
|
#lastCtx;
|
|
4088
4120
|
#lastMousePosition;
|
|
4089
4121
|
// LISTENERS ==============================================================
|
|
4090
4122
|
#nodeRemovedCallbacks;
|
|
4091
4123
|
#registeredNodeAddedCallbacks;
|
|
4124
|
+
#nodeHoverCallbacks = new Array();
|
|
4125
|
+
#hoveredNode = null;
|
|
4092
4126
|
// ========================================================================
|
|
4093
4127
|
constructor(postProcessPass, config) {
|
|
4094
4128
|
this.#postProcessPass = postProcessPass;
|
|
@@ -4110,6 +4144,13 @@ var NodeSubsystem2 = class {
|
|
|
4110
4144
|
this.#boxSelectEnd_graphSpace = Zero();
|
|
4111
4145
|
this.#boxSelectionNodes = new List();
|
|
4112
4146
|
this.#lastCtx = null;
|
|
4147
|
+
this.#casts = config?.casts ?? [];
|
|
4148
|
+
}
|
|
4149
|
+
setCasts(casts) {
|
|
4150
|
+
this.#casts = casts;
|
|
4151
|
+
}
|
|
4152
|
+
casts() {
|
|
4153
|
+
return this.#casts;
|
|
4113
4154
|
}
|
|
4114
4155
|
addPublisher(identifier, publisher) {
|
|
4115
4156
|
this.#nodeFactory.addPublisher(identifier, publisher);
|
|
@@ -4132,6 +4173,18 @@ var NodeSubsystem2 = class {
|
|
|
4132
4173
|
}
|
|
4133
4174
|
this.#nodeRemovedCallbacks.push(callback);
|
|
4134
4175
|
}
|
|
4176
|
+
addNodeHoverListener(callback) {
|
|
4177
|
+
this.#nodeHoverCallbacks.push(callback);
|
|
4178
|
+
}
|
|
4179
|
+
#setHoveredNode(node) {
|
|
4180
|
+
if (this.#hoveredNode === node) {
|
|
4181
|
+
return;
|
|
4182
|
+
}
|
|
4183
|
+
this.#hoveredNode = node;
|
|
4184
|
+
for (let i = 0; i < this.#nodeHoverCallbacks.length; i++) {
|
|
4185
|
+
this.#nodeHoverCallbacks[i](node);
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4135
4188
|
clickStart(mousePosition, camera, ctrlKey) {
|
|
4136
4189
|
this.#boxSelect = false;
|
|
4137
4190
|
this.#nodesGrabbed.Clear();
|
|
@@ -4351,7 +4404,8 @@ var NodeSubsystem2 = class {
|
|
|
4351
4404
|
let firstHidden = -1;
|
|
4352
4405
|
for (let i = 0; i < count; i++) {
|
|
4353
4406
|
const port = side === "INPUT" /* Input */ ? node.inputPort(i) : node.outputPort(i);
|
|
4354
|
-
|
|
4407
|
+
const compatible = side === "INPUT" /* Input */ ? portsConnect(against, port, this.#casts) : portsConnect(port, against, this.#casts);
|
|
4408
|
+
if (!compatible) {
|
|
4355
4409
|
continue;
|
|
4356
4410
|
}
|
|
4357
4411
|
if (!port.hidden()) {
|
|
@@ -4408,11 +4462,11 @@ var NodeSubsystem2 = class {
|
|
|
4408
4462
|
this.#clearCurrentlySelectedConnection();
|
|
4409
4463
|
return;
|
|
4410
4464
|
}
|
|
4411
|
-
if (this.#portHovering.InputPort && !
|
|
4465
|
+
if (this.#portHovering.InputPort && !portsConnect(conn.outPort(), this.#portHovering.Port, this.#casts)) {
|
|
4412
4466
|
this.#clearCurrentlySelectedConnection();
|
|
4413
4467
|
return;
|
|
4414
4468
|
}
|
|
4415
|
-
if (!this.#portHovering.InputPort && !
|
|
4469
|
+
if (!this.#portHovering.InputPort && !portsConnect(this.#portHovering.Port, conn.inPort(), this.#casts)) {
|
|
4416
4470
|
this.#clearCurrentlySelectedConnection();
|
|
4417
4471
|
return;
|
|
4418
4472
|
}
|
|
@@ -4435,7 +4489,7 @@ var NodeSubsystem2 = class {
|
|
|
4435
4489
|
connectNodes(nodeOut, outPort, nodeIn, inPort) {
|
|
4436
4490
|
const from = nodeOut.outputPort(outPort);
|
|
4437
4491
|
const to = nodeIn.inputPort(inPort);
|
|
4438
|
-
if (!
|
|
4492
|
+
if (!portsConnect(from, to, this.#casts)) {
|
|
4439
4493
|
console.error("can't connect nodes of different types", from.getDataType(), to.getDataType());
|
|
4440
4494
|
return;
|
|
4441
4495
|
}
|
|
@@ -4778,6 +4832,7 @@ var NodeSubsystem2 = class {
|
|
|
4778
4832
|
this.#widgetHovering = null;
|
|
4779
4833
|
this.#nodeHovering = -1;
|
|
4780
4834
|
this.#boxSelectionNodes.Clear();
|
|
4835
|
+
let hovered = null;
|
|
4781
4836
|
const selectedBox_Screenspace = this.#boxSelectionScreenspaceBox(camera);
|
|
4782
4837
|
const canvas = {
|
|
4783
4838
|
Position: { x: 0, y: 0 },
|
|
@@ -4791,6 +4846,9 @@ var NodeSubsystem2 = class {
|
|
|
4791
4846
|
}
|
|
4792
4847
|
if (mousePosition !== void 0 && !this.#boxSelect) {
|
|
4793
4848
|
const intersection = this.#nodes[i].inBounds(ctx, camera, mousePosition);
|
|
4849
|
+
if (intersection.Node !== void 0) {
|
|
4850
|
+
hovered = intersection.Node;
|
|
4851
|
+
}
|
|
4794
4852
|
if (intersection.Node !== void 0 && intersection.PortIndex === void 0 && intersection.Widget === void 0) {
|
|
4795
4853
|
state = 1 /* MouseOver */;
|
|
4796
4854
|
this.#nodeHovering = i;
|
|
@@ -4822,6 +4880,7 @@ var NodeSubsystem2 = class {
|
|
|
4822
4880
|
}
|
|
4823
4881
|
this.#nodes[i].render(ctx, camera, state, mousePosition, this.#postProcessPass);
|
|
4824
4882
|
}
|
|
4883
|
+
this.#setHoveredNode(hovered);
|
|
4825
4884
|
if (this.#widgetCurrentlyClicking !== null) {
|
|
4826
4885
|
this.#cursor = this.#widgetCurrentlyClicking.Cursor?.() ?? "pointer" /* Pointer */;
|
|
4827
4886
|
}
|
|
@@ -5127,6 +5186,7 @@ var FlowNode = class {
|
|
|
5127
5186
|
#elementSpacing;
|
|
5128
5187
|
// Runtime ================================================================
|
|
5129
5188
|
#selected;
|
|
5189
|
+
#highlighted = false;
|
|
5130
5190
|
#inputPortPositions;
|
|
5131
5191
|
#outputPortPositions;
|
|
5132
5192
|
#widgetPositions;
|
|
@@ -5230,6 +5290,16 @@ var FlowNode = class {
|
|
|
5230
5290
|
this.#onSelect[i]();
|
|
5231
5291
|
}
|
|
5232
5292
|
}
|
|
5293
|
+
highlighted() {
|
|
5294
|
+
return this.#highlighted;
|
|
5295
|
+
}
|
|
5296
|
+
setHighlighted(highlighted) {
|
|
5297
|
+
if (this.#highlighted === highlighted) {
|
|
5298
|
+
return;
|
|
5299
|
+
}
|
|
5300
|
+
this.#highlighted = highlighted;
|
|
5301
|
+
requestRender();
|
|
5302
|
+
}
|
|
5233
5303
|
raiseDragStoppedEvent() {
|
|
5234
5304
|
for (let i = 0; i < this.#onDragStop.length; i++) {
|
|
5235
5305
|
this.#onDragStop[i](this);
|
|
@@ -5927,6 +5997,22 @@ var FlowNode = class {
|
|
|
5927
5997
|
const nodeBounds = this.calculateBounds(ctx, camera);
|
|
5928
5998
|
const nodeStyle = this.#calculateStyle(state);
|
|
5929
5999
|
nodeStyle.Draw(ctx, nodeBounds, camera.zoom);
|
|
6000
|
+
if (this.#highlighted) {
|
|
6001
|
+
const gap = 3;
|
|
6002
|
+
ctx.save();
|
|
6003
|
+
ctx.strokeStyle = Theme.Node.Border.Highlighted;
|
|
6004
|
+
ctx.lineWidth = 2;
|
|
6005
|
+
ctx.beginPath();
|
|
6006
|
+
ctx.roundRect(
|
|
6007
|
+
nodeBounds.Position.x - gap,
|
|
6008
|
+
nodeBounds.Position.y - gap,
|
|
6009
|
+
nodeBounds.Size.x + gap * 2,
|
|
6010
|
+
nodeBounds.Size.y + gap * 2,
|
|
6011
|
+
nodeStyle.radius() * camera.zoom + gap
|
|
6012
|
+
);
|
|
6013
|
+
ctx.stroke();
|
|
6014
|
+
ctx.restore();
|
|
6015
|
+
}
|
|
5930
6016
|
const borderSize = nodeStyle.borderSize();
|
|
5931
6017
|
ctx.textAlign = "center" /* Center */;
|
|
5932
6018
|
ctx.textBaseline = "middle" /* Middle */;
|
|
@@ -6632,7 +6718,7 @@ var MarkdownSyntaxParser = class {
|
|
|
6632
6718
|
content += token.lexeme();
|
|
6633
6719
|
this.#inc();
|
|
6634
6720
|
}
|
|
6635
|
-
return [new Text(content, { font: "monospace" })];
|
|
6721
|
+
return [new Text(content, { font: Theme.Note.CodeFontFamily ?? "monospace" })];
|
|
6636
6722
|
}
|
|
6637
6723
|
#text() {
|
|
6638
6724
|
let contents = new Array();
|
|
@@ -6746,7 +6832,7 @@ var MarkdownSyntaxParser = class {
|
|
|
6746
6832
|
this.#inc();
|
|
6747
6833
|
this.#inc();
|
|
6748
6834
|
const codeBlockText = this.#originalText.substring(start, end).replace(/\r?\n$/, "");
|
|
6749
|
-
const entryText = new Text(codeBlockText);
|
|
6835
|
+
const entryText = new Text(codeBlockText, { font: Theme.Note.CodeFontFamily ?? void 0 });
|
|
6750
6836
|
this.#assignStandardStyling([entryText]);
|
|
6751
6837
|
entryText.setColor(Theme.Note.CodeBlock.FontColor);
|
|
6752
6838
|
return new CodeBlockEntry(entryText);
|
|
@@ -7508,8 +7594,16 @@ var QuickMenu = class {
|
|
|
7508
7594
|
pos.x = 0;
|
|
7509
7595
|
}
|
|
7510
7596
|
this.#container.render(ctx, pos, 1, this.renderSize);
|
|
7597
|
+
this.#bounds = {
|
|
7598
|
+
Position: { x: pos.x, y: pos.y },
|
|
7599
|
+
Size: { x: this.renderSize.x, y: this.renderSize.y }
|
|
7600
|
+
};
|
|
7511
7601
|
return null;
|
|
7512
7602
|
}
|
|
7603
|
+
#bounds = null;
|
|
7604
|
+
contains(point) {
|
|
7605
|
+
return this.#bounds !== null && InBox(this.#bounds, point);
|
|
7606
|
+
}
|
|
7513
7607
|
};
|
|
7514
7608
|
|
|
7515
7609
|
// src/minimap.ts
|
|
@@ -7720,6 +7814,7 @@ var NodeFlowGraph = class {
|
|
|
7720
7814
|
#backgroundRenderer;
|
|
7721
7815
|
#contextMenuConfig;
|
|
7722
7816
|
#mousePosition;
|
|
7817
|
+
#mouseOverCanvas = false;
|
|
7723
7818
|
#camera;
|
|
7724
7819
|
#openedContextMenu;
|
|
7725
7820
|
#openQuickMenu;
|
|
@@ -7732,7 +7827,8 @@ var NodeFlowGraph = class {
|
|
|
7732
7827
|
const postProcessPass = new PassSubsystem();
|
|
7733
7828
|
this.#mainNodeSubsystem = new NodeSubsystem2(postProcessPass, {
|
|
7734
7829
|
nodes: config?.nodes,
|
|
7735
|
-
idleConnection: config?.idleConnection
|
|
7830
|
+
idleConnection: config?.idleConnection,
|
|
7831
|
+
casts: config?.casts
|
|
7736
7832
|
});
|
|
7737
7833
|
this.#lastFrameCursor = "default" /* Default */;
|
|
7738
7834
|
this.#cursor = "default" /* Default */;
|
|
@@ -7781,6 +7877,7 @@ var NodeFlowGraph = class {
|
|
|
7781
7877
|
this.#mouseDragEvent.bind(this),
|
|
7782
7878
|
(mousePosition) => {
|
|
7783
7879
|
this.#mousePosition = mousePosition;
|
|
7880
|
+
this.#mouseOverCanvas = true;
|
|
7784
7881
|
},
|
|
7785
7882
|
this.#clickStart.bind(this),
|
|
7786
7883
|
this.#clickEnd.bind(this),
|
|
@@ -7788,6 +7885,9 @@ var NodeFlowGraph = class {
|
|
|
7788
7885
|
this.#fileDrop.bind(this),
|
|
7789
7886
|
(factor, anchor) => {
|
|
7790
7887
|
this.#zoomBy(factor, anchor);
|
|
7888
|
+
},
|
|
7889
|
+
() => {
|
|
7890
|
+
this.#mouseOverCanvas = false;
|
|
7791
7891
|
}
|
|
7792
7892
|
);
|
|
7793
7893
|
document.addEventListener(
|
|
@@ -7945,6 +8045,7 @@ var NodeFlowGraph = class {
|
|
|
7945
8045
|
this.#openQuickMenu = null;
|
|
7946
8046
|
this.#contextMenuEntryHovering = null;
|
|
7947
8047
|
this.#mousePosition = mousePosition;
|
|
8048
|
+
this.#mouseOverCanvas = true;
|
|
7948
8049
|
if (this.#minimap.contains(mousePosition)) {
|
|
7949
8050
|
this.#lookAtFromMinimap(mousePosition);
|
|
7950
8051
|
this.#draggingMinimap = true;
|
|
@@ -7973,6 +8074,9 @@ var NodeFlowGraph = class {
|
|
|
7973
8074
|
addPublisher(identifier, publisher) {
|
|
7974
8075
|
this.#mainNodeSubsystem.addPublisher(identifier, publisher);
|
|
7975
8076
|
}
|
|
8077
|
+
setCasts(casts) {
|
|
8078
|
+
this.#mainNodeSubsystem.setCasts(casts);
|
|
8079
|
+
}
|
|
7976
8080
|
getNodes() {
|
|
7977
8081
|
return this.#mainNodeSubsystem.getNodes();
|
|
7978
8082
|
}
|
|
@@ -8093,6 +8197,9 @@ var NodeFlowGraph = class {
|
|
|
8093
8197
|
addOnNodeRemovedListener(callback) {
|
|
8094
8198
|
this.#mainNodeSubsystem.addOnNodeRemovedListener(callback);
|
|
8095
8199
|
}
|
|
8200
|
+
addNodeHoverListener(callback) {
|
|
8201
|
+
this.#mainNodeSubsystem.addNodeHoverListener(callback);
|
|
8202
|
+
}
|
|
8096
8203
|
#sceenPositionToGraphPosition(screenPosition) {
|
|
8097
8204
|
const out = Zero();
|
|
8098
8205
|
this.#camera.screenSpaceToGraphSpace(screenPosition, out);
|
|
@@ -8118,6 +8225,7 @@ var NodeFlowGraph = class {
|
|
|
8118
8225
|
{
|
|
8119
8226
|
needs: dangling.needs,
|
|
8120
8227
|
types: dangling.types,
|
|
8228
|
+
casts: this.#mainNodeSubsystem.casts(),
|
|
8121
8229
|
onCreated: dangling.connectTo
|
|
8122
8230
|
}
|
|
8123
8231
|
);
|
|
@@ -8189,7 +8297,7 @@ var NodeFlowGraph = class {
|
|
|
8189
8297
|
TimeExecution("Render_Background", this.#renderBackground.bind(this));
|
|
8190
8298
|
TimeExecution("Render_View_" + this.#currentView, () => {
|
|
8191
8299
|
placeEditsDuring(this.#canvas, () => {
|
|
8192
|
-
let results = this.currentView().render(this.#ctx, this.#camera, this.#
|
|
8300
|
+
let results = this.currentView().render(this.#ctx, this.#camera, this.#pointerOnGraph());
|
|
8193
8301
|
if (results?.cursorStyle) {
|
|
8194
8302
|
this.#cursor = results?.cursorStyle;
|
|
8195
8303
|
}
|
|
@@ -8205,6 +8313,19 @@ var NodeFlowGraph = class {
|
|
|
8205
8313
|
}
|
|
8206
8314
|
this.#lastFrameCursor = this.#cursor;
|
|
8207
8315
|
}
|
|
8316
|
+
#pointer() {
|
|
8317
|
+
return this.#mouseOverCanvas ? this.#mousePosition : void 0;
|
|
8318
|
+
}
|
|
8319
|
+
#pointerOnGraph() {
|
|
8320
|
+
const pointer = this.#pointer();
|
|
8321
|
+
if (pointer === void 0) {
|
|
8322
|
+
return void 0;
|
|
8323
|
+
}
|
|
8324
|
+
if (this.#openedContextMenu?.Menu.contains(pointer) || this.#openQuickMenu?.Menu.contains(pointer)) {
|
|
8325
|
+
return void 0;
|
|
8326
|
+
}
|
|
8327
|
+
return pointer;
|
|
8328
|
+
}
|
|
8208
8329
|
#renderBackground() {
|
|
8209
8330
|
this.#backgroundRenderer(this.#canvas, this.#ctx, this.#camera.position, this.#camera.zoom);
|
|
8210
8331
|
}
|
|
@@ -8213,7 +8334,7 @@ var NodeFlowGraph = class {
|
|
|
8213
8334
|
if (this.#openedContextMenu !== null) {
|
|
8214
8335
|
const pos = VectorPool.get();
|
|
8215
8336
|
this.#camera.graphSpaceToScreenSpace(this.#openedContextMenu.Position, pos);
|
|
8216
|
-
this.#contextMenuEntryHovering = this.#openedContextMenu.Menu.render(this.#ctx, pos, this.#camera.zoom, this.#
|
|
8337
|
+
this.#contextMenuEntryHovering = this.#openedContextMenu.Menu.render(this.#ctx, pos, this.#camera.zoom, this.#pointer(), true);
|
|
8217
8338
|
if (this.#contextMenuEntryHovering !== null) {
|
|
8218
8339
|
this.#cursor = "pointer" /* Pointer */;
|
|
8219
8340
|
}
|
|
@@ -8225,7 +8346,7 @@ var NodeFlowGraph = class {
|
|
|
8225
8346
|
if (this.#openQuickMenu !== null) {
|
|
8226
8347
|
const pos = VectorPool.get();
|
|
8227
8348
|
this.#camera.graphSpaceToScreenSpace(this.#openQuickMenu.Position, pos);
|
|
8228
|
-
this.#contextMenuEntryHovering = this.#openQuickMenu.Menu.render(this.#ctx, pos, this.#camera.zoom, this.#
|
|
8349
|
+
this.#contextMenuEntryHovering = this.#openQuickMenu.Menu.render(this.#ctx, pos, this.#camera.zoom, this.#pointer());
|
|
8229
8350
|
if (this.#contextMenuEntryHovering !== null) {
|
|
8230
8351
|
this.#cursor = "pointer" /* Pointer */;
|
|
8231
8352
|
}
|
|
@@ -8272,12 +8393,15 @@ export {
|
|
|
8272
8393
|
formatNumber,
|
|
8273
8394
|
onThemeChange,
|
|
8274
8395
|
portConfigTypes,
|
|
8396
|
+
portTypeColor,
|
|
8275
8397
|
portsCompatible,
|
|
8398
|
+
portsConnect,
|
|
8276
8399
|
renderContinuously,
|
|
8277
8400
|
requestRender,
|
|
8278
8401
|
setTheme,
|
|
8279
8402
|
themeVersion,
|
|
8280
8403
|
typeSetsCompatible,
|
|
8404
|
+
typeSetsConnect,
|
|
8281
8405
|
widgetFont
|
|
8282
8406
|
};
|
|
8283
8407
|
//# sourceMappingURL=index.mjs.map
|