@leafer-draw/node 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/node.cjs +63 -53
- package/dist/node.esm.js +63 -53
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
- package/dist/node.cjs.map +0 -1
- package/dist/node.esm.js.map +0 -1
package/dist/node.cjs
CHANGED
|
@@ -199,7 +199,7 @@ class Watcher {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
202
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
|
|
203
203
|
const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
|
|
204
204
|
function updateMatrix(updateList, levelList) {
|
|
205
205
|
let layout;
|
|
@@ -242,15 +242,7 @@ function updateBounds(boundsList) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
function updateChange(updateList) {
|
|
245
|
-
|
|
246
|
-
updateList.list.forEach(leaf => {
|
|
247
|
-
layout = leaf.__layout;
|
|
248
|
-
if (layout.opacityChanged)
|
|
249
|
-
updateAllWorldOpacity(leaf);
|
|
250
|
-
if (layout.stateStyleChanged)
|
|
251
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
252
|
-
leaf.__updateChange();
|
|
253
|
-
});
|
|
245
|
+
updateList.list.forEach(updateOneChange);
|
|
254
246
|
}
|
|
255
247
|
|
|
256
248
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
@@ -471,6 +463,15 @@ class Renderer {
|
|
|
471
463
|
}
|
|
472
464
|
checkRender() {
|
|
473
465
|
if (this.running) {
|
|
466
|
+
const { target } = this;
|
|
467
|
+
if (target.isApp) {
|
|
468
|
+
target.emit(core.RenderEvent.CHILD_START, target);
|
|
469
|
+
target.children.forEach(leafer => {
|
|
470
|
+
leafer.renderer.FPS = this.FPS;
|
|
471
|
+
leafer.renderer.checkRender();
|
|
472
|
+
});
|
|
473
|
+
target.emit(core.RenderEvent.CHILD_END, target);
|
|
474
|
+
}
|
|
474
475
|
if (this.changed && this.canvas.view)
|
|
475
476
|
this.render();
|
|
476
477
|
this.target.emit(core.RenderEvent.NEXT);
|
|
@@ -556,7 +557,7 @@ class Renderer {
|
|
|
556
557
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
557
558
|
canvas.clearWorld(bounds, true);
|
|
558
559
|
canvas.clipWorld(bounds, true);
|
|
559
|
-
this.__render(bounds,
|
|
560
|
+
this.__render(bounds, realBounds);
|
|
560
561
|
canvas.restore();
|
|
561
562
|
core.Run.end(t);
|
|
562
563
|
}
|
|
@@ -565,12 +566,12 @@ class Renderer {
|
|
|
565
566
|
const { canvas } = this;
|
|
566
567
|
canvas.save();
|
|
567
568
|
canvas.clear();
|
|
568
|
-
this.__render(canvas.bounds
|
|
569
|
+
this.__render(canvas.bounds);
|
|
569
570
|
canvas.restore();
|
|
570
571
|
core.Run.end(t);
|
|
571
572
|
}
|
|
572
|
-
__render(bounds,
|
|
573
|
-
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
573
|
+
__render(bounds, realBounds) {
|
|
574
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
574
575
|
if (this.needFill)
|
|
575
576
|
canvas.fillWorld(bounds, this.config.fill);
|
|
576
577
|
if (core.Debug.showRepaint)
|
|
@@ -597,22 +598,14 @@ class Renderer {
|
|
|
597
598
|
}
|
|
598
599
|
__requestRender() {
|
|
599
600
|
const target = this.target;
|
|
600
|
-
if (target
|
|
601
|
-
return target.parentApp.renderer.update(false);
|
|
602
|
-
if (this.requestTime)
|
|
601
|
+
if (this.requestTime || !target)
|
|
603
602
|
return;
|
|
603
|
+
if (target.parentApp)
|
|
604
|
+
return target.parentApp.requestRender(false);
|
|
604
605
|
const requestTime = this.requestTime = Date.now();
|
|
605
606
|
core.Platform.requestRender(() => {
|
|
606
607
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
607
608
|
this.requestTime = 0;
|
|
608
|
-
if (target.isApp) {
|
|
609
|
-
target.emit(core.RenderEvent.CHILD_START, target);
|
|
610
|
-
target.children.forEach(leafer => {
|
|
611
|
-
leafer.renderer.FPS = this.FPS;
|
|
612
|
-
leafer.renderer.checkRender();
|
|
613
|
-
});
|
|
614
|
-
target.emit(core.RenderEvent.CHILD_END, target);
|
|
615
|
-
}
|
|
616
609
|
this.checkRender();
|
|
617
610
|
});
|
|
618
611
|
}
|
|
@@ -683,8 +676,10 @@ Object.assign(core.Creator, {
|
|
|
683
676
|
core.Platform.layout = Layouter.fullLayout;
|
|
684
677
|
|
|
685
678
|
function fillText(ui, canvas) {
|
|
686
|
-
|
|
687
|
-
|
|
679
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
680
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
681
|
+
canvas.fillStyle = data.placeholderColor;
|
|
682
|
+
let row;
|
|
688
683
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
689
684
|
row = rows[i];
|
|
690
685
|
if (row.text)
|
|
@@ -693,7 +688,7 @@ function fillText(ui, canvas) {
|
|
|
693
688
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
694
689
|
}
|
|
695
690
|
if (decorationY) {
|
|
696
|
-
const { decorationColor, decorationHeight } = data;
|
|
691
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
697
692
|
if (decorationColor)
|
|
698
693
|
canvas.fillStyle = decorationColor;
|
|
699
694
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -702,38 +697,44 @@ function fillText(ui, canvas) {
|
|
|
702
697
|
|
|
703
698
|
function fill(fill, ui, canvas) {
|
|
704
699
|
canvas.fillStyle = fill;
|
|
705
|
-
|
|
700
|
+
fillPathOrText(ui, canvas);
|
|
706
701
|
}
|
|
707
702
|
function fills(fills, ui, canvas) {
|
|
708
703
|
let item;
|
|
709
|
-
const { windingRule, __font } = ui.__;
|
|
710
704
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
711
705
|
item = fills[i];
|
|
712
|
-
if (item.image
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
if (item.blendMode)
|
|
720
|
-
canvas.blendMode = item.blendMode;
|
|
721
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
722
|
-
canvas.restore();
|
|
706
|
+
if (item.image) {
|
|
707
|
+
if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
708
|
+
continue;
|
|
709
|
+
if (!item.style) {
|
|
710
|
+
if (!i && item.image.isPlacehold)
|
|
711
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
712
|
+
continue;
|
|
723
713
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
714
|
+
}
|
|
715
|
+
canvas.fillStyle = item.style;
|
|
716
|
+
if (item.transform) {
|
|
717
|
+
canvas.save();
|
|
718
|
+
canvas.transform(item.transform);
|
|
719
|
+
if (item.blendMode)
|
|
720
|
+
canvas.blendMode = item.blendMode;
|
|
721
|
+
fillPathOrText(ui, canvas);
|
|
722
|
+
canvas.restore();
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
if (item.blendMode) {
|
|
726
|
+
canvas.saveBlendMode(item.blendMode);
|
|
727
|
+
fillPathOrText(ui, canvas);
|
|
728
|
+
canvas.restoreBlendMode();
|
|
733
729
|
}
|
|
730
|
+
else
|
|
731
|
+
fillPathOrText(ui, canvas);
|
|
734
732
|
}
|
|
735
733
|
}
|
|
736
734
|
}
|
|
735
|
+
function fillPathOrText(ui, canvas) {
|
|
736
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
737
|
+
}
|
|
737
738
|
|
|
738
739
|
function strokeText(stroke, ui, canvas) {
|
|
739
740
|
const { strokeAlign } = ui.__;
|
|
@@ -973,6 +974,7 @@ const PaintModule = {
|
|
|
973
974
|
compute,
|
|
974
975
|
fill,
|
|
975
976
|
fills,
|
|
977
|
+
fillPathOrText,
|
|
976
978
|
fillText,
|
|
977
979
|
stroke,
|
|
978
980
|
strokes,
|
|
@@ -1165,6 +1167,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1165
1167
|
onLoadError(ui, event, error);
|
|
1166
1168
|
leafPaint.loadId = null;
|
|
1167
1169
|
});
|
|
1170
|
+
if (ui.placeholderColor)
|
|
1171
|
+
setTimeout(() => {
|
|
1172
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
1173
|
+
image.isPlacehold = true;
|
|
1174
|
+
ui.forceUpdate('surface');
|
|
1175
|
+
}
|
|
1176
|
+
}, 100);
|
|
1168
1177
|
}
|
|
1169
1178
|
return leafPaint;
|
|
1170
1179
|
}
|
|
@@ -2233,7 +2242,7 @@ const ExportModule = {
|
|
|
2233
2242
|
else {
|
|
2234
2243
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2235
2244
|
const { worldTransform, isLeafer, leafer, isFrame } = leaf;
|
|
2236
|
-
const { slice, trim, padding, onCanvas } = options;
|
|
2245
|
+
const { slice, clip, trim, padding, onCanvas } = options;
|
|
2237
2246
|
const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
|
|
2238
2247
|
const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
|
|
2239
2248
|
const screenshot = options.screenshot || leaf.isApp;
|
|
@@ -2277,7 +2286,9 @@ const ExportModule = {
|
|
|
2277
2286
|
scaleData.scaleY *= pixelRatio;
|
|
2278
2287
|
pixelRatio = leaf.app.pixelRatio;
|
|
2279
2288
|
}
|
|
2280
|
-
|
|
2289
|
+
let { x, y, width, height } = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2290
|
+
if (clip)
|
|
2291
|
+
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
2281
2292
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2282
2293
|
let canvas = draw.Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
|
|
2283
2294
|
let sliceLeaf;
|
|
@@ -2425,4 +2436,3 @@ Object.keys(draw).forEach(function (k) {
|
|
|
2425
2436
|
get: function () { return draw[k]; }
|
|
2426
2437
|
});
|
|
2427
2438
|
});
|
|
2428
|
-
//# sourceMappingURL=node.cjs.map
|
package/dist/node.esm.js
CHANGED
|
@@ -200,7 +200,7 @@ class Watcher {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
203
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
|
|
204
204
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
205
205
|
function updateMatrix(updateList, levelList) {
|
|
206
206
|
let layout;
|
|
@@ -243,15 +243,7 @@ function updateBounds(boundsList) {
|
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
245
|
function updateChange(updateList) {
|
|
246
|
-
|
|
247
|
-
updateList.list.forEach(leaf => {
|
|
248
|
-
layout = leaf.__layout;
|
|
249
|
-
if (layout.opacityChanged)
|
|
250
|
-
updateAllWorldOpacity(leaf);
|
|
251
|
-
if (layout.stateStyleChanged)
|
|
252
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
253
|
-
leaf.__updateChange();
|
|
254
|
-
});
|
|
246
|
+
updateList.list.forEach(updateOneChange);
|
|
255
247
|
}
|
|
256
248
|
|
|
257
249
|
const { worldBounds } = LeafBoundsHelper;
|
|
@@ -472,6 +464,15 @@ class Renderer {
|
|
|
472
464
|
}
|
|
473
465
|
checkRender() {
|
|
474
466
|
if (this.running) {
|
|
467
|
+
const { target } = this;
|
|
468
|
+
if (target.isApp) {
|
|
469
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
470
|
+
target.children.forEach(leafer => {
|
|
471
|
+
leafer.renderer.FPS = this.FPS;
|
|
472
|
+
leafer.renderer.checkRender();
|
|
473
|
+
});
|
|
474
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
475
|
+
}
|
|
475
476
|
if (this.changed && this.canvas.view)
|
|
476
477
|
this.render();
|
|
477
478
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -557,7 +558,7 @@ class Renderer {
|
|
|
557
558
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
558
559
|
canvas.clearWorld(bounds, true);
|
|
559
560
|
canvas.clipWorld(bounds, true);
|
|
560
|
-
this.__render(bounds,
|
|
561
|
+
this.__render(bounds, realBounds);
|
|
561
562
|
canvas.restore();
|
|
562
563
|
Run.end(t);
|
|
563
564
|
}
|
|
@@ -566,12 +567,12 @@ class Renderer {
|
|
|
566
567
|
const { canvas } = this;
|
|
567
568
|
canvas.save();
|
|
568
569
|
canvas.clear();
|
|
569
|
-
this.__render(canvas.bounds
|
|
570
|
+
this.__render(canvas.bounds);
|
|
570
571
|
canvas.restore();
|
|
571
572
|
Run.end(t);
|
|
572
573
|
}
|
|
573
|
-
__render(bounds,
|
|
574
|
-
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
574
|
+
__render(bounds, realBounds) {
|
|
575
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
575
576
|
if (this.needFill)
|
|
576
577
|
canvas.fillWorld(bounds, this.config.fill);
|
|
577
578
|
if (Debug.showRepaint)
|
|
@@ -598,22 +599,14 @@ class Renderer {
|
|
|
598
599
|
}
|
|
599
600
|
__requestRender() {
|
|
600
601
|
const target = this.target;
|
|
601
|
-
if (target
|
|
602
|
-
return target.parentApp.renderer.update(false);
|
|
603
|
-
if (this.requestTime)
|
|
602
|
+
if (this.requestTime || !target)
|
|
604
603
|
return;
|
|
604
|
+
if (target.parentApp)
|
|
605
|
+
return target.parentApp.requestRender(false);
|
|
605
606
|
const requestTime = this.requestTime = Date.now();
|
|
606
607
|
Platform.requestRender(() => {
|
|
607
608
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
608
609
|
this.requestTime = 0;
|
|
609
|
-
if (target.isApp) {
|
|
610
|
-
target.emit(RenderEvent.CHILD_START, target);
|
|
611
|
-
target.children.forEach(leafer => {
|
|
612
|
-
leafer.renderer.FPS = this.FPS;
|
|
613
|
-
leafer.renderer.checkRender();
|
|
614
|
-
});
|
|
615
|
-
target.emit(RenderEvent.CHILD_END, target);
|
|
616
|
-
}
|
|
617
610
|
this.checkRender();
|
|
618
611
|
});
|
|
619
612
|
}
|
|
@@ -684,8 +677,10 @@ Object.assign(Creator, {
|
|
|
684
677
|
Platform.layout = Layouter.fullLayout;
|
|
685
678
|
|
|
686
679
|
function fillText(ui, canvas) {
|
|
687
|
-
|
|
688
|
-
|
|
680
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
681
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
682
|
+
canvas.fillStyle = data.placeholderColor;
|
|
683
|
+
let row;
|
|
689
684
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
690
685
|
row = rows[i];
|
|
691
686
|
if (row.text)
|
|
@@ -694,7 +689,7 @@ function fillText(ui, canvas) {
|
|
|
694
689
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
695
690
|
}
|
|
696
691
|
if (decorationY) {
|
|
697
|
-
const { decorationColor, decorationHeight } = data;
|
|
692
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
698
693
|
if (decorationColor)
|
|
699
694
|
canvas.fillStyle = decorationColor;
|
|
700
695
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -703,38 +698,44 @@ function fillText(ui, canvas) {
|
|
|
703
698
|
|
|
704
699
|
function fill(fill, ui, canvas) {
|
|
705
700
|
canvas.fillStyle = fill;
|
|
706
|
-
|
|
701
|
+
fillPathOrText(ui, canvas);
|
|
707
702
|
}
|
|
708
703
|
function fills(fills, ui, canvas) {
|
|
709
704
|
let item;
|
|
710
|
-
const { windingRule, __font } = ui.__;
|
|
711
705
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
712
706
|
item = fills[i];
|
|
713
|
-
if (item.image
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
if (item.blendMode)
|
|
721
|
-
canvas.blendMode = item.blendMode;
|
|
722
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
723
|
-
canvas.restore();
|
|
707
|
+
if (item.image) {
|
|
708
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
709
|
+
continue;
|
|
710
|
+
if (!item.style) {
|
|
711
|
+
if (!i && item.image.isPlacehold)
|
|
712
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
713
|
+
continue;
|
|
724
714
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
715
|
+
}
|
|
716
|
+
canvas.fillStyle = item.style;
|
|
717
|
+
if (item.transform) {
|
|
718
|
+
canvas.save();
|
|
719
|
+
canvas.transform(item.transform);
|
|
720
|
+
if (item.blendMode)
|
|
721
|
+
canvas.blendMode = item.blendMode;
|
|
722
|
+
fillPathOrText(ui, canvas);
|
|
723
|
+
canvas.restore();
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
if (item.blendMode) {
|
|
727
|
+
canvas.saveBlendMode(item.blendMode);
|
|
728
|
+
fillPathOrText(ui, canvas);
|
|
729
|
+
canvas.restoreBlendMode();
|
|
734
730
|
}
|
|
731
|
+
else
|
|
732
|
+
fillPathOrText(ui, canvas);
|
|
735
733
|
}
|
|
736
734
|
}
|
|
737
735
|
}
|
|
736
|
+
function fillPathOrText(ui, canvas) {
|
|
737
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
738
|
+
}
|
|
738
739
|
|
|
739
740
|
function strokeText(stroke, ui, canvas) {
|
|
740
741
|
const { strokeAlign } = ui.__;
|
|
@@ -974,6 +975,7 @@ const PaintModule = {
|
|
|
974
975
|
compute,
|
|
975
976
|
fill,
|
|
976
977
|
fills,
|
|
978
|
+
fillPathOrText,
|
|
977
979
|
fillText,
|
|
978
980
|
stroke,
|
|
979
981
|
strokes,
|
|
@@ -1166,6 +1168,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1166
1168
|
onLoadError(ui, event, error);
|
|
1167
1169
|
leafPaint.loadId = null;
|
|
1168
1170
|
});
|
|
1171
|
+
if (ui.placeholderColor)
|
|
1172
|
+
setTimeout(() => {
|
|
1173
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
1174
|
+
image.isPlacehold = true;
|
|
1175
|
+
ui.forceUpdate('surface');
|
|
1176
|
+
}
|
|
1177
|
+
}, 100);
|
|
1169
1178
|
}
|
|
1170
1179
|
return leafPaint;
|
|
1171
1180
|
}
|
|
@@ -2234,7 +2243,7 @@ const ExportModule = {
|
|
|
2234
2243
|
else {
|
|
2235
2244
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2236
2245
|
const { worldTransform, isLeafer, leafer, isFrame } = leaf;
|
|
2237
|
-
const { slice, trim, padding, onCanvas } = options;
|
|
2246
|
+
const { slice, clip, trim, padding, onCanvas } = options;
|
|
2238
2247
|
const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
|
|
2239
2248
|
const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
|
|
2240
2249
|
const screenshot = options.screenshot || leaf.isApp;
|
|
@@ -2278,7 +2287,9 @@ const ExportModule = {
|
|
|
2278
2287
|
scaleData.scaleY *= pixelRatio;
|
|
2279
2288
|
pixelRatio = leaf.app.pixelRatio;
|
|
2280
2289
|
}
|
|
2281
|
-
|
|
2290
|
+
let { x, y, width, height } = new Bounds$1(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2291
|
+
if (clip)
|
|
2292
|
+
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
2282
2293
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2283
2294
|
let canvas = Creator$1.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
|
|
2284
2295
|
let sliceLeaf;
|
|
@@ -2406,4 +2417,3 @@ UI.prototype.syncExport = function (filename, options) {
|
|
|
2406
2417
|
};
|
|
2407
2418
|
|
|
2408
2419
|
export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
|
|
2409
|
-
//# sourceMappingURL=node.esm.js.map
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,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 S,AlignHelper as k,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{PaintImage as O,ColorConvert as C,PaintGradient as M,Export as D,Group as P,TextConvert as I,Paint as F,Effect as Y,TwoPointBoundsHelper as U,Bounds as N,FileHelper as X,Platform as z,Matrix as j,MathHelper as G,Creator as q,TaskProcessor as H,Resource as V,LeaferCanvasBase as Q,Debug as J,Plugin as Z,UI as $}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function K(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class tt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:et,fileType:it}=n;function nt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(et(e),i),canvasToBolb:(t,e,i)=>K(this,void 0,void 0,(function*(){return t.toBuffer(et(e),i)})),canvasSaveAs:(t,e,i)=>K(this,void 0,void 0,(function*(){return T(e,t.toBuffer(et(it(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new tt(t,e),image:t=>new o(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class st{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,i=e.length;t<i;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:ot,updateBounds:at,updateAllWorldOpacity:rt}=f,{pushAllChildBranch:dt,pushAllParent:lt}=p;const{worldBounds:ct}=_;class ht{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,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:ut,updateAllChange:ft}=f,pt=w.get("Layouter");class _t{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){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.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:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(ot(t,!0),e.add(t),t.isBranch&&dt(t,e),lt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lt(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||at(n[t])}at(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&rt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.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:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),_t.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ht([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ht(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 gt=w.get("Renderer");class wt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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,gt.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,gt.error(t)}gt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return gt.warn("rendering");if(this.times>3)return gt.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:i}=this,n=t.getIntersect(i.bounds),s=new g(n);i.save(),n.spread(wt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,t.includes(this.target.__world),s),i.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,i){const{canvas:n}=this,s=e?{includes:e}:{bounds:t,includes:e};this.needFill&&n.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(n,t),this.target.__render(n,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}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 i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),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:i}=t.old;if(!new g(0,0,e,i).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||gt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__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 yt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function mt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?bt(t,!0,e,i):xt(e,i);break;case"inside":vt("inside",t,s,e,i);break;case"outside":vt("outside",t,s,e,i)}}function vt(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?bt(e,!0,n,r):xt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function xt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function bt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?xt(i,n):n.stroke(),n.restoreBlendMode()):e?xt(i,n):n.stroke())}function Bt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}wt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new st(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=_t.fullLayout;const{getSpread:Rt,getOuterOf:St,getByMove:kt,getIntersectData:Et}=B;let Lt;function At(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:C.string(a,r)};case"image":return O.image(i,t,e,n,!Lt||!Lt[e.url]);case"linear":return M.linearGradient(e,n);case"radial":return M.radialGradient(e,n);case"angular":return M.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:C.string(e)}:void 0}}const Wt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),Lt=O.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=At(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&O.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?yt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?yt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?yt(e,i):s?i.fill(s):i.fill())},fillText:yt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)mt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),bt(t,!1,e,i),n.__useArrow&&Bt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),bt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const n=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=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Et(n?Rt(e.bounds,l===c?n*l:[n*c,n*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,i),l*=u,c*=f),r=St(s,a),o=kt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let Tt={};const{get:Ot,rotateOfOuter:Ct,translate:Mt,scaleOfOuter:Dt,scale:Pt,rotate:It}=R;function Ft(t,e,i,n,s,o,a){const r=Ot();Mt(r,e.x+i,e.y+n),Pt(r,s,o),a&&Ct(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Yt(t,e,i,n,s,o,a){const r=Ot();Mt(r,e.x+i,e.y+n),s&&Pt(r,s,o),a&&It(r,a),t.transform=r}function Ut(t,e,i,n,s,o,a,r,d,l){const c=Ot();if(d)if("center"===l)Ct(c,{x:i/2,y:n/2},d);else switch(It(c,d),d){case 90:Mt(c,n,0);break;case 180:Mt(c,i,n);break;case 270:Mt(c,0,i)}Tt.x=e.x+s,Tt.y=e.y+o,Mt(c,Tt.x,Tt.y),a&&Dt(c,Tt,a,r),t.transform=c}const{get:Nt,translate:Xt}=R,zt=new g,jt={},Gt={};function qt(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Ht(i,n,e)}function Ht(t,e,i){let{width:n,height:s}=i;t.padding&&(e=zt.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===n&&e.height===s,_={mode:a},g="center"!==r&&(h||0)%180==90,w=g?s:n,y=g?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,i,Gt),m=Gt.scaleX,v=Gt.scaleY);else if(!p||h){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*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),k.toPoint(r,t,e,jt,!0),x+=jt.x,b+=jt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&Yt(_,e,x,b,m,v,h);break;case"repeat":(!p||m||h)&&Ut(_,e,n,s,x,b,m,v,h,r),u||(_.repeat="repeat");break;default:m&&Ft(_,e,x,b,m,v,h)}return _.transform||(e.x||e.y)&&(_.transform=Nt(),Xt(_.transform,e.x,e.y)),m&&"stretch"!==a&&(_.scaleX=m,_.scaleY=v),_.width=n,_.height=s,o&&(_.opacity=o),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Vt,Qt=new g;const{isSame:Jt}=B;function Zt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.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||qt(s,n,i,o),!0}function $t(t,e){ee(t,E.LOAD,e)}function Kt(t,e){ee(t,E.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,E.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:se,copy:oe}=R,{ceil:ae,abs:re}=Math;function de(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=re(s),o=re(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=ne(),oe(l,p),se(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,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=ne(),p&&oe(l,p)),se(l,1/s,1/o));const y=t.getCanvas(ae(c)||1,ae(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=a,!0}}const{abs:le}=Math;const ce={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return Vt&&i===Vt.paint&&Jt(n,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:r},Vt=r.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Zt(t,e,i,r,o,n),s&&($t(t,a),Kt(t,a))):r.error?s&&te(t,a,r.error):(s&&(ie(t,!0),$t(t,a)),o.loadId=r.load((()=>{ie(t,!1),t.destroyed||(Zt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{ie(t,!1),te(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:d}=n;if(!d||n.patternId===o+"-"+a+"-"+r&&!D.running)return!1;if(s)if(d.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||D.running)){let{width:t,height:i}=d;t*=le(o)*r,i*=le(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,d),!0):(!n.style||n.sync||D.running?de(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>K(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&de(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:de,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a,r;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.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(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:qt,getPatternData:Ht,fillOrFitMode:Ft,clipMode:Yt,repeatMode:Ut},{toPoint:he}=L,ue={},fe={};function pe(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),C.string(n,i)):t.addColorStop(n.offset,C.string(n.color,i))}}const{getAngle:_e,getDistance:ge}=A,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=R,{toPoint:ve}=L,xe={},be={};function Be(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=_e(e,i);o=we(),s?(me(o,e,a/r*(n||1),1),ye(o,e,t+90)):(me(o,e,1,a/r*(n||1)),ye(o,e,t))}return o}const{getDistance:Re}=A,{toPoint:Se}=L,ke={},Ee={};const Le={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;he(n||"top",i,ue),he(s||"bottom",i,fe);const d=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y);pe(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ve(n||"center",i,xe),ve(s||"bottom",i,be);const l=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ge(xe,be));pe(l,t.stops,a);const c={type:o,style:l},h=Be(i,xe,be,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;Se(n||"center",i,ke),Se(s||"bottom",i,Ee);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Re(ke,Ee));pe(l,t.stops,a);const c={type:o,style:l},h=Be(i,ke,Ee,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Be},{copy:Ae,toOffsetOutBounds:We}=B,Te={},Oe={};function Ce(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(Ae(Te,t.bounds),Te.x+=i.x-a.x,Te.y+=i.y-a.y,n){const{matrix:t}=s;Te.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Te.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Te.width*=n,Te.height*=n}t.copyWorld(s.canvas,t.bounds,Te)}else n&&(Ae(Te,i),Te.x-=i.width/2*(n-1),Te.y-=i.height/2*(n-1),Te.width*=n,Te.height*=n),t.copyWorld(s.canvas,a,n?Te:i)}const{toOffsetOutBounds:Me}=B,De={};const Pe={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;We(l,Oe),r.forEach(((r,_)=>{f.setWorldShadow(Oe.offsetX+r.x*h,Oe.offsetY+r.y*u,r.blur*h,C.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,Oe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Me(l,De),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*h,De.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,De,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,C.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ie}=_;function Fe(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ue(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ue(t,i,n,o);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}P.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(Fe(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ye(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Ye(t)),s||(s=Ye(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Ie(i,e)||i.__render(s||t,e);Fe(this,a,t,s,n,o)};const Ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xe=Ne+"_#~&*+\\=|≮≯≈≠=…",ze=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 je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=je(Ne),Ve=je(Xe),Qe=je("- —/~|┆·");var Je;!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"}(Je||(Je={}));const{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Je;function ni(t){return Ge[t]?Ze:Qe[t]?ii:qe[t]?Ke:He[t]?ti:Ve[t]?ei:ze.test(t)?$e:Ze}const si={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function oi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ai}=si,{Letter:ri,Single:di,Before:li,After:ci,Symbol:hi,Break:ui}=Je;let fi,pi,_i,gi,wi,yi,mi,vi,xi,bi,Bi,Ri,Si,ki,Ei,Li,Ai,Wi=[];function Ti(t,e){xi&&!vi&&(vi=xi),fi.data.push({char:t,width:e}),_i+=e}function Oi(){gi+=_i,fi.width=_i,pi.words.push(fi),fi={data:[]},_i=0}function Ci(){ki&&(Ei.paraNumber++,pi.paraStart=!0,ki=!1),xi&&(pi.startCharSize=vi,pi.endCharSize=xi,vi=0),pi.width=gi,Li.width?ai(pi):Ai&&Mi(),Wi.push(pi),pi={words:[]},gi=0}function Mi(){gi>(Ei.maxWidth||0)&&(Ei.maxWidth=gi)}const{top:Di,right:Pi,bottom:Ii,left:Fi}=W;function Yi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ui={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Fi],o-=l[Pi]+l[Fi]):i.autoSizeAlign||(n=l[Fi]),a?(s=l[Di],a-=l[Di]+l[Ii]):i.autoSizeAlign||(s=l[Di]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ei=t,Wi=t.rows,Li=t.bounds,Ai=!Li.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=Li;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;ki=!0,Bi=null,vi=mi=xi=_i=gi=0,fi={data:[]},pi={words:[]};for(let n=0,l=i.length;n<l;n++)yi=i[n],"\n"===yi?(_i&&Oi(),pi.paraEnd=!0,Ci(),ki=!0):(bi=ni(yi),bi===ri&&"none"!==a&&(yi=oi(yi,a,!_i)),mi=r.measureText(yi).width,s&&(s<0&&(xi=mi),mi+=s),Ri=bi===di&&(Bi===di||Bi===ri)||Bi===di&&bi!==ci,Si=!(bi!==li&&bi!==di||Bi!==hi&&Bi!==ci),wi=ki&&o?d-o:d,t&&d&&gi+_i+mi>wi&&(e?(_i&&Oi(),gi&&Ci()):(Si||(Si=bi===ri&&Bi==ci),Ri||Si||bi===ui||bi===li||bi===di||_i+mi>wi?(_i&&Oi(),gi&&Ci()):gi&&Ci()))," "===yi&&!0!==ki&&gi+_i===0||(bi===ui?(" "===yi&&_i&&Oi(),Ti(yi,mi),Oi()):Ri||Si?(_i&&Oi(),Ti(yi,mi)):Ti(yi,mi)),Bi=bi);_i&&Oi(),gi&&Ci(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ei.paraNumber++,gi=r.measureText(t).width,Wi.push({x:o||0,text:t,width:gi,paraStart:!0}),Ai&&Mi()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Fi]);break;case"right":Yi(e,"x",-t[Pi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[Di]);break;case"bottom":Yi(e,"y",-t[Ii])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.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}=n,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=i[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<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&_&&_<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-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,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;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=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char||!n){e.data.splice(n+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,i,n,o),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=C.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const Ni={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!C.object)return t;t=C.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(I,Ui),Object.assign(C,Ni),Object.assign(F,Wt),Object.assign(O,ce),Object.assign(M,Le),Object.assign(Y,Pe);const{setPoint:Xi,addPoint:zi,toBounds:ji}=U;const Gi={syncExport(t,e,i){let n;this.running=!0;const s=X.fileType(e),o=e.includes(".");i=X.getExportOptions(i);const{toURL:a}=z,{download:r}=z.origin;if("json"===s)o&&r(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===s)o&&r(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let s,o,a=1,r=1;const{worldTransform:d,isLeafer:l,leafer:c,isFrame:h}=t,{slice:u,trim:f,padding:p,onCanvas:_}=i,g=void 0===i.smooth?!c||c.config.smooth:i.smooth,w=i.contextSettings||(c?c.config.contextSettings:void 0),y=i.screenshot||t.isApp,m=l&&y&&void 0===i.fill?t.fill:i.fill,v=X.isOpaqueImage(e)||m,x=new j;if(y)s=!0===y?l?c.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,r=d.scaleY,e){case"inner":x.set(d);break;case"local":x.set(d).divide(t.localTransform),a/=t.scaleX,r/=t.scaleY;break;case"world":a=1,r=1;break;case"page":e=c||t;default:x.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};G.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:R,y:S,width:k,height:E}=new N(s).scale(b.scaleX,b.scaleY),L={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-S).withScale(1/a*b.scaleX,1/r*b.scaleY)};let A,W=q.canvas({width:Math.floor(k),height:Math.floor(E),pixelRatio:B,smooth:g,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=c||t,L.bounds=W.bounds),W.save(),h&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,L),t.fill=e}else t.__render(W,L);if(W.restore(),A&&A.__updateWorldOpacity(),f){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?zi(a,s,o):Xi(a={},s,o)),r++;const d=new N;return ji(a,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=q.canvas(n),W.copyWorld(t,o,n)}if(p){const[t,e,i,n]=G.fourNumber(p),s=W,{width:o,height:a}=s;W=q.canvas({width:o+n+e,height:a+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:o,height:a})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),_&&_(W);n={data:"canvas"===e?W:W.export(e,i),width:W.pixelWidth,height:W.pixelHeight,renderBounds:s,trimBounds:o}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){qi||(qi=new H);return new Promise((e=>{qi.add((()=>K(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const o=()=>K(this,void 0,void 0,(function*(){if(!V.isComplete)return z.requestRender(o);const a=Gi.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),n(a),s()}));t.updateLayout(),Hi(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))))}};let qi;function Hi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Hi(t)))}const Vi=Q.prototype,Qi=J.get("@leafer-in/export");Vi.export=function(t,e){const{quality:i,blob:n}=X.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Vi.toBlob=function(t,e){return new Promise((i=>{z.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{Qi.error(t),i(null)}))}))},Vi.toDataURL=function(t,e){return z.origin.canvasToDataURL(this.view,t,e)},Vi.saveAs=function(t,e){return new Promise((i=>{z.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{Qi.error(t),i(!1)}))}))},Z.add("export"),Object.assign(D,Gi),$.prototype.export=function(t,e){return D.export(this,t,e)},$.prototype.syncExport=function(t,e){return D.syncExport(this,t,e)};export{_t as Layouter,tt as LeaferCanvas,wt as Renderer,st as Watcher,nt as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,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 S,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as W}from"fs";import{PaintImage as O,ColorConvert as C,PaintGradient as M,Export as P,Group as D,TextConvert as I,Paint as F,Effect as Y,TwoPointBoundsHelper as U,Bounds as N,FileHelper as X,Platform as z,Matrix as j,MathHelper as G,Creator as q,TaskProcessor as H,Resource as V,LeaferCanvasBase as Q,Debug as J,Plugin as Z,UI as $}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function K(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class tt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:et,fileType:it}=n;function nt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(et(e),i),canvasToBolb:(t,e,i)=>K(this,void 0,void 0,(function*(){return t.toBuffer(et(e),i)})),canvasSaveAs:(t,e,i)=>K(this,void 0,void 0,(function*(){return W(e,t.toBuffer(et(it(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new tt(t,e),image:t=>new o(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class st{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,i=e.length;t<i;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:ot,updateBounds:at,updateChange:rt}=f,{pushAllChildBranch:dt,pushAllParent:lt}=p;const{worldBounds:ct}=_;class ht{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,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:ut,updateAllChange:ft}=f,pt=w.get("Layouter");class _t{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){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.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:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(ot(t,!0),e.add(t),t.isBranch&&dt(t,e),lt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lt(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||at(n[t])}at(i)}}))}(this.__levelList),function(t){t.list.forEach(rt)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.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:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),_t.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ht([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ht(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 gt=w.get("Renderer");class wt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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,gt.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,gt.error(t)}gt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return gt.warn("rendering");if(this.times>3)return gt.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:i}=this,n=t.getIntersect(i.bounds),s=new g(n);i.save(),n.spread(wt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.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:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.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 i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).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||gt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__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 yt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[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}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function mt(t,e){t.__.__font?yt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function vt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,s,e,i);break;case"outside":xt("outside",t,s,e,i)}}function xt(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?Bt(e,!0,n,r):bt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function bt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function Bt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?bt(i,n):n.stroke(),n.restoreBlendMode()):e?bt(i,n):n.stroke())}function Rt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}wt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new st(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=_t.fullLayout;const{getSpread:kt,getOuterOf:St,getByMove:Et,getIntersectData:Lt}=B;let At;function Tt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:C.string(a,r)};case"image":return O.image(i,t,e,n,!At||!At[e.url]);case"linear":return M.linearGradient(e,n);case"radial":return M.radialGradient(e,n);case"angular":return M.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:C.string(e)}:void 0}}const Wt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),At=O.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Tt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,mt(e,i)},fills:function(t,e,i){let n;for(let s=0,o=t.length;s<o;s++){if(n=t[s],n.image){if(O.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),mt(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),mt(e,i),i.restoreBlendMode()):mt(e,i)}},fillPathOrText:mt,fillText:yt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&Rt(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),Bt(t,!1,e,i),n.__useArrow&&Rt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),Bt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:vt,drawTextStroke:bt,shape:function(t,e,i){const n=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=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Lt(n?kt(e.bounds,l===c?n*l:[n*c,n*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,i),l*=u,c*=f),r=St(s,a),o=Et(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let Ot={};const{get:Ct,rotateOfOuter:Mt,translate:Pt,scaleOfOuter:Dt,scale:It,rotate:Ft}=R;function Yt(t,e,i,n,s,o,a){const r=Ct();Pt(r,e.x+i,e.y+n),It(r,s,o),a&&Mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ut(t,e,i,n,s,o,a){const r=Ct();Pt(r,e.x+i,e.y+n),s&&It(r,s,o),a&&Ft(r,a),t.transform=r}function Nt(t,e,i,n,s,o,a,r,d,l){const c=Ct();if(d)if("center"===l)Mt(c,{x:i/2,y:n/2},d);else switch(Ft(c,d),d){case 90:Pt(c,n,0);break;case 180:Pt(c,i,n);break;case 270:Pt(c,0,i)}Ot.x=e.x+s,Ot.y=e.y+o,Pt(c,Ot.x,Ot.y),a&&Dt(c,Ot,a,r),t.transform=c}const{get:Xt,translate:zt}=R,jt=new g,Gt={},qt={};function Ht(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Vt(i,n,e)}function Vt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=jt.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===n&&e.height===s,_={mode:a},g="center"!==r&&(h||0)%180==90,w=g?s:n,y=g?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,qt),m=qt.scaleX,v=qt.scaleY);else if(!p||h){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*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),S.toPoint(r,t,e,Gt,!0),x+=Gt.x,b+=Gt.y}switch(d&&(x+=d.x,b+=d.y),a){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||h)&&Ut(_,e,x,b,m,v,h);break;case"repeat":(!p||m||h)&&Nt(_,e,n,s,x,b,m,v,h,r),u||(_.repeat="repeat");break;default:m&&Yt(_,e,x,b,m,v,h)}return _.transform||(e.x||e.y)&&(_.transform=Xt(),zt(_.transform,e.x,e.y)),m&&"stretch"!==a&&(_.scaleX=m,_.scaleY=v),_.width=n,_.height=s,o&&(_.opacity=o),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Qt,Jt=new g;const{isSame:Zt}=B;function $t(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.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||Ht(s,n,i,o),!0}function Kt(t,e){ie(t,E.LOAD,e)}function te(t,e){ie(t,E.LOADED,e)}function ee(t,e,i){e.error=i,t.forceUpdate("surface"),ie(t,E.ERROR,e)}function ie(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function ne(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:se,scale:oe,copy:ae}=R,{ceil:re,abs:de}=Math;function le(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=de(s),o=de(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=se(),ae(l,p),oe(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,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=se(),p&&ae(l,p)),oe(l,1/s,1/o));const y=t.getCanvas(re(c)||1,re(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=a,!0}}const{abs:ce}=Math;const he={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return Qt&&i===Qt.paint&&Zt(n,Qt.boxBounds)?o=Qt.leafPaint:(o={type:i.type,image:r},Qt=r.use>1?{leafPaint:o,paint:i,boxBounds:Jt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?($t(t,e,i,r,o,n),s&&(Kt(t,a),te(t,a))):r.error?s&&ee(t,a,r.error):(s&&(ne(t,!0),Kt(t,a)),o.loadId=r.load((()=>{ne(t,!1),t.destroyed||($t(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),te(t,a)),o.loadId=null}),(e=>{ne(t,!1),ee(t,a,e),o.loadId=null})),t.placeholderColor&&setTimeout((()=>{r.ready||r.isPlacehold||(r.isPlacehold=!0,t.forceUpdate("surface"))}),100)),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:d}=n;if(!d||n.patternId===o+"-"+a+"-"+r&&!P.running)return!1;if(s)if(d.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||P.running)){let{width:t,height:i}=d;t*=ce(o)*r,i*=ce(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,d),!0):(!n.style||n.sync||P.running?le(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>K(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&le(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a,r;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.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(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Ht,getPatternData:Vt,fillOrFitMode:Yt,clipMode:Ut,repeatMode:Nt},{toPoint:ue}=L,fe={},pe={};function _e(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),C.string(n,i)):t.addColorStop(n.offset,C.string(n.color,i))}}const{getAngle:ge,getDistance:we}=A,{get:ye,rotateOfOuter:me,scaleOfOuter:ve}=R,{toPoint:xe}=L,be={},Be={};function Re(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ge(e,i);o=ye(),s?(ve(o,e,a/r*(n||1),1),me(o,e,t+90)):(ve(o,e,1,a/r*(n||1)),me(o,e,t))}return o}const{getDistance:ke}=A,{toPoint:Se}=L,Ee={},Le={};const Ae={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ue(n||"top",i,fe),ue(s||"bottom",i,pe);const d=e.canvas.createLinearGradient(fe.x,fe.y,pe.x,pe.y);_e(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;xe(n||"center",i,be),xe(s||"bottom",i,Be);const l=e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,we(be,Be));_e(l,t.stops,a);const c={type:o,style:l},h=Re(i,be,Be,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;Se(n||"center",i,Ee),Se(s||"bottom",i,Le);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,ke(Ee,Le));_e(l,t.stops,a);const c={type:o,style:l},h=Re(i,Ee,Le,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Re},{copy:Te,toOffsetOutBounds:We}=B,Oe={},Ce={};function Me(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(Te(Oe,t.bounds),Oe.x+=i.x-a.x,Oe.y+=i.y-a.y,n){const{matrix:t}=s;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Oe.width*=n,Oe.height*=n}t.copyWorld(s.canvas,t.bounds,Oe)}else n&&(Te(Oe,i),Oe.x-=i.width/2*(n-1),Oe.y-=i.height/2*(n-1),Oe.width*=n,Oe.height*=n),t.copyWorld(s.canvas,a,n?Oe:i)}const{toOffsetOutBounds:Pe}=B,De={};const Ie={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;We(l,Ce),r.forEach(((r,_)=>{f.setWorldShadow(Ce.offsetX+r.x*h,Ce.offsetY+r.y*u,r.blur*h,C.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Me(f,Ce,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Pe(l,De),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*h,De.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Me(f,De,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,C.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Fe}=_;function Ye(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ne(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ne(t,i,n,o);break;case"path":i.restore()}}function Ue(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}D.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(Ye(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ue(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Ue(t)),s||(s=Ue(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Fe(i,e)||i.__render(s||t,e);Ye(this,a,t,s,n,o)};const Xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=Xe+"_#~&*+\\=|≮≯≈≠=…",je=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 Ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=Ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ge(Xe),Qe=Ge(ze),Je=Ge("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:$e,Single:Ke,Before:ti,After:ei,Symbol:ii,Break:ni}=Ze;function si(t){return qe[t]?$e:Je[t]?ni:He[t]?ti:Ve[t]?ei:Qe[t]?ii:je.test(t)?Ke:$e}const oi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ai(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ri}=oi,{Letter:di,Single:li,Before:ci,After:hi,Symbol:ui,Break:fi}=Ze;let pi,_i,gi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Ti,Wi=[];function Oi(t,e){bi&&!xi&&(xi=bi),pi.data.push({char:t,width:e}),gi+=e}function Ci(){wi+=gi,pi.width=gi,_i.words.push(pi),pi={data:[]},gi=0}function Mi(){Ei&&(Li.paraNumber++,_i.paraStart=!0,Ei=!1),bi&&(_i.startCharSize=xi,_i.endCharSize=bi,xi=0),_i.width=wi,Ai.width?ri(_i):Ti&&Pi(),Wi.push(_i),_i={words:[]},wi=0}function Pi(){wi>(Li.maxWidth||0)&&(Li.maxWidth=wi)}const{top:Di,right:Ii,bottom:Fi,left:Yi}=T;function Ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ni={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o?(n=l[Yi],o-=l[Ii]+l[Yi]):i.autoSizeAlign||(n=l[Yi]),a?(s=l[Di],a-=l[Di]+l[Fi]):i.autoSizeAlign||(s=l[Di]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Li=t,Wi=t.rows,Ai=t.bounds,Ti=!Ai.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=Ai;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,Ri=null,xi=vi=bi=gi=wi=0,pi={data:[]},_i={words:[]};for(let n=0,l=i.length;n<l;n++)mi=i[n],"\n"===mi?(gi&&Ci(),_i.paraEnd=!0,Mi(),Ei=!0):(Bi=si(mi),Bi===di&&"none"!==a&&(mi=ai(mi,a,!gi)),vi=r.measureText(mi).width,s&&(s<0&&(bi=vi),vi+=s),ki=Bi===li&&(Ri===li||Ri===di)||Ri===li&&Bi!==hi,Si=!(Bi!==ci&&Bi!==li||Ri!==ui&&Ri!==hi),yi=Ei&&o?d-o:d,t&&d&&wi+gi+vi>yi&&(e?(gi&&Ci(),wi&&Mi()):(Si||(Si=Bi===di&&Ri==hi),ki||Si||Bi===fi||Bi===ci||Bi===li||gi+vi>yi?(gi&&Ci(),wi&&Mi()):wi&&Mi()))," "===mi&&!0!==Ei&&wi+gi===0||(Bi===fi?(" "===mi&&gi&&Ci(),Oi(mi,vi),Ci()):ki||Si?(gi&&Ci(),Oi(mi,vi)):Oi(mi,vi)),Ri=Bi);gi&&Ci(),wi&&Mi(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,wi=r.measureText(t).width,Wi.push({x:o||0,text:t,width:wi,paraStart:!0}),Ti&&Pi()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ui(e,"x",t[Yi]);break;case"right":Ui(e,"x",-t[Ii])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ui(e,"y",t[Di]);break;case"bottom":Ui(e,"y",-t[Fi])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.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}=n,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=i[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<n.x&&(n.x=v),x>n.width&&(n.width=x),d&&_&&_<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,d,l,c,h,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-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,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;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=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char||!n){e.data.splice(n+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,i,n,o),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=C.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const Xi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!C.object)return t;t=C.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(I,Ni),Object.assign(C,Xi),Object.assign(F,Wt),Object.assign(O,he),Object.assign(M,Ae),Object.assign(Y,Ie);const{setPoint:zi,addPoint:ji,toBounds:Gi}=U;const qi={syncExport(t,e,i){let n;this.running=!0;const s=X.fileType(e),o=e.includes(".");i=X.getExportOptions(i);const{toURL:a}=z,{download:r}=z.origin;if("json"===s)o&&r(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===s)o&&r(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let s,o,a=1,r=1;const{worldTransform:d,isLeafer:l,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,padding:_,onCanvas:g}=i,w=void 0===i.smooth?!c||c.config.smooth:i.smooth,y=i.contextSettings||(c?c.config.contextSettings:void 0),m=i.screenshot||t.isApp,v=l&&m&&void 0===i.fill?t.fill:i.fill,x=X.isOpaqueImage(e)||v,b=new j;if(m)s=!0===m?l?c.canvas.bounds:t.worldRenderBounds:m;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,r=d.scaleY,e){case"inner":b.set(d);break;case"local":b.set(d).divide(t.localTransform),a/=t.scaleX,r/=t.scaleY;break;case"world":a=1,r=1;break;case"page":e=c||t;default:b.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};G.getScaleData(i.scale,i.size,s,B);let R=i.pixelRatio||1;t.isApp&&(B.scaleX*=R,B.scaleY*=R,R=t.app.pixelRatio);let{x:k,y:S,width:E,height:L}=new N(s).scale(B.scaleX,B.scaleY);f&&(k+=f.x,S+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-k,-S).withScale(1/a*B.scaleX,1/r*B.scaleY)};let T,W=q.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:R,smooth:w,contextSettings:y});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=W.bounds),W.save(),h&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(W,A),t.fill=e}else t.__render(W,A);if(W.restore(),T&&T.__updateWorldOpacity(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?ji(a,s,o):zi(a={},s,o)),r++;const d=new N;return Gi(a,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:R};W=q.canvas(n),W.copyWorld(t,o,n)}if(_){const[t,e,i,n]=G.fourNumber(_),s=W,{width:o,height:a}=s;W=q.canvas({width:o+n+e,height:a+t+i,pixelRatio:R}),W.copyWorld(s,s.bounds,{x:n,y:t,width:o,height:a})}x&&W.fillWorld(W.bounds,v||"#FFFFFF","destination-over"),g&&g(W);n={data:"canvas"===e?W:W.export(e,i),width:W.pixelWidth,height:W.pixelHeight,renderBounds:s,trimBounds:o}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){Hi||(Hi=new H);return new Promise((e=>{Hi.add((()=>K(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const o=()=>K(this,void 0,void 0,(function*(){if(!V.isComplete)return z.requestRender(o);const a=qi.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),n(a),s()}));t.updateLayout(),Vi(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))))}};let Hi;function Vi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Vi(t)))}const Qi=Q.prototype,Ji=J.get("@leafer-in/export");Qi.export=function(t,e){const{quality:i,blob:n}=X.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Qi.toBlob=function(t,e){return new Promise((i=>{z.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{Ji.error(t),i(null)}))}))},Qi.toDataURL=function(t,e){return z.origin.canvasToDataURL(this.view,t,e)},Qi.saveAs=function(t,e){return new Promise((i=>{z.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{Ji.error(t),i(!1)}))}))},Z.add("export"),Object.assign(P,qi),$.prototype.export=function(t,e){return P.export(this,t,e)},$.prototype.syncExport=function(t,e){return P.syncExport(this,t,e)};export{_t as Layouter,tt as LeaferCanvas,wt as Renderer,st as Watcher,nt as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|