@leafer-ui/worker 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/worker.cjs +73 -75
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.esm.js +73 -75
- 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 +317 -202
- 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 +317 -202
- 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,22 @@ class Renderer {
|
|
|
465
458
|
requestLayout() {
|
|
466
459
|
this.target.emit(LayoutEvent.REQUEST);
|
|
467
460
|
}
|
|
461
|
+
checkRender() {
|
|
462
|
+
if (this.running) {
|
|
463
|
+
const { target } = this;
|
|
464
|
+
if (target.isApp) {
|
|
465
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
466
|
+
target.children.forEach(leafer => {
|
|
467
|
+
leafer.renderer.FPS = this.FPS;
|
|
468
|
+
leafer.renderer.checkRender();
|
|
469
|
+
});
|
|
470
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
471
|
+
}
|
|
472
|
+
if (this.changed && this.canvas.view)
|
|
473
|
+
this.render();
|
|
474
|
+
this.target.emit(RenderEvent.NEXT);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
468
477
|
render(callback) {
|
|
469
478
|
if (!(this.running && this.canvas.view))
|
|
470
479
|
return this.update();
|
|
@@ -473,8 +482,6 @@ class Renderer {
|
|
|
473
482
|
this.totalBounds = new Bounds();
|
|
474
483
|
debug.log(target.innerName, '--->');
|
|
475
484
|
try {
|
|
476
|
-
if (!target.isApp)
|
|
477
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
478
485
|
this.emitRender(RenderEvent.START);
|
|
479
486
|
this.renderOnce(callback);
|
|
480
487
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -542,20 +549,12 @@ class Renderer {
|
|
|
542
549
|
}
|
|
543
550
|
clipRender(block) {
|
|
544
551
|
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);
|
|
552
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
549
553
|
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);
|
|
554
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
555
|
+
canvas.clearWorld(bounds, true);
|
|
556
|
+
canvas.clipWorld(bounds, true);
|
|
557
|
+
this.__render(bounds, realBounds);
|
|
559
558
|
canvas.restore();
|
|
560
559
|
Run.end(t);
|
|
561
560
|
}
|
|
@@ -564,28 +563,22 @@ class Renderer {
|
|
|
564
563
|
const { canvas } = this;
|
|
565
564
|
canvas.save();
|
|
566
565
|
canvas.clear();
|
|
567
|
-
this.__render(canvas.bounds
|
|
566
|
+
this.__render(canvas.bounds);
|
|
568
567
|
canvas.restore();
|
|
569
568
|
Run.end(t);
|
|
570
569
|
}
|
|
571
|
-
__render(bounds,
|
|
572
|
-
const
|
|
570
|
+
__render(bounds, realBounds) {
|
|
571
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
573
572
|
if (this.needFill)
|
|
574
|
-
|
|
573
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
575
574
|
if (Debug.showRepaint)
|
|
576
|
-
|
|
577
|
-
this.target.__render(
|
|
575
|
+
Debug.drawRepaint(canvas, bounds);
|
|
576
|
+
this.target.__render(canvas, options);
|
|
578
577
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
579
578
|
this.renderOptions = options;
|
|
580
579
|
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) { }
|
|
580
|
+
canvas.updateRender(realBounds);
|
|
581
|
+
}
|
|
589
582
|
addBlock(block) {
|
|
590
583
|
if (!this.updateBlocks)
|
|
591
584
|
this.updateBlocks = [];
|
|
@@ -601,17 +594,16 @@ class Renderer {
|
|
|
601
594
|
}
|
|
602
595
|
}
|
|
603
596
|
__requestRender() {
|
|
604
|
-
|
|
597
|
+
const target = this.target;
|
|
598
|
+
if (this.requestTime || !target)
|
|
605
599
|
return;
|
|
600
|
+
if (target.parentApp)
|
|
601
|
+
return target.parentApp.requestRender(false);
|
|
606
602
|
const requestTime = this.requestTime = Date.now();
|
|
607
603
|
Platform.requestRender(() => {
|
|
608
604
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
609
605
|
this.requestTime = 0;
|
|
610
|
-
|
|
611
|
-
if (this.changed && this.canvas.view)
|
|
612
|
-
this.render();
|
|
613
|
-
this.target.emit(RenderEvent.NEXT);
|
|
614
|
-
}
|
|
606
|
+
this.checkRender();
|
|
615
607
|
});
|
|
616
608
|
}
|
|
617
609
|
__onResize(e) {
|
|
@@ -669,6 +661,7 @@ class Renderer {
|
|
|
669
661
|
}
|
|
670
662
|
}
|
|
671
663
|
}
|
|
664
|
+
Renderer.clipSpread = 10;
|
|
672
665
|
|
|
673
666
|
const { hitRadiusPoint } = BoundsHelper;
|
|
674
667
|
class Picker {
|
|
@@ -1188,9 +1181,11 @@ const tempBox = new Bounds();
|
|
|
1188
1181
|
const tempPoint = {};
|
|
1189
1182
|
const tempScaleData = {};
|
|
1190
1183
|
function createData(leafPaint, image, paint, box) {
|
|
1191
|
-
const { blendMode, sync } = paint;
|
|
1184
|
+
const { blendMode, changeful, sync } = paint;
|
|
1192
1185
|
if (blendMode)
|
|
1193
1186
|
leafPaint.blendMode = blendMode;
|
|
1187
|
+
if (changeful)
|
|
1188
|
+
leafPaint.changeful = changeful;
|
|
1194
1189
|
if (sync)
|
|
1195
1190
|
leafPaint.sync = sync;
|
|
1196
1191
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1455,40 +1450,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1455
1450
|
};
|
|
1456
1451
|
|
|
1457
1452
|
const { abs } = Math;
|
|
1458
|
-
function checkImage(ui, canvas, paint,
|
|
1453
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1459
1454
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1460
|
-
const { pixelRatio } = canvas;
|
|
1461
|
-
if (!
|
|
1455
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1456
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1462
1457
|
return false;
|
|
1463
1458
|
}
|
|
1464
1459
|
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;
|
|
1460
|
+
if (allowDraw) {
|
|
1461
|
+
if (data.repeat) {
|
|
1462
|
+
allowDraw = false;
|
|
1476
1463
|
}
|
|
1477
1464
|
else {
|
|
1478
|
-
|
|
1465
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1466
|
+
let { width, height } = data;
|
|
1467
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1468
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1469
|
+
if (data.scaleX) {
|
|
1470
|
+
width *= data.scaleX;
|
|
1471
|
+
height *= data.scaleY;
|
|
1472
|
+
}
|
|
1473
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
1474
|
+
}
|
|
1479
1475
|
}
|
|
1480
1476
|
}
|
|
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();
|
|
1477
|
+
if (allowDraw) {
|
|
1478
|
+
drawImage(ui, canvas, paint, data);
|
|
1492
1479
|
return true;
|
|
1493
1480
|
}
|
|
1494
1481
|
else {
|
|
@@ -1509,13 +1496,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1509
1496
|
}
|
|
1510
1497
|
}
|
|
1511
1498
|
}
|
|
1499
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1500
|
+
canvas.save();
|
|
1501
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1502
|
+
if (paint.blendMode)
|
|
1503
|
+
canvas.blendMode = paint.blendMode;
|
|
1504
|
+
if (data.opacity)
|
|
1505
|
+
canvas.opacity *= data.opacity;
|
|
1506
|
+
if (data.transform)
|
|
1507
|
+
canvas.transform(data.transform);
|
|
1508
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1509
|
+
canvas.restore();
|
|
1510
|
+
}
|
|
1512
1511
|
|
|
1513
1512
|
function recycleImage(attrName, data) {
|
|
1514
1513
|
const paints = data['_' + attrName];
|
|
1515
1514
|
if (paints instanceof Array) {
|
|
1516
|
-
let image, recycleMap, input, url;
|
|
1515
|
+
let paint, image, recycleMap, input, url;
|
|
1517
1516
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1518
|
-
|
|
1517
|
+
paint = paints[i];
|
|
1518
|
+
image = paint.image;
|
|
1519
1519
|
url = image && image.url;
|
|
1520
1520
|
if (url) {
|
|
1521
1521
|
if (!recycleMap)
|
|
@@ -1530,8 +1530,6 @@ function recycleImage(attrName, data) {
|
|
|
1530
1530
|
}
|
|
1531
1531
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1532
1532
|
}
|
|
1533
|
-
else
|
|
1534
|
-
paints[i].style = null;
|
|
1535
1533
|
}
|
|
1536
1534
|
}
|
|
1537
1535
|
return recycleMap;
|
|
@@ -1710,7 +1708,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
1710
1708
|
const offsetOutBounds = {};
|
|
1711
1709
|
function innerShadow(ui, current, shape) {
|
|
1712
1710
|
let copyBounds, spreadScale;
|
|
1713
|
-
const { __nowWorld: nowWorld, __layout
|
|
1711
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1714
1712
|
const { innerShadow } = ui.__;
|
|
1715
1713
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1716
1714
|
const other = current.getSameCanvas();
|