@elicdavis/node-flow 0.1.1 → 0.1.3
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 +19 -5
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +728 -674
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +728 -674
- package/dist/index.mjs.map +1 -1
- package/esbuild.ts +1 -1
- package/index.html +16 -12
- package/package.json +1 -1
- package/src/elements/base.ts +1 -0
- package/src/elements/text.ts +32 -4
- package/src/port.ts +54 -17
package/dist/index.mjs
CHANGED
|
@@ -749,6 +749,509 @@ up_fn = function(event) {
|
|
|
749
749
|
__privateGet(this, _clickStop).call(this);
|
|
750
750
|
};
|
|
751
751
|
|
|
752
|
+
// src/elements/interfaces.ts
|
|
753
|
+
function InstantiateRenderElementSidesStyling(config) {
|
|
754
|
+
if (typeof config === "number") {
|
|
755
|
+
return {
|
|
756
|
+
Bottom: config,
|
|
757
|
+
Right: config,
|
|
758
|
+
Top: config,
|
|
759
|
+
Left: config
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
return {
|
|
763
|
+
Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
|
|
764
|
+
Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
|
|
765
|
+
Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
|
|
766
|
+
Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/elements/base.ts
|
|
771
|
+
var _margin, _padding, _border, _backgroundColor, _minWidth, _maxWidth, _minHeight, _maxHeight, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
|
|
772
|
+
var RenderElementBase = class {
|
|
773
|
+
constructor(config) {
|
|
774
|
+
__privateAdd(this, _RenderElementBase_instances);
|
|
775
|
+
__privateAdd(this, _margin);
|
|
776
|
+
__privateAdd(this, _padding);
|
|
777
|
+
__privateAdd(this, _border);
|
|
778
|
+
__privateAdd(this, _backgroundColor);
|
|
779
|
+
__privateAdd(this, _minWidth);
|
|
780
|
+
__privateAdd(this, _maxWidth);
|
|
781
|
+
__privateAdd(this, _minHeight);
|
|
782
|
+
__privateAdd(this, _maxHeight);
|
|
783
|
+
__privateAdd(this, _grow);
|
|
784
|
+
__privateAdd(this, _display);
|
|
785
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
786
|
+
__privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
|
|
787
|
+
__privateSet(this, _padding, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
|
|
788
|
+
__privateSet(this, _backgroundColor, config == null ? void 0 : config.BackgroundColor);
|
|
789
|
+
__privateSet(this, _border, {
|
|
790
|
+
Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
|
|
791
|
+
Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
|
|
792
|
+
Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
|
|
793
|
+
});
|
|
794
|
+
__privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
|
|
795
|
+
__privateSet(this, _maxWidth, config == null ? void 0 : config.MaxWidth);
|
|
796
|
+
__privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
|
|
797
|
+
__privateSet(this, _maxHeight, config == null ? void 0 : config.MaxHeight);
|
|
798
|
+
__privateSet(this, _grow, config == null ? void 0 : config.Grow);
|
|
799
|
+
__privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
|
|
800
|
+
}
|
|
801
|
+
setBackgroundColor(newColor) {
|
|
802
|
+
__privateSet(this, _backgroundColor, newColor);
|
|
803
|
+
}
|
|
804
|
+
render(ctx, position, graphScale, scaledFillableSpace) {
|
|
805
|
+
if (__privateGet(this, _display) === "none" /* None */) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const scaledSize = { x: 0, y: 0 };
|
|
809
|
+
this.size(ctx, scaledSize);
|
|
810
|
+
scaledSize.x = scaledSize.x * graphScale;
|
|
811
|
+
scaledSize.y = scaledSize.y * graphScale;
|
|
812
|
+
scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
|
|
813
|
+
scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
|
|
814
|
+
if (__privateGet(this, _backgroundColor)) {
|
|
815
|
+
ctx.fillStyle = __privateGet(this, _backgroundColor);
|
|
816
|
+
ctx.beginPath();
|
|
817
|
+
ctx.roundRect(
|
|
818
|
+
position.x + __privateGet(this, _margin).Left * graphScale,
|
|
819
|
+
position.y + __privateGet(this, _margin).Right * graphScale,
|
|
820
|
+
scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
|
|
821
|
+
scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
|
|
822
|
+
__privateGet(this, _border).Radius * graphScale
|
|
823
|
+
);
|
|
824
|
+
ctx.fill();
|
|
825
|
+
}
|
|
826
|
+
if (__privateGet(this, _border).Thickness > 0) {
|
|
827
|
+
ctx.lineWidth = __privateGet(this, _border).Thickness * graphScale;
|
|
828
|
+
ctx.strokeStyle = __privateGet(this, _border).Color;
|
|
829
|
+
ctx.stroke();
|
|
830
|
+
}
|
|
831
|
+
const offsetPosition = {
|
|
832
|
+
x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
|
|
833
|
+
y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
|
|
834
|
+
};
|
|
835
|
+
const elementSize = {
|
|
836
|
+
x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
|
|
837
|
+
y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
|
|
838
|
+
};
|
|
839
|
+
this.doRender(ctx, offsetPosition, graphScale, elementSize);
|
|
840
|
+
}
|
|
841
|
+
maxLimitations(out) {
|
|
842
|
+
out.x = -1;
|
|
843
|
+
out.y = -1;
|
|
844
|
+
if (__privateGet(this, _maxWidth)) {
|
|
845
|
+
out.x = __privateGet(this, _maxWidth);
|
|
846
|
+
}
|
|
847
|
+
if (__privateGet(this, _maxHeight)) {
|
|
848
|
+
out.y = __privateGet(this, _maxHeight);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
setDisplay(display) {
|
|
852
|
+
__privateSet(this, _display, display);
|
|
853
|
+
}
|
|
854
|
+
getDisplay() {
|
|
855
|
+
return __privateGet(this, _display);
|
|
856
|
+
}
|
|
857
|
+
size(ctx, out) {
|
|
858
|
+
out.x = 0;
|
|
859
|
+
out.y = 0;
|
|
860
|
+
if (__privateGet(this, _display) === "none" /* None */) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const maxLimits = { x: -1, y: -1 };
|
|
864
|
+
this.maxLimitations(maxLimits);
|
|
865
|
+
this.calcSize(ctx, out, maxLimits);
|
|
866
|
+
out.x += __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this);
|
|
867
|
+
out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
|
|
868
|
+
if (__privateGet(this, _minWidth)) {
|
|
869
|
+
out.x = Math.max(out.x, __privateGet(this, _minWidth));
|
|
870
|
+
}
|
|
871
|
+
if (__privateGet(this, _maxWidth)) {
|
|
872
|
+
out.x = Math.min(__privateGet(this, _maxWidth), out.x);
|
|
873
|
+
}
|
|
874
|
+
if (__privateGet(this, _maxHeight)) {
|
|
875
|
+
out.y = Math.min(__privateGet(this, _maxHeight), out.y);
|
|
876
|
+
}
|
|
877
|
+
if (__privateGet(this, _minHeight)) {
|
|
878
|
+
out.y = Math.max(__privateGet(this, _minHeight), out.y);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
_margin = new WeakMap();
|
|
883
|
+
_padding = new WeakMap();
|
|
884
|
+
_border = new WeakMap();
|
|
885
|
+
_backgroundColor = new WeakMap();
|
|
886
|
+
_minWidth = new WeakMap();
|
|
887
|
+
_maxWidth = new WeakMap();
|
|
888
|
+
_minHeight = new WeakMap();
|
|
889
|
+
_maxHeight = new WeakMap();
|
|
890
|
+
_grow = new WeakMap();
|
|
891
|
+
_display = new WeakMap();
|
|
892
|
+
_RenderElementBase_instances = new WeakSet();
|
|
893
|
+
horizontalOffset_fn = function() {
|
|
894
|
+
return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding).Left + __privateGet(this, _padding).Right;
|
|
895
|
+
};
|
|
896
|
+
verticalOffset_fn = function() {
|
|
897
|
+
return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding).Top + __privateGet(this, _padding).Bottom;
|
|
898
|
+
};
|
|
899
|
+
totalTopOffset_fn = function() {
|
|
900
|
+
return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding).Top;
|
|
901
|
+
};
|
|
902
|
+
totalLeftOffset_fn = function() {
|
|
903
|
+
return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding).Left;
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/elements/container.ts
|
|
907
|
+
var _elements, _layout, _alignment, _ContainerRenderElement_instances, renderColumn_fn;
|
|
908
|
+
var ContainerRenderElement = class extends RenderElementBase {
|
|
909
|
+
constructor(elements, config) {
|
|
910
|
+
super(config);
|
|
911
|
+
__privateAdd(this, _ContainerRenderElement_instances);
|
|
912
|
+
__privateAdd(this, _elements);
|
|
913
|
+
__privateAdd(this, _layout);
|
|
914
|
+
__privateAdd(this, _alignment);
|
|
915
|
+
__privateSet(this, _elements, elements);
|
|
916
|
+
__privateSet(this, _layout, "column" /* Column */);
|
|
917
|
+
__privateSet(this, _alignment, "stretch" /* Stretch */);
|
|
918
|
+
}
|
|
919
|
+
calcSize(ctx, out, limitations) {
|
|
920
|
+
out.x = 0;
|
|
921
|
+
out.y = 0;
|
|
922
|
+
const eleSize = { x: 0, y: 0 };
|
|
923
|
+
switch (__privateGet(this, _layout)) {
|
|
924
|
+
case "column" /* Column */:
|
|
925
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
926
|
+
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
927
|
+
out.x = Math.max(out.x, eleSize.x);
|
|
928
|
+
out.y += eleSize.y;
|
|
929
|
+
}
|
|
930
|
+
break;
|
|
931
|
+
case "row" /* Row */:
|
|
932
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
933
|
+
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
934
|
+
out.y = Math.max(out.y, eleSize.y);
|
|
935
|
+
out.x += eleSize.x;
|
|
936
|
+
}
|
|
937
|
+
break;
|
|
938
|
+
default:
|
|
939
|
+
throw new Error("unknown layout: " + __privateGet(this, _layout));
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
doRender(ctx, position, graphScale, scaledFillableSpace) {
|
|
943
|
+
switch (__privateGet(this, _layout)) {
|
|
944
|
+
case "column" /* Column */:
|
|
945
|
+
__privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
|
|
946
|
+
break;
|
|
947
|
+
default:
|
|
948
|
+
throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
_elements = new WeakMap();
|
|
953
|
+
_layout = new WeakMap();
|
|
954
|
+
_alignment = new WeakMap();
|
|
955
|
+
_ContainerRenderElement_instances = new WeakSet();
|
|
956
|
+
renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
|
|
957
|
+
const currnetPos = { x: position.x, y: position.y };
|
|
958
|
+
const scaledEleSize = { x: 0, y: 0 };
|
|
959
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
960
|
+
const ele = __privateGet(this, _elements)[i];
|
|
961
|
+
ele.size(ctx, scaledEleSize);
|
|
962
|
+
ScaleVector(scaledEleSize, graphScale);
|
|
963
|
+
switch (__privateGet(this, _alignment)) {
|
|
964
|
+
case "stretch" /* Stretch */:
|
|
965
|
+
currnetPos.x = position.x;
|
|
966
|
+
scaledEleSize.x = scaledFillableSpace.x;
|
|
967
|
+
break;
|
|
968
|
+
// I'm not sure if this is even needed, I feel like this should
|
|
969
|
+
// already be the case.
|
|
970
|
+
case "start" /* Start */:
|
|
971
|
+
currnetPos.x = position.x;
|
|
972
|
+
break;
|
|
973
|
+
case "end" /* End */:
|
|
974
|
+
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
|
|
975
|
+
break;
|
|
976
|
+
case "center" /* Center */:
|
|
977
|
+
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
|
|
978
|
+
break;
|
|
979
|
+
default:
|
|
980
|
+
throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
|
|
981
|
+
}
|
|
982
|
+
ele.render(ctx, currnetPos, graphScale, scaledEleSize);
|
|
983
|
+
currnetPos.y += scaledEleSize.y;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
// src/elements/text.ts
|
|
988
|
+
var _text, _align, _verticalAlign, _lineHeight;
|
|
989
|
+
var TextElement = class extends RenderElementBase {
|
|
990
|
+
constructor(text, styling) {
|
|
991
|
+
var _a, _b, _c;
|
|
992
|
+
super(styling);
|
|
993
|
+
__privateAdd(this, _text);
|
|
994
|
+
__privateAdd(this, _align);
|
|
995
|
+
__privateAdd(this, _verticalAlign);
|
|
996
|
+
__privateAdd(this, _lineHeight);
|
|
997
|
+
__privateSet(this, _text, text);
|
|
998
|
+
__privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
|
|
999
|
+
__privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
|
|
1000
|
+
__privateSet(this, _lineHeight, (_c = styling == null ? void 0 : styling.LineHeight) != null ? _c : 1);
|
|
1001
|
+
}
|
|
1002
|
+
doRender(ctx, position, graphScale, scaledFillableSpace) {
|
|
1003
|
+
const scale = Zero();
|
|
1004
|
+
this.calcSize(ctx, scale, scaledFillableSpace);
|
|
1005
|
+
ScaleVector(scale, graphScale);
|
|
1006
|
+
const justifiedPosition = Zero();
|
|
1007
|
+
CopyVector2(justifiedPosition, position);
|
|
1008
|
+
ctx.textAlign = "left";
|
|
1009
|
+
ctx.textBaseline = "top";
|
|
1010
|
+
switch (__privateGet(this, _align)) {
|
|
1011
|
+
case "left" /* Left */:
|
|
1012
|
+
break;
|
|
1013
|
+
case "right" /* Right */:
|
|
1014
|
+
justifiedPosition.x += scaledFillableSpace.x - scale.x;
|
|
1015
|
+
break;
|
|
1016
|
+
case "center" /* Center */:
|
|
1017
|
+
justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
|
|
1018
|
+
break;
|
|
1019
|
+
default:
|
|
1020
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1021
|
+
}
|
|
1022
|
+
switch (__privateGet(this, _verticalAlign)) {
|
|
1023
|
+
case "top" /* Top */:
|
|
1024
|
+
break;
|
|
1025
|
+
case "bottom" /* Bottom */:
|
|
1026
|
+
justifiedPosition.y += scaledFillableSpace.y - scale.y;
|
|
1027
|
+
break;
|
|
1028
|
+
case "center" /* Center */:
|
|
1029
|
+
justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
|
|
1030
|
+
break;
|
|
1031
|
+
default:
|
|
1032
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1033
|
+
}
|
|
1034
|
+
if (scaledFillableSpace.x <= 0) {
|
|
1035
|
+
__privateGet(this, _text).render(ctx, graphScale, justifiedPosition);
|
|
1036
|
+
} else {
|
|
1037
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, scaledFillableSpace.x);
|
|
1038
|
+
const tempSize = { x: 0, y: 0 };
|
|
1039
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1040
|
+
eles[i].render(ctx, graphScale, justifiedPosition);
|
|
1041
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1042
|
+
justifiedPosition.y += __privateGet(this, _text).style().getSize() * __privateGet(this, _lineHeight);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
calcSize(ctx, out, limitations) {
|
|
1047
|
+
if (limitations.x <= 0) {
|
|
1048
|
+
__privateGet(this, _text).size(ctx, 1, out);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, limitations.x);
|
|
1052
|
+
const tempSize = { x: 0, y: 0 };
|
|
1053
|
+
out.x = 0;
|
|
1054
|
+
out.y = __privateGet(this, _text).style().getSize() * eles.length * __privateGet(this, _lineHeight);
|
|
1055
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1056
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1057
|
+
out.x = Math.max(tempSize.x, out.x);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
_text = new WeakMap();
|
|
1062
|
+
_align = new WeakMap();
|
|
1063
|
+
_verticalAlign = new WeakMap();
|
|
1064
|
+
_lineHeight = new WeakMap();
|
|
1065
|
+
|
|
1066
|
+
// src/utils/string.ts
|
|
1067
|
+
var binarySearch = ({ max, getValue, match }) => {
|
|
1068
|
+
let min = 0;
|
|
1069
|
+
while (min <= max) {
|
|
1070
|
+
let guess = Math.floor((min + max) / 2);
|
|
1071
|
+
const compareVal = getValue(guess);
|
|
1072
|
+
if (compareVal === match) return guess;
|
|
1073
|
+
if (compareVal < match) min = guess + 1;
|
|
1074
|
+
else max = guess - 1;
|
|
1075
|
+
}
|
|
1076
|
+
return max;
|
|
1077
|
+
};
|
|
1078
|
+
function fitString(ctx, str, maxWidth) {
|
|
1079
|
+
let width2 = ctx.measureText(str).width;
|
|
1080
|
+
const ellipsis = "\u2026";
|
|
1081
|
+
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
1082
|
+
if (width2 <= maxWidth || width2 <= ellipsisWidth) {
|
|
1083
|
+
return str;
|
|
1084
|
+
}
|
|
1085
|
+
const index = binarySearch({
|
|
1086
|
+
max: str.length,
|
|
1087
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1088
|
+
match: maxWidth - ellipsisWidth
|
|
1089
|
+
});
|
|
1090
|
+
return str.substring(0, index) + ellipsis;
|
|
1091
|
+
}
|
|
1092
|
+
function splitString(ctx, str, maxWidth) {
|
|
1093
|
+
let width2 = ctx.measureText(str).width;
|
|
1094
|
+
if (width2 <= maxWidth) {
|
|
1095
|
+
return [str];
|
|
1096
|
+
}
|
|
1097
|
+
let index = binarySearch({
|
|
1098
|
+
max: str.length,
|
|
1099
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1100
|
+
match: maxWidth
|
|
1101
|
+
});
|
|
1102
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1103
|
+
if (str.charAt(backward) === " ") {
|
|
1104
|
+
index = backward + 1;
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return [str.substring(0, index), str.substring(index)];
|
|
1109
|
+
}
|
|
1110
|
+
function splitStringIntoLines(ctx, str, maxWidth) {
|
|
1111
|
+
let width2 = ctx.measureText(str).width;
|
|
1112
|
+
if (width2 <= maxWidth) {
|
|
1113
|
+
return [str];
|
|
1114
|
+
}
|
|
1115
|
+
const strings = new Array();
|
|
1116
|
+
let remaining = str;
|
|
1117
|
+
while (remaining !== "") {
|
|
1118
|
+
let index = binarySearch({
|
|
1119
|
+
max: remaining.length,
|
|
1120
|
+
getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
1121
|
+
match: maxWidth
|
|
1122
|
+
});
|
|
1123
|
+
if (index === remaining.length) {
|
|
1124
|
+
strings.push(remaining.substring(0, index));
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1128
|
+
if (remaining.charAt(backward) === " ") {
|
|
1129
|
+
index = backward + 1;
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
strings.push(remaining.substring(0, index));
|
|
1134
|
+
remaining = remaining.substring(index);
|
|
1135
|
+
}
|
|
1136
|
+
return strings;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// src/types/text.ts
|
|
1140
|
+
var _measured, _size2, _style, _value, _Text_instances, measure_fn;
|
|
1141
|
+
var _Text = class _Text {
|
|
1142
|
+
constructor(value, style) {
|
|
1143
|
+
__privateAdd(this, _Text_instances);
|
|
1144
|
+
__privateAdd(this, _measured);
|
|
1145
|
+
__privateAdd(this, _size2);
|
|
1146
|
+
__privateAdd(this, _style);
|
|
1147
|
+
__privateAdd(this, _value);
|
|
1148
|
+
__privateSet(this, _value, value);
|
|
1149
|
+
__privateSet(this, _measured, false);
|
|
1150
|
+
__privateSet(this, _size2, Zero());
|
|
1151
|
+
__privateSet(this, _style, new TextStyle(style));
|
|
1152
|
+
if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
|
|
1153
|
+
document.fonts.addEventListener("loadingdone", (event) => {
|
|
1154
|
+
__privateSet(this, _measured, false);
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
set(newValue) {
|
|
1159
|
+
__privateSet(this, _value, newValue);
|
|
1160
|
+
__privateSet(this, _measured, false);
|
|
1161
|
+
}
|
|
1162
|
+
get() {
|
|
1163
|
+
return __privateGet(this, _value);
|
|
1164
|
+
}
|
|
1165
|
+
breakIntoLines(ctx, maxWidth) {
|
|
1166
|
+
const results = new Array();
|
|
1167
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1168
|
+
const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
|
|
1169
|
+
if (entries.length === 1) {
|
|
1170
|
+
return [this];
|
|
1171
|
+
}
|
|
1172
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1173
|
+
const text = new _Text(entries[i]);
|
|
1174
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1175
|
+
results.push(text);
|
|
1176
|
+
}
|
|
1177
|
+
return results;
|
|
1178
|
+
}
|
|
1179
|
+
split(char) {
|
|
1180
|
+
const entries = __privateGet(this, _value).split(char);
|
|
1181
|
+
const results = new Array();
|
|
1182
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1183
|
+
const text = new _Text(entries[i]);
|
|
1184
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1185
|
+
results.push(text);
|
|
1186
|
+
}
|
|
1187
|
+
return results;
|
|
1188
|
+
}
|
|
1189
|
+
splitAtIndex(index) {
|
|
1190
|
+
const results = [
|
|
1191
|
+
new _Text(__privateGet(this, _value).substring(0, index)),
|
|
1192
|
+
new _Text(__privateGet(this, _value).substring(index, 0))
|
|
1193
|
+
];
|
|
1194
|
+
for (let i = 0; i < results.length; i++) {
|
|
1195
|
+
__privateSet(results[i], _style, __privateGet(this, _style));
|
|
1196
|
+
}
|
|
1197
|
+
return results;
|
|
1198
|
+
}
|
|
1199
|
+
splitAtWidth(ctx, maxWidth) {
|
|
1200
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1201
|
+
const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
|
|
1202
|
+
if (entries.length === 1) {
|
|
1203
|
+
return [this];
|
|
1204
|
+
}
|
|
1205
|
+
const results = new Array();
|
|
1206
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1207
|
+
const text = new _Text(entries[i]);
|
|
1208
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1209
|
+
results.push(text);
|
|
1210
|
+
}
|
|
1211
|
+
return results;
|
|
1212
|
+
}
|
|
1213
|
+
size(ctx, scale, out) {
|
|
1214
|
+
__privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
|
|
1215
|
+
CopyVector2(out, __privateGet(this, _size2));
|
|
1216
|
+
ScaleVector(out, scale);
|
|
1217
|
+
}
|
|
1218
|
+
setColor(color) {
|
|
1219
|
+
__privateGet(this, _style).setColor(color);
|
|
1220
|
+
}
|
|
1221
|
+
getColor() {
|
|
1222
|
+
return __privateGet(this, _style).getColor();
|
|
1223
|
+
}
|
|
1224
|
+
setSize(size) {
|
|
1225
|
+
__privateGet(this, _style).setSize(size);
|
|
1226
|
+
}
|
|
1227
|
+
setWeight(weight) {
|
|
1228
|
+
__privateGet(this, _style).setWeight(weight);
|
|
1229
|
+
}
|
|
1230
|
+
render(ctx, scale, position) {
|
|
1231
|
+
__privateGet(this, _style).setupStyle(ctx, scale);
|
|
1232
|
+
ctx.fillText(__privateGet(this, _value), position.x, position.y);
|
|
1233
|
+
}
|
|
1234
|
+
style() {
|
|
1235
|
+
return __privateGet(this, _style);
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
_measured = new WeakMap();
|
|
1239
|
+
_size2 = new WeakMap();
|
|
1240
|
+
_style = new WeakMap();
|
|
1241
|
+
_value = new WeakMap();
|
|
1242
|
+
_Text_instances = new WeakSet();
|
|
1243
|
+
measure_fn = function(ctx) {
|
|
1244
|
+
if (__privateGet(this, _measured)) {
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1248
|
+
const measurements = ctx.measureText(__privateGet(this, _value));
|
|
1249
|
+
__privateGet(this, _size2).x = measurements.width;
|
|
1250
|
+
__privateGet(this, _size2).y = measurements.actualBoundingBoxAscent + measurements.actualBoundingBoxDescent;
|
|
1251
|
+
__privateSet(this, _measured, true);
|
|
1252
|
+
};
|
|
1253
|
+
var Text = _Text;
|
|
1254
|
+
|
|
752
1255
|
// src/utils/math.ts
|
|
753
1256
|
function Clamp(v, min, max) {
|
|
754
1257
|
return Math.min(Math.max(v, min), max);
|
|
@@ -841,7 +1344,7 @@ function fallbackColor(type, s) {
|
|
|
841
1344
|
HSV2RGB(hsv, color);
|
|
842
1345
|
return RgbToHex(color);
|
|
843
1346
|
}
|
|
844
|
-
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
1347
|
+
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _dataTypePopupElement, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
845
1348
|
var Port = class {
|
|
846
1349
|
constructor(node, portType, config) {
|
|
847
1350
|
__privateAdd(this, _node);
|
|
@@ -851,6 +1354,7 @@ var Port = class {
|
|
|
851
1354
|
__privateAdd(this, _connections);
|
|
852
1355
|
__privateAdd(this, _portType);
|
|
853
1356
|
__privateAdd(this, _dataType);
|
|
1357
|
+
__privateAdd(this, _dataTypePopupElement);
|
|
854
1358
|
__privateAdd(this, _onConnectionAdded);
|
|
855
1359
|
__privateAdd(this, _onConnectionRemoved);
|
|
856
1360
|
__privateAdd(this, _box, { Position: { x: 0, y: 0 }, Size: { x: 0, y: 0 } });
|
|
@@ -880,6 +1384,41 @@ var Port = class {
|
|
|
880
1384
|
if (config == null ? void 0 : config.onConnectionRemoved) {
|
|
881
1385
|
__privateGet(this, _onConnectionRemoved).push(config == null ? void 0 : config.onConnectionRemoved);
|
|
882
1386
|
}
|
|
1387
|
+
const containerElements = new Array();
|
|
1388
|
+
let dataTypeDisplay = __privateGet(this, _dataType);
|
|
1389
|
+
if ((config == null ? void 0 : config.array) === true) {
|
|
1390
|
+
dataTypeDisplay = "Array<" + dataTypeDisplay + ">";
|
|
1391
|
+
}
|
|
1392
|
+
containerElements.push(new TextElement(
|
|
1393
|
+
new Text(dataTypeDisplay, {
|
|
1394
|
+
color: "white"
|
|
1395
|
+
}),
|
|
1396
|
+
{
|
|
1397
|
+
Align: "center" /* Center */
|
|
1398
|
+
}
|
|
1399
|
+
));
|
|
1400
|
+
const description = config == null ? void 0 : config.description;
|
|
1401
|
+
if (description && description !== "") {
|
|
1402
|
+
containerElements.push(new TextElement(
|
|
1403
|
+
new Text(description, { color: "white", style: "italic" /* Italic */ }),
|
|
1404
|
+
{
|
|
1405
|
+
Align: "center" /* Center */,
|
|
1406
|
+
Padding: { Top: 16 },
|
|
1407
|
+
MaxWidth: 400,
|
|
1408
|
+
LineHeight: 1.5
|
|
1409
|
+
}
|
|
1410
|
+
));
|
|
1411
|
+
}
|
|
1412
|
+
__privateSet(this, _dataTypePopupElement, new ContainerRenderElement(
|
|
1413
|
+
containerElements,
|
|
1414
|
+
{
|
|
1415
|
+
BackgroundColor: "rgba(0, 0, 0, 0.75)",
|
|
1416
|
+
Border: {
|
|
1417
|
+
Radius: 6
|
|
1418
|
+
},
|
|
1419
|
+
Padding: 13
|
|
1420
|
+
}
|
|
1421
|
+
));
|
|
883
1422
|
}
|
|
884
1423
|
addConnection(connection) {
|
|
885
1424
|
const c = __privateGet(this, _connections).length;
|
|
@@ -948,16 +1487,9 @@ var Port = class {
|
|
|
948
1487
|
const xPos = position.x;
|
|
949
1488
|
const yPos = position.y;
|
|
950
1489
|
postProcess.queue(() => {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
const w = measurement.width + padding * camera.zoom;
|
|
955
|
-
ctx.beginPath();
|
|
956
|
-
ctx.fillStyle = "rgba(0, 0, 0, 0.75)";
|
|
957
|
-
ctx.roundRect(xPos - w / 2, yPos + scaledRadius * 3 - padding * camera.zoom, w, padding * 2 * camera.zoom, 4 * camera.zoom);
|
|
958
|
-
ctx.fill();
|
|
959
|
-
ctx.fillStyle = "#FFFFFF";
|
|
960
|
-
ctx.fillText(__privateGet(this, _dataType), xPos, yPos + scaledRadius * 3);
|
|
1490
|
+
const size = { x: 0, y: 0 };
|
|
1491
|
+
__privateGet(this, _dataTypePopupElement).calcSize(ctx, size, { x: -1, y: -1 });
|
|
1492
|
+
__privateGet(this, _dataTypePopupElement).render(ctx, { x: xPos - size.x / 2, y: yPos }, 1, size);
|
|
961
1493
|
});
|
|
962
1494
|
}
|
|
963
1495
|
__privateGet(this, _box).Position.x = position.x - scaledRadius;
|
|
@@ -984,6 +1516,7 @@ _filledStyle = new WeakMap();
|
|
|
984
1516
|
_connections = new WeakMap();
|
|
985
1517
|
_portType = new WeakMap();
|
|
986
1518
|
_dataType = new WeakMap();
|
|
1519
|
+
_dataTypePopupElement = new WeakMap();
|
|
987
1520
|
_onConnectionAdded = new WeakMap();
|
|
988
1521
|
_onConnectionRemoved = new WeakMap();
|
|
989
1522
|
_box = new WeakMap();
|
|
@@ -995,29 +1528,29 @@ function StrokeStyleWithFallback(input, fallback) {
|
|
|
995
1528
|
size: (input == null ? void 0 : input.size) === void 0 ? fallback == null ? void 0 : fallback.size : input == null ? void 0 : input.size
|
|
996
1529
|
};
|
|
997
1530
|
}
|
|
998
|
-
var
|
|
1531
|
+
var _size3, _color2;
|
|
999
1532
|
var StrokeStyle = class {
|
|
1000
1533
|
constructor(config) {
|
|
1001
|
-
__privateAdd(this,
|
|
1534
|
+
__privateAdd(this, _size3);
|
|
1002
1535
|
__privateAdd(this, _color2);
|
|
1003
|
-
__privateSet(this,
|
|
1536
|
+
__privateSet(this, _size3, (config == null ? void 0 : config.size) === void 0 ? 0.5 : config.size);
|
|
1004
1537
|
__privateSet(this, _color2, (config == null ? void 0 : config.color) === void 0 ? "black" : config.color);
|
|
1005
1538
|
}
|
|
1006
1539
|
setupStyle(ctx, scale) {
|
|
1007
1540
|
ctx.strokeStyle = __privateGet(this, _color2);
|
|
1008
|
-
ctx.lineWidth = scale * __privateGet(this,
|
|
1541
|
+
ctx.lineWidth = scale * __privateGet(this, _size3);
|
|
1009
1542
|
}
|
|
1010
1543
|
setColor(newColor) {
|
|
1011
1544
|
__privateSet(this, _color2, newColor);
|
|
1012
1545
|
}
|
|
1013
1546
|
setSize(newSize) {
|
|
1014
|
-
__privateSet(this,
|
|
1547
|
+
__privateSet(this, _size3, newSize);
|
|
1015
1548
|
}
|
|
1016
1549
|
size() {
|
|
1017
|
-
return __privateGet(this,
|
|
1550
|
+
return __privateGet(this, _size3);
|
|
1018
1551
|
}
|
|
1019
1552
|
};
|
|
1020
|
-
|
|
1553
|
+
_size3 = new WeakMap();
|
|
1021
1554
|
_color2 = new WeakMap();
|
|
1022
1555
|
|
|
1023
1556
|
// src/styles/box.ts
|
|
@@ -1028,20 +1561,20 @@ function BoxStyleWithFallback(input, fallback) {
|
|
|
1028
1561
|
border: StrokeStyleWithFallback(input == null ? void 0 : input.border, fallback == null ? void 0 : fallback.border)
|
|
1029
1562
|
};
|
|
1030
1563
|
}
|
|
1031
|
-
var
|
|
1564
|
+
var _border2, _color3, _radius, _BoxStyle_instances, box_fn, draw_fn;
|
|
1032
1565
|
var BoxStyle = class {
|
|
1033
1566
|
constructor(config) {
|
|
1034
1567
|
__privateAdd(this, _BoxStyle_instances);
|
|
1035
|
-
__privateAdd(this,
|
|
1568
|
+
__privateAdd(this, _border2);
|
|
1036
1569
|
__privateAdd(this, _color3);
|
|
1037
1570
|
__privateAdd(this, _radius);
|
|
1038
1571
|
__privateSet(this, _color3, (config == null ? void 0 : config.color) === void 0 ? "#CCCCCC" : config.color);
|
|
1039
|
-
__privateSet(this,
|
|
1572
|
+
__privateSet(this, _border2, (config == null ? void 0 : config.border) === void 0 ? null : new StrokeStyle(config.border));
|
|
1040
1573
|
__privateSet(this, _radius, (config == null ? void 0 : config.radius) === void 0 ? 2 : config.radius);
|
|
1041
1574
|
}
|
|
1042
1575
|
Outline(ctx, box, scale, radius) {
|
|
1043
1576
|
var _a;
|
|
1044
|
-
(_a = __privateGet(this,
|
|
1577
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1045
1578
|
ctx.beginPath();
|
|
1046
1579
|
ctx.roundRect(
|
|
1047
1580
|
box.Position.x,
|
|
@@ -1066,238 +1599,49 @@ var BoxStyle = class {
|
|
|
1066
1599
|
ctx.stroke();
|
|
1067
1600
|
}
|
|
1068
1601
|
borderSize() {
|
|
1069
|
-
if (__privateGet(this,
|
|
1602
|
+
if (__privateGet(this, _border2) === null) {
|
|
1070
1603
|
return 0;
|
|
1071
1604
|
}
|
|
1072
|
-
return __privateGet(this,
|
|
1605
|
+
return __privateGet(this, _border2).size();
|
|
1073
1606
|
}
|
|
1074
1607
|
radius() {
|
|
1075
1608
|
return __privateGet(this, _radius);
|
|
1076
1609
|
}
|
|
1077
1610
|
setColor(color) {
|
|
1078
|
-
__privateSet(this, _color3, color);
|
|
1079
|
-
}
|
|
1080
|
-
setBorderColor(color) {
|
|
1081
|
-
if (__privateGet(this, _border) === null) {
|
|
1082
|
-
__privateSet(this, _border, new StrokeStyle({
|
|
1083
|
-
color
|
|
1084
|
-
}));
|
|
1085
|
-
} else {
|
|
1086
|
-
__privateGet(this, _border).setColor(color);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
};
|
|
1090
|
-
_border = new WeakMap();
|
|
1091
|
-
_color3 = new WeakMap();
|
|
1092
|
-
_radius = new WeakMap();
|
|
1093
|
-
_BoxStyle_instances = new WeakSet();
|
|
1094
|
-
box_fn = function(ctx, box, scale, radius) {
|
|
1095
|
-
var _a;
|
|
1096
|
-
ctx.fillStyle = __privateGet(this, _color3);
|
|
1097
|
-
(_a = __privateGet(this, _border)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1098
|
-
ctx.beginPath();
|
|
1099
|
-
ctx.roundRect(
|
|
1100
|
-
box.Position.x,
|
|
1101
|
-
box.Position.y,
|
|
1102
|
-
box.Size.x,
|
|
1103
|
-
box.Size.y,
|
|
1104
|
-
radius
|
|
1105
|
-
);
|
|
1106
|
-
ctx.fill();
|
|
1107
|
-
};
|
|
1108
|
-
draw_fn = function(ctx, box, scale, radius) {
|
|
1109
|
-
__privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
|
|
1110
|
-
ctx.stroke();
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
// src/utils/string.ts
|
|
1114
|
-
var binarySearch = ({ max, getValue, match }) => {
|
|
1115
|
-
let min = 0;
|
|
1116
|
-
while (min <= max) {
|
|
1117
|
-
let guess = Math.floor((min + max) / 2);
|
|
1118
|
-
const compareVal = getValue(guess);
|
|
1119
|
-
if (compareVal === match) return guess;
|
|
1120
|
-
if (compareVal < match) min = guess + 1;
|
|
1121
|
-
else max = guess - 1;
|
|
1122
|
-
}
|
|
1123
|
-
return max;
|
|
1124
|
-
};
|
|
1125
|
-
function fitString(ctx, str, maxWidth) {
|
|
1126
|
-
let width2 = ctx.measureText(str).width;
|
|
1127
|
-
const ellipsis = "\u2026";
|
|
1128
|
-
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
1129
|
-
if (width2 <= maxWidth || width2 <= ellipsisWidth) {
|
|
1130
|
-
return str;
|
|
1131
|
-
}
|
|
1132
|
-
const index = binarySearch({
|
|
1133
|
-
max: str.length,
|
|
1134
|
-
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1135
|
-
match: maxWidth - ellipsisWidth
|
|
1136
|
-
});
|
|
1137
|
-
return str.substring(0, index) + ellipsis;
|
|
1138
|
-
}
|
|
1139
|
-
function splitString(ctx, str, maxWidth) {
|
|
1140
|
-
let width2 = ctx.measureText(str).width;
|
|
1141
|
-
if (width2 <= maxWidth) {
|
|
1142
|
-
return [str];
|
|
1143
|
-
}
|
|
1144
|
-
let index = binarySearch({
|
|
1145
|
-
max: str.length,
|
|
1146
|
-
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1147
|
-
match: maxWidth
|
|
1148
|
-
});
|
|
1149
|
-
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1150
|
-
if (str.charAt(backward) === " ") {
|
|
1151
|
-
index = backward + 1;
|
|
1152
|
-
break;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
return [str.substring(0, index), str.substring(index)];
|
|
1156
|
-
}
|
|
1157
|
-
function splitStringIntoLines(ctx, str, maxWidth) {
|
|
1158
|
-
let width2 = ctx.measureText(str).width;
|
|
1159
|
-
if (width2 <= maxWidth) {
|
|
1160
|
-
return [str];
|
|
1161
|
-
}
|
|
1162
|
-
const strings = new Array();
|
|
1163
|
-
let remaining = str;
|
|
1164
|
-
while (remaining !== "") {
|
|
1165
|
-
let index = binarySearch({
|
|
1166
|
-
max: remaining.length,
|
|
1167
|
-
getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
1168
|
-
match: maxWidth
|
|
1169
|
-
});
|
|
1170
|
-
if (index === remaining.length) {
|
|
1171
|
-
strings.push(remaining.substring(0, index));
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1175
|
-
if (remaining.charAt(backward) === " ") {
|
|
1176
|
-
index = backward + 1;
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
strings.push(remaining.substring(0, index));
|
|
1181
|
-
remaining = remaining.substring(index);
|
|
1182
|
-
}
|
|
1183
|
-
return strings;
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
// src/types/text.ts
|
|
1187
|
-
var _measured, _size3, _style, _value, _Text_instances, measure_fn;
|
|
1188
|
-
var _Text = class _Text {
|
|
1189
|
-
constructor(value, style) {
|
|
1190
|
-
__privateAdd(this, _Text_instances);
|
|
1191
|
-
__privateAdd(this, _measured);
|
|
1192
|
-
__privateAdd(this, _size3);
|
|
1193
|
-
__privateAdd(this, _style);
|
|
1194
|
-
__privateAdd(this, _value);
|
|
1195
|
-
__privateSet(this, _value, value);
|
|
1196
|
-
__privateSet(this, _measured, false);
|
|
1197
|
-
__privateSet(this, _size3, Zero());
|
|
1198
|
-
__privateSet(this, _style, new TextStyle(style));
|
|
1199
|
-
if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
|
|
1200
|
-
document.fonts.addEventListener("loadingdone", (event) => {
|
|
1201
|
-
__privateSet(this, _measured, false);
|
|
1202
|
-
});
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
set(newValue) {
|
|
1206
|
-
__privateSet(this, _value, newValue);
|
|
1207
|
-
__privateSet(this, _measured, false);
|
|
1208
|
-
}
|
|
1209
|
-
get() {
|
|
1210
|
-
return __privateGet(this, _value);
|
|
1211
|
-
}
|
|
1212
|
-
breakIntoLines(ctx, maxWidth) {
|
|
1213
|
-
const results = new Array();
|
|
1214
|
-
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1215
|
-
const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
|
|
1216
|
-
if (entries.length === 1) {
|
|
1217
|
-
return [this];
|
|
1218
|
-
}
|
|
1219
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1220
|
-
const text = new _Text(entries[i]);
|
|
1221
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1222
|
-
results.push(text);
|
|
1223
|
-
}
|
|
1224
|
-
return results;
|
|
1225
|
-
}
|
|
1226
|
-
split(char) {
|
|
1227
|
-
const entries = __privateGet(this, _value).split(char);
|
|
1228
|
-
const results = new Array();
|
|
1229
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1230
|
-
const text = new _Text(entries[i]);
|
|
1231
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1232
|
-
results.push(text);
|
|
1233
|
-
}
|
|
1234
|
-
return results;
|
|
1235
|
-
}
|
|
1236
|
-
splitAtIndex(index) {
|
|
1237
|
-
const results = [
|
|
1238
|
-
new _Text(__privateGet(this, _value).substring(0, index)),
|
|
1239
|
-
new _Text(__privateGet(this, _value).substring(index, 0))
|
|
1240
|
-
];
|
|
1241
|
-
for (let i = 0; i < results.length; i++) {
|
|
1242
|
-
__privateSet(results[i], _style, __privateGet(this, _style));
|
|
1243
|
-
}
|
|
1244
|
-
return results;
|
|
1245
|
-
}
|
|
1246
|
-
splitAtWidth(ctx, maxWidth) {
|
|
1247
|
-
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1248
|
-
const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
|
|
1249
|
-
if (entries.length === 1) {
|
|
1250
|
-
return [this];
|
|
1251
|
-
}
|
|
1252
|
-
const results = new Array();
|
|
1253
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1254
|
-
const text = new _Text(entries[i]);
|
|
1255
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1256
|
-
results.push(text);
|
|
1257
|
-
}
|
|
1258
|
-
return results;
|
|
1259
|
-
}
|
|
1260
|
-
size(ctx, scale, out) {
|
|
1261
|
-
__privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
|
|
1262
|
-
CopyVector2(out, __privateGet(this, _size3));
|
|
1263
|
-
ScaleVector(out, scale);
|
|
1264
|
-
}
|
|
1265
|
-
setColor(color) {
|
|
1266
|
-
__privateGet(this, _style).setColor(color);
|
|
1267
|
-
}
|
|
1268
|
-
getColor() {
|
|
1269
|
-
return __privateGet(this, _style).getColor();
|
|
1270
|
-
}
|
|
1271
|
-
setSize(size) {
|
|
1272
|
-
__privateGet(this, _style).setSize(size);
|
|
1273
|
-
}
|
|
1274
|
-
setWeight(weight) {
|
|
1275
|
-
__privateGet(this, _style).setWeight(weight);
|
|
1276
|
-
}
|
|
1277
|
-
render(ctx, scale, position) {
|
|
1278
|
-
__privateGet(this, _style).setupStyle(ctx, scale);
|
|
1279
|
-
ctx.fillText(__privateGet(this, _value), position.x, position.y);
|
|
1611
|
+
__privateSet(this, _color3, color);
|
|
1280
1612
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1613
|
+
setBorderColor(color) {
|
|
1614
|
+
if (__privateGet(this, _border2) === null) {
|
|
1615
|
+
__privateSet(this, _border2, new StrokeStyle({
|
|
1616
|
+
color
|
|
1617
|
+
}));
|
|
1618
|
+
} else {
|
|
1619
|
+
__privateGet(this, _border2).setColor(color);
|
|
1620
|
+
}
|
|
1283
1621
|
}
|
|
1284
1622
|
};
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1623
|
+
_border2 = new WeakMap();
|
|
1624
|
+
_color3 = new WeakMap();
|
|
1625
|
+
_radius = new WeakMap();
|
|
1626
|
+
_BoxStyle_instances = new WeakSet();
|
|
1627
|
+
box_fn = function(ctx, box, scale, radius) {
|
|
1628
|
+
var _a;
|
|
1629
|
+
ctx.fillStyle = __privateGet(this, _color3);
|
|
1630
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1631
|
+
ctx.beginPath();
|
|
1632
|
+
ctx.roundRect(
|
|
1633
|
+
box.Position.x,
|
|
1634
|
+
box.Position.y,
|
|
1635
|
+
box.Size.x,
|
|
1636
|
+
box.Size.y,
|
|
1637
|
+
radius
|
|
1638
|
+
);
|
|
1639
|
+
ctx.fill();
|
|
1640
|
+
};
|
|
1641
|
+
draw_fn = function(ctx, box, scale, radius) {
|
|
1642
|
+
__privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
|
|
1643
|
+
ctx.stroke();
|
|
1299
1644
|
};
|
|
1300
|
-
var Text = _Text;
|
|
1301
1645
|
|
|
1302
1646
|
// src/popup.ts
|
|
1303
1647
|
var _title, _options, _content, _onClose, _buttonCSS, _popup;
|
|
@@ -1372,15 +1716,15 @@ function TextBoxStyleWithFallback(input, fallback) {
|
|
|
1372
1716
|
textBaseline: (input == null ? void 0 : input.textBaseline) === void 0 ? fallback == null ? void 0 : fallback.textBaseline : input == null ? void 0 : input.textBaseline
|
|
1373
1717
|
};
|
|
1374
1718
|
}
|
|
1375
|
-
var _box2,
|
|
1719
|
+
var _box2, _text2, _textAlign, _textBaseline;
|
|
1376
1720
|
var TextBoxStyle = class {
|
|
1377
1721
|
constructor(config) {
|
|
1378
1722
|
__privateAdd(this, _box2);
|
|
1379
|
-
__privateAdd(this,
|
|
1723
|
+
__privateAdd(this, _text2);
|
|
1380
1724
|
__privateAdd(this, _textAlign);
|
|
1381
1725
|
__privateAdd(this, _textBaseline);
|
|
1382
1726
|
__privateSet(this, _box2, new BoxStyle(config == null ? void 0 : config.box));
|
|
1383
|
-
__privateSet(this,
|
|
1727
|
+
__privateSet(this, _text2, new TextStyle(config == null ? void 0 : config.text));
|
|
1384
1728
|
__privateSet(this, _textAlign, (config == null ? void 0 : config.textAlign) === void 0 ? "center" /* Center */ : config.textAlign);
|
|
1385
1729
|
__privateSet(this, _textBaseline, (config == null ? void 0 : config.textBaseline) === void 0 ? "middle" /* Middle */ : config.textBaseline);
|
|
1386
1730
|
}
|
|
@@ -1388,7 +1732,7 @@ var TextBoxStyle = class {
|
|
|
1388
1732
|
__privateGet(this, _box2).Draw(ctx, box, scale);
|
|
1389
1733
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1390
1734
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1391
|
-
__privateGet(this,
|
|
1735
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1392
1736
|
ctx.fillText(
|
|
1393
1737
|
text,
|
|
1394
1738
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1399,7 +1743,7 @@ var TextBoxStyle = class {
|
|
|
1399
1743
|
__privateGet(this, _box2).DrawUnderline(ctx, box, scale);
|
|
1400
1744
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1401
1745
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1402
|
-
__privateGet(this,
|
|
1746
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1403
1747
|
ctx.fillText(
|
|
1404
1748
|
text,
|
|
1405
1749
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1407,7 +1751,7 @@ var TextBoxStyle = class {
|
|
|
1407
1751
|
);
|
|
1408
1752
|
}
|
|
1409
1753
|
setTextColor(color) {
|
|
1410
|
-
__privateGet(this,
|
|
1754
|
+
__privateGet(this, _text2).setColor(color);
|
|
1411
1755
|
}
|
|
1412
1756
|
setBoxColor(color) {
|
|
1413
1757
|
__privateGet(this, _box2).setColor(color);
|
|
@@ -1417,7 +1761,7 @@ var TextBoxStyle = class {
|
|
|
1417
1761
|
}
|
|
1418
1762
|
};
|
|
1419
1763
|
_box2 = new WeakMap();
|
|
1420
|
-
|
|
1764
|
+
_text2 = new WeakMap();
|
|
1421
1765
|
_textAlign = new WeakMap();
|
|
1422
1766
|
_textBaseline = new WeakMap();
|
|
1423
1767
|
|
|
@@ -1426,7 +1770,7 @@ var width = 150;
|
|
|
1426
1770
|
var height = 25;
|
|
1427
1771
|
|
|
1428
1772
|
// src/widgets/number.ts
|
|
1429
|
-
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle,
|
|
1773
|
+
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle, _text3, _callback2;
|
|
1430
1774
|
var NumberWidget = class {
|
|
1431
1775
|
constructor(node, config) {
|
|
1432
1776
|
__privateAdd(this, _node2);
|
|
@@ -1434,10 +1778,10 @@ var NumberWidget = class {
|
|
|
1434
1778
|
__privateAdd(this, _value2);
|
|
1435
1779
|
__privateAdd(this, _idleBoxStyle);
|
|
1436
1780
|
__privateAdd(this, _highlightBoxStyle);
|
|
1437
|
-
__privateAdd(this,
|
|
1781
|
+
__privateAdd(this, _text3);
|
|
1438
1782
|
__privateAdd(this, _callback2);
|
|
1439
1783
|
__privateSet(this, _value2, 0);
|
|
1440
|
-
__privateSet(this,
|
|
1784
|
+
__privateSet(this, _text3, "0");
|
|
1441
1785
|
__privateSet(this, _node2, node);
|
|
1442
1786
|
__privateSet(this, _nodeProperty, config == null ? void 0 : config.property);
|
|
1443
1787
|
__privateSet(this, _idleBoxStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleBoxStyle, {
|
|
@@ -1484,7 +1828,7 @@ var NumberWidget = class {
|
|
|
1484
1828
|
if (__privateGet(this, _callback2) !== void 0) {
|
|
1485
1829
|
__privateGet(this, _callback2).call(this, __privateGet(this, _value2));
|
|
1486
1830
|
}
|
|
1487
|
-
__privateSet(this,
|
|
1831
|
+
__privateSet(this, _text3, "" + parseFloat(__privateGet(this, _value2).toPrecision(6)));
|
|
1488
1832
|
}
|
|
1489
1833
|
ClickStart() {
|
|
1490
1834
|
}
|
|
@@ -1527,7 +1871,7 @@ var NumberWidget = class {
|
|
|
1527
1871
|
style = __privateGet(this, _highlightBoxStyle);
|
|
1528
1872
|
}
|
|
1529
1873
|
}
|
|
1530
|
-
style.DrawUnderline(ctx, box, scale, __privateGet(this,
|
|
1874
|
+
style.DrawUnderline(ctx, box, scale, __privateGet(this, _text3));
|
|
1531
1875
|
return box;
|
|
1532
1876
|
}
|
|
1533
1877
|
};
|
|
@@ -1536,20 +1880,20 @@ _nodeProperty = new WeakMap();
|
|
|
1536
1880
|
_value2 = new WeakMap();
|
|
1537
1881
|
_idleBoxStyle = new WeakMap();
|
|
1538
1882
|
_highlightBoxStyle = new WeakMap();
|
|
1539
|
-
|
|
1883
|
+
_text3 = new WeakMap();
|
|
1540
1884
|
_callback2 = new WeakMap();
|
|
1541
1885
|
|
|
1542
1886
|
// src/widgets/button.ts
|
|
1543
|
-
var
|
|
1887
|
+
var _text4, _idleStyle, _hoverStyle, _clickStyle, _callback3, _gettingClicked;
|
|
1544
1888
|
var ButtonWidget = class {
|
|
1545
1889
|
constructor(config) {
|
|
1546
|
-
__privateAdd(this,
|
|
1890
|
+
__privateAdd(this, _text4);
|
|
1547
1891
|
__privateAdd(this, _idleStyle);
|
|
1548
1892
|
__privateAdd(this, _hoverStyle);
|
|
1549
1893
|
__privateAdd(this, _clickStyle);
|
|
1550
1894
|
__privateAdd(this, _callback3);
|
|
1551
1895
|
__privateAdd(this, _gettingClicked);
|
|
1552
|
-
__privateSet(this,
|
|
1896
|
+
__privateSet(this, _text4, (config == null ? void 0 : config.text) === void 0 ? "Button" : config == null ? void 0 : config.text);
|
|
1553
1897
|
__privateSet(this, _callback3, config == null ? void 0 : config.callback);
|
|
1554
1898
|
__privateSet(this, _gettingClicked, false);
|
|
1555
1899
|
__privateSet(this, _idleStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleStyle, {
|
|
@@ -1604,7 +1948,7 @@ var ButtonWidget = class {
|
|
|
1604
1948
|
if (__privateGet(this, _gettingClicked)) {
|
|
1605
1949
|
style = __privateGet(this, _clickStyle);
|
|
1606
1950
|
}
|
|
1607
|
-
style.Draw(ctx, box, scale, __privateGet(this,
|
|
1951
|
+
style.Draw(ctx, box, scale, __privateGet(this, _text4));
|
|
1608
1952
|
return box;
|
|
1609
1953
|
}
|
|
1610
1954
|
ClickStart() {
|
|
@@ -1617,7 +1961,7 @@ var ButtonWidget = class {
|
|
|
1617
1961
|
}
|
|
1618
1962
|
}
|
|
1619
1963
|
};
|
|
1620
|
-
|
|
1964
|
+
_text4 = new WeakMap();
|
|
1621
1965
|
_idleStyle = new WeakMap();
|
|
1622
1966
|
_hoverStyle = new WeakMap();
|
|
1623
1967
|
_clickStyle = new WeakMap();
|
|
@@ -1735,14 +2079,14 @@ _textBoxStyle = new WeakMap();
|
|
|
1735
2079
|
_callback4 = new WeakMap();
|
|
1736
2080
|
|
|
1737
2081
|
// src/widgets/slider.ts
|
|
1738
|
-
var _min, _max, _value4,
|
|
2082
|
+
var _min, _max, _value4, _text5, _snapIncrement, _node4, _nodeProperty3, _change, _release, _textStyle3, _backgroundColor2, _borderColor, _fillColor, _lastMousePosition2, _clickStartMousePosition, _clicking;
|
|
1739
2083
|
var SliderWidget = class {
|
|
1740
2084
|
constructor(node, config) {
|
|
1741
2085
|
// Data Variables =========================================================
|
|
1742
2086
|
__privateAdd(this, _min);
|
|
1743
2087
|
__privateAdd(this, _max);
|
|
1744
2088
|
__privateAdd(this, _value4);
|
|
1745
|
-
__privateAdd(this,
|
|
2089
|
+
__privateAdd(this, _text5);
|
|
1746
2090
|
__privateAdd(this, _snapIncrement);
|
|
1747
2091
|
__privateAdd(this, _node4);
|
|
1748
2092
|
__privateAdd(this, _nodeProperty3);
|
|
@@ -1751,7 +2095,7 @@ var SliderWidget = class {
|
|
|
1751
2095
|
__privateAdd(this, _release);
|
|
1752
2096
|
// Styling Variables ======================================================
|
|
1753
2097
|
__privateAdd(this, _textStyle3);
|
|
1754
|
-
__privateAdd(this,
|
|
2098
|
+
__privateAdd(this, _backgroundColor2);
|
|
1755
2099
|
__privateAdd(this, _borderColor);
|
|
1756
2100
|
__privateAdd(this, _fillColor);
|
|
1757
2101
|
// Runtime Variables ======================================================
|
|
@@ -1764,9 +2108,9 @@ var SliderWidget = class {
|
|
|
1764
2108
|
__privateSet(this, _max, (config == null ? void 0 : config.max) === void 0 ? 1 : config == null ? void 0 : config.max);
|
|
1765
2109
|
__privateSet(this, _snapIncrement, config == null ? void 0 : config.snapIncrement);
|
|
1766
2110
|
__privateSet(this, _nodeProperty3, config == null ? void 0 : config.property);
|
|
1767
|
-
__privateSet(this,
|
|
2111
|
+
__privateSet(this, _text5, "");
|
|
1768
2112
|
__privateSet(this, _release, config == null ? void 0 : config.release);
|
|
1769
|
-
__privateSet(this,
|
|
2113
|
+
__privateSet(this, _backgroundColor2, (config == null ? void 0 : config.backgroundColor) === void 0 ? Theme.Widget.BackgroundColor : config == null ? void 0 : config.backgroundColor);
|
|
1770
2114
|
__privateSet(this, _fillColor, (config == null ? void 0 : config.fillColor) === void 0 ? Theme.Widget.Slider.FillColor : config == null ? void 0 : config.fillColor);
|
|
1771
2115
|
__privateSet(this, _borderColor, (config == null ? void 0 : config.borderColor) === void 0 ? Theme.Widget.Border.Color : config == null ? void 0 : config.borderColor);
|
|
1772
2116
|
__privateSet(this, _textStyle3, new TextStyle(TextStyleFallback(config == null ? void 0 : config.textStyle, {
|
|
@@ -1792,7 +2136,7 @@ var SliderWidget = class {
|
|
|
1792
2136
|
if (__privateGet(this, _nodeProperty3)) {
|
|
1793
2137
|
__privateGet(this, _node4).setProperty(__privateGet(this, _nodeProperty3), __privateGet(this, _value4));
|
|
1794
2138
|
}
|
|
1795
|
-
__privateSet(this,
|
|
2139
|
+
__privateSet(this, _text5, __privateGet(this, _value4).toFixed(3));
|
|
1796
2140
|
if (__privateGet(this, _change) !== void 0) {
|
|
1797
2141
|
__privateGet(this, _change).call(this, __privateGet(this, _value4));
|
|
1798
2142
|
}
|
|
@@ -1814,7 +2158,7 @@ var SliderWidget = class {
|
|
|
1814
2158
|
const scaledWidth = width * scale;
|
|
1815
2159
|
const scaledHeight = height * scale;
|
|
1816
2160
|
const scaledBorderThickness = Theme.Widget.Border.Size * scale;
|
|
1817
|
-
ctx.fillStyle = __privateGet(this,
|
|
2161
|
+
ctx.fillStyle = __privateGet(this, _backgroundColor2);
|
|
1818
2162
|
ctx.strokeStyle = __privateGet(this, _borderColor);
|
|
1819
2163
|
ctx.lineWidth = scaledBorderThickness;
|
|
1820
2164
|
ctx.beginPath();
|
|
@@ -1842,7 +2186,7 @@ var SliderWidget = class {
|
|
|
1842
2186
|
ctx.textBaseline = "middle" /* Middle */;
|
|
1843
2187
|
__privateGet(this, _textStyle3).setupStyle(ctx, scale);
|
|
1844
2188
|
ctx.fillText(
|
|
1845
|
-
__privateGet(this,
|
|
2189
|
+
__privateGet(this, _text5),
|
|
1846
2190
|
position.x + scaledWidth / 2,
|
|
1847
2191
|
position.y + scaledHeight / 2
|
|
1848
2192
|
);
|
|
@@ -1871,14 +2215,14 @@ var SliderWidget = class {
|
|
|
1871
2215
|
_min = new WeakMap();
|
|
1872
2216
|
_max = new WeakMap();
|
|
1873
2217
|
_value4 = new WeakMap();
|
|
1874
|
-
|
|
2218
|
+
_text5 = new WeakMap();
|
|
1875
2219
|
_snapIncrement = new WeakMap();
|
|
1876
2220
|
_node4 = new WeakMap();
|
|
1877
2221
|
_nodeProperty3 = new WeakMap();
|
|
1878
2222
|
_change = new WeakMap();
|
|
1879
2223
|
_release = new WeakMap();
|
|
1880
2224
|
_textStyle3 = new WeakMap();
|
|
1881
|
-
|
|
2225
|
+
_backgroundColor2 = new WeakMap();
|
|
1882
2226
|
_borderColor = new WeakMap();
|
|
1883
2227
|
_fillColor = new WeakMap();
|
|
1884
2228
|
_lastMousePosition2 = new WeakMap();
|
|
@@ -2082,13 +2426,13 @@ _lightColor = new WeakMap();
|
|
|
2082
2426
|
_lightBorderColor = new WeakMap();
|
|
2083
2427
|
_lightBlur = new WeakMap();
|
|
2084
2428
|
_box3 = new WeakMap();
|
|
2085
|
-
var _node6, _nodeProperty5, _value6,
|
|
2429
|
+
var _node6, _nodeProperty5, _value6, _text6, _enabledStyle, _disabledStyle, _callback6;
|
|
2086
2430
|
var ToggleWidget = class {
|
|
2087
2431
|
constructor(node, config) {
|
|
2088
2432
|
__privateAdd(this, _node6);
|
|
2089
2433
|
__privateAdd(this, _nodeProperty5);
|
|
2090
2434
|
__privateAdd(this, _value6);
|
|
2091
|
-
__privateAdd(this,
|
|
2435
|
+
__privateAdd(this, _text6);
|
|
2092
2436
|
__privateAdd(this, _enabledStyle);
|
|
2093
2437
|
__privateAdd(this, _disabledStyle);
|
|
2094
2438
|
__privateAdd(this, _callback6);
|
|
@@ -2096,7 +2440,7 @@ var ToggleWidget = class {
|
|
|
2096
2440
|
__privateSet(this, _value6, false);
|
|
2097
2441
|
__privateSet(this, _node6, node);
|
|
2098
2442
|
__privateSet(this, _nodeProperty5, config == null ? void 0 : config.property);
|
|
2099
|
-
__privateSet(this,
|
|
2443
|
+
__privateSet(this, _text6, (config == null ? void 0 : config.text) === void 0 ? "Toggle" : config == null ? void 0 : config.text);
|
|
2100
2444
|
__privateSet(this, _enabledStyle, new ToggleStyle({
|
|
2101
2445
|
idle: TextBoxStyleWithFallback((_a = config == null ? void 0 : config.enabledStyle) == null ? void 0 : _a.idle, {
|
|
2102
2446
|
box: {
|
|
@@ -2139,7 +2483,7 @@ var ToggleWidget = class {
|
|
|
2139
2483
|
}
|
|
2140
2484
|
Draw(ctx, position, scale, mousePosition) {
|
|
2141
2485
|
let style = __privateGet(this, _value6) ? __privateGet(this, _enabledStyle) : __privateGet(this, _disabledStyle);
|
|
2142
|
-
return style.Draw(ctx, position, scale, __privateGet(this,
|
|
2486
|
+
return style.Draw(ctx, position, scale, __privateGet(this, _text6), mousePosition);
|
|
2143
2487
|
}
|
|
2144
2488
|
Toggle() {
|
|
2145
2489
|
this.Set(!__privateGet(this, _value6));
|
|
@@ -2165,21 +2509,21 @@ var ToggleWidget = class {
|
|
|
2165
2509
|
_node6 = new WeakMap();
|
|
2166
2510
|
_nodeProperty5 = new WeakMap();
|
|
2167
2511
|
_value6 = new WeakMap();
|
|
2168
|
-
|
|
2512
|
+
_text6 = new WeakMap();
|
|
2169
2513
|
_enabledStyle = new WeakMap();
|
|
2170
2514
|
_disabledStyle = new WeakMap();
|
|
2171
2515
|
_callback6 = new WeakMap();
|
|
2172
2516
|
|
|
2173
2517
|
// src/widgets/image.ts
|
|
2174
|
-
var _url, _image,
|
|
2518
|
+
var _url, _image, _maxWidth2, _maxHeight2;
|
|
2175
2519
|
var ImageWidget = class {
|
|
2176
2520
|
constructor(config) {
|
|
2177
2521
|
__privateAdd(this, _url);
|
|
2178
2522
|
__privateAdd(this, _image);
|
|
2179
|
-
__privateAdd(this,
|
|
2180
|
-
__privateAdd(this,
|
|
2181
|
-
__privateSet(this,
|
|
2182
|
-
__privateSet(this,
|
|
2523
|
+
__privateAdd(this, _maxWidth2);
|
|
2524
|
+
__privateAdd(this, _maxHeight2);
|
|
2525
|
+
__privateSet(this, _maxWidth2, (config == null ? void 0 : config.maxWidth) === void 0 ? 150 : config == null ? void 0 : config.maxWidth);
|
|
2526
|
+
__privateSet(this, _maxHeight2, (config == null ? void 0 : config.maxHeight) === void 0 ? 150 : config == null ? void 0 : config.maxHeight);
|
|
2183
2527
|
if (config == null ? void 0 : config.image) {
|
|
2184
2528
|
this.SetUrl(config == null ? void 0 : config.image);
|
|
2185
2529
|
} else if (config == null ? void 0 : config.blob) {
|
|
@@ -2208,11 +2552,11 @@ var ImageWidget = class {
|
|
|
2208
2552
|
return { "x": 0, "y": 0 };
|
|
2209
2553
|
}
|
|
2210
2554
|
let adjust = 1;
|
|
2211
|
-
if (__privateGet(this, _image).width > __privateGet(this,
|
|
2212
|
-
adjust = __privateGet(this,
|
|
2555
|
+
if (__privateGet(this, _image).width > __privateGet(this, _maxWidth2)) {
|
|
2556
|
+
adjust = __privateGet(this, _maxWidth2) / __privateGet(this, _image).width;
|
|
2213
2557
|
}
|
|
2214
|
-
if (__privateGet(this, _image).height > __privateGet(this,
|
|
2215
|
-
let heightAdjust = __privateGet(this,
|
|
2558
|
+
if (__privateGet(this, _image).height > __privateGet(this, _maxHeight2)) {
|
|
2559
|
+
let heightAdjust = __privateGet(this, _maxHeight2) / __privateGet(this, _image).height;
|
|
2216
2560
|
if (heightAdjust < adjust) {
|
|
2217
2561
|
adjust = heightAdjust;
|
|
2218
2562
|
}
|
|
@@ -2251,8 +2595,8 @@ var ImageWidget = class {
|
|
|
2251
2595
|
};
|
|
2252
2596
|
_url = new WeakMap();
|
|
2253
2597
|
_image = new WeakMap();
|
|
2254
|
-
|
|
2255
|
-
|
|
2598
|
+
_maxWidth2 = new WeakMap();
|
|
2599
|
+
_maxHeight2 = new WeakMap();
|
|
2256
2600
|
|
|
2257
2601
|
// src/widgets/text.ts
|
|
2258
2602
|
var _value7, _callback7, _node7, _nodeProperty6, _size4;
|
|
@@ -3483,7 +3827,7 @@ function FormPopup(config) {
|
|
|
3483
3827
|
|
|
3484
3828
|
// src/node.ts
|
|
3485
3829
|
var MINIMUM_NODE_WIDTH = 150;
|
|
3486
|
-
var _position, _title2, _subTitle, _infoSymbol, _infoText, _input, _output, _widgets, _locked, _canEditTitle, _canEditInfo, _canEditPorts, _contextMenu2, _metadata, _onSelect, _onUnselect, _onFiledrop, _onDragStop, _titleChangeCallback, _infoChangeCallback, _titleColor, _selectedStyle, _stateStyles,
|
|
3830
|
+
var _position, _title2, _subTitle, _infoSymbol, _infoText, _input, _output, _widgets, _locked, _canEditTitle, _canEditInfo, _canEditPorts, _contextMenu2, _metadata, _onSelect, _onUnselect, _onFiledrop, _onDragStop, _titleChangeCallback, _infoChangeCallback, _titleColor, _selectedStyle, _stateStyles, _padding2, _portTextStyle, _elementSpacing, _selected, _inputPortPositions, _outputPortPositions, _widgetPositions, _data, _registeredAnyPropertyChangeCallbacks, _registeredPropertyChangeCallbacks, _FlowNode_instances, popupNodeTitleSelection_fn, popupNodeInfoSelection_fn, popupNewButtonWidget_fn, widgetSubmenu_fn, calculateStyle_fn;
|
|
3487
3831
|
var FlowNode = class {
|
|
3488
3832
|
constructor(config) {
|
|
3489
3833
|
__privateAdd(this, _FlowNode_instances);
|
|
@@ -3512,7 +3856,7 @@ var FlowNode = class {
|
|
|
3512
3856
|
__privateAdd(this, _titleColor);
|
|
3513
3857
|
__privateAdd(this, _selectedStyle);
|
|
3514
3858
|
__privateAdd(this, _stateStyles);
|
|
3515
|
-
__privateAdd(this,
|
|
3859
|
+
__privateAdd(this, _padding2);
|
|
3516
3860
|
__privateAdd(this, _portTextStyle);
|
|
3517
3861
|
__privateAdd(this, _elementSpacing);
|
|
3518
3862
|
// Runtime ================================================================
|
|
@@ -3592,7 +3936,7 @@ var FlowNode = class {
|
|
|
3592
3936
|
));
|
|
3593
3937
|
__privateSet(this, _infoText, (config == null ? void 0 : config.info) ? config == null ? void 0 : config.info : "");
|
|
3594
3938
|
__privateSet(this, _titleColor, ((_f = (_e = config == null ? void 0 : config.style) == null ? void 0 : _e.title) == null ? void 0 : _f.color) === void 0 ? "#154050" : (_h = (_g = config == null ? void 0 : config.style) == null ? void 0 : _g.title) == null ? void 0 : _h.color);
|
|
3595
|
-
__privateSet(this,
|
|
3939
|
+
__privateSet(this, _padding2, ((_j = (_i = config == null ? void 0 : config.style) == null ? void 0 : _i.title) == null ? void 0 : _j.padding) === void 0 ? 15 : (_l = (_k = config == null ? void 0 : config.style) == null ? void 0 : _k.title) == null ? void 0 : _l.padding);
|
|
3596
3940
|
__privateSet(this, _stateStyles, /* @__PURE__ */ new Map());
|
|
3597
3941
|
__privateGet(this, _stateStyles).set(0 /* Idle */, new BoxStyle(BoxStyleWithFallback((_m = config == null ? void 0 : config.style) == null ? void 0 : _m.idle, {
|
|
3598
3942
|
border: { color: Theme.Node.Border.Idle, size: 1 },
|
|
@@ -3873,7 +4217,7 @@ var FlowNode = class {
|
|
|
3873
4217
|
// }
|
|
3874
4218
|
calculateBounds(ctx, camera) {
|
|
3875
4219
|
const tempMeasurement = Zero();
|
|
3876
|
-
const doublePadding = __privateGet(this,
|
|
4220
|
+
const doublePadding = __privateGet(this, _padding2) * 2;
|
|
3877
4221
|
const screenSpacePosition = Zero();
|
|
3878
4222
|
camera.graphSpaceToScreenSpace(__privateGet(this, _position), screenSpacePosition);
|
|
3879
4223
|
const size = Zero();
|
|
@@ -4038,7 +4382,7 @@ var FlowNode = class {
|
|
|
4038
4382
|
__privateGet(this, _inputPortPositions).Clear();
|
|
4039
4383
|
__privateGet(this, _outputPortPositions).Clear();
|
|
4040
4384
|
__privateGet(this, _widgetPositions).Clear();
|
|
4041
|
-
const scaledPadding = __privateGet(this,
|
|
4385
|
+
const scaledPadding = __privateGet(this, _padding2) * camera.zoom;
|
|
4042
4386
|
const scaledElementSpacing = __privateGet(this, _elementSpacing) * camera.zoom;
|
|
4043
4387
|
const nodeBounds = this.calculateBounds(ctx, camera);
|
|
4044
4388
|
const nodeStyle = __privateMethod(this, _FlowNode_instances, calculateStyle_fn).call(this, state);
|
|
@@ -4185,7 +4529,7 @@ _infoChangeCallback = new WeakMap();
|
|
|
4185
4529
|
_titleColor = new WeakMap();
|
|
4186
4530
|
_selectedStyle = new WeakMap();
|
|
4187
4531
|
_stateStyles = new WeakMap();
|
|
4188
|
-
|
|
4532
|
+
_padding2 = new WeakMap();
|
|
4189
4533
|
_portTextStyle = new WeakMap();
|
|
4190
4534
|
_elementSpacing = new WeakMap();
|
|
4191
4535
|
_selected = new WeakMap();
|
|
@@ -4485,15 +4829,15 @@ text_fn = function() {
|
|
|
4485
4829
|
};
|
|
4486
4830
|
|
|
4487
4831
|
// src/markdown/entry.ts
|
|
4488
|
-
var
|
|
4832
|
+
var _text7, _calculatedPositions, _calculatedEntries, _calculatedForWidth, _CodeBlockEntry_instances, calculateLayout_fn;
|
|
4489
4833
|
var CodeBlockEntry = class {
|
|
4490
4834
|
constructor(text) {
|
|
4491
4835
|
__privateAdd(this, _CodeBlockEntry_instances);
|
|
4492
|
-
__privateAdd(this,
|
|
4836
|
+
__privateAdd(this, _text7);
|
|
4493
4837
|
__privateAdd(this, _calculatedPositions);
|
|
4494
4838
|
__privateAdd(this, _calculatedEntries);
|
|
4495
4839
|
__privateAdd(this, _calculatedForWidth);
|
|
4496
|
-
__privateSet(this,
|
|
4840
|
+
__privateSet(this, _text7, text);
|
|
4497
4841
|
__privateSet(this, _calculatedForWidth, -1);
|
|
4498
4842
|
__privateSet(this, _calculatedEntries, new List());
|
|
4499
4843
|
__privateSet(this, _calculatedPositions, new List());
|
|
@@ -4532,7 +4876,7 @@ var CodeBlockEntry = class {
|
|
|
4532
4876
|
return max + padding * 2;
|
|
4533
4877
|
}
|
|
4534
4878
|
};
|
|
4535
|
-
|
|
4879
|
+
_text7 = new WeakMap();
|
|
4536
4880
|
_calculatedPositions = new WeakMap();
|
|
4537
4881
|
_calculatedEntries = new WeakMap();
|
|
4538
4882
|
_calculatedForWidth = new WeakMap();
|
|
@@ -4546,8 +4890,8 @@ calculateLayout_fn = function(ctx, maxWidth) {
|
|
|
4546
4890
|
__privateGet(this, _calculatedEntries).Clear();
|
|
4547
4891
|
__privateGet(this, _calculatedPositions).Clear();
|
|
4548
4892
|
let curHeight = 0;
|
|
4549
|
-
const lineInc = __privateGet(this,
|
|
4550
|
-
let entries = __privateGet(this,
|
|
4893
|
+
const lineInc = __privateGet(this, _text7).style().getSize() + Theme.Note.LineSpacing;
|
|
4894
|
+
let entries = __privateGet(this, _text7).split("\n");
|
|
4551
4895
|
for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
|
|
4552
4896
|
const entry = entries[entryIndex];
|
|
4553
4897
|
let lines = entry.breakIntoLines(ctx, adjustedWith);
|
|
@@ -5334,404 +5678,114 @@ var NoteSubsystem = class {
|
|
|
5334
5678
|
return false;
|
|
5335
5679
|
}
|
|
5336
5680
|
clickEnd() {
|
|
5337
|
-
if (__privateGet(this, _noteSelected) !== null) {
|
|
5338
|
-
__privateGet(this, _noteSelected).selectHandle(0 /* None */);
|
|
5339
|
-
for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
|
|
5340
|
-
__privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
|
|
5341
|
-
}
|
|
5342
|
-
}
|
|
5343
|
-
__privateSet(this, _noteSelected, null);
|
|
5344
|
-
}
|
|
5345
|
-
mouseDragEvent(delta, scale) {
|
|
5346
|
-
if (__privateGet(this, _noteSelected) === null) {
|
|
5347
|
-
return false;
|
|
5348
|
-
}
|
|
5349
|
-
if (__privateGet(this, _noteSelected).handleSelected()) {
|
|
5350
|
-
return true;
|
|
5351
|
-
}
|
|
5352
|
-
__privateGet(this, _noteSelected).translate({
|
|
5353
|
-
x: delta.x * (1 / scale),
|
|
5354
|
-
y: delta.y * (1 / scale)
|
|
5355
|
-
});
|
|
5356
|
-
return true;
|
|
5357
|
-
}
|
|
5358
|
-
fileDrop(file) {
|
|
5359
|
-
return false;
|
|
5360
|
-
}
|
|
5361
|
-
removeNote(note) {
|
|
5362
|
-
const index = __privateGet(this, _notes).indexOf(note);
|
|
5363
|
-
if (index > -1) {
|
|
5364
|
-
const noteRemoved = __privateGet(this, _notes)[index];
|
|
5365
|
-
__privateGet(this, _notes).splice(index, 1);
|
|
5366
|
-
for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
|
|
5367
|
-
__privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
|
|
5368
|
-
}
|
|
5369
|
-
} else {
|
|
5370
|
-
console.error("no note found to remove");
|
|
5371
|
-
}
|
|
5372
|
-
}
|
|
5373
|
-
render(ctx, camera, mousePosition) {
|
|
5374
|
-
__privateSet(this, _noteHovering, null);
|
|
5375
|
-
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
5376
|
-
if (mousePosition) {
|
|
5377
|
-
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5378
|
-
__privateGet(this, _notes)[i].setHovering(false);
|
|
5379
|
-
if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
|
|
5380
|
-
__privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
|
|
5381
|
-
}
|
|
5382
|
-
}
|
|
5383
|
-
}
|
|
5384
|
-
if (__privateGet(this, _noteHovering) != null) {
|
|
5385
|
-
__privateGet(this, _noteHovering).setHovering(true);
|
|
5386
|
-
if (mousePosition) {
|
|
5387
|
-
if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
|
|
5388
|
-
__privateSet(this, _hoveringHandle, 1 /* Left */);
|
|
5389
|
-
} else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
|
|
5390
|
-
__privateSet(this, _hoveringHandle, 2 /* Right */);
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
}
|
|
5394
|
-
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5395
|
-
__privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
|
|
5396
|
-
}
|
|
5397
|
-
return;
|
|
5398
|
-
}
|
|
5399
|
-
};
|
|
5400
|
-
_notes = new WeakMap();
|
|
5401
|
-
_noteHovering = new WeakMap();
|
|
5402
|
-
_noteSelected = new WeakMap();
|
|
5403
|
-
_hoveringHandle = new WeakMap();
|
|
5404
|
-
_onNoteAddedCallbacks = new WeakMap();
|
|
5405
|
-
_onNoteRemovedCallbacks = new WeakMap();
|
|
5406
|
-
_onNoteDragStartCallbacks = new WeakMap();
|
|
5407
|
-
_onNoteDragStopCallbacks = new WeakMap();
|
|
5408
|
-
|
|
5409
|
-
// src/pass/subsystem.ts
|
|
5410
|
-
var _queue;
|
|
5411
|
-
var PassSubsystem = class {
|
|
5412
|
-
constructor() {
|
|
5413
|
-
__privateAdd(this, _queue);
|
|
5414
|
-
__privateSet(this, _queue, new List());
|
|
5415
|
-
}
|
|
5416
|
-
queue(lambda) {
|
|
5417
|
-
if (!lambda) {
|
|
5418
|
-
return;
|
|
5419
|
-
}
|
|
5420
|
-
__privateGet(this, _queue).Push(lambda);
|
|
5421
|
-
}
|
|
5422
|
-
render(ctx, camera, mousePosition) {
|
|
5423
|
-
for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
|
|
5424
|
-
__privateGet(this, _queue).At(i)();
|
|
5425
|
-
}
|
|
5426
|
-
__privateGet(this, _queue).Clear();
|
|
5427
|
-
return;
|
|
5428
|
-
}
|
|
5429
|
-
openContextMenu(ctx, position) {
|
|
5430
|
-
return null;
|
|
5431
|
-
}
|
|
5432
|
-
clickStart(mousePosition, camera, ctrlKey) {
|
|
5433
|
-
return false;
|
|
5434
|
-
}
|
|
5435
|
-
mouseDragEvent(delta, scale) {
|
|
5436
|
-
return false;
|
|
5437
|
-
}
|
|
5438
|
-
fileDrop(file) {
|
|
5439
|
-
return false;
|
|
5440
|
-
}
|
|
5441
|
-
clickEnd() {
|
|
5442
|
-
}
|
|
5443
|
-
};
|
|
5444
|
-
_queue = new WeakMap();
|
|
5445
|
-
|
|
5446
|
-
// src/elements/interfaces.ts
|
|
5447
|
-
function InstantiateRenderElementSidesStyling(config) {
|
|
5448
|
-
if (typeof config === "number") {
|
|
5449
|
-
return {
|
|
5450
|
-
Bottom: config,
|
|
5451
|
-
Right: config,
|
|
5452
|
-
Top: config,
|
|
5453
|
-
Left: config
|
|
5454
|
-
};
|
|
5455
|
-
}
|
|
5456
|
-
return {
|
|
5457
|
-
Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
|
|
5458
|
-
Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
|
|
5459
|
-
Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
|
|
5460
|
-
Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
|
|
5461
|
-
};
|
|
5462
|
-
}
|
|
5463
|
-
|
|
5464
|
-
// src/elements/base.ts
|
|
5465
|
-
var _margin, _padding2, _border2, _backgroundColor2, _minWidth, _maxWidth2, _minHeight, _maxHeight2, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
|
|
5466
|
-
var RenderElementBase = class {
|
|
5467
|
-
constructor(config) {
|
|
5468
|
-
__privateAdd(this, _RenderElementBase_instances);
|
|
5469
|
-
__privateAdd(this, _margin);
|
|
5470
|
-
__privateAdd(this, _padding2);
|
|
5471
|
-
__privateAdd(this, _border2);
|
|
5472
|
-
__privateAdd(this, _backgroundColor2);
|
|
5473
|
-
__privateAdd(this, _minWidth);
|
|
5474
|
-
__privateAdd(this, _maxWidth2);
|
|
5475
|
-
__privateAdd(this, _minHeight);
|
|
5476
|
-
__privateAdd(this, _maxHeight2);
|
|
5477
|
-
__privateAdd(this, _grow);
|
|
5478
|
-
__privateAdd(this, _display);
|
|
5479
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5480
|
-
__privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
|
|
5481
|
-
__privateSet(this, _padding2, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
|
|
5482
|
-
__privateSet(this, _backgroundColor2, config == null ? void 0 : config.BackgroundColor);
|
|
5483
|
-
__privateSet(this, _border2, {
|
|
5484
|
-
Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
|
|
5485
|
-
Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
|
|
5486
|
-
Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
|
|
5487
|
-
});
|
|
5488
|
-
__privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
|
|
5489
|
-
__privateSet(this, _maxWidth2, config == null ? void 0 : config.MaxWidth);
|
|
5490
|
-
__privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
|
|
5491
|
-
__privateSet(this, _maxHeight2, config == null ? void 0 : config.MaxHeight);
|
|
5492
|
-
__privateSet(this, _grow, config == null ? void 0 : config.Grow);
|
|
5493
|
-
__privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
|
|
5494
|
-
}
|
|
5495
|
-
setBackgroundColor(newColor) {
|
|
5496
|
-
__privateSet(this, _backgroundColor2, newColor);
|
|
5497
|
-
}
|
|
5498
|
-
render(ctx, position, graphScale, scaledFillableSpace) {
|
|
5499
|
-
if (__privateGet(this, _display) === "none" /* None */) {
|
|
5500
|
-
return;
|
|
5501
|
-
}
|
|
5502
|
-
const scaledSize = { x: 0, y: 0 };
|
|
5503
|
-
this.size(ctx, scaledSize);
|
|
5504
|
-
scaledSize.x = scaledSize.x * graphScale;
|
|
5505
|
-
scaledSize.y = scaledSize.y * graphScale;
|
|
5506
|
-
scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
|
|
5507
|
-
scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
|
|
5508
|
-
if (__privateGet(this, _backgroundColor2)) {
|
|
5509
|
-
ctx.fillStyle = __privateGet(this, _backgroundColor2);
|
|
5510
|
-
ctx.beginPath();
|
|
5511
|
-
ctx.roundRect(
|
|
5512
|
-
position.x + __privateGet(this, _margin).Left * graphScale,
|
|
5513
|
-
position.y + __privateGet(this, _margin).Right * graphScale,
|
|
5514
|
-
scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
|
|
5515
|
-
scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
|
|
5516
|
-
__privateGet(this, _border2).Radius * graphScale
|
|
5517
|
-
);
|
|
5518
|
-
ctx.fill();
|
|
5519
|
-
}
|
|
5520
|
-
if (__privateGet(this, _border2).Thickness > 0) {
|
|
5521
|
-
ctx.lineWidth = __privateGet(this, _border2).Thickness * graphScale;
|
|
5522
|
-
ctx.strokeStyle = __privateGet(this, _border2).Color;
|
|
5523
|
-
ctx.stroke();
|
|
5681
|
+
if (__privateGet(this, _noteSelected) !== null) {
|
|
5682
|
+
__privateGet(this, _noteSelected).selectHandle(0 /* None */);
|
|
5683
|
+
for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
|
|
5684
|
+
__privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
|
|
5685
|
+
}
|
|
5524
5686
|
}
|
|
5525
|
-
|
|
5526
|
-
x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
|
|
5527
|
-
y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
|
|
5528
|
-
};
|
|
5529
|
-
const elementSize = {
|
|
5530
|
-
x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
|
|
5531
|
-
y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
|
|
5532
|
-
};
|
|
5533
|
-
this.doRender(ctx, offsetPosition, graphScale, elementSize);
|
|
5687
|
+
__privateSet(this, _noteSelected, null);
|
|
5534
5688
|
}
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
if (__privateGet(this, _maxWidth2)) {
|
|
5539
|
-
out.x = __privateGet(this, _maxWidth2);
|
|
5689
|
+
mouseDragEvent(delta, scale) {
|
|
5690
|
+
if (__privateGet(this, _noteSelected) === null) {
|
|
5691
|
+
return false;
|
|
5540
5692
|
}
|
|
5541
|
-
if (__privateGet(this,
|
|
5542
|
-
|
|
5693
|
+
if (__privateGet(this, _noteSelected).handleSelected()) {
|
|
5694
|
+
return true;
|
|
5543
5695
|
}
|
|
5696
|
+
__privateGet(this, _noteSelected).translate({
|
|
5697
|
+
x: delta.x * (1 / scale),
|
|
5698
|
+
y: delta.y * (1 / scale)
|
|
5699
|
+
});
|
|
5700
|
+
return true;
|
|
5544
5701
|
}
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
}
|
|
5548
|
-
getDisplay() {
|
|
5549
|
-
return __privateGet(this, _display);
|
|
5702
|
+
fileDrop(file) {
|
|
5703
|
+
return false;
|
|
5550
5704
|
}
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
|
|
5562
|
-
if (__privateGet(this, _minWidth)) {
|
|
5563
|
-
out.x = Math.max(out.x, __privateGet(this, _minWidth));
|
|
5705
|
+
removeNote(note) {
|
|
5706
|
+
const index = __privateGet(this, _notes).indexOf(note);
|
|
5707
|
+
if (index > -1) {
|
|
5708
|
+
const noteRemoved = __privateGet(this, _notes)[index];
|
|
5709
|
+
__privateGet(this, _notes).splice(index, 1);
|
|
5710
|
+
for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
|
|
5711
|
+
__privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
|
|
5712
|
+
}
|
|
5713
|
+
} else {
|
|
5714
|
+
console.error("no note found to remove");
|
|
5564
5715
|
}
|
|
5565
|
-
|
|
5566
|
-
|
|
5716
|
+
}
|
|
5717
|
+
render(ctx, camera, mousePosition) {
|
|
5718
|
+
__privateSet(this, _noteHovering, null);
|
|
5719
|
+
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
5720
|
+
if (mousePosition) {
|
|
5721
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5722
|
+
__privateGet(this, _notes)[i].setHovering(false);
|
|
5723
|
+
if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
|
|
5724
|
+
__privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5567
5727
|
}
|
|
5568
|
-
if (__privateGet(this,
|
|
5569
|
-
|
|
5728
|
+
if (__privateGet(this, _noteHovering) != null) {
|
|
5729
|
+
__privateGet(this, _noteHovering).setHovering(true);
|
|
5730
|
+
if (mousePosition) {
|
|
5731
|
+
if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
|
|
5732
|
+
__privateSet(this, _hoveringHandle, 1 /* Left */);
|
|
5733
|
+
} else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
|
|
5734
|
+
__privateSet(this, _hoveringHandle, 2 /* Right */);
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5570
5737
|
}
|
|
5571
|
-
|
|
5572
|
-
|
|
5738
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5739
|
+
__privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
|
|
5573
5740
|
}
|
|
5741
|
+
return;
|
|
5574
5742
|
}
|
|
5575
5743
|
};
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
_grow = new WeakMap();
|
|
5585
|
-
_display = new WeakMap();
|
|
5586
|
-
_RenderElementBase_instances = new WeakSet();
|
|
5587
|
-
horizontalOffset_fn = function() {
|
|
5588
|
-
return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding2).Left + __privateGet(this, _padding2).Right;
|
|
5589
|
-
};
|
|
5590
|
-
verticalOffset_fn = function() {
|
|
5591
|
-
return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding2).Top + __privateGet(this, _padding2).Bottom;
|
|
5592
|
-
};
|
|
5593
|
-
totalTopOffset_fn = function() {
|
|
5594
|
-
return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding2).Top;
|
|
5595
|
-
};
|
|
5596
|
-
totalLeftOffset_fn = function() {
|
|
5597
|
-
return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding2).Left;
|
|
5598
|
-
};
|
|
5744
|
+
_notes = new WeakMap();
|
|
5745
|
+
_noteHovering = new WeakMap();
|
|
5746
|
+
_noteSelected = new WeakMap();
|
|
5747
|
+
_hoveringHandle = new WeakMap();
|
|
5748
|
+
_onNoteAddedCallbacks = new WeakMap();
|
|
5749
|
+
_onNoteRemovedCallbacks = new WeakMap();
|
|
5750
|
+
_onNoteDragStartCallbacks = new WeakMap();
|
|
5751
|
+
_onNoteDragStopCallbacks = new WeakMap();
|
|
5599
5752
|
|
|
5600
|
-
// src/
|
|
5601
|
-
var
|
|
5602
|
-
var
|
|
5603
|
-
constructor(
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
__privateAdd(this, _elements);
|
|
5607
|
-
__privateAdd(this, _layout);
|
|
5608
|
-
__privateAdd(this, _alignment);
|
|
5609
|
-
__privateSet(this, _elements, elements);
|
|
5610
|
-
__privateSet(this, _layout, "column" /* Column */);
|
|
5611
|
-
__privateSet(this, _alignment, "stretch" /* Stretch */);
|
|
5753
|
+
// src/pass/subsystem.ts
|
|
5754
|
+
var _queue;
|
|
5755
|
+
var PassSubsystem = class {
|
|
5756
|
+
constructor() {
|
|
5757
|
+
__privateAdd(this, _queue);
|
|
5758
|
+
__privateSet(this, _queue, new List());
|
|
5612
5759
|
}
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
const eleSize = { x: 0, y: 0 };
|
|
5617
|
-
switch (__privateGet(this, _layout)) {
|
|
5618
|
-
case "column" /* Column */:
|
|
5619
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5620
|
-
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
5621
|
-
out.x = Math.max(out.x, eleSize.x);
|
|
5622
|
-
out.y += eleSize.y;
|
|
5623
|
-
}
|
|
5624
|
-
break;
|
|
5625
|
-
case "row" /* Row */:
|
|
5626
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5627
|
-
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
5628
|
-
out.y = Math.max(out.y, eleSize.y);
|
|
5629
|
-
out.x += eleSize.x;
|
|
5630
|
-
}
|
|
5631
|
-
break;
|
|
5632
|
-
default:
|
|
5633
|
-
throw new Error("unknown layout: " + __privateGet(this, _layout));
|
|
5760
|
+
queue(lambda) {
|
|
5761
|
+
if (!lambda) {
|
|
5762
|
+
return;
|
|
5634
5763
|
}
|
|
5764
|
+
__privateGet(this, _queue).Push(lambda);
|
|
5635
5765
|
}
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
__privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
|
|
5640
|
-
break;
|
|
5641
|
-
default:
|
|
5642
|
-
throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
|
|
5766
|
+
render(ctx, camera, mousePosition) {
|
|
5767
|
+
for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
|
|
5768
|
+
__privateGet(this, _queue).At(i)();
|
|
5643
5769
|
}
|
|
5770
|
+
__privateGet(this, _queue).Clear();
|
|
5771
|
+
return;
|
|
5644
5772
|
}
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
_layout = new WeakMap();
|
|
5648
|
-
_alignment = new WeakMap();
|
|
5649
|
-
_ContainerRenderElement_instances = new WeakSet();
|
|
5650
|
-
renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
|
|
5651
|
-
const currnetPos = { x: position.x, y: position.y };
|
|
5652
|
-
const scaledEleSize = { x: 0, y: 0 };
|
|
5653
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5654
|
-
const ele = __privateGet(this, _elements)[i];
|
|
5655
|
-
ele.size(ctx, scaledEleSize);
|
|
5656
|
-
ScaleVector(scaledEleSize, graphScale);
|
|
5657
|
-
switch (__privateGet(this, _alignment)) {
|
|
5658
|
-
case "stretch" /* Stretch */:
|
|
5659
|
-
currnetPos.x = position.x;
|
|
5660
|
-
scaledEleSize.x = scaledFillableSpace.x;
|
|
5661
|
-
break;
|
|
5662
|
-
// I'm not sure if this is even needed, I feel like this should
|
|
5663
|
-
// already be the case.
|
|
5664
|
-
case "start" /* Start */:
|
|
5665
|
-
currnetPos.x = position.x;
|
|
5666
|
-
break;
|
|
5667
|
-
case "end" /* End */:
|
|
5668
|
-
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
|
|
5669
|
-
break;
|
|
5670
|
-
case "center" /* Center */:
|
|
5671
|
-
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
|
|
5672
|
-
break;
|
|
5673
|
-
default:
|
|
5674
|
-
throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
|
|
5675
|
-
}
|
|
5676
|
-
ele.render(ctx, currnetPos, graphScale, scaledEleSize);
|
|
5677
|
-
currnetPos.y += scaledEleSize.y;
|
|
5773
|
+
openContextMenu(ctx, position) {
|
|
5774
|
+
return null;
|
|
5678
5775
|
}
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
// src/elements/text.ts
|
|
5682
|
-
var _text7, _align, _verticalAlign;
|
|
5683
|
-
var TextElement = class extends RenderElementBase {
|
|
5684
|
-
constructor(text, styling) {
|
|
5685
|
-
var _a, _b;
|
|
5686
|
-
super(styling);
|
|
5687
|
-
__privateAdd(this, _text7);
|
|
5688
|
-
__privateAdd(this, _align);
|
|
5689
|
-
__privateAdd(this, _verticalAlign);
|
|
5690
|
-
__privateSet(this, _text7, text);
|
|
5691
|
-
__privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
|
|
5692
|
-
__privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
|
|
5776
|
+
clickStart(mousePosition, camera, ctrlKey) {
|
|
5777
|
+
return false;
|
|
5693
5778
|
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
this.calcSize(ctx, scale);
|
|
5697
|
-
ScaleVector(scale, graphScale);
|
|
5698
|
-
const justifiedPosition = Zero();
|
|
5699
|
-
CopyVector2(justifiedPosition, position);
|
|
5700
|
-
ctx.textAlign = "left";
|
|
5701
|
-
ctx.textBaseline = "top";
|
|
5702
|
-
switch (__privateGet(this, _align)) {
|
|
5703
|
-
case "left" /* Left */:
|
|
5704
|
-
break;
|
|
5705
|
-
case "right" /* Right */:
|
|
5706
|
-
justifiedPosition.x += scaledFillableSpace.x - scale.x;
|
|
5707
|
-
break;
|
|
5708
|
-
case "center" /* Center */:
|
|
5709
|
-
justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
|
|
5710
|
-
break;
|
|
5711
|
-
default:
|
|
5712
|
-
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
5713
|
-
}
|
|
5714
|
-
switch (__privateGet(this, _verticalAlign)) {
|
|
5715
|
-
case "top" /* Top */:
|
|
5716
|
-
break;
|
|
5717
|
-
case "bottom" /* Bottom */:
|
|
5718
|
-
justifiedPosition.y += scaledFillableSpace.y - scale.y;
|
|
5719
|
-
break;
|
|
5720
|
-
case "center" /* Center */:
|
|
5721
|
-
justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
|
|
5722
|
-
break;
|
|
5723
|
-
default:
|
|
5724
|
-
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
5725
|
-
}
|
|
5726
|
-
__privateGet(this, _text7).render(ctx, graphScale, justifiedPosition);
|
|
5779
|
+
mouseDragEvent(delta, scale) {
|
|
5780
|
+
return false;
|
|
5727
5781
|
}
|
|
5728
|
-
|
|
5729
|
-
|
|
5782
|
+
fileDrop(file) {
|
|
5783
|
+
return false;
|
|
5784
|
+
}
|
|
5785
|
+
clickEnd() {
|
|
5730
5786
|
}
|
|
5731
5787
|
};
|
|
5732
|
-
|
|
5733
|
-
_align = new WeakMap();
|
|
5734
|
-
_verticalAlign = new WeakMap();
|
|
5788
|
+
_queue = new WeakMap();
|
|
5735
5789
|
|
|
5736
5790
|
// src/quickMenu.ts
|
|
5737
5791
|
var _text8;
|