@leafer-ui/node 1.5.3 → 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/node.cjs +68 -71
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +68 -71
- package/dist/node.esm.js.map +1 -1
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +12 -11
- package/src/core.ts +73 -0
- package/src/index.ts +2 -2
- package/types/index.d.ts +8 -1
package/dist/node.esm.js
CHANGED
|
@@ -256,7 +256,6 @@ function updateChange(updateList) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
const { worldBounds } = LeafBoundsHelper;
|
|
259
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
260
259
|
class LayoutBlockData {
|
|
261
260
|
constructor(list) {
|
|
262
261
|
this.updatedBounds = new Bounds();
|
|
@@ -270,13 +269,7 @@ class LayoutBlockData {
|
|
|
270
269
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
271
270
|
}
|
|
272
271
|
setAfter() {
|
|
273
|
-
|
|
274
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
275
|
-
this.afterBounds.set(bigBounds);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
279
|
-
}
|
|
272
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
280
273
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
281
274
|
}
|
|
282
275
|
merge(data) {
|
|
@@ -478,6 +471,13 @@ class Renderer {
|
|
|
478
471
|
requestLayout() {
|
|
479
472
|
this.target.emit(LayoutEvent.REQUEST);
|
|
480
473
|
}
|
|
474
|
+
checkRender() {
|
|
475
|
+
if (this.running) {
|
|
476
|
+
if (this.changed && this.canvas.view)
|
|
477
|
+
this.render();
|
|
478
|
+
this.target.emit(RenderEvent.NEXT);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
481
|
render(callback) {
|
|
482
482
|
if (!(this.running && this.canvas.view))
|
|
483
483
|
return this.update();
|
|
@@ -486,8 +486,6 @@ class Renderer {
|
|
|
486
486
|
this.totalBounds = new Bounds();
|
|
487
487
|
debug$1.log(target.innerName, '--->');
|
|
488
488
|
try {
|
|
489
|
-
if (!target.isApp)
|
|
490
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
491
489
|
this.emitRender(RenderEvent.START);
|
|
492
490
|
this.renderOnce(callback);
|
|
493
491
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -555,20 +553,12 @@ class Renderer {
|
|
|
555
553
|
}
|
|
556
554
|
clipRender(block) {
|
|
557
555
|
const t = Run.start('PartRender');
|
|
558
|
-
const { canvas } = this;
|
|
559
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
560
|
-
const includes = block.includes(this.target.__world);
|
|
561
|
-
const realBounds = new Bounds(bounds);
|
|
556
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
562
557
|
canvas.save();
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
568
|
-
canvas.clearWorld(bounds, true);
|
|
569
|
-
canvas.clipWorld(bounds, true);
|
|
570
|
-
}
|
|
571
|
-
this.__render(bounds, includes, realBounds);
|
|
558
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
559
|
+
canvas.clearWorld(bounds, true);
|
|
560
|
+
canvas.clipWorld(bounds, true);
|
|
561
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
572
562
|
canvas.restore();
|
|
573
563
|
Run.end(t);
|
|
574
564
|
}
|
|
@@ -582,23 +572,17 @@ class Renderer {
|
|
|
582
572
|
Run.end(t);
|
|
583
573
|
}
|
|
584
574
|
__render(bounds, includes, realBounds) {
|
|
585
|
-
const options =
|
|
575
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
586
576
|
if (this.needFill)
|
|
587
|
-
|
|
577
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
588
578
|
if (Debug.showRepaint)
|
|
589
|
-
|
|
590
|
-
this.target.__render(
|
|
579
|
+
Debug.drawRepaint(canvas, bounds);
|
|
580
|
+
this.target.__render(canvas, options);
|
|
591
581
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
592
582
|
this.renderOptions = options;
|
|
593
583
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if (Debug.showBoundsView)
|
|
597
|
-
this.renderBoundsView(options);
|
|
598
|
-
this.canvas.updateRender(realBounds);
|
|
599
|
-
}
|
|
600
|
-
renderHitView(_options) { }
|
|
601
|
-
renderBoundsView(_options) { }
|
|
584
|
+
canvas.updateRender(realBounds);
|
|
585
|
+
}
|
|
602
586
|
addBlock(block) {
|
|
603
587
|
if (!this.updateBlocks)
|
|
604
588
|
this.updateBlocks = [];
|
|
@@ -614,17 +598,24 @@ class Renderer {
|
|
|
614
598
|
}
|
|
615
599
|
}
|
|
616
600
|
__requestRender() {
|
|
601
|
+
const target = this.target;
|
|
602
|
+
if (target.parentApp)
|
|
603
|
+
return target.parentApp.renderer.update(false);
|
|
617
604
|
if (this.requestTime)
|
|
618
605
|
return;
|
|
619
606
|
const requestTime = this.requestTime = Date.now();
|
|
620
607
|
Platform.requestRender(() => {
|
|
621
608
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
622
609
|
this.requestTime = 0;
|
|
623
|
-
if (
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
610
|
+
if (target.isApp) {
|
|
611
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
612
|
+
target.children.forEach(leafer => {
|
|
613
|
+
leafer.renderer.FPS = this.FPS;
|
|
614
|
+
leafer.renderer.checkRender();
|
|
615
|
+
});
|
|
616
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
627
617
|
}
|
|
618
|
+
this.checkRender();
|
|
628
619
|
});
|
|
629
620
|
}
|
|
630
621
|
__onResize(e) {
|
|
@@ -682,6 +673,7 @@ class Renderer {
|
|
|
682
673
|
}
|
|
683
674
|
}
|
|
684
675
|
}
|
|
676
|
+
Renderer.clipSpread = 10;
|
|
685
677
|
|
|
686
678
|
const { hitRadiusPoint } = BoundsHelper;
|
|
687
679
|
class Picker {
|
|
@@ -1201,9 +1193,11 @@ const tempBox = new Bounds();
|
|
|
1201
1193
|
const tempPoint = {};
|
|
1202
1194
|
const tempScaleData = {};
|
|
1203
1195
|
function createData(leafPaint, image, paint, box) {
|
|
1204
|
-
const { blendMode, sync } = paint;
|
|
1196
|
+
const { blendMode, changeful, sync } = paint;
|
|
1205
1197
|
if (blendMode)
|
|
1206
1198
|
leafPaint.blendMode = blendMode;
|
|
1199
|
+
if (changeful)
|
|
1200
|
+
leafPaint.changeful = changeful;
|
|
1207
1201
|
if (sync)
|
|
1208
1202
|
leafPaint.sync = sync;
|
|
1209
1203
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1436,40 +1430,32 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
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();
|