@leafer-ui/miniapp 1.0.0 → 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/miniapp.cjs +2941 -0
- package/dist/miniapp.esm.js +203 -190
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -0
- package/dist/miniapp.module.js +429 -297
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +18 -10
- package/src/index.ts +6 -1
package/dist/miniapp.module.js
CHANGED
|
@@ -48,6 +48,8 @@ const I$2 = IncrementId;
|
|
|
48
48
|
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
|
+
if (typeof min === 'object')
|
|
52
|
+
max = min.max, min = min.min;
|
|
51
53
|
if (min !== undefined && value < min)
|
|
52
54
|
value = min;
|
|
53
55
|
if (max !== undefined && value > max)
|
|
@@ -109,6 +111,19 @@ const MathHelper = {
|
|
|
109
111
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
110
112
|
num = round(num * a) / a;
|
|
111
113
|
return num === -0 ? 0 : num;
|
|
114
|
+
},
|
|
115
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
116
|
+
if (!scaleData)
|
|
117
|
+
scaleData = {};
|
|
118
|
+
if (size) {
|
|
119
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
120
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
121
|
+
}
|
|
122
|
+
else if (scale) {
|
|
123
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
124
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
125
|
+
}
|
|
126
|
+
return scaleData;
|
|
112
127
|
}
|
|
113
128
|
};
|
|
114
129
|
const OneRadian = PI$4 / 180;
|
|
@@ -150,10 +165,10 @@ const MatrixHelper = {
|
|
|
150
165
|
t.e += x;
|
|
151
166
|
t.f += y;
|
|
152
167
|
},
|
|
153
|
-
translateInner(t, x, y,
|
|
168
|
+
translateInner(t, x, y, hasOrigin) {
|
|
154
169
|
t.e += t.a * x + t.c * y;
|
|
155
170
|
t.f += t.b * x + t.d * y;
|
|
156
|
-
if (
|
|
171
|
+
if (hasOrigin)
|
|
157
172
|
t.e -= x, t.f -= y;
|
|
158
173
|
},
|
|
159
174
|
scale(t, scaleX, scaleY = scaleX) {
|
|
@@ -312,7 +327,7 @@ const MatrixHelper = {
|
|
|
312
327
|
to.y -= (f * a - e * b) * s;
|
|
313
328
|
}
|
|
314
329
|
},
|
|
315
|
-
setLayout(t, layout, origin, bcChanged) {
|
|
330
|
+
setLayout(t, layout, origin, around, bcChanged) {
|
|
316
331
|
const { x, y, scaleX, scaleY } = layout;
|
|
317
332
|
if (bcChanged === undefined)
|
|
318
333
|
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
@@ -344,10 +359,10 @@ const MatrixHelper = {
|
|
|
344
359
|
}
|
|
345
360
|
t.e = x;
|
|
346
361
|
t.f = y;
|
|
347
|
-
if (origin)
|
|
348
|
-
M$6.translateInner(t, -origin.x, -origin.y,
|
|
362
|
+
if (origin = origin || around)
|
|
363
|
+
M$6.translateInner(t, -origin.x, -origin.y, !around);
|
|
349
364
|
},
|
|
350
|
-
getLayout(t, origin, firstSkewY) {
|
|
365
|
+
getLayout(t, origin, around, firstSkewY) {
|
|
351
366
|
const { a, b, c, d, e, f } = t;
|
|
352
367
|
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
353
368
|
if (b || c) {
|
|
@@ -376,9 +391,11 @@ const MatrixHelper = {
|
|
|
376
391
|
scaleY = d;
|
|
377
392
|
rotation = skewX = skewY = 0;
|
|
378
393
|
}
|
|
379
|
-
if (origin) {
|
|
394
|
+
if (origin = around || origin) {
|
|
380
395
|
x += origin.x * a + origin.y * c;
|
|
381
396
|
y += origin.x * b + origin.y * d;
|
|
397
|
+
if (!around)
|
|
398
|
+
x -= origin.x, y -= origin.y;
|
|
382
399
|
}
|
|
383
400
|
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
384
401
|
},
|
|
@@ -405,7 +422,7 @@ const MatrixHelper = {
|
|
|
405
422
|
};
|
|
406
423
|
const M$6 = MatrixHelper;
|
|
407
424
|
|
|
408
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
425
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
409
426
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
410
427
|
const PointHelper = {
|
|
411
428
|
defaultPoint: getPointData(),
|
|
@@ -461,7 +478,7 @@ const PointHelper = {
|
|
|
461
478
|
tempToOuterOf(t, matrix) {
|
|
462
479
|
const { tempPoint: temp } = P$5;
|
|
463
480
|
copy$b(temp, t);
|
|
464
|
-
toOuterPoint$
|
|
481
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
465
482
|
return temp;
|
|
466
483
|
},
|
|
467
484
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -480,7 +497,7 @@ const PointHelper = {
|
|
|
480
497
|
toInnerPoint$2(matrix, t, to);
|
|
481
498
|
},
|
|
482
499
|
toOuterOf(t, matrix, to) {
|
|
483
|
-
toOuterPoint$
|
|
500
|
+
toOuterPoint$3(matrix, t, to);
|
|
484
501
|
},
|
|
485
502
|
getCenter(t, to) {
|
|
486
503
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -706,12 +723,12 @@ class Matrix {
|
|
|
706
723
|
toInnerPoint(outer, to, distance) {
|
|
707
724
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
708
725
|
}
|
|
709
|
-
setLayout(data, origin) {
|
|
710
|
-
MatrixHelper.setLayout(this, data, origin);
|
|
726
|
+
setLayout(data, origin, around) {
|
|
727
|
+
MatrixHelper.setLayout(this, data, origin, around);
|
|
711
728
|
return this;
|
|
712
729
|
}
|
|
713
|
-
getLayout(origin, firstSkewY) {
|
|
714
|
-
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
730
|
+
getLayout(origin, around, firstSkewY) {
|
|
731
|
+
return MatrixHelper.getLayout(this, origin, around, firstSkewY);
|
|
715
732
|
}
|
|
716
733
|
withScale(scaleX, scaleY) {
|
|
717
734
|
return MatrixHelper.withScale(this, scaleX, scaleY);
|
|
@@ -760,7 +777,7 @@ const TwoPointBoundsHelper = {
|
|
|
760
777
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
761
778
|
|
|
762
779
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
763
|
-
const { toOuterPoint: toOuterPoint$
|
|
780
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
764
781
|
const { float, fourNumber } = MathHelper;
|
|
765
782
|
const { floor, ceil: ceil$2 } = Math;
|
|
766
783
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -780,17 +797,24 @@ const BoundsHelper = {
|
|
|
780
797
|
t.width = bounds.width;
|
|
781
798
|
t.height = bounds.height;
|
|
782
799
|
},
|
|
783
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
800
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
801
|
+
const { x, y, width, height } = bounds;
|
|
784
802
|
if (spread instanceof Array) {
|
|
785
803
|
const four = fourNumber(spread);
|
|
786
804
|
isShrink
|
|
787
|
-
? B.set(t,
|
|
788
|
-
: B.set(t,
|
|
805
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
806
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
789
807
|
}
|
|
790
808
|
else {
|
|
791
809
|
if (isShrink)
|
|
792
810
|
spread = -spread;
|
|
793
|
-
B.set(t,
|
|
811
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
812
|
+
}
|
|
813
|
+
if (side) {
|
|
814
|
+
if (side === 'width')
|
|
815
|
+
t.y = y, t.height = height;
|
|
816
|
+
else
|
|
817
|
+
t.x = x, t.width = width;
|
|
794
818
|
}
|
|
795
819
|
},
|
|
796
820
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -867,16 +891,16 @@ const BoundsHelper = {
|
|
|
867
891
|
else {
|
|
868
892
|
point.x = t.x;
|
|
869
893
|
point.y = t.y;
|
|
870
|
-
toOuterPoint$
|
|
894
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
871
895
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
872
896
|
point.x = t.x + t.width;
|
|
873
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
874
898
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
875
899
|
point.y = t.y + t.height;
|
|
876
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
877
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
878
902
|
point.x = t.x;
|
|
879
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
880
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
881
905
|
toBounds$4(tempPointBounds$1, to);
|
|
882
906
|
}
|
|
@@ -890,16 +914,16 @@ const BoundsHelper = {
|
|
|
890
914
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
891
915
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
892
916
|
},
|
|
893
|
-
getSpread(t, spread) {
|
|
917
|
+
getSpread(t, spread, side) {
|
|
894
918
|
const n = {};
|
|
895
|
-
B.copyAndSpread(n, t, spread);
|
|
919
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
896
920
|
return n;
|
|
897
921
|
},
|
|
898
|
-
spread(t, spread) {
|
|
899
|
-
B.copyAndSpread(t, t, spread);
|
|
922
|
+
spread(t, spread, side) {
|
|
923
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
900
924
|
},
|
|
901
|
-
shrink(t, shrink) {
|
|
902
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
925
|
+
shrink(t, shrink, side) {
|
|
926
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
903
927
|
},
|
|
904
928
|
ceil(t) {
|
|
905
929
|
const { x, y } = t;
|
|
@@ -1082,12 +1106,12 @@ class Bounds {
|
|
|
1082
1106
|
getFitMatrix(put, baseScale) {
|
|
1083
1107
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1084
1108
|
}
|
|
1085
|
-
spread(fourNumber) {
|
|
1086
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1109
|
+
spread(fourNumber, side) {
|
|
1110
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1087
1111
|
return this;
|
|
1088
1112
|
}
|
|
1089
|
-
shrink(fourNumber) {
|
|
1090
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1113
|
+
shrink(fourNumber, side) {
|
|
1114
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1091
1115
|
return this;
|
|
1092
1116
|
}
|
|
1093
1117
|
ceil() {
|
|
@@ -1999,7 +2023,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1999
2023
|
DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
|
|
2000
2024
|
this.size.pixelRatio || (this.size.pixelRatio = 1);
|
|
2001
2025
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2002
|
-
if (!this.unreal) {
|
|
2026
|
+
if (this.context && !this.unreal) {
|
|
2003
2027
|
this.updateViewSize();
|
|
2004
2028
|
this.smooth = this.config.smooth;
|
|
2005
2029
|
}
|
|
@@ -2172,7 +2196,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2172
2196
|
this.manager ? this.manager.recycle(this) : this.destroy();
|
|
2173
2197
|
}
|
|
2174
2198
|
}
|
|
2175
|
-
updateRender() { }
|
|
2199
|
+
updateRender(_bounds) { }
|
|
2176
2200
|
unrealCanvas() { }
|
|
2177
2201
|
destroy() {
|
|
2178
2202
|
this.manager = this.view = this.parentView = null;
|
|
@@ -2904,60 +2928,75 @@ class PathCreator {
|
|
|
2904
2928
|
}
|
|
2905
2929
|
beginPath() {
|
|
2906
2930
|
beginPath(this.__path);
|
|
2931
|
+
this.paint();
|
|
2907
2932
|
return this;
|
|
2908
2933
|
}
|
|
2909
2934
|
moveTo(x, y) {
|
|
2910
2935
|
moveTo$4(this.__path, x, y);
|
|
2936
|
+
this.paint();
|
|
2911
2937
|
return this;
|
|
2912
2938
|
}
|
|
2913
2939
|
lineTo(x, y) {
|
|
2914
2940
|
lineTo$3(this.__path, x, y);
|
|
2941
|
+
this.paint();
|
|
2915
2942
|
return this;
|
|
2916
2943
|
}
|
|
2917
2944
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2918
2945
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2946
|
+
this.paint();
|
|
2919
2947
|
return this;
|
|
2920
2948
|
}
|
|
2921
2949
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2922
2950
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2951
|
+
this.paint();
|
|
2923
2952
|
return this;
|
|
2924
2953
|
}
|
|
2925
2954
|
closePath() {
|
|
2926
2955
|
closePath$3(this.__path);
|
|
2956
|
+
this.paint();
|
|
2927
2957
|
return this;
|
|
2928
2958
|
}
|
|
2929
2959
|
rect(x, y, width, height) {
|
|
2930
2960
|
rect$2(this.__path, x, y, width, height);
|
|
2961
|
+
this.paint();
|
|
2931
2962
|
return this;
|
|
2932
2963
|
}
|
|
2933
2964
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2934
2965
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2966
|
+
this.paint();
|
|
2935
2967
|
return this;
|
|
2936
2968
|
}
|
|
2937
2969
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2938
2970
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2971
|
+
this.paint();
|
|
2939
2972
|
return this;
|
|
2940
2973
|
}
|
|
2941
2974
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2942
2975
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2976
|
+
this.paint();
|
|
2943
2977
|
return this;
|
|
2944
2978
|
}
|
|
2945
2979
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2946
2980
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2981
|
+
this.paint();
|
|
2947
2982
|
return this;
|
|
2948
2983
|
}
|
|
2949
2984
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2950
2985
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2986
|
+
this.paint();
|
|
2951
2987
|
return this;
|
|
2952
2988
|
}
|
|
2953
2989
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2954
2990
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2991
|
+
this.paint();
|
|
2955
2992
|
return this;
|
|
2956
2993
|
}
|
|
2957
2994
|
drawPoints(points, curve, close) {
|
|
2958
2995
|
drawPoints$2(this.__path, points, curve, close);
|
|
2996
|
+
this.paint();
|
|
2959
2997
|
return this;
|
|
2960
2998
|
}
|
|
2999
|
+
paint() { }
|
|
2961
3000
|
}
|
|
2962
3001
|
|
|
2963
3002
|
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;
|
|
@@ -3979,7 +4018,7 @@ function registerUIEvent() {
|
|
|
3979
4018
|
};
|
|
3980
4019
|
}
|
|
3981
4020
|
|
|
3982
|
-
const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4021
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3983
4022
|
const matrix$1 = {};
|
|
3984
4023
|
const LeafHelper = {
|
|
3985
4024
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4044,10 +4083,9 @@ const LeafHelper = {
|
|
|
4044
4083
|
}
|
|
4045
4084
|
return true;
|
|
4046
4085
|
},
|
|
4047
|
-
moveWorld(t, x, y = 0) {
|
|
4086
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4048
4087
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4049
|
-
|
|
4050
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4088
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4051
4089
|
L.moveLocal(t, local.x, local.y);
|
|
4052
4090
|
},
|
|
4053
4091
|
moveLocal(t, x, y = 0) {
|
|
@@ -4066,8 +4104,13 @@ const LeafHelper = {
|
|
|
4066
4104
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4067
4105
|
copy$7(matrix$1, t.__localMatrix);
|
|
4068
4106
|
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4069
|
-
|
|
4070
|
-
|
|
4107
|
+
if (t.origin || t.around) {
|
|
4108
|
+
L.setTransform(t, matrix$1, resize);
|
|
4109
|
+
}
|
|
4110
|
+
else {
|
|
4111
|
+
moveByMatrix(t, matrix$1);
|
|
4112
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4113
|
+
}
|
|
4071
4114
|
},
|
|
4072
4115
|
rotateOfWorld(t, origin, angle) {
|
|
4073
4116
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
@@ -4075,8 +4118,13 @@ const LeafHelper = {
|
|
|
4075
4118
|
rotateOfLocal(t, origin, angle) {
|
|
4076
4119
|
copy$7(matrix$1, t.__localMatrix);
|
|
4077
4120
|
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4078
|
-
|
|
4079
|
-
|
|
4121
|
+
if (t.origin || t.around) {
|
|
4122
|
+
L.setTransform(t, matrix$1);
|
|
4123
|
+
}
|
|
4124
|
+
else {
|
|
4125
|
+
moveByMatrix(t, matrix$1);
|
|
4126
|
+
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4127
|
+
}
|
|
4080
4128
|
},
|
|
4081
4129
|
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4082
4130
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
@@ -4099,7 +4147,7 @@ const LeafHelper = {
|
|
|
4099
4147
|
L.setTransform(t, matrix$1, resize);
|
|
4100
4148
|
},
|
|
4101
4149
|
setTransform(t, transform, resize) {
|
|
4102
|
-
const layout = getLayout(transform);
|
|
4150
|
+
const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
|
|
4103
4151
|
if (resize) {
|
|
4104
4152
|
const scaleX = layout.scaleX / t.scaleX;
|
|
4105
4153
|
const scaleY = layout.scaleY / t.scaleY;
|
|
@@ -4112,13 +4160,19 @@ const LeafHelper = {
|
|
|
4112
4160
|
t.set(layout);
|
|
4113
4161
|
}
|
|
4114
4162
|
},
|
|
4163
|
+
getFlipTransform(t, axis) {
|
|
4164
|
+
const m = getMatrixData();
|
|
4165
|
+
const sign = axis === 'x' ? 1 : -1;
|
|
4166
|
+
scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
|
|
4167
|
+
return m;
|
|
4168
|
+
},
|
|
4115
4169
|
getLocalOrigin(t, origin) {
|
|
4116
4170
|
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4117
4171
|
},
|
|
4118
4172
|
getInnerOrigin(t, origin) {
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
return
|
|
4173
|
+
const innerOrigin = {};
|
|
4174
|
+
AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
|
|
4175
|
+
return innerOrigin;
|
|
4122
4176
|
},
|
|
4123
4177
|
getRelativeWorld(t, relative, temp) {
|
|
4124
4178
|
copy$7(matrix$1, t.worldTransform);
|
|
@@ -4545,7 +4599,10 @@ const LeafEventer = {
|
|
|
4545
4599
|
on(type, listener, options) {
|
|
4546
4600
|
let capture, once;
|
|
4547
4601
|
if (options) {
|
|
4548
|
-
if (
|
|
4602
|
+
if (options === 'once') {
|
|
4603
|
+
once = true;
|
|
4604
|
+
}
|
|
4605
|
+
else if (typeof options === 'boolean') {
|
|
4549
4606
|
capture = options;
|
|
4550
4607
|
}
|
|
4551
4608
|
else {
|
|
@@ -4576,7 +4633,7 @@ const LeafEventer = {
|
|
|
4576
4633
|
if (listener) {
|
|
4577
4634
|
let capture;
|
|
4578
4635
|
if (options)
|
|
4579
|
-
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4636
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4580
4637
|
let events, index;
|
|
4581
4638
|
const map = __getListenerMap(this, capture);
|
|
4582
4639
|
typeList.forEach(type => {
|
|
@@ -4878,7 +4935,7 @@ const LeafMatrix = {
|
|
|
4878
4935
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
4879
4936
|
if (layout.affectScaleOrRotation) {
|
|
4880
4937
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
4881
|
-
setLayout(local, data, null, layout.affectRotation);
|
|
4938
|
+
setLayout(local, data, null, null, layout.affectRotation);
|
|
4882
4939
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4883
4940
|
}
|
|
4884
4941
|
}
|
|
@@ -4886,7 +4943,7 @@ const LeafMatrix = {
|
|
|
4886
4943
|
local.f = data.y + data.offsetY;
|
|
4887
4944
|
if (data.around || data.origin) {
|
|
4888
4945
|
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
|
|
4889
|
-
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.
|
|
4946
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
|
|
4890
4947
|
}
|
|
4891
4948
|
}
|
|
4892
4949
|
this.__layout.matrixChanged = false;
|
|
@@ -4895,7 +4952,7 @@ const LeafMatrix = {
|
|
|
4895
4952
|
|
|
4896
4953
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4897
4954
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4898
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4955
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
|
|
4899
4956
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4900
4957
|
const LeafBounds = {
|
|
4901
4958
|
__updateWorldBounds() {
|
|
@@ -4996,7 +5053,7 @@ const LeafBounds = {
|
|
|
4996
5053
|
updateAllMatrix$2(this);
|
|
4997
5054
|
updateBounds$1(this, this);
|
|
4998
5055
|
if (this.__.__autoSide)
|
|
4999
|
-
this.__updateBoxBounds();
|
|
5056
|
+
this.__updateBoxBounds(true);
|
|
5000
5057
|
}
|
|
5001
5058
|
else {
|
|
5002
5059
|
updateAllMatrix$2(this);
|
|
@@ -5014,11 +5071,11 @@ const LeafBounds = {
|
|
|
5014
5071
|
},
|
|
5015
5072
|
__updateStrokeBounds() {
|
|
5016
5073
|
const layout = this.__layout;
|
|
5017
|
-
copyAndSpread$
|
|
5074
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5018
5075
|
},
|
|
5019
5076
|
__updateRenderBounds() {
|
|
5020
5077
|
const layout = this.__layout;
|
|
5021
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5078
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5022
5079
|
}
|
|
5023
5080
|
};
|
|
5024
5081
|
|
|
@@ -5115,7 +5172,7 @@ const { LEAF, create } = IncrementId;
|
|
|
5115
5172
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5116
5173
|
const { toOuterOf } = BoundsHelper;
|
|
5117
5174
|
const { copy: copy$4 } = PointHelper;
|
|
5118
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5175
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5119
5176
|
let Leaf = class Leaf {
|
|
5120
5177
|
get tag() { return this.__tag; }
|
|
5121
5178
|
set tag(_value) { }
|
|
@@ -5141,6 +5198,8 @@ let Leaf = class Leaf {
|
|
|
5141
5198
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5142
5199
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5143
5200
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5201
|
+
set event(map) { let event; for (let key in map)
|
|
5202
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5144
5203
|
constructor(data) {
|
|
5145
5204
|
this.innerId = create(LEAF);
|
|
5146
5205
|
this.reset(data);
|
|
@@ -5376,6 +5435,9 @@ let Leaf = class Leaf {
|
|
|
5376
5435
|
move(x, y) {
|
|
5377
5436
|
moveLocal(this, x, y);
|
|
5378
5437
|
}
|
|
5438
|
+
moveInner(x, y) {
|
|
5439
|
+
moveWorld(this, x, y, true);
|
|
5440
|
+
}
|
|
5379
5441
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5380
5442
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5381
5443
|
}
|
|
@@ -5400,6 +5462,9 @@ let Leaf = class Leaf {
|
|
|
5400
5462
|
skewOfWorld(worldOrigin, skewX, skewY, resize) {
|
|
5401
5463
|
skewOfWorld(this, worldOrigin, skewX, skewY, resize);
|
|
5402
5464
|
}
|
|
5465
|
+
flip(axis) {
|
|
5466
|
+
transform(this, getFlipTransform(this, axis));
|
|
5467
|
+
}
|
|
5403
5468
|
scaleResize(scaleX, scaleY = scaleX, _noResize) {
|
|
5404
5469
|
this.scaleX *= scaleX;
|
|
5405
5470
|
this.scaleY *= scaleY;
|
|
@@ -5757,13 +5822,14 @@ class LeafLevelList {
|
|
|
5757
5822
|
}
|
|
5758
5823
|
}
|
|
5759
5824
|
|
|
5760
|
-
const version = "1.0.
|
|
5825
|
+
const version = "1.0.1";
|
|
5761
5826
|
const inviteCode = {};
|
|
5762
5827
|
|
|
5763
5828
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5764
5829
|
get allowBackgroundColor() { return false; }
|
|
5765
5830
|
init() {
|
|
5766
|
-
|
|
5831
|
+
const { config } = this;
|
|
5832
|
+
let view = config.view || config.canvas;
|
|
5767
5833
|
if (view) {
|
|
5768
5834
|
if (typeof view === 'string') {
|
|
5769
5835
|
if (view[0] !== '#')
|
|
@@ -5793,16 +5859,20 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5793
5859
|
else {
|
|
5794
5860
|
this.view = view.view || view;
|
|
5795
5861
|
}
|
|
5796
|
-
this.__createContext();
|
|
5862
|
+
this.view.getContext ? this.__createContext() : this.unrealCanvas();
|
|
5797
5863
|
const { width, height, pixelRatio } = this.config;
|
|
5798
5864
|
const size = { width: width || view.width, height: height || view.height, pixelRatio };
|
|
5799
5865
|
this.resize(size);
|
|
5800
|
-
if (this.context
|
|
5801
|
-
this.
|
|
5802
|
-
|
|
5803
|
-
|
|
5866
|
+
if (this.context) {
|
|
5867
|
+
if (this.viewSelect)
|
|
5868
|
+
Platform.renderCanvas = this;
|
|
5869
|
+
if (this.context.roundRect) {
|
|
5870
|
+
this.roundRect = function (x, y, width, height, radius) {
|
|
5871
|
+
this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius);
|
|
5872
|
+
};
|
|
5873
|
+
}
|
|
5874
|
+
canvasPatch(this.context.__proto__);
|
|
5804
5875
|
}
|
|
5805
|
-
canvasPatch(this.context.__proto__);
|
|
5806
5876
|
}
|
|
5807
5877
|
__createView() {
|
|
5808
5878
|
this.view = Platform.origin.createCanvas(1, 1);
|
|
@@ -5820,10 +5890,12 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5820
5890
|
callback();
|
|
5821
5891
|
});
|
|
5822
5892
|
}
|
|
5823
|
-
startAutoLayout(
|
|
5893
|
+
startAutoLayout(autoBounds, listener) {
|
|
5824
5894
|
this.resizeListener = listener;
|
|
5825
|
-
|
|
5826
|
-
|
|
5895
|
+
if (autoBounds) {
|
|
5896
|
+
this.checkSize = this.checkSize.bind(this);
|
|
5897
|
+
Platform.miniapp.onWindowResize(this.checkSize);
|
|
5898
|
+
}
|
|
5827
5899
|
}
|
|
5828
5900
|
checkSize() {
|
|
5829
5901
|
if (this.viewSelect) {
|
|
@@ -5832,13 +5904,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5832
5904
|
const { width, height } = this.clientBounds;
|
|
5833
5905
|
const { pixelRatio } = this;
|
|
5834
5906
|
const size = { width, height, pixelRatio };
|
|
5835
|
-
if (!this.isSameSize(size))
|
|
5836
|
-
|
|
5837
|
-
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5838
|
-
this.resize(size);
|
|
5839
|
-
if (this.width !== undefined)
|
|
5840
|
-
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5841
|
-
}
|
|
5907
|
+
if (!this.isSameSize(size))
|
|
5908
|
+
this.emitResize(size);
|
|
5842
5909
|
});
|
|
5843
5910
|
}, 500);
|
|
5844
5911
|
}
|
|
@@ -5848,6 +5915,16 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5848
5915
|
this.resizeListener = null;
|
|
5849
5916
|
Platform.miniapp.offWindowResize(this.checkSize);
|
|
5850
5917
|
}
|
|
5918
|
+
unrealCanvas() {
|
|
5919
|
+
this.unreal = true;
|
|
5920
|
+
}
|
|
5921
|
+
emitResize(size) {
|
|
5922
|
+
const oldSize = {};
|
|
5923
|
+
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5924
|
+
this.resize(size);
|
|
5925
|
+
if (this.width !== undefined)
|
|
5926
|
+
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5927
|
+
}
|
|
5851
5928
|
}
|
|
5852
5929
|
|
|
5853
5930
|
const { mineType, fileType } = FileHelper;
|
|
@@ -5856,120 +5933,121 @@ Object.assign(Creator, {
|
|
|
5856
5933
|
image: (options) => new LeaferImage(options)
|
|
5857
5934
|
});
|
|
5858
5935
|
function useCanvas(_canvasType, app) {
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
fs.unlink({ filePath });
|
|
5885
|
-
resolve();
|
|
5886
|
-
});
|
|
5887
|
-
}
|
|
5888
|
-
else {
|
|
5936
|
+
Platform.origin = {
|
|
5937
|
+
createCanvas: (width, height, _format) => app.createOffscreenCanvas({ type: '2d', width, height }),
|
|
5938
|
+
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
5939
|
+
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
5940
|
+
canvasSaveAs: (canvas, filePath, quality) => {
|
|
5941
|
+
let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
|
|
5942
|
+
data = data.substring(data.indexOf('64,') + 3);
|
|
5943
|
+
return Platform.origin.download(data, filePath);
|
|
5944
|
+
},
|
|
5945
|
+
download(data, filePath) {
|
|
5946
|
+
return new Promise((resolve, reject) => {
|
|
5947
|
+
let toAlbum;
|
|
5948
|
+
if (!filePath.includes('/')) {
|
|
5949
|
+
filePath = `${app.env.USER_DATA_PATH}/` + filePath;
|
|
5950
|
+
toAlbum = true;
|
|
5951
|
+
}
|
|
5952
|
+
const fs = app.getFileSystemManager();
|
|
5953
|
+
fs.writeFile({
|
|
5954
|
+
filePath,
|
|
5955
|
+
data,
|
|
5956
|
+
encoding: 'base64',
|
|
5957
|
+
success() {
|
|
5958
|
+
if (toAlbum) {
|
|
5959
|
+
Platform.miniapp.saveToAlbum(filePath).then(() => {
|
|
5960
|
+
fs.unlink({ filePath });
|
|
5889
5961
|
resolve();
|
|
5890
|
-
}
|
|
5891
|
-
},
|
|
5892
|
-
fail(error) {
|
|
5893
|
-
reject(error);
|
|
5962
|
+
});
|
|
5894
5963
|
}
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
img.onerror = (error) => { reject(error); };
|
|
5903
|
-
img.src = Platform.image.getRealURL(src);
|
|
5964
|
+
else {
|
|
5965
|
+
resolve();
|
|
5966
|
+
}
|
|
5967
|
+
},
|
|
5968
|
+
fail(error) {
|
|
5969
|
+
reject(error);
|
|
5970
|
+
}
|
|
5904
5971
|
});
|
|
5905
|
-
}
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5972
|
+
});
|
|
5973
|
+
},
|
|
5974
|
+
loadImage(src) {
|
|
5975
|
+
return new Promise((resolve, reject) => {
|
|
5976
|
+
const img = Platform.canvas.view.createImage();
|
|
5977
|
+
img.onload = () => { resolve(img); };
|
|
5978
|
+
img.onerror = (error) => { reject(error); };
|
|
5979
|
+
img.src = Platform.image.getRealURL(src);
|
|
5980
|
+
});
|
|
5981
|
+
},
|
|
5982
|
+
noRepeat: 'repeat-x'
|
|
5983
|
+
};
|
|
5984
|
+
Platform.miniapp = {
|
|
5985
|
+
select(name) {
|
|
5986
|
+
return app.createSelectorQuery().select(name);
|
|
5987
|
+
},
|
|
5988
|
+
getBounds(select) {
|
|
5989
|
+
return new Promise((resolve) => {
|
|
5990
|
+
select.boundingClientRect().exec((res) => {
|
|
5991
|
+
const rect = res[1];
|
|
5992
|
+
resolve({ x: rect.top, y: rect.left, width: rect.width, height: rect.height });
|
|
5918
5993
|
});
|
|
5919
|
-
}
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
});
|
|
5994
|
+
});
|
|
5995
|
+
},
|
|
5996
|
+
getSizeView(select) {
|
|
5997
|
+
return new Promise((resolve) => {
|
|
5998
|
+
select.fields({ node: true, size: true }).exec((res) => {
|
|
5999
|
+
const data = res[0];
|
|
6000
|
+
resolve({ view: data.node, width: data.width, height: data.height });
|
|
5926
6001
|
});
|
|
5927
|
-
}
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
}
|
|
5938
|
-
else {
|
|
5939
|
-
app.authorize({
|
|
5940
|
-
scope: 'scope.writePhotosAlbum',
|
|
5941
|
-
success: () => {
|
|
5942
|
-
app.saveImageToPhotosAlbum({
|
|
5943
|
-
filePath: path,
|
|
5944
|
-
success() { resolve(true); }
|
|
5945
|
-
});
|
|
5946
|
-
},
|
|
5947
|
-
fail: () => { }
|
|
5948
|
-
});
|
|
5949
|
-
}
|
|
6002
|
+
});
|
|
6003
|
+
},
|
|
6004
|
+
saveToAlbum(path) {
|
|
6005
|
+
return new Promise((resolve) => {
|
|
6006
|
+
app.getSetting({
|
|
6007
|
+
success: (res) => {
|
|
6008
|
+
if (res.authSetting['scope.writePhotosAlbum']) {
|
|
6009
|
+
app.saveImageToPhotosAlbum({
|
|
6010
|
+
filePath: path,
|
|
6011
|
+
success() { resolve(true); }
|
|
6012
|
+
});
|
|
5950
6013
|
}
|
|
5951
|
-
|
|
6014
|
+
else {
|
|
6015
|
+
app.authorize({
|
|
6016
|
+
scope: 'scope.writePhotosAlbum',
|
|
6017
|
+
success: () => {
|
|
6018
|
+
app.saveImageToPhotosAlbum({
|
|
6019
|
+
filePath: path,
|
|
6020
|
+
success() { resolve(true); }
|
|
6021
|
+
});
|
|
6022
|
+
},
|
|
6023
|
+
fail: () => { }
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
5952
6027
|
});
|
|
5953
|
-
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
}
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
}
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
6028
|
+
});
|
|
6029
|
+
},
|
|
6030
|
+
onWindowResize(fun) {
|
|
6031
|
+
app.onWindowResize(fun);
|
|
6032
|
+
},
|
|
6033
|
+
offWindowResize(fun) {
|
|
6034
|
+
app.offWindowResize(fun);
|
|
6035
|
+
}
|
|
6036
|
+
};
|
|
6037
|
+
Platform.event = {
|
|
6038
|
+
stopDefault(_origin) { },
|
|
6039
|
+
stopNow(_origin) { },
|
|
6040
|
+
stop(_origin) { }
|
|
6041
|
+
};
|
|
6042
|
+
Platform.canvas = Creator.canvas();
|
|
6043
|
+
Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
|
|
5969
6044
|
}
|
|
5970
6045
|
Platform.name = 'miniapp';
|
|
5971
|
-
Platform.requestRender = function (render) {
|
|
5972
|
-
Platform.
|
|
6046
|
+
Platform.requestRender = function (render) {
|
|
6047
|
+
const { view } = (Platform.renderCanvas || Platform.canvas);
|
|
6048
|
+
view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
|
|
6049
|
+
};
|
|
6050
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
|
|
5973
6051
|
|
|
5974
6052
|
class Watcher {
|
|
5975
6053
|
get childrenChanged() { return this.hasAdd || this.hasRemove || this.hasVisible; }
|
|
@@ -6447,14 +6525,14 @@ class Renderer {
|
|
|
6447
6525
|
if (Debug.showRepaint)
|
|
6448
6526
|
this.canvas.strokeWorld(bounds, 'red');
|
|
6449
6527
|
this.target.__render(this.canvas, options);
|
|
6450
|
-
this.renderBounds = realBounds || bounds;
|
|
6528
|
+
this.renderBounds = realBounds = realBounds || bounds;
|
|
6451
6529
|
this.renderOptions = options;
|
|
6452
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
6530
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6453
6531
|
if (Debug.showHitView)
|
|
6454
6532
|
this.renderHitView(options);
|
|
6455
6533
|
if (Debug.showBoundsView)
|
|
6456
6534
|
this.renderBoundsView(options);
|
|
6457
|
-
this.canvas.updateRender();
|
|
6535
|
+
this.canvas.updateRender(realBounds);
|
|
6458
6536
|
}
|
|
6459
6537
|
renderHitView(_options) { }
|
|
6460
6538
|
renderBoundsView(_options) { }
|
|
@@ -7034,6 +7112,11 @@ class BoxData extends GroupData {
|
|
|
7034
7112
|
}
|
|
7035
7113
|
|
|
7036
7114
|
class LeaferData extends GroupData {
|
|
7115
|
+
__getInputData() {
|
|
7116
|
+
const data = super.__getInputData();
|
|
7117
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
7118
|
+
return data;
|
|
7119
|
+
}
|
|
7037
7120
|
}
|
|
7038
7121
|
|
|
7039
7122
|
class FrameData extends BoxData {
|
|
@@ -7111,6 +7194,11 @@ class ImageData extends RectData {
|
|
|
7111
7194
|
}
|
|
7112
7195
|
|
|
7113
7196
|
class CanvasData extends RectData {
|
|
7197
|
+
__getInputData() {
|
|
7198
|
+
const data = super.__getInputData();
|
|
7199
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7200
|
+
return data;
|
|
7201
|
+
}
|
|
7114
7202
|
}
|
|
7115
7203
|
|
|
7116
7204
|
const UIBounds = {
|
|
@@ -7776,7 +7864,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7776
7864
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7777
7865
|
if (this.isApp)
|
|
7778
7866
|
this.__setApp();
|
|
7779
|
-
this.__checkAutoLayout(config);
|
|
7867
|
+
this.__checkAutoLayout(config, parentApp);
|
|
7780
7868
|
this.view = canvas.view;
|
|
7781
7869
|
if (parentApp) {
|
|
7782
7870
|
this.__bindApp(parentApp);
|
|
@@ -7877,9 +7965,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7877
7965
|
this.leafer = leafer;
|
|
7878
7966
|
this.__level = 1;
|
|
7879
7967
|
}
|
|
7880
|
-
__checkAutoLayout(config) {
|
|
7881
|
-
if (!
|
|
7882
|
-
|
|
7968
|
+
__checkAutoLayout(config, parentApp) {
|
|
7969
|
+
if (!parentApp) {
|
|
7970
|
+
if (!config.width || !config.height)
|
|
7971
|
+
this.autoLayout = new AutoBounds(config);
|
|
7883
7972
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
7884
7973
|
}
|
|
7885
7974
|
}
|
|
@@ -8014,12 +8103,21 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8014
8103
|
list.push(item);
|
|
8015
8104
|
}
|
|
8016
8105
|
}
|
|
8017
|
-
zoom(_zoomType, _padding, _fixedScale) {
|
|
8106
|
+
zoom(_zoomType, _padding, _fixedScale) {
|
|
8107
|
+
return debug$3.error('need @leafer-in/view');
|
|
8108
|
+
}
|
|
8018
8109
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
8019
8110
|
getValidScale(changeScale) { return changeScale; }
|
|
8020
8111
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
8021
8112
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
8022
8113
|
}
|
|
8114
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
8115
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8116
|
+
}
|
|
8117
|
+
updateClientBounds() {
|
|
8118
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
8119
|
+
}
|
|
8120
|
+
receiveEvent(_event) { }
|
|
8023
8121
|
__checkUpdateLayout() {
|
|
8024
8122
|
this.__layout.update();
|
|
8025
8123
|
}
|
|
@@ -8103,7 +8201,7 @@ Rect = __decorate([
|
|
|
8103
8201
|
const rect$1 = Rect.prototype;
|
|
8104
8202
|
const group$1 = Group.prototype;
|
|
8105
8203
|
const childrenRenderBounds = {};
|
|
8106
|
-
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8204
|
+
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8107
8205
|
let Box = class Box extends Group {
|
|
8108
8206
|
get __tag() { return 'Box'; }
|
|
8109
8207
|
get isBranchLeaf() { return true; }
|
|
@@ -8117,20 +8215,23 @@ let Box = class Box extends Group {
|
|
|
8117
8215
|
return this.__updateRectRenderSpread() || -1;
|
|
8118
8216
|
}
|
|
8119
8217
|
__updateRectBoxBounds() { }
|
|
8120
|
-
__updateBoxBounds() {
|
|
8218
|
+
__updateBoxBounds(secondLayout) {
|
|
8121
8219
|
const data = this.__;
|
|
8122
8220
|
if (this.children.length) {
|
|
8123
8221
|
if (data.__autoSide) {
|
|
8124
8222
|
if (this.leafer && this.leafer.ready)
|
|
8125
8223
|
this.leafer.layouter.addExtra(this);
|
|
8126
8224
|
super.__updateBoxBounds();
|
|
8225
|
+
const { boxBounds } = this.__layout;
|
|
8127
8226
|
if (!data.__autoSize) {
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8227
|
+
if (data.__autoWidth)
|
|
8228
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8229
|
+
else
|
|
8230
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8133
8231
|
}
|
|
8232
|
+
if (secondLayout && data.flow && data.padding)
|
|
8233
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8234
|
+
this.__updateNaturalSize();
|
|
8134
8235
|
}
|
|
8135
8236
|
else {
|
|
8136
8237
|
this.__updateRectBoxBounds();
|
|
@@ -8150,13 +8251,13 @@ let Box = class Box extends Group {
|
|
|
8150
8251
|
super.__updateRenderBounds();
|
|
8151
8252
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8152
8253
|
this.__updateRectRenderBounds();
|
|
8153
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8254
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8154
8255
|
}
|
|
8155
8256
|
else {
|
|
8156
8257
|
this.__updateRectRenderBounds();
|
|
8157
8258
|
}
|
|
8158
8259
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8159
|
-
if (
|
|
8260
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8160
8261
|
add(renderBounds, childrenRenderBounds);
|
|
8161
8262
|
}
|
|
8162
8263
|
__updateRectRenderBounds() { }
|
|
@@ -8490,14 +8591,26 @@ __decorate([
|
|
|
8490
8591
|
Image = __decorate([
|
|
8491
8592
|
registerUI()
|
|
8492
8593
|
], Image);
|
|
8594
|
+
const MyImage = Image;
|
|
8493
8595
|
|
|
8494
8596
|
let Canvas = class Canvas extends Rect {
|
|
8495
8597
|
get __tag() { return 'Canvas'; }
|
|
8598
|
+
get ready() { return !this.url; }
|
|
8496
8599
|
constructor(data) {
|
|
8497
8600
|
super(data);
|
|
8498
8601
|
this.canvas = Creator.canvas(this.__);
|
|
8499
8602
|
this.context = this.canvas.context;
|
|
8500
8603
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8604
|
+
if (data && data.url)
|
|
8605
|
+
this.drawImage(data.url);
|
|
8606
|
+
}
|
|
8607
|
+
drawImage(url) {
|
|
8608
|
+
new LeaferImage({ url }).load((image) => {
|
|
8609
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8610
|
+
this.url = undefined;
|
|
8611
|
+
this.paint();
|
|
8612
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8613
|
+
});
|
|
8501
8614
|
}
|
|
8502
8615
|
draw(ui, offset, scale, rotation) {
|
|
8503
8616
|
ui.__layout.update();
|
|
@@ -8541,8 +8654,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8541
8654
|
destroy() {
|
|
8542
8655
|
if (this.canvas) {
|
|
8543
8656
|
this.canvas.destroy();
|
|
8544
|
-
this.canvas = null;
|
|
8545
|
-
this.context = null;
|
|
8657
|
+
this.canvas = this.context = null;
|
|
8546
8658
|
}
|
|
8547
8659
|
super.destroy();
|
|
8548
8660
|
}
|
|
@@ -8557,7 +8669,7 @@ __decorate([
|
|
|
8557
8669
|
resizeType(100)
|
|
8558
8670
|
], Canvas.prototype, "height", void 0);
|
|
8559
8671
|
__decorate([
|
|
8560
|
-
resizeType(
|
|
8672
|
+
resizeType(1)
|
|
8561
8673
|
], Canvas.prototype, "pixelRatio", void 0);
|
|
8562
8674
|
__decorate([
|
|
8563
8675
|
resizeType(true)
|
|
@@ -8581,13 +8693,13 @@ let Text = class Text extends UI {
|
|
|
8581
8693
|
super(data);
|
|
8582
8694
|
}
|
|
8583
8695
|
__drawHitPath(canvas) {
|
|
8584
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8696
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8585
8697
|
canvas.beginPath();
|
|
8586
8698
|
if (this.__.__letterSpacing < 0) {
|
|
8587
8699
|
this.__drawPathByData(canvas);
|
|
8588
8700
|
}
|
|
8589
8701
|
else {
|
|
8590
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8702
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8591
8703
|
}
|
|
8592
8704
|
}
|
|
8593
8705
|
__drawPathByData(drawer, _data) {
|
|
@@ -8780,7 +8892,8 @@ let Pen = class Pen extends Group {
|
|
|
8780
8892
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8781
8893
|
clearPath() { return this; }
|
|
8782
8894
|
paint() {
|
|
8783
|
-
this.pathElement.
|
|
8895
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8896
|
+
this.pathElement.forceUpdate('path');
|
|
8784
8897
|
}
|
|
8785
8898
|
};
|
|
8786
8899
|
__decorate([
|
|
@@ -8790,7 +8903,7 @@ __decorate([
|
|
|
8790
8903
|
penPathType()
|
|
8791
8904
|
], Pen.prototype, "path", void 0);
|
|
8792
8905
|
Pen = __decorate([
|
|
8793
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8906
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8794
8907
|
registerUI()
|
|
8795
8908
|
], Pen);
|
|
8796
8909
|
function penPathType() {
|
|
@@ -8895,11 +9008,13 @@ let App = class App extends Leafer {
|
|
|
8895
9008
|
this.renderer.update();
|
|
8896
9009
|
}
|
|
8897
9010
|
__render(canvas, options) {
|
|
8898
|
-
if (
|
|
8899
|
-
|
|
8900
|
-
|
|
9011
|
+
if (canvas.context) {
|
|
9012
|
+
if (options.matrix) {
|
|
9013
|
+
const { a, b, c, d, e, f } = options.matrix;
|
|
9014
|
+
canvas.setTransform(a, b, c, d, e, f);
|
|
9015
|
+
}
|
|
9016
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8901
9017
|
}
|
|
8902
|
-
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8903
9018
|
}
|
|
8904
9019
|
__onResize(event) {
|
|
8905
9020
|
this.children.forEach(leafer => leafer.resize(event));
|
|
@@ -9011,6 +9126,7 @@ PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
|
9011
9126
|
PointerEvent = __decorate([
|
|
9012
9127
|
registerUIEvent()
|
|
9013
9128
|
], PointerEvent);
|
|
9129
|
+
const MyPointerEvent = PointerEvent;
|
|
9014
9130
|
|
|
9015
9131
|
const move = {};
|
|
9016
9132
|
let DragEvent = class DragEvent extends PointerEvent {
|
|
@@ -9110,6 +9226,7 @@ DragEvent.LEAVE = 'drag.leave';
|
|
|
9110
9226
|
DragEvent = __decorate([
|
|
9111
9227
|
registerUIEvent()
|
|
9112
9228
|
], DragEvent);
|
|
9229
|
+
const MyDragEvent = DragEvent;
|
|
9113
9230
|
|
|
9114
9231
|
let DropEvent = class DropEvent extends PointerEvent {
|
|
9115
9232
|
static setList(data) {
|
|
@@ -9191,36 +9308,32 @@ function addInteractionWindow(leafer) {
|
|
|
9191
9308
|
|
|
9192
9309
|
function document(leafer) {
|
|
9193
9310
|
addInteractionWindow(leafer);
|
|
9194
|
-
|
|
9195
|
-
|
|
9311
|
+
const { move, zoom } = leafer.config;
|
|
9312
|
+
move.scroll = 'limit';
|
|
9313
|
+
zoom.min = 1;
|
|
9314
|
+
}
|
|
9315
|
+
|
|
9316
|
+
function block(leafer) {
|
|
9317
|
+
const { config } = leafer;
|
|
9318
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9319
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9196
9320
|
}
|
|
9197
9321
|
|
|
9198
9322
|
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9199
9323
|
const LeaferTypeCreator = {
|
|
9200
9324
|
list: {},
|
|
9201
9325
|
register(name, fn) {
|
|
9202
|
-
|
|
9203
|
-
debug$2.repeat(name);
|
|
9204
|
-
}
|
|
9205
|
-
else {
|
|
9206
|
-
list[name] = fn;
|
|
9207
|
-
}
|
|
9326
|
+
list[name] ? debug$2.repeat(name) : list[name] = fn;
|
|
9208
9327
|
},
|
|
9209
9328
|
run(name, leafer) {
|
|
9210
9329
|
const fn = list[name];
|
|
9211
|
-
|
|
9212
|
-
fn(leafer);
|
|
9213
|
-
}
|
|
9214
|
-
else {
|
|
9215
|
-
debug$2.error('no', name);
|
|
9216
|
-
}
|
|
9330
|
+
fn && fn(leafer);
|
|
9217
9331
|
}
|
|
9218
9332
|
};
|
|
9219
9333
|
const { list, register } = LeaferTypeCreator;
|
|
9220
|
-
register('draw', () => { });
|
|
9221
|
-
register('custom', () => { });
|
|
9222
9334
|
register('design', addInteractionWindow);
|
|
9223
9335
|
register('document', document);
|
|
9336
|
+
register('block', block);
|
|
9224
9337
|
|
|
9225
9338
|
const leafer = Leafer.prototype;
|
|
9226
9339
|
leafer.initType = function (type) {
|
|
@@ -9266,11 +9379,14 @@ leafer.getValidScale = function (changeScale) {
|
|
|
9266
9379
|
};
|
|
9267
9380
|
|
|
9268
9381
|
class Transformer {
|
|
9382
|
+
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9269
9383
|
constructor(interaction) {
|
|
9270
9384
|
this.interaction = interaction;
|
|
9271
9385
|
}
|
|
9272
9386
|
move(data) {
|
|
9273
9387
|
const { interaction } = this;
|
|
9388
|
+
if (!data.moveType)
|
|
9389
|
+
data.moveType = 'move';
|
|
9274
9390
|
if (!this.moveData) {
|
|
9275
9391
|
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9276
9392
|
data.path = path;
|
|
@@ -9406,7 +9522,13 @@ const InteractionHelper = {
|
|
|
9406
9522
|
find.add(list[i]);
|
|
9407
9523
|
}
|
|
9408
9524
|
return find;
|
|
9409
|
-
}
|
|
9525
|
+
},
|
|
9526
|
+
pathCanDrag(path) {
|
|
9527
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(DragEvent.DRAG)));
|
|
9528
|
+
},
|
|
9529
|
+
pathHasOutside(path) {
|
|
9530
|
+
return path && path.list.some(item => item.isOutside);
|
|
9531
|
+
},
|
|
9410
9532
|
};
|
|
9411
9533
|
const I = InteractionHelper;
|
|
9412
9534
|
|
|
@@ -9435,8 +9557,10 @@ class Dragger {
|
|
|
9435
9557
|
return;
|
|
9436
9558
|
}
|
|
9437
9559
|
if (!this.moving && canDrag) {
|
|
9438
|
-
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
|
|
9560
|
+
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
|
|
9561
|
+
this.dragData.moveType = 'drag';
|
|
9439
9562
|
interaction.emit(MoveEvent.START, this.dragData);
|
|
9563
|
+
}
|
|
9440
9564
|
}
|
|
9441
9565
|
if (!this.moving) {
|
|
9442
9566
|
this.dragStart(data, canDrag);
|
|
@@ -9475,6 +9599,7 @@ class Dragger {
|
|
|
9475
9599
|
this.dragData.throughPath = throughPath;
|
|
9476
9600
|
this.dragData.path = path;
|
|
9477
9601
|
if (this.moving) {
|
|
9602
|
+
this.dragData.moveType = 'drag';
|
|
9478
9603
|
interaction.emit(MoveEvent.BEFORE_MOVE, this.dragData);
|
|
9479
9604
|
interaction.emit(MoveEvent.MOVE, this.dragData);
|
|
9480
9605
|
}
|
|
@@ -9541,6 +9666,7 @@ class Dragger {
|
|
|
9541
9666
|
endDragData.path = path;
|
|
9542
9667
|
if (this.moving) {
|
|
9543
9668
|
this.moving = false;
|
|
9669
|
+
endDragData.moveType = 'drag';
|
|
9544
9670
|
interaction.emit(MoveEvent.END, endDragData);
|
|
9545
9671
|
}
|
|
9546
9672
|
if (this.dragging) {
|
|
@@ -9599,7 +9725,7 @@ class Dragger {
|
|
|
9599
9725
|
totalY += moveY;
|
|
9600
9726
|
PointHelper.move(downData, moveX, moveY);
|
|
9601
9727
|
PointHelper.move(this.dragData, moveX, moveY);
|
|
9602
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
|
|
9728
|
+
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9603
9729
|
interaction.pointerMoveReal(data);
|
|
9604
9730
|
}, 10);
|
|
9605
9731
|
}
|
|
@@ -9712,22 +9838,27 @@ const config = {
|
|
|
9712
9838
|
swipeDistance: 20,
|
|
9713
9839
|
preventDefaultMenu: true
|
|
9714
9840
|
},
|
|
9841
|
+
touch: {
|
|
9842
|
+
preventDefault: true
|
|
9843
|
+
},
|
|
9715
9844
|
cursor: true,
|
|
9716
9845
|
keyEvent: true
|
|
9717
9846
|
};
|
|
9718
9847
|
|
|
9719
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
9848
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9720
9849
|
class InteractionBase {
|
|
9721
9850
|
get dragging() { return this.dragger.dragging; }
|
|
9722
|
-
get
|
|
9851
|
+
get transforming() { return this.transformer.transforming; }
|
|
9852
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9853
|
+
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9723
9854
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9724
|
-
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.
|
|
9855
|
+
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
9725
9856
|
get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
|
|
9726
9857
|
get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
|
|
9727
9858
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9728
9859
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9729
9860
|
constructor(target, canvas, selector, userConfig) {
|
|
9730
|
-
this.config = config;
|
|
9861
|
+
this.config = DataHelper.clone(config);
|
|
9731
9862
|
this.tapCount = 0;
|
|
9732
9863
|
this.downKeyMap = {};
|
|
9733
9864
|
this.target = target;
|
|
@@ -9814,6 +9945,7 @@ class InteractionBase {
|
|
|
9814
9945
|
if (!downData)
|
|
9815
9946
|
return;
|
|
9816
9947
|
PointerButton.defaultLeft(data);
|
|
9948
|
+
data.multiTouch = downData.multiTouch;
|
|
9817
9949
|
this.findPath(data);
|
|
9818
9950
|
const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
|
|
9819
9951
|
data.path.addList(downData.path.list);
|
|
@@ -9886,7 +10018,7 @@ class InteractionBase {
|
|
|
9886
10018
|
this.updateCursor();
|
|
9887
10019
|
}
|
|
9888
10020
|
pointerHover(data) {
|
|
9889
|
-
if (this.
|
|
10021
|
+
if (this.canHover) {
|
|
9890
10022
|
this.pointerOverOrOut(data);
|
|
9891
10023
|
this.pointerEnterOrLeave(data);
|
|
9892
10024
|
}
|
|
@@ -9978,11 +10110,11 @@ class InteractionBase {
|
|
|
9978
10110
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
9979
10111
|
}
|
|
9980
10112
|
checkPath(data, useDefaultPath) {
|
|
9981
|
-
if (useDefaultPath || this.
|
|
10113
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
9982
10114
|
data.path = this.defaultPath;
|
|
9983
10115
|
}
|
|
9984
10116
|
canMove(data) {
|
|
9985
|
-
return this.moveMode
|
|
10117
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
9986
10118
|
}
|
|
9987
10119
|
isDrag(leaf) {
|
|
9988
10120
|
return this.dragger.getList().has(leaf);
|
|
@@ -10023,7 +10155,7 @@ class InteractionBase {
|
|
|
10023
10155
|
this.hoverData = data;
|
|
10024
10156
|
}
|
|
10025
10157
|
updateCursor(data) {
|
|
10026
|
-
if (!this.config.cursor || !this.
|
|
10158
|
+
if (!this.config.cursor || !this.canHover)
|
|
10027
10159
|
return;
|
|
10028
10160
|
if (!data) {
|
|
10029
10161
|
this.updateHoverData();
|
|
@@ -10330,7 +10462,7 @@ const PointerEventHelper = {
|
|
|
10330
10462
|
convertTouch(e, local) {
|
|
10331
10463
|
const touch = PointerEventHelper.getTouch(e);
|
|
10332
10464
|
const base = InteractionHelper.getBase(e);
|
|
10333
|
-
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', pressure: touch.force || 1 });
|
|
10465
|
+
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', multiTouch: e.touches.length > 1, pressure: touch.force || 1 });
|
|
10334
10466
|
},
|
|
10335
10467
|
getTouch(e) {
|
|
10336
10468
|
return e.touches[0] || e.changedTouches[0];
|
|
@@ -10390,7 +10522,7 @@ class Interaction extends InteractionBase {
|
|
|
10390
10522
|
this.pointerCancel();
|
|
10391
10523
|
}
|
|
10392
10524
|
multiTouchStart(e) {
|
|
10393
|
-
this.useMultiTouch = (e.touches.length
|
|
10525
|
+
this.useMultiTouch = (e.touches.length > 1);
|
|
10394
10526
|
this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined;
|
|
10395
10527
|
if (this.useMultiTouch)
|
|
10396
10528
|
this.pointerCancel();
|
|
@@ -10782,10 +10914,13 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
10782
10914
|
const { get: get$2, translate } = MatrixHelper;
|
|
10783
10915
|
const tempBox = new Bounds();
|
|
10784
10916
|
const tempPoint = {};
|
|
10917
|
+
const tempScaleData = {};
|
|
10785
10918
|
function createData(leafPaint, image, paint, box) {
|
|
10786
|
-
const { blendMode } = paint;
|
|
10919
|
+
const { blendMode, sync } = paint;
|
|
10787
10920
|
if (blendMode)
|
|
10788
10921
|
leafPaint.blendMode = blendMode;
|
|
10922
|
+
if (sync)
|
|
10923
|
+
leafPaint.sync = sync;
|
|
10789
10924
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10790
10925
|
}
|
|
10791
10926
|
function getPatternData(paint, box, image) {
|
|
@@ -10805,13 +10940,10 @@ function getPatternData(paint, box, image) {
|
|
|
10805
10940
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
10806
10941
|
}
|
|
10807
10942
|
}
|
|
10808
|
-
else if (size) {
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
else if (scale) {
|
|
10813
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
10814
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
10943
|
+
else if (scale || size) {
|
|
10944
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10945
|
+
scaleX = tempScaleData.scaleX;
|
|
10946
|
+
scaleY = tempScaleData.scaleY;
|
|
10815
10947
|
}
|
|
10816
10948
|
if (align) {
|
|
10817
10949
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -11016,7 +11148,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
11016
11148
|
const { abs } = Math;
|
|
11017
11149
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
11018
11150
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11019
|
-
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
11151
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
11020
11152
|
return false;
|
|
11021
11153
|
}
|
|
11022
11154
|
else {
|
|
@@ -11050,7 +11182,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11050
11182
|
return true;
|
|
11051
11183
|
}
|
|
11052
11184
|
else {
|
|
11053
|
-
if (!paint.style || Export.running) {
|
|
11185
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
11054
11186
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
11055
11187
|
}
|
|
11056
11188
|
else {
|
|
@@ -11920,6 +12052,7 @@ const ExportModule = {
|
|
|
11920
12052
|
export(leaf, filename, options) {
|
|
11921
12053
|
this.running = true;
|
|
11922
12054
|
const fileType = FileHelper.fileType(filename);
|
|
12055
|
+
const isDownload = filename.includes('.');
|
|
11923
12056
|
options = FileHelper.getExportOptions(options);
|
|
11924
12057
|
return addTask((success) => new Promise((resolve) => {
|
|
11925
12058
|
const over = (result) => {
|
|
@@ -11929,19 +12062,13 @@ const ExportModule = {
|
|
|
11929
12062
|
};
|
|
11930
12063
|
const { toURL } = Platform;
|
|
11931
12064
|
const { download } = Platform.origin;
|
|
11932
|
-
if (
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
else if (fileType === 'json') {
|
|
11936
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11937
|
-
return over({ data: true });
|
|
12065
|
+
if (fileType === 'json') {
|
|
12066
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12067
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11938
12068
|
}
|
|
11939
|
-
if (
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
else if (fileType === 'svg') {
|
|
11943
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11944
|
-
return over({ data: true });
|
|
12069
|
+
if (fileType === 'svg') {
|
|
12070
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
12071
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11945
12072
|
}
|
|
11946
12073
|
const { leafer } = leaf;
|
|
11947
12074
|
if (leafer) {
|
|
@@ -11950,14 +12077,8 @@ const ExportModule = {
|
|
|
11950
12077
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
11951
12078
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
11952
12079
|
const { slice, trim, onCanvas } = options;
|
|
11953
|
-
let scale = options.scale || 1;
|
|
11954
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
11955
12080
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
11956
12081
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
11957
|
-
if (leaf.isApp) {
|
|
11958
|
-
scale *= pixelRatio;
|
|
11959
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
11960
|
-
}
|
|
11961
12082
|
const screenshot = options.screenshot || leaf.isApp;
|
|
11962
12083
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
11963
12084
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -11991,10 +12112,21 @@ const ExportModule = {
|
|
|
11991
12112
|
}
|
|
11992
12113
|
renderBounds = leaf.getBounds('render', relative);
|
|
11993
12114
|
}
|
|
11994
|
-
const {
|
|
12115
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
12116
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
12117
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
12118
|
+
if (leaf.isApp) {
|
|
12119
|
+
scaleData.scaleX *= pixelRatio;
|
|
12120
|
+
scaleData.scaleY *= pixelRatio;
|
|
12121
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
12122
|
+
}
|
|
12123
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
12124
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
11995
12125
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
11996
|
-
|
|
12126
|
+
let sliceLeaf;
|
|
11997
12127
|
if (slice) {
|
|
12128
|
+
sliceLeaf = leaf;
|
|
12129
|
+
sliceLeaf.__worldOpacity = 0;
|
|
11998
12130
|
leaf = leafer;
|
|
11999
12131
|
renderOptions.bounds = canvas.bounds;
|
|
12000
12132
|
}
|
|
@@ -12009,6 +12141,8 @@ const ExportModule = {
|
|
|
12009
12141
|
leaf.__render(canvas, renderOptions);
|
|
12010
12142
|
}
|
|
12011
12143
|
canvas.restore();
|
|
12144
|
+
if (sliceLeaf)
|
|
12145
|
+
sliceLeaf.__updateWorldOpacity();
|
|
12012
12146
|
if (trim) {
|
|
12013
12147
|
trimBounds = getTrimBounds(canvas);
|
|
12014
12148
|
const old = canvas, { width, height } = trimBounds;
|
|
@@ -12096,39 +12230,37 @@ Object.assign(Creator, {
|
|
|
12096
12230
|
hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
12097
12231
|
hitCanvasManager: () => new HitCanvasManager()
|
|
12098
12232
|
});
|
|
12233
|
+
Leafer.prototype.receiveEvent = function (event) {
|
|
12234
|
+
this.interaction && this.interaction.receive(event);
|
|
12235
|
+
};
|
|
12099
12236
|
try {
|
|
12100
|
-
|
|
12237
|
+
if (wx)
|
|
12238
|
+
useCanvas('miniapp', wx);
|
|
12101
12239
|
}
|
|
12102
12240
|
catch (_a) { }
|
|
12103
12241
|
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
this.
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
}
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
view.height = height * pixelRatio;
|
|
12128
|
-
if (testView) {
|
|
12129
|
-
testView.width = view.width;
|
|
12130
|
-
testView.height = view.height;
|
|
12131
|
-
}
|
|
12132
|
-
};
|
|
12242
|
+
const systemInfo = wx.getSystemInfoSync();
|
|
12243
|
+
const platform = systemInfo.platform;
|
|
12244
|
+
if (platform === 'ios') {
|
|
12245
|
+
LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
|
|
12246
|
+
const pattern = Platform.canvas.createPattern(this.view, repeat);
|
|
12247
|
+
const { width, height } = canvas;
|
|
12248
|
+
if (this.width !== width || this.height !== height) {
|
|
12249
|
+
if (!transform)
|
|
12250
|
+
transform = MatrixHelper.get();
|
|
12251
|
+
MatrixHelper.scale(transform, width / this.width, height / this.height);
|
|
12252
|
+
}
|
|
12253
|
+
try {
|
|
12254
|
+
if (transform && pattern.setTransform) {
|
|
12255
|
+
pattern.setTransform(transform);
|
|
12256
|
+
transform = null;
|
|
12257
|
+
}
|
|
12258
|
+
}
|
|
12259
|
+
catch (_a) { }
|
|
12260
|
+
if (paint)
|
|
12261
|
+
paint.transform = transform;
|
|
12262
|
+
return pattern;
|
|
12263
|
+
};
|
|
12264
|
+
}
|
|
12133
12265
|
|
|
12134
|
-
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
12266
|
+
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|