@leafer/miniapp 2.1.0 → 2.1.1
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.module.js +44 -25
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +25 -25
package/dist/miniapp.module.js
CHANGED
|
@@ -3082,7 +3082,7 @@ const PathConvert = {
|
|
|
3082
3082
|
case M$a:
|
|
3083
3083
|
x = old[i + 1];
|
|
3084
3084
|
y = old[i + 2];
|
|
3085
|
-
data.push(M$a, x, y);
|
|
3085
|
+
data.push(lastCommand === command ? L$a : M$a, x, y);
|
|
3086
3086
|
i += 3;
|
|
3087
3087
|
break;
|
|
3088
3088
|
|
|
@@ -6075,12 +6075,13 @@ const LeafBounds = {
|
|
|
6075
6075
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
6076
6076
|
},
|
|
6077
6077
|
__updateLocalBounds() {
|
|
6078
|
-
const layout = this.__layout;
|
|
6078
|
+
const layout = this.__layout, data = this.__;
|
|
6079
6079
|
if (layout.boxChanged) {
|
|
6080
|
-
if (!
|
|
6080
|
+
if (!data.__pathInputed) this.__updatePath();
|
|
6081
6081
|
this.__updateRenderPath();
|
|
6082
6082
|
this.__updateBoxBounds();
|
|
6083
6083
|
layout.resized = "inner";
|
|
6084
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6084
6085
|
}
|
|
6085
6086
|
if (layout.localBoxChanged) {
|
|
6086
6087
|
if (this.__local) this.__updateLocalBoxBounds();
|
|
@@ -6103,6 +6104,7 @@ const LeafBounds = {
|
|
|
6103
6104
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true;
|
|
6104
6105
|
if (this.parent) this.parent.__layout.strokeChange();
|
|
6105
6106
|
layout.resized = "inner";
|
|
6107
|
+
if (data.__strokeGeometry) data.__strokeGeometry = undefined;
|
|
6106
6108
|
}
|
|
6107
6109
|
if (layout.renderChanged) {
|
|
6108
6110
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -7079,7 +7081,7 @@ class LeafLevelList {
|
|
|
7079
7081
|
}
|
|
7080
7082
|
}
|
|
7081
7083
|
|
|
7082
|
-
const version = "2.1.
|
|
7084
|
+
const version = "2.1.1";
|
|
7083
7085
|
|
|
7084
7086
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
7085
7087
|
get allowBackgroundColor() {
|
|
@@ -8313,7 +8315,7 @@ class UIData extends LeafData {
|
|
|
8313
8315
|
const isStr = isString(value);
|
|
8314
8316
|
if (isStr || value && isObject(value[0])) {
|
|
8315
8317
|
this.__setInput("path", value);
|
|
8316
|
-
this._path = isStr ? parse(value) : objectToCanvasData(value);
|
|
8318
|
+
this._path = isStr ? parse(value, this.__useArrow) : objectToCanvasData(value);
|
|
8317
8319
|
} else {
|
|
8318
8320
|
if (this.__input) this.__removeInput("path");
|
|
8319
8321
|
this._path = value;
|
|
@@ -8428,7 +8430,11 @@ class EllipseData extends UIData {
|
|
|
8428
8430
|
}
|
|
8429
8431
|
}
|
|
8430
8432
|
|
|
8431
|
-
class PolygonData extends
|
|
8433
|
+
class PolygonData extends UIData {
|
|
8434
|
+
get __usePathBox() {
|
|
8435
|
+
return this.points || this.__pathInputed;
|
|
8436
|
+
}
|
|
8437
|
+
}
|
|
8432
8438
|
|
|
8433
8439
|
class StarData extends UIData {
|
|
8434
8440
|
get __boxStroke() {
|
|
@@ -8539,7 +8545,7 @@ const UIBounds = {
|
|
|
8539
8545
|
if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
|
|
8540
8546
|
boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
|
|
8541
8547
|
if (!data.__boxStroke || data.__useArrow) {
|
|
8542
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
|
|
8548
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : (data.strokeJoin === "miter" ? 10 : 1) * spread;
|
|
8543
8549
|
const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
|
|
8544
8550
|
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
|
|
8545
8551
|
}
|
|
@@ -9843,7 +9849,7 @@ __decorate([ resizeType() ], Canvas.prototype, "contextSettings", void 0);
|
|
|
9843
9849
|
|
|
9844
9850
|
Canvas = __decorate([ registerUI() ], Canvas);
|
|
9845
9851
|
|
|
9846
|
-
const {copyAndSpread: copyAndSpread$3, includes: includes,
|
|
9852
|
+
const {copyAndSpread: copyAndSpread$3, includes: includes, setList: setList} = BoundsHelper, {stintSet: stintSet$3} = DataHelper;
|
|
9847
9853
|
|
|
9848
9854
|
let Text = class Text extends UI {
|
|
9849
9855
|
get __tag() {
|
|
@@ -9871,9 +9877,10 @@ let Text = class Text extends UI {
|
|
|
9871
9877
|
const {fontSize: fontSize, italic: italic, padding: padding, __autoWidth: autoWidth, __autoHeight: autoHeight} = data;
|
|
9872
9878
|
this.__updateTextDrawData();
|
|
9873
9879
|
const {bounds: contentBounds} = data.__textDrawData;
|
|
9880
|
+
console.log(contentBounds);
|
|
9874
9881
|
const b = layout.boxBounds;
|
|
9875
9882
|
layout.contentBounds = contentBounds;
|
|
9876
|
-
if (data.__lineHeight < fontSize)
|
|
9883
|
+
if (data.__lineHeight < fontSize) layout.renderChanged = true;
|
|
9877
9884
|
if (autoWidth || autoHeight) {
|
|
9878
9885
|
b.x = autoWidth ? contentBounds.x : 0;
|
|
9879
9886
|
b.y = autoHeight ? contentBounds.y : 0;
|
|
@@ -9893,6 +9900,8 @@ let Text = class Text extends UI {
|
|
|
9893
9900
|
__updateRenderSpread() {
|
|
9894
9901
|
let spread = super.__updateRenderSpread();
|
|
9895
9902
|
if (!spread) spread = this.isOverflow ? 1 : 0;
|
|
9903
|
+
const {__lineHeight: __lineHeight, fontSize: fontSize} = this.__;
|
|
9904
|
+
if (__lineHeight < fontSize) spread = FourNumberHelper.max(spread, (fontSize - __lineHeight) / 2);
|
|
9896
9905
|
return spread;
|
|
9897
9906
|
}
|
|
9898
9907
|
__updateRenderBounds() {
|
|
@@ -11978,8 +11987,8 @@ function compute(attrName, ui) {
|
|
|
11978
11987
|
}
|
|
11979
11988
|
}
|
|
11980
11989
|
}
|
|
11981
|
-
data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
11982
11990
|
if (leafPaints.length) {
|
|
11991
|
+
data["_" + attrName] = leafPaints;
|
|
11983
11992
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
11984
11993
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11985
11994
|
isTransparent = true;
|
|
@@ -11994,6 +12003,7 @@ function compute(attrName, ui) {
|
|
|
11994
12003
|
}
|
|
11995
12004
|
} else {
|
|
11996
12005
|
data.__removePaint(attrName, false);
|
|
12006
|
+
data["_" + attrName] = "";
|
|
11997
12007
|
}
|
|
11998
12008
|
}
|
|
11999
12009
|
|
|
@@ -12143,11 +12153,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
12143
12153
|
needUpdate = false;
|
|
12144
12154
|
}
|
|
12145
12155
|
}
|
|
12156
|
+
if (paint.mode === "brush") PaintImage.brush(leafPaint);
|
|
12146
12157
|
if (!leafPaint.data) {
|
|
12147
12158
|
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
12148
|
-
const {transform: transform} = leafPaint.data, {opacity: opacity
|
|
12149
|
-
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
12150
|
-
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
12159
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity} = paint;
|
|
12160
|
+
const clip = (transform && !transform.onlyScale || data.path || data.cornerRadius) && !leafPaint.brush;
|
|
12161
|
+
if (clip || opacity && opacity < 1 || paint.blendMode) leafPaint.complex = clip ? 2 : true;
|
|
12151
12162
|
}
|
|
12152
12163
|
if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
|
|
12153
12164
|
return needUpdate;
|
|
@@ -12237,6 +12248,7 @@ function getPatternData(paint, box, image) {
|
|
|
12237
12248
|
break;
|
|
12238
12249
|
|
|
12239
12250
|
case "repeat":
|
|
12251
|
+
case "brush":
|
|
12240
12252
|
if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
|
|
12241
12253
|
if (!repeat) data.repeat = "repeat";
|
|
12242
12254
|
const count = isObject(repeat);
|
|
@@ -12377,7 +12389,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12377
12389
|
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12378
12390
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
12379
12391
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
12380
|
-
const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12392
|
+
const {image: image, brush: brush, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
12381
12393
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
12382
12394
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
12383
12395
|
width *= scaleX;
|
|
@@ -12385,6 +12397,10 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12385
12397
|
if (gap) {
|
|
12386
12398
|
xGap = gap.x * scaleX / abs$7(data.scaleX || 1);
|
|
12387
12399
|
yGap = gap.y * scaleY / abs$7(data.scaleY || 1);
|
|
12400
|
+
if (brush) {
|
|
12401
|
+
const brushScale = PaintImage.getBrushScale(paint, ui);
|
|
12402
|
+
xGap /= brushScale, yGap /= brushScale;
|
|
12403
|
+
}
|
|
12388
12404
|
}
|
|
12389
12405
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
12390
12406
|
scaleX *= getFloorScale(width + (xGap || 0));
|
|
@@ -12394,7 +12410,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
12394
12410
|
scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
12395
12411
|
}
|
|
12396
12412
|
const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
12397
|
-
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12413
|
+
const pattern = brush ? imageCanvas : image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
12398
12414
|
paint.style = pattern;
|
|
12399
12415
|
paint.patternId = id;
|
|
12400
12416
|
}
|
|
@@ -12415,9 +12431,9 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
12415
12431
|
|
|
12416
12432
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
12417
12433
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
12418
|
-
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12434
|
+
const {image: image, brush: brush, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
12419
12435
|
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
12420
|
-
return false;
|
|
12436
|
+
if (!(brush && paint.style)) return false;
|
|
12421
12437
|
} else {
|
|
12422
12438
|
if (drawImage) {
|
|
12423
12439
|
if (data.repeat) {
|
|
@@ -12431,18 +12447,18 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
12431
12447
|
canvas.fillStyle = paint.style || "#000";
|
|
12432
12448
|
canvas.fill();
|
|
12433
12449
|
}
|
|
12434
|
-
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12435
|
-
return true;
|
|
12436
12450
|
} else {
|
|
12437
12451
|
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
12438
|
-
return false;
|
|
12452
|
+
if (!(brush && paint.style)) return false;
|
|
12439
12453
|
}
|
|
12440
12454
|
}
|
|
12455
|
+
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
12456
|
+
return true;
|
|
12441
12457
|
}
|
|
12442
12458
|
|
|
12443
12459
|
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
12444
|
-
const {data: data, image: image, complex: complex} = paint;
|
|
12445
|
-
let {width: width, height: height} = image;
|
|
12460
|
+
const {data: data, image: image, brush: brush, complex: complex} = paint;
|
|
12461
|
+
let {width: width, height: height} = image, view = brush || image;
|
|
12446
12462
|
if (complex) {
|
|
12447
12463
|
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
12448
12464
|
canvas.save();
|
|
@@ -12450,16 +12466,17 @@ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions)
|
|
|
12450
12466
|
blendMode && (canvas.blendMode = blendMode);
|
|
12451
12467
|
opacity && (canvas.opacity *= opacity);
|
|
12452
12468
|
transform && canvas.transform(transform);
|
|
12453
|
-
|
|
12469
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12454
12470
|
canvas.restore();
|
|
12455
12471
|
} else {
|
|
12456
12472
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12457
|
-
|
|
12473
|
+
view.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12458
12474
|
}
|
|
12459
12475
|
}
|
|
12460
12476
|
|
|
12461
12477
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
12462
12478
|
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
12479
|
+
if (paint.brush) PaintImage.addBrushScale(scaleData, paint, ui);
|
|
12463
12480
|
if (canvas) {
|
|
12464
12481
|
const {pixelRatio: pixelRatio} = canvas;
|
|
12465
12482
|
scaleData.scaleX *= pixelRatio;
|
|
@@ -12476,6 +12493,7 @@ function recycleImage(attrName, data) {
|
|
|
12476
12493
|
const paints = data["_" + attrName];
|
|
12477
12494
|
if (isArray(paints)) {
|
|
12478
12495
|
let paint, image, recycleMap, input, url;
|
|
12496
|
+
const ui = data.__leaf;
|
|
12479
12497
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
12480
12498
|
paint = paints[i];
|
|
12481
12499
|
image = paint.image;
|
|
@@ -12484,7 +12502,8 @@ function recycleImage(attrName, data) {
|
|
|
12484
12502
|
if (!recycleMap) recycleMap = {};
|
|
12485
12503
|
recycleMap[url] = true;
|
|
12486
12504
|
ImageManager.recyclePaint(paint);
|
|
12487
|
-
if (
|
|
12505
|
+
if (paint.brush) PaintImage.recycleBrush(paint, ui);
|
|
12506
|
+
if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, ui);
|
|
12488
12507
|
if (image.loading) {
|
|
12489
12508
|
if (!input) {
|
|
12490
12509
|
input = data.__input && data.__input[attrName] || [];
|