@leafer-draw/miniapp 1.12.1 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +6 -4
- package/dist/miniapp.esm.js +6 -4
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +77 -38
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.module.js
CHANGED
|
@@ -461,7 +461,7 @@ function getMatrixData() {
|
|
|
461
461
|
|
|
462
462
|
const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
|
|
463
463
|
|
|
464
|
-
const {float: float$
|
|
464
|
+
const {float: float$2} = MathHelper;
|
|
465
465
|
|
|
466
466
|
const tempPoint$3 = {};
|
|
467
467
|
|
|
@@ -712,12 +712,12 @@ const MatrixHelper = {
|
|
|
712
712
|
const cosR = c / scaleY;
|
|
713
713
|
rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
|
|
714
714
|
}
|
|
715
|
-
const cosR = float$
|
|
715
|
+
const cosR = float$2(cos$5(rotation));
|
|
716
716
|
const sinR = sin$5(rotation);
|
|
717
|
-
scaleX = float$
|
|
718
|
-
skewX = cosR ? float$
|
|
719
|
-
skewY = cosR ? float$
|
|
720
|
-
rotation = float$
|
|
717
|
+
scaleX = float$2(scaleX), scaleY = float$2(scaleY);
|
|
718
|
+
skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
|
|
719
|
+
skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
|
|
720
|
+
rotation = float$2(rotation / OneRadian);
|
|
721
721
|
} else {
|
|
722
722
|
scaleX = a;
|
|
723
723
|
scaleY = d;
|
|
@@ -761,6 +761,8 @@ const MatrixHelper = {
|
|
|
761
761
|
|
|
762
762
|
const M$6 = MatrixHelper;
|
|
763
763
|
|
|
764
|
+
const {float: float$1} = MathHelper;
|
|
765
|
+
|
|
764
766
|
const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
|
|
765
767
|
|
|
766
768
|
const {sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = Math;
|
|
@@ -828,6 +830,11 @@ const PointHelper = {
|
|
|
828
830
|
P$5.toInnerRadiusPointOf(t, matrix, temp);
|
|
829
831
|
return temp;
|
|
830
832
|
},
|
|
833
|
+
copyRadiusPoint(t, point, x, y) {
|
|
834
|
+
copy$9(t, point);
|
|
835
|
+
setRadius(t, x, y);
|
|
836
|
+
return t;
|
|
837
|
+
},
|
|
831
838
|
toInnerRadiusPointOf(t, matrix, to) {
|
|
832
839
|
to || (to = t);
|
|
833
840
|
toInnerPoint$2(matrix, t, to);
|
|
@@ -895,7 +902,7 @@ const PointHelper = {
|
|
|
895
902
|
return points;
|
|
896
903
|
},
|
|
897
904
|
isSame(t, point) {
|
|
898
|
-
return t.x === point.x && t.y === point.y;
|
|
905
|
+
return float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
|
|
899
906
|
},
|
|
900
907
|
reset(t) {
|
|
901
908
|
P$5.reset(t);
|
|
@@ -904,7 +911,7 @@ const PointHelper = {
|
|
|
904
911
|
|
|
905
912
|
const P$5 = PointHelper;
|
|
906
913
|
|
|
907
|
-
const {getDistanceFrom: getDistanceFrom, copy: copy$9, getAtan2: getAtan2} = P$5;
|
|
914
|
+
const {getDistanceFrom: getDistanceFrom, copy: copy$9, setRadius: setRadius, getAtan2: getAtan2} = P$5;
|
|
908
915
|
|
|
909
916
|
class Point {
|
|
910
917
|
constructor(x, y) {
|
|
@@ -2407,7 +2414,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2407
2414
|
const {pixelRatio: pixelRatio} = this;
|
|
2408
2415
|
this.filter = `blur(${blur * pixelRatio}px)`;
|
|
2409
2416
|
}
|
|
2410
|
-
copyWorld(canvas, from, to, blendMode, ceilPixel
|
|
2417
|
+
copyWorld(canvas, from, to, blendMode, ceilPixel) {
|
|
2411
2418
|
if (blendMode) this.blendMode = blendMode;
|
|
2412
2419
|
if (from) {
|
|
2413
2420
|
this.setTempPixelBounds(from, ceilPixel);
|
|
@@ -2418,7 +2425,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2418
2425
|
}
|
|
2419
2426
|
if (blendMode) this.blendMode = "source-over";
|
|
2420
2427
|
}
|
|
2421
|
-
copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel
|
|
2428
|
+
copyWorldToInner(canvas, fromWorld, toInnerBounds, blendMode, ceilPixel) {
|
|
2422
2429
|
if (fromWorld.b || fromWorld.c) {
|
|
2423
2430
|
this.save();
|
|
2424
2431
|
this.resetTransform();
|
|
@@ -2431,7 +2438,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2431
2438
|
if (blendMode) this.blendMode = "source-over";
|
|
2432
2439
|
}
|
|
2433
2440
|
}
|
|
2434
|
-
copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel
|
|
2441
|
+
copyWorldByReset(canvas, from, to, blendMode, onlyResetTransform, ceilPixel) {
|
|
2435
2442
|
this.resetTransform();
|
|
2436
2443
|
this.copyWorld(canvas, from, to, blendMode, ceilPixel);
|
|
2437
2444
|
if (!onlyResetTransform) this.useWorldTransform();
|
|
@@ -2658,7 +2665,7 @@ const BezierHelper = {
|
|
|
2658
2665
|
data.push(M$5, points[0], points[1]);
|
|
2659
2666
|
if (curve && points.length > 5) {
|
|
2660
2667
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
2661
|
-
let ba, cb, d, len = points.length;
|
|
2668
|
+
let baX, baY, ba, cb, d, len = points.length;
|
|
2662
2669
|
const t = curve === true ? .5 : curve;
|
|
2663
2670
|
if (close) {
|
|
2664
2671
|
points = [ points[len - 2], points[len - 1], ...points, points[0], points[1], points[2], points[3] ];
|
|
@@ -2671,7 +2678,9 @@ const BezierHelper = {
|
|
|
2671
2678
|
bY = points[i + 1];
|
|
2672
2679
|
cX = points[i + 2];
|
|
2673
2680
|
cY = points[i + 3];
|
|
2674
|
-
|
|
2681
|
+
baX = bX - aX;
|
|
2682
|
+
baY = bY - aY;
|
|
2683
|
+
ba = sqrt$1(pow(baX, 2) + pow(baY, 2));
|
|
2675
2684
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2676
2685
|
if (!ba && !cb) continue;
|
|
2677
2686
|
d = ba + cb;
|
|
@@ -2684,7 +2693,7 @@ const BezierHelper = {
|
|
|
2684
2693
|
if (i === 2) {
|
|
2685
2694
|
if (!close) data.push(Q$4, c1X, c1Y, bX, bY);
|
|
2686
2695
|
} else {
|
|
2687
|
-
data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2696
|
+
if (baX || baY) data.push(C$4, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2688
2697
|
}
|
|
2689
2698
|
c2X = bX + cb * cX;
|
|
2690
2699
|
c2Y = bY + cb * cY;
|
|
@@ -3269,6 +3278,7 @@ const PathCommandDataHelper = {
|
|
|
3269
3278
|
}
|
|
3270
3279
|
},
|
|
3271
3280
|
ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
3281
|
+
if (radiusX === radiusY) return arc$2(data, x, y, radiusX, startAngle, endAngle, anticlockwise);
|
|
3272
3282
|
if (isNull(rotation)) {
|
|
3273
3283
|
data.push(F$3, x, y, radiusX, radiusY);
|
|
3274
3284
|
} else {
|
|
@@ -3281,6 +3291,7 @@ const PathCommandDataHelper = {
|
|
|
3281
3291
|
if (isNull(startAngle)) {
|
|
3282
3292
|
data.push(P$2, x, y, radius);
|
|
3283
3293
|
} else {
|
|
3294
|
+
if (isNull(startAngle)) startAngle = 0;
|
|
3284
3295
|
if (isNull(endAngle)) endAngle = 360;
|
|
3285
3296
|
data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
|
|
3286
3297
|
}
|
|
@@ -3631,6 +3642,7 @@ const PathCorner = {
|
|
|
3631
3642
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3632
3643
|
let command, lastCommand, commandLen;
|
|
3633
3644
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3645
|
+
if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
|
|
3634
3646
|
const len = data.length;
|
|
3635
3647
|
const smooth = [];
|
|
3636
3648
|
while (i < len) {
|
|
@@ -4046,7 +4058,9 @@ const R = Resource;
|
|
|
4046
4058
|
const ImageManager = {
|
|
4047
4059
|
maxRecycled: 10,
|
|
4048
4060
|
recycledList: [],
|
|
4049
|
-
patternTasker: new TaskProcessor
|
|
4061
|
+
patternTasker: new TaskProcessor({
|
|
4062
|
+
parallel: 1
|
|
4063
|
+
}),
|
|
4050
4064
|
get(config) {
|
|
4051
4065
|
let image = Resource.get(config.url);
|
|
4052
4066
|
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
@@ -4103,6 +4117,10 @@ class LeaferImage {
|
|
|
4103
4117
|
get url() {
|
|
4104
4118
|
return this.config.url;
|
|
4105
4119
|
}
|
|
4120
|
+
get crossOrigin() {
|
|
4121
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4122
|
+
return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
|
|
4123
|
+
}
|
|
4106
4124
|
get completed() {
|
|
4107
4125
|
return this.ready || !!this.error;
|
|
4108
4126
|
}
|
|
@@ -4120,12 +4138,14 @@ class LeaferImage {
|
|
|
4120
4138
|
ImageManager.isFormat("svg", config) && (this.isSVG = true);
|
|
4121
4139
|
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
4122
4140
|
}
|
|
4123
|
-
load(onSuccess, onError) {
|
|
4141
|
+
load(onSuccess, onError, thumbSize) {
|
|
4124
4142
|
if (!this.loading) {
|
|
4125
4143
|
this.loading = true;
|
|
4126
|
-
const {crossOrigin: crossOrigin} = this.config;
|
|
4127
4144
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4128
|
-
return yield Platform.origin.loadImage(this.
|
|
4145
|
+
return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4146
|
+
if (thumbSize) this.setThumbView(img);
|
|
4147
|
+
this.setView(img);
|
|
4148
|
+
}).catch(e => {
|
|
4129
4149
|
this.error = e;
|
|
4130
4150
|
this.onComplete(false);
|
|
4131
4151
|
});
|
|
@@ -4146,9 +4166,11 @@ class LeaferImage {
|
|
|
4146
4166
|
}
|
|
4147
4167
|
setView(img) {
|
|
4148
4168
|
this.ready = true;
|
|
4149
|
-
this.width
|
|
4150
|
-
|
|
4151
|
-
|
|
4169
|
+
if (!this.width) {
|
|
4170
|
+
this.width = img.width;
|
|
4171
|
+
this.height = img.height;
|
|
4172
|
+
this.view = img;
|
|
4173
|
+
}
|
|
4152
4174
|
this.onComplete(true);
|
|
4153
4175
|
}
|
|
4154
4176
|
onComplete(isSuccess) {
|
|
@@ -4194,6 +4216,19 @@ class LeaferImage {
|
|
|
4194
4216
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4195
4217
|
return pattern;
|
|
4196
4218
|
}
|
|
4219
|
+
getLoadUrl(_thumbSize) {
|
|
4220
|
+
return this.url;
|
|
4221
|
+
}
|
|
4222
|
+
setThumbView(_view) {}
|
|
4223
|
+
getThumbSize() {
|
|
4224
|
+
return undefined;
|
|
4225
|
+
}
|
|
4226
|
+
getMinLevel() {
|
|
4227
|
+
return undefined;
|
|
4228
|
+
}
|
|
4229
|
+
getLevelData(_level) {
|
|
4230
|
+
return undefined;
|
|
4231
|
+
}
|
|
4197
4232
|
clearLevels(_checkUse) {}
|
|
4198
4233
|
destroy() {
|
|
4199
4234
|
this.clearLevels();
|
|
@@ -6923,7 +6958,7 @@ class LeafLevelList {
|
|
|
6923
6958
|
}
|
|
6924
6959
|
}
|
|
6925
6960
|
|
|
6926
|
-
const version = "1.12.
|
|
6961
|
+
const version = "1.12.3";
|
|
6927
6962
|
|
|
6928
6963
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6929
6964
|
get allowBackgroundColor() {
|
|
@@ -8240,7 +8275,7 @@ const UIRender = {
|
|
|
8240
8275
|
if (stroke && !__fillAfterStroke) data.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
|
|
8241
8276
|
}
|
|
8242
8277
|
} else {
|
|
8243
|
-
if (data.
|
|
8278
|
+
if (data.__pathForRender) drawFast(this, canvas, options); else this.__drawFast(canvas, options);
|
|
8244
8279
|
}
|
|
8245
8280
|
},
|
|
8246
8281
|
__drawShape(canvas, options) {
|
|
@@ -8364,7 +8399,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8364
8399
|
getPath(curve, pathForRender) {
|
|
8365
8400
|
this.__layout.update();
|
|
8366
8401
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
8367
|
-
if (!path) pen.set(path = []), this.__drawPathByBox(pen);
|
|
8402
|
+
if (!path) pen.set(path = []), this.__drawPathByBox(pen, !pathForRender);
|
|
8368
8403
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
8369
8404
|
}
|
|
8370
8405
|
getPathString(curve, pathForRender, floatLength) {
|
|
@@ -8392,17 +8427,18 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8392
8427
|
}
|
|
8393
8428
|
__drawPath(canvas) {
|
|
8394
8429
|
canvas.beginPath();
|
|
8395
|
-
this.__drawPathByData(canvas, this.__.path);
|
|
8430
|
+
this.__drawPathByData(canvas, this.__.path, true);
|
|
8396
8431
|
}
|
|
8397
|
-
__drawPathByData(drawer, data) {
|
|
8398
|
-
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
8432
|
+
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8433
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
8399
8434
|
}
|
|
8400
|
-
__drawPathByBox(drawer) {
|
|
8435
|
+
__drawPathByBox(drawer, ignoreCornerRadius) {
|
|
8401
8436
|
const {x: x, y: y, width: width, height: height} = this.__layout.boxBounds;
|
|
8402
|
-
if (this.__.cornerRadius) {
|
|
8437
|
+
if (this.__.cornerRadius && !ignoreCornerRadius) {
|
|
8403
8438
|
const {cornerRadius: cornerRadius} = this.__;
|
|
8404
8439
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8405
8440
|
} else drawer.rect(x, y, width, height);
|
|
8441
|
+
drawer.closePath();
|
|
8406
8442
|
}
|
|
8407
8443
|
drawImagePlaceholder(_paint, canvas, renderOptions) {
|
|
8408
8444
|
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
@@ -8671,6 +8707,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8671
8707
|
get layoutLocked() {
|
|
8672
8708
|
return !this.layouter.running;
|
|
8673
8709
|
}
|
|
8710
|
+
get view() {
|
|
8711
|
+
return this.canvas && this.canvas.view;
|
|
8712
|
+
}
|
|
8674
8713
|
get FPS() {
|
|
8675
8714
|
return this.renderer ? this.renderer.FPS : 60;
|
|
8676
8715
|
}
|
|
@@ -8722,7 +8761,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8722
8761
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
8723
8762
|
if (this.isApp) this.__setApp();
|
|
8724
8763
|
this.__checkAutoLayout();
|
|
8725
|
-
this.view = canvas.view;
|
|
8726
8764
|
if (!parentApp) {
|
|
8727
8765
|
this.selector = Creator.selector(this);
|
|
8728
8766
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
@@ -9002,7 +9040,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
9002
9040
|
if (this.canvasManager) this.canvasManager.destroy();
|
|
9003
9041
|
}
|
|
9004
9042
|
if (this.canvas) this.canvas.destroy();
|
|
9005
|
-
this.config.view = this.
|
|
9043
|
+
this.config.view = this.parentApp = null;
|
|
9006
9044
|
if (this.userConfig) this.userConfig.view = null;
|
|
9007
9045
|
super.destroy();
|
|
9008
9046
|
setTimeout(() => {
|
|
@@ -9186,7 +9224,6 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9186
9224
|
if (startAngle || endAngle) {
|
|
9187
9225
|
if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
|
|
9188
9226
|
ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
|
|
9189
|
-
if (innerRadius < 1) closePath$2(path);
|
|
9190
9227
|
} else {
|
|
9191
9228
|
if (innerRadius < 1) {
|
|
9192
9229
|
ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
|
|
@@ -9194,16 +9231,16 @@ let Ellipse = class Ellipse extends UI {
|
|
|
9194
9231
|
}
|
|
9195
9232
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
9196
9233
|
}
|
|
9197
|
-
if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
9198
9234
|
} else {
|
|
9199
9235
|
if (startAngle || endAngle) {
|
|
9200
9236
|
moveTo$3(path, rx, ry);
|
|
9201
9237
|
ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false);
|
|
9202
|
-
closePath$2(path);
|
|
9203
9238
|
} else {
|
|
9204
9239
|
ellipse(path, rx, ry, rx, ry);
|
|
9205
9240
|
}
|
|
9206
9241
|
}
|
|
9242
|
+
closePath$2(path);
|
|
9243
|
+
if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
|
|
9207
9244
|
}
|
|
9208
9245
|
};
|
|
9209
9246
|
|
|
@@ -10064,7 +10101,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
10064
10101
|
ignoreRender(ui, false);
|
|
10065
10102
|
onLoadError(ui, event, error);
|
|
10066
10103
|
leafPaint.loadId = undefined;
|
|
10067
|
-
});
|
|
10104
|
+
}, paint.lod && image.getThumbSize());
|
|
10068
10105
|
if (ui.placeholderColor) {
|
|
10069
10106
|
if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
|
|
10070
10107
|
if (!image.ready) {
|
|
@@ -10304,10 +10341,12 @@ const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
|
|
|
10304
10341
|
function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
10305
10342
|
if (!paint.patternTask) {
|
|
10306
10343
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
10307
|
-
paint
|
|
10308
|
-
if (canvas.bounds.hit(ui.__nowWorld)) PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10344
|
+
PaintImage.createPattern(paint, ui, canvas, renderOptions);
|
|
10309
10345
|
ui.forceUpdate("surface");
|
|
10310
|
-
}),
|
|
10346
|
+
}), 0, () => {
|
|
10347
|
+
paint.patternTask = null;
|
|
10348
|
+
return canvas.bounds.hit(ui.__nowWorld);
|
|
10349
|
+
});
|
|
10311
10350
|
}
|
|
10312
10351
|
}
|
|
10313
10352
|
|