@leafer-ui/miniapp 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +2941 -0
- package/dist/miniapp.esm.js +144 -140
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -0
- package/dist/miniapp.module.js +282 -201
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +18 -10
- package/src/index.ts +6 -1
package/dist/miniapp.module.js
CHANGED
|
@@ -111,6 +111,19 @@ 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
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
124
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
125
|
+
}
|
|
126
|
+
return scaleData;
|
|
114
127
|
}
|
|
115
128
|
};
|
|
116
129
|
const OneRadian = PI$4 / 180;
|
|
@@ -409,7 +422,7 @@ const MatrixHelper = {
|
|
|
409
422
|
};
|
|
410
423
|
const M$6 = MatrixHelper;
|
|
411
424
|
|
|
412
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
425
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
413
426
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
414
427
|
const PointHelper = {
|
|
415
428
|
defaultPoint: getPointData(),
|
|
@@ -465,7 +478,7 @@ const PointHelper = {
|
|
|
465
478
|
tempToOuterOf(t, matrix) {
|
|
466
479
|
const { tempPoint: temp } = P$5;
|
|
467
480
|
copy$b(temp, t);
|
|
468
|
-
toOuterPoint$
|
|
481
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
469
482
|
return temp;
|
|
470
483
|
},
|
|
471
484
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -484,7 +497,7 @@ const PointHelper = {
|
|
|
484
497
|
toInnerPoint$2(matrix, t, to);
|
|
485
498
|
},
|
|
486
499
|
toOuterOf(t, matrix, to) {
|
|
487
|
-
toOuterPoint$
|
|
500
|
+
toOuterPoint$3(matrix, t, to);
|
|
488
501
|
},
|
|
489
502
|
getCenter(t, to) {
|
|
490
503
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -764,7 +777,7 @@ const TwoPointBoundsHelper = {
|
|
|
764
777
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
765
778
|
|
|
766
779
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
767
|
-
const { toOuterPoint: toOuterPoint$
|
|
780
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
768
781
|
const { float, fourNumber } = MathHelper;
|
|
769
782
|
const { floor, ceil: ceil$2 } = Math;
|
|
770
783
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -784,17 +797,24 @@ const BoundsHelper = {
|
|
|
784
797
|
t.width = bounds.width;
|
|
785
798
|
t.height = bounds.height;
|
|
786
799
|
},
|
|
787
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
800
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
801
|
+
const { x, y, width, height } = bounds;
|
|
788
802
|
if (spread instanceof Array) {
|
|
789
803
|
const four = fourNumber(spread);
|
|
790
804
|
isShrink
|
|
791
|
-
? B.set(t,
|
|
792
|
-
: B.set(t,
|
|
805
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
806
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
793
807
|
}
|
|
794
808
|
else {
|
|
795
809
|
if (isShrink)
|
|
796
810
|
spread = -spread;
|
|
797
|
-
B.set(t,
|
|
811
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
812
|
+
}
|
|
813
|
+
if (side) {
|
|
814
|
+
if (side === 'width')
|
|
815
|
+
t.y = y, t.height = height;
|
|
816
|
+
else
|
|
817
|
+
t.x = x, t.width = width;
|
|
798
818
|
}
|
|
799
819
|
},
|
|
800
820
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -871,16 +891,16 @@ const BoundsHelper = {
|
|
|
871
891
|
else {
|
|
872
892
|
point.x = t.x;
|
|
873
893
|
point.y = t.y;
|
|
874
|
-
toOuterPoint$
|
|
894
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
875
895
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
876
896
|
point.x = t.x + t.width;
|
|
877
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
878
898
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
879
899
|
point.y = t.y + t.height;
|
|
880
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
881
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
882
902
|
point.x = t.x;
|
|
883
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
884
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
885
905
|
toBounds$4(tempPointBounds$1, to);
|
|
886
906
|
}
|
|
@@ -894,16 +914,16 @@ const BoundsHelper = {
|
|
|
894
914
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
895
915
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
896
916
|
},
|
|
897
|
-
getSpread(t, spread) {
|
|
917
|
+
getSpread(t, spread, side) {
|
|
898
918
|
const n = {};
|
|
899
|
-
B.copyAndSpread(n, t, spread);
|
|
919
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
900
920
|
return n;
|
|
901
921
|
},
|
|
902
|
-
spread(t, spread) {
|
|
903
|
-
B.copyAndSpread(t, t, spread);
|
|
922
|
+
spread(t, spread, side) {
|
|
923
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
904
924
|
},
|
|
905
|
-
shrink(t, shrink) {
|
|
906
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
925
|
+
shrink(t, shrink, side) {
|
|
926
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
907
927
|
},
|
|
908
928
|
ceil(t) {
|
|
909
929
|
const { x, y } = t;
|
|
@@ -1086,12 +1106,12 @@ class Bounds {
|
|
|
1086
1106
|
getFitMatrix(put, baseScale) {
|
|
1087
1107
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1088
1108
|
}
|
|
1089
|
-
spread(fourNumber) {
|
|
1090
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1109
|
+
spread(fourNumber, side) {
|
|
1110
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1091
1111
|
return this;
|
|
1092
1112
|
}
|
|
1093
|
-
shrink(fourNumber) {
|
|
1094
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1113
|
+
shrink(fourNumber, side) {
|
|
1114
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1095
1115
|
return this;
|
|
1096
1116
|
}
|
|
1097
1117
|
ceil() {
|
|
@@ -2908,60 +2928,75 @@ class PathCreator {
|
|
|
2908
2928
|
}
|
|
2909
2929
|
beginPath() {
|
|
2910
2930
|
beginPath(this.__path);
|
|
2931
|
+
this.paint();
|
|
2911
2932
|
return this;
|
|
2912
2933
|
}
|
|
2913
2934
|
moveTo(x, y) {
|
|
2914
2935
|
moveTo$4(this.__path, x, y);
|
|
2936
|
+
this.paint();
|
|
2915
2937
|
return this;
|
|
2916
2938
|
}
|
|
2917
2939
|
lineTo(x, y) {
|
|
2918
2940
|
lineTo$3(this.__path, x, y);
|
|
2941
|
+
this.paint();
|
|
2919
2942
|
return this;
|
|
2920
2943
|
}
|
|
2921
2944
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2922
2945
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2946
|
+
this.paint();
|
|
2923
2947
|
return this;
|
|
2924
2948
|
}
|
|
2925
2949
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2926
2950
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2951
|
+
this.paint();
|
|
2927
2952
|
return this;
|
|
2928
2953
|
}
|
|
2929
2954
|
closePath() {
|
|
2930
2955
|
closePath$3(this.__path);
|
|
2956
|
+
this.paint();
|
|
2931
2957
|
return this;
|
|
2932
2958
|
}
|
|
2933
2959
|
rect(x, y, width, height) {
|
|
2934
2960
|
rect$2(this.__path, x, y, width, height);
|
|
2961
|
+
this.paint();
|
|
2935
2962
|
return this;
|
|
2936
2963
|
}
|
|
2937
2964
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2938
2965
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2966
|
+
this.paint();
|
|
2939
2967
|
return this;
|
|
2940
2968
|
}
|
|
2941
2969
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2942
2970
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2971
|
+
this.paint();
|
|
2943
2972
|
return this;
|
|
2944
2973
|
}
|
|
2945
2974
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2946
2975
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2976
|
+
this.paint();
|
|
2947
2977
|
return this;
|
|
2948
2978
|
}
|
|
2949
2979
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2950
2980
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2981
|
+
this.paint();
|
|
2951
2982
|
return this;
|
|
2952
2983
|
}
|
|
2953
2984
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2954
2985
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2986
|
+
this.paint();
|
|
2955
2987
|
return this;
|
|
2956
2988
|
}
|
|
2957
2989
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2958
2990
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2991
|
+
this.paint();
|
|
2959
2992
|
return this;
|
|
2960
2993
|
}
|
|
2961
2994
|
drawPoints(points, curve, close) {
|
|
2962
2995
|
drawPoints$2(this.__path, points, curve, close);
|
|
2996
|
+
this.paint();
|
|
2963
2997
|
return this;
|
|
2964
2998
|
}
|
|
2999
|
+
paint() { }
|
|
2965
3000
|
}
|
|
2966
3001
|
|
|
2967
3002
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3983,7 +4018,7 @@ function registerUIEvent() {
|
|
|
3983
4018
|
};
|
|
3984
4019
|
}
|
|
3985
4020
|
|
|
3986
|
-
const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4021
|
+
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3987
4022
|
const matrix$1 = {};
|
|
3988
4023
|
const LeafHelper = {
|
|
3989
4024
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4048,10 +4083,9 @@ const LeafHelper = {
|
|
|
4048
4083
|
}
|
|
4049
4084
|
return true;
|
|
4050
4085
|
},
|
|
4051
|
-
moveWorld(t, x, y = 0) {
|
|
4086
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4052
4087
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4053
|
-
|
|
4054
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4088
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4055
4089
|
L.moveLocal(t, local.x, local.y);
|
|
4056
4090
|
},
|
|
4057
4091
|
moveLocal(t, x, y = 0) {
|
|
@@ -4918,7 +4952,7 @@ const LeafMatrix = {
|
|
|
4918
4952
|
|
|
4919
4953
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4920
4954
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4921
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4955
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$5 } = BoundsHelper;
|
|
4922
4956
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4923
4957
|
const LeafBounds = {
|
|
4924
4958
|
__updateWorldBounds() {
|
|
@@ -5019,7 +5053,7 @@ const LeafBounds = {
|
|
|
5019
5053
|
updateAllMatrix$2(this);
|
|
5020
5054
|
updateBounds$1(this, this);
|
|
5021
5055
|
if (this.__.__autoSide)
|
|
5022
|
-
this.__updateBoxBounds();
|
|
5056
|
+
this.__updateBoxBounds(true);
|
|
5023
5057
|
}
|
|
5024
5058
|
else {
|
|
5025
5059
|
updateAllMatrix$2(this);
|
|
@@ -5037,11 +5071,11 @@ const LeafBounds = {
|
|
|
5037
5071
|
},
|
|
5038
5072
|
__updateStrokeBounds() {
|
|
5039
5073
|
const layout = this.__layout;
|
|
5040
|
-
copyAndSpread$
|
|
5074
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5041
5075
|
},
|
|
5042
5076
|
__updateRenderBounds() {
|
|
5043
5077
|
const layout = this.__layout;
|
|
5044
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5078
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5045
5079
|
}
|
|
5046
5080
|
};
|
|
5047
5081
|
|
|
@@ -5401,6 +5435,9 @@ let Leaf = class Leaf {
|
|
|
5401
5435
|
move(x, y) {
|
|
5402
5436
|
moveLocal(this, x, y);
|
|
5403
5437
|
}
|
|
5438
|
+
moveInner(x, y) {
|
|
5439
|
+
moveWorld(this, x, y, true);
|
|
5440
|
+
}
|
|
5404
5441
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5405
5442
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5406
5443
|
}
|
|
@@ -5827,6 +5864,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5827
5864
|
const size = { width: width || view.width, height: height || view.height, pixelRatio };
|
|
5828
5865
|
this.resize(size);
|
|
5829
5866
|
if (this.context) {
|
|
5867
|
+
if (this.viewSelect)
|
|
5868
|
+
Platform.renderCanvas = this;
|
|
5830
5869
|
if (this.context.roundRect) {
|
|
5831
5870
|
this.roundRect = function (x, y, width, height, radius) {
|
|
5832
5871
|
this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius);
|
|
@@ -5894,119 +5933,120 @@ Object.assign(Creator, {
|
|
|
5894
5933
|
image: (options) => new LeaferImage(options)
|
|
5895
5934
|
});
|
|
5896
5935
|
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 {
|
|
5936
|
+
Platform.origin = {
|
|
5937
|
+
createCanvas: (width, height, _format) => app.createOffscreenCanvas({ type: '2d', width, height }),
|
|
5938
|
+
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
5939
|
+
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
5940
|
+
canvasSaveAs: (canvas, filePath, quality) => {
|
|
5941
|
+
let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
|
|
5942
|
+
data = data.substring(data.indexOf('64,') + 3);
|
|
5943
|
+
return Platform.origin.download(data, filePath);
|
|
5944
|
+
},
|
|
5945
|
+
download(data, filePath) {
|
|
5946
|
+
return new Promise((resolve, reject) => {
|
|
5947
|
+
let toAlbum;
|
|
5948
|
+
if (!filePath.includes('/')) {
|
|
5949
|
+
filePath = `${app.env.USER_DATA_PATH}/` + filePath;
|
|
5950
|
+
toAlbum = true;
|
|
5951
|
+
}
|
|
5952
|
+
const fs = app.getFileSystemManager();
|
|
5953
|
+
fs.writeFile({
|
|
5954
|
+
filePath,
|
|
5955
|
+
data,
|
|
5956
|
+
encoding: 'base64',
|
|
5957
|
+
success() {
|
|
5958
|
+
if (toAlbum) {
|
|
5959
|
+
Platform.miniapp.saveToAlbum(filePath).then(() => {
|
|
5960
|
+
fs.unlink({ filePath });
|
|
5927
5961
|
resolve();
|
|
5928
|
-
}
|
|
5929
|
-
},
|
|
5930
|
-
fail(error) {
|
|
5931
|
-
reject(error);
|
|
5962
|
+
});
|
|
5932
5963
|
}
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
img.onerror = (error) => { reject(error); };
|
|
5941
|
-
img.src = Platform.image.getRealURL(src);
|
|
5964
|
+
else {
|
|
5965
|
+
resolve();
|
|
5966
|
+
}
|
|
5967
|
+
},
|
|
5968
|
+
fail(error) {
|
|
5969
|
+
reject(error);
|
|
5970
|
+
}
|
|
5942
5971
|
});
|
|
5943
|
-
}
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5972
|
+
});
|
|
5973
|
+
},
|
|
5974
|
+
loadImage(src) {
|
|
5975
|
+
return new Promise((resolve, reject) => {
|
|
5976
|
+
const img = Platform.canvas.view.createImage();
|
|
5977
|
+
img.onload = () => { resolve(img); };
|
|
5978
|
+
img.onerror = (error) => { reject(error); };
|
|
5979
|
+
img.src = Platform.image.getRealURL(src);
|
|
5980
|
+
});
|
|
5981
|
+
},
|
|
5982
|
+
noRepeat: 'repeat-x'
|
|
5983
|
+
};
|
|
5984
|
+
Platform.miniapp = {
|
|
5985
|
+
select(name) {
|
|
5986
|
+
return app.createSelectorQuery().select(name);
|
|
5987
|
+
},
|
|
5988
|
+
getBounds(select) {
|
|
5989
|
+
return new Promise((resolve) => {
|
|
5990
|
+
select.boundingClientRect().exec((res) => {
|
|
5991
|
+
const rect = res[1];
|
|
5992
|
+
resolve({ x: rect.top, y: rect.left, width: rect.width, height: rect.height });
|
|
5956
5993
|
});
|
|
5957
|
-
}
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
});
|
|
5994
|
+
});
|
|
5995
|
+
},
|
|
5996
|
+
getSizeView(select) {
|
|
5997
|
+
return new Promise((resolve) => {
|
|
5998
|
+
select.fields({ node: true, size: true }).exec((res) => {
|
|
5999
|
+
const data = res[0];
|
|
6000
|
+
resolve({ view: data.node, width: data.width, height: data.height });
|
|
5964
6001
|
});
|
|
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
|
-
}
|
|
6002
|
+
});
|
|
6003
|
+
},
|
|
6004
|
+
saveToAlbum(path) {
|
|
6005
|
+
return new Promise((resolve) => {
|
|
6006
|
+
app.getSetting({
|
|
6007
|
+
success: (res) => {
|
|
6008
|
+
if (res.authSetting['scope.writePhotosAlbum']) {
|
|
6009
|
+
app.saveImageToPhotosAlbum({
|
|
6010
|
+
filePath: path,
|
|
6011
|
+
success() { resolve(true); }
|
|
6012
|
+
});
|
|
5988
6013
|
}
|
|
5989
|
-
|
|
6014
|
+
else {
|
|
6015
|
+
app.authorize({
|
|
6016
|
+
scope: 'scope.writePhotosAlbum',
|
|
6017
|
+
success: () => {
|
|
6018
|
+
app.saveImageToPhotosAlbum({
|
|
6019
|
+
filePath: path,
|
|
6020
|
+
success() { resolve(true); }
|
|
6021
|
+
});
|
|
6022
|
+
},
|
|
6023
|
+
fail: () => { }
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
5990
6027
|
});
|
|
5991
|
-
}
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
}
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6028
|
+
});
|
|
6029
|
+
},
|
|
6030
|
+
onWindowResize(fun) {
|
|
6031
|
+
app.onWindowResize(fun);
|
|
6032
|
+
},
|
|
6033
|
+
offWindowResize(fun) {
|
|
6034
|
+
app.offWindowResize(fun);
|
|
6035
|
+
}
|
|
6036
|
+
};
|
|
6037
|
+
Platform.event = {
|
|
6038
|
+
stopDefault(_origin) { },
|
|
6039
|
+
stopNow(_origin) { },
|
|
6040
|
+
stop(_origin) { }
|
|
6041
|
+
};
|
|
6042
|
+
Platform.canvas = Creator.canvas();
|
|
6043
|
+
Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
|
|
6007
6044
|
}
|
|
6008
6045
|
Platform.name = 'miniapp';
|
|
6009
|
-
Platform.requestRender = function (render) {
|
|
6046
|
+
Platform.requestRender = function (render) {
|
|
6047
|
+
const { view } = (Platform.renderCanvas || Platform.canvas);
|
|
6048
|
+
view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
|
|
6049
|
+
};
|
|
6010
6050
|
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
|
|
6011
6051
|
|
|
6012
6052
|
class Watcher {
|
|
@@ -7072,6 +7112,11 @@ class BoxData extends GroupData {
|
|
|
7072
7112
|
}
|
|
7073
7113
|
|
|
7074
7114
|
class LeaferData extends GroupData {
|
|
7115
|
+
__getInputData() {
|
|
7116
|
+
const data = super.__getInputData();
|
|
7117
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
7118
|
+
return data;
|
|
7119
|
+
}
|
|
7075
7120
|
}
|
|
7076
7121
|
|
|
7077
7122
|
class FrameData extends BoxData {
|
|
@@ -7149,6 +7194,11 @@ class ImageData extends RectData {
|
|
|
7149
7194
|
}
|
|
7150
7195
|
|
|
7151
7196
|
class CanvasData extends RectData {
|
|
7197
|
+
__getInputData() {
|
|
7198
|
+
const data = super.__getInputData();
|
|
7199
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7200
|
+
return data;
|
|
7201
|
+
}
|
|
7152
7202
|
}
|
|
7153
7203
|
|
|
7154
7204
|
const UIBounds = {
|
|
@@ -8061,6 +8111,13 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8061
8111
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
8062
8112
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
8063
8113
|
}
|
|
8114
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
8115
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8116
|
+
}
|
|
8117
|
+
updateClientBounds() {
|
|
8118
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
8119
|
+
}
|
|
8120
|
+
receiveEvent(_event) { }
|
|
8064
8121
|
__checkUpdateLayout() {
|
|
8065
8122
|
this.__layout.update();
|
|
8066
8123
|
}
|
|
@@ -8144,7 +8201,7 @@ Rect = __decorate([
|
|
|
8144
8201
|
const rect$1 = Rect.prototype;
|
|
8145
8202
|
const group$1 = Group.prototype;
|
|
8146
8203
|
const childrenRenderBounds = {};
|
|
8147
|
-
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8204
|
+
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8148
8205
|
let Box = class Box extends Group {
|
|
8149
8206
|
get __tag() { return 'Box'; }
|
|
8150
8207
|
get isBranchLeaf() { return true; }
|
|
@@ -8158,20 +8215,23 @@ let Box = class Box extends Group {
|
|
|
8158
8215
|
return this.__updateRectRenderSpread() || -1;
|
|
8159
8216
|
}
|
|
8160
8217
|
__updateRectBoxBounds() { }
|
|
8161
|
-
__updateBoxBounds() {
|
|
8218
|
+
__updateBoxBounds(secondLayout) {
|
|
8162
8219
|
const data = this.__;
|
|
8163
8220
|
if (this.children.length) {
|
|
8164
8221
|
if (data.__autoSide) {
|
|
8165
8222
|
if (this.leafer && this.leafer.ready)
|
|
8166
8223
|
this.leafer.layouter.addExtra(this);
|
|
8167
8224
|
super.__updateBoxBounds();
|
|
8225
|
+
const { boxBounds } = this.__layout;
|
|
8168
8226
|
if (!data.__autoSize) {
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8227
|
+
if (data.__autoWidth)
|
|
8228
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8229
|
+
else
|
|
8230
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8174
8231
|
}
|
|
8232
|
+
if (secondLayout && data.flow && data.padding)
|
|
8233
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8234
|
+
this.__updateNaturalSize();
|
|
8175
8235
|
}
|
|
8176
8236
|
else {
|
|
8177
8237
|
this.__updateRectBoxBounds();
|
|
@@ -8191,13 +8251,13 @@ let Box = class Box extends Group {
|
|
|
8191
8251
|
super.__updateRenderBounds();
|
|
8192
8252
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8193
8253
|
this.__updateRectRenderBounds();
|
|
8194
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8254
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8195
8255
|
}
|
|
8196
8256
|
else {
|
|
8197
8257
|
this.__updateRectRenderBounds();
|
|
8198
8258
|
}
|
|
8199
8259
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8200
|
-
if (
|
|
8260
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8201
8261
|
add(renderBounds, childrenRenderBounds);
|
|
8202
8262
|
}
|
|
8203
8263
|
__updateRectRenderBounds() { }
|
|
@@ -8531,14 +8591,26 @@ __decorate([
|
|
|
8531
8591
|
Image = __decorate([
|
|
8532
8592
|
registerUI()
|
|
8533
8593
|
], Image);
|
|
8594
|
+
const MyImage = Image;
|
|
8534
8595
|
|
|
8535
8596
|
let Canvas = class Canvas extends Rect {
|
|
8536
8597
|
get __tag() { return 'Canvas'; }
|
|
8598
|
+
get ready() { return !this.url; }
|
|
8537
8599
|
constructor(data) {
|
|
8538
8600
|
super(data);
|
|
8539
8601
|
this.canvas = Creator.canvas(this.__);
|
|
8540
8602
|
this.context = this.canvas.context;
|
|
8541
8603
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8604
|
+
if (data && data.url)
|
|
8605
|
+
this.drawImage(data.url);
|
|
8606
|
+
}
|
|
8607
|
+
drawImage(url) {
|
|
8608
|
+
new LeaferImage({ url }).load((image) => {
|
|
8609
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8610
|
+
this.url = undefined;
|
|
8611
|
+
this.paint();
|
|
8612
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8613
|
+
});
|
|
8542
8614
|
}
|
|
8543
8615
|
draw(ui, offset, scale, rotation) {
|
|
8544
8616
|
ui.__layout.update();
|
|
@@ -8597,7 +8669,7 @@ __decorate([
|
|
|
8597
8669
|
resizeType(100)
|
|
8598
8670
|
], Canvas.prototype, "height", void 0);
|
|
8599
8671
|
__decorate([
|
|
8600
|
-
resizeType(
|
|
8672
|
+
resizeType(1)
|
|
8601
8673
|
], Canvas.prototype, "pixelRatio", void 0);
|
|
8602
8674
|
__decorate([
|
|
8603
8675
|
resizeType(true)
|
|
@@ -8621,13 +8693,13 @@ let Text = class Text extends UI {
|
|
|
8621
8693
|
super(data);
|
|
8622
8694
|
}
|
|
8623
8695
|
__drawHitPath(canvas) {
|
|
8624
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8696
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8625
8697
|
canvas.beginPath();
|
|
8626
8698
|
if (this.__.__letterSpacing < 0) {
|
|
8627
8699
|
this.__drawPathByData(canvas);
|
|
8628
8700
|
}
|
|
8629
8701
|
else {
|
|
8630
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8702
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8631
8703
|
}
|
|
8632
8704
|
}
|
|
8633
8705
|
__drawPathByData(drawer, _data) {
|
|
@@ -8820,7 +8892,8 @@ let Pen = class Pen extends Group {
|
|
|
8820
8892
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8821
8893
|
clearPath() { return this; }
|
|
8822
8894
|
paint() {
|
|
8823
|
-
this.pathElement.
|
|
8895
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8896
|
+
this.pathElement.forceUpdate('path');
|
|
8824
8897
|
}
|
|
8825
8898
|
};
|
|
8826
8899
|
__decorate([
|
|
@@ -8830,7 +8903,7 @@ __decorate([
|
|
|
8830
8903
|
penPathType()
|
|
8831
8904
|
], Pen.prototype, "path", void 0);
|
|
8832
8905
|
Pen = __decorate([
|
|
8833
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8906
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8834
8907
|
registerUI()
|
|
8835
8908
|
], Pen);
|
|
8836
8909
|
function penPathType() {
|
|
@@ -9053,6 +9126,7 @@ PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
|
9053
9126
|
PointerEvent = __decorate([
|
|
9054
9127
|
registerUIEvent()
|
|
9055
9128
|
], PointerEvent);
|
|
9129
|
+
const MyPointerEvent = PointerEvent;
|
|
9056
9130
|
|
|
9057
9131
|
const move = {};
|
|
9058
9132
|
let DragEvent = class DragEvent extends PointerEvent {
|
|
@@ -9152,6 +9226,7 @@ DragEvent.LEAVE = 'drag.leave';
|
|
|
9152
9226
|
DragEvent = __decorate([
|
|
9153
9227
|
registerUIEvent()
|
|
9154
9228
|
], DragEvent);
|
|
9229
|
+
const MyDragEvent = DragEvent;
|
|
9155
9230
|
|
|
9156
9231
|
let DropEvent = class DropEvent extends PointerEvent {
|
|
9157
9232
|
static setList(data) {
|
|
@@ -9233,36 +9308,32 @@ function addInteractionWindow(leafer) {
|
|
|
9233
9308
|
|
|
9234
9309
|
function document(leafer) {
|
|
9235
9310
|
addInteractionWindow(leafer);
|
|
9236
|
-
|
|
9237
|
-
|
|
9311
|
+
const { move, zoom } = leafer.config;
|
|
9312
|
+
move.scroll = 'limit';
|
|
9313
|
+
zoom.min = 1;
|
|
9314
|
+
}
|
|
9315
|
+
|
|
9316
|
+
function block(leafer) {
|
|
9317
|
+
const { config } = leafer;
|
|
9318
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9319
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9238
9320
|
}
|
|
9239
9321
|
|
|
9240
9322
|
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9241
9323
|
const LeaferTypeCreator = {
|
|
9242
9324
|
list: {},
|
|
9243
9325
|
register(name, fn) {
|
|
9244
|
-
|
|
9245
|
-
debug$2.repeat(name);
|
|
9246
|
-
}
|
|
9247
|
-
else {
|
|
9248
|
-
list[name] = fn;
|
|
9249
|
-
}
|
|
9326
|
+
list[name] ? debug$2.repeat(name) : list[name] = fn;
|
|
9250
9327
|
},
|
|
9251
9328
|
run(name, leafer) {
|
|
9252
9329
|
const fn = list[name];
|
|
9253
|
-
|
|
9254
|
-
fn(leafer);
|
|
9255
|
-
}
|
|
9256
|
-
else {
|
|
9257
|
-
debug$2.error('no', name);
|
|
9258
|
-
}
|
|
9330
|
+
fn && fn(leafer);
|
|
9259
9331
|
}
|
|
9260
9332
|
};
|
|
9261
9333
|
const { list, register } = LeaferTypeCreator;
|
|
9262
|
-
register('draw', () => { });
|
|
9263
|
-
register('custom', () => { });
|
|
9264
9334
|
register('design', addInteractionWindow);
|
|
9265
9335
|
register('document', document);
|
|
9336
|
+
register('block', block);
|
|
9266
9337
|
|
|
9267
9338
|
const leafer = Leafer.prototype;
|
|
9268
9339
|
leafer.initType = function (type) {
|
|
@@ -9451,7 +9522,13 @@ const InteractionHelper = {
|
|
|
9451
9522
|
find.add(list[i]);
|
|
9452
9523
|
}
|
|
9453
9524
|
return find;
|
|
9454
|
-
}
|
|
9525
|
+
},
|
|
9526
|
+
pathCanDrag(path) {
|
|
9527
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(DragEvent.DRAG)));
|
|
9528
|
+
},
|
|
9529
|
+
pathHasOutside(path) {
|
|
9530
|
+
return path && path.list.some(item => item.isOutside);
|
|
9531
|
+
},
|
|
9455
9532
|
};
|
|
9456
9533
|
const I = InteractionHelper;
|
|
9457
9534
|
|
|
@@ -9761,15 +9838,18 @@ const config = {
|
|
|
9761
9838
|
swipeDistance: 20,
|
|
9762
9839
|
preventDefaultMenu: true
|
|
9763
9840
|
},
|
|
9841
|
+
touch: {
|
|
9842
|
+
preventDefault: true
|
|
9843
|
+
},
|
|
9764
9844
|
cursor: true,
|
|
9765
9845
|
keyEvent: true
|
|
9766
9846
|
};
|
|
9767
9847
|
|
|
9768
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
9848
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9769
9849
|
class InteractionBase {
|
|
9770
9850
|
get dragging() { return this.dragger.dragging; }
|
|
9771
9851
|
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; }
|
|
9852
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9773
9853
|
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9774
9854
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9775
9855
|
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
@@ -9778,7 +9858,7 @@ class InteractionBase {
|
|
|
9778
9858
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9779
9859
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9780
9860
|
constructor(target, canvas, selector, userConfig) {
|
|
9781
|
-
this.config = config;
|
|
9861
|
+
this.config = DataHelper.clone(config);
|
|
9782
9862
|
this.tapCount = 0;
|
|
9783
9863
|
this.downKeyMap = {};
|
|
9784
9864
|
this.target = target;
|
|
@@ -10030,11 +10110,11 @@ class InteractionBase {
|
|
|
10030
10110
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
10031
10111
|
}
|
|
10032
10112
|
checkPath(data, useDefaultPath) {
|
|
10033
|
-
if (useDefaultPath || this.
|
|
10113
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
10034
10114
|
data.path = this.defaultPath;
|
|
10035
10115
|
}
|
|
10036
10116
|
canMove(data) {
|
|
10037
|
-
return this.moveMode
|
|
10117
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
10038
10118
|
}
|
|
10039
10119
|
isDrag(leaf) {
|
|
10040
10120
|
return this.dragger.getList().has(leaf);
|
|
@@ -10834,10 +10914,13 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
10834
10914
|
const { get: get$2, translate } = MatrixHelper;
|
|
10835
10915
|
const tempBox = new Bounds();
|
|
10836
10916
|
const tempPoint = {};
|
|
10917
|
+
const tempScaleData = {};
|
|
10837
10918
|
function createData(leafPaint, image, paint, box) {
|
|
10838
|
-
const { blendMode } = paint;
|
|
10919
|
+
const { blendMode, sync } = paint;
|
|
10839
10920
|
if (blendMode)
|
|
10840
10921
|
leafPaint.blendMode = blendMode;
|
|
10922
|
+
if (sync)
|
|
10923
|
+
leafPaint.sync = sync;
|
|
10841
10924
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10842
10925
|
}
|
|
10843
10926
|
function getPatternData(paint, box, image) {
|
|
@@ -10857,13 +10940,10 @@ function getPatternData(paint, box, image) {
|
|
|
10857
10940
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
10858
10941
|
}
|
|
10859
10942
|
}
|
|
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;
|
|
10943
|
+
else if (scale || size) {
|
|
10944
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10945
|
+
scaleX = tempScaleData.scaleX;
|
|
10946
|
+
scaleY = tempScaleData.scaleY;
|
|
10867
10947
|
}
|
|
10868
10948
|
if (align) {
|
|
10869
10949
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -11102,7 +11182,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11102
11182
|
return true;
|
|
11103
11183
|
}
|
|
11104
11184
|
else {
|
|
11105
|
-
if (!paint.style || Export.running) {
|
|
11185
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
11106
11186
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
11107
11187
|
}
|
|
11108
11188
|
else {
|
|
@@ -11972,6 +12052,7 @@ const ExportModule = {
|
|
|
11972
12052
|
export(leaf, filename, options) {
|
|
11973
12053
|
this.running = true;
|
|
11974
12054
|
const fileType = FileHelper.fileType(filename);
|
|
12055
|
+
const isDownload = filename.includes('.');
|
|
11975
12056
|
options = FileHelper.getExportOptions(options);
|
|
11976
12057
|
return addTask((success) => new Promise((resolve) => {
|
|
11977
12058
|
const over = (result) => {
|
|
@@ -11981,19 +12062,13 @@ const ExportModule = {
|
|
|
11981
12062
|
};
|
|
11982
12063
|
const { toURL } = Platform;
|
|
11983
12064
|
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 });
|
|
11990
|
-
}
|
|
11991
|
-
if (filename === 'svg') {
|
|
11992
|
-
return over({ data: leaf.toSVG() });
|
|
12065
|
+
if (fileType === 'json') {
|
|
12066
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12067
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11993
12068
|
}
|
|
11994
|
-
|
|
11995
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11996
|
-
return over({ data: true });
|
|
12069
|
+
if (fileType === 'svg') {
|
|
12070
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
12071
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11997
12072
|
}
|
|
11998
12073
|
const { leafer } = leaf;
|
|
11999
12074
|
if (leafer) {
|
|
@@ -12002,14 +12077,8 @@ const ExportModule = {
|
|
|
12002
12077
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
12003
12078
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
12004
12079
|
const { slice, trim, onCanvas } = options;
|
|
12005
|
-
let scale = options.scale || 1;
|
|
12006
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
12007
12080
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
12008
12081
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
12009
|
-
if (leaf.isApp) {
|
|
12010
|
-
scale *= pixelRatio;
|
|
12011
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
12012
|
-
}
|
|
12013
12082
|
const screenshot = options.screenshot || leaf.isApp;
|
|
12014
12083
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
12015
12084
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -12043,9 +12112,17 @@ const ExportModule = {
|
|
|
12043
12112
|
}
|
|
12044
12113
|
renderBounds = leaf.getBounds('render', relative);
|
|
12045
12114
|
}
|
|
12046
|
-
const {
|
|
12115
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
12116
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
12117
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
12118
|
+
if (leaf.isApp) {
|
|
12119
|
+
scaleData.scaleX *= pixelRatio;
|
|
12120
|
+
scaleData.scaleY *= pixelRatio;
|
|
12121
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
12122
|
+
}
|
|
12123
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
12124
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
12047
12125
|
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
12126
|
let sliceLeaf;
|
|
12050
12127
|
if (slice) {
|
|
12051
12128
|
sliceLeaf = leaf;
|
|
@@ -12153,8 +12230,12 @@ Object.assign(Creator, {
|
|
|
12153
12230
|
hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
12154
12231
|
hitCanvasManager: () => new HitCanvasManager()
|
|
12155
12232
|
});
|
|
12233
|
+
Leafer.prototype.receiveEvent = function (event) {
|
|
12234
|
+
this.interaction && this.interaction.receive(event);
|
|
12235
|
+
};
|
|
12156
12236
|
try {
|
|
12157
|
-
|
|
12237
|
+
if (wx)
|
|
12238
|
+
useCanvas('miniapp', wx);
|
|
12158
12239
|
}
|
|
12159
12240
|
catch (_a) { }
|
|
12160
12241
|
|
|
@@ -12182,4 +12263,4 @@ if (platform === 'ios') {
|
|
|
12182
12263
|
};
|
|
12183
12264
|
}
|
|
12184
12265
|
|
|
12185
|
-
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
12266
|
+
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|