@leafer-draw/miniapp 1.0.6 → 1.0.8
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 +17 -33
- package/dist/miniapp.esm.js +17 -33
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +55 -94
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +7 -7
package/dist/miniapp.module.js
CHANGED
|
@@ -2958,7 +2958,6 @@ class PathCreator {
|
|
|
2958
2958
|
set path(value) { this.__path = value; }
|
|
2959
2959
|
get path() { return this.__path; }
|
|
2960
2960
|
constructor(path) {
|
|
2961
|
-
this.clearPath = this.beginPath;
|
|
2962
2961
|
this.set(path);
|
|
2963
2962
|
}
|
|
2964
2963
|
set(path) {
|
|
@@ -3040,6 +3039,9 @@ class PathCreator {
|
|
|
3040
3039
|
this.paint();
|
|
3041
3040
|
return this;
|
|
3042
3041
|
}
|
|
3042
|
+
clearPath() {
|
|
3043
|
+
return this.beginPath();
|
|
3044
|
+
}
|
|
3043
3045
|
paint() { }
|
|
3044
3046
|
}
|
|
3045
3047
|
|
|
@@ -3635,6 +3637,8 @@ const ImageManager = {
|
|
|
3635
3637
|
else {
|
|
3636
3638
|
if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
|
|
3637
3639
|
return true;
|
|
3640
|
+
else if (format === 'png' && !url.includes('.'))
|
|
3641
|
+
return true;
|
|
3638
3642
|
}
|
|
3639
3643
|
return false;
|
|
3640
3644
|
},
|
|
@@ -4426,13 +4430,10 @@ class LeafLayout {
|
|
|
4426
4430
|
update() {
|
|
4427
4431
|
const { leafer } = this.leaf;
|
|
4428
4432
|
if (leafer) {
|
|
4429
|
-
if (leafer.ready)
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
}
|
|
4433
|
-
else {
|
|
4433
|
+
if (leafer.ready)
|
|
4434
|
+
leafer.watcher.changed && leafer.layouter.layout();
|
|
4435
|
+
else
|
|
4434
4436
|
leafer.start();
|
|
4435
|
-
}
|
|
4436
4437
|
}
|
|
4437
4438
|
else {
|
|
4438
4439
|
let root = this.leaf;
|
|
@@ -5641,11 +5642,10 @@ let Leaf = class Leaf {
|
|
|
5641
5642
|
}
|
|
5642
5643
|
destroy() {
|
|
5643
5644
|
if (!this.destroyed) {
|
|
5644
|
-
|
|
5645
|
-
if (parent)
|
|
5645
|
+
if (this.parent)
|
|
5646
5646
|
this.remove();
|
|
5647
5647
|
if (this.children)
|
|
5648
|
-
this.
|
|
5648
|
+
this.clear();
|
|
5649
5649
|
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5650
5650
|
this.__.destroy();
|
|
5651
5651
|
this.__layout.destroy();
|
|
@@ -5959,7 +5959,7 @@ class LeafLevelList {
|
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
5961
|
|
|
5962
|
-
const version = "1.0.
|
|
5962
|
+
const version = "1.0.8";
|
|
5963
5963
|
|
|
5964
5964
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5965
5965
|
get allowBackgroundColor() { return false; }
|
|
@@ -6070,7 +6070,10 @@ Object.assign(Creator, {
|
|
|
6070
6070
|
});
|
|
6071
6071
|
function useCanvas(_canvasType, app) {
|
|
6072
6072
|
Platform.origin = {
|
|
6073
|
-
createCanvas: (width, height, _format) =>
|
|
6073
|
+
createCanvas: (width, height, _format) => {
|
|
6074
|
+
const data = { type: '2d', width, height };
|
|
6075
|
+
app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
|
|
6076
|
+
},
|
|
6074
6077
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
6075
6078
|
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
6076
6079
|
canvasSaveAs: (canvas, filePath, quality) => {
|
|
@@ -6824,12 +6827,8 @@ const State = {
|
|
|
6824
6827
|
};
|
|
6825
6828
|
const Transition = {
|
|
6826
6829
|
list: {},
|
|
6827
|
-
register(attrName, fn) {
|
|
6828
|
-
|
|
6829
|
-
},
|
|
6830
|
-
get(attrName) {
|
|
6831
|
-
return Transition.list[attrName];
|
|
6832
|
-
}
|
|
6830
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6831
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6833
6832
|
};
|
|
6834
6833
|
|
|
6835
6834
|
const { parse, objectToCanvasData } = PathConvert;
|
|
@@ -7275,8 +7274,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7275
7274
|
pen.set(path = []), this.__drawPathByBox(pen);
|
|
7276
7275
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
7277
7276
|
}
|
|
7278
|
-
getPathString(curve, pathForRender) {
|
|
7279
|
-
return PathConvert.stringify(this.getPath(curve, pathForRender));
|
|
7277
|
+
getPathString(curve, pathForRender, floatLength) {
|
|
7278
|
+
return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
|
|
7280
7279
|
}
|
|
7281
7280
|
load() {
|
|
7282
7281
|
this.__.__computePaint();
|
|
@@ -7685,11 +7684,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7685
7684
|
start() {
|
|
7686
7685
|
clearTimeout(this.__startTimer);
|
|
7687
7686
|
if (!this.running && this.canvas) {
|
|
7687
|
+
this.running = true;
|
|
7688
7688
|
this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START);
|
|
7689
7689
|
this.__controllers.forEach(item => item.start());
|
|
7690
7690
|
if (!this.isApp)
|
|
7691
7691
|
this.renderer.render();
|
|
7692
|
-
this.running = true;
|
|
7693
7692
|
}
|
|
7694
7693
|
}
|
|
7695
7694
|
stop() {
|
|
@@ -7795,12 +7794,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7795
7794
|
}
|
|
7796
7795
|
__changeFill(newValue) {
|
|
7797
7796
|
this.config.fill = newValue;
|
|
7798
|
-
if (this.canvas.allowBackgroundColor)
|
|
7797
|
+
if (this.canvas.allowBackgroundColor)
|
|
7799
7798
|
this.canvas.backgroundColor = newValue;
|
|
7800
|
-
|
|
7801
|
-
else {
|
|
7799
|
+
else
|
|
7802
7800
|
this.forceRender();
|
|
7803
|
-
}
|
|
7804
7801
|
}
|
|
7805
7802
|
__onCreated() {
|
|
7806
7803
|
this.created = true;
|
|
@@ -7867,13 +7864,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7867
7864
|
if (bind)
|
|
7868
7865
|
item = item.bind(bind);
|
|
7869
7866
|
this.__viewCompletedWait.push(item);
|
|
7870
|
-
if (this.viewCompleted)
|
|
7867
|
+
if (this.viewCompleted)
|
|
7871
7868
|
this.__checkViewCompleted(false);
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
if (!this.running)
|
|
7875
|
-
this.start();
|
|
7876
|
-
}
|
|
7869
|
+
else if (!this.running)
|
|
7870
|
+
this.start();
|
|
7877
7871
|
}
|
|
7878
7872
|
nextRender(item, bind, off) {
|
|
7879
7873
|
if (bind)
|
|
@@ -7887,9 +7881,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7887
7881
|
}
|
|
7888
7882
|
}
|
|
7889
7883
|
}
|
|
7890
|
-
else
|
|
7884
|
+
else
|
|
7891
7885
|
list.push(item);
|
|
7892
|
-
}
|
|
7893
7886
|
}
|
|
7894
7887
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
7895
7888
|
return needPlugin('view');
|
|
@@ -7933,10 +7926,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7933
7926
|
this.stop();
|
|
7934
7927
|
this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
|
|
7935
7928
|
this.__removeListenEvents();
|
|
7936
|
-
this.__controllers.forEach(item =>
|
|
7937
|
-
if (!(this.parent && item === this.interaction))
|
|
7938
|
-
item.destroy();
|
|
7939
|
-
});
|
|
7929
|
+
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
7940
7930
|
this.__controllers.length = 0;
|
|
7941
7931
|
if (!this.parent) {
|
|
7942
7932
|
if (this.selector)
|
|
@@ -8469,23 +8459,23 @@ let Text = class Text extends UI {
|
|
|
8469
8459
|
}
|
|
8470
8460
|
__updateTextDrawData() {
|
|
8471
8461
|
const data = this.__;
|
|
8472
|
-
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8473
|
-
}
|
|
8474
|
-
__updateBoxBounds() {
|
|
8475
|
-
const data = this.__;
|
|
8476
|
-
const layout = this.__layout;
|
|
8477
8462
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
8478
|
-
const autoWidth = data.__autoWidth;
|
|
8479
|
-
const autoHeight = data.__autoHeight;
|
|
8480
8463
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8481
8464
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8482
8465
|
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
8483
8466
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8484
8467
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8485
8468
|
data.__clipText = textOverflow !== 'show' && !data.__autoSize;
|
|
8469
|
+
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8470
|
+
}
|
|
8471
|
+
__updateBoxBounds() {
|
|
8472
|
+
const data = this.__;
|
|
8473
|
+
const layout = this.__layout;
|
|
8474
|
+
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8486
8475
|
this.__updateTextDrawData();
|
|
8487
8476
|
const { bounds } = data.__textDrawData;
|
|
8488
8477
|
const b = layout.boxBounds;
|
|
8478
|
+
console.log(bounds, autoWidth, autoHeight);
|
|
8489
8479
|
if (data.__lineHeight < fontSize)
|
|
8490
8480
|
spread(bounds, fontSize / 2);
|
|
8491
8481
|
if (autoWidth || autoHeight) {
|
|
@@ -8495,20 +8485,15 @@ let Text = class Text extends UI {
|
|
|
8495
8485
|
b.height = autoHeight ? bounds.height : data.height;
|
|
8496
8486
|
if (padding) {
|
|
8497
8487
|
const [top, right, bottom, left] = data.__padding;
|
|
8498
|
-
if (autoWidth)
|
|
8499
|
-
b.x -= left;
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
if (autoHeight) {
|
|
8503
|
-
b.y -= top;
|
|
8504
|
-
b.height += (bottom + top);
|
|
8505
|
-
}
|
|
8488
|
+
if (autoWidth)
|
|
8489
|
+
b.x -= left, b.width += (right + left);
|
|
8490
|
+
if (autoHeight)
|
|
8491
|
+
b.y -= top, b.height += (bottom + top);
|
|
8506
8492
|
}
|
|
8507
8493
|
this.__updateNaturalSize();
|
|
8508
8494
|
}
|
|
8509
|
-
else
|
|
8495
|
+
else
|
|
8510
8496
|
super.__updateBoxBounds();
|
|
8511
|
-
}
|
|
8512
8497
|
if (italic)
|
|
8513
8498
|
b.width += fontSize * 0.16;
|
|
8514
8499
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
@@ -8517,9 +8502,8 @@ let Text = class Text extends UI {
|
|
|
8517
8502
|
layout.renderChanged = true;
|
|
8518
8503
|
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8519
8504
|
}
|
|
8520
|
-
else
|
|
8505
|
+
else
|
|
8521
8506
|
data.__textBoxBounds = contentBounds;
|
|
8522
|
-
}
|
|
8523
8507
|
}
|
|
8524
8508
|
__updateRenderSpread() {
|
|
8525
8509
|
let width = super.__updateRenderSpread();
|
|
@@ -8632,11 +8616,7 @@ let Pen = class Pen extends Group {
|
|
|
8632
8616
|
this.add(path);
|
|
8633
8617
|
return this;
|
|
8634
8618
|
}
|
|
8635
|
-
beginPath() {
|
|
8636
|
-
this.__path.length = 0;
|
|
8637
|
-
this.paint();
|
|
8638
|
-
return this;
|
|
8639
|
-
}
|
|
8619
|
+
beginPath() { return this; }
|
|
8640
8620
|
moveTo(_x, _y) { return this; }
|
|
8641
8621
|
lineTo(_x, _y) { return this; }
|
|
8642
8622
|
bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) { return this; }
|
|
@@ -8663,7 +8643,7 @@ __decorate([
|
|
|
8663
8643
|
penPathType()
|
|
8664
8644
|
], Pen.prototype, "path", void 0);
|
|
8665
8645
|
Pen = __decorate([
|
|
8666
|
-
useModule(PathCreator, ['set', '
|
|
8646
|
+
useModule(PathCreator, ['set', 'path', 'paint']),
|
|
8667
8647
|
registerUI()
|
|
8668
8648
|
], Pen);
|
|
8669
8649
|
function penPathType() {
|
|
@@ -8679,14 +8659,10 @@ function fillText(ui, canvas) {
|
|
|
8679
8659
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
8680
8660
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8681
8661
|
row = rows[i];
|
|
8682
|
-
if (row.text)
|
|
8662
|
+
if (row.text)
|
|
8683
8663
|
canvas.fillText(row.text, row.x, row.y);
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
row.data.forEach(charData => {
|
|
8687
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
8688
|
-
});
|
|
8689
|
-
}
|
|
8664
|
+
else if (row.data)
|
|
8665
|
+
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
8690
8666
|
if (decorationY)
|
|
8691
8667
|
canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
|
|
8692
8668
|
}
|
|
@@ -8752,12 +8728,10 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
|
|
|
8752
8728
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
8753
8729
|
fillText(ui, out);
|
|
8754
8730
|
out.blendMode = 'normal';
|
|
8755
|
-
if (ui.__worldFlipped)
|
|
8731
|
+
if (ui.__worldFlipped)
|
|
8756
8732
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8757
|
-
|
|
8758
|
-
else {
|
|
8733
|
+
else
|
|
8759
8734
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
8760
|
-
}
|
|
8761
8735
|
out.recycle(ui.__nowWorld);
|
|
8762
8736
|
}
|
|
8763
8737
|
function drawTextStroke(ui, canvas) {
|
|
@@ -8765,14 +8739,10 @@ function drawTextStroke(ui, canvas) {
|
|
|
8765
8739
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
8766
8740
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8767
8741
|
row = rows[i];
|
|
8768
|
-
if (row.text)
|
|
8742
|
+
if (row.text)
|
|
8769
8743
|
canvas.strokeText(row.text, row.x, row.y);
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
row.data.forEach(charData => {
|
|
8773
|
-
canvas.strokeText(charData.char, charData.x, row.y);
|
|
8774
|
-
});
|
|
8775
|
-
}
|
|
8744
|
+
else if (row.data)
|
|
8745
|
+
row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
|
|
8776
8746
|
if (decorationY)
|
|
8777
8747
|
canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
|
|
8778
8748
|
}
|
|
@@ -8825,12 +8795,10 @@ function stroke(stroke, ui, canvas) {
|
|
|
8825
8795
|
out.stroke();
|
|
8826
8796
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
8827
8797
|
out.clearWorld(ui.__layout.renderBounds);
|
|
8828
|
-
if (ui.__worldFlipped)
|
|
8798
|
+
if (ui.__worldFlipped)
|
|
8829
8799
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8830
|
-
|
|
8831
|
-
else {
|
|
8800
|
+
else
|
|
8832
8801
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
8833
|
-
}
|
|
8834
8802
|
out.recycle(ui.__nowWorld);
|
|
8835
8803
|
break;
|
|
8836
8804
|
}
|
|
@@ -8865,12 +8833,10 @@ function strokes(strokes, ui, canvas) {
|
|
|
8865
8833
|
drawStrokesStyle(strokes, false, ui, out);
|
|
8866
8834
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
8867
8835
|
out.clearWorld(renderBounds);
|
|
8868
|
-
if (ui.__worldFlipped)
|
|
8836
|
+
if (ui.__worldFlipped)
|
|
8869
8837
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
8870
|
-
|
|
8871
|
-
else {
|
|
8838
|
+
else
|
|
8872
8839
|
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
8873
|
-
}
|
|
8874
8840
|
out.recycle(ui.__nowWorld);
|
|
8875
8841
|
break;
|
|
8876
8842
|
}
|
|
@@ -8934,12 +8900,7 @@ function compute(attrName, ui) {
|
|
|
8934
8900
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
8935
8901
|
if (leafPaints.length && leafPaints[0].image)
|
|
8936
8902
|
hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
|
|
8937
|
-
|
|
8938
|
-
data.__pixelFill = hasOpacityPixel;
|
|
8939
|
-
}
|
|
8940
|
-
else {
|
|
8941
|
-
data.__pixelStroke = hasOpacityPixel;
|
|
8942
|
-
}
|
|
8903
|
+
attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
|
|
8943
8904
|
}
|
|
8944
8905
|
function getLeafPaint(attrName, paint, ui) {
|
|
8945
8906
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|