@elicdavis/node-flow 0.1.14 → 0.1.15
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 +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +56 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -24
- package/dist/index.mjs.map +1 -1
- package/index.html +30 -0
- package/package.json +1 -1
- package/src/graph.ts +7 -0
- package/src/node.ts +26 -25
- package/dist/web/NodeFlow.js +0 -8
- package/dist/web/NodeFlow.js.map +0 -7
package/dist/index.mjs
CHANGED
|
@@ -3092,6 +3092,20 @@ var Camera = class {
|
|
|
3092
3092
|
out.x = this.position.x + graphPosition.x * this.zoom;
|
|
3093
3093
|
out.y = this.position.y + graphPosition.y * this.zoom;
|
|
3094
3094
|
}
|
|
3095
|
+
getOrientation() {
|
|
3096
|
+
return {
|
|
3097
|
+
position: {
|
|
3098
|
+
x: this.position.x,
|
|
3099
|
+
y: this.position.y
|
|
3100
|
+
},
|
|
3101
|
+
zoom: this.zoom
|
|
3102
|
+
};
|
|
3103
|
+
}
|
|
3104
|
+
setOrientation(orientation) {
|
|
3105
|
+
this.position.x = orientation.position.x;
|
|
3106
|
+
this.position.y = orientation.position.y;
|
|
3107
|
+
this.zoom = orientation.zoom;
|
|
3108
|
+
}
|
|
3095
3109
|
reset() {
|
|
3096
3110
|
this.zoom = 1;
|
|
3097
3111
|
this.position.x = 0;
|
|
@@ -4522,44 +4536,42 @@ var FlowNode = class {
|
|
|
4522
4536
|
// }
|
|
4523
4537
|
calculateBounds(ctx, camera) {
|
|
4524
4538
|
const tempMeasurement = Zero();
|
|
4525
|
-
const
|
|
4526
|
-
const scaledPadding = __privateGet(this, _padding2) * zoom;
|
|
4527
|
-
const doubleScaledPadding = scaledPadding * 2;
|
|
4528
|
-
const scaledElementSpacing = __privateGet(this, _elementSpacing) * zoom;
|
|
4539
|
+
const doublePadding = __privateGet(this, _padding2) * 2;
|
|
4529
4540
|
const screenSpacePosition = Zero();
|
|
4530
4541
|
camera.graphSpaceToScreenSpace(__privateGet(this, _position), screenSpacePosition);
|
|
4531
4542
|
const size = Zero();
|
|
4532
|
-
__privateGet(this, _title2).size(ctx,
|
|
4543
|
+
__privateGet(this, _title2).size(ctx, 1, size);
|
|
4533
4544
|
const subtitleSize = Zero();
|
|
4534
|
-
__privateGet(this, _subTitle).size(ctx,
|
|
4545
|
+
__privateGet(this, _subTitle).size(ctx, 1, subtitleSize);
|
|
4535
4546
|
size.x = Math.max(size.x, subtitleSize.x);
|
|
4536
4547
|
if (__privateGet(this, _infoText) !== "") {
|
|
4537
4548
|
size.x += size.y * 4;
|
|
4538
4549
|
}
|
|
4539
|
-
size.x +=
|
|
4540
|
-
size.y +=
|
|
4550
|
+
size.x += doublePadding;
|
|
4551
|
+
size.y += doublePadding + __privateGet(this, _elementSpacing) * __privateGet(this, _input).length;
|
|
4541
4552
|
for (let i = 0; i < __privateGet(this, _input).length; i++) {
|
|
4542
4553
|
const port = __privateGet(this, _input)[i];
|
|
4543
|
-
__privateGet(this, _portTextStyle).measure(ctx,
|
|
4554
|
+
__privateGet(this, _portTextStyle).measure(ctx, 1, port.getDisplayName(), tempMeasurement);
|
|
4544
4555
|
size.y += tempMeasurement.y;
|
|
4545
|
-
size.x = Math.max(size.x, tempMeasurement.x +
|
|
4556
|
+
size.x = Math.max(size.x, tempMeasurement.x + doublePadding);
|
|
4546
4557
|
}
|
|
4547
|
-
size.y +=
|
|
4558
|
+
size.y += __privateGet(this, _elementSpacing) * __privateGet(this, _output).length;
|
|
4548
4559
|
for (let i = 0; i < __privateGet(this, _output).length; i++) {
|
|
4549
4560
|
const port = __privateGet(this, _output)[i];
|
|
4550
|
-
__privateGet(this, _portTextStyle).measure(ctx,
|
|
4561
|
+
__privateGet(this, _portTextStyle).measure(ctx, 1, port.getDisplayName(), tempMeasurement);
|
|
4551
4562
|
size.y += tempMeasurement.y;
|
|
4552
|
-
size.x = Math.max(size.x, tempMeasurement.x +
|
|
4563
|
+
size.x = Math.max(size.x, tempMeasurement.x + doublePadding);
|
|
4553
4564
|
}
|
|
4554
|
-
size.y +=
|
|
4565
|
+
size.y += __privateGet(this, _elementSpacing) * __privateGet(this, _widgets).length;
|
|
4555
4566
|
for (let i = 0; i < __privateGet(this, _widgets).length; i++) {
|
|
4556
4567
|
const element = __privateGet(this, _widgets)[i];
|
|
4557
4568
|
const eleSize = element.Size();
|
|
4558
|
-
size.y += eleSize.y
|
|
4559
|
-
size.x = Math.max(size.x, eleSize.x
|
|
4569
|
+
size.y += eleSize.y;
|
|
4570
|
+
size.x = Math.max(size.x, eleSize.x + doublePadding);
|
|
4560
4571
|
}
|
|
4561
|
-
size.y +=
|
|
4562
|
-
size.x = Math.max(size.x, MINIMUM_NODE_WIDTH
|
|
4572
|
+
size.y += __privateGet(this, _elementSpacing);
|
|
4573
|
+
size.x = Math.max(size.x, MINIMUM_NODE_WIDTH);
|
|
4574
|
+
ScaleVector(size, camera.zoom);
|
|
4563
4575
|
return {
|
|
4564
4576
|
Position: screenSpacePosition,
|
|
4565
4577
|
Size: size
|
|
@@ -4791,27 +4803,29 @@ var FlowNode = class {
|
|
|
4791
4803
|
for (let i = 0; i < __privateGet(this, _input).length; i++) {
|
|
4792
4804
|
ctx.textAlign = "left" /* Left */;
|
|
4793
4805
|
const port = __privateGet(this, _input)[i];
|
|
4794
|
-
__privateGet(this, _portTextStyle).measure(ctx,
|
|
4806
|
+
__privateGet(this, _portTextStyle).measure(ctx, 1, port.getDisplayName(), tempMeasurement);
|
|
4807
|
+
const portHeight = tempMeasurement.y * camera.zoom;
|
|
4795
4808
|
const position = VectorPool.get();
|
|
4796
4809
|
position.x = nodeBounds.Position.x;
|
|
4797
|
-
position.y = startY +
|
|
4810
|
+
position.y = startY + portHeight / 2;
|
|
4798
4811
|
__privateGet(this, _portTextStyle).setupStyle(ctx, camera.zoom);
|
|
4799
4812
|
ctx.fillText(port.getDisplayName(), leftSide, position.y);
|
|
4800
4813
|
__privateGet(this, _inputPortPositions).Push(port.render(ctx, position, camera, mousePosition, postProcess));
|
|
4801
|
-
startY +=
|
|
4814
|
+
startY += portHeight + scaledElementSpacing;
|
|
4802
4815
|
}
|
|
4803
4816
|
const rightSide = nodeBounds.Position.x + nodeBounds.Size.x;
|
|
4804
4817
|
ctx.textAlign = "right" /* Right */;
|
|
4805
4818
|
for (let i = 0; i < __privateGet(this, _output).length; i++) {
|
|
4806
4819
|
const port = __privateGet(this, _output)[i];
|
|
4807
|
-
__privateGet(this, _portTextStyle).measure(ctx,
|
|
4820
|
+
__privateGet(this, _portTextStyle).measure(ctx, 1, port.getDisplayName(), tempMeasurement);
|
|
4821
|
+
const portHeight = tempMeasurement.y * camera.zoom;
|
|
4808
4822
|
const position = VectorPool.get();
|
|
4809
4823
|
position.x = rightSide;
|
|
4810
|
-
position.y = startY +
|
|
4824
|
+
position.y = startY + portHeight / 2;
|
|
4811
4825
|
__privateGet(this, _portTextStyle).setupStyle(ctx, camera.zoom);
|
|
4812
4826
|
ctx.fillText(port.getDisplayName(), rightSide - scaledPadding, position.y);
|
|
4813
4827
|
__privateGet(this, _outputPortPositions).Push(port.render(ctx, position, camera, mousePosition, postProcess));
|
|
4814
|
-
startY +=
|
|
4828
|
+
startY += portHeight + scaledElementSpacing;
|
|
4815
4829
|
}
|
|
4816
4830
|
for (let i = 0; i < __privateGet(this, _widgets).length; i++) {
|
|
4817
4831
|
const widget = __privateGet(this, _widgets)[i];
|
|
@@ -6640,6 +6654,24 @@ var NodeFlowGraph = class {
|
|
|
6640
6654
|
getSelectedNodes() {
|
|
6641
6655
|
return __privateGet(this, _mainNodeSubsystem).getSelectedNodes();
|
|
6642
6656
|
}
|
|
6657
|
+
/**
|
|
6658
|
+
* Returns a copy of the current camera orientation (screen-space pan + zoom).
|
|
6659
|
+
*/
|
|
6660
|
+
getCamera() {
|
|
6661
|
+
return __privateGet(this, _camera).getOrientation();
|
|
6662
|
+
}
|
|
6663
|
+
/**
|
|
6664
|
+
* Restores a previously saved camera orientation.
|
|
6665
|
+
*/
|
|
6666
|
+
setCamera(orientation) {
|
|
6667
|
+
__privateGet(this, _camera).setOrientation(orientation);
|
|
6668
|
+
}
|
|
6669
|
+
/**
|
|
6670
|
+
* Resets the camera to the default orientation (origin, zoom 1).
|
|
6671
|
+
*/
|
|
6672
|
+
resetCamera() {
|
|
6673
|
+
__privateGet(this, _camera).reset();
|
|
6674
|
+
}
|
|
6643
6675
|
/**
|
|
6644
6676
|
* Adjusts camera position and zoom so all nodes fit in view (~10% padding).
|
|
6645
6677
|
* Falls back to camera.reset() when there are no nodes.
|