@leafer-ui/worker 1.0.1 → 1.0.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/dist/worker.cjs +2667 -0
- package/dist/worker.esm.js +27 -30
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +172 -95
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +170 -96
- package/dist/worker.module.min.js +1 -1
- package/package.json +16 -10
package/dist/worker.js
CHANGED
|
@@ -114,6 +114,19 @@ var LeaferUI = (function (exports) {
|
|
|
114
114
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
|
+
},
|
|
118
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
119
|
+
if (!scaleData)
|
|
120
|
+
scaleData = {};
|
|
121
|
+
if (size) {
|
|
122
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
123
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
124
|
+
}
|
|
125
|
+
else if (scale) {
|
|
126
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
127
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
128
|
+
}
|
|
129
|
+
return scaleData;
|
|
117
130
|
}
|
|
118
131
|
};
|
|
119
132
|
const OneRadian = PI$4 / 180;
|
|
@@ -412,7 +425,7 @@ var LeaferUI = (function (exports) {
|
|
|
412
425
|
};
|
|
413
426
|
const M$6 = MatrixHelper;
|
|
414
427
|
|
|
415
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
428
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
416
429
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
417
430
|
const PointHelper = {
|
|
418
431
|
defaultPoint: getPointData(),
|
|
@@ -468,7 +481,7 @@ var LeaferUI = (function (exports) {
|
|
|
468
481
|
tempToOuterOf(t, matrix) {
|
|
469
482
|
const { tempPoint: temp } = P$5;
|
|
470
483
|
copy$b(temp, t);
|
|
471
|
-
toOuterPoint$
|
|
484
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
472
485
|
return temp;
|
|
473
486
|
},
|
|
474
487
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -487,7 +500,7 @@ var LeaferUI = (function (exports) {
|
|
|
487
500
|
toInnerPoint$2(matrix, t, to);
|
|
488
501
|
},
|
|
489
502
|
toOuterOf(t, matrix, to) {
|
|
490
|
-
toOuterPoint$
|
|
503
|
+
toOuterPoint$3(matrix, t, to);
|
|
491
504
|
},
|
|
492
505
|
getCenter(t, to) {
|
|
493
506
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -767,7 +780,7 @@ var LeaferUI = (function (exports) {
|
|
|
767
780
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
768
781
|
|
|
769
782
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
770
|
-
const { toOuterPoint: toOuterPoint$
|
|
783
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
771
784
|
const { float, fourNumber } = MathHelper;
|
|
772
785
|
const { floor, ceil: ceil$2 } = Math;
|
|
773
786
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -787,17 +800,24 @@ var LeaferUI = (function (exports) {
|
|
|
787
800
|
t.width = bounds.width;
|
|
788
801
|
t.height = bounds.height;
|
|
789
802
|
},
|
|
790
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
803
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
804
|
+
const { x, y, width, height } = bounds;
|
|
791
805
|
if (spread instanceof Array) {
|
|
792
806
|
const four = fourNumber(spread);
|
|
793
807
|
isShrink
|
|
794
|
-
? B.set(t,
|
|
795
|
-
: B.set(t,
|
|
808
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
809
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
796
810
|
}
|
|
797
811
|
else {
|
|
798
812
|
if (isShrink)
|
|
799
813
|
spread = -spread;
|
|
800
|
-
B.set(t,
|
|
814
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
815
|
+
}
|
|
816
|
+
if (side) {
|
|
817
|
+
if (side === 'width')
|
|
818
|
+
t.y = y, t.height = height;
|
|
819
|
+
else
|
|
820
|
+
t.x = x, t.width = width;
|
|
801
821
|
}
|
|
802
822
|
},
|
|
803
823
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -874,16 +894,16 @@ var LeaferUI = (function (exports) {
|
|
|
874
894
|
else {
|
|
875
895
|
point.x = t.x;
|
|
876
896
|
point.y = t.y;
|
|
877
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
878
898
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
879
899
|
point.x = t.x + t.width;
|
|
880
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
881
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
882
902
|
point.y = t.y + t.height;
|
|
883
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
884
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
885
905
|
point.x = t.x;
|
|
886
|
-
toOuterPoint$
|
|
906
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
887
907
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
888
908
|
toBounds$4(tempPointBounds$1, to);
|
|
889
909
|
}
|
|
@@ -897,16 +917,16 @@ var LeaferUI = (function (exports) {
|
|
|
897
917
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
898
918
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
899
919
|
},
|
|
900
|
-
getSpread(t, spread) {
|
|
920
|
+
getSpread(t, spread, side) {
|
|
901
921
|
const n = {};
|
|
902
|
-
B.copyAndSpread(n, t, spread);
|
|
922
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
903
923
|
return n;
|
|
904
924
|
},
|
|
905
|
-
spread(t, spread) {
|
|
906
|
-
B.copyAndSpread(t, t, spread);
|
|
925
|
+
spread(t, spread, side) {
|
|
926
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
907
927
|
},
|
|
908
|
-
shrink(t, shrink) {
|
|
909
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
928
|
+
shrink(t, shrink, side) {
|
|
929
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
910
930
|
},
|
|
911
931
|
ceil(t) {
|
|
912
932
|
const { x, y } = t;
|
|
@@ -1089,12 +1109,12 @@ var LeaferUI = (function (exports) {
|
|
|
1089
1109
|
getFitMatrix(put, baseScale) {
|
|
1090
1110
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1091
1111
|
}
|
|
1092
|
-
spread(fourNumber) {
|
|
1093
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1112
|
+
spread(fourNumber, side) {
|
|
1113
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1094
1114
|
return this;
|
|
1095
1115
|
}
|
|
1096
|
-
shrink(fourNumber) {
|
|
1097
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1116
|
+
shrink(fourNumber, side) {
|
|
1117
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1098
1118
|
return this;
|
|
1099
1119
|
}
|
|
1100
1120
|
ceil() {
|
|
@@ -2911,60 +2931,75 @@ var LeaferUI = (function (exports) {
|
|
|
2911
2931
|
}
|
|
2912
2932
|
beginPath() {
|
|
2913
2933
|
beginPath(this.__path);
|
|
2934
|
+
this.paint();
|
|
2914
2935
|
return this;
|
|
2915
2936
|
}
|
|
2916
2937
|
moveTo(x, y) {
|
|
2917
2938
|
moveTo$4(this.__path, x, y);
|
|
2939
|
+
this.paint();
|
|
2918
2940
|
return this;
|
|
2919
2941
|
}
|
|
2920
2942
|
lineTo(x, y) {
|
|
2921
2943
|
lineTo$3(this.__path, x, y);
|
|
2944
|
+
this.paint();
|
|
2922
2945
|
return this;
|
|
2923
2946
|
}
|
|
2924
2947
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2925
2948
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2949
|
+
this.paint();
|
|
2926
2950
|
return this;
|
|
2927
2951
|
}
|
|
2928
2952
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2929
2953
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2954
|
+
this.paint();
|
|
2930
2955
|
return this;
|
|
2931
2956
|
}
|
|
2932
2957
|
closePath() {
|
|
2933
2958
|
closePath$3(this.__path);
|
|
2959
|
+
this.paint();
|
|
2934
2960
|
return this;
|
|
2935
2961
|
}
|
|
2936
2962
|
rect(x, y, width, height) {
|
|
2937
2963
|
rect$2(this.__path, x, y, width, height);
|
|
2964
|
+
this.paint();
|
|
2938
2965
|
return this;
|
|
2939
2966
|
}
|
|
2940
2967
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2941
2968
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2969
|
+
this.paint();
|
|
2942
2970
|
return this;
|
|
2943
2971
|
}
|
|
2944
2972
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2945
2973
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2974
|
+
this.paint();
|
|
2946
2975
|
return this;
|
|
2947
2976
|
}
|
|
2948
2977
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2949
2978
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2979
|
+
this.paint();
|
|
2950
2980
|
return this;
|
|
2951
2981
|
}
|
|
2952
2982
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2953
2983
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2984
|
+
this.paint();
|
|
2954
2985
|
return this;
|
|
2955
2986
|
}
|
|
2956
2987
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2957
2988
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2989
|
+
this.paint();
|
|
2958
2990
|
return this;
|
|
2959
2991
|
}
|
|
2960
2992
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2961
2993
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2994
|
+
this.paint();
|
|
2962
2995
|
return this;
|
|
2963
2996
|
}
|
|
2964
2997
|
drawPoints(points, curve, close) {
|
|
2965
2998
|
drawPoints$2(this.__path, points, curve, close);
|
|
2999
|
+
this.paint();
|
|
2966
3000
|
return this;
|
|
2967
3001
|
}
|
|
3002
|
+
paint() { }
|
|
2968
3003
|
}
|
|
2969
3004
|
|
|
2970
3005
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3986,7 +4021,7 @@ var LeaferUI = (function (exports) {
|
|
|
3986
4021
|
};
|
|
3987
4022
|
}
|
|
3988
4023
|
|
|
3989
|
-
const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4024
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3990
4025
|
const matrix$1 = {};
|
|
3991
4026
|
const LeafHelper = {
|
|
3992
4027
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4051,10 +4086,9 @@ var LeaferUI = (function (exports) {
|
|
|
4051
4086
|
}
|
|
4052
4087
|
return true;
|
|
4053
4088
|
},
|
|
4054
|
-
moveWorld(t, x, y = 0) {
|
|
4089
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4055
4090
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4056
|
-
|
|
4057
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4091
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4058
4092
|
L.moveLocal(t, local.x, local.y);
|
|
4059
4093
|
},
|
|
4060
4094
|
moveLocal(t, x, y = 0) {
|
|
@@ -4921,7 +4955,7 @@ var LeaferUI = (function (exports) {
|
|
|
4921
4955
|
|
|
4922
4956
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4923
4957
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4924
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4958
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
|
|
4925
4959
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4926
4960
|
const LeafBounds = {
|
|
4927
4961
|
__updateWorldBounds() {
|
|
@@ -5022,7 +5056,7 @@ var LeaferUI = (function (exports) {
|
|
|
5022
5056
|
updateAllMatrix$2(this);
|
|
5023
5057
|
updateBounds$1(this, this);
|
|
5024
5058
|
if (this.__.__autoSide)
|
|
5025
|
-
this.__updateBoxBounds();
|
|
5059
|
+
this.__updateBoxBounds(true);
|
|
5026
5060
|
}
|
|
5027
5061
|
else {
|
|
5028
5062
|
updateAllMatrix$2(this);
|
|
@@ -5040,11 +5074,11 @@ var LeaferUI = (function (exports) {
|
|
|
5040
5074
|
},
|
|
5041
5075
|
__updateStrokeBounds() {
|
|
5042
5076
|
const layout = this.__layout;
|
|
5043
|
-
copyAndSpread$
|
|
5077
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5044
5078
|
},
|
|
5045
5079
|
__updateRenderBounds() {
|
|
5046
5080
|
const layout = this.__layout;
|
|
5047
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5081
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5048
5082
|
}
|
|
5049
5083
|
};
|
|
5050
5084
|
|
|
@@ -5404,6 +5438,9 @@ var LeaferUI = (function (exports) {
|
|
|
5404
5438
|
move(x, y) {
|
|
5405
5439
|
moveLocal(this, x, y);
|
|
5406
5440
|
}
|
|
5441
|
+
moveInner(x, y) {
|
|
5442
|
+
moveWorld(this, x, y, true);
|
|
5443
|
+
}
|
|
5407
5444
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5408
5445
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5409
5446
|
}
|
|
@@ -6941,6 +6978,11 @@ var LeaferUI = (function (exports) {
|
|
|
6941
6978
|
}
|
|
6942
6979
|
|
|
6943
6980
|
class LeaferData extends GroupData {
|
|
6981
|
+
__getInputData() {
|
|
6982
|
+
const data = super.__getInputData();
|
|
6983
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6984
|
+
return data;
|
|
6985
|
+
}
|
|
6944
6986
|
}
|
|
6945
6987
|
|
|
6946
6988
|
class FrameData extends BoxData {
|
|
@@ -7018,6 +7060,11 @@ var LeaferUI = (function (exports) {
|
|
|
7018
7060
|
}
|
|
7019
7061
|
|
|
7020
7062
|
class CanvasData extends RectData {
|
|
7063
|
+
__getInputData() {
|
|
7064
|
+
const data = super.__getInputData();
|
|
7065
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7066
|
+
return data;
|
|
7067
|
+
}
|
|
7021
7068
|
}
|
|
7022
7069
|
|
|
7023
7070
|
const UIBounds = {
|
|
@@ -7930,6 +7977,13 @@ var LeaferUI = (function (exports) {
|
|
|
7930
7977
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7931
7978
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7932
7979
|
}
|
|
7980
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7981
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7982
|
+
}
|
|
7983
|
+
updateClientBounds() {
|
|
7984
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7985
|
+
}
|
|
7986
|
+
receiveEvent(_event) { }
|
|
7933
7987
|
__checkUpdateLayout() {
|
|
7934
7988
|
this.__layout.update();
|
|
7935
7989
|
}
|
|
@@ -8013,7 +8067,7 @@ var LeaferUI = (function (exports) {
|
|
|
8013
8067
|
const rect$1 = exports.Rect.prototype;
|
|
8014
8068
|
const group$1 = exports.Group.prototype;
|
|
8015
8069
|
const childrenRenderBounds = {};
|
|
8016
|
-
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8070
|
+
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8017
8071
|
exports.Box = class Box extends exports.Group {
|
|
8018
8072
|
get __tag() { return 'Box'; }
|
|
8019
8073
|
get isBranchLeaf() { return true; }
|
|
@@ -8027,20 +8081,23 @@ var LeaferUI = (function (exports) {
|
|
|
8027
8081
|
return this.__updateRectRenderSpread() || -1;
|
|
8028
8082
|
}
|
|
8029
8083
|
__updateRectBoxBounds() { }
|
|
8030
|
-
__updateBoxBounds() {
|
|
8084
|
+
__updateBoxBounds(secondLayout) {
|
|
8031
8085
|
const data = this.__;
|
|
8032
8086
|
if (this.children.length) {
|
|
8033
8087
|
if (data.__autoSide) {
|
|
8034
8088
|
if (this.leafer && this.leafer.ready)
|
|
8035
8089
|
this.leafer.layouter.addExtra(this);
|
|
8036
8090
|
super.__updateBoxBounds();
|
|
8091
|
+
const { boxBounds } = this.__layout;
|
|
8037
8092
|
if (!data.__autoSize) {
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8093
|
+
if (data.__autoWidth)
|
|
8094
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8095
|
+
else
|
|
8096
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8043
8097
|
}
|
|
8098
|
+
if (secondLayout && data.flow && data.padding)
|
|
8099
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8100
|
+
this.__updateNaturalSize();
|
|
8044
8101
|
}
|
|
8045
8102
|
else {
|
|
8046
8103
|
this.__updateRectBoxBounds();
|
|
@@ -8060,13 +8117,13 @@ var LeaferUI = (function (exports) {
|
|
|
8060
8117
|
super.__updateRenderBounds();
|
|
8061
8118
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8062
8119
|
this.__updateRectRenderBounds();
|
|
8063
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8120
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8064
8121
|
}
|
|
8065
8122
|
else {
|
|
8066
8123
|
this.__updateRectRenderBounds();
|
|
8067
8124
|
}
|
|
8068
8125
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8069
|
-
if (
|
|
8126
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8070
8127
|
add(renderBounds, childrenRenderBounds);
|
|
8071
8128
|
}
|
|
8072
8129
|
__updateRectRenderBounds() { }
|
|
@@ -8400,14 +8457,26 @@ var LeaferUI = (function (exports) {
|
|
|
8400
8457
|
exports.Image = __decorate([
|
|
8401
8458
|
registerUI()
|
|
8402
8459
|
], exports.Image);
|
|
8460
|
+
const MyImage = exports.Image;
|
|
8403
8461
|
|
|
8404
8462
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8405
8463
|
get __tag() { return 'Canvas'; }
|
|
8464
|
+
get ready() { return !this.url; }
|
|
8406
8465
|
constructor(data) {
|
|
8407
8466
|
super(data);
|
|
8408
8467
|
this.canvas = Creator.canvas(this.__);
|
|
8409
8468
|
this.context = this.canvas.context;
|
|
8410
8469
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8470
|
+
if (data && data.url)
|
|
8471
|
+
this.drawImage(data.url);
|
|
8472
|
+
}
|
|
8473
|
+
drawImage(url) {
|
|
8474
|
+
new LeaferImage({ url }).load((image) => {
|
|
8475
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8476
|
+
this.url = undefined;
|
|
8477
|
+
this.paint();
|
|
8478
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8479
|
+
});
|
|
8411
8480
|
}
|
|
8412
8481
|
draw(ui, offset, scale, rotation) {
|
|
8413
8482
|
ui.__layout.update();
|
|
@@ -8466,7 +8535,7 @@ var LeaferUI = (function (exports) {
|
|
|
8466
8535
|
resizeType(100)
|
|
8467
8536
|
], exports.Canvas.prototype, "height", void 0);
|
|
8468
8537
|
__decorate([
|
|
8469
|
-
resizeType(
|
|
8538
|
+
resizeType(1)
|
|
8470
8539
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8471
8540
|
__decorate([
|
|
8472
8541
|
resizeType(true)
|
|
@@ -8490,13 +8559,13 @@ var LeaferUI = (function (exports) {
|
|
|
8490
8559
|
super(data);
|
|
8491
8560
|
}
|
|
8492
8561
|
__drawHitPath(canvas) {
|
|
8493
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8562
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8494
8563
|
canvas.beginPath();
|
|
8495
8564
|
if (this.__.__letterSpacing < 0) {
|
|
8496
8565
|
this.__drawPathByData(canvas);
|
|
8497
8566
|
}
|
|
8498
8567
|
else {
|
|
8499
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8568
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8500
8569
|
}
|
|
8501
8570
|
}
|
|
8502
8571
|
__drawPathByData(drawer, _data) {
|
|
@@ -8689,7 +8758,8 @@ var LeaferUI = (function (exports) {
|
|
|
8689
8758
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8690
8759
|
clearPath() { return this; }
|
|
8691
8760
|
paint() {
|
|
8692
|
-
this.pathElement.
|
|
8761
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8762
|
+
this.pathElement.forceUpdate('path');
|
|
8693
8763
|
}
|
|
8694
8764
|
};
|
|
8695
8765
|
__decorate([
|
|
@@ -8699,7 +8769,7 @@ var LeaferUI = (function (exports) {
|
|
|
8699
8769
|
penPathType()
|
|
8700
8770
|
], exports.Pen.prototype, "path", void 0);
|
|
8701
8771
|
exports.Pen = __decorate([
|
|
8702
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8772
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8703
8773
|
registerUI()
|
|
8704
8774
|
], exports.Pen);
|
|
8705
8775
|
function penPathType() {
|
|
@@ -8922,6 +8992,7 @@ var LeaferUI = (function (exports) {
|
|
|
8922
8992
|
exports.PointerEvent = __decorate([
|
|
8923
8993
|
registerUIEvent()
|
|
8924
8994
|
], exports.PointerEvent);
|
|
8995
|
+
const MyPointerEvent = exports.PointerEvent;
|
|
8925
8996
|
|
|
8926
8997
|
const move = {};
|
|
8927
8998
|
exports.DragEvent = class DragEvent extends exports.PointerEvent {
|
|
@@ -9021,6 +9092,7 @@ var LeaferUI = (function (exports) {
|
|
|
9021
9092
|
exports.DragEvent = __decorate([
|
|
9022
9093
|
registerUIEvent()
|
|
9023
9094
|
], exports.DragEvent);
|
|
9095
|
+
const MyDragEvent = exports.DragEvent;
|
|
9024
9096
|
|
|
9025
9097
|
exports.DropEvent = class DropEvent extends exports.PointerEvent {
|
|
9026
9098
|
static setList(data) {
|
|
@@ -9102,36 +9174,32 @@ var LeaferUI = (function (exports) {
|
|
|
9102
9174
|
|
|
9103
9175
|
function document(leafer) {
|
|
9104
9176
|
addInteractionWindow(leafer);
|
|
9105
|
-
|
|
9106
|
-
|
|
9177
|
+
const { move, zoom } = leafer.config;
|
|
9178
|
+
move.scroll = 'limit';
|
|
9179
|
+
zoom.min = 1;
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
function block(leafer) {
|
|
9183
|
+
const { config } = leafer;
|
|
9184
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9185
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9107
9186
|
}
|
|
9108
9187
|
|
|
9109
9188
|
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9110
9189
|
const LeaferTypeCreator = {
|
|
9111
9190
|
list: {},
|
|
9112
9191
|
register(name, fn) {
|
|
9113
|
-
|
|
9114
|
-
debug$2.repeat(name);
|
|
9115
|
-
}
|
|
9116
|
-
else {
|
|
9117
|
-
list[name] = fn;
|
|
9118
|
-
}
|
|
9192
|
+
list[name] ? debug$2.repeat(name) : list[name] = fn;
|
|
9119
9193
|
},
|
|
9120
9194
|
run(name, leafer) {
|
|
9121
9195
|
const fn = list[name];
|
|
9122
|
-
|
|
9123
|
-
fn(leafer);
|
|
9124
|
-
}
|
|
9125
|
-
else {
|
|
9126
|
-
debug$2.error('no', name);
|
|
9127
|
-
}
|
|
9196
|
+
fn && fn(leafer);
|
|
9128
9197
|
}
|
|
9129
9198
|
};
|
|
9130
9199
|
const { list, register } = LeaferTypeCreator;
|
|
9131
|
-
register('draw', () => { });
|
|
9132
|
-
register('custom', () => { });
|
|
9133
9200
|
register('design', addInteractionWindow);
|
|
9134
9201
|
register('document', document);
|
|
9202
|
+
register('block', block);
|
|
9135
9203
|
|
|
9136
9204
|
const leafer = exports.Leafer.prototype;
|
|
9137
9205
|
leafer.initType = function (type) {
|
|
@@ -9320,7 +9388,13 @@ var LeaferUI = (function (exports) {
|
|
|
9320
9388
|
find.add(list[i]);
|
|
9321
9389
|
}
|
|
9322
9390
|
return find;
|
|
9323
|
-
}
|
|
9391
|
+
},
|
|
9392
|
+
pathCanDrag(path) {
|
|
9393
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(exports.DragEvent.DRAG)));
|
|
9394
|
+
},
|
|
9395
|
+
pathHasOutside(path) {
|
|
9396
|
+
return path && path.list.some(item => item.isOutside);
|
|
9397
|
+
},
|
|
9324
9398
|
};
|
|
9325
9399
|
const I = InteractionHelper;
|
|
9326
9400
|
|
|
@@ -9630,15 +9704,18 @@ var LeaferUI = (function (exports) {
|
|
|
9630
9704
|
swipeDistance: 20,
|
|
9631
9705
|
preventDefaultMenu: true
|
|
9632
9706
|
},
|
|
9707
|
+
touch: {
|
|
9708
|
+
preventDefault: true
|
|
9709
|
+
},
|
|
9633
9710
|
cursor: true,
|
|
9634
9711
|
keyEvent: true
|
|
9635
9712
|
};
|
|
9636
9713
|
|
|
9637
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
9714
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9638
9715
|
class InteractionBase {
|
|
9639
9716
|
get dragging() { return this.dragger.dragging; }
|
|
9640
9717
|
get transforming() { return this.transformer.transforming; }
|
|
9641
|
-
get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9718
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9642
9719
|
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9643
9720
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9644
9721
|
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
@@ -9647,7 +9724,7 @@ var LeaferUI = (function (exports) {
|
|
|
9647
9724
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9648
9725
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9649
9726
|
constructor(target, canvas, selector, userConfig) {
|
|
9650
|
-
this.config = config;
|
|
9727
|
+
this.config = DataHelper.clone(config);
|
|
9651
9728
|
this.tapCount = 0;
|
|
9652
9729
|
this.downKeyMap = {};
|
|
9653
9730
|
this.target = target;
|
|
@@ -9899,11 +9976,11 @@ var LeaferUI = (function (exports) {
|
|
|
9899
9976
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
9900
9977
|
}
|
|
9901
9978
|
checkPath(data, useDefaultPath) {
|
|
9902
|
-
if (useDefaultPath || this.
|
|
9979
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
9903
9980
|
data.path = this.defaultPath;
|
|
9904
9981
|
}
|
|
9905
9982
|
canMove(data) {
|
|
9906
|
-
return this.moveMode
|
|
9983
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
9907
9984
|
}
|
|
9908
9985
|
isDrag(leaf) {
|
|
9909
9986
|
return this.dragger.getList().has(leaf);
|
|
@@ -10598,10 +10675,13 @@ var LeaferUI = (function (exports) {
|
|
|
10598
10675
|
const { get: get$2, translate } = MatrixHelper;
|
|
10599
10676
|
const tempBox = new Bounds();
|
|
10600
10677
|
const tempPoint = {};
|
|
10678
|
+
const tempScaleData = {};
|
|
10601
10679
|
function createData(leafPaint, image, paint, box) {
|
|
10602
|
-
const { blendMode } = paint;
|
|
10680
|
+
const { blendMode, sync } = paint;
|
|
10603
10681
|
if (blendMode)
|
|
10604
10682
|
leafPaint.blendMode = blendMode;
|
|
10683
|
+
if (sync)
|
|
10684
|
+
leafPaint.sync = sync;
|
|
10605
10685
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10606
10686
|
}
|
|
10607
10687
|
function getPatternData(paint, box, image) {
|
|
@@ -10621,13 +10701,10 @@ var LeaferUI = (function (exports) {
|
|
|
10621
10701
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
10622
10702
|
}
|
|
10623
10703
|
}
|
|
10624
|
-
else if (size) {
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
else if (scale) {
|
|
10629
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
10630
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
10704
|
+
else if (scale || size) {
|
|
10705
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10706
|
+
scaleX = tempScaleData.scaleX;
|
|
10707
|
+
scaleY = tempScaleData.scaleY;
|
|
10631
10708
|
}
|
|
10632
10709
|
if (align) {
|
|
10633
10710
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -10866,7 +10943,7 @@ var LeaferUI = (function (exports) {
|
|
|
10866
10943
|
return true;
|
|
10867
10944
|
}
|
|
10868
10945
|
else {
|
|
10869
|
-
if (!paint.style || Export.running) {
|
|
10946
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
10870
10947
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
10871
10948
|
}
|
|
10872
10949
|
else {
|
|
@@ -11736,6 +11813,7 @@ var LeaferUI = (function (exports) {
|
|
|
11736
11813
|
export(leaf, filename, options) {
|
|
11737
11814
|
this.running = true;
|
|
11738
11815
|
const fileType = FileHelper.fileType(filename);
|
|
11816
|
+
const isDownload = filename.includes('.');
|
|
11739
11817
|
options = FileHelper.getExportOptions(options);
|
|
11740
11818
|
return addTask((success) => new Promise((resolve) => {
|
|
11741
11819
|
const over = (result) => {
|
|
@@ -11745,19 +11823,13 @@ var LeaferUI = (function (exports) {
|
|
|
11745
11823
|
};
|
|
11746
11824
|
const { toURL } = Platform;
|
|
11747
11825
|
const { download } = Platform.origin;
|
|
11748
|
-
if (
|
|
11749
|
-
|
|
11826
|
+
if (fileType === 'json') {
|
|
11827
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11828
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11750
11829
|
}
|
|
11751
|
-
|
|
11752
|
-
download(toURL(
|
|
11753
|
-
return over({ data: true });
|
|
11754
|
-
}
|
|
11755
|
-
if (filename === 'svg') {
|
|
11756
|
-
return over({ data: leaf.toSVG() });
|
|
11757
|
-
}
|
|
11758
|
-
else if (fileType === 'svg') {
|
|
11759
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11760
|
-
return over({ data: true });
|
|
11830
|
+
if (fileType === 'svg') {
|
|
11831
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11832
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11761
11833
|
}
|
|
11762
11834
|
const { leafer } = leaf;
|
|
11763
11835
|
if (leafer) {
|
|
@@ -11766,14 +11838,8 @@ var LeaferUI = (function (exports) {
|
|
|
11766
11838
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
11767
11839
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
11768
11840
|
const { slice, trim, onCanvas } = options;
|
|
11769
|
-
let scale = options.scale || 1;
|
|
11770
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
11771
11841
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
11772
11842
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
11773
|
-
if (leaf.isApp) {
|
|
11774
|
-
scale *= pixelRatio;
|
|
11775
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
11776
|
-
}
|
|
11777
11843
|
const screenshot = options.screenshot || leaf.isApp;
|
|
11778
11844
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
11779
11845
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -11807,9 +11873,17 @@ var LeaferUI = (function (exports) {
|
|
|
11807
11873
|
}
|
|
11808
11874
|
renderBounds = leaf.getBounds('render', relative);
|
|
11809
11875
|
}
|
|
11810
|
-
const {
|
|
11876
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
11877
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
11878
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
11879
|
+
if (leaf.isApp) {
|
|
11880
|
+
scaleData.scaleX *= pixelRatio;
|
|
11881
|
+
scaleData.scaleY *= pixelRatio;
|
|
11882
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
11883
|
+
}
|
|
11884
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
11885
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
11811
11886
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
11812
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
11813
11887
|
let sliceLeaf;
|
|
11814
11888
|
if (slice) {
|
|
11815
11889
|
sliceLeaf = leaf;
|
|
@@ -11978,6 +12052,9 @@ var LeaferUI = (function (exports) {
|
|
|
11978
12052
|
exports.Matrix = Matrix;
|
|
11979
12053
|
exports.MatrixHelper = MatrixHelper;
|
|
11980
12054
|
exports.MultiTouchHelper = MultiTouchHelper;
|
|
12055
|
+
exports.MyDragEvent = MyDragEvent;
|
|
12056
|
+
exports.MyImage = MyImage;
|
|
12057
|
+
exports.MyPointerEvent = MyPointerEvent;
|
|
11981
12058
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
11982
12059
|
exports.OneRadian = OneRadian;
|
|
11983
12060
|
exports.PI2 = PI2;
|