@leafer-draw/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 +260 -165
- 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 +9 -8
- 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
|
@@ -381,7 +381,6 @@ function updateChange(updateList) {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
const { worldBounds } = LeafBoundsHelper;
|
|
384
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
385
384
|
class LayoutBlockData {
|
|
386
385
|
constructor(list) {
|
|
387
386
|
this.updatedBounds = new Bounds();
|
|
@@ -395,13 +394,7 @@ class LayoutBlockData {
|
|
|
395
394
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
396
395
|
}
|
|
397
396
|
setAfter() {
|
|
398
|
-
|
|
399
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
400
|
-
this.afterBounds.set(bigBounds);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
404
|
-
}
|
|
397
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
405
398
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
406
399
|
}
|
|
407
400
|
merge(data) {
|
|
@@ -603,6 +596,13 @@ class Renderer {
|
|
|
603
596
|
requestLayout() {
|
|
604
597
|
this.target.emit(LayoutEvent.REQUEST);
|
|
605
598
|
}
|
|
599
|
+
checkRender() {
|
|
600
|
+
if (this.running) {
|
|
601
|
+
if (this.changed && this.canvas.view)
|
|
602
|
+
this.render();
|
|
603
|
+
this.target.emit(RenderEvent.NEXT);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
606
|
render(callback) {
|
|
607
607
|
if (!(this.running && this.canvas.view))
|
|
608
608
|
return this.update();
|
|
@@ -611,8 +611,6 @@ class Renderer {
|
|
|
611
611
|
this.totalBounds = new Bounds();
|
|
612
612
|
debug.log(target.innerName, '--->');
|
|
613
613
|
try {
|
|
614
|
-
if (!target.isApp)
|
|
615
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
616
614
|
this.emitRender(RenderEvent.START);
|
|
617
615
|
this.renderOnce(callback);
|
|
618
616
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -680,20 +678,12 @@ class Renderer {
|
|
|
680
678
|
}
|
|
681
679
|
clipRender(block) {
|
|
682
680
|
const t = Run.start('PartRender');
|
|
683
|
-
const { canvas } = this;
|
|
684
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
685
|
-
const includes = block.includes(this.target.__world);
|
|
686
|
-
const realBounds = new Bounds(bounds);
|
|
681
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
687
682
|
canvas.save();
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
693
|
-
canvas.clearWorld(bounds, true);
|
|
694
|
-
canvas.clipWorld(bounds, true);
|
|
695
|
-
}
|
|
696
|
-
this.__render(bounds, includes, realBounds);
|
|
683
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
684
|
+
canvas.clearWorld(bounds, true);
|
|
685
|
+
canvas.clipWorld(bounds, true);
|
|
686
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
697
687
|
canvas.restore();
|
|
698
688
|
Run.end(t);
|
|
699
689
|
}
|
|
@@ -707,23 +697,17 @@ class Renderer {
|
|
|
707
697
|
Run.end(t);
|
|
708
698
|
}
|
|
709
699
|
__render(bounds, includes, realBounds) {
|
|
710
|
-
const options =
|
|
700
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
711
701
|
if (this.needFill)
|
|
712
|
-
|
|
702
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
713
703
|
if (Debug.showRepaint)
|
|
714
|
-
|
|
715
|
-
this.target.__render(
|
|
704
|
+
Debug.drawRepaint(canvas, bounds);
|
|
705
|
+
this.target.__render(canvas, options);
|
|
716
706
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
717
707
|
this.renderOptions = options;
|
|
718
708
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (Debug.showBoundsView)
|
|
722
|
-
this.renderBoundsView(options);
|
|
723
|
-
this.canvas.updateRender(realBounds);
|
|
724
|
-
}
|
|
725
|
-
renderHitView(_options) { }
|
|
726
|
-
renderBoundsView(_options) { }
|
|
709
|
+
canvas.updateRender(realBounds);
|
|
710
|
+
}
|
|
727
711
|
addBlock(block) {
|
|
728
712
|
if (!this.updateBlocks)
|
|
729
713
|
this.updateBlocks = [];
|
|
@@ -739,17 +723,24 @@ class Renderer {
|
|
|
739
723
|
}
|
|
740
724
|
}
|
|
741
725
|
__requestRender() {
|
|
726
|
+
const target = this.target;
|
|
727
|
+
if (target.parentApp)
|
|
728
|
+
return target.parentApp.renderer.update(false);
|
|
742
729
|
if (this.requestTime)
|
|
743
730
|
return;
|
|
744
731
|
const requestTime = this.requestTime = Date.now();
|
|
745
732
|
Platform.requestRender(() => {
|
|
746
733
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
747
734
|
this.requestTime = 0;
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
735
|
+
if (target.isApp) {
|
|
736
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
737
|
+
target.children.forEach(leafer => {
|
|
738
|
+
leafer.renderer.FPS = this.FPS;
|
|
739
|
+
leafer.renderer.checkRender();
|
|
740
|
+
});
|
|
741
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
752
742
|
}
|
|
743
|
+
this.checkRender();
|
|
753
744
|
});
|
|
754
745
|
}
|
|
755
746
|
__onResize(e) {
|
|
@@ -807,6 +798,7 @@ class Renderer {
|
|
|
807
798
|
}
|
|
808
799
|
}
|
|
809
800
|
}
|
|
801
|
+
Renderer.clipSpread = 10;
|
|
810
802
|
|
|
811
803
|
Object.assign(Creator, {
|
|
812
804
|
watcher: (target, options) => new Watcher(target, options),
|
|
@@ -1169,9 +1161,11 @@ const tempBox = new Bounds();
|
|
|
1169
1161
|
const tempPoint = {};
|
|
1170
1162
|
const tempScaleData = {};
|
|
1171
1163
|
function createData(leafPaint, image, paint, box) {
|
|
1172
|
-
const { blendMode, sync } = paint;
|
|
1164
|
+
const { blendMode, changeful, sync } = paint;
|
|
1173
1165
|
if (blendMode)
|
|
1174
1166
|
leafPaint.blendMode = blendMode;
|
|
1167
|
+
if (changeful)
|
|
1168
|
+
leafPaint.changeful = changeful;
|
|
1175
1169
|
if (sync)
|
|
1176
1170
|
leafPaint.sync = sync;
|
|
1177
1171
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1436,40 +1430,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1436
1430
|
};
|
|
1437
1431
|
|
|
1438
1432
|
const { abs } = Math;
|
|
1439
|
-
function checkImage(ui, canvas, paint,
|
|
1433
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1440
1434
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1441
|
-
const { pixelRatio } = canvas;
|
|
1442
|
-
if (!
|
|
1435
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1436
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1443
1437
|
return false;
|
|
1444
1438
|
}
|
|
1445
1439
|
else {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
let { width, height } = data;
|
|
1450
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1451
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1452
|
-
if (data.scaleX) {
|
|
1453
|
-
width *= data.scaleX;
|
|
1454
|
-
height *= data.scaleY;
|
|
1455
|
-
}
|
|
1456
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
1440
|
+
if (allowDraw) {
|
|
1441
|
+
if (data.repeat) {
|
|
1442
|
+
allowDraw = false;
|
|
1457
1443
|
}
|
|
1458
1444
|
else {
|
|
1459
|
-
|
|
1445
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1446
|
+
let { width, height } = data;
|
|
1447
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1448
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1449
|
+
if (data.scaleX) {
|
|
1450
|
+
width *= data.scaleX;
|
|
1451
|
+
height *= data.scaleY;
|
|
1452
|
+
}
|
|
1453
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
1454
|
+
}
|
|
1460
1455
|
}
|
|
1461
1456
|
}
|
|
1462
|
-
if (
|
|
1463
|
-
canvas
|
|
1464
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1465
|
-
if (paint.blendMode)
|
|
1466
|
-
canvas.blendMode = paint.blendMode;
|
|
1467
|
-
if (data.opacity)
|
|
1468
|
-
canvas.opacity *= data.opacity;
|
|
1469
|
-
if (data.transform)
|
|
1470
|
-
canvas.transform(data.transform);
|
|
1471
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1472
|
-
canvas.restore();
|
|
1457
|
+
if (allowDraw) {
|
|
1458
|
+
drawImage(ui, canvas, paint, data);
|
|
1473
1459
|
return true;
|
|
1474
1460
|
}
|
|
1475
1461
|
else {
|
|
@@ -1490,13 +1476,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1490
1476
|
}
|
|
1491
1477
|
}
|
|
1492
1478
|
}
|
|
1479
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1480
|
+
canvas.save();
|
|
1481
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1482
|
+
if (paint.blendMode)
|
|
1483
|
+
canvas.blendMode = paint.blendMode;
|
|
1484
|
+
if (data.opacity)
|
|
1485
|
+
canvas.opacity *= data.opacity;
|
|
1486
|
+
if (data.transform)
|
|
1487
|
+
canvas.transform(data.transform);
|
|
1488
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1489
|
+
canvas.restore();
|
|
1490
|
+
}
|
|
1493
1491
|
|
|
1494
1492
|
function recycleImage(attrName, data) {
|
|
1495
1493
|
const paints = data['_' + attrName];
|
|
1496
1494
|
if (paints instanceof Array) {
|
|
1497
|
-
let image, recycleMap, input, url;
|
|
1495
|
+
let paint, image, recycleMap, input, url;
|
|
1498
1496
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1499
|
-
|
|
1497
|
+
paint = paints[i];
|
|
1498
|
+
image = paint.image;
|
|
1500
1499
|
url = image && image.url;
|
|
1501
1500
|
if (url) {
|
|
1502
1501
|
if (!recycleMap)
|
|
@@ -1511,8 +1510,6 @@ function recycleImage(attrName, data) {
|
|
|
1511
1510
|
}
|
|
1512
1511
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1513
1512
|
}
|
|
1514
|
-
else
|
|
1515
|
-
paints[i].style = null;
|
|
1516
1513
|
}
|
|
1517
1514
|
}
|
|
1518
1515
|
return recycleMap;
|
|
@@ -1691,7 +1688,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
1691
1688
|
const offsetOutBounds = {};
|
|
1692
1689
|
function innerShadow(ui, current, shape) {
|
|
1693
1690
|
let copyBounds, spreadScale;
|
|
1694
|
-
const { __nowWorld: nowWorld, __layout
|
|
1691
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1695
1692
|
const { innerShadow } = ui.__;
|
|
1696
1693
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1697
1694
|
const other = current.getSameCanvas();
|