@leafer-ui/miniapp 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +2954 -0
- package/dist/miniapp.esm.js +178 -161
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -0
- package/dist/miniapp.module.js +700 -570
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +18 -10
- package/src/index.ts +8 -1
- package/types/index.d.ts +1 -0
package/dist/miniapp.module.js
CHANGED
|
@@ -111,6 +111,26 @@ const MathHelper = {
|
|
|
111
111
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
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
|
+
MathHelper.assignScale(scaleData, scale);
|
|
124
|
+
return scaleData;
|
|
125
|
+
},
|
|
126
|
+
assignScale(scaleData, scale) {
|
|
127
|
+
if (typeof scale === 'number') {
|
|
128
|
+
scaleData.scaleX = scaleData.scaleY = scale;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
scaleData.scaleX = scale.x;
|
|
132
|
+
scaleData.scaleY = scale.y;
|
|
133
|
+
}
|
|
114
134
|
}
|
|
115
135
|
};
|
|
116
136
|
const OneRadian = PI$4 / 180;
|
|
@@ -409,7 +429,7 @@ const MatrixHelper = {
|
|
|
409
429
|
};
|
|
410
430
|
const M$6 = MatrixHelper;
|
|
411
431
|
|
|
412
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
432
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
413
433
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
414
434
|
const PointHelper = {
|
|
415
435
|
defaultPoint: getPointData(),
|
|
@@ -465,7 +485,7 @@ const PointHelper = {
|
|
|
465
485
|
tempToOuterOf(t, matrix) {
|
|
466
486
|
const { tempPoint: temp } = P$5;
|
|
467
487
|
copy$b(temp, t);
|
|
468
|
-
toOuterPoint$
|
|
488
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
469
489
|
return temp;
|
|
470
490
|
},
|
|
471
491
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -484,7 +504,7 @@ const PointHelper = {
|
|
|
484
504
|
toInnerPoint$2(matrix, t, to);
|
|
485
505
|
},
|
|
486
506
|
toOuterOf(t, matrix, to) {
|
|
487
|
-
toOuterPoint$
|
|
507
|
+
toOuterPoint$3(matrix, t, to);
|
|
488
508
|
},
|
|
489
509
|
getCenter(t, to) {
|
|
490
510
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -764,7 +784,7 @@ const TwoPointBoundsHelper = {
|
|
|
764
784
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
765
785
|
|
|
766
786
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
767
|
-
const { toOuterPoint: toOuterPoint$
|
|
787
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
768
788
|
const { float, fourNumber } = MathHelper;
|
|
769
789
|
const { floor, ceil: ceil$2 } = Math;
|
|
770
790
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -784,17 +804,24 @@ const BoundsHelper = {
|
|
|
784
804
|
t.width = bounds.width;
|
|
785
805
|
t.height = bounds.height;
|
|
786
806
|
},
|
|
787
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
807
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
808
|
+
const { x, y, width, height } = bounds;
|
|
788
809
|
if (spread instanceof Array) {
|
|
789
810
|
const four = fourNumber(spread);
|
|
790
811
|
isShrink
|
|
791
|
-
? B.set(t,
|
|
792
|
-
: B.set(t,
|
|
812
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
813
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
793
814
|
}
|
|
794
815
|
else {
|
|
795
816
|
if (isShrink)
|
|
796
817
|
spread = -spread;
|
|
797
|
-
B.set(t,
|
|
818
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
819
|
+
}
|
|
820
|
+
if (side) {
|
|
821
|
+
if (side === 'width')
|
|
822
|
+
t.y = y, t.height = height;
|
|
823
|
+
else
|
|
824
|
+
t.x = x, t.width = width;
|
|
798
825
|
}
|
|
799
826
|
},
|
|
800
827
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -871,16 +898,16 @@ const BoundsHelper = {
|
|
|
871
898
|
else {
|
|
872
899
|
point.x = t.x;
|
|
873
900
|
point.y = t.y;
|
|
874
|
-
toOuterPoint$
|
|
901
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
875
902
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
876
903
|
point.x = t.x + t.width;
|
|
877
|
-
toOuterPoint$
|
|
904
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
878
905
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
879
906
|
point.y = t.y + t.height;
|
|
880
|
-
toOuterPoint$
|
|
907
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
881
908
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
882
909
|
point.x = t.x;
|
|
883
|
-
toOuterPoint$
|
|
910
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
884
911
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
885
912
|
toBounds$4(tempPointBounds$1, to);
|
|
886
913
|
}
|
|
@@ -894,16 +921,16 @@ const BoundsHelper = {
|
|
|
894
921
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
895
922
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
896
923
|
},
|
|
897
|
-
getSpread(t, spread) {
|
|
924
|
+
getSpread(t, spread, side) {
|
|
898
925
|
const n = {};
|
|
899
|
-
B.copyAndSpread(n, t, spread);
|
|
926
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
900
927
|
return n;
|
|
901
928
|
},
|
|
902
|
-
spread(t, spread) {
|
|
903
|
-
B.copyAndSpread(t, t, spread);
|
|
929
|
+
spread(t, spread, side) {
|
|
930
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
904
931
|
},
|
|
905
|
-
shrink(t, shrink) {
|
|
906
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
932
|
+
shrink(t, shrink, side) {
|
|
933
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
907
934
|
},
|
|
908
935
|
ceil(t) {
|
|
909
936
|
const { x, y } = t;
|
|
@@ -1086,12 +1113,12 @@ class Bounds {
|
|
|
1086
1113
|
getFitMatrix(put, baseScale) {
|
|
1087
1114
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1088
1115
|
}
|
|
1089
|
-
spread(fourNumber) {
|
|
1090
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1116
|
+
spread(fourNumber, side) {
|
|
1117
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1091
1118
|
return this;
|
|
1092
1119
|
}
|
|
1093
|
-
shrink(fourNumber) {
|
|
1094
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1120
|
+
shrink(fourNumber, side) {
|
|
1121
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1095
1122
|
return this;
|
|
1096
1123
|
}
|
|
1097
1124
|
ceil() {
|
|
@@ -1235,7 +1262,6 @@ const AroundHelper = {
|
|
|
1235
1262
|
tempPoint: {},
|
|
1236
1263
|
get: get$4,
|
|
1237
1264
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1238
|
-
to || (to = {});
|
|
1239
1265
|
const point = get$4(around);
|
|
1240
1266
|
to.x = point.x;
|
|
1241
1267
|
to.y = point.y;
|
|
@@ -1370,6 +1396,10 @@ const Run = {
|
|
|
1370
1396
|
};
|
|
1371
1397
|
const R = Run;
|
|
1372
1398
|
|
|
1399
|
+
function needPlugin(name) {
|
|
1400
|
+
console.error('need plugin: @leafer-in/' + name);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1373
1403
|
const debug$e = Debug.get('UICreator');
|
|
1374
1404
|
const UICreator = {
|
|
1375
1405
|
list: {},
|
|
@@ -1632,6 +1662,9 @@ var Answer;
|
|
|
1632
1662
|
Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
|
|
1633
1663
|
})(Answer || (Answer = {}));
|
|
1634
1664
|
const emptyData = {};
|
|
1665
|
+
function isNull(value) {
|
|
1666
|
+
return value === undefined || value === null;
|
|
1667
|
+
}
|
|
1635
1668
|
|
|
1636
1669
|
/******************************************************************************
|
|
1637
1670
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2397,7 +2430,7 @@ const BezierHelper = {
|
|
|
2397
2430
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2398
2431
|
let fromX = cx + x, fromY = cy + y;
|
|
2399
2432
|
if (data)
|
|
2400
|
-
data.push(L$6, fromX, fromY);
|
|
2433
|
+
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2401
2434
|
if (setPointBounds)
|
|
2402
2435
|
setPoint$2(setPointBounds, fromX, fromY);
|
|
2403
2436
|
if (setStartPoint)
|
|
@@ -2908,60 +2941,75 @@ class PathCreator {
|
|
|
2908
2941
|
}
|
|
2909
2942
|
beginPath() {
|
|
2910
2943
|
beginPath(this.__path);
|
|
2944
|
+
this.paint();
|
|
2911
2945
|
return this;
|
|
2912
2946
|
}
|
|
2913
2947
|
moveTo(x, y) {
|
|
2914
2948
|
moveTo$4(this.__path, x, y);
|
|
2949
|
+
this.paint();
|
|
2915
2950
|
return this;
|
|
2916
2951
|
}
|
|
2917
2952
|
lineTo(x, y) {
|
|
2918
2953
|
lineTo$3(this.__path, x, y);
|
|
2954
|
+
this.paint();
|
|
2919
2955
|
return this;
|
|
2920
2956
|
}
|
|
2921
2957
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2922
2958
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2959
|
+
this.paint();
|
|
2923
2960
|
return this;
|
|
2924
2961
|
}
|
|
2925
2962
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2926
2963
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2964
|
+
this.paint();
|
|
2927
2965
|
return this;
|
|
2928
2966
|
}
|
|
2929
2967
|
closePath() {
|
|
2930
2968
|
closePath$3(this.__path);
|
|
2969
|
+
this.paint();
|
|
2931
2970
|
return this;
|
|
2932
2971
|
}
|
|
2933
2972
|
rect(x, y, width, height) {
|
|
2934
2973
|
rect$2(this.__path, x, y, width, height);
|
|
2974
|
+
this.paint();
|
|
2935
2975
|
return this;
|
|
2936
2976
|
}
|
|
2937
2977
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2938
2978
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2979
|
+
this.paint();
|
|
2939
2980
|
return this;
|
|
2940
2981
|
}
|
|
2941
2982
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2942
2983
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2984
|
+
this.paint();
|
|
2943
2985
|
return this;
|
|
2944
2986
|
}
|
|
2945
2987
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2946
2988
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2989
|
+
this.paint();
|
|
2947
2990
|
return this;
|
|
2948
2991
|
}
|
|
2949
2992
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2950
2993
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2994
|
+
this.paint();
|
|
2951
2995
|
return this;
|
|
2952
2996
|
}
|
|
2953
2997
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2954
2998
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2999
|
+
this.paint();
|
|
2955
3000
|
return this;
|
|
2956
3001
|
}
|
|
2957
3002
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2958
3003
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
3004
|
+
this.paint();
|
|
2959
3005
|
return this;
|
|
2960
3006
|
}
|
|
2961
3007
|
drawPoints(points, curve, close) {
|
|
2962
3008
|
drawPoints$2(this.__path, points, curve, close);
|
|
3009
|
+
this.paint();
|
|
2963
3010
|
return this;
|
|
2964
3011
|
}
|
|
3012
|
+
paint() { }
|
|
2965
3013
|
}
|
|
2966
3014
|
|
|
2967
3015
|
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;
|
|
@@ -3051,8 +3099,7 @@ const PathBounds = {
|
|
|
3051
3099
|
toTwoPointBounds(data, setPointBounds) {
|
|
3052
3100
|
if (!data || !data.length)
|
|
3053
3101
|
return setPoint$1(setPointBounds, 0, 0);
|
|
3054
|
-
let command;
|
|
3055
|
-
let i = 0, x = 0, y = 0, x1, y1, toX, toY;
|
|
3102
|
+
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3056
3103
|
const len = data.length;
|
|
3057
3104
|
while (i < len) {
|
|
3058
3105
|
command = data[i];
|
|
@@ -3708,7 +3755,7 @@ function autoLayoutType(defaultValue) {
|
|
|
3708
3755
|
set(value) {
|
|
3709
3756
|
if (this.__setAttr(key, value)) {
|
|
3710
3757
|
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3711
|
-
this.__hasAutoLayout = !!
|
|
3758
|
+
this.__hasAutoLayout = !!(this.origin || this.around || this.flow);
|
|
3712
3759
|
if (!this.__local)
|
|
3713
3760
|
this.__layout.createLocal();
|
|
3714
3761
|
}
|
|
@@ -3801,14 +3848,25 @@ function visibleType(defaultValue) {
|
|
|
3801
3848
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3802
3849
|
set(value) {
|
|
3803
3850
|
const oldValue = this.visible;
|
|
3804
|
-
if (
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3851
|
+
if (oldValue === true && value === 0) {
|
|
3852
|
+
if (this.animationOut)
|
|
3853
|
+
return this.__runAnimation('out', () => doVisible(this, key, value, oldValue));
|
|
3854
|
+
}
|
|
3855
|
+
else if (oldValue === 0 && value === true) {
|
|
3856
|
+
if (this.animation)
|
|
3857
|
+
this.__runAnimation('in');
|
|
3808
3858
|
}
|
|
3859
|
+
doVisible(this, key, value, oldValue);
|
|
3809
3860
|
}
|
|
3810
3861
|
}));
|
|
3811
3862
|
}
|
|
3863
|
+
function doVisible(leaf, key, value, oldValue) {
|
|
3864
|
+
if (leaf.__setAttr(key, value)) {
|
|
3865
|
+
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
3866
|
+
if (oldValue === 0 || value === 0)
|
|
3867
|
+
doBoundsType(leaf);
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3812
3870
|
function sortType(defaultValue) {
|
|
3813
3871
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3814
3872
|
set(value) {
|
|
@@ -3892,7 +3950,16 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3892
3950
|
if (defaultValue === undefined) {
|
|
3893
3951
|
property.get = function () { return this[computedKey]; };
|
|
3894
3952
|
}
|
|
3895
|
-
else if (
|
|
3953
|
+
else if (typeof defaultValue === 'object') {
|
|
3954
|
+
const { clone } = DataHelper;
|
|
3955
|
+
property.get = function () {
|
|
3956
|
+
let v = this[computedKey];
|
|
3957
|
+
if (v === undefined)
|
|
3958
|
+
this[computedKey] = v = clone(defaultValue);
|
|
3959
|
+
return v;
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
if (key === 'width') {
|
|
3896
3963
|
property.get = function () {
|
|
3897
3964
|
const v = this[computedKey];
|
|
3898
3965
|
if (v === undefined) {
|
|
@@ -3983,7 +4050,7 @@ function registerUIEvent() {
|
|
|
3983
4050
|
};
|
|
3984
4051
|
}
|
|
3985
4052
|
|
|
3986
|
-
const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4053
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3987
4054
|
const matrix$1 = {};
|
|
3988
4055
|
const LeafHelper = {
|
|
3989
4056
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4048,10 +4115,9 @@ const LeafHelper = {
|
|
|
4048
4115
|
}
|
|
4049
4116
|
return true;
|
|
4050
4117
|
},
|
|
4051
|
-
moveWorld(t, x, y = 0) {
|
|
4118
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4052
4119
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4053
|
-
|
|
4054
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4120
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4055
4121
|
L.moveLocal(t, local.x, local.y);
|
|
4056
4122
|
},
|
|
4057
4123
|
moveLocal(t, x, y = 0) {
|
|
@@ -4560,144 +4626,6 @@ class LeafLayout {
|
|
|
4560
4626
|
destroy() { }
|
|
4561
4627
|
}
|
|
4562
4628
|
|
|
4563
|
-
const empty = {};
|
|
4564
|
-
const LeafEventer = {
|
|
4565
|
-
on(type, listener, options) {
|
|
4566
|
-
let capture, once;
|
|
4567
|
-
if (options) {
|
|
4568
|
-
if (options === 'once') {
|
|
4569
|
-
once = true;
|
|
4570
|
-
}
|
|
4571
|
-
else if (typeof options === 'boolean') {
|
|
4572
|
-
capture = options;
|
|
4573
|
-
}
|
|
4574
|
-
else {
|
|
4575
|
-
capture = options.capture;
|
|
4576
|
-
once = options.once;
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
let events;
|
|
4580
|
-
const map = __getListenerMap(this, capture, true);
|
|
4581
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4582
|
-
const item = once ? { listener, once } : { listener };
|
|
4583
|
-
typeList.forEach(type => {
|
|
4584
|
-
if (type) {
|
|
4585
|
-
events = map[type];
|
|
4586
|
-
if (events) {
|
|
4587
|
-
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4588
|
-
events.push(item);
|
|
4589
|
-
}
|
|
4590
|
-
else {
|
|
4591
|
-
map[type] = [item];
|
|
4592
|
-
}
|
|
4593
|
-
}
|
|
4594
|
-
});
|
|
4595
|
-
},
|
|
4596
|
-
off(type, listener, options) {
|
|
4597
|
-
if (type) {
|
|
4598
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4599
|
-
if (listener) {
|
|
4600
|
-
let capture;
|
|
4601
|
-
if (options)
|
|
4602
|
-
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4603
|
-
let events, index;
|
|
4604
|
-
const map = __getListenerMap(this, capture);
|
|
4605
|
-
typeList.forEach(type => {
|
|
4606
|
-
if (type) {
|
|
4607
|
-
events = map[type];
|
|
4608
|
-
if (events) {
|
|
4609
|
-
index = events.findIndex(item => item.listener === listener);
|
|
4610
|
-
if (index > -1)
|
|
4611
|
-
events.splice(index, 1);
|
|
4612
|
-
if (!events.length)
|
|
4613
|
-
delete map[type];
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
});
|
|
4617
|
-
}
|
|
4618
|
-
else {
|
|
4619
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4620
|
-
typeList.forEach(type => {
|
|
4621
|
-
if (b)
|
|
4622
|
-
delete b[type];
|
|
4623
|
-
if (c)
|
|
4624
|
-
delete c[type];
|
|
4625
|
-
});
|
|
4626
|
-
}
|
|
4627
|
-
}
|
|
4628
|
-
else {
|
|
4629
|
-
this.__bubbleMap = this.__captureMap = undefined;
|
|
4630
|
-
}
|
|
4631
|
-
},
|
|
4632
|
-
on_(type, listener, bind, options) {
|
|
4633
|
-
if (bind)
|
|
4634
|
-
listener = listener.bind(bind);
|
|
4635
|
-
this.on(type, listener, options);
|
|
4636
|
-
return { type, current: this, listener, options };
|
|
4637
|
-
},
|
|
4638
|
-
off_(id) {
|
|
4639
|
-
if (!id)
|
|
4640
|
-
return;
|
|
4641
|
-
const list = id instanceof Array ? id : [id];
|
|
4642
|
-
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4643
|
-
list.length = 0;
|
|
4644
|
-
},
|
|
4645
|
-
once(type, listener, capture) {
|
|
4646
|
-
this.on(type, listener, { once: true, capture });
|
|
4647
|
-
},
|
|
4648
|
-
emit(type, event, capture) {
|
|
4649
|
-
if (!event && EventCreator.has(type))
|
|
4650
|
-
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4651
|
-
const map = __getListenerMap(this, capture);
|
|
4652
|
-
const list = map[type];
|
|
4653
|
-
if (list) {
|
|
4654
|
-
let item;
|
|
4655
|
-
for (let i = 0, len = list.length; i < len; i++) {
|
|
4656
|
-
item = list[i];
|
|
4657
|
-
item.listener(event);
|
|
4658
|
-
if (item.once) {
|
|
4659
|
-
this.off(type, item.listener, capture);
|
|
4660
|
-
i--, len--;
|
|
4661
|
-
}
|
|
4662
|
-
if (event && event.isStopNow)
|
|
4663
|
-
break;
|
|
4664
|
-
}
|
|
4665
|
-
}
|
|
4666
|
-
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4667
|
-
},
|
|
4668
|
-
emitEvent(event, capture) {
|
|
4669
|
-
event.current = this;
|
|
4670
|
-
this.emit(event.type, event, capture);
|
|
4671
|
-
},
|
|
4672
|
-
hasEvent(type, capture) {
|
|
4673
|
-
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4674
|
-
return true;
|
|
4675
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4676
|
-
const hasB = b && b[type], hasC = c && c[type];
|
|
4677
|
-
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4678
|
-
},
|
|
4679
|
-
};
|
|
4680
|
-
function __getListenerMap(eventer, capture, create) {
|
|
4681
|
-
if (capture) {
|
|
4682
|
-
const { __captureMap: c } = eventer;
|
|
4683
|
-
if (c) {
|
|
4684
|
-
return c;
|
|
4685
|
-
}
|
|
4686
|
-
else {
|
|
4687
|
-
return create ? eventer.__captureMap = {} : empty;
|
|
4688
|
-
}
|
|
4689
|
-
}
|
|
4690
|
-
else {
|
|
4691
|
-
const { __bubbleMap: b } = eventer;
|
|
4692
|
-
if (b) {
|
|
4693
|
-
return b;
|
|
4694
|
-
}
|
|
4695
|
-
else {
|
|
4696
|
-
return create ? eventer.__bubbleMap = {} : empty;
|
|
4697
|
-
}
|
|
4698
|
-
}
|
|
4699
|
-
}
|
|
4700
|
-
|
|
4701
4629
|
class Event {
|
|
4702
4630
|
constructor(type, target) {
|
|
4703
4631
|
this.bubbles = false;
|
|
@@ -4732,7 +4660,10 @@ class ChildEvent extends Event {
|
|
|
4732
4660
|
}
|
|
4733
4661
|
ChildEvent.ADD = 'child.add';
|
|
4734
4662
|
ChildEvent.REMOVE = 'child.remove';
|
|
4735
|
-
ChildEvent.
|
|
4663
|
+
ChildEvent.CREATED = 'created';
|
|
4664
|
+
ChildEvent.MOUNTED = 'mounted';
|
|
4665
|
+
ChildEvent.UNMOUNTED = 'unmounted';
|
|
4666
|
+
ChildEvent.DESTROY = 'destroy';
|
|
4736
4667
|
|
|
4737
4668
|
class PropertyEvent extends Event {
|
|
4738
4669
|
constructor(type, target, attrName, oldValue, newValue) {
|
|
@@ -4810,10 +4741,6 @@ LayoutEvent.AFTER = 'layout.after';
|
|
|
4810
4741
|
LayoutEvent.AGAIN = 'layout.again';
|
|
4811
4742
|
LayoutEvent.END = 'layout.end';
|
|
4812
4743
|
|
|
4813
|
-
class AnimateEvent extends Event {
|
|
4814
|
-
}
|
|
4815
|
-
AnimateEvent.FRAME = 'animate.frame';
|
|
4816
|
-
|
|
4817
4744
|
class RenderEvent extends Event {
|
|
4818
4745
|
constructor(type, times, bounds, options) {
|
|
4819
4746
|
super(type);
|
|
@@ -4825,26 +4752,177 @@ class RenderEvent extends Event {
|
|
|
4825
4752
|
}
|
|
4826
4753
|
}
|
|
4827
4754
|
}
|
|
4828
|
-
RenderEvent.REQUEST = 'render.request';
|
|
4829
|
-
RenderEvent.START = 'render.start';
|
|
4830
|
-
RenderEvent.BEFORE = 'render.before';
|
|
4831
|
-
RenderEvent.RENDER = 'render';
|
|
4832
|
-
RenderEvent.AFTER = 'render.after';
|
|
4833
|
-
RenderEvent.AGAIN = 'render.again';
|
|
4834
|
-
RenderEvent.END = 'render.end';
|
|
4835
|
-
RenderEvent.NEXT = 'render.next';
|
|
4755
|
+
RenderEvent.REQUEST = 'render.request';
|
|
4756
|
+
RenderEvent.START = 'render.start';
|
|
4757
|
+
RenderEvent.BEFORE = 'render.before';
|
|
4758
|
+
RenderEvent.RENDER = 'render';
|
|
4759
|
+
RenderEvent.AFTER = 'render.after';
|
|
4760
|
+
RenderEvent.AGAIN = 'render.again';
|
|
4761
|
+
RenderEvent.END = 'render.end';
|
|
4762
|
+
RenderEvent.NEXT = 'render.next';
|
|
4763
|
+
|
|
4764
|
+
class LeaferEvent extends Event {
|
|
4765
|
+
}
|
|
4766
|
+
LeaferEvent.START = 'leafer.start';
|
|
4767
|
+
LeaferEvent.BEFORE_READY = 'leafer.before_ready';
|
|
4768
|
+
LeaferEvent.READY = 'leafer.ready';
|
|
4769
|
+
LeaferEvent.AFTER_READY = 'leafer.after_ready';
|
|
4770
|
+
LeaferEvent.VIEW_READY = 'leafer.view_ready';
|
|
4771
|
+
LeaferEvent.VIEW_COMPLETED = 'leafer.view_completed';
|
|
4772
|
+
LeaferEvent.STOP = 'leafer.stop';
|
|
4773
|
+
LeaferEvent.RESTART = 'leafer.restart';
|
|
4774
|
+
LeaferEvent.END = 'leafer.end';
|
|
4775
|
+
|
|
4776
|
+
const empty = {};
|
|
4777
|
+
class Eventer {
|
|
4778
|
+
set event(map) { this.on(map); }
|
|
4779
|
+
on(type, listener, options) {
|
|
4780
|
+
if (!listener) {
|
|
4781
|
+
let event, map = type;
|
|
4782
|
+
for (let key in map)
|
|
4783
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4784
|
+
return;
|
|
4785
|
+
}
|
|
4786
|
+
let capture, once;
|
|
4787
|
+
if (options) {
|
|
4788
|
+
if (options === 'once') {
|
|
4789
|
+
once = true;
|
|
4790
|
+
}
|
|
4791
|
+
else if (typeof options === 'boolean') {
|
|
4792
|
+
capture = options;
|
|
4793
|
+
}
|
|
4794
|
+
else {
|
|
4795
|
+
capture = options.capture;
|
|
4796
|
+
once = options.once;
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
let events;
|
|
4800
|
+
const map = __getListenerMap(this, capture, true);
|
|
4801
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4802
|
+
const item = once ? { listener, once } : { listener };
|
|
4803
|
+
typeList.forEach(type => {
|
|
4804
|
+
if (type) {
|
|
4805
|
+
events = map[type];
|
|
4806
|
+
if (events) {
|
|
4807
|
+
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4808
|
+
events.push(item);
|
|
4809
|
+
}
|
|
4810
|
+
else {
|
|
4811
|
+
map[type] = [item];
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
});
|
|
4815
|
+
}
|
|
4816
|
+
off(type, listener, options) {
|
|
4817
|
+
if (type) {
|
|
4818
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4819
|
+
if (listener) {
|
|
4820
|
+
let capture;
|
|
4821
|
+
if (options)
|
|
4822
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4823
|
+
let events, index;
|
|
4824
|
+
const map = __getListenerMap(this, capture);
|
|
4825
|
+
typeList.forEach(type => {
|
|
4826
|
+
if (type) {
|
|
4827
|
+
events = map[type];
|
|
4828
|
+
if (events) {
|
|
4829
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4830
|
+
if (index > -1)
|
|
4831
|
+
events.splice(index, 1);
|
|
4832
|
+
if (!events.length)
|
|
4833
|
+
delete map[type];
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
});
|
|
4837
|
+
}
|
|
4838
|
+
else {
|
|
4839
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4840
|
+
typeList.forEach(type => {
|
|
4841
|
+
if (b)
|
|
4842
|
+
delete b[type];
|
|
4843
|
+
if (c)
|
|
4844
|
+
delete c[type];
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
else {
|
|
4849
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
on_(type, listener, bind, options) {
|
|
4853
|
+
if (bind)
|
|
4854
|
+
listener = listener.bind(bind);
|
|
4855
|
+
this.on(type, listener, options);
|
|
4856
|
+
return { type, current: this, listener, options };
|
|
4857
|
+
}
|
|
4858
|
+
off_(id) {
|
|
4859
|
+
if (!id)
|
|
4860
|
+
return;
|
|
4861
|
+
const list = id instanceof Array ? id : [id];
|
|
4862
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4863
|
+
list.length = 0;
|
|
4864
|
+
}
|
|
4865
|
+
once(type, listener, capture) {
|
|
4866
|
+
this.on(type, listener, { once: true, capture });
|
|
4867
|
+
}
|
|
4868
|
+
emit(type, event, capture) {
|
|
4869
|
+
if (!event && EventCreator.has(type))
|
|
4870
|
+
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4871
|
+
const map = __getListenerMap(this, capture);
|
|
4872
|
+
const list = map[type];
|
|
4873
|
+
if (list) {
|
|
4874
|
+
let item;
|
|
4875
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
4876
|
+
item = list[i];
|
|
4877
|
+
item.listener(event);
|
|
4878
|
+
if (item.once) {
|
|
4879
|
+
this.off(type, item.listener, capture);
|
|
4880
|
+
i--, len--;
|
|
4881
|
+
}
|
|
4882
|
+
if (event && event.isStopNow)
|
|
4883
|
+
break;
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4887
|
+
}
|
|
4888
|
+
emitEvent(event, capture) {
|
|
4889
|
+
event.current = this;
|
|
4890
|
+
this.emit(event.type, event, capture);
|
|
4891
|
+
}
|
|
4892
|
+
hasEvent(type, capture) {
|
|
4893
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4894
|
+
return true;
|
|
4895
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4896
|
+
const hasB = b && b[type], hasC = c && c[type];
|
|
4897
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4898
|
+
}
|
|
4899
|
+
destroy() {
|
|
4900
|
+
this.__captureMap = this.__bubbleMap = this.syncEventer = null;
|
|
4901
|
+
}
|
|
4902
|
+
}
|
|
4903
|
+
function __getListenerMap(eventer, capture, create) {
|
|
4904
|
+
if (capture) {
|
|
4905
|
+
const { __captureMap: c } = eventer;
|
|
4906
|
+
if (c) {
|
|
4907
|
+
return c;
|
|
4908
|
+
}
|
|
4909
|
+
else {
|
|
4910
|
+
return create ? eventer.__captureMap = {} : empty;
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
else {
|
|
4914
|
+
const { __bubbleMap: b } = eventer;
|
|
4915
|
+
if (b) {
|
|
4916
|
+
return b;
|
|
4917
|
+
}
|
|
4918
|
+
else {
|
|
4919
|
+
return create ? eventer.__bubbleMap = {} : empty;
|
|
4920
|
+
}
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4836
4923
|
|
|
4837
|
-
|
|
4838
|
-
}
|
|
4839
|
-
LeaferEvent.START = 'leafer.start';
|
|
4840
|
-
LeaferEvent.BEFORE_READY = 'leafer.before_ready';
|
|
4841
|
-
LeaferEvent.READY = 'leafer.ready';
|
|
4842
|
-
LeaferEvent.AFTER_READY = 'leafer.after_ready';
|
|
4843
|
-
LeaferEvent.VIEW_READY = 'leafer.view_ready';
|
|
4844
|
-
LeaferEvent.VIEW_COMPLETED = 'leafer.view_completed';
|
|
4845
|
-
LeaferEvent.STOP = 'leafer.stop';
|
|
4846
|
-
LeaferEvent.RESTART = 'leafer.restart';
|
|
4847
|
-
LeaferEvent.END = 'leafer.end';
|
|
4924
|
+
const { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroy } = Eventer.prototype;
|
|
4925
|
+
const LeafEventer = { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroyEventer: destroy };
|
|
4848
4926
|
|
|
4849
4927
|
const { isFinite } = Number;
|
|
4850
4928
|
const debug$7 = Debug.get('setAttr');
|
|
@@ -4857,9 +4935,7 @@ const LeafDataProxy = {
|
|
|
4857
4935
|
newValue = undefined;
|
|
4858
4936
|
}
|
|
4859
4937
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4860
|
-
this.
|
|
4861
|
-
if (this.__proxyData)
|
|
4862
|
-
this.setProxyAttr(name, newValue);
|
|
4938
|
+
this.__realSetAttr(name, newValue);
|
|
4863
4939
|
const { CHANGE } = PropertyEvent;
|
|
4864
4940
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
4865
4941
|
if (this.isLeafer) {
|
|
@@ -4877,12 +4953,18 @@ const LeafDataProxy = {
|
|
|
4877
4953
|
}
|
|
4878
4954
|
}
|
|
4879
4955
|
else {
|
|
4880
|
-
this.
|
|
4881
|
-
if (this.__proxyData)
|
|
4882
|
-
this.setProxyAttr(name, newValue);
|
|
4956
|
+
this.__realSetAttr(name, newValue);
|
|
4883
4957
|
return true;
|
|
4884
4958
|
}
|
|
4885
4959
|
},
|
|
4960
|
+
__realSetAttr(name, newValue) {
|
|
4961
|
+
const data = this.__;
|
|
4962
|
+
data[name] = newValue;
|
|
4963
|
+
if (this.__proxyData)
|
|
4964
|
+
this.setProxyAttr(name, newValue);
|
|
4965
|
+
if (data.normalStyle)
|
|
4966
|
+
this.lockNormalStyle || data.normalStyle[name] === undefined || (data.normalStyle[name] = newValue);
|
|
4967
|
+
},
|
|
4886
4968
|
__getAttr(name) {
|
|
4887
4969
|
if (this.__proxyData)
|
|
4888
4970
|
return this.getProxyAttr(name);
|
|
@@ -4918,7 +5000,7 @@ const LeafMatrix = {
|
|
|
4918
5000
|
|
|
4919
5001
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4920
5002
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4921
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5003
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
|
|
4922
5004
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4923
5005
|
const LeafBounds = {
|
|
4924
5006
|
__updateWorldBounds() {
|
|
@@ -4985,6 +5067,8 @@ const LeafBounds = {
|
|
|
4985
5067
|
layout.boundsChanged = false;
|
|
4986
5068
|
},
|
|
4987
5069
|
__updateLocalBoxBounds() {
|
|
5070
|
+
if (this.__hasMotionPath)
|
|
5071
|
+
this.__updateMotionPath();
|
|
4988
5072
|
if (this.__hasAutoLayout)
|
|
4989
5073
|
this.__updateAutoLayout();
|
|
4990
5074
|
toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
|
|
@@ -5019,7 +5103,7 @@ const LeafBounds = {
|
|
|
5019
5103
|
updateAllMatrix$2(this);
|
|
5020
5104
|
updateBounds$1(this, this);
|
|
5021
5105
|
if (this.__.__autoSide)
|
|
5022
|
-
this.__updateBoxBounds();
|
|
5106
|
+
this.__updateBoxBounds(true);
|
|
5023
5107
|
}
|
|
5024
5108
|
else {
|
|
5025
5109
|
updateAllMatrix$2(this);
|
|
@@ -5037,11 +5121,11 @@ const LeafBounds = {
|
|
|
5037
5121
|
},
|
|
5038
5122
|
__updateStrokeBounds() {
|
|
5039
5123
|
const layout = this.__layout;
|
|
5040
|
-
copyAndSpread$
|
|
5124
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5041
5125
|
},
|
|
5042
5126
|
__updateRenderBounds() {
|
|
5043
5127
|
const layout = this.__layout;
|
|
5044
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5128
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5045
5129
|
}
|
|
5046
5130
|
};
|
|
5047
5131
|
|
|
@@ -5137,7 +5221,7 @@ const BranchRender = {
|
|
|
5137
5221
|
const { LEAF, create } = IncrementId;
|
|
5138
5222
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5139
5223
|
const { toOuterOf } = BoundsHelper;
|
|
5140
|
-
const { copy: copy$4 } = PointHelper;
|
|
5224
|
+
const { copy: copy$4, move: move$1 } = PointHelper;
|
|
5141
5225
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5142
5226
|
let Leaf = class Leaf {
|
|
5143
5227
|
get tag() { return this.__tag; }
|
|
@@ -5164,13 +5248,16 @@ let Leaf = class Leaf {
|
|
|
5164
5248
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5165
5249
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5166
5250
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5167
|
-
set event(map) {
|
|
5168
|
-
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5251
|
+
set event(map) { this.on(map); }
|
|
5169
5252
|
constructor(data) {
|
|
5170
5253
|
this.innerId = create(LEAF);
|
|
5171
5254
|
this.reset(data);
|
|
5255
|
+
if (this.__bubbleMap)
|
|
5256
|
+
this.__emitLifeEvent(ChildEvent.CREATED);
|
|
5172
5257
|
}
|
|
5173
5258
|
reset(data) {
|
|
5259
|
+
if (this.leafer)
|
|
5260
|
+
this.leafer.forceRender(this.__world);
|
|
5174
5261
|
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
|
|
5175
5262
|
if (data !== null)
|
|
5176
5263
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -5192,12 +5279,12 @@ let Leaf = class Leaf {
|
|
|
5192
5279
|
waitParent(item, bind) {
|
|
5193
5280
|
if (bind)
|
|
5194
5281
|
item = item.bind(bind);
|
|
5195
|
-
this.parent ? item() :
|
|
5282
|
+
this.parent ? item() : this.on(ChildEvent.ADD, item, 'once');
|
|
5196
5283
|
}
|
|
5197
5284
|
waitLeafer(item, bind) {
|
|
5198
5285
|
if (bind)
|
|
5199
5286
|
item = item.bind(bind);
|
|
5200
|
-
this.leafer ? item() :
|
|
5287
|
+
this.leafer ? item() : this.on(ChildEvent.MOUNTED, item, 'once');
|
|
5201
5288
|
}
|
|
5202
5289
|
nextRender(item, bind, off) {
|
|
5203
5290
|
this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
|
|
@@ -5206,18 +5293,21 @@ let Leaf = class Leaf {
|
|
|
5206
5293
|
this.nextRender(item, null, 'off');
|
|
5207
5294
|
}
|
|
5208
5295
|
__bindLeafer(leafer) {
|
|
5209
|
-
if (this.isLeafer)
|
|
5210
|
-
|
|
5211
|
-
leafer = this;
|
|
5212
|
-
}
|
|
5296
|
+
if (this.isLeafer && leafer !== null)
|
|
5297
|
+
leafer = this;
|
|
5213
5298
|
if (this.leafer && !leafer)
|
|
5214
5299
|
this.leafer.leafs--;
|
|
5215
5300
|
this.leafer = leafer;
|
|
5216
5301
|
if (leafer) {
|
|
5217
5302
|
leafer.leafs++;
|
|
5218
5303
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5219
|
-
if (this.
|
|
5220
|
-
|
|
5304
|
+
if (this.animation)
|
|
5305
|
+
this.__runAnimation('in');
|
|
5306
|
+
if (this.__bubbleMap)
|
|
5307
|
+
this.__emitLifeEvent(ChildEvent.MOUNTED);
|
|
5308
|
+
}
|
|
5309
|
+
else {
|
|
5310
|
+
this.__emitLifeEvent(ChildEvent.UNMOUNTED);
|
|
5221
5311
|
}
|
|
5222
5312
|
if (this.isBranch) {
|
|
5223
5313
|
const { children } = this;
|
|
@@ -5226,7 +5316,7 @@ let Leaf = class Leaf {
|
|
|
5226
5316
|
}
|
|
5227
5317
|
}
|
|
5228
5318
|
}
|
|
5229
|
-
set(_data) { }
|
|
5319
|
+
set(_data, _isTemp) { }
|
|
5230
5320
|
get(_name) { return undefined; }
|
|
5231
5321
|
setAttr(name, value) { this[name] = value; }
|
|
5232
5322
|
getAttr(name) { return this[name]; }
|
|
@@ -5251,6 +5341,7 @@ let Leaf = class Leaf {
|
|
|
5251
5341
|
findOne(_condition, _options) { return undefined; }
|
|
5252
5342
|
findId(_id) { return undefined; }
|
|
5253
5343
|
focus(_value) { }
|
|
5344
|
+
updateState() { }
|
|
5254
5345
|
updateLayout() {
|
|
5255
5346
|
this.__layout.update();
|
|
5256
5347
|
}
|
|
@@ -5358,11 +5449,24 @@ let Leaf = class Leaf {
|
|
|
5358
5449
|
if (relative)
|
|
5359
5450
|
relative.worldToInner(to ? to : inner, null, distance);
|
|
5360
5451
|
}
|
|
5452
|
+
getBoxPoint(world, relative, distance, change) {
|
|
5453
|
+
return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
|
|
5454
|
+
}
|
|
5455
|
+
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5456
|
+
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5457
|
+
move$1(point, -x, -y);
|
|
5458
|
+
return point;
|
|
5459
|
+
}
|
|
5361
5460
|
getInnerPoint(world, relative, distance, change) {
|
|
5362
5461
|
const point = change ? world : {};
|
|
5363
5462
|
this.worldToInner(world, point, distance, relative);
|
|
5364
5463
|
return point;
|
|
5365
5464
|
}
|
|
5465
|
+
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5466
|
+
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5467
|
+
move$1(point, x, y);
|
|
5468
|
+
return point;
|
|
5469
|
+
}
|
|
5366
5470
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
5367
5471
|
return this.getInnerPoint(local, this.parent, distance, change);
|
|
5368
5472
|
}
|
|
@@ -5374,20 +5478,23 @@ let Leaf = class Leaf {
|
|
|
5374
5478
|
getLocalPointByInner(inner, _relative, distance, change) {
|
|
5375
5479
|
return this.getWorldPoint(inner, this.parent, distance, change);
|
|
5376
5480
|
}
|
|
5481
|
+
getPagePoint(world, relative, distance, change) {
|
|
5482
|
+
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5483
|
+
return layer.getInnerPoint(world, relative, distance, change);
|
|
5484
|
+
}
|
|
5377
5485
|
getWorldPoint(inner, relative, distance, change) {
|
|
5378
5486
|
const point = change ? inner : {};
|
|
5379
5487
|
this.innerToWorld(inner, point, distance, relative);
|
|
5380
5488
|
return point;
|
|
5381
5489
|
}
|
|
5490
|
+
getWorldPointByBox(box, relative, distance, change) {
|
|
5491
|
+
return this.getWorldPoint(this.getInnerPointByBox(box, null, null, change), relative, distance, true);
|
|
5492
|
+
}
|
|
5382
5493
|
getWorldPointByLocal(local, relative, distance, change) {
|
|
5383
5494
|
const point = change ? local : {};
|
|
5384
5495
|
this.localToWorld(local, point, distance, relative);
|
|
5385
5496
|
return point;
|
|
5386
5497
|
}
|
|
5387
|
-
getPagePoint(world, relative, distance, change) {
|
|
5388
|
-
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5389
|
-
return layer.getInnerPoint(world, relative, distance, change);
|
|
5390
|
-
}
|
|
5391
5498
|
getWorldPointByPage(page, relative, distance, change) {
|
|
5392
5499
|
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5393
5500
|
return layer.getWorldPoint(page, relative, distance, change);
|
|
@@ -5401,6 +5508,9 @@ let Leaf = class Leaf {
|
|
|
5401
5508
|
move(x, y) {
|
|
5402
5509
|
moveLocal(this, x, y);
|
|
5403
5510
|
}
|
|
5511
|
+
moveInner(x, y) {
|
|
5512
|
+
moveWorld(this, x, y, true);
|
|
5513
|
+
}
|
|
5404
5514
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5405
5515
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5406
5516
|
}
|
|
@@ -5453,6 +5563,17 @@ let Leaf = class Leaf {
|
|
|
5453
5563
|
__drawRenderPath(_canvas) { }
|
|
5454
5564
|
__updatePath() { }
|
|
5455
5565
|
__updateRenderPath() { }
|
|
5566
|
+
getMotionPathData() {
|
|
5567
|
+
return needPlugin('path');
|
|
5568
|
+
}
|
|
5569
|
+
getMotionPoint(_motionDistance) {
|
|
5570
|
+
return needPlugin('path');
|
|
5571
|
+
}
|
|
5572
|
+
getMotionTotal() {
|
|
5573
|
+
return 0;
|
|
5574
|
+
}
|
|
5575
|
+
__updateMotionPath() { }
|
|
5576
|
+
__runAnimation(_type, _complete) { }
|
|
5456
5577
|
__updateSortChildren() { }
|
|
5457
5578
|
add(_child, _index) { }
|
|
5458
5579
|
remove(_child, destroy) {
|
|
@@ -5478,6 +5599,10 @@ let Leaf = class Leaf {
|
|
|
5478
5599
|
fn = boundsType;
|
|
5479
5600
|
fn(defaultValue)(this.prototype, attrName);
|
|
5480
5601
|
}
|
|
5602
|
+
__emitLifeEvent(type) {
|
|
5603
|
+
if (this.hasEvent(type))
|
|
5604
|
+
this.emitEvent(new ChildEvent(type, this, this.parent));
|
|
5605
|
+
}
|
|
5481
5606
|
destroy() {
|
|
5482
5607
|
if (!this.destroyed) {
|
|
5483
5608
|
const { parent } = this;
|
|
@@ -5485,11 +5610,10 @@ let Leaf = class Leaf {
|
|
|
5485
5610
|
this.remove();
|
|
5486
5611
|
if (this.children)
|
|
5487
5612
|
this.removeAll(true);
|
|
5488
|
-
|
|
5489
|
-
this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
|
|
5613
|
+
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5490
5614
|
this.__.destroy();
|
|
5491
5615
|
this.__layout.destroy();
|
|
5492
|
-
this.
|
|
5616
|
+
this.destroyEventer();
|
|
5493
5617
|
this.destroyed = true;
|
|
5494
5618
|
}
|
|
5495
5619
|
}
|
|
@@ -5555,8 +5679,8 @@ let Branch = class Branch extends Leaf {
|
|
|
5555
5679
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5556
5680
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
5557
5681
|
child.__layout.matrixChanged || child.__layout.matrixChange();
|
|
5558
|
-
if (child.
|
|
5559
|
-
|
|
5682
|
+
if (child.__bubbleMap)
|
|
5683
|
+
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5560
5684
|
if (this.leafer) {
|
|
5561
5685
|
child.__bindLeafer(this.leafer);
|
|
5562
5686
|
if (this.leafer.created)
|
|
@@ -5569,16 +5693,10 @@ let Branch = class Branch extends Leaf {
|
|
|
5569
5693
|
}
|
|
5570
5694
|
remove(child, destroy) {
|
|
5571
5695
|
if (child) {
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5577
|
-
this.__preRemove();
|
|
5578
|
-
this.__realRemoveChild(child);
|
|
5579
|
-
if (destroy)
|
|
5580
|
-
child.destroy();
|
|
5581
|
-
}
|
|
5696
|
+
if (child.animationOut)
|
|
5697
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5698
|
+
else
|
|
5699
|
+
this.__remove(child, destroy);
|
|
5582
5700
|
}
|
|
5583
5701
|
else if (child === undefined) {
|
|
5584
5702
|
super.remove(null, destroy);
|
|
@@ -5600,6 +5718,18 @@ let Branch = class Branch extends Leaf {
|
|
|
5600
5718
|
clear() {
|
|
5601
5719
|
this.removeAll(true);
|
|
5602
5720
|
}
|
|
5721
|
+
__remove(child, destroy) {
|
|
5722
|
+
const index = this.children.indexOf(child);
|
|
5723
|
+
if (index > -1) {
|
|
5724
|
+
this.children.splice(index, 1);
|
|
5725
|
+
if (child.isBranch)
|
|
5726
|
+
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5727
|
+
this.__preRemove();
|
|
5728
|
+
this.__realRemoveChild(child);
|
|
5729
|
+
if (destroy)
|
|
5730
|
+
child.destroy();
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5603
5733
|
__preRemove() {
|
|
5604
5734
|
if (this.__hasMask)
|
|
5605
5735
|
this.__updateMask();
|
|
@@ -5609,6 +5739,7 @@ let Branch = class Branch extends Leaf {
|
|
|
5609
5739
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5610
5740
|
}
|
|
5611
5741
|
__realRemoveChild(child) {
|
|
5742
|
+
child.__emitLifeEvent(ChildEvent.REMOVE);
|
|
5612
5743
|
child.parent = null;
|
|
5613
5744
|
if (this.leafer) {
|
|
5614
5745
|
child.__bindLeafer(null);
|
|
@@ -5621,8 +5752,6 @@ let Branch = class Branch extends Leaf {
|
|
|
5621
5752
|
}
|
|
5622
5753
|
__emitChildEvent(type, child) {
|
|
5623
5754
|
const event = new ChildEvent(type, child, this);
|
|
5624
|
-
if (child.hasEvent(type))
|
|
5625
|
-
child.emitEvent(event);
|
|
5626
5755
|
if (this.hasEvent(type) && !this.isLeafer)
|
|
5627
5756
|
this.emitEvent(event);
|
|
5628
5757
|
this.leafer.emitEvent(event);
|
|
@@ -5785,8 +5914,7 @@ class LeafLevelList {
|
|
|
5785
5914
|
}
|
|
5786
5915
|
}
|
|
5787
5916
|
|
|
5788
|
-
const version = "1.0.
|
|
5789
|
-
const inviteCode = {};
|
|
5917
|
+
const version = "1.0.3";
|
|
5790
5918
|
|
|
5791
5919
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5792
5920
|
get allowBackgroundColor() { return false; }
|
|
@@ -5827,6 +5955,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5827
5955
|
const size = { width: width || view.width, height: height || view.height, pixelRatio };
|
|
5828
5956
|
this.resize(size);
|
|
5829
5957
|
if (this.context) {
|
|
5958
|
+
if (this.viewSelect)
|
|
5959
|
+
Platform.renderCanvas = this;
|
|
5830
5960
|
if (this.context.roundRect) {
|
|
5831
5961
|
this.roundRect = function (x, y, width, height, radius) {
|
|
5832
5962
|
this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius);
|
|
@@ -5894,119 +6024,120 @@ Object.assign(Creator, {
|
|
|
5894
6024
|
image: (options) => new LeaferImage(options)
|
|
5895
6025
|
});
|
|
5896
6026
|
function useCanvas(_canvasType, app) {
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
fs.unlink({ filePath });
|
|
5923
|
-
resolve();
|
|
5924
|
-
});
|
|
5925
|
-
}
|
|
5926
|
-
else {
|
|
6027
|
+
Platform.origin = {
|
|
6028
|
+
createCanvas: (width, height, _format) => app.createOffscreenCanvas({ type: '2d', width, height }),
|
|
6029
|
+
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
6030
|
+
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
6031
|
+
canvasSaveAs: (canvas, filePath, quality) => {
|
|
6032
|
+
let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
|
|
6033
|
+
data = data.substring(data.indexOf('64,') + 3);
|
|
6034
|
+
return Platform.origin.download(data, filePath);
|
|
6035
|
+
},
|
|
6036
|
+
download(data, filePath) {
|
|
6037
|
+
return new Promise((resolve, reject) => {
|
|
6038
|
+
let toAlbum;
|
|
6039
|
+
if (!filePath.includes('/')) {
|
|
6040
|
+
filePath = `${app.env.USER_DATA_PATH}/` + filePath;
|
|
6041
|
+
toAlbum = true;
|
|
6042
|
+
}
|
|
6043
|
+
const fs = app.getFileSystemManager();
|
|
6044
|
+
fs.writeFile({
|
|
6045
|
+
filePath,
|
|
6046
|
+
data,
|
|
6047
|
+
encoding: 'base64',
|
|
6048
|
+
success() {
|
|
6049
|
+
if (toAlbum) {
|
|
6050
|
+
Platform.miniapp.saveToAlbum(filePath).then(() => {
|
|
6051
|
+
fs.unlink({ filePath });
|
|
5927
6052
|
resolve();
|
|
5928
|
-
}
|
|
5929
|
-
},
|
|
5930
|
-
fail(error) {
|
|
5931
|
-
reject(error);
|
|
6053
|
+
});
|
|
5932
6054
|
}
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
img.onerror = (error) => { reject(error); };
|
|
5941
|
-
img.src = Platform.image.getRealURL(src);
|
|
6055
|
+
else {
|
|
6056
|
+
resolve();
|
|
6057
|
+
}
|
|
6058
|
+
},
|
|
6059
|
+
fail(error) {
|
|
6060
|
+
reject(error);
|
|
6061
|
+
}
|
|
5942
6062
|
});
|
|
5943
|
-
}
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
6063
|
+
});
|
|
6064
|
+
},
|
|
6065
|
+
loadImage(src) {
|
|
6066
|
+
return new Promise((resolve, reject) => {
|
|
6067
|
+
const img = Platform.canvas.view.createImage();
|
|
6068
|
+
img.onload = () => { resolve(img); };
|
|
6069
|
+
img.onerror = (error) => { reject(error); };
|
|
6070
|
+
img.src = Platform.image.getRealURL(src);
|
|
6071
|
+
});
|
|
6072
|
+
},
|
|
6073
|
+
noRepeat: 'repeat-x'
|
|
6074
|
+
};
|
|
6075
|
+
Platform.miniapp = {
|
|
6076
|
+
select(name) {
|
|
6077
|
+
return app.createSelectorQuery().select(name);
|
|
6078
|
+
},
|
|
6079
|
+
getBounds(select) {
|
|
6080
|
+
return new Promise((resolve) => {
|
|
6081
|
+
select.boundingClientRect().exec((res) => {
|
|
6082
|
+
const rect = res[1];
|
|
6083
|
+
resolve({ x: rect.top, y: rect.left, width: rect.width, height: rect.height });
|
|
5956
6084
|
});
|
|
5957
|
-
}
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
});
|
|
6085
|
+
});
|
|
6086
|
+
},
|
|
6087
|
+
getSizeView(select) {
|
|
6088
|
+
return new Promise((resolve) => {
|
|
6089
|
+
select.fields({ node: true, size: true }).exec((res) => {
|
|
6090
|
+
const data = res[0];
|
|
6091
|
+
resolve({ view: data.node, width: data.width, height: data.height });
|
|
5964
6092
|
});
|
|
5965
|
-
}
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
}
|
|
5976
|
-
else {
|
|
5977
|
-
app.authorize({
|
|
5978
|
-
scope: 'scope.writePhotosAlbum',
|
|
5979
|
-
success: () => {
|
|
5980
|
-
app.saveImageToPhotosAlbum({
|
|
5981
|
-
filePath: path,
|
|
5982
|
-
success() { resolve(true); }
|
|
5983
|
-
});
|
|
5984
|
-
},
|
|
5985
|
-
fail: () => { }
|
|
5986
|
-
});
|
|
5987
|
-
}
|
|
6093
|
+
});
|
|
6094
|
+
},
|
|
6095
|
+
saveToAlbum(path) {
|
|
6096
|
+
return new Promise((resolve) => {
|
|
6097
|
+
app.getSetting({
|
|
6098
|
+
success: (res) => {
|
|
6099
|
+
if (res.authSetting['scope.writePhotosAlbum']) {
|
|
6100
|
+
app.saveImageToPhotosAlbum({
|
|
6101
|
+
filePath: path,
|
|
6102
|
+
success() { resolve(true); }
|
|
6103
|
+
});
|
|
5988
6104
|
}
|
|
5989
|
-
|
|
6105
|
+
else {
|
|
6106
|
+
app.authorize({
|
|
6107
|
+
scope: 'scope.writePhotosAlbum',
|
|
6108
|
+
success: () => {
|
|
6109
|
+
app.saveImageToPhotosAlbum({
|
|
6110
|
+
filePath: path,
|
|
6111
|
+
success() { resolve(true); }
|
|
6112
|
+
});
|
|
6113
|
+
},
|
|
6114
|
+
fail: () => { }
|
|
6115
|
+
});
|
|
6116
|
+
}
|
|
6117
|
+
}
|
|
5990
6118
|
});
|
|
5991
|
-
}
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
}
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6119
|
+
});
|
|
6120
|
+
},
|
|
6121
|
+
onWindowResize(fun) {
|
|
6122
|
+
app.onWindowResize(fun);
|
|
6123
|
+
},
|
|
6124
|
+
offWindowResize(fun) {
|
|
6125
|
+
app.offWindowResize(fun);
|
|
6126
|
+
}
|
|
6127
|
+
};
|
|
6128
|
+
Platform.event = {
|
|
6129
|
+
stopDefault(_origin) { },
|
|
6130
|
+
stopNow(_origin) { },
|
|
6131
|
+
stop(_origin) { }
|
|
6132
|
+
};
|
|
6133
|
+
Platform.canvas = Creator.canvas();
|
|
6134
|
+
Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
|
|
6007
6135
|
}
|
|
6008
6136
|
Platform.name = 'miniapp';
|
|
6009
|
-
Platform.requestRender = function (render) {
|
|
6137
|
+
Platform.requestRender = function (render) {
|
|
6138
|
+
const { view } = (Platform.renderCanvas || Platform.canvas);
|
|
6139
|
+
view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
|
|
6140
|
+
};
|
|
6010
6141
|
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
|
|
6011
6142
|
|
|
6012
6143
|
class Watcher {
|
|
@@ -6147,9 +6278,13 @@ function updateBounds(boundsList) {
|
|
|
6147
6278
|
});
|
|
6148
6279
|
}
|
|
6149
6280
|
function updateChange(updateList) {
|
|
6281
|
+
let layout;
|
|
6150
6282
|
updateList.list.forEach(leaf => {
|
|
6151
|
-
|
|
6283
|
+
layout = leaf.__layout;
|
|
6284
|
+
if (layout.opacityChanged)
|
|
6152
6285
|
updateAllWorldOpacity(leaf);
|
|
6286
|
+
if (layout.stateStyleChanged)
|
|
6287
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
6153
6288
|
leaf.__updateChange();
|
|
6154
6289
|
});
|
|
6155
6290
|
}
|
|
@@ -6515,7 +6650,6 @@ class Renderer {
|
|
|
6515
6650
|
Platform.requestRender(() => {
|
|
6516
6651
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
6517
6652
|
if (this.running) {
|
|
6518
|
-
this.target.emit(AnimateEvent.FRAME);
|
|
6519
6653
|
if (this.changed && this.canvas.view)
|
|
6520
6654
|
this.render();
|
|
6521
6655
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -6860,36 +6994,6 @@ Object.assign(Creator, {
|
|
|
6860
6994
|
});
|
|
6861
6995
|
Platform.layout = Layouter.fullLayout;
|
|
6862
6996
|
|
|
6863
|
-
const TextConvert = {};
|
|
6864
|
-
const ColorConvert = {};
|
|
6865
|
-
const PathArrow = {};
|
|
6866
|
-
const Paint = {};
|
|
6867
|
-
const PaintImage = {};
|
|
6868
|
-
const PaintGradient = {};
|
|
6869
|
-
const Effect = {};
|
|
6870
|
-
const Export = {};
|
|
6871
|
-
const State = {};
|
|
6872
|
-
|
|
6873
|
-
function stateType(defaultValue) {
|
|
6874
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6875
|
-
set(value) {
|
|
6876
|
-
this.__setAttr(key, value);
|
|
6877
|
-
this.waitLeafer(() => { if (State.setStyle)
|
|
6878
|
-
State.setStyle(this, key + 'Style', value); });
|
|
6879
|
-
}
|
|
6880
|
-
}));
|
|
6881
|
-
}
|
|
6882
|
-
function arrowType(defaultValue) {
|
|
6883
|
-
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6884
|
-
set(value) {
|
|
6885
|
-
if (this.__setAttr(key, value)) {
|
|
6886
|
-
const data = this.__;
|
|
6887
|
-
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
6888
|
-
doStrokeType(this);
|
|
6889
|
-
}
|
|
6890
|
-
}
|
|
6891
|
-
}));
|
|
6892
|
-
}
|
|
6893
6997
|
function effectType(defaultValue) {
|
|
6894
6998
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6895
6999
|
set(value) {
|
|
@@ -6924,10 +7028,33 @@ function zoomLayerType() {
|
|
|
6924
7028
|
};
|
|
6925
7029
|
}
|
|
6926
7030
|
|
|
7031
|
+
const TextConvert = {};
|
|
7032
|
+
const ColorConvert = {};
|
|
7033
|
+
const PathArrow = {};
|
|
7034
|
+
const Paint = {};
|
|
7035
|
+
const PaintImage = {};
|
|
7036
|
+
const PaintGradient = {};
|
|
7037
|
+
const Effect = {};
|
|
7038
|
+
const Export = {};
|
|
7039
|
+
const State = {
|
|
7040
|
+
setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
|
|
7041
|
+
set(_leaf, _stateName) { return needPlugin('state'); }
|
|
7042
|
+
};
|
|
7043
|
+
const Transition = {
|
|
7044
|
+
list: {},
|
|
7045
|
+
register(attrName, fn) {
|
|
7046
|
+
Transition.list[attrName] = fn;
|
|
7047
|
+
},
|
|
7048
|
+
get(attrName) {
|
|
7049
|
+
return Transition.list[attrName];
|
|
7050
|
+
}
|
|
7051
|
+
};
|
|
7052
|
+
|
|
6927
7053
|
const { parse } = PathConvert;
|
|
6928
7054
|
const emptyPaint = {};
|
|
6929
7055
|
const debug$4 = Debug.get('UIData');
|
|
6930
7056
|
class UIData extends LeafData {
|
|
7057
|
+
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6931
7058
|
get __strokeWidth() {
|
|
6932
7059
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
6933
7060
|
if (strokeWidthFixed) {
|
|
@@ -6946,9 +7073,10 @@ class UIData extends LeafData {
|
|
|
6946
7073
|
get __autoSide() { return !this._width || !this._height; }
|
|
6947
7074
|
get __autoSize() { return !this._width && !this._height; }
|
|
6948
7075
|
setVisible(value) {
|
|
6949
|
-
if (this.__leaf.leafer)
|
|
6950
|
-
this.__leaf.leafer.watcher.hasVisible = true;
|
|
6951
7076
|
this._visible = value;
|
|
7077
|
+
const { leafer } = this.__leaf;
|
|
7078
|
+
if (leafer)
|
|
7079
|
+
leafer.watcher.hasVisible = true;
|
|
6952
7080
|
}
|
|
6953
7081
|
setWidth(value) {
|
|
6954
7082
|
if (value < 0) {
|
|
@@ -7072,6 +7200,11 @@ class BoxData extends GroupData {
|
|
|
7072
7200
|
}
|
|
7073
7201
|
|
|
7074
7202
|
class LeaferData extends GroupData {
|
|
7203
|
+
__getInputData() {
|
|
7204
|
+
const data = super.__getInputData();
|
|
7205
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
7206
|
+
return data;
|
|
7207
|
+
}
|
|
7075
7208
|
}
|
|
7076
7209
|
|
|
7077
7210
|
class FrameData extends BoxData {
|
|
@@ -7134,7 +7267,7 @@ class ImageData extends RectData {
|
|
|
7134
7267
|
__setImageFill(value) {
|
|
7135
7268
|
if (this.__leaf.image)
|
|
7136
7269
|
this.__leaf.image = null;
|
|
7137
|
-
this.fill = value ? { type: 'image', mode: '
|
|
7270
|
+
this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
|
|
7138
7271
|
}
|
|
7139
7272
|
__getData() {
|
|
7140
7273
|
const data = super.__getData();
|
|
@@ -7149,6 +7282,11 @@ class ImageData extends RectData {
|
|
|
7149
7282
|
}
|
|
7150
7283
|
|
|
7151
7284
|
class CanvasData extends RectData {
|
|
7285
|
+
__getInputData() {
|
|
7286
|
+
const data = super.__getInputData();
|
|
7287
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7288
|
+
return data;
|
|
7289
|
+
}
|
|
7152
7290
|
}
|
|
7153
7291
|
|
|
7154
7292
|
const UIBounds = {
|
|
@@ -7319,19 +7457,8 @@ var UI_1;
|
|
|
7319
7457
|
let UI = UI_1 = class UI extends Leaf {
|
|
7320
7458
|
get app() { return this.leafer && this.leafer.app; }
|
|
7321
7459
|
get isFrame() { return false; }
|
|
7322
|
-
set scale(value) {
|
|
7323
|
-
|
|
7324
|
-
this.scaleX = this.scaleY = value;
|
|
7325
|
-
}
|
|
7326
|
-
else {
|
|
7327
|
-
this.scaleX = value.x;
|
|
7328
|
-
this.scaleY = value.y;
|
|
7329
|
-
}
|
|
7330
|
-
}
|
|
7331
|
-
get scale() {
|
|
7332
|
-
const { scaleX, scaleY } = this;
|
|
7333
|
-
return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
|
|
7334
|
-
}
|
|
7460
|
+
set scale(value) { MathHelper.assignScale(this, value); }
|
|
7461
|
+
get scale() { return this.__.scale; }
|
|
7335
7462
|
get pen() {
|
|
7336
7463
|
const { path } = this.__;
|
|
7337
7464
|
pen.set(this.path = path || []);
|
|
@@ -7346,8 +7473,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7346
7473
|
super(data);
|
|
7347
7474
|
}
|
|
7348
7475
|
reset(_data) { }
|
|
7349
|
-
set(data) {
|
|
7350
|
-
|
|
7476
|
+
set(data, isTemp) {
|
|
7477
|
+
if (isTemp) {
|
|
7478
|
+
this.lockNormalStyle = true;
|
|
7479
|
+
Object.assign(this, data);
|
|
7480
|
+
this.lockNormalStyle = false;
|
|
7481
|
+
}
|
|
7482
|
+
else {
|
|
7483
|
+
Object.assign(this, data);
|
|
7484
|
+
}
|
|
7351
7485
|
}
|
|
7352
7486
|
get(name) {
|
|
7353
7487
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -7410,11 +7544,18 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7410
7544
|
drawer.rect(x, y, width, height);
|
|
7411
7545
|
}
|
|
7412
7546
|
}
|
|
7547
|
+
animate(_keyframe, _options, _type, _isTemp) {
|
|
7548
|
+
return needPlugin('animate');
|
|
7549
|
+
}
|
|
7550
|
+
killAnimate(_type) { }
|
|
7413
7551
|
export(filename, options) {
|
|
7414
7552
|
return Export.export(this, filename, options);
|
|
7415
7553
|
}
|
|
7416
|
-
clone() {
|
|
7417
|
-
|
|
7554
|
+
clone(newData) {
|
|
7555
|
+
const json = this.toJSON();
|
|
7556
|
+
if (newData)
|
|
7557
|
+
Object.assign(json, newData);
|
|
7558
|
+
return UI_1.one(json);
|
|
7418
7559
|
}
|
|
7419
7560
|
static one(data, x, y, width, height) {
|
|
7420
7561
|
return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
|
|
@@ -7430,6 +7571,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7430
7571
|
static setEditInner(_editorName) { }
|
|
7431
7572
|
destroy() {
|
|
7432
7573
|
this.fill = this.stroke = null;
|
|
7574
|
+
if (this.__animate)
|
|
7575
|
+
this.killAnimate();
|
|
7433
7576
|
super.destroy();
|
|
7434
7577
|
}
|
|
7435
7578
|
};
|
|
@@ -7457,12 +7600,6 @@ __decorate([
|
|
|
7457
7600
|
__decorate([
|
|
7458
7601
|
visibleType(true)
|
|
7459
7602
|
], UI.prototype, "visible", void 0);
|
|
7460
|
-
__decorate([
|
|
7461
|
-
stateType(false)
|
|
7462
|
-
], UI.prototype, "selected", void 0);
|
|
7463
|
-
__decorate([
|
|
7464
|
-
stateType(false)
|
|
7465
|
-
], UI.prototype, "disabled", void 0);
|
|
7466
7603
|
__decorate([
|
|
7467
7604
|
surfaceType(false)
|
|
7468
7605
|
], UI.prototype, "locked", void 0);
|
|
@@ -7535,45 +7672,9 @@ __decorate([
|
|
|
7535
7672
|
__decorate([
|
|
7536
7673
|
pathType(true)
|
|
7537
7674
|
], UI.prototype, "closed", void 0);
|
|
7538
|
-
__decorate([
|
|
7539
|
-
autoLayoutType(false)
|
|
7540
|
-
], UI.prototype, "flow", void 0);
|
|
7541
7675
|
__decorate([
|
|
7542
7676
|
boundsType(0)
|
|
7543
7677
|
], UI.prototype, "padding", void 0);
|
|
7544
|
-
__decorate([
|
|
7545
|
-
boundsType(0)
|
|
7546
|
-
], UI.prototype, "gap", void 0);
|
|
7547
|
-
__decorate([
|
|
7548
|
-
boundsType('top-left')
|
|
7549
|
-
], UI.prototype, "flowAlign", void 0);
|
|
7550
|
-
__decorate([
|
|
7551
|
-
boundsType(false)
|
|
7552
|
-
], UI.prototype, "flowWrap", void 0);
|
|
7553
|
-
__decorate([
|
|
7554
|
-
boundsType('box')
|
|
7555
|
-
], UI.prototype, "itemBox", void 0);
|
|
7556
|
-
__decorate([
|
|
7557
|
-
boundsType(true)
|
|
7558
|
-
], UI.prototype, "inFlow", void 0);
|
|
7559
|
-
__decorate([
|
|
7560
|
-
boundsType()
|
|
7561
|
-
], UI.prototype, "autoWidth", void 0);
|
|
7562
|
-
__decorate([
|
|
7563
|
-
boundsType()
|
|
7564
|
-
], UI.prototype, "autoHeight", void 0);
|
|
7565
|
-
__decorate([
|
|
7566
|
-
boundsType()
|
|
7567
|
-
], UI.prototype, "lockRatio", void 0);
|
|
7568
|
-
__decorate([
|
|
7569
|
-
boundsType()
|
|
7570
|
-
], UI.prototype, "autoBox", void 0);
|
|
7571
|
-
__decorate([
|
|
7572
|
-
boundsType()
|
|
7573
|
-
], UI.prototype, "widthRange", void 0);
|
|
7574
|
-
__decorate([
|
|
7575
|
-
boundsType()
|
|
7576
|
-
], UI.prototype, "heightRange", void 0);
|
|
7577
7678
|
__decorate([
|
|
7578
7679
|
dataType(false)
|
|
7579
7680
|
], UI.prototype, "draggable", void 0);
|
|
@@ -7637,12 +7738,6 @@ __decorate([
|
|
|
7637
7738
|
__decorate([
|
|
7638
7739
|
strokeType(10)
|
|
7639
7740
|
], UI.prototype, "miterLimit", void 0);
|
|
7640
|
-
__decorate([
|
|
7641
|
-
arrowType('none')
|
|
7642
|
-
], UI.prototype, "startArrow", void 0);
|
|
7643
|
-
__decorate([
|
|
7644
|
-
arrowType('none')
|
|
7645
|
-
], UI.prototype, "endArrow", void 0);
|
|
7646
7741
|
__decorate([
|
|
7647
7742
|
pathType(0)
|
|
7648
7743
|
], UI.prototype, "cornerRadius", void 0);
|
|
@@ -7664,24 +7759,6 @@ __decorate([
|
|
|
7664
7759
|
__decorate([
|
|
7665
7760
|
effectType()
|
|
7666
7761
|
], UI.prototype, "grayscale", void 0);
|
|
7667
|
-
__decorate([
|
|
7668
|
-
dataType()
|
|
7669
|
-
], UI.prototype, "normalStyle", void 0);
|
|
7670
|
-
__decorate([
|
|
7671
|
-
dataType()
|
|
7672
|
-
], UI.prototype, "hoverStyle", void 0);
|
|
7673
|
-
__decorate([
|
|
7674
|
-
dataType()
|
|
7675
|
-
], UI.prototype, "pressStyle", void 0);
|
|
7676
|
-
__decorate([
|
|
7677
|
-
dataType()
|
|
7678
|
-
], UI.prototype, "focusStyle", void 0);
|
|
7679
|
-
__decorate([
|
|
7680
|
-
dataType()
|
|
7681
|
-
], UI.prototype, "selectedStyle", void 0);
|
|
7682
|
-
__decorate([
|
|
7683
|
-
dataType()
|
|
7684
|
-
], UI.prototype, "disabledStyle", void 0);
|
|
7685
7762
|
__decorate([
|
|
7686
7763
|
dataType({})
|
|
7687
7764
|
], UI.prototype, "data", void 0);
|
|
@@ -7708,7 +7785,7 @@ let Group = class Group extends UI {
|
|
|
7708
7785
|
if (!this.children)
|
|
7709
7786
|
this.children = [];
|
|
7710
7787
|
}
|
|
7711
|
-
set(data) {
|
|
7788
|
+
set(data, isTemp) {
|
|
7712
7789
|
if (data.children) {
|
|
7713
7790
|
const { children } = data;
|
|
7714
7791
|
delete data.children;
|
|
@@ -7718,7 +7795,7 @@ let Group = class Group extends UI {
|
|
|
7718
7795
|
else {
|
|
7719
7796
|
this.clear();
|
|
7720
7797
|
}
|
|
7721
|
-
super.set(data);
|
|
7798
|
+
super.set(data, isTemp);
|
|
7722
7799
|
let child;
|
|
7723
7800
|
children.forEach(childData => {
|
|
7724
7801
|
child = childData.__ ? childData : UICreator.get(childData.tag, childData);
|
|
@@ -7727,7 +7804,7 @@ let Group = class Group extends UI {
|
|
|
7727
7804
|
data.children = children;
|
|
7728
7805
|
}
|
|
7729
7806
|
else {
|
|
7730
|
-
super.set(data);
|
|
7807
|
+
super.set(data, isTemp);
|
|
7731
7808
|
}
|
|
7732
7809
|
}
|
|
7733
7810
|
toJSON(options) {
|
|
@@ -8054,13 +8131,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8054
8131
|
}
|
|
8055
8132
|
}
|
|
8056
8133
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8057
|
-
return
|
|
8134
|
+
return needPlugin('view');
|
|
8058
8135
|
}
|
|
8059
8136
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
8060
8137
|
getValidScale(changeScale) { return changeScale; }
|
|
8061
8138
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
8062
8139
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
8063
8140
|
}
|
|
8141
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
8142
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8143
|
+
}
|
|
8144
|
+
updateClientBounds() {
|
|
8145
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
8146
|
+
}
|
|
8147
|
+
receiveEvent(_event) { }
|
|
8064
8148
|
__checkUpdateLayout() {
|
|
8065
8149
|
this.__layout.update();
|
|
8066
8150
|
}
|
|
@@ -8144,7 +8228,7 @@ Rect = __decorate([
|
|
|
8144
8228
|
const rect$1 = Rect.prototype;
|
|
8145
8229
|
const group$1 = Group.prototype;
|
|
8146
8230
|
const childrenRenderBounds = {};
|
|
8147
|
-
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8231
|
+
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8148
8232
|
let Box = class Box extends Group {
|
|
8149
8233
|
get __tag() { return 'Box'; }
|
|
8150
8234
|
get isBranchLeaf() { return true; }
|
|
@@ -8158,20 +8242,23 @@ let Box = class Box extends Group {
|
|
|
8158
8242
|
return this.__updateRectRenderSpread() || -1;
|
|
8159
8243
|
}
|
|
8160
8244
|
__updateRectBoxBounds() { }
|
|
8161
|
-
__updateBoxBounds() {
|
|
8245
|
+
__updateBoxBounds(secondLayout) {
|
|
8162
8246
|
const data = this.__;
|
|
8163
8247
|
if (this.children.length) {
|
|
8164
8248
|
if (data.__autoSide) {
|
|
8165
8249
|
if (this.leafer && this.leafer.ready)
|
|
8166
8250
|
this.leafer.layouter.addExtra(this);
|
|
8167
8251
|
super.__updateBoxBounds();
|
|
8252
|
+
const { boxBounds } = this.__layout;
|
|
8168
8253
|
if (!data.__autoSize) {
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8254
|
+
if (data.__autoWidth)
|
|
8255
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8256
|
+
else
|
|
8257
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8174
8258
|
}
|
|
8259
|
+
if (secondLayout && data.flow && data.padding)
|
|
8260
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8261
|
+
this.__updateNaturalSize();
|
|
8175
8262
|
}
|
|
8176
8263
|
else {
|
|
8177
8264
|
this.__updateRectBoxBounds();
|
|
@@ -8191,13 +8278,13 @@ let Box = class Box extends Group {
|
|
|
8191
8278
|
super.__updateRenderBounds();
|
|
8192
8279
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8193
8280
|
this.__updateRectRenderBounds();
|
|
8194
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8281
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8195
8282
|
}
|
|
8196
8283
|
else {
|
|
8197
8284
|
this.__updateRectRenderBounds();
|
|
8198
8285
|
}
|
|
8199
8286
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8200
|
-
if (
|
|
8287
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8201
8288
|
add(renderBounds, childrenRenderBounds);
|
|
8202
8289
|
}
|
|
8203
8290
|
__updateRectRenderBounds() { }
|
|
@@ -8531,14 +8618,26 @@ __decorate([
|
|
|
8531
8618
|
Image = __decorate([
|
|
8532
8619
|
registerUI()
|
|
8533
8620
|
], Image);
|
|
8621
|
+
const MyImage = Image;
|
|
8534
8622
|
|
|
8535
8623
|
let Canvas = class Canvas extends Rect {
|
|
8536
8624
|
get __tag() { return 'Canvas'; }
|
|
8625
|
+
get ready() { return !this.url; }
|
|
8537
8626
|
constructor(data) {
|
|
8538
8627
|
super(data);
|
|
8539
8628
|
this.canvas = Creator.canvas(this.__);
|
|
8540
8629
|
this.context = this.canvas.context;
|
|
8541
8630
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8631
|
+
if (data && data.url)
|
|
8632
|
+
this.drawImage(data.url);
|
|
8633
|
+
}
|
|
8634
|
+
drawImage(url) {
|
|
8635
|
+
new LeaferImage({ url }).load((image) => {
|
|
8636
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8637
|
+
this.url = undefined;
|
|
8638
|
+
this.paint();
|
|
8639
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8640
|
+
});
|
|
8542
8641
|
}
|
|
8543
8642
|
draw(ui, offset, scale, rotation) {
|
|
8544
8643
|
ui.__layout.update();
|
|
@@ -8555,19 +8654,18 @@ let Canvas = class Canvas extends Rect {
|
|
|
8555
8654
|
this.paint();
|
|
8556
8655
|
}
|
|
8557
8656
|
paint() {
|
|
8558
|
-
this.
|
|
8657
|
+
this.forceRender();
|
|
8559
8658
|
}
|
|
8560
8659
|
__drawAfterFill(canvas, _options) {
|
|
8561
|
-
const
|
|
8562
|
-
|
|
8563
|
-
if (this.__.cornerRadius || this.pathInputed) {
|
|
8660
|
+
const { width, height, cornerRadius } = this.__, { view } = this.canvas;
|
|
8661
|
+
if (cornerRadius || this.pathInputed) {
|
|
8564
8662
|
canvas.save();
|
|
8565
8663
|
canvas.clip();
|
|
8566
|
-
canvas.drawImage(
|
|
8664
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8567
8665
|
canvas.restore();
|
|
8568
8666
|
}
|
|
8569
8667
|
else {
|
|
8570
|
-
canvas.drawImage(
|
|
8668
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
8571
8669
|
}
|
|
8572
8670
|
}
|
|
8573
8671
|
__updateSize() {
|
|
@@ -8597,7 +8695,7 @@ __decorate([
|
|
|
8597
8695
|
resizeType(100)
|
|
8598
8696
|
], Canvas.prototype, "height", void 0);
|
|
8599
8697
|
__decorate([
|
|
8600
|
-
resizeType(
|
|
8698
|
+
resizeType(1)
|
|
8601
8699
|
], Canvas.prototype, "pixelRatio", void 0);
|
|
8602
8700
|
__decorate([
|
|
8603
8701
|
resizeType(true)
|
|
@@ -8621,13 +8719,13 @@ let Text = class Text extends UI {
|
|
|
8621
8719
|
super(data);
|
|
8622
8720
|
}
|
|
8623
8721
|
__drawHitPath(canvas) {
|
|
8624
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8722
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8625
8723
|
canvas.beginPath();
|
|
8626
8724
|
if (this.__.__letterSpacing < 0) {
|
|
8627
8725
|
this.__drawPathByData(canvas);
|
|
8628
8726
|
}
|
|
8629
8727
|
else {
|
|
8630
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8728
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8631
8729
|
}
|
|
8632
8730
|
}
|
|
8633
8731
|
__drawPathByData(drawer, _data) {
|
|
@@ -8820,7 +8918,8 @@ let Pen = class Pen extends Group {
|
|
|
8820
8918
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8821
8919
|
clearPath() { return this; }
|
|
8822
8920
|
paint() {
|
|
8823
|
-
this.pathElement.
|
|
8921
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8922
|
+
this.pathElement.forceUpdate('path');
|
|
8824
8923
|
}
|
|
8825
8924
|
};
|
|
8826
8925
|
__decorate([
|
|
@@ -8830,7 +8929,7 @@ __decorate([
|
|
|
8830
8929
|
penPathType()
|
|
8831
8930
|
], Pen.prototype, "path", void 0);
|
|
8832
8931
|
Pen = __decorate([
|
|
8833
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8932
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8834
8933
|
registerUI()
|
|
8835
8934
|
], Pen);
|
|
8836
8935
|
function penPathType() {
|
|
@@ -9009,21 +9108,29 @@ class UIEvent extends Event {
|
|
|
9009
9108
|
constructor(params) {
|
|
9010
9109
|
super(params.type);
|
|
9011
9110
|
this.bubbles = true;
|
|
9111
|
+
this.getInner = this.getInnerPoint;
|
|
9112
|
+
this.getLocal = this.getLocalPoint;
|
|
9113
|
+
this.getPage = this.getPagePoint;
|
|
9012
9114
|
Object.assign(this, params);
|
|
9013
9115
|
}
|
|
9014
|
-
|
|
9015
|
-
|
|
9116
|
+
getBoxPoint(relative) {
|
|
9117
|
+
if (!relative)
|
|
9118
|
+
relative = this.current;
|
|
9119
|
+
return relative.getBoxPoint(this);
|
|
9016
9120
|
}
|
|
9017
|
-
|
|
9121
|
+
getInnerPoint(relative) {
|
|
9018
9122
|
if (!relative)
|
|
9019
9123
|
relative = this.current;
|
|
9020
9124
|
return relative.getInnerPoint(this);
|
|
9021
9125
|
}
|
|
9022
|
-
|
|
9126
|
+
getLocalPoint(relative) {
|
|
9023
9127
|
if (!relative)
|
|
9024
9128
|
relative = this.current;
|
|
9025
9129
|
return relative.getLocalPoint(this);
|
|
9026
9130
|
}
|
|
9131
|
+
getPagePoint() {
|
|
9132
|
+
return this.current.getPagePoint(this);
|
|
9133
|
+
}
|
|
9027
9134
|
static changeName(oldName, newName) {
|
|
9028
9135
|
EventCreator.changeName(oldName, newName);
|
|
9029
9136
|
}
|
|
@@ -9053,6 +9160,7 @@ PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
|
9053
9160
|
PointerEvent = __decorate([
|
|
9054
9161
|
registerUIEvent()
|
|
9055
9162
|
], PointerEvent);
|
|
9163
|
+
const MyPointerEvent = PointerEvent;
|
|
9056
9164
|
|
|
9057
9165
|
const move = {};
|
|
9058
9166
|
let DragEvent = class DragEvent extends PointerEvent {
|
|
@@ -9130,7 +9238,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9130
9238
|
}
|
|
9131
9239
|
getPageBounds() {
|
|
9132
9240
|
const total = this.getPageTotal();
|
|
9133
|
-
const start = this.
|
|
9241
|
+
const start = this.getPagePoint();
|
|
9134
9242
|
const bounds = {};
|
|
9135
9243
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9136
9244
|
BoundsHelper.unsign(bounds);
|
|
@@ -9152,6 +9260,7 @@ DragEvent.LEAVE = 'drag.leave';
|
|
|
9152
9260
|
DragEvent = __decorate([
|
|
9153
9261
|
registerUIEvent()
|
|
9154
9262
|
], DragEvent);
|
|
9263
|
+
const MyDragEvent = DragEvent;
|
|
9155
9264
|
|
|
9156
9265
|
let DropEvent = class DropEvent extends PointerEvent {
|
|
9157
9266
|
static setList(data) {
|
|
@@ -9233,36 +9342,32 @@ function addInteractionWindow(leafer) {
|
|
|
9233
9342
|
|
|
9234
9343
|
function document(leafer) {
|
|
9235
9344
|
addInteractionWindow(leafer);
|
|
9236
|
-
|
|
9237
|
-
|
|
9345
|
+
const { move, zoom } = leafer.config;
|
|
9346
|
+
move.scroll = 'limit';
|
|
9347
|
+
zoom.min = 1;
|
|
9348
|
+
}
|
|
9349
|
+
|
|
9350
|
+
function block(leafer) {
|
|
9351
|
+
const { config } = leafer;
|
|
9352
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9353
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9238
9354
|
}
|
|
9239
9355
|
|
|
9240
9356
|
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9241
9357
|
const LeaferTypeCreator = {
|
|
9242
9358
|
list: {},
|
|
9243
9359
|
register(name, fn) {
|
|
9244
|
-
|
|
9245
|
-
debug$2.repeat(name);
|
|
9246
|
-
}
|
|
9247
|
-
else {
|
|
9248
|
-
list[name] = fn;
|
|
9249
|
-
}
|
|
9360
|
+
list[name] ? debug$2.repeat(name) : list[name] = fn;
|
|
9250
9361
|
},
|
|
9251
9362
|
run(name, leafer) {
|
|
9252
9363
|
const fn = list[name];
|
|
9253
|
-
|
|
9254
|
-
fn(leafer);
|
|
9255
|
-
}
|
|
9256
|
-
else {
|
|
9257
|
-
debug$2.error('no', name);
|
|
9258
|
-
}
|
|
9364
|
+
fn && fn(leafer);
|
|
9259
9365
|
}
|
|
9260
9366
|
};
|
|
9261
9367
|
const { list, register } = LeaferTypeCreator;
|
|
9262
|
-
register('draw', () => { });
|
|
9263
|
-
register('custom', () => { });
|
|
9264
9368
|
register('design', addInteractionWindow);
|
|
9265
9369
|
register('document', document);
|
|
9370
|
+
register('block', block);
|
|
9266
9371
|
|
|
9267
9372
|
const leafer = Leafer.prototype;
|
|
9268
9373
|
leafer.initType = function (type) {
|
|
@@ -9451,7 +9556,13 @@ const InteractionHelper = {
|
|
|
9451
9556
|
find.add(list[i]);
|
|
9452
9557
|
}
|
|
9453
9558
|
return find;
|
|
9454
|
-
}
|
|
9559
|
+
},
|
|
9560
|
+
pathCanDrag(path) {
|
|
9561
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(DragEvent.DRAG)));
|
|
9562
|
+
},
|
|
9563
|
+
pathHasOutside(path) {
|
|
9564
|
+
return path && path.list.some(item => item.isOutside);
|
|
9565
|
+
},
|
|
9455
9566
|
};
|
|
9456
9567
|
const I = InteractionHelper;
|
|
9457
9568
|
|
|
@@ -9711,7 +9822,7 @@ function emitEvent(leaf, type, data, capture, excludePath) {
|
|
|
9711
9822
|
if (leaf.destroyed)
|
|
9712
9823
|
return false;
|
|
9713
9824
|
if (leaf.__.hitSelf && !exclude(leaf, excludePath)) {
|
|
9714
|
-
if (State.updateEventStyle)
|
|
9825
|
+
if (State.updateEventStyle && !capture)
|
|
9715
9826
|
State.updateEventStyle(leaf, type);
|
|
9716
9827
|
if (leaf.hasEvent(type, capture)) {
|
|
9717
9828
|
data.phase = capture ? 1 : ((leaf === data.target) ? 2 : 3);
|
|
@@ -9761,15 +9872,18 @@ const config = {
|
|
|
9761
9872
|
swipeDistance: 20,
|
|
9762
9873
|
preventDefaultMenu: true
|
|
9763
9874
|
},
|
|
9875
|
+
touch: {
|
|
9876
|
+
preventDefault: true
|
|
9877
|
+
},
|
|
9764
9878
|
cursor: true,
|
|
9765
9879
|
keyEvent: true
|
|
9766
9880
|
};
|
|
9767
9881
|
|
|
9768
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
9882
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9769
9883
|
class InteractionBase {
|
|
9770
9884
|
get dragging() { return this.dragger.dragging; }
|
|
9771
9885
|
get transforming() { return this.transformer.transforming; }
|
|
9772
|
-
get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9886
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9773
9887
|
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9774
9888
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9775
9889
|
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
@@ -9778,7 +9892,7 @@ class InteractionBase {
|
|
|
9778
9892
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9779
9893
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9780
9894
|
constructor(target, canvas, selector, userConfig) {
|
|
9781
|
-
this.config = config;
|
|
9895
|
+
this.config = DataHelper.clone(config);
|
|
9782
9896
|
this.tapCount = 0;
|
|
9783
9897
|
this.downKeyMap = {};
|
|
9784
9898
|
this.target = target;
|
|
@@ -9813,7 +9927,7 @@ class InteractionBase {
|
|
|
9813
9927
|
this.tapWait();
|
|
9814
9928
|
this.longPressWait(data);
|
|
9815
9929
|
}
|
|
9816
|
-
this.
|
|
9930
|
+
this.waitRightTap = PointerButton.right(data);
|
|
9817
9931
|
this.dragger.setDragData(data);
|
|
9818
9932
|
if (!this.isHoldRightKey)
|
|
9819
9933
|
this.updateCursor(data);
|
|
@@ -9841,7 +9955,7 @@ class InteractionBase {
|
|
|
9841
9955
|
if (canDrag) {
|
|
9842
9956
|
if (this.waitTap)
|
|
9843
9957
|
this.pointerWaitCancel();
|
|
9844
|
-
this.
|
|
9958
|
+
this.waitRightTap = false;
|
|
9845
9959
|
}
|
|
9846
9960
|
this.dragger.checkDrag(data, canDrag);
|
|
9847
9961
|
}
|
|
@@ -9895,10 +10009,15 @@ class InteractionBase {
|
|
|
9895
10009
|
menu(data) {
|
|
9896
10010
|
this.findPath(data);
|
|
9897
10011
|
this.emit(PointerEvent.MENU, data);
|
|
10012
|
+
this.waitMenuTap = true;
|
|
10013
|
+
if (!this.downData && this.waitRightTap)
|
|
10014
|
+
this.menuTap(data);
|
|
9898
10015
|
}
|
|
9899
10016
|
menuTap(data) {
|
|
9900
|
-
if (this.waitMenuTap)
|
|
10017
|
+
if (this.waitRightTap && this.waitMenuTap) {
|
|
9901
10018
|
this.emit(PointerEvent.MENU_TAP, data);
|
|
10019
|
+
this.waitRightTap = this.waitMenuTap = false;
|
|
10020
|
+
}
|
|
9902
10021
|
}
|
|
9903
10022
|
move(data) {
|
|
9904
10023
|
this.transformer.move(data);
|
|
@@ -10030,11 +10149,11 @@ class InteractionBase {
|
|
|
10030
10149
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
10031
10150
|
}
|
|
10032
10151
|
checkPath(data, useDefaultPath) {
|
|
10033
|
-
if (useDefaultPath || this.
|
|
10152
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
10034
10153
|
data.path = this.defaultPath;
|
|
10035
10154
|
}
|
|
10036
10155
|
canMove(data) {
|
|
10037
|
-
return this.moveMode
|
|
10156
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
10038
10157
|
}
|
|
10039
10158
|
isDrag(leaf) {
|
|
10040
10159
|
return this.dragger.getList().has(leaf);
|
|
@@ -10834,16 +10953,21 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
10834
10953
|
const { get: get$2, translate } = MatrixHelper;
|
|
10835
10954
|
const tempBox = new Bounds();
|
|
10836
10955
|
const tempPoint = {};
|
|
10956
|
+
const tempScaleData = {};
|
|
10837
10957
|
function createData(leafPaint, image, paint, box) {
|
|
10838
|
-
const { blendMode } = paint;
|
|
10958
|
+
const { blendMode, sync } = paint;
|
|
10839
10959
|
if (blendMode)
|
|
10840
10960
|
leafPaint.blendMode = blendMode;
|
|
10961
|
+
if (sync)
|
|
10962
|
+
leafPaint.sync = sync;
|
|
10841
10963
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10842
10964
|
}
|
|
10843
10965
|
function getPatternData(paint, box, image) {
|
|
10844
10966
|
let { width, height } = image;
|
|
10845
10967
|
if (paint.padding)
|
|
10846
10968
|
box = tempBox.set(box).shrink(paint.padding);
|
|
10969
|
+
if (paint.mode === 'strench')
|
|
10970
|
+
paint.mode = 'stretch';
|
|
10847
10971
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
10848
10972
|
const sameBox = box.width === width && box.height === height;
|
|
10849
10973
|
const data = { mode };
|
|
@@ -10857,13 +10981,10 @@ function getPatternData(paint, box, image) {
|
|
|
10857
10981
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
10858
10982
|
}
|
|
10859
10983
|
}
|
|
10860
|
-
else if (size) {
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
else if (scale) {
|
|
10865
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
10866
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
10984
|
+
else if (scale || size) {
|
|
10985
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10986
|
+
scaleX = tempScaleData.scaleX;
|
|
10987
|
+
scaleY = tempScaleData.scaleY;
|
|
10867
10988
|
}
|
|
10868
10989
|
if (align) {
|
|
10869
10990
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -10875,7 +10996,7 @@ function getPatternData(paint, box, image) {
|
|
|
10875
10996
|
if (offset)
|
|
10876
10997
|
x += offset.x, y += offset.y;
|
|
10877
10998
|
switch (mode) {
|
|
10878
|
-
case '
|
|
10999
|
+
case 'stretch':
|
|
10879
11000
|
if (!sameBox)
|
|
10880
11001
|
width = box.width, height = box.height;
|
|
10881
11002
|
break;
|
|
@@ -10902,7 +11023,7 @@ function getPatternData(paint, box, image) {
|
|
|
10902
11023
|
translate(data.transform, box.x, box.y);
|
|
10903
11024
|
}
|
|
10904
11025
|
}
|
|
10905
|
-
if (scaleX && mode !== '
|
|
11026
|
+
if (scaleX && mode !== 'stretch') {
|
|
10906
11027
|
data.scaleX = scaleX;
|
|
10907
11028
|
data.scaleY = scaleY;
|
|
10908
11029
|
}
|
|
@@ -11006,7 +11127,7 @@ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
|
11006
11127
|
const { ceil, abs: abs$1 } = Math;
|
|
11007
11128
|
function createPattern(ui, paint, pixelRatio) {
|
|
11008
11129
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11009
|
-
const id = scaleX + '-' + scaleY;
|
|
11130
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
11010
11131
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11011
11132
|
scaleX = abs$1(scaleX);
|
|
11012
11133
|
scaleY = abs$1(scaleY);
|
|
@@ -11068,7 +11189,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
11068
11189
|
const { abs } = Math;
|
|
11069
11190
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
11070
11191
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11071
|
-
|
|
11192
|
+
const { pixelRatio } = canvas;
|
|
11193
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
11072
11194
|
return false;
|
|
11073
11195
|
}
|
|
11074
11196
|
else {
|
|
@@ -11076,8 +11198,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11076
11198
|
if (allowPaint) {
|
|
11077
11199
|
if (!data.repeat) {
|
|
11078
11200
|
let { width, height } = data;
|
|
11079
|
-
width *= abs(scaleX) *
|
|
11080
|
-
height *= abs(scaleY) *
|
|
11201
|
+
width *= abs(scaleX) * pixelRatio;
|
|
11202
|
+
height *= abs(scaleY) * pixelRatio;
|
|
11081
11203
|
if (data.scaleX) {
|
|
11082
11204
|
width *= data.scaleX;
|
|
11083
11205
|
height *= data.scaleY;
|
|
@@ -11102,15 +11224,15 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11102
11224
|
return true;
|
|
11103
11225
|
}
|
|
11104
11226
|
else {
|
|
11105
|
-
if (!paint.style || Export.running) {
|
|
11106
|
-
createPattern(ui, paint,
|
|
11227
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
11228
|
+
createPattern(ui, paint, pixelRatio);
|
|
11107
11229
|
}
|
|
11108
11230
|
else {
|
|
11109
11231
|
if (!paint.patternTask) {
|
|
11110
11232
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
11111
11233
|
paint.patternTask = null;
|
|
11112
11234
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
11113
|
-
createPattern(ui, paint,
|
|
11235
|
+
createPattern(ui, paint, pixelRatio);
|
|
11114
11236
|
ui.forceUpdate('surface');
|
|
11115
11237
|
}), 300);
|
|
11116
11238
|
}
|
|
@@ -11174,14 +11296,16 @@ function linearGradient(paint, box) {
|
|
|
11174
11296
|
return data;
|
|
11175
11297
|
}
|
|
11176
11298
|
function applyStops(gradient, stops, opacity) {
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11299
|
+
if (stops) {
|
|
11300
|
+
let stop;
|
|
11301
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
11302
|
+
stop = stops[i];
|
|
11303
|
+
if (typeof stop === 'string') {
|
|
11304
|
+
gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
|
|
11305
|
+
}
|
|
11306
|
+
else {
|
|
11307
|
+
gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
|
|
11308
|
+
}
|
|
11185
11309
|
}
|
|
11186
11310
|
}
|
|
11187
11311
|
}
|
|
@@ -11937,10 +12061,15 @@ const TextConvertModule = {
|
|
|
11937
12061
|
};
|
|
11938
12062
|
|
|
11939
12063
|
function string(color, opacity) {
|
|
11940
|
-
|
|
11941
|
-
|
|
12064
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
12065
|
+
if (typeof color === 'string') {
|
|
12066
|
+
if (doOpacity && ColorConvert.object)
|
|
12067
|
+
color = ColorConvert.object(color);
|
|
12068
|
+
else
|
|
12069
|
+
return color;
|
|
12070
|
+
}
|
|
11942
12071
|
let a = color.a === undefined ? 1 : color.a;
|
|
11943
|
-
if (
|
|
12072
|
+
if (doOpacity)
|
|
11944
12073
|
a *= opacity;
|
|
11945
12074
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
11946
12075
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
|
@@ -11972,6 +12101,7 @@ const ExportModule = {
|
|
|
11972
12101
|
export(leaf, filename, options) {
|
|
11973
12102
|
this.running = true;
|
|
11974
12103
|
const fileType = FileHelper.fileType(filename);
|
|
12104
|
+
const isDownload = filename.includes('.');
|
|
11975
12105
|
options = FileHelper.getExportOptions(options);
|
|
11976
12106
|
return addTask((success) => new Promise((resolve) => {
|
|
11977
12107
|
const over = (result) => {
|
|
@@ -11981,19 +12111,13 @@ const ExportModule = {
|
|
|
11981
12111
|
};
|
|
11982
12112
|
const { toURL } = Platform;
|
|
11983
12113
|
const { download } = Platform.origin;
|
|
11984
|
-
if (
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
else if (fileType === 'json') {
|
|
11988
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11989
|
-
return over({ data: true });
|
|
12114
|
+
if (fileType === 'json') {
|
|
12115
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12116
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11990
12117
|
}
|
|
11991
|
-
if (
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
else if (fileType === 'svg') {
|
|
11995
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11996
|
-
return over({ data: true });
|
|
12118
|
+
if (fileType === 'svg') {
|
|
12119
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
12120
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11997
12121
|
}
|
|
11998
12122
|
const { leafer } = leaf;
|
|
11999
12123
|
if (leafer) {
|
|
@@ -12002,14 +12126,8 @@ const ExportModule = {
|
|
|
12002
12126
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
12003
12127
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
12004
12128
|
const { slice, trim, onCanvas } = options;
|
|
12005
|
-
let scale = options.scale || 1;
|
|
12006
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
12007
12129
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
12008
12130
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
12009
|
-
if (leaf.isApp) {
|
|
12010
|
-
scale *= pixelRatio;
|
|
12011
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
12012
|
-
}
|
|
12013
12131
|
const screenshot = options.screenshot || leaf.isApp;
|
|
12014
12132
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
12015
12133
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -12043,9 +12161,17 @@ const ExportModule = {
|
|
|
12043
12161
|
}
|
|
12044
12162
|
renderBounds = leaf.getBounds('render', relative);
|
|
12045
12163
|
}
|
|
12046
|
-
const {
|
|
12164
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
12165
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
12166
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
12167
|
+
if (leaf.isApp) {
|
|
12168
|
+
scaleData.scaleX *= pixelRatio;
|
|
12169
|
+
scaleData.scaleY *= pixelRatio;
|
|
12170
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
12171
|
+
}
|
|
12172
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
12173
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
12047
12174
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
12048
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
12049
12175
|
let sliceLeaf;
|
|
12050
12176
|
if (slice) {
|
|
12051
12177
|
sliceLeaf = leaf;
|
|
@@ -12153,8 +12279,12 @@ Object.assign(Creator, {
|
|
|
12153
12279
|
hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
12154
12280
|
hitCanvasManager: () => new HitCanvasManager()
|
|
12155
12281
|
});
|
|
12282
|
+
Leafer.prototype.receiveEvent = function (event) {
|
|
12283
|
+
this.interaction && this.interaction.receive(event);
|
|
12284
|
+
};
|
|
12156
12285
|
try {
|
|
12157
|
-
|
|
12286
|
+
if (wx)
|
|
12287
|
+
useCanvas('miniapp', wx);
|
|
12158
12288
|
}
|
|
12159
12289
|
catch (_a) { }
|
|
12160
12290
|
|
|
@@ -12182,4 +12312,4 @@ if (platform === 'ios') {
|
|
|
12182
12312
|
};
|
|
12183
12313
|
}
|
|
12184
12314
|
|
|
12185
|
-
export { AlignHelper,
|
|
12315
|
+
export { AlignHelper, 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, Eventer, 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, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|