@leafer-ui/worker 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/worker.cjs +68 -71
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.esm.js +68 -71
- package/dist/worker.esm.js.map +1 -1
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +303 -192
- package/dist/worker.js.map +1 -1
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +303 -192
- package/dist/worker.module.js.map +1 -1
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +11 -10
- package/src/core.ts +86 -0
- package/src/index.ts +2 -2
- package/types/index.d.ts +8 -1
package/dist/worker.esm.js
CHANGED
|
@@ -243,7 +243,6 @@ function updateChange(updateList) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
const { worldBounds } = LeafBoundsHelper;
|
|
246
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
247
246
|
class LayoutBlockData {
|
|
248
247
|
constructor(list) {
|
|
249
248
|
this.updatedBounds = new Bounds();
|
|
@@ -257,13 +256,7 @@ class LayoutBlockData {
|
|
|
257
256
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
258
257
|
}
|
|
259
258
|
setAfter() {
|
|
260
|
-
|
|
261
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
262
|
-
this.afterBounds.set(bigBounds);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
266
|
-
}
|
|
259
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
267
260
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
268
261
|
}
|
|
269
262
|
merge(data) {
|
|
@@ -465,6 +458,13 @@ class Renderer {
|
|
|
465
458
|
requestLayout() {
|
|
466
459
|
this.target.emit(LayoutEvent.REQUEST);
|
|
467
460
|
}
|
|
461
|
+
checkRender() {
|
|
462
|
+
if (this.running) {
|
|
463
|
+
if (this.changed && this.canvas.view)
|
|
464
|
+
this.render();
|
|
465
|
+
this.target.emit(RenderEvent.NEXT);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
468
|
render(callback) {
|
|
469
469
|
if (!(this.running && this.canvas.view))
|
|
470
470
|
return this.update();
|
|
@@ -473,8 +473,6 @@ class Renderer {
|
|
|
473
473
|
this.totalBounds = new Bounds();
|
|
474
474
|
debug.log(target.innerName, '--->');
|
|
475
475
|
try {
|
|
476
|
-
if (!target.isApp)
|
|
477
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
478
476
|
this.emitRender(RenderEvent.START);
|
|
479
477
|
this.renderOnce(callback);
|
|
480
478
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -542,20 +540,12 @@ class Renderer {
|
|
|
542
540
|
}
|
|
543
541
|
clipRender(block) {
|
|
544
542
|
const t = Run.start('PartRender');
|
|
545
|
-
const { canvas } = this;
|
|
546
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
547
|
-
const includes = block.includes(this.target.__world);
|
|
548
|
-
const realBounds = new Bounds(bounds);
|
|
543
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
549
544
|
canvas.save();
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
555
|
-
canvas.clearWorld(bounds, true);
|
|
556
|
-
canvas.clipWorld(bounds, true);
|
|
557
|
-
}
|
|
558
|
-
this.__render(bounds, includes, realBounds);
|
|
545
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
546
|
+
canvas.clearWorld(bounds, true);
|
|
547
|
+
canvas.clipWorld(bounds, true);
|
|
548
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
559
549
|
canvas.restore();
|
|
560
550
|
Run.end(t);
|
|
561
551
|
}
|
|
@@ -569,23 +559,17 @@ class Renderer {
|
|
|
569
559
|
Run.end(t);
|
|
570
560
|
}
|
|
571
561
|
__render(bounds, includes, realBounds) {
|
|
572
|
-
const options =
|
|
562
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
573
563
|
if (this.needFill)
|
|
574
|
-
|
|
564
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
575
565
|
if (Debug.showRepaint)
|
|
576
|
-
|
|
577
|
-
this.target.__render(
|
|
566
|
+
Debug.drawRepaint(canvas, bounds);
|
|
567
|
+
this.target.__render(canvas, options);
|
|
578
568
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
579
569
|
this.renderOptions = options;
|
|
580
570
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
if (Debug.showBoundsView)
|
|
584
|
-
this.renderBoundsView(options);
|
|
585
|
-
this.canvas.updateRender(realBounds);
|
|
586
|
-
}
|
|
587
|
-
renderHitView(_options) { }
|
|
588
|
-
renderBoundsView(_options) { }
|
|
571
|
+
canvas.updateRender(realBounds);
|
|
572
|
+
}
|
|
589
573
|
addBlock(block) {
|
|
590
574
|
if (!this.updateBlocks)
|
|
591
575
|
this.updateBlocks = [];
|
|
@@ -601,17 +585,24 @@ class Renderer {
|
|
|
601
585
|
}
|
|
602
586
|
}
|
|
603
587
|
__requestRender() {
|
|
588
|
+
const target = this.target;
|
|
589
|
+
if (target.parentApp)
|
|
590
|
+
return target.parentApp.renderer.update(false);
|
|
604
591
|
if (this.requestTime)
|
|
605
592
|
return;
|
|
606
593
|
const requestTime = this.requestTime = Date.now();
|
|
607
594
|
Platform.requestRender(() => {
|
|
608
595
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
609
596
|
this.requestTime = 0;
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
597
|
+
if (target.isApp) {
|
|
598
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
599
|
+
target.children.forEach(leafer => {
|
|
600
|
+
leafer.renderer.FPS = this.FPS;
|
|
601
|
+
leafer.renderer.checkRender();
|
|
602
|
+
});
|
|
603
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
614
604
|
}
|
|
605
|
+
this.checkRender();
|
|
615
606
|
});
|
|
616
607
|
}
|
|
617
608
|
__onResize(e) {
|
|
@@ -669,6 +660,7 @@ class Renderer {
|
|
|
669
660
|
}
|
|
670
661
|
}
|
|
671
662
|
}
|
|
663
|
+
Renderer.clipSpread = 10;
|
|
672
664
|
|
|
673
665
|
const { hitRadiusPoint } = BoundsHelper;
|
|
674
666
|
class Picker {
|
|
@@ -1188,9 +1180,11 @@ const tempBox = new Bounds();
|
|
|
1188
1180
|
const tempPoint = {};
|
|
1189
1181
|
const tempScaleData = {};
|
|
1190
1182
|
function createData(leafPaint, image, paint, box) {
|
|
1191
|
-
const { blendMode, sync } = paint;
|
|
1183
|
+
const { blendMode, changeful, sync } = paint;
|
|
1192
1184
|
if (blendMode)
|
|
1193
1185
|
leafPaint.blendMode = blendMode;
|
|
1186
|
+
if (changeful)
|
|
1187
|
+
leafPaint.changeful = changeful;
|
|
1194
1188
|
if (sync)
|
|
1195
1189
|
leafPaint.sync = sync;
|
|
1196
1190
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1455,40 +1449,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1455
1449
|
};
|
|
1456
1450
|
|
|
1457
1451
|
const { abs } = Math;
|
|
1458
|
-
function checkImage(ui, canvas, paint,
|
|
1452
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1459
1453
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1460
|
-
const { pixelRatio } = canvas;
|
|
1461
|
-
if (!
|
|
1454
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1455
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1462
1456
|
return false;
|
|
1463
1457
|
}
|
|
1464
1458
|
else {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
let { width, height } = data;
|
|
1469
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1470
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1471
|
-
if (data.scaleX) {
|
|
1472
|
-
width *= data.scaleX;
|
|
1473
|
-
height *= data.scaleY;
|
|
1474
|
-
}
|
|
1475
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
1459
|
+
if (allowDraw) {
|
|
1460
|
+
if (data.repeat) {
|
|
1461
|
+
allowDraw = false;
|
|
1476
1462
|
}
|
|
1477
1463
|
else {
|
|
1478
|
-
|
|
1464
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1465
|
+
let { width, height } = data;
|
|
1466
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1467
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1468
|
+
if (data.scaleX) {
|
|
1469
|
+
width *= data.scaleX;
|
|
1470
|
+
height *= data.scaleY;
|
|
1471
|
+
}
|
|
1472
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
1473
|
+
}
|
|
1479
1474
|
}
|
|
1480
1475
|
}
|
|
1481
|
-
if (
|
|
1482
|
-
canvas
|
|
1483
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1484
|
-
if (paint.blendMode)
|
|
1485
|
-
canvas.blendMode = paint.blendMode;
|
|
1486
|
-
if (data.opacity)
|
|
1487
|
-
canvas.opacity *= data.opacity;
|
|
1488
|
-
if (data.transform)
|
|
1489
|
-
canvas.transform(data.transform);
|
|
1490
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1491
|
-
canvas.restore();
|
|
1476
|
+
if (allowDraw) {
|
|
1477
|
+
drawImage(ui, canvas, paint, data);
|
|
1492
1478
|
return true;
|
|
1493
1479
|
}
|
|
1494
1480
|
else {
|
|
@@ -1509,13 +1495,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1509
1495
|
}
|
|
1510
1496
|
}
|
|
1511
1497
|
}
|
|
1498
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1499
|
+
canvas.save();
|
|
1500
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1501
|
+
if (paint.blendMode)
|
|
1502
|
+
canvas.blendMode = paint.blendMode;
|
|
1503
|
+
if (data.opacity)
|
|
1504
|
+
canvas.opacity *= data.opacity;
|
|
1505
|
+
if (data.transform)
|
|
1506
|
+
canvas.transform(data.transform);
|
|
1507
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1508
|
+
canvas.restore();
|
|
1509
|
+
}
|
|
1512
1510
|
|
|
1513
1511
|
function recycleImage(attrName, data) {
|
|
1514
1512
|
const paints = data['_' + attrName];
|
|
1515
1513
|
if (paints instanceof Array) {
|
|
1516
|
-
let image, recycleMap, input, url;
|
|
1514
|
+
let paint, image, recycleMap, input, url;
|
|
1517
1515
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1518
|
-
|
|
1516
|
+
paint = paints[i];
|
|
1517
|
+
image = paint.image;
|
|
1519
1518
|
url = image && image.url;
|
|
1520
1519
|
if (url) {
|
|
1521
1520
|
if (!recycleMap)
|
|
@@ -1530,8 +1529,6 @@ function recycleImage(attrName, data) {
|
|
|
1530
1529
|
}
|
|
1531
1530
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1532
1531
|
}
|
|
1533
|
-
else
|
|
1534
|
-
paints[i].style = null;
|
|
1535
1532
|
}
|
|
1536
1533
|
}
|
|
1537
1534
|
return recycleMap;
|
|
@@ -1710,7 +1707,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
1710
1707
|
const offsetOutBounds = {};
|
|
1711
1708
|
function innerShadow(ui, current, shape) {
|
|
1712
1709
|
let copyBounds, spreadScale;
|
|
1713
|
-
const { __nowWorld: nowWorld, __layout
|
|
1710
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1714
1711
|
const { innerShadow } = ui.__;
|
|
1715
1712
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1716
1713
|
const other = current.getSameCanvas();
|