@elicdavis/node-flow 0.1.1 → 0.1.2
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 +725 -674
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +725 -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 +53 -17
package/dist/index.js
CHANGED
|
@@ -786,6 +786,507 @@ 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;
|
|
1026
|
+
var TextElement = class extends RenderElementBase {
|
|
1027
|
+
constructor(text, styling) {
|
|
1028
|
+
var _a, _b;
|
|
1029
|
+
super(styling);
|
|
1030
|
+
__privateAdd(this, _text);
|
|
1031
|
+
__privateAdd(this, _align);
|
|
1032
|
+
__privateAdd(this, _verticalAlign);
|
|
1033
|
+
__privateSet(this, _text, text);
|
|
1034
|
+
__privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
|
|
1035
|
+
__privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
|
|
1036
|
+
}
|
|
1037
|
+
doRender(ctx, position, graphScale, scaledFillableSpace) {
|
|
1038
|
+
const scale = Zero();
|
|
1039
|
+
this.calcSize(ctx, scale, scaledFillableSpace);
|
|
1040
|
+
ScaleVector(scale, graphScale);
|
|
1041
|
+
const justifiedPosition = Zero();
|
|
1042
|
+
CopyVector2(justifiedPosition, position);
|
|
1043
|
+
ctx.textAlign = "left";
|
|
1044
|
+
ctx.textBaseline = "top";
|
|
1045
|
+
switch (__privateGet(this, _align)) {
|
|
1046
|
+
case "left" /* Left */:
|
|
1047
|
+
break;
|
|
1048
|
+
case "right" /* Right */:
|
|
1049
|
+
justifiedPosition.x += scaledFillableSpace.x - scale.x;
|
|
1050
|
+
break;
|
|
1051
|
+
case "center" /* Center */:
|
|
1052
|
+
justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
|
|
1053
|
+
break;
|
|
1054
|
+
default:
|
|
1055
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1056
|
+
}
|
|
1057
|
+
switch (__privateGet(this, _verticalAlign)) {
|
|
1058
|
+
case "top" /* Top */:
|
|
1059
|
+
break;
|
|
1060
|
+
case "bottom" /* Bottom */:
|
|
1061
|
+
justifiedPosition.y += scaledFillableSpace.y - scale.y;
|
|
1062
|
+
break;
|
|
1063
|
+
case "center" /* Center */:
|
|
1064
|
+
justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
|
|
1065
|
+
break;
|
|
1066
|
+
default:
|
|
1067
|
+
throw new Error("unimplemented justification: " + __privateGet(this, _align));
|
|
1068
|
+
}
|
|
1069
|
+
if (scaledFillableSpace.x <= 0) {
|
|
1070
|
+
__privateGet(this, _text).render(ctx, graphScale, justifiedPosition);
|
|
1071
|
+
} else {
|
|
1072
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, scaledFillableSpace.x);
|
|
1073
|
+
const tempSize = { x: 0, y: 0 };
|
|
1074
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1075
|
+
eles[i].render(ctx, graphScale, justifiedPosition);
|
|
1076
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1077
|
+
justifiedPosition.y += tempSize.y;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
calcSize(ctx, out, limitations) {
|
|
1082
|
+
if (limitations.x <= 0) {
|
|
1083
|
+
__privateGet(this, _text).size(ctx, 1, out);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const eles = __privateGet(this, _text).breakIntoLines(ctx, limitations.x);
|
|
1087
|
+
const tempSize = { x: 0, y: 0 };
|
|
1088
|
+
out.x = 0;
|
|
1089
|
+
out.y = 0;
|
|
1090
|
+
for (let i = 0; i < eles.length; i++) {
|
|
1091
|
+
eles[i].size(ctx, 1, tempSize);
|
|
1092
|
+
out.x = Math.max(tempSize.x, out.x);
|
|
1093
|
+
out.y += tempSize.y;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
_text = new WeakMap();
|
|
1098
|
+
_align = new WeakMap();
|
|
1099
|
+
_verticalAlign = new WeakMap();
|
|
1100
|
+
|
|
1101
|
+
// src/utils/string.ts
|
|
1102
|
+
var binarySearch = ({ max, getValue, match }) => {
|
|
1103
|
+
let min = 0;
|
|
1104
|
+
while (min <= max) {
|
|
1105
|
+
let guess = Math.floor((min + max) / 2);
|
|
1106
|
+
const compareVal = getValue(guess);
|
|
1107
|
+
if (compareVal === match) return guess;
|
|
1108
|
+
if (compareVal < match) min = guess + 1;
|
|
1109
|
+
else max = guess - 1;
|
|
1110
|
+
}
|
|
1111
|
+
return max;
|
|
1112
|
+
};
|
|
1113
|
+
function fitString(ctx, str, maxWidth) {
|
|
1114
|
+
let width2 = ctx.measureText(str).width;
|
|
1115
|
+
const ellipsis = "\u2026";
|
|
1116
|
+
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
1117
|
+
if (width2 <= maxWidth || width2 <= ellipsisWidth) {
|
|
1118
|
+
return str;
|
|
1119
|
+
}
|
|
1120
|
+
const index = binarySearch({
|
|
1121
|
+
max: str.length,
|
|
1122
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1123
|
+
match: maxWidth - ellipsisWidth
|
|
1124
|
+
});
|
|
1125
|
+
return str.substring(0, index) + ellipsis;
|
|
1126
|
+
}
|
|
1127
|
+
function splitString(ctx, str, maxWidth) {
|
|
1128
|
+
let width2 = ctx.measureText(str).width;
|
|
1129
|
+
if (width2 <= maxWidth) {
|
|
1130
|
+
return [str];
|
|
1131
|
+
}
|
|
1132
|
+
let index = binarySearch({
|
|
1133
|
+
max: str.length,
|
|
1134
|
+
getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
|
|
1135
|
+
match: maxWidth
|
|
1136
|
+
});
|
|
1137
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1138
|
+
if (str.charAt(backward) === " ") {
|
|
1139
|
+
index = backward + 1;
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return [str.substring(0, index), str.substring(index)];
|
|
1144
|
+
}
|
|
1145
|
+
function splitStringIntoLines(ctx, str, maxWidth) {
|
|
1146
|
+
let width2 = ctx.measureText(str).width;
|
|
1147
|
+
if (width2 <= maxWidth) {
|
|
1148
|
+
return [str];
|
|
1149
|
+
}
|
|
1150
|
+
const strings = new Array();
|
|
1151
|
+
let remaining = str;
|
|
1152
|
+
while (remaining !== "") {
|
|
1153
|
+
let index = binarySearch({
|
|
1154
|
+
max: remaining.length,
|
|
1155
|
+
getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
1156
|
+
match: maxWidth
|
|
1157
|
+
});
|
|
1158
|
+
if (index === remaining.length) {
|
|
1159
|
+
strings.push(remaining.substring(0, index));
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
for (let backward = index - 1; backward >= 1; backward--) {
|
|
1163
|
+
if (remaining.charAt(backward) === " ") {
|
|
1164
|
+
index = backward + 1;
|
|
1165
|
+
break;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
strings.push(remaining.substring(0, index));
|
|
1169
|
+
remaining = remaining.substring(index);
|
|
1170
|
+
}
|
|
1171
|
+
return strings;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// src/types/text.ts
|
|
1175
|
+
var _measured, _size2, _style, _value, _Text_instances, measure_fn;
|
|
1176
|
+
var _Text = class _Text {
|
|
1177
|
+
constructor(value, style) {
|
|
1178
|
+
__privateAdd(this, _Text_instances);
|
|
1179
|
+
__privateAdd(this, _measured);
|
|
1180
|
+
__privateAdd(this, _size2);
|
|
1181
|
+
__privateAdd(this, _style);
|
|
1182
|
+
__privateAdd(this, _value);
|
|
1183
|
+
__privateSet(this, _value, value);
|
|
1184
|
+
__privateSet(this, _measured, false);
|
|
1185
|
+
__privateSet(this, _size2, Zero());
|
|
1186
|
+
__privateSet(this, _style, new TextStyle(style));
|
|
1187
|
+
if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
|
|
1188
|
+
document.fonts.addEventListener("loadingdone", (event) => {
|
|
1189
|
+
__privateSet(this, _measured, false);
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
set(newValue) {
|
|
1194
|
+
__privateSet(this, _value, newValue);
|
|
1195
|
+
__privateSet(this, _measured, false);
|
|
1196
|
+
}
|
|
1197
|
+
get() {
|
|
1198
|
+
return __privateGet(this, _value);
|
|
1199
|
+
}
|
|
1200
|
+
breakIntoLines(ctx, maxWidth) {
|
|
1201
|
+
const results = new Array();
|
|
1202
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1203
|
+
const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
|
|
1204
|
+
if (entries.length === 1) {
|
|
1205
|
+
return [this];
|
|
1206
|
+
}
|
|
1207
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1208
|
+
const text = new _Text(entries[i]);
|
|
1209
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1210
|
+
results.push(text);
|
|
1211
|
+
}
|
|
1212
|
+
return results;
|
|
1213
|
+
}
|
|
1214
|
+
split(char) {
|
|
1215
|
+
const entries = __privateGet(this, _value).split(char);
|
|
1216
|
+
const results = new Array();
|
|
1217
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1218
|
+
const text = new _Text(entries[i]);
|
|
1219
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1220
|
+
results.push(text);
|
|
1221
|
+
}
|
|
1222
|
+
return results;
|
|
1223
|
+
}
|
|
1224
|
+
splitAtIndex(index) {
|
|
1225
|
+
const results = [
|
|
1226
|
+
new _Text(__privateGet(this, _value).substring(0, index)),
|
|
1227
|
+
new _Text(__privateGet(this, _value).substring(index, 0))
|
|
1228
|
+
];
|
|
1229
|
+
for (let i = 0; i < results.length; i++) {
|
|
1230
|
+
__privateSet(results[i], _style, __privateGet(this, _style));
|
|
1231
|
+
}
|
|
1232
|
+
return results;
|
|
1233
|
+
}
|
|
1234
|
+
splitAtWidth(ctx, maxWidth) {
|
|
1235
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1236
|
+
const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
|
|
1237
|
+
if (entries.length === 1) {
|
|
1238
|
+
return [this];
|
|
1239
|
+
}
|
|
1240
|
+
const results = new Array();
|
|
1241
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1242
|
+
const text = new _Text(entries[i]);
|
|
1243
|
+
__privateSet(text, _style, __privateGet(this, _style));
|
|
1244
|
+
results.push(text);
|
|
1245
|
+
}
|
|
1246
|
+
return results;
|
|
1247
|
+
}
|
|
1248
|
+
size(ctx, scale, out) {
|
|
1249
|
+
__privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
|
|
1250
|
+
CopyVector2(out, __privateGet(this, _size2));
|
|
1251
|
+
ScaleVector(out, scale);
|
|
1252
|
+
}
|
|
1253
|
+
setColor(color) {
|
|
1254
|
+
__privateGet(this, _style).setColor(color);
|
|
1255
|
+
}
|
|
1256
|
+
getColor() {
|
|
1257
|
+
return __privateGet(this, _style).getColor();
|
|
1258
|
+
}
|
|
1259
|
+
setSize(size) {
|
|
1260
|
+
__privateGet(this, _style).setSize(size);
|
|
1261
|
+
}
|
|
1262
|
+
setWeight(weight) {
|
|
1263
|
+
__privateGet(this, _style).setWeight(weight);
|
|
1264
|
+
}
|
|
1265
|
+
render(ctx, scale, position) {
|
|
1266
|
+
__privateGet(this, _style).setupStyle(ctx, scale);
|
|
1267
|
+
ctx.fillText(__privateGet(this, _value), position.x, position.y);
|
|
1268
|
+
}
|
|
1269
|
+
style() {
|
|
1270
|
+
return __privateGet(this, _style);
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
_measured = new WeakMap();
|
|
1274
|
+
_size2 = new WeakMap();
|
|
1275
|
+
_style = new WeakMap();
|
|
1276
|
+
_value = new WeakMap();
|
|
1277
|
+
_Text_instances = new WeakSet();
|
|
1278
|
+
measure_fn = function(ctx) {
|
|
1279
|
+
if (__privateGet(this, _measured)) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
__privateGet(this, _style).setupStyle(ctx, 1);
|
|
1283
|
+
const measurements = ctx.measureText(__privateGet(this, _value));
|
|
1284
|
+
__privateGet(this, _size2).x = measurements.width;
|
|
1285
|
+
__privateGet(this, _size2).y = measurements.actualBoundingBoxAscent + measurements.actualBoundingBoxDescent;
|
|
1286
|
+
__privateSet(this, _measured, true);
|
|
1287
|
+
};
|
|
1288
|
+
var Text = _Text;
|
|
1289
|
+
|
|
789
1290
|
// src/utils/math.ts
|
|
790
1291
|
function Clamp(v, min, max) {
|
|
791
1292
|
return Math.min(Math.max(v, min), max);
|
|
@@ -878,7 +1379,7 @@ function fallbackColor(type, s) {
|
|
|
878
1379
|
HSV2RGB(hsv, color);
|
|
879
1380
|
return RgbToHex(color);
|
|
880
1381
|
}
|
|
881
|
-
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
1382
|
+
var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _dataTypePopupElement, _onConnectionAdded, _onConnectionRemoved, _box;
|
|
882
1383
|
var Port = class {
|
|
883
1384
|
constructor(node, portType, config) {
|
|
884
1385
|
__privateAdd(this, _node);
|
|
@@ -888,6 +1389,7 @@ var Port = class {
|
|
|
888
1389
|
__privateAdd(this, _connections);
|
|
889
1390
|
__privateAdd(this, _portType);
|
|
890
1391
|
__privateAdd(this, _dataType);
|
|
1392
|
+
__privateAdd(this, _dataTypePopupElement);
|
|
891
1393
|
__privateAdd(this, _onConnectionAdded);
|
|
892
1394
|
__privateAdd(this, _onConnectionRemoved);
|
|
893
1395
|
__privateAdd(this, _box, { Position: { x: 0, y: 0 }, Size: { x: 0, y: 0 } });
|
|
@@ -917,6 +1419,40 @@ var Port = class {
|
|
|
917
1419
|
if (config == null ? void 0 : config.onConnectionRemoved) {
|
|
918
1420
|
__privateGet(this, _onConnectionRemoved).push(config == null ? void 0 : config.onConnectionRemoved);
|
|
919
1421
|
}
|
|
1422
|
+
const containerElements = new Array();
|
|
1423
|
+
let dataTypeDisplay = __privateGet(this, _dataType);
|
|
1424
|
+
if ((config == null ? void 0 : config.array) === true) {
|
|
1425
|
+
dataTypeDisplay = "Array<" + dataTypeDisplay + ">";
|
|
1426
|
+
}
|
|
1427
|
+
containerElements.push(new TextElement(
|
|
1428
|
+
new Text(dataTypeDisplay, {
|
|
1429
|
+
color: "white"
|
|
1430
|
+
}),
|
|
1431
|
+
{
|
|
1432
|
+
Align: "center" /* Center */
|
|
1433
|
+
}
|
|
1434
|
+
));
|
|
1435
|
+
const description = config == null ? void 0 : config.description;
|
|
1436
|
+
if (description && description !== "") {
|
|
1437
|
+
containerElements.push(new TextElement(
|
|
1438
|
+
new Text(description, { color: "white", style: "italic" /* Italic */ }),
|
|
1439
|
+
{
|
|
1440
|
+
Align: "center" /* Center */,
|
|
1441
|
+
Padding: { Top: 8 },
|
|
1442
|
+
MaxWidth: 300
|
|
1443
|
+
}
|
|
1444
|
+
));
|
|
1445
|
+
}
|
|
1446
|
+
__privateSet(this, _dataTypePopupElement, new ContainerRenderElement(
|
|
1447
|
+
containerElements,
|
|
1448
|
+
{
|
|
1449
|
+
BackgroundColor: "rgba(0, 0, 0, 0.75)",
|
|
1450
|
+
Border: {
|
|
1451
|
+
Radius: 6
|
|
1452
|
+
},
|
|
1453
|
+
Padding: 13
|
|
1454
|
+
}
|
|
1455
|
+
));
|
|
920
1456
|
}
|
|
921
1457
|
addConnection(connection) {
|
|
922
1458
|
const c = __privateGet(this, _connections).length;
|
|
@@ -985,16 +1521,9 @@ var Port = class {
|
|
|
985
1521
|
const xPos = position.x;
|
|
986
1522
|
const yPos = position.y;
|
|
987
1523
|
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);
|
|
1524
|
+
const size = { x: 0, y: 0 };
|
|
1525
|
+
__privateGet(this, _dataTypePopupElement).calcSize(ctx, size, { x: -1, y: -1 });
|
|
1526
|
+
__privateGet(this, _dataTypePopupElement).render(ctx, { x: xPos - size.x / 2, y: yPos }, 1, size);
|
|
998
1527
|
});
|
|
999
1528
|
}
|
|
1000
1529
|
__privateGet(this, _box).Position.x = position.x - scaledRadius;
|
|
@@ -1021,6 +1550,7 @@ _filledStyle = new WeakMap();
|
|
|
1021
1550
|
_connections = new WeakMap();
|
|
1022
1551
|
_portType = new WeakMap();
|
|
1023
1552
|
_dataType = new WeakMap();
|
|
1553
|
+
_dataTypePopupElement = new WeakMap();
|
|
1024
1554
|
_onConnectionAdded = new WeakMap();
|
|
1025
1555
|
_onConnectionRemoved = new WeakMap();
|
|
1026
1556
|
_box = new WeakMap();
|
|
@@ -1032,29 +1562,29 @@ function StrokeStyleWithFallback(input, fallback) {
|
|
|
1032
1562
|
size: (input == null ? void 0 : input.size) === void 0 ? fallback == null ? void 0 : fallback.size : input == null ? void 0 : input.size
|
|
1033
1563
|
};
|
|
1034
1564
|
}
|
|
1035
|
-
var
|
|
1565
|
+
var _size3, _color2;
|
|
1036
1566
|
var StrokeStyle = class {
|
|
1037
1567
|
constructor(config) {
|
|
1038
|
-
__privateAdd(this,
|
|
1568
|
+
__privateAdd(this, _size3);
|
|
1039
1569
|
__privateAdd(this, _color2);
|
|
1040
|
-
__privateSet(this,
|
|
1570
|
+
__privateSet(this, _size3, (config == null ? void 0 : config.size) === void 0 ? 0.5 : config.size);
|
|
1041
1571
|
__privateSet(this, _color2, (config == null ? void 0 : config.color) === void 0 ? "black" : config.color);
|
|
1042
1572
|
}
|
|
1043
1573
|
setupStyle(ctx, scale) {
|
|
1044
1574
|
ctx.strokeStyle = __privateGet(this, _color2);
|
|
1045
|
-
ctx.lineWidth = scale * __privateGet(this,
|
|
1575
|
+
ctx.lineWidth = scale * __privateGet(this, _size3);
|
|
1046
1576
|
}
|
|
1047
1577
|
setColor(newColor) {
|
|
1048
1578
|
__privateSet(this, _color2, newColor);
|
|
1049
1579
|
}
|
|
1050
1580
|
setSize(newSize) {
|
|
1051
|
-
__privateSet(this,
|
|
1581
|
+
__privateSet(this, _size3, newSize);
|
|
1052
1582
|
}
|
|
1053
1583
|
size() {
|
|
1054
|
-
return __privateGet(this,
|
|
1584
|
+
return __privateGet(this, _size3);
|
|
1055
1585
|
}
|
|
1056
1586
|
};
|
|
1057
|
-
|
|
1587
|
+
_size3 = new WeakMap();
|
|
1058
1588
|
_color2 = new WeakMap();
|
|
1059
1589
|
|
|
1060
1590
|
// src/styles/box.ts
|
|
@@ -1065,20 +1595,20 @@ function BoxStyleWithFallback(input, fallback) {
|
|
|
1065
1595
|
border: StrokeStyleWithFallback(input == null ? void 0 : input.border, fallback == null ? void 0 : fallback.border)
|
|
1066
1596
|
};
|
|
1067
1597
|
}
|
|
1068
|
-
var
|
|
1598
|
+
var _border2, _color3, _radius, _BoxStyle_instances, box_fn, draw_fn;
|
|
1069
1599
|
var BoxStyle = class {
|
|
1070
1600
|
constructor(config) {
|
|
1071
1601
|
__privateAdd(this, _BoxStyle_instances);
|
|
1072
|
-
__privateAdd(this,
|
|
1602
|
+
__privateAdd(this, _border2);
|
|
1073
1603
|
__privateAdd(this, _color3);
|
|
1074
1604
|
__privateAdd(this, _radius);
|
|
1075
1605
|
__privateSet(this, _color3, (config == null ? void 0 : config.color) === void 0 ? "#CCCCCC" : config.color);
|
|
1076
|
-
__privateSet(this,
|
|
1606
|
+
__privateSet(this, _border2, (config == null ? void 0 : config.border) === void 0 ? null : new StrokeStyle(config.border));
|
|
1077
1607
|
__privateSet(this, _radius, (config == null ? void 0 : config.radius) === void 0 ? 2 : config.radius);
|
|
1078
1608
|
}
|
|
1079
1609
|
Outline(ctx, box, scale, radius) {
|
|
1080
1610
|
var _a;
|
|
1081
|
-
(_a = __privateGet(this,
|
|
1611
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1082
1612
|
ctx.beginPath();
|
|
1083
1613
|
ctx.roundRect(
|
|
1084
1614
|
box.Position.x,
|
|
@@ -1103,238 +1633,49 @@ var BoxStyle = class {
|
|
|
1103
1633
|
ctx.stroke();
|
|
1104
1634
|
}
|
|
1105
1635
|
borderSize() {
|
|
1106
|
-
if (__privateGet(this,
|
|
1636
|
+
if (__privateGet(this, _border2) === null) {
|
|
1107
1637
|
return 0;
|
|
1108
1638
|
}
|
|
1109
|
-
return __privateGet(this,
|
|
1639
|
+
return __privateGet(this, _border2).size();
|
|
1110
1640
|
}
|
|
1111
1641
|
radius() {
|
|
1112
1642
|
return __privateGet(this, _radius);
|
|
1113
1643
|
}
|
|
1114
1644
|
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);
|
|
1645
|
+
__privateSet(this, _color3, color);
|
|
1317
1646
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1647
|
+
setBorderColor(color) {
|
|
1648
|
+
if (__privateGet(this, _border2) === null) {
|
|
1649
|
+
__privateSet(this, _border2, new StrokeStyle({
|
|
1650
|
+
color
|
|
1651
|
+
}));
|
|
1652
|
+
} else {
|
|
1653
|
+
__privateGet(this, _border2).setColor(color);
|
|
1654
|
+
}
|
|
1320
1655
|
}
|
|
1321
1656
|
};
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1657
|
+
_border2 = new WeakMap();
|
|
1658
|
+
_color3 = new WeakMap();
|
|
1659
|
+
_radius = new WeakMap();
|
|
1660
|
+
_BoxStyle_instances = new WeakSet();
|
|
1661
|
+
box_fn = function(ctx, box, scale, radius) {
|
|
1662
|
+
var _a;
|
|
1663
|
+
ctx.fillStyle = __privateGet(this, _color3);
|
|
1664
|
+
(_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
|
|
1665
|
+
ctx.beginPath();
|
|
1666
|
+
ctx.roundRect(
|
|
1667
|
+
box.Position.x,
|
|
1668
|
+
box.Position.y,
|
|
1669
|
+
box.Size.x,
|
|
1670
|
+
box.Size.y,
|
|
1671
|
+
radius
|
|
1672
|
+
);
|
|
1673
|
+
ctx.fill();
|
|
1674
|
+
};
|
|
1675
|
+
draw_fn = function(ctx, box, scale, radius) {
|
|
1676
|
+
__privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
|
|
1677
|
+
ctx.stroke();
|
|
1336
1678
|
};
|
|
1337
|
-
var Text = _Text;
|
|
1338
1679
|
|
|
1339
1680
|
// src/popup.ts
|
|
1340
1681
|
var _title, _options, _content, _onClose, _buttonCSS, _popup;
|
|
@@ -1409,15 +1750,15 @@ function TextBoxStyleWithFallback(input, fallback) {
|
|
|
1409
1750
|
textBaseline: (input == null ? void 0 : input.textBaseline) === void 0 ? fallback == null ? void 0 : fallback.textBaseline : input == null ? void 0 : input.textBaseline
|
|
1410
1751
|
};
|
|
1411
1752
|
}
|
|
1412
|
-
var _box2,
|
|
1753
|
+
var _box2, _text2, _textAlign, _textBaseline;
|
|
1413
1754
|
var TextBoxStyle = class {
|
|
1414
1755
|
constructor(config) {
|
|
1415
1756
|
__privateAdd(this, _box2);
|
|
1416
|
-
__privateAdd(this,
|
|
1757
|
+
__privateAdd(this, _text2);
|
|
1417
1758
|
__privateAdd(this, _textAlign);
|
|
1418
1759
|
__privateAdd(this, _textBaseline);
|
|
1419
1760
|
__privateSet(this, _box2, new BoxStyle(config == null ? void 0 : config.box));
|
|
1420
|
-
__privateSet(this,
|
|
1761
|
+
__privateSet(this, _text2, new TextStyle(config == null ? void 0 : config.text));
|
|
1421
1762
|
__privateSet(this, _textAlign, (config == null ? void 0 : config.textAlign) === void 0 ? "center" /* Center */ : config.textAlign);
|
|
1422
1763
|
__privateSet(this, _textBaseline, (config == null ? void 0 : config.textBaseline) === void 0 ? "middle" /* Middle */ : config.textBaseline);
|
|
1423
1764
|
}
|
|
@@ -1425,7 +1766,7 @@ var TextBoxStyle = class {
|
|
|
1425
1766
|
__privateGet(this, _box2).Draw(ctx, box, scale);
|
|
1426
1767
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1427
1768
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1428
|
-
__privateGet(this,
|
|
1769
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1429
1770
|
ctx.fillText(
|
|
1430
1771
|
text,
|
|
1431
1772
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1436,7 +1777,7 @@ var TextBoxStyle = class {
|
|
|
1436
1777
|
__privateGet(this, _box2).DrawUnderline(ctx, box, scale);
|
|
1437
1778
|
ctx.textAlign = __privateGet(this, _textAlign);
|
|
1438
1779
|
ctx.textBaseline = __privateGet(this, _textBaseline);
|
|
1439
|
-
__privateGet(this,
|
|
1780
|
+
__privateGet(this, _text2).setupStyle(ctx, scale);
|
|
1440
1781
|
ctx.fillText(
|
|
1441
1782
|
text,
|
|
1442
1783
|
box.Position.x + box.Size.x / 2,
|
|
@@ -1444,7 +1785,7 @@ var TextBoxStyle = class {
|
|
|
1444
1785
|
);
|
|
1445
1786
|
}
|
|
1446
1787
|
setTextColor(color) {
|
|
1447
|
-
__privateGet(this,
|
|
1788
|
+
__privateGet(this, _text2).setColor(color);
|
|
1448
1789
|
}
|
|
1449
1790
|
setBoxColor(color) {
|
|
1450
1791
|
__privateGet(this, _box2).setColor(color);
|
|
@@ -1454,7 +1795,7 @@ var TextBoxStyle = class {
|
|
|
1454
1795
|
}
|
|
1455
1796
|
};
|
|
1456
1797
|
_box2 = new WeakMap();
|
|
1457
|
-
|
|
1798
|
+
_text2 = new WeakMap();
|
|
1458
1799
|
_textAlign = new WeakMap();
|
|
1459
1800
|
_textBaseline = new WeakMap();
|
|
1460
1801
|
|
|
@@ -1463,7 +1804,7 @@ var width = 150;
|
|
|
1463
1804
|
var height = 25;
|
|
1464
1805
|
|
|
1465
1806
|
// src/widgets/number.ts
|
|
1466
|
-
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle,
|
|
1807
|
+
var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle, _text3, _callback2;
|
|
1467
1808
|
var NumberWidget = class {
|
|
1468
1809
|
constructor(node, config) {
|
|
1469
1810
|
__privateAdd(this, _node2);
|
|
@@ -1471,10 +1812,10 @@ var NumberWidget = class {
|
|
|
1471
1812
|
__privateAdd(this, _value2);
|
|
1472
1813
|
__privateAdd(this, _idleBoxStyle);
|
|
1473
1814
|
__privateAdd(this, _highlightBoxStyle);
|
|
1474
|
-
__privateAdd(this,
|
|
1815
|
+
__privateAdd(this, _text3);
|
|
1475
1816
|
__privateAdd(this, _callback2);
|
|
1476
1817
|
__privateSet(this, _value2, 0);
|
|
1477
|
-
__privateSet(this,
|
|
1818
|
+
__privateSet(this, _text3, "0");
|
|
1478
1819
|
__privateSet(this, _node2, node);
|
|
1479
1820
|
__privateSet(this, _nodeProperty, config == null ? void 0 : config.property);
|
|
1480
1821
|
__privateSet(this, _idleBoxStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleBoxStyle, {
|
|
@@ -1521,7 +1862,7 @@ var NumberWidget = class {
|
|
|
1521
1862
|
if (__privateGet(this, _callback2) !== void 0) {
|
|
1522
1863
|
__privateGet(this, _callback2).call(this, __privateGet(this, _value2));
|
|
1523
1864
|
}
|
|
1524
|
-
__privateSet(this,
|
|
1865
|
+
__privateSet(this, _text3, "" + parseFloat(__privateGet(this, _value2).toPrecision(6)));
|
|
1525
1866
|
}
|
|
1526
1867
|
ClickStart() {
|
|
1527
1868
|
}
|
|
@@ -1564,7 +1905,7 @@ var NumberWidget = class {
|
|
|
1564
1905
|
style = __privateGet(this, _highlightBoxStyle);
|
|
1565
1906
|
}
|
|
1566
1907
|
}
|
|
1567
|
-
style.DrawUnderline(ctx, box, scale, __privateGet(this,
|
|
1908
|
+
style.DrawUnderline(ctx, box, scale, __privateGet(this, _text3));
|
|
1568
1909
|
return box;
|
|
1569
1910
|
}
|
|
1570
1911
|
};
|
|
@@ -1573,20 +1914,20 @@ _nodeProperty = new WeakMap();
|
|
|
1573
1914
|
_value2 = new WeakMap();
|
|
1574
1915
|
_idleBoxStyle = new WeakMap();
|
|
1575
1916
|
_highlightBoxStyle = new WeakMap();
|
|
1576
|
-
|
|
1917
|
+
_text3 = new WeakMap();
|
|
1577
1918
|
_callback2 = new WeakMap();
|
|
1578
1919
|
|
|
1579
1920
|
// src/widgets/button.ts
|
|
1580
|
-
var
|
|
1921
|
+
var _text4, _idleStyle, _hoverStyle, _clickStyle, _callback3, _gettingClicked;
|
|
1581
1922
|
var ButtonWidget = class {
|
|
1582
1923
|
constructor(config) {
|
|
1583
|
-
__privateAdd(this,
|
|
1924
|
+
__privateAdd(this, _text4);
|
|
1584
1925
|
__privateAdd(this, _idleStyle);
|
|
1585
1926
|
__privateAdd(this, _hoverStyle);
|
|
1586
1927
|
__privateAdd(this, _clickStyle);
|
|
1587
1928
|
__privateAdd(this, _callback3);
|
|
1588
1929
|
__privateAdd(this, _gettingClicked);
|
|
1589
|
-
__privateSet(this,
|
|
1930
|
+
__privateSet(this, _text4, (config == null ? void 0 : config.text) === void 0 ? "Button" : config == null ? void 0 : config.text);
|
|
1590
1931
|
__privateSet(this, _callback3, config == null ? void 0 : config.callback);
|
|
1591
1932
|
__privateSet(this, _gettingClicked, false);
|
|
1592
1933
|
__privateSet(this, _idleStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleStyle, {
|
|
@@ -1641,7 +1982,7 @@ var ButtonWidget = class {
|
|
|
1641
1982
|
if (__privateGet(this, _gettingClicked)) {
|
|
1642
1983
|
style = __privateGet(this, _clickStyle);
|
|
1643
1984
|
}
|
|
1644
|
-
style.Draw(ctx, box, scale, __privateGet(this,
|
|
1985
|
+
style.Draw(ctx, box, scale, __privateGet(this, _text4));
|
|
1645
1986
|
return box;
|
|
1646
1987
|
}
|
|
1647
1988
|
ClickStart() {
|
|
@@ -1654,7 +1995,7 @@ var ButtonWidget = class {
|
|
|
1654
1995
|
}
|
|
1655
1996
|
}
|
|
1656
1997
|
};
|
|
1657
|
-
|
|
1998
|
+
_text4 = new WeakMap();
|
|
1658
1999
|
_idleStyle = new WeakMap();
|
|
1659
2000
|
_hoverStyle = new WeakMap();
|
|
1660
2001
|
_clickStyle = new WeakMap();
|
|
@@ -1772,14 +2113,14 @@ _textBoxStyle = new WeakMap();
|
|
|
1772
2113
|
_callback4 = new WeakMap();
|
|
1773
2114
|
|
|
1774
2115
|
// src/widgets/slider.ts
|
|
1775
|
-
var _min, _max, _value4,
|
|
2116
|
+
var _min, _max, _value4, _text5, _snapIncrement, _node4, _nodeProperty3, _change, _release, _textStyle3, _backgroundColor2, _borderColor, _fillColor, _lastMousePosition2, _clickStartMousePosition, _clicking;
|
|
1776
2117
|
var SliderWidget = class {
|
|
1777
2118
|
constructor(node, config) {
|
|
1778
2119
|
// Data Variables =========================================================
|
|
1779
2120
|
__privateAdd(this, _min);
|
|
1780
2121
|
__privateAdd(this, _max);
|
|
1781
2122
|
__privateAdd(this, _value4);
|
|
1782
|
-
__privateAdd(this,
|
|
2123
|
+
__privateAdd(this, _text5);
|
|
1783
2124
|
__privateAdd(this, _snapIncrement);
|
|
1784
2125
|
__privateAdd(this, _node4);
|
|
1785
2126
|
__privateAdd(this, _nodeProperty3);
|
|
@@ -1788,7 +2129,7 @@ var SliderWidget = class {
|
|
|
1788
2129
|
__privateAdd(this, _release);
|
|
1789
2130
|
// Styling Variables ======================================================
|
|
1790
2131
|
__privateAdd(this, _textStyle3);
|
|
1791
|
-
__privateAdd(this,
|
|
2132
|
+
__privateAdd(this, _backgroundColor2);
|
|
1792
2133
|
__privateAdd(this, _borderColor);
|
|
1793
2134
|
__privateAdd(this, _fillColor);
|
|
1794
2135
|
// Runtime Variables ======================================================
|
|
@@ -1801,9 +2142,9 @@ var SliderWidget = class {
|
|
|
1801
2142
|
__privateSet(this, _max, (config == null ? void 0 : config.max) === void 0 ? 1 : config == null ? void 0 : config.max);
|
|
1802
2143
|
__privateSet(this, _snapIncrement, config == null ? void 0 : config.snapIncrement);
|
|
1803
2144
|
__privateSet(this, _nodeProperty3, config == null ? void 0 : config.property);
|
|
1804
|
-
__privateSet(this,
|
|
2145
|
+
__privateSet(this, _text5, "");
|
|
1805
2146
|
__privateSet(this, _release, config == null ? void 0 : config.release);
|
|
1806
|
-
__privateSet(this,
|
|
2147
|
+
__privateSet(this, _backgroundColor2, (config == null ? void 0 : config.backgroundColor) === void 0 ? Theme.Widget.BackgroundColor : config == null ? void 0 : config.backgroundColor);
|
|
1807
2148
|
__privateSet(this, _fillColor, (config == null ? void 0 : config.fillColor) === void 0 ? Theme.Widget.Slider.FillColor : config == null ? void 0 : config.fillColor);
|
|
1808
2149
|
__privateSet(this, _borderColor, (config == null ? void 0 : config.borderColor) === void 0 ? Theme.Widget.Border.Color : config == null ? void 0 : config.borderColor);
|
|
1809
2150
|
__privateSet(this, _textStyle3, new TextStyle(TextStyleFallback(config == null ? void 0 : config.textStyle, {
|
|
@@ -1829,7 +2170,7 @@ var SliderWidget = class {
|
|
|
1829
2170
|
if (__privateGet(this, _nodeProperty3)) {
|
|
1830
2171
|
__privateGet(this, _node4).setProperty(__privateGet(this, _nodeProperty3), __privateGet(this, _value4));
|
|
1831
2172
|
}
|
|
1832
|
-
__privateSet(this,
|
|
2173
|
+
__privateSet(this, _text5, __privateGet(this, _value4).toFixed(3));
|
|
1833
2174
|
if (__privateGet(this, _change) !== void 0) {
|
|
1834
2175
|
__privateGet(this, _change).call(this, __privateGet(this, _value4));
|
|
1835
2176
|
}
|
|
@@ -1851,7 +2192,7 @@ var SliderWidget = class {
|
|
|
1851
2192
|
const scaledWidth = width * scale;
|
|
1852
2193
|
const scaledHeight = height * scale;
|
|
1853
2194
|
const scaledBorderThickness = Theme.Widget.Border.Size * scale;
|
|
1854
|
-
ctx.fillStyle = __privateGet(this,
|
|
2195
|
+
ctx.fillStyle = __privateGet(this, _backgroundColor2);
|
|
1855
2196
|
ctx.strokeStyle = __privateGet(this, _borderColor);
|
|
1856
2197
|
ctx.lineWidth = scaledBorderThickness;
|
|
1857
2198
|
ctx.beginPath();
|
|
@@ -1879,7 +2220,7 @@ var SliderWidget = class {
|
|
|
1879
2220
|
ctx.textBaseline = "middle" /* Middle */;
|
|
1880
2221
|
__privateGet(this, _textStyle3).setupStyle(ctx, scale);
|
|
1881
2222
|
ctx.fillText(
|
|
1882
|
-
__privateGet(this,
|
|
2223
|
+
__privateGet(this, _text5),
|
|
1883
2224
|
position.x + scaledWidth / 2,
|
|
1884
2225
|
position.y + scaledHeight / 2
|
|
1885
2226
|
);
|
|
@@ -1908,14 +2249,14 @@ var SliderWidget = class {
|
|
|
1908
2249
|
_min = new WeakMap();
|
|
1909
2250
|
_max = new WeakMap();
|
|
1910
2251
|
_value4 = new WeakMap();
|
|
1911
|
-
|
|
2252
|
+
_text5 = new WeakMap();
|
|
1912
2253
|
_snapIncrement = new WeakMap();
|
|
1913
2254
|
_node4 = new WeakMap();
|
|
1914
2255
|
_nodeProperty3 = new WeakMap();
|
|
1915
2256
|
_change = new WeakMap();
|
|
1916
2257
|
_release = new WeakMap();
|
|
1917
2258
|
_textStyle3 = new WeakMap();
|
|
1918
|
-
|
|
2259
|
+
_backgroundColor2 = new WeakMap();
|
|
1919
2260
|
_borderColor = new WeakMap();
|
|
1920
2261
|
_fillColor = new WeakMap();
|
|
1921
2262
|
_lastMousePosition2 = new WeakMap();
|
|
@@ -2119,13 +2460,13 @@ _lightColor = new WeakMap();
|
|
|
2119
2460
|
_lightBorderColor = new WeakMap();
|
|
2120
2461
|
_lightBlur = new WeakMap();
|
|
2121
2462
|
_box3 = new WeakMap();
|
|
2122
|
-
var _node6, _nodeProperty5, _value6,
|
|
2463
|
+
var _node6, _nodeProperty5, _value6, _text6, _enabledStyle, _disabledStyle, _callback6;
|
|
2123
2464
|
var ToggleWidget = class {
|
|
2124
2465
|
constructor(node, config) {
|
|
2125
2466
|
__privateAdd(this, _node6);
|
|
2126
2467
|
__privateAdd(this, _nodeProperty5);
|
|
2127
2468
|
__privateAdd(this, _value6);
|
|
2128
|
-
__privateAdd(this,
|
|
2469
|
+
__privateAdd(this, _text6);
|
|
2129
2470
|
__privateAdd(this, _enabledStyle);
|
|
2130
2471
|
__privateAdd(this, _disabledStyle);
|
|
2131
2472
|
__privateAdd(this, _callback6);
|
|
@@ -2133,7 +2474,7 @@ var ToggleWidget = class {
|
|
|
2133
2474
|
__privateSet(this, _value6, false);
|
|
2134
2475
|
__privateSet(this, _node6, node);
|
|
2135
2476
|
__privateSet(this, _nodeProperty5, config == null ? void 0 : config.property);
|
|
2136
|
-
__privateSet(this,
|
|
2477
|
+
__privateSet(this, _text6, (config == null ? void 0 : config.text) === void 0 ? "Toggle" : config == null ? void 0 : config.text);
|
|
2137
2478
|
__privateSet(this, _enabledStyle, new ToggleStyle({
|
|
2138
2479
|
idle: TextBoxStyleWithFallback((_a = config == null ? void 0 : config.enabledStyle) == null ? void 0 : _a.idle, {
|
|
2139
2480
|
box: {
|
|
@@ -2176,7 +2517,7 @@ var ToggleWidget = class {
|
|
|
2176
2517
|
}
|
|
2177
2518
|
Draw(ctx, position, scale, mousePosition) {
|
|
2178
2519
|
let style = __privateGet(this, _value6) ? __privateGet(this, _enabledStyle) : __privateGet(this, _disabledStyle);
|
|
2179
|
-
return style.Draw(ctx, position, scale, __privateGet(this,
|
|
2520
|
+
return style.Draw(ctx, position, scale, __privateGet(this, _text6), mousePosition);
|
|
2180
2521
|
}
|
|
2181
2522
|
Toggle() {
|
|
2182
2523
|
this.Set(!__privateGet(this, _value6));
|
|
@@ -2202,21 +2543,21 @@ var ToggleWidget = class {
|
|
|
2202
2543
|
_node6 = new WeakMap();
|
|
2203
2544
|
_nodeProperty5 = new WeakMap();
|
|
2204
2545
|
_value6 = new WeakMap();
|
|
2205
|
-
|
|
2546
|
+
_text6 = new WeakMap();
|
|
2206
2547
|
_enabledStyle = new WeakMap();
|
|
2207
2548
|
_disabledStyle = new WeakMap();
|
|
2208
2549
|
_callback6 = new WeakMap();
|
|
2209
2550
|
|
|
2210
2551
|
// src/widgets/image.ts
|
|
2211
|
-
var _url, _image,
|
|
2552
|
+
var _url, _image, _maxWidth2, _maxHeight2;
|
|
2212
2553
|
var ImageWidget = class {
|
|
2213
2554
|
constructor(config) {
|
|
2214
2555
|
__privateAdd(this, _url);
|
|
2215
2556
|
__privateAdd(this, _image);
|
|
2216
|
-
__privateAdd(this,
|
|
2217
|
-
__privateAdd(this,
|
|
2218
|
-
__privateSet(this,
|
|
2219
|
-
__privateSet(this,
|
|
2557
|
+
__privateAdd(this, _maxWidth2);
|
|
2558
|
+
__privateAdd(this, _maxHeight2);
|
|
2559
|
+
__privateSet(this, _maxWidth2, (config == null ? void 0 : config.maxWidth) === void 0 ? 150 : config == null ? void 0 : config.maxWidth);
|
|
2560
|
+
__privateSet(this, _maxHeight2, (config == null ? void 0 : config.maxHeight) === void 0 ? 150 : config == null ? void 0 : config.maxHeight);
|
|
2220
2561
|
if (config == null ? void 0 : config.image) {
|
|
2221
2562
|
this.SetUrl(config == null ? void 0 : config.image);
|
|
2222
2563
|
} else if (config == null ? void 0 : config.blob) {
|
|
@@ -2245,11 +2586,11 @@ var ImageWidget = class {
|
|
|
2245
2586
|
return { "x": 0, "y": 0 };
|
|
2246
2587
|
}
|
|
2247
2588
|
let adjust = 1;
|
|
2248
|
-
if (__privateGet(this, _image).width > __privateGet(this,
|
|
2249
|
-
adjust = __privateGet(this,
|
|
2589
|
+
if (__privateGet(this, _image).width > __privateGet(this, _maxWidth2)) {
|
|
2590
|
+
adjust = __privateGet(this, _maxWidth2) / __privateGet(this, _image).width;
|
|
2250
2591
|
}
|
|
2251
|
-
if (__privateGet(this, _image).height > __privateGet(this,
|
|
2252
|
-
let heightAdjust = __privateGet(this,
|
|
2592
|
+
if (__privateGet(this, _image).height > __privateGet(this, _maxHeight2)) {
|
|
2593
|
+
let heightAdjust = __privateGet(this, _maxHeight2) / __privateGet(this, _image).height;
|
|
2253
2594
|
if (heightAdjust < adjust) {
|
|
2254
2595
|
adjust = heightAdjust;
|
|
2255
2596
|
}
|
|
@@ -2288,8 +2629,8 @@ var ImageWidget = class {
|
|
|
2288
2629
|
};
|
|
2289
2630
|
_url = new WeakMap();
|
|
2290
2631
|
_image = new WeakMap();
|
|
2291
|
-
|
|
2292
|
-
|
|
2632
|
+
_maxWidth2 = new WeakMap();
|
|
2633
|
+
_maxHeight2 = new WeakMap();
|
|
2293
2634
|
|
|
2294
2635
|
// src/widgets/text.ts
|
|
2295
2636
|
var _value7, _callback7, _node7, _nodeProperty6, _size4;
|
|
@@ -3520,7 +3861,7 @@ function FormPopup(config) {
|
|
|
3520
3861
|
|
|
3521
3862
|
// src/node.ts
|
|
3522
3863
|
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,
|
|
3864
|
+
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
3865
|
var FlowNode = class {
|
|
3525
3866
|
constructor(config) {
|
|
3526
3867
|
__privateAdd(this, _FlowNode_instances);
|
|
@@ -3549,7 +3890,7 @@ var FlowNode = class {
|
|
|
3549
3890
|
__privateAdd(this, _titleColor);
|
|
3550
3891
|
__privateAdd(this, _selectedStyle);
|
|
3551
3892
|
__privateAdd(this, _stateStyles);
|
|
3552
|
-
__privateAdd(this,
|
|
3893
|
+
__privateAdd(this, _padding2);
|
|
3553
3894
|
__privateAdd(this, _portTextStyle);
|
|
3554
3895
|
__privateAdd(this, _elementSpacing);
|
|
3555
3896
|
// Runtime ================================================================
|
|
@@ -3629,7 +3970,7 @@ var FlowNode = class {
|
|
|
3629
3970
|
));
|
|
3630
3971
|
__privateSet(this, _infoText, (config == null ? void 0 : config.info) ? config == null ? void 0 : config.info : "");
|
|
3631
3972
|
__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,
|
|
3973
|
+
__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
3974
|
__privateSet(this, _stateStyles, /* @__PURE__ */ new Map());
|
|
3634
3975
|
__privateGet(this, _stateStyles).set(0 /* Idle */, new BoxStyle(BoxStyleWithFallback((_m = config == null ? void 0 : config.style) == null ? void 0 : _m.idle, {
|
|
3635
3976
|
border: { color: Theme.Node.Border.Idle, size: 1 },
|
|
@@ -3910,7 +4251,7 @@ var FlowNode = class {
|
|
|
3910
4251
|
// }
|
|
3911
4252
|
calculateBounds(ctx, camera) {
|
|
3912
4253
|
const tempMeasurement = Zero();
|
|
3913
|
-
const doublePadding = __privateGet(this,
|
|
4254
|
+
const doublePadding = __privateGet(this, _padding2) * 2;
|
|
3914
4255
|
const screenSpacePosition = Zero();
|
|
3915
4256
|
camera.graphSpaceToScreenSpace(__privateGet(this, _position), screenSpacePosition);
|
|
3916
4257
|
const size = Zero();
|
|
@@ -4075,7 +4416,7 @@ var FlowNode = class {
|
|
|
4075
4416
|
__privateGet(this, _inputPortPositions).Clear();
|
|
4076
4417
|
__privateGet(this, _outputPortPositions).Clear();
|
|
4077
4418
|
__privateGet(this, _widgetPositions).Clear();
|
|
4078
|
-
const scaledPadding = __privateGet(this,
|
|
4419
|
+
const scaledPadding = __privateGet(this, _padding2) * camera.zoom;
|
|
4079
4420
|
const scaledElementSpacing = __privateGet(this, _elementSpacing) * camera.zoom;
|
|
4080
4421
|
const nodeBounds = this.calculateBounds(ctx, camera);
|
|
4081
4422
|
const nodeStyle = __privateMethod(this, _FlowNode_instances, calculateStyle_fn).call(this, state);
|
|
@@ -4222,7 +4563,7 @@ _infoChangeCallback = new WeakMap();
|
|
|
4222
4563
|
_titleColor = new WeakMap();
|
|
4223
4564
|
_selectedStyle = new WeakMap();
|
|
4224
4565
|
_stateStyles = new WeakMap();
|
|
4225
|
-
|
|
4566
|
+
_padding2 = new WeakMap();
|
|
4226
4567
|
_portTextStyle = new WeakMap();
|
|
4227
4568
|
_elementSpacing = new WeakMap();
|
|
4228
4569
|
_selected = new WeakMap();
|
|
@@ -4522,15 +4863,15 @@ text_fn = function() {
|
|
|
4522
4863
|
};
|
|
4523
4864
|
|
|
4524
4865
|
// src/markdown/entry.ts
|
|
4525
|
-
var
|
|
4866
|
+
var _text7, _calculatedPositions, _calculatedEntries, _calculatedForWidth, _CodeBlockEntry_instances, calculateLayout_fn;
|
|
4526
4867
|
var CodeBlockEntry = class {
|
|
4527
4868
|
constructor(text) {
|
|
4528
4869
|
__privateAdd(this, _CodeBlockEntry_instances);
|
|
4529
|
-
__privateAdd(this,
|
|
4870
|
+
__privateAdd(this, _text7);
|
|
4530
4871
|
__privateAdd(this, _calculatedPositions);
|
|
4531
4872
|
__privateAdd(this, _calculatedEntries);
|
|
4532
4873
|
__privateAdd(this, _calculatedForWidth);
|
|
4533
|
-
__privateSet(this,
|
|
4874
|
+
__privateSet(this, _text7, text);
|
|
4534
4875
|
__privateSet(this, _calculatedForWidth, -1);
|
|
4535
4876
|
__privateSet(this, _calculatedEntries, new List());
|
|
4536
4877
|
__privateSet(this, _calculatedPositions, new List());
|
|
@@ -4569,7 +4910,7 @@ var CodeBlockEntry = class {
|
|
|
4569
4910
|
return max + padding * 2;
|
|
4570
4911
|
}
|
|
4571
4912
|
};
|
|
4572
|
-
|
|
4913
|
+
_text7 = new WeakMap();
|
|
4573
4914
|
_calculatedPositions = new WeakMap();
|
|
4574
4915
|
_calculatedEntries = new WeakMap();
|
|
4575
4916
|
_calculatedForWidth = new WeakMap();
|
|
@@ -4583,8 +4924,8 @@ calculateLayout_fn = function(ctx, maxWidth) {
|
|
|
4583
4924
|
__privateGet(this, _calculatedEntries).Clear();
|
|
4584
4925
|
__privateGet(this, _calculatedPositions).Clear();
|
|
4585
4926
|
let curHeight = 0;
|
|
4586
|
-
const lineInc = __privateGet(this,
|
|
4587
|
-
let entries = __privateGet(this,
|
|
4927
|
+
const lineInc = __privateGet(this, _text7).style().getSize() + Theme.Note.LineSpacing;
|
|
4928
|
+
let entries = __privateGet(this, _text7).split("\n");
|
|
4588
4929
|
for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
|
|
4589
4930
|
const entry = entries[entryIndex];
|
|
4590
4931
|
let lines = entry.breakIntoLines(ctx, adjustedWith);
|
|
@@ -5371,404 +5712,114 @@ var NoteSubsystem = class {
|
|
|
5371
5712
|
return false;
|
|
5372
5713
|
}
|
|
5373
5714
|
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();
|
|
5715
|
+
if (__privateGet(this, _noteSelected) !== null) {
|
|
5716
|
+
__privateGet(this, _noteSelected).selectHandle(0 /* None */);
|
|
5717
|
+
for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
|
|
5718
|
+
__privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
|
|
5719
|
+
}
|
|
5561
5720
|
}
|
|
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);
|
|
5721
|
+
__privateSet(this, _noteSelected, null);
|
|
5571
5722
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
if (__privateGet(this, _maxWidth2)) {
|
|
5576
|
-
out.x = __privateGet(this, _maxWidth2);
|
|
5723
|
+
mouseDragEvent(delta, scale) {
|
|
5724
|
+
if (__privateGet(this, _noteSelected) === null) {
|
|
5725
|
+
return false;
|
|
5577
5726
|
}
|
|
5578
|
-
if (__privateGet(this,
|
|
5579
|
-
|
|
5727
|
+
if (__privateGet(this, _noteSelected).handleSelected()) {
|
|
5728
|
+
return true;
|
|
5580
5729
|
}
|
|
5730
|
+
__privateGet(this, _noteSelected).translate({
|
|
5731
|
+
x: delta.x * (1 / scale),
|
|
5732
|
+
y: delta.y * (1 / scale)
|
|
5733
|
+
});
|
|
5734
|
+
return true;
|
|
5581
5735
|
}
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
}
|
|
5585
|
-
getDisplay() {
|
|
5586
|
-
return __privateGet(this, _display);
|
|
5736
|
+
fileDrop(file) {
|
|
5737
|
+
return false;
|
|
5587
5738
|
}
|
|
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));
|
|
5739
|
+
removeNote(note) {
|
|
5740
|
+
const index = __privateGet(this, _notes).indexOf(note);
|
|
5741
|
+
if (index > -1) {
|
|
5742
|
+
const noteRemoved = __privateGet(this, _notes)[index];
|
|
5743
|
+
__privateGet(this, _notes).splice(index, 1);
|
|
5744
|
+
for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
|
|
5745
|
+
__privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
|
|
5746
|
+
}
|
|
5747
|
+
} else {
|
|
5748
|
+
console.error("no note found to remove");
|
|
5601
5749
|
}
|
|
5602
|
-
|
|
5603
|
-
|
|
5750
|
+
}
|
|
5751
|
+
render(ctx, camera, mousePosition) {
|
|
5752
|
+
__privateSet(this, _noteHovering, null);
|
|
5753
|
+
__privateSet(this, _hoveringHandle, 0 /* None */);
|
|
5754
|
+
if (mousePosition) {
|
|
5755
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5756
|
+
__privateGet(this, _notes)[i].setHovering(false);
|
|
5757
|
+
if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
|
|
5758
|
+
__privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5604
5761
|
}
|
|
5605
|
-
if (__privateGet(this,
|
|
5606
|
-
|
|
5762
|
+
if (__privateGet(this, _noteHovering) != null) {
|
|
5763
|
+
__privateGet(this, _noteHovering).setHovering(true);
|
|
5764
|
+
if (mousePosition) {
|
|
5765
|
+
if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
|
|
5766
|
+
__privateSet(this, _hoveringHandle, 1 /* Left */);
|
|
5767
|
+
} else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
|
|
5768
|
+
__privateSet(this, _hoveringHandle, 2 /* Right */);
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5607
5771
|
}
|
|
5608
|
-
|
|
5609
|
-
|
|
5772
|
+
for (let i = 0; i < __privateGet(this, _notes).length; i++) {
|
|
5773
|
+
__privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
|
|
5610
5774
|
}
|
|
5775
|
+
return;
|
|
5611
5776
|
}
|
|
5612
5777
|
};
|
|
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
|
-
};
|
|
5778
|
+
_notes = new WeakMap();
|
|
5779
|
+
_noteHovering = new WeakMap();
|
|
5780
|
+
_noteSelected = new WeakMap();
|
|
5781
|
+
_hoveringHandle = new WeakMap();
|
|
5782
|
+
_onNoteAddedCallbacks = new WeakMap();
|
|
5783
|
+
_onNoteRemovedCallbacks = new WeakMap();
|
|
5784
|
+
_onNoteDragStartCallbacks = new WeakMap();
|
|
5785
|
+
_onNoteDragStopCallbacks = new WeakMap();
|
|
5636
5786
|
|
|
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 */);
|
|
5787
|
+
// src/pass/subsystem.ts
|
|
5788
|
+
var _queue;
|
|
5789
|
+
var PassSubsystem = class {
|
|
5790
|
+
constructor() {
|
|
5791
|
+
__privateAdd(this, _queue);
|
|
5792
|
+
__privateSet(this, _queue, new List());
|
|
5649
5793
|
}
|
|
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));
|
|
5794
|
+
queue(lambda) {
|
|
5795
|
+
if (!lambda) {
|
|
5796
|
+
return;
|
|
5671
5797
|
}
|
|
5798
|
+
__privateGet(this, _queue).Push(lambda);
|
|
5672
5799
|
}
|
|
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));
|
|
5800
|
+
render(ctx, camera, mousePosition) {
|
|
5801
|
+
for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
|
|
5802
|
+
__privateGet(this, _queue).At(i)();
|
|
5680
5803
|
}
|
|
5804
|
+
__privateGet(this, _queue).Clear();
|
|
5805
|
+
return;
|
|
5681
5806
|
}
|
|
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;
|
|
5807
|
+
openContextMenu(ctx, position) {
|
|
5808
|
+
return null;
|
|
5715
5809
|
}
|
|
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 */);
|
|
5810
|
+
clickStart(mousePosition, camera, ctrlKey) {
|
|
5811
|
+
return false;
|
|
5730
5812
|
}
|
|
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);
|
|
5813
|
+
mouseDragEvent(delta, scale) {
|
|
5814
|
+
return false;
|
|
5764
5815
|
}
|
|
5765
|
-
|
|
5766
|
-
|
|
5816
|
+
fileDrop(file) {
|
|
5817
|
+
return false;
|
|
5818
|
+
}
|
|
5819
|
+
clickEnd() {
|
|
5767
5820
|
}
|
|
5768
5821
|
};
|
|
5769
|
-
|
|
5770
|
-
_align = new WeakMap();
|
|
5771
|
-
_verticalAlign = new WeakMap();
|
|
5822
|
+
_queue = new WeakMap();
|
|
5772
5823
|
|
|
5773
5824
|
// src/quickMenu.ts
|
|
5774
5825
|
var _text8;
|