@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.js
CHANGED
|
@@ -786,6 +786,509 @@ up_fn = function(event) {
|
|
|
786
786
|
__privateGet(this, _clickStop).call(this);
|
|
787
787
|
};
|
|
788
788
|
|
|
789
|
+
// src/elements/interfaces.ts
|
|
790
|
+
function InstantiateRenderElementSidesStyling(config) {
|
|
791
|
+
if (typeof config === "number") {
|
|
792
|
+
return {
|
|
793
|
+
Bottom: config,
|
|
794
|
+
Right: config,
|
|
795
|
+
Top: config,
|
|
796
|
+
Left: config
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
return {
|
|
800
|
+
Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
|
|
801
|
+
Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
|
|
802
|
+
Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
|
|
803
|
+
Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// src/elements/base.ts
|
|
808
|
+
var _margin, _padding, _border, _backgroundColor, _minWidth, _maxWidth, _minHeight, _maxHeight, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
|
|
809
|
+
var RenderElementBase = class {
|
|
810
|
+
constructor(config) {
|
|
811
|
+
__privateAdd(this, _RenderElementBase_instances);
|
|
812
|
+
__privateAdd(this, _margin);
|
|
813
|
+
__privateAdd(this, _padding);
|
|
814
|
+
__privateAdd(this, _border);
|
|
815
|
+
__privateAdd(this, _backgroundColor);
|
|
816
|
+
__privateAdd(this, _minWidth);
|
|
817
|
+
__privateAdd(this, _maxWidth);
|
|
818
|
+
__privateAdd(this, _minHeight);
|
|
819
|
+
__privateAdd(this, _maxHeight);
|
|
820
|
+
__privateAdd(this, _grow);
|
|
821
|
+
__privateAdd(this, _display);
|
|
822
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
823
|
+
__privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
|
|
824
|
+
__privateSet(this, _padding, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
|
|
825
|
+
__privateSet(this, _backgroundColor, config == null ? void 0 : config.BackgroundColor);
|
|
826
|
+
__privateSet(this, _border, {
|
|
827
|
+
Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
|
|
828
|
+
Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
|
|
829
|
+
Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
|
|
830
|
+
});
|
|
831
|
+
__privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
|
|
832
|
+
__privateSet(this, _maxWidth, config == null ? void 0 : config.MaxWidth);
|
|
833
|
+
__privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
|
|
834
|
+
__privateSet(this, _maxHeight, config == null ? void 0 : config.MaxHeight);
|
|
835
|
+
__privateSet(this, _grow, config == null ? void 0 : config.Grow);
|
|
836
|
+
__privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
|
|
837
|
+
}
|
|
838
|
+
setBackgroundColor(newColor) {
|
|
839
|
+
__privateSet(this, _backgroundColor, newColor);
|
|
840
|
+
}
|
|
841
|
+
render(ctx, position, graphScale, scaledFillableSpace) {
|
|
842
|
+
if (__privateGet(this, _display) === "none" /* None */) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const scaledSize = { x: 0, y: 0 };
|
|
846
|
+
this.size(ctx, scaledSize);
|
|
847
|
+
scaledSize.x = scaledSize.x * graphScale;
|
|
848
|
+
scaledSize.y = scaledSize.y * graphScale;
|
|
849
|
+
scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
|
|
850
|
+
scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
|
|
851
|
+
if (__privateGet(this, _backgroundColor)) {
|
|
852
|
+
ctx.fillStyle = __privateGet(this, _backgroundColor);
|
|
853
|
+
ctx.beginPath();
|
|
854
|
+
ctx.roundRect(
|
|
855
|
+
position.x + __privateGet(this, _margin).Left * graphScale,
|
|
856
|
+
position.y + __privateGet(this, _margin).Right * graphScale,
|
|
857
|
+
scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
|
|
858
|
+
scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
|
|
859
|
+
__privateGet(this, _border).Radius * graphScale
|
|
860
|
+
);
|
|
861
|
+
ctx.fill();
|
|
862
|
+
}
|
|
863
|
+
if (__privateGet(this, _border).Thickness > 0) {
|
|
864
|
+
ctx.lineWidth = __privateGet(this, _border).Thickness * graphScale;
|
|
865
|
+
ctx.strokeStyle = __privateGet(this, _border).Color;
|
|
866
|
+
ctx.stroke();
|
|
867
|
+
}
|
|
868
|
+
const offsetPosition = {
|
|
869
|
+
x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
|
|
870
|
+
y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
|
|
871
|
+
};
|
|
872
|
+
const elementSize = {
|
|
873
|
+
x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
|
|
874
|
+
y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
|
|
875
|
+
};
|
|
876
|
+
this.doRender(ctx, offsetPosition, graphScale, elementSize);
|
|
877
|
+
}
|
|
878
|
+
maxLimitations(out) {
|
|
879
|
+
out.x = -1;
|
|
880
|
+
out.y = -1;
|
|
881
|
+
if (__privateGet(this, _maxWidth)) {
|
|
882
|
+
out.x = __privateGet(this, _maxWidth);
|
|
883
|
+
}
|
|
884
|
+
if (__privateGet(this, _maxHeight)) {
|
|
885
|
+
out.y = __privateGet(this, _maxHeight);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
setDisplay(display) {
|
|
889
|
+
__privateSet(this, _display, display);
|
|
890
|
+
}
|
|
891
|
+
getDisplay() {
|
|
892
|
+
return __privateGet(this, _display);
|
|
893
|
+
}
|
|
894
|
+
size(ctx, out) {
|
|
895
|
+
out.x = 0;
|
|
896
|
+
out.y = 0;
|
|
897
|
+
if (__privateGet(this, _display) === "none" /* None */) {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
const maxLimits = { x: -1, y: -1 };
|
|
901
|
+
this.maxLimitations(maxLimits);
|
|
902
|
+
this.calcSize(ctx, out, maxLimits);
|
|
903
|
+
out.x += __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this);
|
|
904
|
+
out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
|
|
905
|
+
if (__privateGet(this, _minWidth)) {
|
|
906
|
+
out.x = Math.max(out.x, __privateGet(this, _minWidth));
|
|
907
|
+
}
|
|
908
|
+
if (__privateGet(this, _maxWidth)) {
|
|
909
|
+
out.x = Math.min(__privateGet(this, _maxWidth), out.x);
|
|
910
|
+
}
|
|
911
|
+
if (__privateGet(this, _maxHeight)) {
|
|
912
|
+
out.y = Math.min(__privateGet(this, _maxHeight), out.y);
|
|
913
|
+
}
|
|
914
|
+
if (__privateGet(this, _minHeight)) {
|
|
915
|
+
out.y = Math.max(__privateGet(this, _minHeight), out.y);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
_margin = new WeakMap();
|
|
920
|
+
_padding = new WeakMap();
|
|
921
|
+
_border = new WeakMap();
|
|
922
|
+
_backgroundColor = new WeakMap();
|
|
923
|
+
_minWidth = new WeakMap();
|
|
924
|
+
_maxWidth = new WeakMap();
|
|
925
|
+
_minHeight = new WeakMap();
|
|
926
|
+
_maxHeight = new WeakMap();
|
|
927
|
+
_grow = new WeakMap();
|
|
928
|
+
_display = new WeakMap();
|
|
929
|
+
_RenderElementBase_instances = new WeakSet();
|
|
930
|
+
horizontalOffset_fn = function() {
|
|
931
|
+
return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding).Left + __privateGet(this, _padding).Right;
|
|
932
|
+
};
|
|
933
|
+
verticalOffset_fn = function() {
|
|
934
|
+
return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding).Top + __privateGet(this, _padding).Bottom;
|
|
935
|
+
};
|
|
936
|
+
totalTopOffset_fn = function() {
|
|
937
|
+
return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding).Top;
|
|
938
|
+
};
|
|
939
|
+
totalLeftOffset_fn = function() {
|
|
940
|
+
return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding).Left;
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
// src/elements/container.ts
|
|
944
|
+
var _elements, _layout, _alignment, _ContainerRenderElement_instances, renderColumn_fn;
|
|
945
|
+
var ContainerRenderElement = class extends RenderElementBase {
|
|
946
|
+
constructor(elements, config) {
|
|
947
|
+
super(config);
|
|
948
|
+
__privateAdd(this, _ContainerRenderElement_instances);
|
|
949
|
+
__privateAdd(this, _elements);
|
|
950
|
+
__privateAdd(this, _layout);
|
|
951
|
+
__privateAdd(this, _alignment);
|
|
952
|
+
__privateSet(this, _elements, elements);
|
|
953
|
+
__privateSet(this, _layout, "column" /* Column */);
|
|
954
|
+
__privateSet(this, _alignment, "stretch" /* Stretch */);
|
|
955
|
+
}
|
|
956
|
+
calcSize(ctx, out, limitations) {
|
|
957
|
+
out.x = 0;
|
|
958
|
+
out.y = 0;
|
|
959
|
+
const eleSize = { x: 0, y: 0 };
|
|
960
|
+
switch (__privateGet(this, _layout)) {
|
|
961
|
+
case "column" /* Column */:
|
|
962
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
963
|
+
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
964
|
+
out.x = Math.max(out.x, eleSize.x);
|
|
965
|
+
out.y += eleSize.y;
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
case "row" /* Row */:
|
|
969
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
970
|
+
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
971
|
+
out.y = Math.max(out.y, eleSize.y);
|
|
972
|
+
out.x += eleSize.x;
|
|
973
|
+
}
|
|
974
|
+
break;
|
|
975
|
+
default:
|
|
976
|
+
throw new Error("unknown layout: " + __privateGet(this, _layout));
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
doRender(ctx, position, graphScale, scaledFillableSpace) {
|
|
980
|
+
switch (__privateGet(this, _layout)) {
|
|
981
|
+
case "column" /* Column */:
|
|
982
|
+
__privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
|
|
983
|
+
break;
|
|
984
|
+
default:
|
|
985
|
+
throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
_elements = new WeakMap();
|
|
990
|
+
_layout = new WeakMap();
|
|
991
|
+
_alignment = new WeakMap();
|
|
992
|
+
_ContainerRenderElement_instances = new WeakSet();
|
|
993
|
+
renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
|
|
994
|
+
const currnetPos = { x: position.x, y: position.y };
|
|
995
|
+
const scaledEleSize = { x: 0, y: 0 };
|
|
996
|
+
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
997
|
+
const ele = __privateGet(this, _elements)[i];
|
|
998
|
+
ele.size(ctx, scaledEleSize);
|
|
999
|
+
ScaleVector(scaledEleSize, graphScale);
|
|
1000
|
+
switch (__privateGet(this, _alignment)) {
|
|
1001
|
+
case "stretch" /* Stretch */:
|
|
1002
|
+
currnetPos.x = position.x;
|
|
1003
|
+
scaledEleSize.x = scaledFillableSpace.x;
|
|
1004
|
+
break;
|
|
1005
|
+
// I'm not sure if this is even needed, I feel like this should
|
|
1006
|
+
// already be the case.
|
|
1007
|
+
case "start" /* Start */:
|
|
1008
|
+
currnetPos.x = position.x;
|
|
1009
|
+
break;
|
|
1010
|
+
case "end" /* End */:
|
|
1011
|
+
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
|
|
1012
|
+
break;
|
|
1013
|
+
case "center" /* Center */:
|
|
1014
|
+
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
|
|
1015
|
+
break;
|
|
1016
|
+
default:
|
|
1017
|
+
throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
|
|
1018
|
+
}
|
|
1019
|
+
ele.render(ctx, currnetPos, graphScale, scaledEleSize);
|
|
1020
|
+
currnetPos.y += scaledEleSize.y;
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
// src/elements/text.ts
|
|
1025
|
+
var _text, _align, _verticalAlign, _lineHeight;
|
|
1026
|
+
var TextElement = class extends RenderElementBase {
|
|
1027
|
+
constructor(text, styling) {
|
|
1028
|
+
var _a, _b, _c;
|
|
1029
|
+
super(styling);
|
|
1030
|
+
__privateAdd(this, _text);
|
|
1031
|
+
__privateAdd(this, _align);
|
|
1032
|
+
__privateAdd(this, _verticalAlign);
|
|
1033
|
+
__privateAdd(this, _lineHeight);
|
|
1034
|
+
__privateSet(this, _text, text);
|
|
1035
|
+
__privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
|
|
1036
|
+
__privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
|
|
1037
|
+
__privateSet(this, _lineHeight, (_c = styling == null ? void 0 : styling.LineHeight) != null ? _c : 1);
|
|
1038
|
+
}
|
|
1039
|
+
doRender(ctx, position, graphScale, scaledFillableSpace) {
|
|
1040
|
+
const scale = Zero();
|
|
1041
|
+
this.calcSize(ctx, scale, scaledFillableSpace);
|
|
1042
|
+
ScaleVector(scale, graphScale);
|
|
1043
|
+
const justifiedPosition = Zero();
|
|
1044
|
+
CopyVector2(justifiedPosition, position);
|
|
1045
|
+
ctx.textAlign = "left";
|
|
1046
|
+
ctx.textBaseline = "top";
|
|
1047
|
+
switch (__privateGet(this, _align)) {
|
|
1048
|
+
case "left" /* Left */:
|
|
1049
|
+
break;
|
|
1050
|
+
case "right" /* Right */:
|
|
1051
|
+
justifiedPosition.x += scaledFillableSpace.x - scale.x;
|
|
1052
|
+
break;
|
|
1053
|
+
case "center" /* Center */:
|
|
1054
|
+
justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
|
|
1055
|
+
break;
|
|
1056
|
+
default:
|
|
1057
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1058
|
+
}
|
|
1059
|
+
switch (__privateGet(this, _verticalAlign)) {
|
|
1060
|
+
case "top" /* Top */:
|
|
1061
|
+
break;
|
|
1062
|
+
case "bottom" /* Bottom */:
|
|
1063
|
+
justifiedPosition.y += scaledFillableSpace.y - scale.y;
|
|
1064
|
+
break;
|
|
1065
|
+
case "center" /* Center */:
|
|
1066
|
+
justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
|
|
1067
|
+
break;
|
|
1068
|
+
default:
|
|
1069
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1070
|
+
}
|
|
1071
|
+
if (scaledFillableSpace.x <= 0) {
|
|
1072
|
+
__privateGet(this, _text).render(ctx, graphScale, justifiedPosition);
|
|
1073
|
+
} else {
|
|
1074
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, scaledFillableSpace.x);
|
|
1075
|
+
const tempSize = { x: 0, y: 0 };
|
|
1076
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1077
|
+
eles[i].render(ctx, graphScale, justifiedPosition);
|
|
1078
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1079
|
+
justifiedPosition.y += __privateGet(this, _text).style().getSize() * __privateGet(this, _lineHeight);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
calcSize(ctx, out, limitations) {
|
|
1084
|
+
if (limitations.x <= 0) {
|
|
1085
|
+
__privateGet(this, _text).size(ctx, 1, out);
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, limitations.x);
|
|
1089
|
+
const tempSize = { x: 0, y: 0 };
|
|
1090
|
+
out.x = 0;
|
|
1091
|
+
out.y = __privateGet(this, _text).style().getSize() * eles.length * __privateGet(this, _lineHeight);
|
|
1092
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1093
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1094
|
+
out.x = Math.max(tempSize.x, out.x);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
_text = new WeakMap();
|
|
1099
|
+
_align = new WeakMap();
|
|
1100
|
+
_verticalAlign = new WeakMap();
|
|
1101
|
+
_lineHeight = new WeakMap();
|
|
1102
|
+
|
|
1103
|
+
// src/utils/string.ts
|
|
1104
|
+
var binarySearch = ({ max, getValue, match }) => {
|
|
1105
|
+
let min = 0;
|
|
1106
|
+
while (min <= max) {
|
|
1107
|
+
let guess = Math.floor((min + max) / 2);
|
|
1108
|
+
const compareVal = getValue(guess);
|
|
1109
|
+
if (compareVal === match) return guess;
|
|
1110
|
+
if (compareVal < match) min = guess + 1;
|
|
1111
|
+
else max = guess - 1;
|
|
1112
|
+
}
|
|
1113
|
+
return max;
|
|
1114
|
+
};
|
|
1115
|
+
function fitString(ctx, str, maxWidth) {
|
|
1116
|
+
let width2 = ctx.measureText(str).width;
|
|
1117
|
+
const ellipsis = "\u2026";
|
|
1118
|
+
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
1119
|
+
if (width2 <= maxWidth || width2 <= ellipsisWidth) {
|
|
1120
|
+
return str;
|
|
1121
|
+
}
|
|
1122
|
+
const index = binarySearch({
|
|
1123
|
+
max: str.length,
|
|
1124
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1125
|
+
match: maxWidth - ellipsisWidth
|
|
1126
|
+
});
|
|
1127
|
+
return str.substring(0, index) + ellipsis;
|
|
1128
|
+
}
|
|
1129
|
+
function splitString(ctx, str, maxWidth) {
|
|
1130
|
+
let width2 = ctx.measureText(str).width;
|
|
1131
|
+
if (width2 <= maxWidth) {
|
|
1132
|
+
return [str];
|
|
1133
|
+
}
|
|
1134
|
+
let index = binarySearch({
|
|
1135
|
+
max: str.length,
|
|
1136
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1137
|
+
match: maxWidth
|
|
1138
|
+
});
|
|
1139
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1140
|
+
if (str.charAt(backward) === " ") {
|
|
1141
|
+
index = backward + 1;
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return [str.substring(0, index), str.substring(index)];
|
|
1146
|
+
}
|
|
1147
|
+
function splitStringIntoLines(ctx, str, maxWidth) {
|
|
1148
|
+
let width2 = ctx.measureText(str).width;
|
|
1149
|
+
if (width2 <= maxWidth) {
|
|
1150
|
+
return [str];
|
|
1151
|
+
}
|
|
1152
|
+
const strings = new Array();
|
|
1153
|
+
let remaining = str;
|
|
1154
|
+
while (remaining !== "") {
|
|
1155
|
+
let index = binarySearch({
|
|
1156
|
+
max: remaining.length,
|
|
1157
|
+
getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
1158
|
+
match: maxWidth
|
|
1159
|
+
});
|
|
1160
|
+
if (index === remaining.length) {
|
|
1161
|
+
strings.push(remaining.substring(0, index));
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1165
|
+
if (remaining.charAt(backward) === " ") {
|
|
1166
|
+
index = backward + 1;
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
strings.push(remaining.substring(0, index));
|
|
1171
|
+
remaining = remaining.substring(index);
|
|
1172
|
+
}
|
|
1173
|
+
return strings;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// src/types/text.ts
|
|
1177
|
+
var _measured, _size2, _style, _value, _Text_instances, measure_fn;
|
|
1178
|
+
var _Text = class _Text {
|
|
1179
|
+
constructor(value, style) {
|
|
1180
|
+
__privateAdd(this, _Text_instances);
|
|
1181
|
+
__privateAdd(this, _measured);
|
|
1182
|
+
__privateAdd(this, _size2);
|
|
1183
|
+
__privateAdd(this, _style);
|
|
1184
|
+
__privateAdd(this, _value);
|
|
1185
|
+
__privateSet(this, _value, value);
|
|
1186
|
+
__privateSet(this, _measured, false);
|
|
1187
|
+
__privateSet(this, _size2, Zero());
|
|
1188
|
+
__privateSet(this, _style, new TextStyle(style));
|
|
1189
|
+
if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
|
|
1190
|
+
document.fonts.addEventListener("loadingdone", (event) => {
|
|
1191
|
+
__privateSet(this, _measured, false);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
set(newValue) {
|
|
1196
|
+
__privateSet(this, _value, newValue);
|
|
1197
|
+
__privateSet(this, _measured, false);
|
|
1198
|
+
}
|
|
1199
|
+
get() {
|
|
1200
|
+
return __privateGet(this, _value);
|
|
1201
|
+
}
|
|
1202
|
+
breakIntoLines(ctx, maxWidth) {
|
|
1203
|
+
const results = new Array();
|
|
1204
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1205
|
+
const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
|
|
1206
|
+
if (entries.length === 1) {
|
|
1207
|
+
return [this];
|
|
1208
|
+
}
|
|
1209
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1210
|
+
const text = new _Text(entries[i]);
|
|
1211
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1212
|
+
results.push(text);
|
|
1213
|
+
}
|
|
1214
|
+
return results;
|
|
1215
|
+
}
|
|
1216
|
+
split(char) {
|
|
1217
|
+
const entries = __privateGet(this, _value).split(char);
|
|
1218
|
+
const results = new Array();
|
|
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
|
+
splitAtIndex(index) {
|
|
1227
|
+
const results = [
|
|
1228
|
+
new _Text(__privateGet(this, _value).substring(0, index)),
|
|
1229
|
+
new _Text(__privateGet(this, _value).substring(index, 0))
|
|
1230
|
+
];
|
|
1231
|
+
for (let i = 0; i < results.length; i++) {
|
|
1232
|
+
__privateSet(results[i], _style, __privateGet(this, _style));
|
|
1233
|
+
}
|
|
1234
|
+
return results;
|
|
1235
|
+
}
|
|
1236
|
+
splitAtWidth(ctx, maxWidth) {
|
|
1237
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1238
|
+
const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
|
|
1239
|
+
if (entries.length === 1) {
|
|
1240
|
+
return [this];
|
|
1241
|
+
}
|
|
1242
|
+
const results = new Array();
|
|
1243
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1244
|
+
const text = new _Text(entries[i]);
|
|
1245
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1246
|
+
results.push(text);
|
|
1247
|
+
}
|
|
1248
|
+
return results;
|
|
1249
|
+
}
|
|
1250
|
+
size(ctx, scale, out) {
|
|
1251
|
+
__privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
|
|
1252
|
+
CopyVector2(out, __privateGet(this, _size2));
|
|
1253
|
+
ScaleVector(out, scale);
|
|
1254
|
+
}
|
|
1255
|
+
setColor(color) {
|
|
1256
|
+
__privateGet(this, _style).setColor(color);
|
|
1257
|
+
}
|
|
1258
|
+
getColor() {
|
|
1259
|
+
return __privateGet(this, _style).getColor();
|
|
1260
|
+
}
|
|
1261
|
+
setSize(size) {
|
|
1262
|
+
__privateGet(this, _style).setSize(size);
|
|
1263
|
+
}
|
|
1264
|
+
setWeight(weight) {
|
|
1265
|
+
__privateGet(this, _style).setWeight(weight);
|
|
1266
|
+
}
|
|
1267
|
+
render(ctx, scale, position) {
|
|
1268
|
+
__privateGet(this, _style).setupStyle(ctx, scale);
|
|
1269
|
+
ctx.fillText(__privateGet(this, _value), position.x, position.y);
|
|
1270
|
+
}
|
|
1271
|
+
style() {
|
|
1272
|
+
return __privateGet(this, _style);
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
_measured = new WeakMap();
|
|
1276
|
+
_size2 = new WeakMap();
|
|
1277
|
+
_style = new WeakMap();
|
|
1278
|
+
_value = new WeakMap();
|
|
1279
|
+
_Text_instances = new WeakSet();
|
|
1280
|
+
measure_fn = function(ctx) {
|
|
1281
|
+
if (__privateGet(this, _measured)) {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1285
|
+
const measurements = ctx.measureText(__privateGet(this, _value));
|
|
1286
|
+
__privateGet(this, _size2).x = measurements.width;
|
|
1287
|
+
__privateGet(this, _size2).y = measurements.actualBoundingBoxAscent + measurements.actualBoundingBoxDescent;
|
|
1288
|
+
__privateSet(this, _measured, true);
|
|
1289
|
+
};
|
|
1290
|
+
var Text = _Text;
|
|
1291
|
+
|
|
789
1292
|
// src/utils/math.ts
|
|
790
1293
|
function Clamp(v, min, max) {
|
|
791
1294
|
return Math.min(Math.max(v, min), max);
|
|
@@ -878,7 +1381,7 @@ function fallbackColor(type, s) {
|
|
|
878
1381
|
HSV2RGB(hsv, color);
|
|
879
1382
|
return RgbToHex(color);
|
|
880
1383
|
}
|
|
881
|
-
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
1384
|
+
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _dataTypePopupElement, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
882
1385
|
var Port = class {
|
|
883
1386
|
constructor(node, portType, config) {
|
|
884
1387
|
__privateAdd(this, _node);
|
|
@@ -888,6 +1391,7 @@ var Port = class {
|
|
|
888
1391
|
__privateAdd(this, _connections);
|
|
889
1392
|
__privateAdd(this, _portType);
|
|
890
1393
|
__privateAdd(this, _dataType);
|
|
1394
|
+
__privateAdd(this, _dataTypePopupElement);
|
|
891
1395
|
__privateAdd(this, _onConnectionAdded);
|
|
892
1396
|
__privateAdd(this, _onConnectionRemoved);
|
|
893
1397
|
__privateAdd(this, _box, { Position: { x: 0, y: 0 }, Size: { x: 0, y: 0 } });
|
|
@@ -917,6 +1421,41 @@ var Port = class {
|
|
|
917
1421
|
if (config == null ? void 0 : config.onConnectionRemoved) {
|
|
918
1422
|
__privateGet(this, _onConnectionRemoved).push(config == null ? void 0 : config.onConnectionRemoved);
|
|
919
1423
|
}
|
|
1424
|
+
const containerElements = new Array();
|
|
1425
|
+
let dataTypeDisplay = __privateGet(this, _dataType);
|
|
1426
|
+
if ((config == null ? void 0 : config.array) === true) {
|
|
1427
|
+
dataTypeDisplay = "Array<" + dataTypeDisplay + ">";
|
|
1428
|
+
}
|
|
1429
|
+
containerElements.push(new TextElement(
|
|
1430
|
+
new Text(dataTypeDisplay, {
|
|
1431
|
+
color: "white"
|
|
1432
|
+
}),
|
|
1433
|
+
{
|
|
1434
|
+
Align: "center" /* Center */
|
|
1435
|
+
}
|
|
1436
|
+
));
|
|
1437
|
+
const description = config == null ? void 0 : config.description;
|
|
1438
|
+
if (description && description !== "") {
|
|
1439
|
+
containerElements.push(new TextElement(
|
|
1440
|
+
new Text(description, { color: "white", style: "italic" /* Italic */ }),
|
|
1441
|
+
{
|
|
1442
|
+
Align: "center" /* Center */,
|
|
1443
|
+
Padding: { Top: 16 },
|
|
1444
|
+
MaxWidth: 400,
|
|
1445
|
+
LineHeight: 1.5
|
|
1446
|
+
}
|
|
1447
|
+
));
|
|
1448
|
+
}
|
|
1449
|
+
__privateSet(this, _dataTypePopupElement, new ContainerRenderElement(
|
|
1450
|
+
containerElements,
|
|
1451
|
+
{
|
|
1452
|
+
BackgroundColor: "rgba(0, 0, 0, 0.75)",
|
|
1453
|
+
Border: {
|
|
1454
|
+
Radius: 6
|
|
1455
|
+
},
|
|
1456
|
+
Padding: 13
|
|
1457
|
+
}
|
|
1458
|
+
));
|
|
920
1459
|
}
|
|
921
1460
|
addConnection(connection) {
|
|
922
1461
|
const c = __privateGet(this, _connections).length;
|
|
@@ -985,16 +1524,9 @@ var Port = class {
|
|
|
985
1524
|
const xPos = position.x;
|
|
986
1525
|
const yPos = position.y;
|
|
987
1526
|
postProcess.queue(() => {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const w = measurement.width + padding * camera.zoom;
|
|
992
|
-
ctx.beginPath();
|
|
993
|
-
ctx.fillStyle = "rgba(0, 0, 0, 0.75)";
|
|
994
|
-
ctx.roundRect(xPos - w / 2, yPos + scaledRadius * 3 - padding * camera.zoom, w, padding * 2 * camera.zoom, 4 * camera.zoom);
|
|
995
|
-
ctx.fill();
|
|
996
|
-
ctx.fillStyle = "#FFFFFF";
|
|
997
|
-
ctx.fillText(__privateGet(this, _dataType), xPos, yPos + scaledRadius * 3);
|
|
1527
|
+
const size = { x: 0, y: 0 };
|
|
1528
|
+
__privateGet(this, _dataTypePopupElement).calcSize(ctx, size, { x: -1, y: -1 });
|
|
1529
|
+
__privateGet(this, _dataTypePopupElement).render(ctx, { x: xPos - size.x / 2, y: yPos }, 1, size);
|
|
998
1530
|
});
|
|
999
1531
|
}
|
|
1000
1532
|
__privateGet(this, _box).Position.x = position.x - scaledRadius;
|
|
@@ -1021,6 +1553,7 @@ _filledStyle = new WeakMap();
|
|
|
1021
1553
|
_connections = new WeakMap();
|
|
1022
1554
|
_portType = new WeakMap();
|
|
1023
1555
|
_dataType = new WeakMap();
|
|
1556
|
+
_dataTypePopupElement = new WeakMap();
|
|
1024
1557
|
_onConnectionAdded = new WeakMap();
|
|
1025
1558
|
_onConnectionRemoved = new WeakMap();
|
|
1026
1559
|
_box = new WeakMap();
|
|
@@ -1032,29 +1565,29 @@ function StrokeStyleWithFallback(input, fallback) {
|
|
|
1032
1565
|
size: (input == null ? void 0 : input.size) === void 0 ? fallback == null ? void 0 : fallback.size : input == null ? void 0 : input.size
|
|
1033
1566
|
};
|
|
1034
1567
|
}
|
|
1035
|
-
var
|
|
1568
|
+
var _size3, _color2;
|
|
1036
1569
|
var StrokeStyle = class {
|
|
1037
1570
|
constructor(config) {
|
|
1038
|
-
__privateAdd(this,
|
|
1571
|
+
__privateAdd(this, _size3);
|
|
1039
1572
|
__privateAdd(this, _color2);
|
|
1040
|
-
__privateSet(this,
|
|
1573
|
+
__privateSet(this, _size3, (config == null ? void 0 : config.size) === void 0 ? 0.5 : config.size);
|
|
1041
1574
|
__privateSet(this, _color2, (config == null ? void 0 : config.color) === void 0 ? "black" : config.color);
|
|
1042
1575
|
}
|
|
1043
1576
|
setupStyle(ctx, scale) {
|
|
1044
1577
|
ctx.strokeStyle = __privateGet(this, _color2);
|
|
1045
|
-
ctx.lineWidth = scale * __privateGet(this,
|
|
1578
|
+
ctx.lineWidth = scale * __privateGet(this, _size3);
|
|
1046
1579
|
}
|
|
1047
1580
|
setColor(newColor) {
|
|
1048
1581
|
__privateSet(this, _color2, newColor);
|
|
1049
1582
|
}
|
|
1050
1583
|
setSize(newSize) {
|
|
1051
|
-
__privateSet(this,
|
|
1584
|
+
__privateSet(this, _size3, newSize);
|
|
1052
1585
|
}
|
|
1053
1586
|
size() {
|
|
1054
|
-
return __privateGet(this,
|
|
1587
|
+
return __privateGet(this, _size3);
|
|
1055
1588
|
}
|
|
1056
1589
|
};
|
|
1057
|
-
|
|
1590
|
+
_size3 = new WeakMap();
|
|
1058
1591
|
_color2 = new WeakMap();
|
|
1059
1592
|
|
|
1060
1593
|
// src/styles/box.ts
|
|
@@ -1065,20 +1598,20 @@ function BoxStyleWithFallback(input, fallback) {
|
|
|
1065
1598
|
border: StrokeStyleWithFallback(input == null ? void 0 : input.border, fallback == null ? void 0 : fallback.border)
|
|
1066
1599
|
};
|
|
1067
1600
|
}
|
|
1068
|
-
var
|
|
1601
|
+
var _border2, _color3, _radius, _BoxStyle_instances, box_fn, draw_fn;
|
|
1069
1602
|
var BoxStyle = class {
|
|
1070
1603
|
constructor(config) {
|
|
1071
1604
|
__privateAdd(this, _BoxStyle_instances);
|
|
1072
|
-
__privateAdd(this,
|
|
1605
|
+
__privateAdd(this, _border2);
|
|
1073
1606
|
__privateAdd(this, _color3);
|
|
1074
1607
|
__privateAdd(this, _radius);
|
|
1075
1608
|
__privateSet(this, _color3, (config == null ? void 0 : config.color) === void 0 ? "#CCCCCC" : config.color);
|
|
1076
|
-
__privateSet(this,
|
|
1609
|
+
__privateSet(this, _border2, (config == null ? void 0 : config.border) === void 0 ? null : new StrokeStyle(config.border));
|
|
1077
1610
|
__privateSet(this, _radius, (config == null ? void 0 : config.radius) === void 0 ? 2 : config.radius);
|
|
1078
1611
|
}
|
|
1079
1612
|
Outline(ctx, box, scale, radius) {
|
|
1080
1613
|
var _a;
|
|
1081
|
-
(_a = __privateGet(this,
|
|
1614
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1082
1615
|
ctx.beginPath();
|
|
1083
1616
|
ctx.roundRect(
|
|
1084
1617
|
box.Position.x,
|
|
@@ -1103,238 +1636,49 @@ var BoxStyle = class {
|
|
|
1103
1636
|
ctx.stroke();
|
|
1104
1637
|
}
|
|
1105
1638
|
borderSize() {
|
|
1106
|
-
if (__privateGet(this,
|
|
1639
|
+
if (__privateGet(this, _border2) === null) {
|
|
1107
1640
|
return 0;
|
|
1108
1641
|
}
|
|
1109
|
-
return __privateGet(this,
|
|
1642
|
+
return __privateGet(this, _border2).size();
|
|
1110
1643
|
}
|
|
1111
1644
|
radius() {
|
|
1112
1645
|
return __privateGet(this, _radius);
|
|
1113
1646
|
}
|
|
1114
1647
|
setColor(color) {
|
|
1115
|
-
__privateSet(this, _color3, color);
|
|
1116
|
-
}
|
|
1117
|
-
setBorderColor(color) {
|
|
1118
|
-
if (__privateGet(this, _border) === null) {
|
|
1119
|
-
__privateSet(this, _border, new StrokeStyle({
|
|
1120
|
-
color
|
|
1121
|
-
}));
|
|
1122
|
-
} else {
|
|
1123
|
-
__privateGet(this, _border).setColor(color);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
_border = new WeakMap();
|
|
1128
|
-
_color3 = new WeakMap();
|
|
1129
|
-
_radius = new WeakMap();
|
|
1130
|
-
_BoxStyle_instances = new WeakSet();
|
|
1131
|
-
box_fn = function(ctx, box, scale, radius) {
|
|
1132
|
-
var _a;
|
|
1133
|
-
ctx.fillStyle = __privateGet(this, _color3);
|
|
1134
|
-
(_a = __privateGet(this, _border)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1135
|
-
ctx.beginPath();
|
|
1136
|
-
ctx.roundRect(
|
|
1137
|
-
box.Position.x,
|
|
1138
|
-
box.Position.y,
|
|
1139
|
-
box.Size.x,
|
|
1140
|
-
box.Size.y,
|
|
1141
|
-
radius
|
|
1142
|
-
);
|
|
1143
|
-
ctx.fill();
|
|
1144
|
-
};
|
|
1145
|
-
draw_fn = function(ctx, box, scale, radius) {
|
|
1146
|
-
__privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
|
|
1147
|
-
ctx.stroke();
|
|
1148
|
-
};
|
|
1149
|
-
|
|
1150
|
-
// src/utils/string.ts
|
|
1151
|
-
var binarySearch = ({ max, getValue, match }) => {
|
|
1152
|
-
let min = 0;
|
|
1153
|
-
while (min <= max) {
|
|
1154
|
-
let guess = Math.floor((min + max) / 2);
|
|
1155
|
-
const compareVal = getValue(guess);
|
|
1156
|
-
if (compareVal === match) return guess;
|
|
1157
|
-
if (compareVal < match) min = guess + 1;
|
|
1158
|
-
else max = guess - 1;
|
|
1159
|
-
}
|
|
1160
|
-
return max;
|
|
1161
|
-
};
|
|
1162
|
-
function fitString(ctx, str, maxWidth) {
|
|
1163
|
-
let width2 = ctx.measureText(str).width;
|
|
1164
|
-
const ellipsis = "\u2026";
|
|
1165
|
-
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
1166
|
-
if (width2 <= maxWidth || width2 <= ellipsisWidth) {
|
|
1167
|
-
return str;
|
|
1168
|
-
}
|
|
1169
|
-
const index = binarySearch({
|
|
1170
|
-
max: str.length,
|
|
1171
|
-
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1172
|
-
match: maxWidth - ellipsisWidth
|
|
1173
|
-
});
|
|
1174
|
-
return str.substring(0, index) + ellipsis;
|
|
1175
|
-
}
|
|
1176
|
-
function splitString(ctx, str, maxWidth) {
|
|
1177
|
-
let width2 = ctx.measureText(str).width;
|
|
1178
|
-
if (width2 <= maxWidth) {
|
|
1179
|
-
return [str];
|
|
1180
|
-
}
|
|
1181
|
-
let index = binarySearch({
|
|
1182
|
-
max: str.length,
|
|
1183
|
-
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1184
|
-
match: maxWidth
|
|
1185
|
-
});
|
|
1186
|
-
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1187
|
-
if (str.charAt(backward) === " ") {
|
|
1188
|
-
index = backward + 1;
|
|
1189
|
-
break;
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
return [str.substring(0, index), str.substring(index)];
|
|
1193
|
-
}
|
|
1194
|
-
function splitStringIntoLines(ctx, str, maxWidth) {
|
|
1195
|
-
let width2 = ctx.measureText(str).width;
|
|
1196
|
-
if (width2 <= maxWidth) {
|
|
1197
|
-
return [str];
|
|
1198
|
-
}
|
|
1199
|
-
const strings = new Array();
|
|
1200
|
-
let remaining = str;
|
|
1201
|
-
while (remaining !== "") {
|
|
1202
|
-
let index = binarySearch({
|
|
1203
|
-
max: remaining.length,
|
|
1204
|
-
getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
1205
|
-
match: maxWidth
|
|
1206
|
-
});
|
|
1207
|
-
if (index === remaining.length) {
|
|
1208
|
-
strings.push(remaining.substring(0, index));
|
|
1209
|
-
break;
|
|
1210
|
-
}
|
|
1211
|
-
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1212
|
-
if (remaining.charAt(backward) === " ") {
|
|
1213
|
-
index = backward + 1;
|
|
1214
|
-
break;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
strings.push(remaining.substring(0, index));
|
|
1218
|
-
remaining = remaining.substring(index);
|
|
1219
|
-
}
|
|
1220
|
-
return strings;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
// src/types/text.ts
|
|
1224
|
-
var _measured, _size3, _style, _value, _Text_instances, measure_fn;
|
|
1225
|
-
var _Text = class _Text {
|
|
1226
|
-
constructor(value, style) {
|
|
1227
|
-
__privateAdd(this, _Text_instances);
|
|
1228
|
-
__privateAdd(this, _measured);
|
|
1229
|
-
__privateAdd(this, _size3);
|
|
1230
|
-
__privateAdd(this, _style);
|
|
1231
|
-
__privateAdd(this, _value);
|
|
1232
|
-
__privateSet(this, _value, value);
|
|
1233
|
-
__privateSet(this, _measured, false);
|
|
1234
|
-
__privateSet(this, _size3, Zero());
|
|
1235
|
-
__privateSet(this, _style, new TextStyle(style));
|
|
1236
|
-
if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
|
|
1237
|
-
document.fonts.addEventListener("loadingdone", (event) => {
|
|
1238
|
-
__privateSet(this, _measured, false);
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
set(newValue) {
|
|
1243
|
-
__privateSet(this, _value, newValue);
|
|
1244
|
-
__privateSet(this, _measured, false);
|
|
1245
|
-
}
|
|
1246
|
-
get() {
|
|
1247
|
-
return __privateGet(this, _value);
|
|
1248
|
-
}
|
|
1249
|
-
breakIntoLines(ctx, maxWidth) {
|
|
1250
|
-
const results = new Array();
|
|
1251
|
-
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1252
|
-
const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
|
|
1253
|
-
if (entries.length === 1) {
|
|
1254
|
-
return [this];
|
|
1255
|
-
}
|
|
1256
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1257
|
-
const text = new _Text(entries[i]);
|
|
1258
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1259
|
-
results.push(text);
|
|
1260
|
-
}
|
|
1261
|
-
return results;
|
|
1262
|
-
}
|
|
1263
|
-
split(char) {
|
|
1264
|
-
const entries = __privateGet(this, _value).split(char);
|
|
1265
|
-
const results = new Array();
|
|
1266
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1267
|
-
const text = new _Text(entries[i]);
|
|
1268
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1269
|
-
results.push(text);
|
|
1270
|
-
}
|
|
1271
|
-
return results;
|
|
1272
|
-
}
|
|
1273
|
-
splitAtIndex(index) {
|
|
1274
|
-
const results = [
|
|
1275
|
-
new _Text(__privateGet(this, _value).substring(0, index)),
|
|
1276
|
-
new _Text(__privateGet(this, _value).substring(index, 0))
|
|
1277
|
-
];
|
|
1278
|
-
for (let i = 0; i < results.length; i++) {
|
|
1279
|
-
__privateSet(results[i], _style, __privateGet(this, _style));
|
|
1280
|
-
}
|
|
1281
|
-
return results;
|
|
1282
|
-
}
|
|
1283
|
-
splitAtWidth(ctx, maxWidth) {
|
|
1284
|
-
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1285
|
-
const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
|
|
1286
|
-
if (entries.length === 1) {
|
|
1287
|
-
return [this];
|
|
1288
|
-
}
|
|
1289
|
-
const results = new Array();
|
|
1290
|
-
for (let i = 0; i < entries.length; i++) {
|
|
1291
|
-
const text = new _Text(entries[i]);
|
|
1292
|
-
__privateSet(text, _style, __privateGet(this, _style));
|
|
1293
|
-
results.push(text);
|
|
1294
|
-
}
|
|
1295
|
-
return results;
|
|
1296
|
-
}
|
|
1297
|
-
size(ctx, scale, out) {
|
|
1298
|
-
__privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
|
|
1299
|
-
CopyVector2(out, __privateGet(this, _size3));
|
|
1300
|
-
ScaleVector(out, scale);
|
|
1301
|
-
}
|
|
1302
|
-
setColor(color) {
|
|
1303
|
-
__privateGet(this, _style).setColor(color);
|
|
1304
|
-
}
|
|
1305
|
-
getColor() {
|
|
1306
|
-
return __privateGet(this, _style).getColor();
|
|
1307
|
-
}
|
|
1308
|
-
setSize(size) {
|
|
1309
|
-
__privateGet(this, _style).setSize(size);
|
|
1310
|
-
}
|
|
1311
|
-
setWeight(weight) {
|
|
1312
|
-
__privateGet(this, _style).setWeight(weight);
|
|
1313
|
-
}
|
|
1314
|
-
render(ctx, scale, position) {
|
|
1315
|
-
__privateGet(this, _style).setupStyle(ctx, scale);
|
|
1316
|
-
ctx.fillText(__privateGet(this, _value), position.x, position.y);
|
|
1648
|
+
__privateSet(this, _color3, color);
|
|
1317
1649
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1650
|
+
setBorderColor(color) {
|
|
1651
|
+
if (__privateGet(this, _border2) === null) {
|
|
1652
|
+
__privateSet(this, _border2, new StrokeStyle({
|
|
1653
|
+
color
|
|
1654
|
+
}));
|
|
1655
|
+
} else {
|
|
1656
|
+
__privateGet(this, _border2).setColor(color);
|
|
1657
|
+
}
|
|
1320
1658
|
}
|
|
1321
1659
|
};
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1660
|
+
_border2 = new WeakMap();
|
|
1661
|
+
_color3 = new WeakMap();
|
|
1662
|
+
_radius = new WeakMap();
|
|
1663
|
+
_BoxStyle_instances = new WeakSet();
|
|
1664
|
+
box_fn = function(ctx, box, scale, radius) {
|
|
1665
|
+
var _a;
|
|
1666
|
+
ctx.fillStyle = __privateGet(this, _color3);
|
|
1667
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1668
|
+
ctx.beginPath();
|
|
1669
|
+
ctx.roundRect(
|
|
1670
|
+
box.Position.x,
|
|
1671
|
+
box.Position.y,
|
|
1672
|
+
box.Size.x,
|
|
1673
|
+
box.Size.y,
|
|
1674
|
+
radius
|
|
1675
|
+
);
|
|
1676
|
+
ctx.fill();
|
|
1677
|
+
};
|
|
1678
|
+
draw_fn = function(ctx, box, scale, radius) {
|
|
1679
|
+
__privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
|
|
1680
|
+
ctx.stroke();
|
|
1336
1681
|
};
|
|
1337
|
-
var Text = _Text;
|
|
1338
1682
|
|
|
1339
1683
|
// src/popup.ts
|
|
1340
1684
|
var _title, _options, _content, _onClose, _buttonCSS, _popup;
|
|
@@ -1409,15 +1753,15 @@ function TextBoxStyleWithFallback(input, fallback) {
|
|
|
1409
1753
|
textBaseline: (input == null ? void 0 : input.textBaseline) === void 0 ? fallback == null ? void 0 : fallback.textBaseline : input == null ? void 0 : input.textBaseline
|
|
1410
1754
|
};
|
|
1411
1755
|
}
|
|
1412
|
-
var _box2,
|
|
1756
|
+
var _box2, _text2, _textAlign, _textBaseline;
|
|
1413
1757
|
var TextBoxStyle = class {
|
|
1414
1758
|
constructor(config) {
|
|
1415
1759
|
__privateAdd(this, _box2);
|
|
1416
|
-
__privateAdd(this,
|
|
1760
|
+
__privateAdd(this, _text2);
|
|
1417
1761
|
__privateAdd(this, _textAlign);
|
|
1418
1762
|
__privateAdd(this, _textBaseline);
|
|
1419
1763
|
__privateSet(this, _box2, new BoxStyle(config == null ? void 0 : config.box));
|
|
1420
|
-
__privateSet(this,
|
|
1764
|
+
__privateSet(this, _text2, new TextStyle(config == null ? void 0 : config.text));
|
|
1421
1765
|
__privateSet(this, _textAlign, (config == null ? void 0 : config.textAlign) === void 0 ? "center" /* Center */ : config.textAlign);
|
|
1422
1766
|
__privateSet(this, _textBaseline, (config == null ? void 0 : config.textBaseline) === void 0 ? "middle" /* Middle */ : config.textBaseline);
|
|
1423
1767
|
}
|
|
@@ -1425,7 +1769,7 @@ var TextBoxStyle = class {
|
|
|
1425
1769
|
__privateGet(this, _box2).Draw(ctx, box, scale);
|
|
1426
1770
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1427
1771
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1428
|
-
__privateGet(this,
|
|
1772
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1429
1773
|
ctx.fillText(
|
|
1430
1774
|
text,
|
|
1431
1775
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1436,7 +1780,7 @@ var TextBoxStyle = class {
|
|
|
1436
1780
|
__privateGet(this, _box2).DrawUnderline(ctx, box, scale);
|
|
1437
1781
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1438
1782
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1439
|
-
__privateGet(this,
|
|
1783
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1440
1784
|
ctx.fillText(
|
|
1441
1785
|
text,
|
|
1442
1786
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1444,7 +1788,7 @@ var TextBoxStyle = class {
|
|
|
1444
1788
|
);
|
|
1445
1789
|
}
|
|
1446
1790
|
setTextColor(color) {
|
|
1447
|
-
__privateGet(this,
|
|
1791
|
+
__privateGet(this, _text2).setColor(color);
|
|
1448
1792
|
}
|
|
1449
1793
|
setBoxColor(color) {
|
|
1450
1794
|
__privateGet(this, _box2).setColor(color);
|
|
@@ -1454,7 +1798,7 @@ var TextBoxStyle = class {
|
|
|
1454
1798
|
}
|
|
1455
1799
|
};
|
|
1456
1800
|
_box2 = new WeakMap();
|
|
1457
|
-
|
|
1801
|
+
_text2 = new WeakMap();
|
|
1458
1802
|
_textAlign = new WeakMap();
|
|
1459
1803
|
_textBaseline = new WeakMap();
|
|
1460
1804
|
|
|
@@ -1463,7 +1807,7 @@ var width = 150;
|
|
|
1463
1807
|
var height = 25;
|
|
1464
1808
|
|
|
1465
1809
|
// src/widgets/number.ts
|
|
1466
|
-
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle,
|
|
1810
|
+
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle, _text3, _callback2;
|
|
1467
1811
|
var NumberWidget = class {
|
|
1468
1812
|
constructor(node, config) {
|
|
1469
1813
|
__privateAdd(this, _node2);
|
|
@@ -1471,10 +1815,10 @@ var NumberWidget = class {
|
|
|
1471
1815
|
__privateAdd(this, _value2);
|
|
1472
1816
|
__privateAdd(this, _idleBoxStyle);
|
|
1473
1817
|
__privateAdd(this, _highlightBoxStyle);
|
|
1474
|
-
__privateAdd(this,
|
|
1818
|
+
__privateAdd(this, _text3);
|
|
1475
1819
|
__privateAdd(this, _callback2);
|
|
1476
1820
|
__privateSet(this, _value2, 0);
|
|
1477
|
-
__privateSet(this,
|
|
1821
|
+
__privateSet(this, _text3, "0");
|
|
1478
1822
|
__privateSet(this, _node2, node);
|
|
1479
1823
|
__privateSet(this, _nodeProperty, config == null ? void 0 : config.property);
|
|
1480
1824
|
__privateSet(this, _idleBoxStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleBoxStyle, {
|
|
@@ -1521,7 +1865,7 @@ var NumberWidget = class {
|
|
|
1521
1865
|
if (__privateGet(this, _callback2) !== void 0) {
|
|
1522
1866
|
__privateGet(this, _callback2).call(this, __privateGet(this, _value2));
|
|
1523
1867
|
}
|
|
1524
|
-
__privateSet(this,
|
|
1868
|
+
__privateSet(this, _text3, "" + parseFloat(__privateGet(this, _value2).toPrecision(6)));
|
|
1525
1869
|
}
|
|
1526
1870
|
ClickStart() {
|
|
1527
1871
|
}
|
|
@@ -1564,7 +1908,7 @@ var NumberWidget = class {
|
|
|
1564
1908
|
style = __privateGet(this, _highlightBoxStyle);
|
|
1565
1909
|
}
|
|
1566
1910
|
}
|
|
1567
|
-
style.DrawUnderline(ctx, box, scale, __privateGet(this,
|
|
1911
|
+
style.DrawUnderline(ctx, box, scale, __privateGet(this, _text3));
|
|
1568
1912
|
return box;
|
|
1569
1913
|
}
|
|
1570
1914
|
};
|
|
@@ -1573,20 +1917,20 @@ _nodeProperty = new WeakMap();
|
|
|
1573
1917
|
_value2 = new WeakMap();
|
|
1574
1918
|
_idleBoxStyle = new WeakMap();
|
|
1575
1919
|
_highlightBoxStyle = new WeakMap();
|
|
1576
|
-
|
|
1920
|
+
_text3 = new WeakMap();
|
|
1577
1921
|
_callback2 = new WeakMap();
|
|
1578
1922
|
|
|
1579
1923
|
// src/widgets/button.ts
|
|
1580
|
-
var
|
|
1924
|
+
var _text4, _idleStyle, _hoverStyle, _clickStyle, _callback3, _gettingClicked;
|
|
1581
1925
|
var ButtonWidget = class {
|
|
1582
1926
|
constructor(config) {
|
|
1583
|
-
__privateAdd(this,
|
|
1927
|
+
__privateAdd(this, _text4);
|
|
1584
1928
|
__privateAdd(this, _idleStyle);
|
|
1585
1929
|
__privateAdd(this, _hoverStyle);
|
|
1586
1930
|
__privateAdd(this, _clickStyle);
|
|
1587
1931
|
__privateAdd(this, _callback3);
|
|
1588
1932
|
__privateAdd(this, _gettingClicked);
|
|
1589
|
-
__privateSet(this,
|
|
1933
|
+
__privateSet(this, _text4, (config == null ? void 0 : config.text) === void 0 ? "Button" : config == null ? void 0 : config.text);
|
|
1590
1934
|
__privateSet(this, _callback3, config == null ? void 0 : config.callback);
|
|
1591
1935
|
__privateSet(this, _gettingClicked, false);
|
|
1592
1936
|
__privateSet(this, _idleStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleStyle, {
|
|
@@ -1641,7 +1985,7 @@ var ButtonWidget = class {
|
|
|
1641
1985
|
if (__privateGet(this, _gettingClicked)) {
|
|
1642
1986
|
style = __privateGet(this, _clickStyle);
|
|
1643
1987
|
}
|
|
1644
|
-
style.Draw(ctx, box, scale, __privateGet(this,
|
|
1988
|
+
style.Draw(ctx, box, scale, __privateGet(this, _text4));
|
|
1645
1989
|
return box;
|
|
1646
1990
|
}
|
|
1647
1991
|
ClickStart() {
|
|
@@ -1654,7 +1998,7 @@ var ButtonWidget = class {
|
|
|
1654
1998
|
}
|
|
1655
1999
|
}
|
|
1656
2000
|
};
|
|
1657
|
-
|
|
2001
|
+
_text4 = new WeakMap();
|
|
1658
2002
|
_idleStyle = new WeakMap();
|
|
1659
2003
|
_hoverStyle = new WeakMap();
|
|
1660
2004
|
_clickStyle = new WeakMap();
|
|
@@ -1772,14 +2116,14 @@ _textBoxStyle = new WeakMap();
|
|
|
1772
2116
|
_callback4 = new WeakMap();
|
|
1773
2117
|
|
|
1774
2118
|
// src/widgets/slider.ts
|
|
1775
|
-
var _min, _max, _value4,
|
|
2119
|
+
var _min, _max, _value4, _text5, _snapIncrement, _node4, _nodeProperty3, _change, _release, _textStyle3, _backgroundColor2, _borderColor, _fillColor, _lastMousePosition2, _clickStartMousePosition, _clicking;
|
|
1776
2120
|
var SliderWidget = class {
|
|
1777
2121
|
constructor(node, config) {
|
|
1778
2122
|
// Data Variables =========================================================
|
|
1779
2123
|
__privateAdd(this, _min);
|
|
1780
2124
|
__privateAdd(this, _max);
|
|
1781
2125
|
__privateAdd(this, _value4);
|
|
1782
|
-
__privateAdd(this,
|
|
2126
|
+
__privateAdd(this, _text5);
|
|
1783
2127
|
__privateAdd(this, _snapIncrement);
|
|
1784
2128
|
__privateAdd(this, _node4);
|
|
1785
2129
|
__privateAdd(this, _nodeProperty3);
|
|
@@ -1788,7 +2132,7 @@ var SliderWidget = class {
|
|
|
1788
2132
|
__privateAdd(this, _release);
|
|
1789
2133
|
// Styling Variables ======================================================
|
|
1790
2134
|
__privateAdd(this, _textStyle3);
|
|
1791
|
-
__privateAdd(this,
|
|
2135
|
+
__privateAdd(this, _backgroundColor2);
|
|
1792
2136
|
__privateAdd(this, _borderColor);
|
|
1793
2137
|
__privateAdd(this, _fillColor);
|
|
1794
2138
|
// Runtime Variables ======================================================
|
|
@@ -1801,9 +2145,9 @@ var SliderWidget = class {
|
|
|
1801
2145
|
__privateSet(this, _max, (config == null ? void 0 : config.max) === void 0 ? 1 : config == null ? void 0 : config.max);
|
|
1802
2146
|
__privateSet(this, _snapIncrement, config == null ? void 0 : config.snapIncrement);
|
|
1803
2147
|
__privateSet(this, _nodeProperty3, config == null ? void 0 : config.property);
|
|
1804
|
-
__privateSet(this,
|
|
2148
|
+
__privateSet(this, _text5, "");
|
|
1805
2149
|
__privateSet(this, _release, config == null ? void 0 : config.release);
|
|
1806
|
-
__privateSet(this,
|
|
2150
|
+
__privateSet(this, _backgroundColor2, (config == null ? void 0 : config.backgroundColor) === void 0 ? Theme.Widget.BackgroundColor : config == null ? void 0 : config.backgroundColor);
|
|
1807
2151
|
__privateSet(this, _fillColor, (config == null ? void 0 : config.fillColor) === void 0 ? Theme.Widget.Slider.FillColor : config == null ? void 0 : config.fillColor);
|
|
1808
2152
|
__privateSet(this, _borderColor, (config == null ? void 0 : config.borderColor) === void 0 ? Theme.Widget.Border.Color : config == null ? void 0 : config.borderColor);
|
|
1809
2153
|
__privateSet(this, _textStyle3, new TextStyle(TextStyleFallback(config == null ? void 0 : config.textStyle, {
|
|
@@ -1829,7 +2173,7 @@ var SliderWidget = class {
|
|
|
1829
2173
|
if (__privateGet(this, _nodeProperty3)) {
|
|
1830
2174
|
__privateGet(this, _node4).setProperty(__privateGet(this, _nodeProperty3), __privateGet(this, _value4));
|
|
1831
2175
|
}
|
|
1832
|
-
__privateSet(this,
|
|
2176
|
+
__privateSet(this, _text5, __privateGet(this, _value4).toFixed(3));
|
|
1833
2177
|
if (__privateGet(this, _change) !== void 0) {
|
|
1834
2178
|
__privateGet(this, _change).call(this, __privateGet(this, _value4));
|
|
1835
2179
|
}
|
|
@@ -1851,7 +2195,7 @@ var SliderWidget = class {
|
|
|
1851
2195
|
const scaledWidth = width * scale;
|
|
1852
2196
|
const scaledHeight = height * scale;
|
|
1853
2197
|
const scaledBorderThickness = Theme.Widget.Border.Size * scale;
|
|
1854
|
-
ctx.fillStyle = __privateGet(this,
|
|
2198
|
+
ctx.fillStyle = __privateGet(this, _backgroundColor2);
|
|
1855
2199
|
ctx.strokeStyle = __privateGet(this, _borderColor);
|
|
1856
2200
|
ctx.lineWidth = scaledBorderThickness;
|
|
1857
2201
|
ctx.beginPath();
|
|
@@ -1879,7 +2223,7 @@ var SliderWidget = class {
|
|
|
1879
2223
|
ctx.textBaseline = "middle" /* Middle */;
|
|
1880
2224
|
__privateGet(this, _textStyle3).setupStyle(ctx, scale);
|
|
1881
2225
|
ctx.fillText(
|
|
1882
|
-
__privateGet(this,
|
|
2226
|
+
__privateGet(this, _text5),
|
|
1883
2227
|
position.x + scaledWidth / 2,
|
|
1884
2228
|
position.y + scaledHeight / 2
|
|
1885
2229
|
);
|
|
@@ -1908,14 +2252,14 @@ var SliderWidget = class {
|
|
|
1908
2252
|
_min = new WeakMap();
|
|
1909
2253
|
_max = new WeakMap();
|
|
1910
2254
|
_value4 = new WeakMap();
|
|
1911
|
-
|
|
2255
|
+
_text5 = new WeakMap();
|
|
1912
2256
|
_snapIncrement = new WeakMap();
|
|
1913
2257
|
_node4 = new WeakMap();
|
|
1914
2258
|
_nodeProperty3 = new WeakMap();
|
|
1915
2259
|
_change = new WeakMap();
|
|
1916
2260
|
_release = new WeakMap();
|
|
1917
2261
|
_textStyle3 = new WeakMap();
|
|
1918
|
-
|
|
2262
|
+
_backgroundColor2 = new WeakMap();
|
|
1919
2263
|
_borderColor = new WeakMap();
|
|
1920
2264
|
_fillColor = new WeakMap();
|
|
1921
2265
|
_lastMousePosition2 = new WeakMap();
|
|
@@ -2119,13 +2463,13 @@ _lightColor = new WeakMap();
|
|
|
2119
2463
|
_lightBorderColor = new WeakMap();
|
|
2120
2464
|
_lightBlur = new WeakMap();
|
|
2121
2465
|
_box3 = new WeakMap();
|
|
2122
|
-
var _node6, _nodeProperty5, _value6,
|
|
2466
|
+
var _node6, _nodeProperty5, _value6, _text6, _enabledStyle, _disabledStyle, _callback6;
|
|
2123
2467
|
var ToggleWidget = class {
|
|
2124
2468
|
constructor(node, config) {
|
|
2125
2469
|
__privateAdd(this, _node6);
|
|
2126
2470
|
__privateAdd(this, _nodeProperty5);
|
|
2127
2471
|
__privateAdd(this, _value6);
|
|
2128
|
-
__privateAdd(this,
|
|
2472
|
+
__privateAdd(this, _text6);
|
|
2129
2473
|
__privateAdd(this, _enabledStyle);
|
|
2130
2474
|
__privateAdd(this, _disabledStyle);
|
|
2131
2475
|
__privateAdd(this, _callback6);
|
|
@@ -2133,7 +2477,7 @@ var ToggleWidget = class {
|
|
|
2133
2477
|
__privateSet(this, _value6, false);
|
|
2134
2478
|
__privateSet(this, _node6, node);
|
|
2135
2479
|
__privateSet(this, _nodeProperty5, config == null ? void 0 : config.property);
|
|
2136
|
-
__privateSet(this,
|
|
2480
|
+
__privateSet(this, _text6, (config == null ? void 0 : config.text) === void 0 ? "Toggle" : config == null ? void 0 : config.text);
|
|
2137
2481
|
__privateSet(this, _enabledStyle, new ToggleStyle({
|
|
2138
2482
|
idle: TextBoxStyleWithFallback((_a = config == null ? void 0 : config.enabledStyle) == null ? void 0 : _a.idle, {
|
|
2139
2483
|
box: {
|
|
@@ -2176,7 +2520,7 @@ var ToggleWidget = class {
|
|
|
2176
2520
|
}
|
|
2177
2521
|
Draw(ctx, position, scale, mousePosition) {
|
|
2178
2522
|
let style = __privateGet(this, _value6) ? __privateGet(this, _enabledStyle) : __privateGet(this, _disabledStyle);
|
|
2179
|
-
return style.Draw(ctx, position, scale, __privateGet(this,
|
|
2523
|
+
return style.Draw(ctx, position, scale, __privateGet(this, _text6), mousePosition);
|
|
2180
2524
|
}
|
|
2181
2525
|
Toggle() {
|
|
2182
2526
|
this.Set(!__privateGet(this, _value6));
|
|
@@ -2202,21 +2546,21 @@ var ToggleWidget = class {
|
|
|
2202
2546
|
_node6 = new WeakMap();
|
|
2203
2547
|
_nodeProperty5 = new WeakMap();
|
|
2204
2548
|
_value6 = new WeakMap();
|
|
2205
|
-
|
|
2549
|
+
_text6 = new WeakMap();
|
|
2206
2550
|
_enabledStyle = new WeakMap();
|
|
2207
2551
|
_disabledStyle = new WeakMap();
|
|
2208
2552
|
_callback6 = new WeakMap();
|
|
2209
2553
|
|
|
2210
2554
|
// src/widgets/image.ts
|
|
2211
|
-
var _url, _image,
|
|
2555
|
+
var _url, _image, _maxWidth2, _maxHeight2;
|
|
2212
2556
|
var ImageWidget = class {
|
|
2213
2557
|
constructor(config) {
|
|
2214
2558
|
__privateAdd(this, _url);
|
|
2215
2559
|
__privateAdd(this, _image);
|
|
2216
|
-
__privateAdd(this,
|
|
2217
|
-
__privateAdd(this,
|
|
2218
|
-
__privateSet(this,
|
|
2219
|
-
__privateSet(this,
|
|
2560
|
+
__privateAdd(this, _maxWidth2);
|
|
2561
|
+
__privateAdd(this, _maxHeight2);
|
|
2562
|
+
__privateSet(this, _maxWidth2, (config == null ? void 0 : config.maxWidth) === void 0 ? 150 : config == null ? void 0 : config.maxWidth);
|
|
2563
|
+
__privateSet(this, _maxHeight2, (config == null ? void 0 : config.maxHeight) === void 0 ? 150 : config == null ? void 0 : config.maxHeight);
|
|
2220
2564
|
if (config == null ? void 0 : config.image) {
|
|
2221
2565
|
this.SetUrl(config == null ? void 0 : config.image);
|
|
2222
2566
|
} else if (config == null ? void 0 : config.blob) {
|
|
@@ -2245,11 +2589,11 @@ var ImageWidget = class {
|
|
|
2245
2589
|
return { "x": 0, "y": 0 };
|
|
2246
2590
|
}
|
|
2247
2591
|
let adjust = 1;
|
|
2248
|
-
if (__privateGet(this, _image).width > __privateGet(this,
|
|
2249
|
-
adjust = __privateGet(this,
|
|
2592
|
+
if (__privateGet(this, _image).width > __privateGet(this, _maxWidth2)) {
|
|
2593
|
+
adjust = __privateGet(this, _maxWidth2) / __privateGet(this, _image).width;
|
|
2250
2594
|
}
|
|
2251
|
-
if (__privateGet(this, _image).height > __privateGet(this,
|
|
2252
|
-
let heightAdjust = __privateGet(this,
|
|
2595
|
+
if (__privateGet(this, _image).height > __privateGet(this, _maxHeight2)) {
|
|
2596
|
+
let heightAdjust = __privateGet(this, _maxHeight2) / __privateGet(this, _image).height;
|
|
2253
2597
|
if (heightAdjust < adjust) {
|
|
2254
2598
|
adjust = heightAdjust;
|
|
2255
2599
|
}
|
|
@@ -2288,8 +2632,8 @@ var ImageWidget = class {
|
|
|
2288
2632
|
};
|
|
2289
2633
|
_url = new WeakMap();
|
|
2290
2634
|
_image = new WeakMap();
|
|
2291
|
-
|
|
2292
|
-
|
|
2635
|
+
_maxWidth2 = new WeakMap();
|
|
2636
|
+
_maxHeight2 = new WeakMap();
|
|
2293
2637
|
|
|
2294
2638
|
// src/widgets/text.ts
|
|
2295
2639
|
var _value7, _callback7, _node7, _nodeProperty6, _size4;
|
|
@@ -3520,7 +3864,7 @@ function FormPopup(config) {
|
|
|
3520
3864
|
|
|
3521
3865
|
// src/node.ts
|
|
3522
3866
|
var MINIMUM_NODE_WIDTH = 150;
|
|
3523
|
-
var _position, _title2, _subTitle, _infoSymbol, _infoText, _input, _output, _widgets, _locked, _canEditTitle, _canEditInfo, _canEditPorts, _contextMenu2, _metadata, _onSelect, _onUnselect, _onFiledrop, _onDragStop, _titleChangeCallback, _infoChangeCallback, _titleColor, _selectedStyle, _stateStyles,
|
|
3867
|
+
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;
|
|
3524
3868
|
var FlowNode = class {
|
|
3525
3869
|
constructor(config) {
|
|
3526
3870
|
__privateAdd(this, _FlowNode_instances);
|
|
@@ -3549,7 +3893,7 @@ var FlowNode = class {
|
|
|
3549
3893
|
__privateAdd(this, _titleColor);
|
|
3550
3894
|
__privateAdd(this, _selectedStyle);
|
|
3551
3895
|
__privateAdd(this, _stateStyles);
|
|
3552
|
-
__privateAdd(this,
|
|
3896
|
+
__privateAdd(this, _padding2);
|
|
3553
3897
|
__privateAdd(this, _portTextStyle);
|
|
3554
3898
|
__privateAdd(this, _elementSpacing);
|
|
3555
3899
|
// Runtime ================================================================
|
|
@@ -3629,7 +3973,7 @@ var FlowNode = class {
|
|
|
3629
3973
|
));
|
|
3630
3974
|
__privateSet(this, _infoText, (config == null ? void 0 : config.info) ? config == null ? void 0 : config.info : "");
|
|
3631
3975
|
__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);
|
|
3632
|
-
__privateSet(this,
|
|
3976
|
+
__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);
|
|
3633
3977
|
__privateSet(this, _stateStyles, /* @__PURE__ */ new Map());
|
|
3634
3978
|
__privateGet(this, _stateStyles).set(0 /* Idle */, new BoxStyle(BoxStyleWithFallback((_m = config == null ? void 0 : config.style) == null ? void 0 : _m.idle, {
|
|
3635
3979
|
border: { color: Theme.Node.Border.Idle, size: 1 },
|
|
@@ -3910,7 +4254,7 @@ var FlowNode = class {
|
|
|
3910
4254
|
// }
|
|
3911
4255
|
calculateBounds(ctx, camera) {
|
|
3912
4256
|
const tempMeasurement = Zero();
|
|
3913
|
-
const doublePadding = __privateGet(this,
|
|
4257
|
+
const doublePadding = __privateGet(this, _padding2) * 2;
|
|
3914
4258
|
const screenSpacePosition = Zero();
|
|
3915
4259
|
camera.graphSpaceToScreenSpace(__privateGet(this, _position), screenSpacePosition);
|
|
3916
4260
|
const size = Zero();
|
|
@@ -4075,7 +4419,7 @@ var FlowNode = class {
|
|
|
4075
4419
|
__privateGet(this, _inputPortPositions).Clear();
|
|
4076
4420
|
__privateGet(this, _outputPortPositions).Clear();
|
|
4077
4421
|
__privateGet(this, _widgetPositions).Clear();
|
|
4078
|
-
const scaledPadding = __privateGet(this,
|
|
4422
|
+
const scaledPadding = __privateGet(this, _padding2) * camera.zoom;
|
|
4079
4423
|
const scaledElementSpacing = __privateGet(this, _elementSpacing) * camera.zoom;
|
|
4080
4424
|
const nodeBounds = this.calculateBounds(ctx, camera);
|
|
4081
4425
|
const nodeStyle = __privateMethod(this, _FlowNode_instances, calculateStyle_fn).call(this, state);
|
|
@@ -4222,7 +4566,7 @@ _infoChangeCallback = new WeakMap();
|
|
|
4222
4566
|
_titleColor = new WeakMap();
|
|
4223
4567
|
_selectedStyle = new WeakMap();
|
|
4224
4568
|
_stateStyles = new WeakMap();
|
|
4225
|
-
|
|
4569
|
+
_padding2 = new WeakMap();
|
|
4226
4570
|
_portTextStyle = new WeakMap();
|
|
4227
4571
|
_elementSpacing = new WeakMap();
|
|
4228
4572
|
_selected = new WeakMap();
|
|
@@ -4522,15 +4866,15 @@ text_fn = function() {
|
|
|
4522
4866
|
};
|
|
4523
4867
|
|
|
4524
4868
|
// src/markdown/entry.ts
|
|
4525
|
-
var
|
|
4869
|
+
var _text7, _calculatedPositions, _calculatedEntries, _calculatedForWidth, _CodeBlockEntry_instances, calculateLayout_fn;
|
|
4526
4870
|
var CodeBlockEntry = class {
|
|
4527
4871
|
constructor(text) {
|
|
4528
4872
|
__privateAdd(this, _CodeBlockEntry_instances);
|
|
4529
|
-
__privateAdd(this,
|
|
4873
|
+
__privateAdd(this, _text7);
|
|
4530
4874
|
__privateAdd(this, _calculatedPositions);
|
|
4531
4875
|
__privateAdd(this, _calculatedEntries);
|
|
4532
4876
|
__privateAdd(this, _calculatedForWidth);
|
|
4533
|
-
__privateSet(this,
|
|
4877
|
+
__privateSet(this, _text7, text);
|
|
4534
4878
|
__privateSet(this, _calculatedForWidth, -1);
|
|
4535
4879
|
__privateSet(this, _calculatedEntries, new List());
|
|
4536
4880
|
__privateSet(this, _calculatedPositions, new List());
|
|
@@ -4569,7 +4913,7 @@ var CodeBlockEntry = class {
|
|
|
4569
4913
|
return max + padding * 2;
|
|
4570
4914
|
}
|
|
4571
4915
|
};
|
|
4572
|
-
|
|
4916
|
+
_text7 = new WeakMap();
|
|
4573
4917
|
_calculatedPositions = new WeakMap();
|
|
4574
4918
|
_calculatedEntries = new WeakMap();
|
|
4575
4919
|
_calculatedForWidth = new WeakMap();
|
|
@@ -4583,8 +4927,8 @@ calculateLayout_fn = function(ctx, maxWidth) {
|
|
|
4583
4927
|
__privateGet(this, _calculatedEntries).Clear();
|
|
4584
4928
|
__privateGet(this, _calculatedPositions).Clear();
|
|
4585
4929
|
let curHeight = 0;
|
|
4586
|
-
const lineInc = __privateGet(this,
|
|
4587
|
-
let entries = __privateGet(this,
|
|
4930
|
+
const lineInc = __privateGet(this, _text7).style().getSize() + Theme.Note.LineSpacing;
|
|
4931
|
+
let entries = __privateGet(this, _text7).split("\n");
|
|
4588
4932
|
for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
|
|
4589
4933
|
const entry = entries[entryIndex];
|
|
4590
4934
|
let lines = entry.breakIntoLines(ctx, adjustedWith);
|
|
@@ -5371,404 +5715,114 @@ var NoteSubsystem = class {
|
|
|
5371
5715
|
return false;
|
|
5372
5716
|
}
|
|
5373
5717
|
clickEnd() {
|
|
5374
|
-
if (__privateGet(this, _noteSelected) !== null) {
|
|
5375
|
-
__privateGet(this, _noteSelected).selectHandle(0 /* None */);
|
|
5376
|
-
for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
|
|
5377
|
-
__privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
|
|
5378
|
-
}
|
|
5379
|
-
}
|
|
5380
|
-
__privateSet(this, _noteSelected, null);
|
|
5381
|
-
}
|
|
5382
|
-
mouseDragEvent(delta, scale) {
|
|
5383
|
-
if (__privateGet(this, _noteSelected) === null) {
|
|
5384
|
-
return false;
|
|
5385
|
-
}
|
|
5386
|
-
if (__privateGet(this, _noteSelected).handleSelected()) {
|
|
5387
|
-
return true;
|
|
5388
|
-
}
|
|
5389
|
-
__privateGet(this, _noteSelected).translate({
|
|
5390
|
-
x: delta.x * (1 / scale),
|
|
5391
|
-
y: delta.y * (1 / scale)
|
|
5392
|
-
});
|
|
5393
|
-
return true;
|
|
5394
|
-
}
|
|
5395
|
-
fileDrop(file) {
|
|
5396
|
-
return false;
|
|
5397
|
-
}
|
|
5398
|
-
removeNote(note) {
|
|
5399
|
-
const index = __privateGet(this, _notes).indexOf(note);
|
|
5400
|
-
if (index > -1) {
|
|
5401
|
-
const noteRemoved = __privateGet(this, _notes)[index];
|
|
5402
|
-
__privateGet(this, _notes).splice(index, 1);
|
|
5403
|
-
for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
|
|
5404
|
-
__privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
|
|
5405
|
-
}
|
|
5406
|
-
} else {
|
|
5407
|
-
console.error("no note found to remove");
|
|
5408
|
-
}
|
|
5409
|
-
}
|
|
5410
|
-
render(ctx, camera, mousePosition) {
|
|
5411
|
-
__privateSet(this, _noteHovering, null);
|
|
5412
|
-
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
5413
|
-
if (mousePosition) {
|
|
5414
|
-
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5415
|
-
__privateGet(this, _notes)[i].setHovering(false);
|
|
5416
|
-
if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
|
|
5417
|
-
__privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
|
|
5418
|
-
}
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
if (__privateGet(this, _noteHovering) != null) {
|
|
5422
|
-
__privateGet(this, _noteHovering).setHovering(true);
|
|
5423
|
-
if (mousePosition) {
|
|
5424
|
-
if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
|
|
5425
|
-
__privateSet(this, _hoveringHandle, 1 /* Left */);
|
|
5426
|
-
} else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
|
|
5427
|
-
__privateSet(this, _hoveringHandle, 2 /* Right */);
|
|
5428
|
-
}
|
|
5429
|
-
}
|
|
5430
|
-
}
|
|
5431
|
-
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5432
|
-
__privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
|
|
5433
|
-
}
|
|
5434
|
-
return;
|
|
5435
|
-
}
|
|
5436
|
-
};
|
|
5437
|
-
_notes = new WeakMap();
|
|
5438
|
-
_noteHovering = new WeakMap();
|
|
5439
|
-
_noteSelected = new WeakMap();
|
|
5440
|
-
_hoveringHandle = new WeakMap();
|
|
5441
|
-
_onNoteAddedCallbacks = new WeakMap();
|
|
5442
|
-
_onNoteRemovedCallbacks = new WeakMap();
|
|
5443
|
-
_onNoteDragStartCallbacks = new WeakMap();
|
|
5444
|
-
_onNoteDragStopCallbacks = new WeakMap();
|
|
5445
|
-
|
|
5446
|
-
// src/pass/subsystem.ts
|
|
5447
|
-
var _queue;
|
|
5448
|
-
var PassSubsystem = class {
|
|
5449
|
-
constructor() {
|
|
5450
|
-
__privateAdd(this, _queue);
|
|
5451
|
-
__privateSet(this, _queue, new List());
|
|
5452
|
-
}
|
|
5453
|
-
queue(lambda) {
|
|
5454
|
-
if (!lambda) {
|
|
5455
|
-
return;
|
|
5456
|
-
}
|
|
5457
|
-
__privateGet(this, _queue).Push(lambda);
|
|
5458
|
-
}
|
|
5459
|
-
render(ctx, camera, mousePosition) {
|
|
5460
|
-
for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
|
|
5461
|
-
__privateGet(this, _queue).At(i)();
|
|
5462
|
-
}
|
|
5463
|
-
__privateGet(this, _queue).Clear();
|
|
5464
|
-
return;
|
|
5465
|
-
}
|
|
5466
|
-
openContextMenu(ctx, position) {
|
|
5467
|
-
return null;
|
|
5468
|
-
}
|
|
5469
|
-
clickStart(mousePosition, camera, ctrlKey) {
|
|
5470
|
-
return false;
|
|
5471
|
-
}
|
|
5472
|
-
mouseDragEvent(delta, scale) {
|
|
5473
|
-
return false;
|
|
5474
|
-
}
|
|
5475
|
-
fileDrop(file) {
|
|
5476
|
-
return false;
|
|
5477
|
-
}
|
|
5478
|
-
clickEnd() {
|
|
5479
|
-
}
|
|
5480
|
-
};
|
|
5481
|
-
_queue = new WeakMap();
|
|
5482
|
-
|
|
5483
|
-
// src/elements/interfaces.ts
|
|
5484
|
-
function InstantiateRenderElementSidesStyling(config) {
|
|
5485
|
-
if (typeof config === "number") {
|
|
5486
|
-
return {
|
|
5487
|
-
Bottom: config,
|
|
5488
|
-
Right: config,
|
|
5489
|
-
Top: config,
|
|
5490
|
-
Left: config
|
|
5491
|
-
};
|
|
5492
|
-
}
|
|
5493
|
-
return {
|
|
5494
|
-
Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
|
|
5495
|
-
Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
|
|
5496
|
-
Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
|
|
5497
|
-
Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
|
|
5498
|
-
};
|
|
5499
|
-
}
|
|
5500
|
-
|
|
5501
|
-
// src/elements/base.ts
|
|
5502
|
-
var _margin, _padding2, _border2, _backgroundColor2, _minWidth, _maxWidth2, _minHeight, _maxHeight2, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
|
|
5503
|
-
var RenderElementBase = class {
|
|
5504
|
-
constructor(config) {
|
|
5505
|
-
__privateAdd(this, _RenderElementBase_instances);
|
|
5506
|
-
__privateAdd(this, _margin);
|
|
5507
|
-
__privateAdd(this, _padding2);
|
|
5508
|
-
__privateAdd(this, _border2);
|
|
5509
|
-
__privateAdd(this, _backgroundColor2);
|
|
5510
|
-
__privateAdd(this, _minWidth);
|
|
5511
|
-
__privateAdd(this, _maxWidth2);
|
|
5512
|
-
__privateAdd(this, _minHeight);
|
|
5513
|
-
__privateAdd(this, _maxHeight2);
|
|
5514
|
-
__privateAdd(this, _grow);
|
|
5515
|
-
__privateAdd(this, _display);
|
|
5516
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5517
|
-
__privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
|
|
5518
|
-
__privateSet(this, _padding2, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
|
|
5519
|
-
__privateSet(this, _backgroundColor2, config == null ? void 0 : config.BackgroundColor);
|
|
5520
|
-
__privateSet(this, _border2, {
|
|
5521
|
-
Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
|
|
5522
|
-
Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
|
|
5523
|
-
Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
|
|
5524
|
-
});
|
|
5525
|
-
__privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
|
|
5526
|
-
__privateSet(this, _maxWidth2, config == null ? void 0 : config.MaxWidth);
|
|
5527
|
-
__privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
|
|
5528
|
-
__privateSet(this, _maxHeight2, config == null ? void 0 : config.MaxHeight);
|
|
5529
|
-
__privateSet(this, _grow, config == null ? void 0 : config.Grow);
|
|
5530
|
-
__privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
|
|
5531
|
-
}
|
|
5532
|
-
setBackgroundColor(newColor) {
|
|
5533
|
-
__privateSet(this, _backgroundColor2, newColor);
|
|
5534
|
-
}
|
|
5535
|
-
render(ctx, position, graphScale, scaledFillableSpace) {
|
|
5536
|
-
if (__privateGet(this, _display) === "none" /* None */) {
|
|
5537
|
-
return;
|
|
5538
|
-
}
|
|
5539
|
-
const scaledSize = { x: 0, y: 0 };
|
|
5540
|
-
this.size(ctx, scaledSize);
|
|
5541
|
-
scaledSize.x = scaledSize.x * graphScale;
|
|
5542
|
-
scaledSize.y = scaledSize.y * graphScale;
|
|
5543
|
-
scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
|
|
5544
|
-
scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
|
|
5545
|
-
if (__privateGet(this, _backgroundColor2)) {
|
|
5546
|
-
ctx.fillStyle = __privateGet(this, _backgroundColor2);
|
|
5547
|
-
ctx.beginPath();
|
|
5548
|
-
ctx.roundRect(
|
|
5549
|
-
position.x + __privateGet(this, _margin).Left * graphScale,
|
|
5550
|
-
position.y + __privateGet(this, _margin).Right * graphScale,
|
|
5551
|
-
scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
|
|
5552
|
-
scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
|
|
5553
|
-
__privateGet(this, _border2).Radius * graphScale
|
|
5554
|
-
);
|
|
5555
|
-
ctx.fill();
|
|
5556
|
-
}
|
|
5557
|
-
if (__privateGet(this, _border2).Thickness > 0) {
|
|
5558
|
-
ctx.lineWidth = __privateGet(this, _border2).Thickness * graphScale;
|
|
5559
|
-
ctx.strokeStyle = __privateGet(this, _border2).Color;
|
|
5560
|
-
ctx.stroke();
|
|
5718
|
+
if (__privateGet(this, _noteSelected) !== null) {
|
|
5719
|
+
__privateGet(this, _noteSelected).selectHandle(0 /* None */);
|
|
5720
|
+
for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
|
|
5721
|
+
__privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
|
|
5722
|
+
}
|
|
5561
5723
|
}
|
|
5562
|
-
|
|
5563
|
-
x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
|
|
5564
|
-
y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
|
|
5565
|
-
};
|
|
5566
|
-
const elementSize = {
|
|
5567
|
-
x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
|
|
5568
|
-
y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
|
|
5569
|
-
};
|
|
5570
|
-
this.doRender(ctx, offsetPosition, graphScale, elementSize);
|
|
5724
|
+
__privateSet(this, _noteSelected, null);
|
|
5571
5725
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
if (__privateGet(this, _maxWidth2)) {
|
|
5576
|
-
out.x = __privateGet(this, _maxWidth2);
|
|
5726
|
+
mouseDragEvent(delta, scale) {
|
|
5727
|
+
if (__privateGet(this, _noteSelected) === null) {
|
|
5728
|
+
return false;
|
|
5577
5729
|
}
|
|
5578
|
-
if (__privateGet(this,
|
|
5579
|
-
|
|
5730
|
+
if (__privateGet(this, _noteSelected).handleSelected()) {
|
|
5731
|
+
return true;
|
|
5580
5732
|
}
|
|
5733
|
+
__privateGet(this, _noteSelected).translate({
|
|
5734
|
+
x: delta.x * (1 / scale),
|
|
5735
|
+
y: delta.y * (1 / scale)
|
|
5736
|
+
});
|
|
5737
|
+
return true;
|
|
5581
5738
|
}
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
}
|
|
5585
|
-
getDisplay() {
|
|
5586
|
-
return __privateGet(this, _display);
|
|
5739
|
+
fileDrop(file) {
|
|
5740
|
+
return false;
|
|
5587
5741
|
}
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
|
|
5599
|
-
if (__privateGet(this, _minWidth)) {
|
|
5600
|
-
out.x = Math.max(out.x, __privateGet(this, _minWidth));
|
|
5742
|
+
removeNote(note) {
|
|
5743
|
+
const index = __privateGet(this, _notes).indexOf(note);
|
|
5744
|
+
if (index > -1) {
|
|
5745
|
+
const noteRemoved = __privateGet(this, _notes)[index];
|
|
5746
|
+
__privateGet(this, _notes).splice(index, 1);
|
|
5747
|
+
for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
|
|
5748
|
+
__privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
|
|
5749
|
+
}
|
|
5750
|
+
} else {
|
|
5751
|
+
console.error("no note found to remove");
|
|
5601
5752
|
}
|
|
5602
|
-
|
|
5603
|
-
|
|
5753
|
+
}
|
|
5754
|
+
render(ctx, camera, mousePosition) {
|
|
5755
|
+
__privateSet(this, _noteHovering, null);
|
|
5756
|
+
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
5757
|
+
if (mousePosition) {
|
|
5758
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5759
|
+
__privateGet(this, _notes)[i].setHovering(false);
|
|
5760
|
+
if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
|
|
5761
|
+
__privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
|
|
5762
|
+
}
|
|
5763
|
+
}
|
|
5604
5764
|
}
|
|
5605
|
-
if (__privateGet(this,
|
|
5606
|
-
|
|
5765
|
+
if (__privateGet(this, _noteHovering) != null) {
|
|
5766
|
+
__privateGet(this, _noteHovering).setHovering(true);
|
|
5767
|
+
if (mousePosition) {
|
|
5768
|
+
if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
|
|
5769
|
+
__privateSet(this, _hoveringHandle, 1 /* Left */);
|
|
5770
|
+
} else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
|
|
5771
|
+
__privateSet(this, _hoveringHandle, 2 /* Right */);
|
|
5772
|
+
}
|
|
5773
|
+
}
|
|
5607
5774
|
}
|
|
5608
|
-
|
|
5609
|
-
|
|
5775
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5776
|
+
__privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
|
|
5610
5777
|
}
|
|
5778
|
+
return;
|
|
5611
5779
|
}
|
|
5612
5780
|
};
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
_grow = new WeakMap();
|
|
5622
|
-
_display = new WeakMap();
|
|
5623
|
-
_RenderElementBase_instances = new WeakSet();
|
|
5624
|
-
horizontalOffset_fn = function() {
|
|
5625
|
-
return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding2).Left + __privateGet(this, _padding2).Right;
|
|
5626
|
-
};
|
|
5627
|
-
verticalOffset_fn = function() {
|
|
5628
|
-
return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding2).Top + __privateGet(this, _padding2).Bottom;
|
|
5629
|
-
};
|
|
5630
|
-
totalTopOffset_fn = function() {
|
|
5631
|
-
return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding2).Top;
|
|
5632
|
-
};
|
|
5633
|
-
totalLeftOffset_fn = function() {
|
|
5634
|
-
return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding2).Left;
|
|
5635
|
-
};
|
|
5781
|
+
_notes = new WeakMap();
|
|
5782
|
+
_noteHovering = new WeakMap();
|
|
5783
|
+
_noteSelected = new WeakMap();
|
|
5784
|
+
_hoveringHandle = new WeakMap();
|
|
5785
|
+
_onNoteAddedCallbacks = new WeakMap();
|
|
5786
|
+
_onNoteRemovedCallbacks = new WeakMap();
|
|
5787
|
+
_onNoteDragStartCallbacks = new WeakMap();
|
|
5788
|
+
_onNoteDragStopCallbacks = new WeakMap();
|
|
5636
5789
|
|
|
5637
|
-
// src/
|
|
5638
|
-
var
|
|
5639
|
-
var
|
|
5640
|
-
constructor(
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
__privateAdd(this, _elements);
|
|
5644
|
-
__privateAdd(this, _layout);
|
|
5645
|
-
__privateAdd(this, _alignment);
|
|
5646
|
-
__privateSet(this, _elements, elements);
|
|
5647
|
-
__privateSet(this, _layout, "column" /* Column */);
|
|
5648
|
-
__privateSet(this, _alignment, "stretch" /* Stretch */);
|
|
5790
|
+
// src/pass/subsystem.ts
|
|
5791
|
+
var _queue;
|
|
5792
|
+
var PassSubsystem = class {
|
|
5793
|
+
constructor() {
|
|
5794
|
+
__privateAdd(this, _queue);
|
|
5795
|
+
__privateSet(this, _queue, new List());
|
|
5649
5796
|
}
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
const eleSize = { x: 0, y: 0 };
|
|
5654
|
-
switch (__privateGet(this, _layout)) {
|
|
5655
|
-
case "column" /* Column */:
|
|
5656
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5657
|
-
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
5658
|
-
out.x = Math.max(out.x, eleSize.x);
|
|
5659
|
-
out.y += eleSize.y;
|
|
5660
|
-
}
|
|
5661
|
-
break;
|
|
5662
|
-
case "row" /* Row */:
|
|
5663
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5664
|
-
__privateGet(this, _elements)[i].size(ctx, eleSize);
|
|
5665
|
-
out.y = Math.max(out.y, eleSize.y);
|
|
5666
|
-
out.x += eleSize.x;
|
|
5667
|
-
}
|
|
5668
|
-
break;
|
|
5669
|
-
default:
|
|
5670
|
-
throw new Error("unknown layout: " + __privateGet(this, _layout));
|
|
5797
|
+
queue(lambda) {
|
|
5798
|
+
if (!lambda) {
|
|
5799
|
+
return;
|
|
5671
5800
|
}
|
|
5801
|
+
__privateGet(this, _queue).Push(lambda);
|
|
5672
5802
|
}
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
__privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
|
|
5677
|
-
break;
|
|
5678
|
-
default:
|
|
5679
|
-
throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
|
|
5803
|
+
render(ctx, camera, mousePosition) {
|
|
5804
|
+
for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
|
|
5805
|
+
__privateGet(this, _queue).At(i)();
|
|
5680
5806
|
}
|
|
5807
|
+
__privateGet(this, _queue).Clear();
|
|
5808
|
+
return;
|
|
5681
5809
|
}
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
_layout = new WeakMap();
|
|
5685
|
-
_alignment = new WeakMap();
|
|
5686
|
-
_ContainerRenderElement_instances = new WeakSet();
|
|
5687
|
-
renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
|
|
5688
|
-
const currnetPos = { x: position.x, y: position.y };
|
|
5689
|
-
const scaledEleSize = { x: 0, y: 0 };
|
|
5690
|
-
for (let i = 0; i < __privateGet(this, _elements).length; i++) {
|
|
5691
|
-
const ele = __privateGet(this, _elements)[i];
|
|
5692
|
-
ele.size(ctx, scaledEleSize);
|
|
5693
|
-
ScaleVector(scaledEleSize, graphScale);
|
|
5694
|
-
switch (__privateGet(this, _alignment)) {
|
|
5695
|
-
case "stretch" /* Stretch */:
|
|
5696
|
-
currnetPos.x = position.x;
|
|
5697
|
-
scaledEleSize.x = scaledFillableSpace.x;
|
|
5698
|
-
break;
|
|
5699
|
-
// I'm not sure if this is even needed, I feel like this should
|
|
5700
|
-
// already be the case.
|
|
5701
|
-
case "start" /* Start */:
|
|
5702
|
-
currnetPos.x = position.x;
|
|
5703
|
-
break;
|
|
5704
|
-
case "end" /* End */:
|
|
5705
|
-
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
|
|
5706
|
-
break;
|
|
5707
|
-
case "center" /* Center */:
|
|
5708
|
-
currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
|
|
5709
|
-
break;
|
|
5710
|
-
default:
|
|
5711
|
-
throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
|
|
5712
|
-
}
|
|
5713
|
-
ele.render(ctx, currnetPos, graphScale, scaledEleSize);
|
|
5714
|
-
currnetPos.y += scaledEleSize.y;
|
|
5810
|
+
openContextMenu(ctx, position) {
|
|
5811
|
+
return null;
|
|
5715
5812
|
}
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
// src/elements/text.ts
|
|
5719
|
-
var _text7, _align, _verticalAlign;
|
|
5720
|
-
var TextElement = class extends RenderElementBase {
|
|
5721
|
-
constructor(text, styling) {
|
|
5722
|
-
var _a, _b;
|
|
5723
|
-
super(styling);
|
|
5724
|
-
__privateAdd(this, _text7);
|
|
5725
|
-
__privateAdd(this, _align);
|
|
5726
|
-
__privateAdd(this, _verticalAlign);
|
|
5727
|
-
__privateSet(this, _text7, text);
|
|
5728
|
-
__privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
|
|
5729
|
-
__privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
|
|
5813
|
+
clickStart(mousePosition, camera, ctrlKey) {
|
|
5814
|
+
return false;
|
|
5730
5815
|
}
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
this.calcSize(ctx, scale);
|
|
5734
|
-
ScaleVector(scale, graphScale);
|
|
5735
|
-
const justifiedPosition = Zero();
|
|
5736
|
-
CopyVector2(justifiedPosition, position);
|
|
5737
|
-
ctx.textAlign = "left";
|
|
5738
|
-
ctx.textBaseline = "top";
|
|
5739
|
-
switch (__privateGet(this, _align)) {
|
|
5740
|
-
case "left" /* Left */:
|
|
5741
|
-
break;
|
|
5742
|
-
case "right" /* Right */:
|
|
5743
|
-
justifiedPosition.x += scaledFillableSpace.x - scale.x;
|
|
5744
|
-
break;
|
|
5745
|
-
case "center" /* Center */:
|
|
5746
|
-
justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
|
|
5747
|
-
break;
|
|
5748
|
-
default:
|
|
5749
|
-
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
5750
|
-
}
|
|
5751
|
-
switch (__privateGet(this, _verticalAlign)) {
|
|
5752
|
-
case "top" /* Top */:
|
|
5753
|
-
break;
|
|
5754
|
-
case "bottom" /* Bottom */:
|
|
5755
|
-
justifiedPosition.y += scaledFillableSpace.y - scale.y;
|
|
5756
|
-
break;
|
|
5757
|
-
case "center" /* Center */:
|
|
5758
|
-
justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
|
|
5759
|
-
break;
|
|
5760
|
-
default:
|
|
5761
|
-
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
5762
|
-
}
|
|
5763
|
-
__privateGet(this, _text7).render(ctx, graphScale, justifiedPosition);
|
|
5816
|
+
mouseDragEvent(delta, scale) {
|
|
5817
|
+
return false;
|
|
5764
5818
|
}
|
|
5765
|
-
|
|
5766
|
-
|
|
5819
|
+
fileDrop(file) {
|
|
5820
|
+
return false;
|
|
5821
|
+
}
|
|
5822
|
+
clickEnd() {
|
|
5767
5823
|
}
|
|
5768
5824
|
};
|
|
5769
|
-
|
|
5770
|
-
_align = new WeakMap();
|
|
5771
|
-
_verticalAlign = new WeakMap();
|
|
5825
|
+
_queue = new WeakMap();
|
|
5772
5826
|
|
|
5773
5827
|
// src/quickMenu.ts
|
|
5774
5828
|
var _text8;
|