@leafer-draw/worker 1.6.0 → 1.6.2
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 +59 -51
- package/dist/worker.esm.js +59 -51
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +106 -69
- 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 +102 -69
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
- package/dist/worker.cjs.map +0 -1
- package/dist/worker.esm.js.map +0 -1
- package/dist/worker.js.map +0 -1
- package/dist/worker.module.js.map +0 -1
package/dist/worker.cjs
CHANGED
|
@@ -186,7 +186,7 @@ class Watcher {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
189
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
|
|
190
190
|
const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
|
|
191
191
|
function updateMatrix(updateList, levelList) {
|
|
192
192
|
let layout;
|
|
@@ -229,15 +229,7 @@ function updateBounds(boundsList) {
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
function updateChange(updateList) {
|
|
232
|
-
|
|
233
|
-
updateList.list.forEach(leaf => {
|
|
234
|
-
layout = leaf.__layout;
|
|
235
|
-
if (layout.opacityChanged)
|
|
236
|
-
updateAllWorldOpacity(leaf);
|
|
237
|
-
if (layout.stateStyleChanged)
|
|
238
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
239
|
-
leaf.__updateChange();
|
|
240
|
-
});
|
|
232
|
+
updateList.list.forEach(updateOneChange);
|
|
241
233
|
}
|
|
242
234
|
|
|
243
235
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
@@ -458,6 +450,15 @@ class Renderer {
|
|
|
458
450
|
}
|
|
459
451
|
checkRender() {
|
|
460
452
|
if (this.running) {
|
|
453
|
+
const { target } = this;
|
|
454
|
+
if (target.isApp) {
|
|
455
|
+
target.emit(core.RenderEvent.CHILD_START, target);
|
|
456
|
+
target.children.forEach(leafer => {
|
|
457
|
+
leafer.renderer.FPS = this.FPS;
|
|
458
|
+
leafer.renderer.checkRender();
|
|
459
|
+
});
|
|
460
|
+
target.emit(core.RenderEvent.CHILD_END, target);
|
|
461
|
+
}
|
|
461
462
|
if (this.changed && this.canvas.view)
|
|
462
463
|
this.render();
|
|
463
464
|
this.target.emit(core.RenderEvent.NEXT);
|
|
@@ -543,7 +544,7 @@ class Renderer {
|
|
|
543
544
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
544
545
|
canvas.clearWorld(bounds, true);
|
|
545
546
|
canvas.clipWorld(bounds, true);
|
|
546
|
-
this.__render(bounds,
|
|
547
|
+
this.__render(bounds, realBounds);
|
|
547
548
|
canvas.restore();
|
|
548
549
|
core.Run.end(t);
|
|
549
550
|
}
|
|
@@ -552,12 +553,12 @@ class Renderer {
|
|
|
552
553
|
const { canvas } = this;
|
|
553
554
|
canvas.save();
|
|
554
555
|
canvas.clear();
|
|
555
|
-
this.__render(canvas.bounds
|
|
556
|
+
this.__render(canvas.bounds);
|
|
556
557
|
canvas.restore();
|
|
557
558
|
core.Run.end(t);
|
|
558
559
|
}
|
|
559
|
-
__render(bounds,
|
|
560
|
-
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
560
|
+
__render(bounds, realBounds) {
|
|
561
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
561
562
|
if (this.needFill)
|
|
562
563
|
canvas.fillWorld(bounds, this.config.fill);
|
|
563
564
|
if (core.Debug.showRepaint)
|
|
@@ -584,22 +585,14 @@ class Renderer {
|
|
|
584
585
|
}
|
|
585
586
|
__requestRender() {
|
|
586
587
|
const target = this.target;
|
|
587
|
-
if (target
|
|
588
|
-
return target.parentApp.renderer.update(false);
|
|
589
|
-
if (this.requestTime)
|
|
588
|
+
if (this.requestTime || !target)
|
|
590
589
|
return;
|
|
590
|
+
if (target.parentApp)
|
|
591
|
+
return target.parentApp.requestRender(false);
|
|
591
592
|
const requestTime = this.requestTime = Date.now();
|
|
592
593
|
core.Platform.requestRender(() => {
|
|
593
594
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
594
595
|
this.requestTime = 0;
|
|
595
|
-
if (target.isApp) {
|
|
596
|
-
target.emit(core.RenderEvent.CHILD_START, target);
|
|
597
|
-
target.children.forEach(leafer => {
|
|
598
|
-
leafer.renderer.FPS = this.FPS;
|
|
599
|
-
leafer.renderer.checkRender();
|
|
600
|
-
});
|
|
601
|
-
target.emit(core.RenderEvent.CHILD_END, target);
|
|
602
|
-
}
|
|
603
596
|
this.checkRender();
|
|
604
597
|
});
|
|
605
598
|
}
|
|
@@ -670,8 +663,10 @@ Object.assign(core.Creator, {
|
|
|
670
663
|
core.Platform.layout = Layouter.fullLayout;
|
|
671
664
|
|
|
672
665
|
function fillText(ui, canvas) {
|
|
673
|
-
|
|
674
|
-
|
|
666
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
667
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
668
|
+
canvas.fillStyle = data.placeholderColor;
|
|
669
|
+
let row;
|
|
675
670
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
676
671
|
row = rows[i];
|
|
677
672
|
if (row.text)
|
|
@@ -680,7 +675,7 @@ function fillText(ui, canvas) {
|
|
|
680
675
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
681
676
|
}
|
|
682
677
|
if (decorationY) {
|
|
683
|
-
const { decorationColor, decorationHeight } = data;
|
|
678
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
684
679
|
if (decorationColor)
|
|
685
680
|
canvas.fillStyle = decorationColor;
|
|
686
681
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -689,38 +684,44 @@ function fillText(ui, canvas) {
|
|
|
689
684
|
|
|
690
685
|
function fill(fill, ui, canvas) {
|
|
691
686
|
canvas.fillStyle = fill;
|
|
692
|
-
|
|
687
|
+
fillPathOrText(ui, canvas);
|
|
693
688
|
}
|
|
694
689
|
function fills(fills, ui, canvas) {
|
|
695
690
|
let item;
|
|
696
|
-
const { windingRule, __font } = ui.__;
|
|
697
691
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
698
692
|
item = fills[i];
|
|
699
|
-
if (item.image
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
if (item.blendMode)
|
|
707
|
-
canvas.blendMode = item.blendMode;
|
|
708
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
709
|
-
canvas.restore();
|
|
693
|
+
if (item.image) {
|
|
694
|
+
if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
695
|
+
continue;
|
|
696
|
+
if (!item.style) {
|
|
697
|
+
if (!i && item.image.isPlacehold)
|
|
698
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
699
|
+
continue;
|
|
710
700
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
701
|
+
}
|
|
702
|
+
canvas.fillStyle = item.style;
|
|
703
|
+
if (item.transform) {
|
|
704
|
+
canvas.save();
|
|
705
|
+
canvas.transform(item.transform);
|
|
706
|
+
if (item.blendMode)
|
|
707
|
+
canvas.blendMode = item.blendMode;
|
|
708
|
+
fillPathOrText(ui, canvas);
|
|
709
|
+
canvas.restore();
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
if (item.blendMode) {
|
|
713
|
+
canvas.saveBlendMode(item.blendMode);
|
|
714
|
+
fillPathOrText(ui, canvas);
|
|
715
|
+
canvas.restoreBlendMode();
|
|
720
716
|
}
|
|
717
|
+
else
|
|
718
|
+
fillPathOrText(ui, canvas);
|
|
721
719
|
}
|
|
722
720
|
}
|
|
723
721
|
}
|
|
722
|
+
function fillPathOrText(ui, canvas) {
|
|
723
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
724
|
+
}
|
|
724
725
|
|
|
725
726
|
function strokeText(stroke, ui, canvas) {
|
|
726
727
|
const { strokeAlign } = ui.__;
|
|
@@ -960,6 +961,7 @@ const PaintModule = {
|
|
|
960
961
|
compute,
|
|
961
962
|
fill,
|
|
962
963
|
fills,
|
|
964
|
+
fillPathOrText,
|
|
963
965
|
fillText,
|
|
964
966
|
stroke,
|
|
965
967
|
strokes,
|
|
@@ -1152,6 +1154,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1152
1154
|
onLoadError(ui, event, error);
|
|
1153
1155
|
leafPaint.loadId = null;
|
|
1154
1156
|
});
|
|
1157
|
+
if (ui.placeholderColor)
|
|
1158
|
+
setTimeout(() => {
|
|
1159
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
1160
|
+
image.isPlacehold = true;
|
|
1161
|
+
ui.forceUpdate('surface');
|
|
1162
|
+
}
|
|
1163
|
+
}, 100);
|
|
1155
1164
|
}
|
|
1156
1165
|
return leafPaint;
|
|
1157
1166
|
}
|
|
@@ -2237,4 +2246,3 @@ Object.keys(draw).forEach(function (k) {
|
|
|
2237
2246
|
get: function () { return draw[k]; }
|
|
2238
2247
|
});
|
|
2239
2248
|
});
|
|
2240
|
-
//# sourceMappingURL=worker.cjs.map
|
package/dist/worker.esm.js
CHANGED
|
@@ -187,7 +187,7 @@ class Watcher {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
190
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
|
|
191
191
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
192
192
|
function updateMatrix(updateList, levelList) {
|
|
193
193
|
let layout;
|
|
@@ -230,15 +230,7 @@ function updateBounds(boundsList) {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
function updateChange(updateList) {
|
|
233
|
-
|
|
234
|
-
updateList.list.forEach(leaf => {
|
|
235
|
-
layout = leaf.__layout;
|
|
236
|
-
if (layout.opacityChanged)
|
|
237
|
-
updateAllWorldOpacity(leaf);
|
|
238
|
-
if (layout.stateStyleChanged)
|
|
239
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
240
|
-
leaf.__updateChange();
|
|
241
|
-
});
|
|
233
|
+
updateList.list.forEach(updateOneChange);
|
|
242
234
|
}
|
|
243
235
|
|
|
244
236
|
const { worldBounds } = LeafBoundsHelper;
|
|
@@ -459,6 +451,15 @@ class Renderer {
|
|
|
459
451
|
}
|
|
460
452
|
checkRender() {
|
|
461
453
|
if (this.running) {
|
|
454
|
+
const { target } = this;
|
|
455
|
+
if (target.isApp) {
|
|
456
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
457
|
+
target.children.forEach(leafer => {
|
|
458
|
+
leafer.renderer.FPS = this.FPS;
|
|
459
|
+
leafer.renderer.checkRender();
|
|
460
|
+
});
|
|
461
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
462
|
+
}
|
|
462
463
|
if (this.changed && this.canvas.view)
|
|
463
464
|
this.render();
|
|
464
465
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -544,7 +545,7 @@ class Renderer {
|
|
|
544
545
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
545
546
|
canvas.clearWorld(bounds, true);
|
|
546
547
|
canvas.clipWorld(bounds, true);
|
|
547
|
-
this.__render(bounds,
|
|
548
|
+
this.__render(bounds, realBounds);
|
|
548
549
|
canvas.restore();
|
|
549
550
|
Run.end(t);
|
|
550
551
|
}
|
|
@@ -553,12 +554,12 @@ class Renderer {
|
|
|
553
554
|
const { canvas } = this;
|
|
554
555
|
canvas.save();
|
|
555
556
|
canvas.clear();
|
|
556
|
-
this.__render(canvas.bounds
|
|
557
|
+
this.__render(canvas.bounds);
|
|
557
558
|
canvas.restore();
|
|
558
559
|
Run.end(t);
|
|
559
560
|
}
|
|
560
|
-
__render(bounds,
|
|
561
|
-
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
561
|
+
__render(bounds, realBounds) {
|
|
562
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
562
563
|
if (this.needFill)
|
|
563
564
|
canvas.fillWorld(bounds, this.config.fill);
|
|
564
565
|
if (Debug.showRepaint)
|
|
@@ -585,22 +586,14 @@ class Renderer {
|
|
|
585
586
|
}
|
|
586
587
|
__requestRender() {
|
|
587
588
|
const target = this.target;
|
|
588
|
-
if (target
|
|
589
|
-
return target.parentApp.renderer.update(false);
|
|
590
|
-
if (this.requestTime)
|
|
589
|
+
if (this.requestTime || !target)
|
|
591
590
|
return;
|
|
591
|
+
if (target.parentApp)
|
|
592
|
+
return target.parentApp.requestRender(false);
|
|
592
593
|
const requestTime = this.requestTime = Date.now();
|
|
593
594
|
Platform.requestRender(() => {
|
|
594
595
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
595
596
|
this.requestTime = 0;
|
|
596
|
-
if (target.isApp) {
|
|
597
|
-
target.emit(RenderEvent.CHILD_START, target);
|
|
598
|
-
target.children.forEach(leafer => {
|
|
599
|
-
leafer.renderer.FPS = this.FPS;
|
|
600
|
-
leafer.renderer.checkRender();
|
|
601
|
-
});
|
|
602
|
-
target.emit(RenderEvent.CHILD_END, target);
|
|
603
|
-
}
|
|
604
597
|
this.checkRender();
|
|
605
598
|
});
|
|
606
599
|
}
|
|
@@ -671,8 +664,10 @@ Object.assign(Creator, {
|
|
|
671
664
|
Platform.layout = Layouter.fullLayout;
|
|
672
665
|
|
|
673
666
|
function fillText(ui, canvas) {
|
|
674
|
-
|
|
675
|
-
|
|
667
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
668
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
669
|
+
canvas.fillStyle = data.placeholderColor;
|
|
670
|
+
let row;
|
|
676
671
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
677
672
|
row = rows[i];
|
|
678
673
|
if (row.text)
|
|
@@ -681,7 +676,7 @@ function fillText(ui, canvas) {
|
|
|
681
676
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
682
677
|
}
|
|
683
678
|
if (decorationY) {
|
|
684
|
-
const { decorationColor, decorationHeight } = data;
|
|
679
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
685
680
|
if (decorationColor)
|
|
686
681
|
canvas.fillStyle = decorationColor;
|
|
687
682
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -690,38 +685,44 @@ function fillText(ui, canvas) {
|
|
|
690
685
|
|
|
691
686
|
function fill(fill, ui, canvas) {
|
|
692
687
|
canvas.fillStyle = fill;
|
|
693
|
-
|
|
688
|
+
fillPathOrText(ui, canvas);
|
|
694
689
|
}
|
|
695
690
|
function fills(fills, ui, canvas) {
|
|
696
691
|
let item;
|
|
697
|
-
const { windingRule, __font } = ui.__;
|
|
698
692
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
699
693
|
item = fills[i];
|
|
700
|
-
if (item.image
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
if (item.blendMode)
|
|
708
|
-
canvas.blendMode = item.blendMode;
|
|
709
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
710
|
-
canvas.restore();
|
|
694
|
+
if (item.image) {
|
|
695
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
696
|
+
continue;
|
|
697
|
+
if (!item.style) {
|
|
698
|
+
if (!i && item.image.isPlacehold)
|
|
699
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
700
|
+
continue;
|
|
711
701
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
702
|
+
}
|
|
703
|
+
canvas.fillStyle = item.style;
|
|
704
|
+
if (item.transform) {
|
|
705
|
+
canvas.save();
|
|
706
|
+
canvas.transform(item.transform);
|
|
707
|
+
if (item.blendMode)
|
|
708
|
+
canvas.blendMode = item.blendMode;
|
|
709
|
+
fillPathOrText(ui, canvas);
|
|
710
|
+
canvas.restore();
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
if (item.blendMode) {
|
|
714
|
+
canvas.saveBlendMode(item.blendMode);
|
|
715
|
+
fillPathOrText(ui, canvas);
|
|
716
|
+
canvas.restoreBlendMode();
|
|
721
717
|
}
|
|
718
|
+
else
|
|
719
|
+
fillPathOrText(ui, canvas);
|
|
722
720
|
}
|
|
723
721
|
}
|
|
724
722
|
}
|
|
723
|
+
function fillPathOrText(ui, canvas) {
|
|
724
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
725
|
+
}
|
|
725
726
|
|
|
726
727
|
function strokeText(stroke, ui, canvas) {
|
|
727
728
|
const { strokeAlign } = ui.__;
|
|
@@ -961,6 +962,7 @@ const PaintModule = {
|
|
|
961
962
|
compute,
|
|
962
963
|
fill,
|
|
963
964
|
fills,
|
|
965
|
+
fillPathOrText,
|
|
964
966
|
fillText,
|
|
965
967
|
stroke,
|
|
966
968
|
strokes,
|
|
@@ -1153,6 +1155,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1153
1155
|
onLoadError(ui, event, error);
|
|
1154
1156
|
leafPaint.loadId = null;
|
|
1155
1157
|
});
|
|
1158
|
+
if (ui.placeholderColor)
|
|
1159
|
+
setTimeout(() => {
|
|
1160
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
1161
|
+
image.isPlacehold = true;
|
|
1162
|
+
ui.forceUpdate('surface');
|
|
1163
|
+
}
|
|
1164
|
+
}, 100);
|
|
1156
1165
|
}
|
|
1157
1166
|
return leafPaint;
|
|
1158
1167
|
}
|
|
@@ -2218,4 +2227,3 @@ Object.assign(Effect, EffectModule);
|
|
|
2218
2227
|
useCanvas();
|
|
2219
2228
|
|
|
2220
2229
|
export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
|
|
2221
|
-
//# sourceMappingURL=worker.esm.js.map
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,FileHelper as i,Creator as s,LeaferImage as o,defineKey as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as _,Bounds as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as A,PointHelper as L,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as C,Export as M,Group as D,TextConvert as I,Paint as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class Y extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:G}=i;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:G(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:G(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new Y(t,e),image:t=>new o(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:N}=navigator;N.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):N.indexOf("Safari")>-1&&-1===N.indexOf("Chrome")&&(e.fullImageShadow=!0),N.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):N.indexOf("Mac")>-1?e.os="Mac":N.indexOf("Linux")>-1&&(e.os="Linux");class U{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:j,updateBounds:q,updateAllWorldOpacity:X}=f,{pushAllChildBranch:H,pushAllParent:V}=p;const{worldBounds:Q}=_;class Z{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Q),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:$,updateAllChange:J}=f,K=w.get("Layouter");class tt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(j(t,!0),e.add(t),t.isBranch&&H(t,e),V(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),V(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||q(i[t])}q(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&X(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),tt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){$(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),J(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new Z([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new Z(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const et=w.get("Renderer");class nt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,et.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,et.error(t)}et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return et.warn("rendering");if(this.times>3)return et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=new g(i);n.save(),i.spread(nt.clipSpread).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0),this.__render(i,t.includes(this.target.__world),s),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const{canvas:i}=this,s=e?{includes:e}:{bounds:t,includes:e};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=n=n||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(t.parentApp)return t.parentApp.renderer.update(!1);if(this.requestTime)return;const n=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new g(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||et.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function it(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)}));if(o){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function st(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?rt(t,!0,e,n):at(e,n);break;case"inside":ot("inside",t,s,e,n);break;case"outside":ot("outside",t,s,e,n)}}function ot(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?rt(e,!0,i,r):at(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",it(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function at(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function rt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?at(n,i):i.stroke(),i.restoreBlendMode()):e?at(n,i):i.stroke())}function dt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}nt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new U(t,e),layouter:(t,e)=>new tt(t,e),renderer:(t,e,n)=>new nt(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=tt.fullLayout;const{getSpread:lt,getOuterOf:ct,getByMove:ht,getIntersectData:ut}=B;let ft;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!ft||!ft[e.url]);case"linear":return C.linearGradient(e,i);case"radial":return C.radialGradient(e,i);case"angular":return C.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const _t={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),ft=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?it(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?it(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?it(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?it(e,n):s?n.fill(s):n.fill())},fillText:it,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)st(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&dt(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)st(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),rt(t,!1,e,n),i.__useArrow&&dt(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),rt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),rt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:st,drawTextStroke:at,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ut(i?lt(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ct(s,a),o=ht(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let gt={};const{get:wt,rotateOfOuter:yt,translate:mt,scaleOfOuter:vt,scale:xt,rotate:bt}=R;function Bt(t,e,n,i,s,o,a){const r=wt();mt(r,e.x+n,e.y+i),xt(r,s,o),a&&yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Rt(t,e,n,i,s,o,a){const r=wt();mt(r,e.x+n,e.y+i),s&&xt(r,s,o),a&&bt(r,a),t.transform=r}function kt(t,e,n,i,s,o,a,r,d,l){const c=wt();if(d)if("center"===l)yt(c,{x:n/2,y:i/2},d);else switch(bt(c,d),d){case 90:mt(c,i,0);break;case 180:mt(c,n,i);break;case 270:mt(c,0,n)}gt.x=e.x+s,gt.y=e.y+o,mt(c,gt.x,gt.y),a&&vt(c,gt,a,r),t.transform=c}const{get:Et,translate:St}=R,At=new g,Lt={},Wt={};function Ot(t,e,n,i){const{blendMode:s,changeful:o,sync:a}=n;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Tt(n,i,e)}function Tt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===i&&e.height===s,_={mode:a},g="center"!==r&&(h||0)%180==90,w=g?s:i,y=g?i:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Wt),m=Wt.scaleX,v=Wt.scaleY);else if(!p||h){const t=e.width/w,n=e.height/y;m=v="fit"===a?Math.min(t,n):Math.max(t,n),x+=(e.width-i*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Lt,!0),x+=Lt.x,b+=Lt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":p||(i=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&Rt(_,e,x,b,m,v,h);break;case"repeat":(!p||m||h)&&kt(_,e,i,s,x,b,m,v,h,r),u||(_.repeat="repeat");break;default:m&&Bt(_,e,x,b,m,v,h)}return _.transform||(e.x||e.y)&&(_.transform=Et(),St(_.transform,e.x,e.y)),m&&"stretch"!==a&&(_.scaleX=m,_.scaleY=v),_.width=i,_.height=s,o&&(_.opacity=o),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ct,Mt=new g;const{isSame:Dt}=B;function It(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Ot(s,i,n,o),!0}function Pt(t,e){Gt(t,S.LOAD,e)}function Ft(t,e){Gt(t,S.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),Gt(t,S.ERROR,e)}function Gt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function zt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:Ut,copy:jt}=R,{ceil:qt,abs:Xt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Xt(s),o=Xt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=Nt(),jt(l,p),Ut(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const g=c*h;if(!_&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&jt(l,p)),Ut(l,1/s,1/o));const y=t.getCanvas(qt(c)||1,qt(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,n);return n.style=m,n.patternId=a,!0}}function Vt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Qt}=Math;const Zt={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ct&&n===Ct.paint&&Dt(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Mt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(It(t,e,n,r,o,i),s&&(Pt(t,a),Ft(t,a))):r.error?s&&Yt(t,a,r.error):(s&&(zt(t,!0),Pt(t,a)),o.loadId=r.load((()=>{zt(t,!1),t.destroyed||(It(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ft(t,a)),o.loadId=null}),(e=>{zt(t,!1),Yt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n,{data:d}=i;if(!d||i.patternId===o+"-"+a+"-"+r&&!M.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||b.isResizing(t)||M.running)){let{width:t,height:n}=d;t*=Qt(o)*r,n*=Qt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize}return s?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,n,i,d),!0):(!i.style||i.sync||M.running?Ht(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Vt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:Ht,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a,r;for(let d=0,l=n.length;d<l;d++)i=n[d],s=i.image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,x.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(n[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Ot,getPatternData:Tt,fillOrFitMode:Bt,clipMode:Rt,repeatMode:kt},{toPoint:$t}=A,Jt={},Kt={};function te(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ee,getDistance:ne}=L,{get:ie,rotateOfOuter:se,scaleOfOuter:oe}=R,{toPoint:ae}=A,re={},de={};function le(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ee(e,n);o=ie(),s?(oe(o,e,a/r*(i||1),1),se(o,e,t+90)):(oe(o,e,1,a/r*(i||1)),se(o,e,t))}return o}const{getDistance:ce}=L,{toPoint:he}=A,ue={},fe={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;$t(i||"top",n,Jt),$t(s||"bottom",n,Kt);const d=e.canvas.createLinearGradient(Jt.x,Jt.y,Kt.x,Kt.y);te(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ae(i||"center",n,re),ae(s||"bottom",n,de);const l=e.canvas.createRadialGradient(re.x,re.y,0,re.x,re.y,ne(re,de));te(l,t.stops,a);const c={type:o,style:l},h=le(n,re,de,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;he(i||"center",n,ue),he(s||"bottom",n,fe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,ue.x,ue.y):e.canvas.createRadialGradient(ue.x,ue.y,0,ue.x,ue.y,ce(ue,fe));te(l,t.stops,a);const c={type:o,style:l},h=le(n,ue,fe,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:le},{copy:_e,toOffsetOutBounds:ge}=B,we={},ye={};function me(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(_e(we,t.bounds),we.x+=n.x-a.x,we.y+=n.y-a.y,i){const{matrix:t}=s;we.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),we.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),we.width*=i,we.height*=i}t.copyWorld(s.canvas,t.bounds,we)}else i&&(_e(we,n),we.x-=n.width/2*(i-1),we.y-=n.height/2*(i-1),we.width*=i,we.height*=i),t.copyWorld(s.canvas,a,i?we:n)}const{toOffsetOutBounds:ve}=B,xe={};const be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;ge(l,ye),r.forEach(((r,_)=>{f.setWorldShadow(ye.offsetX+r.x*h,ye.offsetY+r.y*u,r.blur*h,T.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,me(f,ye,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;ve(l,xe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(xe.offsetX+r.x*h,xe.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,me(f,xe,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,T.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Be}=_;function Re(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ee(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ee(t,n,i,o);break;case"path":n.restore()}}function ke(t){return t.getSameCanvas(!1,!0)}function Ee(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(Re(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=ke(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=ke(t)),s||(s=ke(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Be(n,e)||n.__render(s||t,e);Re(this,a,t,s,i,o)};const Se=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Se+"_#~&*+\\=|≮≯≈≠=…",Le=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function We(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Oe=We("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Te=We("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=We(Se),Me=We(Ae),De=We("- —/~|┆·");var Ie;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Ie||(Ie={}));const{Letter:Pe,Single:Fe,Before:Ye,After:Ge,Symbol:ze,Break:Ne}=Ie;function Ue(t){return Oe[t]?Pe:De[t]?Ne:Te[t]?Ye:Ce[t]?Ge:Me[t]?ze:Le.test(t)?Fe:Pe}const je={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function qe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Xe}=je,{Letter:He,Single:Ve,Before:Qe,After:Ze,Symbol:$e,Break:Je}=Ie;let Ke,tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn=[];function yn(t,e){dn&&!rn&&(rn=dn),Ke.data.push({char:t,width:e}),en+=e}function mn(){nn+=en,Ke.width=en,tn.words.push(Ke),Ke={data:[]},en=0}function vn(){fn&&(pn.paraNumber++,tn.paraStart=!0,fn=!1),dn&&(tn.startCharSize=rn,tn.endCharSize=dn,rn=0),tn.width=nn,_n.width?Xe(tn):gn&&xn(),wn.push(tn),tn={words:[]},nn=0}function xn(){nn>(pn.maxWidth||0)&&(pn.maxWidth=nn)}const{top:bn,right:Bn,bottom:Rn,left:kn}=W;function En(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Sn={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[kn],o-=l[Bn]+l[kn]):n.autoSizeAlign||(i=l[kn]),a?(s=l[bn],a-=l[bn]+l[Rn]):n.autoSizeAlign||(s=l[bn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,wn=t.rows,_n=t.bounds,gn=!_n.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=_n;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;fn=!0,cn=null,rn=an=dn=en=nn=0,Ke={data:[]},tn={words:[]};for(let i=0,l=n.length;i<l;i++)on=n[i],"\n"===on?(en&&mn(),tn.paraEnd=!0,vn(),fn=!0):(ln=Ue(on),ln===He&&"none"!==a&&(on=qe(on,a,!en)),an=r.measureText(on).width,s&&(s<0&&(dn=an),an+=s),hn=ln===Ve&&(cn===Ve||cn===He)||cn===Ve&&ln!==Ze,un=!(ln!==Qe&&ln!==Ve||cn!==$e&&cn!==Ze),sn=fn&&o?d-o:d,t&&d&&nn+en+an>sn&&(e?(en&&mn(),nn&&vn()):(un||(un=ln===He&&cn==Ze),hn||un||ln===Je||ln===Qe||ln===Ve||en+an>sn?(en&&mn(),nn&&vn()):nn&&vn()))," "===on&&!0!==fn&&nn+en===0||(ln===Je?(" "===on&&en&&mn(),yn(on,an),mn()):hn||un?(en&&mn(),yn(on,an)):yn(on,an)),cn=ln);en&&mn(),nn&&vn(),wn.length>0&&(wn[wn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,nn=r.measureText(t).width,wn.push({x:o||0,text:t,width:nn,paraStart:!0}),gn&&xn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":En(e,"x",t[kn]);break;case"right":En(e,"x",-t[Bn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":En(e,"y",t[bn]);break;case"bottom":En(e,"y",-t[Rn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:_,height:g}=i,w=o*s+(h?h*(t.paraNumber-1):0),y=a;if(d&&w>g)w=Math.max(g,o),s>1&&(t.overflow=s);else if(g||u)switch(c){case"middle":p+=(g-w)/2;break;case"bottom":p+=g-w}y+=p;let m,v,x,b=_||u?_:t.maxWidth;for(let a=0,c=s;a<c;a++){if(m=n[a],m.x=f,m.width<_||m.width>_&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&a>0&&(y+=h),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),d&&_&&_<x&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(c,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){let n;const{fontSize:i,textDecoration:s}=e;switch(t.decorationHeight=i/11,"object"==typeof s?(n=s.type,s.color&&(t.decorationColor=T.string(s.color))):n=s,n){case"under":t.decorationY=[.15*i];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i,.35*-i]}}(c,n),c}};const An={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,Sn),Object.assign(T,An),Object.assign(P,_t),Object.assign(O,Zt),Object.assign(C,pe),Object.assign(F,be),z();export{tt as Layouter,Y as LeaferCanvas,nt as Renderer,U as Watcher,z as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,FileHelper as i,Creator as s,LeaferImage as o,defineKey as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,LeafBoundsHelper as p,Bounds as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as C,Export as M,Group as D,TextConvert as P,Paint as I,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class Y extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:G}=i;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:G(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:G(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new Y(t,e),image:t=>new o(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:U}=navigator;U.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):U.indexOf("Safari")>-1&&-1===U.indexOf("Chrome")&&(e.fullImageShadow=!0),U.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):U.indexOf("Mac")>-1?e.os="Mac":U.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:j,updateChange:X}=f,{pushAllChildBranch:H,pushAllParent:V}=_;const{worldBounds:Q}=p;class Z{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Q),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:$,updateAllChange:J}=f,K=w.get("Layouter");class tt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&H(t,e),V(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),V(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||j(i[t])}j(n)}}))}(this.__levelList),function(t){t.list.forEach(X)}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),tt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){$(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),J(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new Z([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new Z(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const et=w.get("Renderer");class nt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,et.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,et.error(t)}et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return et.warn("rendering");if(this.times>3)return et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=new g(i);n.save(),i.spread(nt.clipSpread).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0),this.__render(i,s),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:n}=this,i=t.includes(this.target.__world),s=i?{includes:i}:{bounds:t,includes:i};this.needFill&&n.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(n,t),this.target.__render(n,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),n.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const n=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new g(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||et.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function it(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function st(t,e){t.__.__font?it(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ot(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":at("inside",t,s,e,n);break;case"outside":at("outside",t,s,e,n)}}function at(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",it(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function dt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}nt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new tt(t,e),renderer:(t,e,n)=>new nt(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=tt.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=B;let _t;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return C.linearGradient(e,i);case"radial":return C.radialGradient(e,i);case"angular":return C.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const gt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,st(e,n)},fills:function(t,e,n){let i;for(let s=0,o=t.length;s<o;s++){if(i=t[s],i.image){if(O.checkImage(e,n,i,!e.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&e.drawImagePlaceholder(n,i.image);continue}}n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),st(e,n),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),st(e,n),n.restoreBlendMode()):st(e,n)}},fillPathOrText:st,fillText:it,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),dt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ft(i?ct(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ht(s,a),o=ut(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=R;function Rt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function Et(t,e,n,i,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:n/2,y:i/2},d);else switch(Bt(c,d),d){case 90:vt(c,i,0);break;case 180:vt(c,n,i);break;case 270:vt(c,0,n)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:St,translate:Lt}=R,At=new g,Wt={},Ot={};function Tt(t,e,n,i){const{blendMode:s,changeful:o,sync:a}=n;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Ct(n,i,e)}function Ct(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:f}=t,_=e.width===i&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,w=g?s:i,y=g?i:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ot),m=Ot.scaleX,v=Ot.scaleY);else if(!_||h){const t=e.width/w,n=e.height/y;m=v="fit"===a?Math.min(t,n):Math.max(t,n),x+=(e.width-i*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Wt,!0),x+=Wt.x,b+=Wt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":_||(i=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&kt(p,e,x,b,m,v,h);break;case"repeat":(!_||m||h)&&Et(p,e,i,s,x,b,m,v,h,r),u||(p.repeat="repeat");break;default:m&&Rt(p,e,x,b,m,v,h)}return p.transform||(e.x||e.y)&&(p.transform=St(),Lt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=i,p.height=s,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Mt,Dt=new g;const{isSame:Pt}=B;function It(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Ft(t,e){zt(t,S.LOAD,e)}function Yt(t,e){zt(t,S.LOADED,e)}function Gt(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,S.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:qt,copy:jt}=R,{ceil:Xt,abs:Ht}=Math;function Vt(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Ht(s),o=Ht(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:_,repeat:p}=r;u&&(l=Nt(),jt(l,_),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const g=c*h;if(!p&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=Nt(),_&&jt(l,_)),qt(l,1/s,1/o));const y=t.getCanvas(Xt(c)||1,Xt(h)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",l,n);return n.style=m,n.patternId=a,!0}}function Qt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Mt&&n===Mt.paint&&Pt(i,Mt.boxBounds)?o=Mt.leafPaint:(o={type:n.type,image:r},Mt=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(It(t,e,n,r,o,i),s&&(Ft(t,a),Yt(t,a))):r.error?s&&Gt(t,a,r.error):(s&&(Ut(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(It(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Gt(t,a,e),o.loadId=null})),t.placeholderColor&&setTimeout((()=>{r.ready||r.isPlacehold||(r.isPlacehold=!0,t.forceUpdate("surface"))}),100)),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n,{data:d}=i;if(!d||i.patternId===o+"-"+a+"-"+r&&!M.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||b.isResizing(t)||M.running)){let{width:t,height:n}=d;t*=Zt(o)*r,n*=Zt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize}return s?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,n,i,d),!0):(!i.style||i.sync||M.running?Vt(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Vt(t,i,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:Vt,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a,r;for(let d=0,l=n.length;d<l;d++)i=n[d],s=i.image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,x.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(n[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Tt,getPatternData:Ct,fillOrFitMode:Rt,clipMode:kt,repeatMode:Et},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ne,getDistance:ie}=A,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=L,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=A,{toPoint:ue}=L,fe={},_e={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Jt(i||"top",n,Kt),Jt(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(i||"center",n,fe),ue(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,_e));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;we(l,me),r.forEach(((r,p)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,T.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;xe(l,be),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,T.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=p;function ke(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(ke(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",We=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Me=Oe(Le),De=Oe(Ae),Pe=Oe("- —/~|┆·");var Ie;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Ie||(Ie={}));const{Letter:Fe,Single:Ye,Before:Ge,After:ze,Symbol:Ue,Break:Ne}=Ie;function qe(t){return Te[t]?Fe:Pe[t]?Ne:Ce[t]?Ge:Me[t]?ze:De[t]?Ue:We.test(t)?Ye:Fe}const je={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function Xe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:He}=je,{Letter:Ve,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Ie;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn=[];function mn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function vn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){_n&&(pn.paraNumber++,en.paraStart=!0,_n=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width?He(en):wn&&bn(),yn.push(en),en={words:[]},sn=0}function bn(){sn>(pn.maxWidth||0)&&(pn.maxWidth=sn)}const{top:Bn,right:Rn,bottom:kn,left:En}=W;function Sn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ln={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[En],o-=l[Rn]+l[En]):n.autoSizeAlign||(i=l[En]),a?(s=l[Bn],a-=l[Bn]+l[kn]):n.autoSizeAlign||(s=l[Bn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,yn=t.rows,gn=t.bounds,wn=!gn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&vn(),en.paraEnd=!0,xn(),_n=!0):(cn=qe(an),cn===Ve&&"none"!==a&&(an=Xe(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===Ve)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),on=_n&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&vn(),sn&&xn()):(fn||(fn=cn===Ve&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>on?(nn&&vn(),sn&&xn()):sn&&xn()))," "===an&&!0!==_n&&sn+nn===0||(cn===Ke?(" "===an&&nn&&vn(),mn(an,rn),vn()):un||fn?(nn&&vn(),mn(an,rn)):mn(an,rn)),hn=cn);nn&&vn(),sn&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,sn=r.measureText(t).width,yn.push({x:o||0,text:t,width:sn,paraStart:!0}),wn&&bn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Sn(e,"x",t[En]);break;case"right":Sn(e,"x",-t[Rn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Sn(e,"y",t[Bn]);break;case"bottom":Sn(e,"y",-t[kn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:_,width:p,height:g}=i,w=o*s+(h?h*(t.paraNumber-1):0),y=a;if(d&&w>g)w=Math.max(g,o),s>1&&(t.overflow=s);else if(g||u)switch(c){case"middle":_+=(g-w)/2;break;case"bottom":_+=g-w}y+=_;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,c=s;a<c;a++){if(m=n[a],m.x=f,m.width<p||m.width>p&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&a>0&&(y+=h),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),d&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=w}(c,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){let n;const{fontSize:i,textDecoration:s}=e;switch(t.decorationHeight=i/11,"object"==typeof s?(n=s.type,s.color&&(t.decorationColor=T.string(s.color))):n=s,n){case"under":t.decorationY=[.15*i];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i,.35*-i]}}(c,n),c}};const An={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(P,Ln),Object.assign(T,An),Object.assign(I,gt),Object.assign(O,$t),Object.assign(C,pe),Object.assign(F,Be),z();export{tt as Layouter,Y as LeaferCanvas,nt as Renderer,N as Watcher,z as useCanvas};
|
|
2
2
|
//# sourceMappingURL=worker.esm.min.js.map
|