@leafer-draw/worker 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +2389 -0
- package/dist/worker.esm.js +27 -30
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +141 -73
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +141 -74
- package/dist/worker.module.min.js +1 -1
- package/package.json +13 -7
package/dist/worker.js
CHANGED
|
@@ -114,6 +114,19 @@ var LeaferUI = (function (exports) {
|
|
|
114
114
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
|
+
},
|
|
118
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
119
|
+
if (!scaleData)
|
|
120
|
+
scaleData = {};
|
|
121
|
+
if (size) {
|
|
122
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
123
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
124
|
+
}
|
|
125
|
+
else if (scale) {
|
|
126
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
127
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
128
|
+
}
|
|
129
|
+
return scaleData;
|
|
117
130
|
}
|
|
118
131
|
};
|
|
119
132
|
const OneRadian = PI$4 / 180;
|
|
@@ -412,7 +425,7 @@ var LeaferUI = (function (exports) {
|
|
|
412
425
|
};
|
|
413
426
|
const M$6 = MatrixHelper;
|
|
414
427
|
|
|
415
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
428
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
416
429
|
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
417
430
|
const PointHelper = {
|
|
418
431
|
defaultPoint: getPointData(),
|
|
@@ -468,7 +481,7 @@ var LeaferUI = (function (exports) {
|
|
|
468
481
|
tempToOuterOf(t, matrix) {
|
|
469
482
|
const { tempPoint: temp } = P$5;
|
|
470
483
|
copy$a(temp, t);
|
|
471
|
-
toOuterPoint$
|
|
484
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
472
485
|
return temp;
|
|
473
486
|
},
|
|
474
487
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -487,7 +500,7 @@ var LeaferUI = (function (exports) {
|
|
|
487
500
|
toInnerPoint$2(matrix, t, to);
|
|
488
501
|
},
|
|
489
502
|
toOuterOf(t, matrix, to) {
|
|
490
|
-
toOuterPoint$
|
|
503
|
+
toOuterPoint$3(matrix, t, to);
|
|
491
504
|
},
|
|
492
505
|
getCenter(t, to) {
|
|
493
506
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -767,7 +780,7 @@ var LeaferUI = (function (exports) {
|
|
|
767
780
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
768
781
|
|
|
769
782
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
770
|
-
const { toOuterPoint: toOuterPoint$
|
|
783
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
771
784
|
const { float, fourNumber } = MathHelper;
|
|
772
785
|
const { floor, ceil: ceil$2 } = Math;
|
|
773
786
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
@@ -787,17 +800,24 @@ var LeaferUI = (function (exports) {
|
|
|
787
800
|
t.width = bounds.width;
|
|
788
801
|
t.height = bounds.height;
|
|
789
802
|
},
|
|
790
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
803
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
804
|
+
const { x, y, width, height } = bounds;
|
|
791
805
|
if (spread instanceof Array) {
|
|
792
806
|
const four = fourNumber(spread);
|
|
793
807
|
isShrink
|
|
794
|
-
? B.set(t,
|
|
795
|
-
: B.set(t,
|
|
808
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
809
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
796
810
|
}
|
|
797
811
|
else {
|
|
798
812
|
if (isShrink)
|
|
799
813
|
spread = -spread;
|
|
800
|
-
B.set(t,
|
|
814
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
815
|
+
}
|
|
816
|
+
if (side) {
|
|
817
|
+
if (side === 'width')
|
|
818
|
+
t.y = y, t.height = height;
|
|
819
|
+
else
|
|
820
|
+
t.x = x, t.width = width;
|
|
801
821
|
}
|
|
802
822
|
},
|
|
803
823
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -874,16 +894,16 @@ var LeaferUI = (function (exports) {
|
|
|
874
894
|
else {
|
|
875
895
|
point.x = t.x;
|
|
876
896
|
point.y = t.y;
|
|
877
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
878
898
|
setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
879
899
|
point.x = t.x + t.width;
|
|
880
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
881
901
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
882
902
|
point.y = t.y + t.height;
|
|
883
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
884
904
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
885
905
|
point.x = t.x;
|
|
886
|
-
toOuterPoint$
|
|
906
|
+
toOuterPoint$2(matrix, point, toPoint$5);
|
|
887
907
|
addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
888
908
|
toBounds$4(tempPointBounds$1, to);
|
|
889
909
|
}
|
|
@@ -897,16 +917,16 @@ var LeaferUI = (function (exports) {
|
|
|
897
917
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
898
918
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
899
919
|
},
|
|
900
|
-
getSpread(t, spread) {
|
|
920
|
+
getSpread(t, spread, side) {
|
|
901
921
|
const n = {};
|
|
902
|
-
B.copyAndSpread(n, t, spread);
|
|
922
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
903
923
|
return n;
|
|
904
924
|
},
|
|
905
|
-
spread(t, spread) {
|
|
906
|
-
B.copyAndSpread(t, t, spread);
|
|
925
|
+
spread(t, spread, side) {
|
|
926
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
907
927
|
},
|
|
908
|
-
shrink(t, shrink) {
|
|
909
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
928
|
+
shrink(t, shrink, side) {
|
|
929
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
910
930
|
},
|
|
911
931
|
ceil(t) {
|
|
912
932
|
const { x, y } = t;
|
|
@@ -1089,12 +1109,12 @@ var LeaferUI = (function (exports) {
|
|
|
1089
1109
|
getFitMatrix(put, baseScale) {
|
|
1090
1110
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1091
1111
|
}
|
|
1092
|
-
spread(fourNumber) {
|
|
1093
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1112
|
+
spread(fourNumber, side) {
|
|
1113
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1094
1114
|
return this;
|
|
1095
1115
|
}
|
|
1096
|
-
shrink(fourNumber) {
|
|
1097
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1116
|
+
shrink(fourNumber, side) {
|
|
1117
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1098
1118
|
return this;
|
|
1099
1119
|
}
|
|
1100
1120
|
ceil() {
|
|
@@ -2911,60 +2931,75 @@ var LeaferUI = (function (exports) {
|
|
|
2911
2931
|
}
|
|
2912
2932
|
beginPath() {
|
|
2913
2933
|
beginPath(this.__path);
|
|
2934
|
+
this.paint();
|
|
2914
2935
|
return this;
|
|
2915
2936
|
}
|
|
2916
2937
|
moveTo(x, y) {
|
|
2917
2938
|
moveTo$4(this.__path, x, y);
|
|
2939
|
+
this.paint();
|
|
2918
2940
|
return this;
|
|
2919
2941
|
}
|
|
2920
2942
|
lineTo(x, y) {
|
|
2921
2943
|
lineTo$3(this.__path, x, y);
|
|
2944
|
+
this.paint();
|
|
2922
2945
|
return this;
|
|
2923
2946
|
}
|
|
2924
2947
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2925
2948
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2949
|
+
this.paint();
|
|
2926
2950
|
return this;
|
|
2927
2951
|
}
|
|
2928
2952
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2929
2953
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2954
|
+
this.paint();
|
|
2930
2955
|
return this;
|
|
2931
2956
|
}
|
|
2932
2957
|
closePath() {
|
|
2933
2958
|
closePath$3(this.__path);
|
|
2959
|
+
this.paint();
|
|
2934
2960
|
return this;
|
|
2935
2961
|
}
|
|
2936
2962
|
rect(x, y, width, height) {
|
|
2937
2963
|
rect$1(this.__path, x, y, width, height);
|
|
2964
|
+
this.paint();
|
|
2938
2965
|
return this;
|
|
2939
2966
|
}
|
|
2940
2967
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2941
2968
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2969
|
+
this.paint();
|
|
2942
2970
|
return this;
|
|
2943
2971
|
}
|
|
2944
2972
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2945
2973
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2974
|
+
this.paint();
|
|
2946
2975
|
return this;
|
|
2947
2976
|
}
|
|
2948
2977
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2949
2978
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2979
|
+
this.paint();
|
|
2950
2980
|
return this;
|
|
2951
2981
|
}
|
|
2952
2982
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2953
2983
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2984
|
+
this.paint();
|
|
2954
2985
|
return this;
|
|
2955
2986
|
}
|
|
2956
2987
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2957
2988
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2989
|
+
this.paint();
|
|
2958
2990
|
return this;
|
|
2959
2991
|
}
|
|
2960
2992
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2961
2993
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2994
|
+
this.paint();
|
|
2962
2995
|
return this;
|
|
2963
2996
|
}
|
|
2964
2997
|
drawPoints(points, curve, close) {
|
|
2965
2998
|
drawPoints$2(this.__path, points, curve, close);
|
|
2999
|
+
this.paint();
|
|
2966
3000
|
return this;
|
|
2967
3001
|
}
|
|
3002
|
+
paint() { }
|
|
2968
3003
|
}
|
|
2969
3004
|
|
|
2970
3005
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
@@ -3986,7 +4021,7 @@ var LeaferUI = (function (exports) {
|
|
|
3986
4021
|
};
|
|
3987
4022
|
}
|
|
3988
4023
|
|
|
3989
|
-
const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4024
|
+
const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3990
4025
|
const matrix = {};
|
|
3991
4026
|
const LeafHelper = {
|
|
3992
4027
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4051,10 +4086,9 @@ var LeaferUI = (function (exports) {
|
|
|
4051
4086
|
}
|
|
4052
4087
|
return true;
|
|
4053
4088
|
},
|
|
4054
|
-
moveWorld(t, x, y = 0) {
|
|
4089
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4055
4090
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4056
|
-
|
|
4057
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4091
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4058
4092
|
L.moveLocal(t, local.x, local.y);
|
|
4059
4093
|
},
|
|
4060
4094
|
moveLocal(t, x, y = 0) {
|
|
@@ -4921,7 +4955,7 @@ var LeaferUI = (function (exports) {
|
|
|
4921
4955
|
|
|
4922
4956
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4923
4957
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4924
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4958
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$4 } = BoundsHelper;
|
|
4925
4959
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4926
4960
|
const LeafBounds = {
|
|
4927
4961
|
__updateWorldBounds() {
|
|
@@ -5022,7 +5056,7 @@ var LeaferUI = (function (exports) {
|
|
|
5022
5056
|
updateAllMatrix$2(this);
|
|
5023
5057
|
updateBounds$1(this, this);
|
|
5024
5058
|
if (this.__.__autoSide)
|
|
5025
|
-
this.__updateBoxBounds();
|
|
5059
|
+
this.__updateBoxBounds(true);
|
|
5026
5060
|
}
|
|
5027
5061
|
else {
|
|
5028
5062
|
updateAllMatrix$2(this);
|
|
@@ -5040,11 +5074,11 @@ var LeaferUI = (function (exports) {
|
|
|
5040
5074
|
},
|
|
5041
5075
|
__updateStrokeBounds() {
|
|
5042
5076
|
const layout = this.__layout;
|
|
5043
|
-
copyAndSpread$
|
|
5077
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5044
5078
|
},
|
|
5045
5079
|
__updateRenderBounds() {
|
|
5046
5080
|
const layout = this.__layout;
|
|
5047
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5081
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
|
|
5048
5082
|
}
|
|
5049
5083
|
};
|
|
5050
5084
|
|
|
@@ -5404,6 +5438,9 @@ var LeaferUI = (function (exports) {
|
|
|
5404
5438
|
move(x, y) {
|
|
5405
5439
|
moveLocal(this, x, y);
|
|
5406
5440
|
}
|
|
5441
|
+
moveInner(x, y) {
|
|
5442
|
+
moveWorld(this, x, y, true);
|
|
5443
|
+
}
|
|
5407
5444
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5408
5445
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5409
5446
|
}
|
|
@@ -6670,6 +6707,11 @@ var LeaferUI = (function (exports) {
|
|
|
6670
6707
|
}
|
|
6671
6708
|
|
|
6672
6709
|
class LeaferData extends GroupData {
|
|
6710
|
+
__getInputData() {
|
|
6711
|
+
const data = super.__getInputData();
|
|
6712
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6713
|
+
return data;
|
|
6714
|
+
}
|
|
6673
6715
|
}
|
|
6674
6716
|
|
|
6675
6717
|
class FrameData extends BoxData {
|
|
@@ -6747,6 +6789,11 @@ var LeaferUI = (function (exports) {
|
|
|
6747
6789
|
}
|
|
6748
6790
|
|
|
6749
6791
|
class CanvasData extends RectData {
|
|
6792
|
+
__getInputData() {
|
|
6793
|
+
const data = super.__getInputData();
|
|
6794
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
6795
|
+
return data;
|
|
6796
|
+
}
|
|
6750
6797
|
}
|
|
6751
6798
|
|
|
6752
6799
|
const UIBounds = {
|
|
@@ -7659,6 +7706,13 @@ var LeaferUI = (function (exports) {
|
|
|
7659
7706
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7660
7707
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7661
7708
|
}
|
|
7709
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7710
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7711
|
+
}
|
|
7712
|
+
updateClientBounds() {
|
|
7713
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7714
|
+
}
|
|
7715
|
+
receiveEvent(_event) { }
|
|
7662
7716
|
__checkUpdateLayout() {
|
|
7663
7717
|
this.__layout.update();
|
|
7664
7718
|
}
|
|
@@ -7742,7 +7796,7 @@ var LeaferUI = (function (exports) {
|
|
|
7742
7796
|
const rect = exports.Rect.prototype;
|
|
7743
7797
|
const group = exports.Group.prototype;
|
|
7744
7798
|
const childrenRenderBounds = {};
|
|
7745
|
-
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
7799
|
+
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
7746
7800
|
exports.Box = class Box extends exports.Group {
|
|
7747
7801
|
get __tag() { return 'Box'; }
|
|
7748
7802
|
get isBranchLeaf() { return true; }
|
|
@@ -7756,20 +7810,23 @@ var LeaferUI = (function (exports) {
|
|
|
7756
7810
|
return this.__updateRectRenderSpread() || -1;
|
|
7757
7811
|
}
|
|
7758
7812
|
__updateRectBoxBounds() { }
|
|
7759
|
-
__updateBoxBounds() {
|
|
7813
|
+
__updateBoxBounds(secondLayout) {
|
|
7760
7814
|
const data = this.__;
|
|
7761
7815
|
if (this.children.length) {
|
|
7762
7816
|
if (data.__autoSide) {
|
|
7763
7817
|
if (this.leafer && this.leafer.ready)
|
|
7764
7818
|
this.leafer.layouter.addExtra(this);
|
|
7765
7819
|
super.__updateBoxBounds();
|
|
7820
|
+
const { boxBounds } = this.__layout;
|
|
7766
7821
|
if (!data.__autoSize) {
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
7822
|
+
if (data.__autoWidth)
|
|
7823
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
7824
|
+
else
|
|
7825
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
7772
7826
|
}
|
|
7827
|
+
if (secondLayout && data.flow && data.padding)
|
|
7828
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
7829
|
+
this.__updateNaturalSize();
|
|
7773
7830
|
}
|
|
7774
7831
|
else {
|
|
7775
7832
|
this.__updateRectBoxBounds();
|
|
@@ -7789,13 +7846,13 @@ var LeaferUI = (function (exports) {
|
|
|
7789
7846
|
super.__updateRenderBounds();
|
|
7790
7847
|
copy$2(childrenRenderBounds, renderBounds);
|
|
7791
7848
|
this.__updateRectRenderBounds();
|
|
7792
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
7849
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
7793
7850
|
}
|
|
7794
7851
|
else {
|
|
7795
7852
|
this.__updateRectRenderBounds();
|
|
7796
7853
|
}
|
|
7797
7854
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
7798
|
-
if (
|
|
7855
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
7799
7856
|
add(renderBounds, childrenRenderBounds);
|
|
7800
7857
|
}
|
|
7801
7858
|
__updateRectRenderBounds() { }
|
|
@@ -8129,14 +8186,26 @@ var LeaferUI = (function (exports) {
|
|
|
8129
8186
|
exports.Image = __decorate([
|
|
8130
8187
|
registerUI()
|
|
8131
8188
|
], exports.Image);
|
|
8189
|
+
const MyImage = exports.Image;
|
|
8132
8190
|
|
|
8133
8191
|
exports.Canvas = class Canvas extends exports.Rect {
|
|
8134
8192
|
get __tag() { return 'Canvas'; }
|
|
8193
|
+
get ready() { return !this.url; }
|
|
8135
8194
|
constructor(data) {
|
|
8136
8195
|
super(data);
|
|
8137
8196
|
this.canvas = Creator.canvas(this.__);
|
|
8138
8197
|
this.context = this.canvas.context;
|
|
8139
8198
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8199
|
+
if (data && data.url)
|
|
8200
|
+
this.drawImage(data.url);
|
|
8201
|
+
}
|
|
8202
|
+
drawImage(url) {
|
|
8203
|
+
new LeaferImage({ url }).load((image) => {
|
|
8204
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8205
|
+
this.url = undefined;
|
|
8206
|
+
this.paint();
|
|
8207
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8208
|
+
});
|
|
8140
8209
|
}
|
|
8141
8210
|
draw(ui, offset, scale, rotation) {
|
|
8142
8211
|
ui.__layout.update();
|
|
@@ -8195,7 +8264,7 @@ var LeaferUI = (function (exports) {
|
|
|
8195
8264
|
resizeType(100)
|
|
8196
8265
|
], exports.Canvas.prototype, "height", void 0);
|
|
8197
8266
|
__decorate([
|
|
8198
|
-
resizeType(
|
|
8267
|
+
resizeType(1)
|
|
8199
8268
|
], exports.Canvas.prototype, "pixelRatio", void 0);
|
|
8200
8269
|
__decorate([
|
|
8201
8270
|
resizeType(true)
|
|
@@ -8219,13 +8288,13 @@ var LeaferUI = (function (exports) {
|
|
|
8219
8288
|
super(data);
|
|
8220
8289
|
}
|
|
8221
8290
|
__drawHitPath(canvas) {
|
|
8222
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8291
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8223
8292
|
canvas.beginPath();
|
|
8224
8293
|
if (this.__.__letterSpacing < 0) {
|
|
8225
8294
|
this.__drawPathByData(canvas);
|
|
8226
8295
|
}
|
|
8227
8296
|
else {
|
|
8228
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8297
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8229
8298
|
}
|
|
8230
8299
|
}
|
|
8231
8300
|
__drawPathByData(drawer, _data) {
|
|
@@ -8418,7 +8487,8 @@ var LeaferUI = (function (exports) {
|
|
|
8418
8487
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8419
8488
|
clearPath() { return this; }
|
|
8420
8489
|
paint() {
|
|
8421
|
-
this.pathElement.
|
|
8490
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8491
|
+
this.pathElement.forceUpdate('path');
|
|
8422
8492
|
}
|
|
8423
8493
|
};
|
|
8424
8494
|
__decorate([
|
|
@@ -8428,7 +8498,7 @@ var LeaferUI = (function (exports) {
|
|
|
8428
8498
|
penPathType()
|
|
8429
8499
|
], exports.Pen.prototype, "path", void 0);
|
|
8430
8500
|
exports.Pen = __decorate([
|
|
8431
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8501
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8432
8502
|
registerUI()
|
|
8433
8503
|
], exports.Pen);
|
|
8434
8504
|
function penPathType() {
|
|
@@ -8790,10 +8860,13 @@ var LeaferUI = (function (exports) {
|
|
|
8790
8860
|
const { get: get$2, translate } = MatrixHelper;
|
|
8791
8861
|
const tempBox = new Bounds();
|
|
8792
8862
|
const tempPoint = {};
|
|
8863
|
+
const tempScaleData = {};
|
|
8793
8864
|
function createData(leafPaint, image, paint, box) {
|
|
8794
|
-
const { blendMode } = paint;
|
|
8865
|
+
const { blendMode, sync } = paint;
|
|
8795
8866
|
if (blendMode)
|
|
8796
8867
|
leafPaint.blendMode = blendMode;
|
|
8868
|
+
if (sync)
|
|
8869
|
+
leafPaint.sync = sync;
|
|
8797
8870
|
leafPaint.data = getPatternData(paint, box, image);
|
|
8798
8871
|
}
|
|
8799
8872
|
function getPatternData(paint, box, image) {
|
|
@@ -8813,13 +8886,10 @@ var LeaferUI = (function (exports) {
|
|
|
8813
8886
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
8814
8887
|
}
|
|
8815
8888
|
}
|
|
8816
|
-
else if (size) {
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
else if (scale) {
|
|
8821
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
8822
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
8889
|
+
else if (scale || size) {
|
|
8890
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
8891
|
+
scaleX = tempScaleData.scaleX;
|
|
8892
|
+
scaleY = tempScaleData.scaleY;
|
|
8823
8893
|
}
|
|
8824
8894
|
if (align) {
|
|
8825
8895
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -9058,7 +9128,7 @@ var LeaferUI = (function (exports) {
|
|
|
9058
9128
|
return true;
|
|
9059
9129
|
}
|
|
9060
9130
|
else {
|
|
9061
|
-
if (!paint.style || Export.running) {
|
|
9131
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
9062
9132
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
9063
9133
|
}
|
|
9064
9134
|
else {
|
|
@@ -9928,6 +9998,7 @@ var LeaferUI = (function (exports) {
|
|
|
9928
9998
|
export(leaf, filename, options) {
|
|
9929
9999
|
this.running = true;
|
|
9930
10000
|
const fileType = FileHelper.fileType(filename);
|
|
10001
|
+
const isDownload = filename.includes('.');
|
|
9931
10002
|
options = FileHelper.getExportOptions(options);
|
|
9932
10003
|
return addTask((success) => new Promise((resolve) => {
|
|
9933
10004
|
const over = (result) => {
|
|
@@ -9937,19 +10008,13 @@ var LeaferUI = (function (exports) {
|
|
|
9937
10008
|
};
|
|
9938
10009
|
const { toURL } = Platform;
|
|
9939
10010
|
const { download } = Platform.origin;
|
|
9940
|
-
if (
|
|
9941
|
-
|
|
10011
|
+
if (fileType === 'json') {
|
|
10012
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10013
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
9942
10014
|
}
|
|
9943
|
-
|
|
9944
|
-
download(toURL(
|
|
9945
|
-
return over({ data: true });
|
|
9946
|
-
}
|
|
9947
|
-
if (filename === 'svg') {
|
|
9948
|
-
return over({ data: leaf.toSVG() });
|
|
9949
|
-
}
|
|
9950
|
-
else if (fileType === 'svg') {
|
|
9951
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
9952
|
-
return over({ data: true });
|
|
10015
|
+
if (fileType === 'svg') {
|
|
10016
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10017
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
9953
10018
|
}
|
|
9954
10019
|
const { leafer } = leaf;
|
|
9955
10020
|
if (leafer) {
|
|
@@ -9958,14 +10023,8 @@ var LeaferUI = (function (exports) {
|
|
|
9958
10023
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
9959
10024
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
9960
10025
|
const { slice, trim, onCanvas } = options;
|
|
9961
|
-
let scale = options.scale || 1;
|
|
9962
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
9963
10026
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
9964
10027
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
9965
|
-
if (leaf.isApp) {
|
|
9966
|
-
scale *= pixelRatio;
|
|
9967
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
9968
|
-
}
|
|
9969
10028
|
const screenshot = options.screenshot || leaf.isApp;
|
|
9970
10029
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
9971
10030
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -9999,9 +10058,17 @@ var LeaferUI = (function (exports) {
|
|
|
9999
10058
|
}
|
|
10000
10059
|
renderBounds = leaf.getBounds('render', relative);
|
|
10001
10060
|
}
|
|
10002
|
-
const {
|
|
10061
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10062
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10063
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
10064
|
+
if (leaf.isApp) {
|
|
10065
|
+
scaleData.scaleX *= pixelRatio;
|
|
10066
|
+
scaleData.scaleY *= pixelRatio;
|
|
10067
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
10068
|
+
}
|
|
10069
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10070
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10003
10071
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10004
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
10005
10072
|
let sliceLeaf;
|
|
10006
10073
|
if (slice) {
|
|
10007
10074
|
sliceLeaf = leaf;
|
|
@@ -10158,6 +10225,7 @@ var LeaferUI = (function (exports) {
|
|
|
10158
10225
|
exports.MathHelper = MathHelper;
|
|
10159
10226
|
exports.Matrix = Matrix;
|
|
10160
10227
|
exports.MatrixHelper = MatrixHelper;
|
|
10228
|
+
exports.MyImage = MyImage;
|
|
10161
10229
|
exports.NeedConvertToCanvasCommandMap = NeedConvertToCanvasCommandMap;
|
|
10162
10230
|
exports.OneRadian = OneRadian;
|
|
10163
10231
|
exports.PI2 = PI2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:i}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((a,o)=>{t.convertToBlob({type:i(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:i(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&d(t),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return y.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,a,e,n);break;case"outside":B("outside",t,a,e,n)}}function B(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,o)}function R(t,n,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),n?E(i,a):a.stroke(),a.restoreBlendMode()):n?E(i,a):a.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:L,getOuterOf:k,getByMove:P,getIntersectData:S}=t.BoundsHelper;let O;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:a}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:l}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,a,!O||!O[n.url]);case"linear":return e.PaintGradient.linearGradient(n,a);case"radial":return e.PaintGradient.radialGradient(n,a);case"angular":return e.PaintGradient.conicGradient(n,a);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const A={compute:function(t,n){const i=n.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),O=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=s.length;i<o;i++)e=W(t,s[i],n),e&&a.push(e);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let a;const{windingRule:o,__font:s}=n.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&e.PaintImage.checkImage(n,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),R(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),R(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=S(i?L(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=k(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let C={};const{get:M,rotateOfOuter:T,translate:I,scaleOfOuter:D,scale:H,rotate:F}=t.MatrixHelper;function Y(t,e,n,i,a,o,s){const r=M();I(r,e.x+n,e.y+i),H(r,a,o),s&&T(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function G(t,e,n,i,a,o,s){const r=M();I(r,e.x+n,e.y+i),a&&H(r,a,o),s&&F(r,s),t.transform=r}function j(t,e,n,i,a,o,s,r,l,d){const c=M();if(l)if("center"===d)T(c,{x:n/2,y:i/2},l);else switch(F(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}C.x=e.x+a,C.y=e.y+o,I(c,C.x,C.y),s&&D(c,C,s,r),t.transform=c}const{get:X,translate:U}=t.MatrixHelper,N=new t.Bounds,q={},V={};function z(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:a,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding));const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,V),y=V.scaleX,v=V.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*y)/2,b+=(n.height-o*v)/2}if(l){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,q,!0),x+=q.x,b+=q.y}switch(d&&(x+=d.x,b+=d.y),r){case"strench":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&G(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&j(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&Y(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=X(),U(g.transform,n.x,n.y)),y&&"strench"!==r&&(g.scaleX=y,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:K}=t.BoundsHelper;function $(t,e,n,i,a,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||z(a,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:st,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o;if(n.patternId===s||e.destroyed)return!1;{a=dt(a),o=dt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),rt(d,g),st(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=ot(),g&&rt(d,g)),st(d,1/a,1/o));const y=e.getCanvas(lt(c)||1,lt(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return J&&i===J.paint&&K(a,J.boxBounds)?s=J.leafPaint:(s={type:i.type,image:l},J=l.use>1?{leafPaint:s,paint:i,boxBounds:Z.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?($(e,n,i,l,s,a),o&&(tt(e,r),et(e,r))):l.error?o&&nt(e,r,l.error):(at(e,!0),o&&tt(e,r),s.loadId=l.load((()=>{at(e,!1),e.destroyed||($(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),s.loadId=null}),(t=>{at(e,!1),nt(e,r,t),s.loadId=null}))),s},checkImage:function(n,i,a,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld;if(!a.data||a.patternId===s+"-"+r&&!e.Export.running)return!1;{const{data:l}=a;if(o)if(l.repeat)o=!1;else{let{width:n,height:a}=l;n*=ut(s)*i.pixelRatio,a*=ut(r)*i.pixelRatio,l.scaleX&&(n*=l.scaleX,a*=l.scaleY),o=n*a>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),i.clip(),a.blendMode&&(i.blendMode=a.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(a.image.view,0,0,l.width,l.height),i.restore(),!0):(!a.style||a.sync||e.Export.running?ct(n,a,i.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,a,i.pixelRatio),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:z,getPatternData:Q,fillOrFitMode:Y,clipMode:G,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){let a;for(let o=0,s=n.length;o<s;o++)a=n[o],"string"==typeof a?t.addColorStop(o/(s-1),e.ColorConvert.string(a,i)):t.addColorStop(a.offset,e.ColorConvert.string(a.color,i))}const{getAngle:mt,getDistance:yt}=t.PointHelper,{get:vt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Bt}=t.AroundHelper,Et={},Rt={};function Lt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=mt(e,n);o=vt(),a?(bt(o,e,s/r*(i||1),1),xt(o,e,t+90)):(bt(o,e,1,s/r*(i||1)),xt(o,e,t))}return o}const{getDistance:kt}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,St={},Ot={};const Wt={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;pt(i||"top",n,gt),pt(a||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Bt(i||"center",n,Et),Bt(a||"bottom",n,Rt);const d=t.Platform.canvas.createRadialGradient(Et.x,Et.y,0,Et.x,Et.y,yt(Et,Rt));wt(d,e.stops,s);const c={type:o,style:d},h=Lt(n,Et,Rt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ot);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,St.x,St.y):t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,kt(St,Ot));wt(d,e.stops,s);const c={type:o,style:d},h=Lt(n,St,Ot,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Lt},{copy:At,toOffsetOutBounds:Ct}=t.BoundsHelper,Mt={},Tt={};function It(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(At(Mt,e.bounds),Mt.x+=n.x-s.x,Mt.y+=n.y-s.y,i){const{matrix:t}=a;Mt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Mt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(a.canvas,e.bounds,Mt)}else i&&(At(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(a.canvas,s,i?Mt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,Ht={};const Ft={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ct(d,Tt),r.forEach(((r,g)=>{f.setWorldShadow(Tt.offsetX+r.x*h,Tt.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,It(f,Tt,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,Ht),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ht.offsetX+r.x*h,Ht.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,It(f,Ht,a,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Yt}=t.LeafBoundsHelper;function Gt(t,e,n,i,a,o){switch(e){case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Xt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Xt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}e.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(s&&(Gt(this,s,t,a,i,o),i=a=null),"path"===n.__.mask?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=jt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="alpha",i||(i=jt(t)),a||(a=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Yt(n,e)||n.__render(a||t,e);Gt(this,s,t,a,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Ut+"_#~&*+\\=|≮≯≈≠=…",qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const zt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Vt(Ut),Zt=Vt(Nt),Kt=Vt("- —/~|┆·");var $t;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}($t||($t={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:ae,Break:oe}=$t;function se(t){return zt[t]?te:Kt[t]?oe:Qt[t]?ne:Jt[t]?ie:Zt[t]?ae:qt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=$t;let _e,we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Oe,We,Ae=[];function Ce(t,e){Ee&&!Be&&(Be=Ee),_e.data.push({char:t,width:e}),me+=e}function Me(){ye+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Te(){Se&&(Oe.paraNumber++,we.paraStart=!0,Se=!1),Ee&&(we.startCharSize=Be,we.endCharSize=Ee,Be=0),we.width=ye,We.width&&de(we),Ae.push(we),we={words:[]},ye=0}const Ie=0,De=1,He=2;const{top:Fe,right:Ye,bottom:Ge,left:je}=t.Direction4;function Xe(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ue={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o&&(i=d[je],o-=d[Ye]+d[je]),s&&(a=d[Fe],s-=d[Fe]+d[Ge]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Oe=e,Ae=e.rows,We=e.bounds;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Se=!0,Le=null,Be=be=Ee=me=ye=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Me(),we.paraEnd=!0,Te(),Se=!0):(Re=se(xe),Re===ce&&"none"!==s&&(xe=le(xe,s,!me)),be=r.measureText(xe).width,a&&(a<0&&(Ee=be),be+=a),ke=Re===he&&(Le===he||Le===ce)||Le===he&&Re!==fe,Pe=!(Re!==ue&&Re!==he||Le!==pe&&Le!==fe),ve=Se&&o?l-o:l,t&&l&&ye+me+be>ve&&(e?(me&&Me(),ye&&Te()):(Pe||(Pe=Re===ce&&Le==fe),ke||Pe||Re===ge||Re===ue||Re===he||me+be>ve?(me&&Me(),ye&&Te()):ye&&Te()))," "===xe&&!0!==Se&&ye+me===0||(Re===ge?(" "===xe&&me&&Me(),Ce(xe,be),Me()):ke||Pe?(me&&Me(),Ce(xe,be)):Ce(xe,be)),Le=Re);me&&Me(),ye&&Te(),Ae.length>0&&(Ae[Ae.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,Ae.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),d&&function(t,e,n,i,a){if(!i)switch(n.textAlign){case"left":Xe(e,"x",t[je]);break;case"right":Xe(e,"x",-t[Ye])}if(!a)switch(n.verticalAlign){case"top":Xe(e,"y",t[Fe]);break;case"bottom":Xe(e,"y",-t[Ge])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=i,m=a*n.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,a),t.overflow=n.length;else switch(d){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}y+=g;for(let o=0,d=n.length;o<d;o++){if(h=n[o],h.x=p,h.width<_||h.width>_&&!r)switch(l){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(y+=c),h.y=y,y+=a,t.overflow>o&&y>m&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,s<0&&(h.width<0?(f=-h.width+e.fontSize+s,u-=f,f+=e.fontSize):f-=s),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=m}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Ie:d>.01?De:He,t.isOverflow&&!r&&(t.textMode=!0),h===He?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===De?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ne={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:qe,addPoint:Ve,toBounds:ze}=t.TwoPointBoundsHelper;const Qe={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){Je||(Je=new t.TaskProcessor);return new Promise((t=>{Je.add((()=>ht(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((r=>{const l=t=>{s(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(Ze(e),h.waitViewCompleted((()=>ht(this,void 0,void 0,(function*(){let a,o,s=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,y=c&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)a=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(s=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}a=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,a,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(a).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let S,O=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=O.bounds),O.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(O,P),e.fill=t}else e.__render(O,P);if(O.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Ve(r,o,s):qe(r={},o,s)),l++;const d=new t.Bounds;return ze(r,d),d.scale(1/e.pixelRatio).ceil()}(O);const e=O,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};O=t.Creator.canvas(a),O.copyWorld(e,o,a)}v&&O.fillWorld(O.bounds,y||"#FFFFFF","destination-over"),g&&g(O);const W="canvas"===n?O:yield O.export(n,i);l({data:W,width:O.pixelWidth,height:O.pixelHeight,renderBounds:a,trimBounds:o})}))))):l({data:!1})}))))}};let Je;function Ze(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ze(t)))}const Ke=t.LeaferCanvasBase.prototype,$e=t.Debug.get("@leafer-ui/export");Ke.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},Ke.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{$e.error(t),i(null)}))}))},Ke.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},Ke.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{$e.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Ue),Object.assign(e.ColorConvert,Ne),Object.assign(e.Paint,A),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Ft),Object.assign(e.Export,Qe),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|