@leafer-ui/node 1.5.3 → 1.6.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/node.cjs +73 -75
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +73 -75
- 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,22 @@ class Renderer {
|
|
|
478
471
|
requestLayout() {
|
|
479
472
|
this.target.emit(LayoutEvent.REQUEST);
|
|
480
473
|
}
|
|
474
|
+
checkRender() {
|
|
475
|
+
if (this.running) {
|
|
476
|
+
const { target } = this;
|
|
477
|
+
if (target.isApp) {
|
|
478
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
479
|
+
target.children.forEach(leafer => {
|
|
480
|
+
leafer.renderer.FPS = this.FPS;
|
|
481
|
+
leafer.renderer.checkRender();
|
|
482
|
+
});
|
|
483
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
484
|
+
}
|
|
485
|
+
if (this.changed && this.canvas.view)
|
|
486
|
+
this.render();
|
|
487
|
+
this.target.emit(RenderEvent.NEXT);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
481
490
|
render(callback) {
|
|
482
491
|
if (!(this.running && this.canvas.view))
|
|
483
492
|
return this.update();
|
|
@@ -486,8 +495,6 @@ class Renderer {
|
|
|
486
495
|
this.totalBounds = new Bounds();
|
|
487
496
|
debug$1.log(target.innerName, '--->');
|
|
488
497
|
try {
|
|
489
|
-
if (!target.isApp)
|
|
490
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
491
498
|
this.emitRender(RenderEvent.START);
|
|
492
499
|
this.renderOnce(callback);
|
|
493
500
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -555,20 +562,12 @@ class Renderer {
|
|
|
555
562
|
}
|
|
556
563
|
clipRender(block) {
|
|
557
564
|
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);
|
|
565
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
562
566
|
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);
|
|
567
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
568
|
+
canvas.clearWorld(bounds, true);
|
|
569
|
+
canvas.clipWorld(bounds, true);
|
|
570
|
+
this.__render(bounds, realBounds);
|
|
572
571
|
canvas.restore();
|
|
573
572
|
Run.end(t);
|
|
574
573
|
}
|
|
@@ -577,28 +576,22 @@ class Renderer {
|
|
|
577
576
|
const { canvas } = this;
|
|
578
577
|
canvas.save();
|
|
579
578
|
canvas.clear();
|
|
580
|
-
this.__render(canvas.bounds
|
|
579
|
+
this.__render(canvas.bounds);
|
|
581
580
|
canvas.restore();
|
|
582
581
|
Run.end(t);
|
|
583
582
|
}
|
|
584
|
-
__render(bounds,
|
|
585
|
-
const
|
|
583
|
+
__render(bounds, realBounds) {
|
|
584
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
586
585
|
if (this.needFill)
|
|
587
|
-
|
|
586
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
588
587
|
if (Debug.showRepaint)
|
|
589
|
-
|
|
590
|
-
this.target.__render(
|
|
588
|
+
Debug.drawRepaint(canvas, bounds);
|
|
589
|
+
this.target.__render(canvas, options);
|
|
591
590
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
592
591
|
this.renderOptions = options;
|
|
593
592
|
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) { }
|
|
593
|
+
canvas.updateRender(realBounds);
|
|
594
|
+
}
|
|
602
595
|
addBlock(block) {
|
|
603
596
|
if (!this.updateBlocks)
|
|
604
597
|
this.updateBlocks = [];
|
|
@@ -614,17 +607,16 @@ class Renderer {
|
|
|
614
607
|
}
|
|
615
608
|
}
|
|
616
609
|
__requestRender() {
|
|
617
|
-
|
|
610
|
+
const target = this.target;
|
|
611
|
+
if (this.requestTime || !target)
|
|
618
612
|
return;
|
|
613
|
+
if (target.parentApp)
|
|
614
|
+
return target.parentApp.requestRender(false);
|
|
619
615
|
const requestTime = this.requestTime = Date.now();
|
|
620
616
|
Platform.requestRender(() => {
|
|
621
617
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
622
618
|
this.requestTime = 0;
|
|
623
|
-
|
|
624
|
-
if (this.changed && this.canvas.view)
|
|
625
|
-
this.render();
|
|
626
|
-
this.target.emit(RenderEvent.NEXT);
|
|
627
|
-
}
|
|
619
|
+
this.checkRender();
|
|
628
620
|
});
|
|
629
621
|
}
|
|
630
622
|
__onResize(e) {
|
|
@@ -682,6 +674,7 @@ class Renderer {
|
|
|
682
674
|
}
|
|
683
675
|
}
|
|
684
676
|
}
|
|
677
|
+
Renderer.clipSpread = 10;
|
|
685
678
|
|
|
686
679
|
const { hitRadiusPoint } = BoundsHelper;
|
|
687
680
|
class Picker {
|
|
@@ -1201,9 +1194,11 @@ const tempBox = new Bounds();
|
|
|
1201
1194
|
const tempPoint = {};
|
|
1202
1195
|
const tempScaleData = {};
|
|
1203
1196
|
function createData(leafPaint, image, paint, box) {
|
|
1204
|
-
const { blendMode, sync } = paint;
|
|
1197
|
+
const { blendMode, changeful, sync } = paint;
|
|
1205
1198
|
if (blendMode)
|
|
1206
1199
|
leafPaint.blendMode = blendMode;
|
|
1200
|
+
if (changeful)
|
|
1201
|
+
leafPaint.changeful = changeful;
|
|
1207
1202
|
if (sync)
|
|
1208
1203
|
leafPaint.sync = sync;
|
|
1209
1204
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1436,40 +1431,32 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1436
1431
|
}
|
|
1437
1432
|
|
|
1438
1433
|
const { abs } = Math;
|
|
1439
|
-
function checkImage(ui, canvas, paint,
|
|
1434
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1440
1435
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1441
|
-
const { pixelRatio } = canvas;
|
|
1442
|
-
if (!
|
|
1436
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1437
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1443
1438
|
return false;
|
|
1444
1439
|
}
|
|
1445
1440
|
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;
|
|
1441
|
+
if (allowDraw) {
|
|
1442
|
+
if (data.repeat) {
|
|
1443
|
+
allowDraw = false;
|
|
1457
1444
|
}
|
|
1458
1445
|
else {
|
|
1459
|
-
|
|
1446
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1447
|
+
let { width, height } = data;
|
|
1448
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1449
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1450
|
+
if (data.scaleX) {
|
|
1451
|
+
width *= data.scaleX;
|
|
1452
|
+
height *= data.scaleY;
|
|
1453
|
+
}
|
|
1454
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
1455
|
+
}
|
|
1460
1456
|
}
|
|
1461
1457
|
}
|
|
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();
|
|
1458
|
+
if (allowDraw) {
|
|
1459
|
+
drawImage(ui, canvas, paint, data);
|
|
1473
1460
|
return true;
|
|
1474
1461
|
}
|
|
1475
1462
|
else {
|
|
@@ -1490,13 +1477,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1490
1477
|
}
|
|
1491
1478
|
}
|
|
1492
1479
|
}
|
|
1480
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1481
|
+
canvas.save();
|
|
1482
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1483
|
+
if (paint.blendMode)
|
|
1484
|
+
canvas.blendMode = paint.blendMode;
|
|
1485
|
+
if (data.opacity)
|
|
1486
|
+
canvas.opacity *= data.opacity;
|
|
1487
|
+
if (data.transform)
|
|
1488
|
+
canvas.transform(data.transform);
|
|
1489
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1490
|
+
canvas.restore();
|
|
1491
|
+
}
|
|
1493
1492
|
|
|
1494
1493
|
function recycleImage(attrName, data) {
|
|
1495
1494
|
const paints = data['_' + attrName];
|
|
1496
1495
|
if (paints instanceof Array) {
|
|
1497
|
-
let image, recycleMap, input, url;
|
|
1496
|
+
let paint, image, recycleMap, input, url;
|
|
1498
1497
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1499
|
-
|
|
1498
|
+
paint = paints[i];
|
|
1499
|
+
image = paint.image;
|
|
1500
1500
|
url = image && image.url;
|
|
1501
1501
|
if (url) {
|
|
1502
1502
|
if (!recycleMap)
|
|
@@ -1511,8 +1511,6 @@ function recycleImage(attrName, data) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1513
1513
|
}
|
|
1514
|
-
else
|
|
1515
|
-
paints[i].style = null;
|
|
1516
1514
|
}
|
|
1517
1515
|
}
|
|
1518
1516
|
return recycleMap;
|
|
@@ -1691,7 +1689,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
1691
1689
|
const offsetOutBounds = {};
|
|
1692
1690
|
function innerShadow(ui, current, shape) {
|
|
1693
1691
|
let copyBounds, spreadScale;
|
|
1694
|
-
const { __nowWorld: nowWorld, __layout
|
|
1692
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1695
1693
|
const { innerShadow } = ui.__;
|
|
1696
1694
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1697
1695
|
const other = current.getSameCanvas();
|