@leafer-ui/miniapp 1.5.2 → 1.6.0
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 +68 -71
- package/dist/miniapp.cjs.map +1 -1
- package/dist/miniapp.esm.js +68 -71
- package/dist/miniapp.esm.js.map +1 -1
- 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 +303 -192
- package/dist/miniapp.module.js.map +1 -1
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -11
- package/src/core.ts +143 -0
- package/src/index.ts +2 -2
- package/types/index.d.ts +8 -1
package/dist/miniapp.esm.js
CHANGED
|
@@ -382,7 +382,6 @@ function updateChange(updateList) {
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
const { worldBounds } = LeafBoundsHelper;
|
|
385
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
386
385
|
class LayoutBlockData {
|
|
387
386
|
constructor(list) {
|
|
388
387
|
this.updatedBounds = new Bounds();
|
|
@@ -396,13 +395,7 @@ class LayoutBlockData {
|
|
|
396
395
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
397
396
|
}
|
|
398
397
|
setAfter() {
|
|
399
|
-
|
|
400
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
401
|
-
this.afterBounds.set(bigBounds);
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
405
|
-
}
|
|
398
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
406
399
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
407
400
|
}
|
|
408
401
|
merge(data) {
|
|
@@ -604,6 +597,13 @@ class Renderer {
|
|
|
604
597
|
requestLayout() {
|
|
605
598
|
this.target.emit(LayoutEvent.REQUEST);
|
|
606
599
|
}
|
|
600
|
+
checkRender() {
|
|
601
|
+
if (this.running) {
|
|
602
|
+
if (this.changed && this.canvas.view)
|
|
603
|
+
this.render();
|
|
604
|
+
this.target.emit(RenderEvent.NEXT);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
607
|
render(callback) {
|
|
608
608
|
if (!(this.running && this.canvas.view))
|
|
609
609
|
return this.update();
|
|
@@ -612,8 +612,6 @@ class Renderer {
|
|
|
612
612
|
this.totalBounds = new Bounds();
|
|
613
613
|
debug.log(target.innerName, '--->');
|
|
614
614
|
try {
|
|
615
|
-
if (!target.isApp)
|
|
616
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
617
615
|
this.emitRender(RenderEvent.START);
|
|
618
616
|
this.renderOnce(callback);
|
|
619
617
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -681,20 +679,12 @@ class Renderer {
|
|
|
681
679
|
}
|
|
682
680
|
clipRender(block) {
|
|
683
681
|
const t = Run.start('PartRender');
|
|
684
|
-
const { canvas } = this;
|
|
685
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
686
|
-
const includes = block.includes(this.target.__world);
|
|
687
|
-
const realBounds = new Bounds(bounds);
|
|
682
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
688
683
|
canvas.save();
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
694
|
-
canvas.clearWorld(bounds, true);
|
|
695
|
-
canvas.clipWorld(bounds, true);
|
|
696
|
-
}
|
|
697
|
-
this.__render(bounds, includes, realBounds);
|
|
684
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
685
|
+
canvas.clearWorld(bounds, true);
|
|
686
|
+
canvas.clipWorld(bounds, true);
|
|
687
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
698
688
|
canvas.restore();
|
|
699
689
|
Run.end(t);
|
|
700
690
|
}
|
|
@@ -708,23 +698,17 @@ class Renderer {
|
|
|
708
698
|
Run.end(t);
|
|
709
699
|
}
|
|
710
700
|
__render(bounds, includes, realBounds) {
|
|
711
|
-
const options =
|
|
701
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
712
702
|
if (this.needFill)
|
|
713
|
-
|
|
703
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
714
704
|
if (Debug.showRepaint)
|
|
715
|
-
|
|
716
|
-
this.target.__render(
|
|
705
|
+
Debug.drawRepaint(canvas, bounds);
|
|
706
|
+
this.target.__render(canvas, options);
|
|
717
707
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
718
708
|
this.renderOptions = options;
|
|
719
709
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (Debug.showBoundsView)
|
|
723
|
-
this.renderBoundsView(options);
|
|
724
|
-
this.canvas.updateRender(realBounds);
|
|
725
|
-
}
|
|
726
|
-
renderHitView(_options) { }
|
|
727
|
-
renderBoundsView(_options) { }
|
|
710
|
+
canvas.updateRender(realBounds);
|
|
711
|
+
}
|
|
728
712
|
addBlock(block) {
|
|
729
713
|
if (!this.updateBlocks)
|
|
730
714
|
this.updateBlocks = [];
|
|
@@ -740,17 +724,24 @@ class Renderer {
|
|
|
740
724
|
}
|
|
741
725
|
}
|
|
742
726
|
__requestRender() {
|
|
727
|
+
const target = this.target;
|
|
728
|
+
if (target.parentApp)
|
|
729
|
+
return target.parentApp.renderer.update(false);
|
|
743
730
|
if (this.requestTime)
|
|
744
731
|
return;
|
|
745
732
|
const requestTime = this.requestTime = Date.now();
|
|
746
733
|
Platform.requestRender(() => {
|
|
747
734
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
748
735
|
this.requestTime = 0;
|
|
749
|
-
if (
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
736
|
+
if (target.isApp) {
|
|
737
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
738
|
+
target.children.forEach(leafer => {
|
|
739
|
+
leafer.renderer.FPS = this.FPS;
|
|
740
|
+
leafer.renderer.checkRender();
|
|
741
|
+
});
|
|
742
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
753
743
|
}
|
|
744
|
+
this.checkRender();
|
|
754
745
|
});
|
|
755
746
|
}
|
|
756
747
|
__onResize(e) {
|
|
@@ -808,6 +799,7 @@ class Renderer {
|
|
|
808
799
|
}
|
|
809
800
|
}
|
|
810
801
|
}
|
|
802
|
+
Renderer.clipSpread = 10;
|
|
811
803
|
|
|
812
804
|
const { hitRadiusPoint } = BoundsHelper;
|
|
813
805
|
class Picker {
|
|
@@ -1432,9 +1424,11 @@ const tempBox = new Bounds();
|
|
|
1432
1424
|
const tempPoint = {};
|
|
1433
1425
|
const tempScaleData = {};
|
|
1434
1426
|
function createData(leafPaint, image, paint, box) {
|
|
1435
|
-
const { blendMode, sync } = paint;
|
|
1427
|
+
const { blendMode, changeful, sync } = paint;
|
|
1436
1428
|
if (blendMode)
|
|
1437
1429
|
leafPaint.blendMode = blendMode;
|
|
1430
|
+
if (changeful)
|
|
1431
|
+
leafPaint.changeful = changeful;
|
|
1438
1432
|
if (sync)
|
|
1439
1433
|
leafPaint.sync = sync;
|
|
1440
1434
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1699,40 +1693,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1699
1693
|
};
|
|
1700
1694
|
|
|
1701
1695
|
const { abs } = Math;
|
|
1702
|
-
function checkImage(ui, canvas, paint,
|
|
1696
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1703
1697
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1704
|
-
const { pixelRatio } = canvas;
|
|
1705
|
-
if (!
|
|
1698
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1699
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1706
1700
|
return false;
|
|
1707
1701
|
}
|
|
1708
1702
|
else {
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
let { width, height } = data;
|
|
1713
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1714
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1715
|
-
if (data.scaleX) {
|
|
1716
|
-
width *= data.scaleX;
|
|
1717
|
-
height *= data.scaleY;
|
|
1718
|
-
}
|
|
1719
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
1703
|
+
if (allowDraw) {
|
|
1704
|
+
if (data.repeat) {
|
|
1705
|
+
allowDraw = false;
|
|
1720
1706
|
}
|
|
1721
1707
|
else {
|
|
1722
|
-
|
|
1708
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1709
|
+
let { width, height } = data;
|
|
1710
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1711
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1712
|
+
if (data.scaleX) {
|
|
1713
|
+
width *= data.scaleX;
|
|
1714
|
+
height *= data.scaleY;
|
|
1715
|
+
}
|
|
1716
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
1717
|
+
}
|
|
1723
1718
|
}
|
|
1724
1719
|
}
|
|
1725
|
-
if (
|
|
1726
|
-
canvas
|
|
1727
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1728
|
-
if (paint.blendMode)
|
|
1729
|
-
canvas.blendMode = paint.blendMode;
|
|
1730
|
-
if (data.opacity)
|
|
1731
|
-
canvas.opacity *= data.opacity;
|
|
1732
|
-
if (data.transform)
|
|
1733
|
-
canvas.transform(data.transform);
|
|
1734
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1735
|
-
canvas.restore();
|
|
1720
|
+
if (allowDraw) {
|
|
1721
|
+
drawImage(ui, canvas, paint, data);
|
|
1736
1722
|
return true;
|
|
1737
1723
|
}
|
|
1738
1724
|
else {
|
|
@@ -1753,13 +1739,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1753
1739
|
}
|
|
1754
1740
|
}
|
|
1755
1741
|
}
|
|
1742
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1743
|
+
canvas.save();
|
|
1744
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1745
|
+
if (paint.blendMode)
|
|
1746
|
+
canvas.blendMode = paint.blendMode;
|
|
1747
|
+
if (data.opacity)
|
|
1748
|
+
canvas.opacity *= data.opacity;
|
|
1749
|
+
if (data.transform)
|
|
1750
|
+
canvas.transform(data.transform);
|
|
1751
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1752
|
+
canvas.restore();
|
|
1753
|
+
}
|
|
1756
1754
|
|
|
1757
1755
|
function recycleImage(attrName, data) {
|
|
1758
1756
|
const paints = data['_' + attrName];
|
|
1759
1757
|
if (paints instanceof Array) {
|
|
1760
|
-
let image, recycleMap, input, url;
|
|
1758
|
+
let paint, image, recycleMap, input, url;
|
|
1761
1759
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1762
|
-
|
|
1760
|
+
paint = paints[i];
|
|
1761
|
+
image = paint.image;
|
|
1763
1762
|
url = image && image.url;
|
|
1764
1763
|
if (url) {
|
|
1765
1764
|
if (!recycleMap)
|
|
@@ -1774,8 +1773,6 @@ function recycleImage(attrName, data) {
|
|
|
1774
1773
|
}
|
|
1775
1774
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1776
1775
|
}
|
|
1777
|
-
else
|
|
1778
|
-
paints[i].style = null;
|
|
1779
1776
|
}
|
|
1780
1777
|
}
|
|
1781
1778
|
return recycleMap;
|
|
@@ -1954,7 +1951,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
1954
1951
|
const offsetOutBounds = {};
|
|
1955
1952
|
function innerShadow(ui, current, shape) {
|
|
1956
1953
|
let copyBounds, spreadScale;
|
|
1957
|
-
const { __nowWorld: nowWorld, __layout
|
|
1954
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1958
1955
|
const { innerShadow } = ui.__;
|
|
1959
1956
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1960
1957
|
const other = current.getSameCanvas();
|