@leafer-ui/draw 1.0.0-rc.21 → 1.0.0-rc.23
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/lib/draw.cjs +93 -36
- package/lib/draw.esm.js +94 -37
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.min.cjs +1 -1
- package/package.json +6 -6
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/draw.cjs
CHANGED
|
@@ -85,7 +85,11 @@ function zoomLayerType() {
|
|
|
85
85
|
core.defineKey(target, key, {
|
|
86
86
|
set(value) { if (this.isLeafer)
|
|
87
87
|
this[privateKey] = value; },
|
|
88
|
-
get() {
|
|
88
|
+
get() {
|
|
89
|
+
return this.isApp
|
|
90
|
+
? this.tree.zoomLayer
|
|
91
|
+
: (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
|
|
92
|
+
}
|
|
89
93
|
});
|
|
90
94
|
};
|
|
91
95
|
}
|
|
@@ -225,7 +229,7 @@ class UIData extends core.LeafData {
|
|
|
225
229
|
const UnitConvert = {
|
|
226
230
|
number(value, percentRefer) {
|
|
227
231
|
if (typeof value === 'object')
|
|
228
|
-
return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
|
|
232
|
+
return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
|
|
229
233
|
return value;
|
|
230
234
|
}
|
|
231
235
|
};
|
|
@@ -491,6 +495,9 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
491
495
|
core.pen.set(this.path = this.__.path || []);
|
|
492
496
|
return core.pen;
|
|
493
497
|
}
|
|
498
|
+
get editConfig() { return undefined; }
|
|
499
|
+
get editOuter() { return 'EditTool'; }
|
|
500
|
+
get editInner() { return 'PathEditor'; }
|
|
494
501
|
constructor(data) {
|
|
495
502
|
super(data);
|
|
496
503
|
}
|
|
@@ -503,7 +510,9 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
503
510
|
}
|
|
504
511
|
createProxyData() { return undefined; }
|
|
505
512
|
find(_condition, _options) { return undefined; }
|
|
513
|
+
findTag(tag) { return this.find({ tag }); }
|
|
506
514
|
findOne(_condition, _options) { return undefined; }
|
|
515
|
+
findId(id) { return this.findOne({ id }); }
|
|
507
516
|
getPath(curve, pathForRender) {
|
|
508
517
|
this.__layout.update();
|
|
509
518
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
@@ -552,7 +561,8 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
552
561
|
__drawPathByBox(drawer) {
|
|
553
562
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
554
563
|
if (this.__.cornerRadius) {
|
|
555
|
-
|
|
564
|
+
const { cornerRadius } = this.__;
|
|
565
|
+
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
556
566
|
}
|
|
557
567
|
else {
|
|
558
568
|
drawer.rect(x, y, width, height);
|
|
@@ -573,6 +583,9 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
573
583
|
static registerData(data) {
|
|
574
584
|
core.dataProcessor(data)(this.prototype);
|
|
575
585
|
}
|
|
586
|
+
static setEditConfig(_config) { }
|
|
587
|
+
static setEditOuter(_toolName) { }
|
|
588
|
+
static setEditInner(_editorName) { }
|
|
576
589
|
destroy() {
|
|
577
590
|
this.fill = this.stroke = null;
|
|
578
591
|
super.destroy();
|
|
@@ -650,21 +663,84 @@ __decorate([
|
|
|
650
663
|
__decorate([
|
|
651
664
|
core.rotationType(0, true)
|
|
652
665
|
], exports.UI.prototype, "skewY", void 0);
|
|
666
|
+
__decorate([
|
|
667
|
+
core.positionType(0, true)
|
|
668
|
+
], exports.UI.prototype, "offsetX", void 0);
|
|
669
|
+
__decorate([
|
|
670
|
+
core.positionType(0, true)
|
|
671
|
+
], exports.UI.prototype, "offsetY", void 0);
|
|
672
|
+
__decorate([
|
|
673
|
+
core.positionType(0, true)
|
|
674
|
+
], exports.UI.prototype, "scrollX", void 0);
|
|
675
|
+
__decorate([
|
|
676
|
+
core.positionType(0, true)
|
|
677
|
+
], exports.UI.prototype, "scrollY", void 0);
|
|
678
|
+
__decorate([
|
|
679
|
+
core.autoLayoutType()
|
|
680
|
+
], exports.UI.prototype, "origin", void 0);
|
|
653
681
|
__decorate([
|
|
654
682
|
core.autoLayoutType()
|
|
655
683
|
], exports.UI.prototype, "around", void 0);
|
|
656
684
|
__decorate([
|
|
657
685
|
core.dataType(false)
|
|
658
|
-
], exports.UI.prototype, "
|
|
686
|
+
], exports.UI.prototype, "lazy", void 0);
|
|
659
687
|
__decorate([
|
|
660
|
-
core.
|
|
661
|
-
], exports.UI.prototype, "
|
|
688
|
+
core.naturalBoundsType(1)
|
|
689
|
+
], exports.UI.prototype, "pixelRatio", void 0);
|
|
690
|
+
__decorate([
|
|
691
|
+
core.pathInputType()
|
|
692
|
+
], exports.UI.prototype, "path", void 0);
|
|
693
|
+
__decorate([
|
|
694
|
+
core.pathType()
|
|
695
|
+
], exports.UI.prototype, "windingRule", void 0);
|
|
696
|
+
__decorate([
|
|
697
|
+
core.pathType(true)
|
|
698
|
+
], exports.UI.prototype, "closed", void 0);
|
|
699
|
+
__decorate([
|
|
700
|
+
core.autoLayoutType(false)
|
|
701
|
+
], exports.UI.prototype, "flow", void 0);
|
|
702
|
+
__decorate([
|
|
703
|
+
core.boundsType(0)
|
|
704
|
+
], exports.UI.prototype, "padding", void 0);
|
|
705
|
+
__decorate([
|
|
706
|
+
core.boundsType(0)
|
|
707
|
+
], exports.UI.prototype, "gap", void 0);
|
|
708
|
+
__decorate([
|
|
709
|
+
core.boundsType('top-left')
|
|
710
|
+
], exports.UI.prototype, "align", void 0);
|
|
711
|
+
__decorate([
|
|
712
|
+
core.boundsType(false)
|
|
713
|
+
], exports.UI.prototype, "wrap", void 0);
|
|
714
|
+
__decorate([
|
|
715
|
+
core.boundsType('box')
|
|
716
|
+
], exports.UI.prototype, "itemBox", void 0);
|
|
662
717
|
__decorate([
|
|
663
|
-
core.
|
|
664
|
-
], exports.UI.prototype, "
|
|
718
|
+
core.boundsType(true)
|
|
719
|
+
], exports.UI.prototype, "inFlow", void 0);
|
|
720
|
+
__decorate([
|
|
721
|
+
core.boundsType()
|
|
722
|
+
], exports.UI.prototype, "autoWidth", void 0);
|
|
723
|
+
__decorate([
|
|
724
|
+
core.boundsType()
|
|
725
|
+
], exports.UI.prototype, "autoHeight", void 0);
|
|
726
|
+
__decorate([
|
|
727
|
+
core.boundsType()
|
|
728
|
+
], exports.UI.prototype, "autoBox", void 0);
|
|
729
|
+
__decorate([
|
|
730
|
+
core.boundsType()
|
|
731
|
+
], exports.UI.prototype, "widthRange", void 0);
|
|
732
|
+
__decorate([
|
|
733
|
+
core.boundsType()
|
|
734
|
+
], exports.UI.prototype, "heightRange", void 0);
|
|
735
|
+
__decorate([
|
|
736
|
+
core.dataType(false)
|
|
737
|
+
], exports.UI.prototype, "draggable", void 0);
|
|
665
738
|
__decorate([
|
|
666
739
|
core.dataType()
|
|
667
|
-
], exports.UI.prototype, "
|
|
740
|
+
], exports.UI.prototype, "dragBounds", void 0);
|
|
741
|
+
__decorate([
|
|
742
|
+
core.dataType(false)
|
|
743
|
+
], exports.UI.prototype, "editable", void 0);
|
|
668
744
|
__decorate([
|
|
669
745
|
core.hitType(true)
|
|
670
746
|
], exports.UI.prototype, "hittable", void 0);
|
|
@@ -719,21 +795,6 @@ __decorate([
|
|
|
719
795
|
__decorate([
|
|
720
796
|
core.strokeType(10)
|
|
721
797
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
722
|
-
__decorate([
|
|
723
|
-
core.dataType(false)
|
|
724
|
-
], exports.UI.prototype, "lazy", void 0);
|
|
725
|
-
__decorate([
|
|
726
|
-
core.naturalBoundsType(1)
|
|
727
|
-
], exports.UI.prototype, "pixelRatio", void 0);
|
|
728
|
-
__decorate([
|
|
729
|
-
core.pathInputType()
|
|
730
|
-
], exports.UI.prototype, "path", void 0);
|
|
731
|
-
__decorate([
|
|
732
|
-
core.pathType()
|
|
733
|
-
], exports.UI.prototype, "windingRule", void 0);
|
|
734
|
-
__decorate([
|
|
735
|
-
core.pathType(true)
|
|
736
|
-
], exports.UI.prototype, "closed", void 0);
|
|
737
798
|
__decorate([
|
|
738
799
|
arrowType('none')
|
|
739
800
|
], exports.UI.prototype, "startArrow", void 0);
|
|
@@ -856,7 +917,6 @@ exports.Group = __decorate([
|
|
|
856
917
|
var Leafer_1;
|
|
857
918
|
const debug = core.Debug.get('Leafer');
|
|
858
919
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
859
|
-
static get version() { return '1.0.0-rc.21'; }
|
|
860
920
|
get __tag() { return 'Leafer'; }
|
|
861
921
|
get isApp() { return false; }
|
|
862
922
|
get app() { return this.parent || this; }
|
|
@@ -909,7 +969,6 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
909
969
|
if (this.isApp)
|
|
910
970
|
this.__setApp();
|
|
911
971
|
this.__checkAutoLayout(config);
|
|
912
|
-
this.updateLazyBounds();
|
|
913
972
|
this.view = canvas.view;
|
|
914
973
|
if (parentApp) {
|
|
915
974
|
this.__bindApp(parentApp);
|
|
@@ -969,9 +1028,6 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
969
1028
|
const data = core.DataHelper.copyAttrs({}, size, core.canvasSizeAttrs);
|
|
970
1029
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
971
1030
|
}
|
|
972
|
-
forceFullRender() {
|
|
973
|
-
this.forceRender();
|
|
974
|
-
}
|
|
975
1031
|
forceRender(bounds) {
|
|
976
1032
|
this.renderer.addBlock(bounds ? new core.Bounds(bounds) : this.canvas.bounds);
|
|
977
1033
|
if (this.viewReady)
|
|
@@ -1049,7 +1105,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1049
1105
|
this.canvas.backgroundColor = newValue;
|
|
1050
1106
|
}
|
|
1051
1107
|
else {
|
|
1052
|
-
this.
|
|
1108
|
+
this.forceRender();
|
|
1053
1109
|
}
|
|
1054
1110
|
}
|
|
1055
1111
|
__onCreated() {
|
|
@@ -1153,6 +1209,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
|
1153
1209
|
__listenEvents() {
|
|
1154
1210
|
const runId = core.Run.start('FirstCreate ' + this.innerName);
|
|
1155
1211
|
this.once(core.LeaferEvent.START, () => core.Run.end(runId));
|
|
1212
|
+
this.once(core.LayoutEvent.START, () => this.updateLazyBounds());
|
|
1156
1213
|
this.once(core.LayoutEvent.END, () => this.__onReady());
|
|
1157
1214
|
this.once(core.RenderEvent.START, () => this.__onCreated());
|
|
1158
1215
|
this.once(core.RenderEvent.END, () => this.__onViewReady());
|
|
@@ -1259,6 +1316,8 @@ exports.Box = class Box extends exports.Group {
|
|
|
1259
1316
|
else {
|
|
1260
1317
|
this.__updateRectBoxBounds();
|
|
1261
1318
|
}
|
|
1319
|
+
if (data.flow)
|
|
1320
|
+
this.__updateContentBounds();
|
|
1262
1321
|
}
|
|
1263
1322
|
__updateStrokeBounds() { }
|
|
1264
1323
|
__updateRenderBounds() {
|
|
@@ -1668,9 +1727,10 @@ exports.Canvas = __decorate([
|
|
|
1668
1727
|
core.registerUI()
|
|
1669
1728
|
], exports.Canvas);
|
|
1670
1729
|
|
|
1671
|
-
const { copyAndSpread, includes, spread, setList } = core.BoundsHelper;
|
|
1730
|
+
const { copyAndSpread, includes, isSame, spread, setList } = core.BoundsHelper;
|
|
1672
1731
|
exports.Text = class Text extends exports.UI {
|
|
1673
1732
|
get __tag() { return 'Text'; }
|
|
1733
|
+
get editInner() { return 'TextEditor'; }
|
|
1674
1734
|
get textDrawData() {
|
|
1675
1735
|
this.__layout.update();
|
|
1676
1736
|
return this.__.__textDrawData;
|
|
@@ -1740,7 +1800,7 @@ exports.Text = class Text extends exports.UI {
|
|
|
1740
1800
|
if (italic)
|
|
1741
1801
|
b.width += fontSize * 0.16;
|
|
1742
1802
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1743
|
-
if (contentBounds
|
|
1803
|
+
if (!isSame(contentBounds, layout.contentBounds)) {
|
|
1744
1804
|
layout.contentBounds = contentBounds;
|
|
1745
1805
|
layout.renderChanged = true;
|
|
1746
1806
|
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
@@ -1768,9 +1828,6 @@ __decorate([
|
|
|
1768
1828
|
__decorate([
|
|
1769
1829
|
core.boundsType(0)
|
|
1770
1830
|
], exports.Text.prototype, "height", void 0);
|
|
1771
|
-
__decorate([
|
|
1772
|
-
core.boundsType(0)
|
|
1773
|
-
], exports.Text.prototype, "padding", void 0);
|
|
1774
1831
|
__decorate([
|
|
1775
1832
|
core.surfaceType('#000000')
|
|
1776
1833
|
], exports.Text.prototype, "fill", void 0);
|
|
@@ -1899,7 +1956,7 @@ function penPathType() {
|
|
|
1899
1956
|
};
|
|
1900
1957
|
}
|
|
1901
1958
|
|
|
1902
|
-
const version = "1.0.0-rc.
|
|
1959
|
+
const version = "1.0.0-rc.23";
|
|
1903
1960
|
|
|
1904
1961
|
exports.BoxData = BoxData;
|
|
1905
1962
|
exports.CanvasData = CanvasData;
|
package/lib/draw.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decorateLeafAttr, attr, doStrokeType, defineKey, Debug, LeafData, PathConvert, OneRadian, dataProcessor, dataType, surfaceType, opacityType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType,
|
|
1
|
+
import { decorateLeafAttr, attr, doStrokeType, defineKey, Debug, LeafData, PathConvert, OneRadian, dataProcessor, dataType, surfaceType, opacityType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, pen, PathCorner, PathDrawer, UICreator, registerUI, Branch, LeafList, ImageManager, DataHelper, Creator, CanvasManager, WaitHelper, LeaferEvent, canvasSizeAttrs, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, affectRenderBoundsType, BoundsHelper, Platform, PathCommandDataHelper, affectStrokeBoundsType, getPointData, PointHelper, PathBounds, ImageEvent, Matrix, MathHelper, PathCreator } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
@@ -84,7 +84,11 @@ function zoomLayerType() {
|
|
|
84
84
|
defineKey(target, key, {
|
|
85
85
|
set(value) { if (this.isLeafer)
|
|
86
86
|
this[privateKey] = value; },
|
|
87
|
-
get() {
|
|
87
|
+
get() {
|
|
88
|
+
return this.isApp
|
|
89
|
+
? this.tree.zoomLayer
|
|
90
|
+
: (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
|
|
91
|
+
}
|
|
88
92
|
});
|
|
89
93
|
};
|
|
90
94
|
}
|
|
@@ -224,7 +228,7 @@ class UIData extends LeafData {
|
|
|
224
228
|
const UnitConvert = {
|
|
225
229
|
number(value, percentRefer) {
|
|
226
230
|
if (typeof value === 'object')
|
|
227
|
-
return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
|
|
231
|
+
return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
|
|
228
232
|
return value;
|
|
229
233
|
}
|
|
230
234
|
};
|
|
@@ -490,6 +494,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
490
494
|
pen.set(this.path = this.__.path || []);
|
|
491
495
|
return pen;
|
|
492
496
|
}
|
|
497
|
+
get editConfig() { return undefined; }
|
|
498
|
+
get editOuter() { return 'EditTool'; }
|
|
499
|
+
get editInner() { return 'PathEditor'; }
|
|
493
500
|
constructor(data) {
|
|
494
501
|
super(data);
|
|
495
502
|
}
|
|
@@ -502,7 +509,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
502
509
|
}
|
|
503
510
|
createProxyData() { return undefined; }
|
|
504
511
|
find(_condition, _options) { return undefined; }
|
|
512
|
+
findTag(tag) { return this.find({ tag }); }
|
|
505
513
|
findOne(_condition, _options) { return undefined; }
|
|
514
|
+
findId(id) { return this.findOne({ id }); }
|
|
506
515
|
getPath(curve, pathForRender) {
|
|
507
516
|
this.__layout.update();
|
|
508
517
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
@@ -551,7 +560,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
551
560
|
__drawPathByBox(drawer) {
|
|
552
561
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
553
562
|
if (this.__.cornerRadius) {
|
|
554
|
-
|
|
563
|
+
const { cornerRadius } = this.__;
|
|
564
|
+
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
555
565
|
}
|
|
556
566
|
else {
|
|
557
567
|
drawer.rect(x, y, width, height);
|
|
@@ -572,6 +582,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
572
582
|
static registerData(data) {
|
|
573
583
|
dataProcessor(data)(this.prototype);
|
|
574
584
|
}
|
|
585
|
+
static setEditConfig(_config) { }
|
|
586
|
+
static setEditOuter(_toolName) { }
|
|
587
|
+
static setEditInner(_editorName) { }
|
|
575
588
|
destroy() {
|
|
576
589
|
this.fill = this.stroke = null;
|
|
577
590
|
super.destroy();
|
|
@@ -649,21 +662,84 @@ __decorate([
|
|
|
649
662
|
__decorate([
|
|
650
663
|
rotationType(0, true)
|
|
651
664
|
], UI.prototype, "skewY", void 0);
|
|
665
|
+
__decorate([
|
|
666
|
+
positionType(0, true)
|
|
667
|
+
], UI.prototype, "offsetX", void 0);
|
|
668
|
+
__decorate([
|
|
669
|
+
positionType(0, true)
|
|
670
|
+
], UI.prototype, "offsetY", void 0);
|
|
671
|
+
__decorate([
|
|
672
|
+
positionType(0, true)
|
|
673
|
+
], UI.prototype, "scrollX", void 0);
|
|
674
|
+
__decorate([
|
|
675
|
+
positionType(0, true)
|
|
676
|
+
], UI.prototype, "scrollY", void 0);
|
|
677
|
+
__decorate([
|
|
678
|
+
autoLayoutType()
|
|
679
|
+
], UI.prototype, "origin", void 0);
|
|
652
680
|
__decorate([
|
|
653
681
|
autoLayoutType()
|
|
654
682
|
], UI.prototype, "around", void 0);
|
|
655
683
|
__decorate([
|
|
656
684
|
dataType(false)
|
|
657
|
-
], UI.prototype, "
|
|
685
|
+
], UI.prototype, "lazy", void 0);
|
|
658
686
|
__decorate([
|
|
659
|
-
|
|
660
|
-
], UI.prototype, "
|
|
687
|
+
naturalBoundsType(1)
|
|
688
|
+
], UI.prototype, "pixelRatio", void 0);
|
|
689
|
+
__decorate([
|
|
690
|
+
pathInputType()
|
|
691
|
+
], UI.prototype, "path", void 0);
|
|
692
|
+
__decorate([
|
|
693
|
+
pathType()
|
|
694
|
+
], UI.prototype, "windingRule", void 0);
|
|
695
|
+
__decorate([
|
|
696
|
+
pathType(true)
|
|
697
|
+
], UI.prototype, "closed", void 0);
|
|
698
|
+
__decorate([
|
|
699
|
+
autoLayoutType(false)
|
|
700
|
+
], UI.prototype, "flow", void 0);
|
|
701
|
+
__decorate([
|
|
702
|
+
boundsType(0)
|
|
703
|
+
], UI.prototype, "padding", void 0);
|
|
704
|
+
__decorate([
|
|
705
|
+
boundsType(0)
|
|
706
|
+
], UI.prototype, "gap", void 0);
|
|
707
|
+
__decorate([
|
|
708
|
+
boundsType('top-left')
|
|
709
|
+
], UI.prototype, "align", void 0);
|
|
710
|
+
__decorate([
|
|
711
|
+
boundsType(false)
|
|
712
|
+
], UI.prototype, "wrap", void 0);
|
|
713
|
+
__decorate([
|
|
714
|
+
boundsType('box')
|
|
715
|
+
], UI.prototype, "itemBox", void 0);
|
|
661
716
|
__decorate([
|
|
662
|
-
|
|
663
|
-
], UI.prototype, "
|
|
717
|
+
boundsType(true)
|
|
718
|
+
], UI.prototype, "inFlow", void 0);
|
|
719
|
+
__decorate([
|
|
720
|
+
boundsType()
|
|
721
|
+
], UI.prototype, "autoWidth", void 0);
|
|
722
|
+
__decorate([
|
|
723
|
+
boundsType()
|
|
724
|
+
], UI.prototype, "autoHeight", void 0);
|
|
725
|
+
__decorate([
|
|
726
|
+
boundsType()
|
|
727
|
+
], UI.prototype, "autoBox", void 0);
|
|
728
|
+
__decorate([
|
|
729
|
+
boundsType()
|
|
730
|
+
], UI.prototype, "widthRange", void 0);
|
|
731
|
+
__decorate([
|
|
732
|
+
boundsType()
|
|
733
|
+
], UI.prototype, "heightRange", void 0);
|
|
734
|
+
__decorate([
|
|
735
|
+
dataType(false)
|
|
736
|
+
], UI.prototype, "draggable", void 0);
|
|
664
737
|
__decorate([
|
|
665
738
|
dataType()
|
|
666
|
-
], UI.prototype, "
|
|
739
|
+
], UI.prototype, "dragBounds", void 0);
|
|
740
|
+
__decorate([
|
|
741
|
+
dataType(false)
|
|
742
|
+
], UI.prototype, "editable", void 0);
|
|
667
743
|
__decorate([
|
|
668
744
|
hitType(true)
|
|
669
745
|
], UI.prototype, "hittable", void 0);
|
|
@@ -718,21 +794,6 @@ __decorate([
|
|
|
718
794
|
__decorate([
|
|
719
795
|
strokeType(10)
|
|
720
796
|
], UI.prototype, "miterLimit", void 0);
|
|
721
|
-
__decorate([
|
|
722
|
-
dataType(false)
|
|
723
|
-
], UI.prototype, "lazy", void 0);
|
|
724
|
-
__decorate([
|
|
725
|
-
naturalBoundsType(1)
|
|
726
|
-
], UI.prototype, "pixelRatio", void 0);
|
|
727
|
-
__decorate([
|
|
728
|
-
pathInputType()
|
|
729
|
-
], UI.prototype, "path", void 0);
|
|
730
|
-
__decorate([
|
|
731
|
-
pathType()
|
|
732
|
-
], UI.prototype, "windingRule", void 0);
|
|
733
|
-
__decorate([
|
|
734
|
-
pathType(true)
|
|
735
|
-
], UI.prototype, "closed", void 0);
|
|
736
797
|
__decorate([
|
|
737
798
|
arrowType('none')
|
|
738
799
|
], UI.prototype, "startArrow", void 0);
|
|
@@ -855,7 +916,6 @@ Group = __decorate([
|
|
|
855
916
|
var Leafer_1;
|
|
856
917
|
const debug = Debug.get('Leafer');
|
|
857
918
|
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
858
|
-
static get version() { return '1.0.0-rc.21'; }
|
|
859
919
|
get __tag() { return 'Leafer'; }
|
|
860
920
|
get isApp() { return false; }
|
|
861
921
|
get app() { return this.parent || this; }
|
|
@@ -908,7 +968,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
908
968
|
if (this.isApp)
|
|
909
969
|
this.__setApp();
|
|
910
970
|
this.__checkAutoLayout(config);
|
|
911
|
-
this.updateLazyBounds();
|
|
912
971
|
this.view = canvas.view;
|
|
913
972
|
if (parentApp) {
|
|
914
973
|
this.__bindApp(parentApp);
|
|
@@ -968,9 +1027,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
968
1027
|
const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
|
|
969
1028
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
970
1029
|
}
|
|
971
|
-
forceFullRender() {
|
|
972
|
-
this.forceRender();
|
|
973
|
-
}
|
|
974
1030
|
forceRender(bounds) {
|
|
975
1031
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
976
1032
|
if (this.viewReady)
|
|
@@ -1048,7 +1104,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1048
1104
|
this.canvas.backgroundColor = newValue;
|
|
1049
1105
|
}
|
|
1050
1106
|
else {
|
|
1051
|
-
this.
|
|
1107
|
+
this.forceRender();
|
|
1052
1108
|
}
|
|
1053
1109
|
}
|
|
1054
1110
|
__onCreated() {
|
|
@@ -1152,6 +1208,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
1152
1208
|
__listenEvents() {
|
|
1153
1209
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
1154
1210
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
1211
|
+
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
1155
1212
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
1156
1213
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
1157
1214
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
@@ -1258,6 +1315,8 @@ let Box = class Box extends Group {
|
|
|
1258
1315
|
else {
|
|
1259
1316
|
this.__updateRectBoxBounds();
|
|
1260
1317
|
}
|
|
1318
|
+
if (data.flow)
|
|
1319
|
+
this.__updateContentBounds();
|
|
1261
1320
|
}
|
|
1262
1321
|
__updateStrokeBounds() { }
|
|
1263
1322
|
__updateRenderBounds() {
|
|
@@ -1667,9 +1726,10 @@ Canvas = __decorate([
|
|
|
1667
1726
|
registerUI()
|
|
1668
1727
|
], Canvas);
|
|
1669
1728
|
|
|
1670
|
-
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
1729
|
+
const { copyAndSpread, includes, isSame, spread, setList } = BoundsHelper;
|
|
1671
1730
|
let Text = class Text extends UI {
|
|
1672
1731
|
get __tag() { return 'Text'; }
|
|
1732
|
+
get editInner() { return 'TextEditor'; }
|
|
1673
1733
|
get textDrawData() {
|
|
1674
1734
|
this.__layout.update();
|
|
1675
1735
|
return this.__.__textDrawData;
|
|
@@ -1739,7 +1799,7 @@ let Text = class Text extends UI {
|
|
|
1739
1799
|
if (italic)
|
|
1740
1800
|
b.width += fontSize * 0.16;
|
|
1741
1801
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1742
|
-
if (contentBounds
|
|
1802
|
+
if (!isSame(contentBounds, layout.contentBounds)) {
|
|
1743
1803
|
layout.contentBounds = contentBounds;
|
|
1744
1804
|
layout.renderChanged = true;
|
|
1745
1805
|
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
@@ -1767,9 +1827,6 @@ __decorate([
|
|
|
1767
1827
|
__decorate([
|
|
1768
1828
|
boundsType(0)
|
|
1769
1829
|
], Text.prototype, "height", void 0);
|
|
1770
|
-
__decorate([
|
|
1771
|
-
boundsType(0)
|
|
1772
|
-
], Text.prototype, "padding", void 0);
|
|
1773
1830
|
__decorate([
|
|
1774
1831
|
surfaceType('#000000')
|
|
1775
1832
|
], Text.prototype, "fill", void 0);
|
|
@@ -1898,6 +1955,6 @@ function penPathType() {
|
|
|
1898
1955
|
};
|
|
1899
1956
|
}
|
|
1900
1957
|
|
|
1901
|
-
const version = "1.0.0-rc.
|
|
1958
|
+
const version = "1.0.0-rc.23";
|
|
1902
1959
|
|
|
1903
1960
|
export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, UI, UIBounds, UIData, UIRender, UnitConvert, arrowType, effectType, resizeType, stateType, version, zoomLayerType };
|
package/lib/draw.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decorateLeafAttr as t,attr as e,doStrokeType as i,defineKey as s,Debug as o,LeafData as r,PathConvert as a,OneRadian as _,dataProcessor as n,dataType as h,surfaceType as d,opacityType as p,sortType as l,maskType as u,eraserType as c,positionType as y,boundsType as v,scaleType as g,rotationType as f,autoLayoutType as w,hitType as x,strokeType as m,cursorType as R,naturalBoundsType as S,pathInputType as k,pathType as b,rewrite as B,Leaf as A,useModule as P,rewriteAble as C,pen as F,PathCorner as D,PathDrawer as L,UICreator as E,registerUI as W,Branch as T,LeafList as I,ImageManager as z,DataHelper as M,Creator as O,CanvasManager as N,WaitHelper as V,LeaferEvent as H,canvasSizeAttrs as Y,Bounds as U,ResizeEvent as X,AutoBounds as j,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as q,BoundsHelper as Q,Platform as Z,PathCommandDataHelper as tt,affectStrokeBoundsType as et,getPointData as it,PointHelper as st,PathBounds as ot,ImageEvent as rt,Matrix as at,MathHelper as _t,PathCreator as nt}from"@leafer/core";export*from"@leafer/core";function ht(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var _=t.length-1;_>=0;_--)(o=t[_])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const dt={},pt={},lt={},ut={},ct={},yt={},vt={},gt={},ft={};function wt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{ft.setStyle&&ft.setStyle(this,t+"Style",e)}))}})))}function xt(s){return t(s,(t=>e({set(e){this.__setAttr(t,e);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow,i(this)}})))}function mt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Rt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function St(){return(t,e)=>{const i="_"+e;s(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:kt}=a,bt={},Bt=o.get("UIData");class At extends r{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=bt)):(this.__isFills&&(this.__removeInput("fill"),ct.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=bt)):(this.__isStrokes&&(this.__removeInput("stroke"),ct.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=kt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ut.compute("fill",this.__leaf),e&&ut.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Pt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class Ct extends At{}class Ft extends Ct{get __boxStroke(){return!0}}class Dt extends Ct{}class Lt extends Ft{}class Et extends At{}class Wt extends At{get __boxStroke(){return!0}}class Tt extends At{get __boxStroke(){return!0}}class It extends At{}class zt extends At{}class Mt extends At{}class Ot extends Ct{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Vt extends At{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Wt{}const Ut={__updateStrokeSpread(){let t=0,e=0;const{stroke:i,hitStroke:s,strokeAlign:o,strokeWidth:r}=this.__;if((i||"all"===s)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:i}=this.__,s="Line"!==this.__tag?1/Math.sin(e*_/2)*Math.sqrt(r)-t:0,o="none"===i?0:r;t+=Math.max(s,o)}return this.__layout.strokeBoxSpread=e,this.__.__useArrow&&(t+=5*r),t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){jt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ut.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:n}=i;_&&vt.shadow(this,t,a),s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),n&&vt.innerShadow(this,t,a),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t))}else i.__pathInputed?jt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ut.fills(o,this,t):ut.fill("#000000",this,t)),r&&!s&&(this.__.__pixelStroke?ut.strokes(r,this,t):ut.stroke("#000000",this,t))}}};function jt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ut.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ut.stroke(o,t,e)}const Gt={__drawFast(t,e){const{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,i,s);break;case"inside":t.strokeRect(a,a,i-o,s-o);break;case"outside":t.strokeRect(-a,-a,i+o,s+o)}}}};var Jt;let $t=Jt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return F.set(this.path=this.__.path||[]),F}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findOne(t,e){}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;if(!i){const{width:t,height:e}=this.boxBounds;(t||e)&&(F.set(i=[]),this.__drawPathByBox(F))}return t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;t.lazy&&this.leafer&&this.leafer.created&&!this.leafer.lazyBounds.hit(this.__world)?t.__needComputePaint=!0:t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?D.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&<.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,i,s,o,this.__.cornerRadius):t.rect(e,i,s,o)}export(t,e){return gt.export(this,t,e)}clone(){return Jt.one(this.toJSON())}static one(t,e,i,s,o){return E.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){W()(this)}static registerData(t){n(t)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}};ht([n(At)],$t.prototype,"__",void 0),ht([St()],$t.prototype,"zoomLayer",void 0),ht([h("")],$t.prototype,"id",void 0),ht([h("")],$t.prototype,"name",void 0),ht([h("")],$t.prototype,"className",void 0),ht([d("pass-through")],$t.prototype,"blendMode",void 0),ht([p(1)],$t.prototype,"opacity",void 0),ht([p(!0)],$t.prototype,"visible",void 0),ht([wt(!1)],$t.prototype,"selected",void 0),ht([wt(!1)],$t.prototype,"disabled",void 0),ht([h(!1)],$t.prototype,"locked",void 0),ht([l(0)],$t.prototype,"zIndex",void 0),ht([u(!1)],$t.prototype,"mask",void 0),ht([d("pixel")],$t.prototype,"maskType",void 0),ht([c(!1)],$t.prototype,"eraser",void 0),ht([y(0,!0)],$t.prototype,"x",void 0),ht([y(0,!0)],$t.prototype,"y",void 0),ht([v(100,!0)],$t.prototype,"width",void 0),ht([v(100,!0)],$t.prototype,"height",void 0),ht([g(1,!0)],$t.prototype,"scaleX",void 0),ht([g(1,!0)],$t.prototype,"scaleY",void 0),ht([f(0,!0)],$t.prototype,"rotation",void 0),ht([f(0,!0)],$t.prototype,"skewX",void 0),ht([f(0,!0)],$t.prototype,"skewY",void 0),ht([w()],$t.prototype,"around",void 0),ht([h(!1)],$t.prototype,"draggable",void 0),ht([h(!1)],$t.prototype,"editable",void 0),ht([h("size")],$t.prototype,"editSize",void 0),ht([h()],$t.prototype,"editorStyle",void 0),ht([x(!0)],$t.prototype,"hittable",void 0),ht([x("path")],$t.prototype,"hitFill",void 0),ht([m("path")],$t.prototype,"hitStroke",void 0),ht([x(!1)],$t.prototype,"hitBox",void 0),ht([x(!0)],$t.prototype,"hitChildren",void 0),ht([x(!0)],$t.prototype,"hitSelf",void 0),ht([x()],$t.prototype,"hitRadius",void 0),ht([R("")],$t.prototype,"cursor",void 0),ht([d()],$t.prototype,"fill",void 0),ht([m()],$t.prototype,"stroke",void 0),ht([m("inside")],$t.prototype,"strokeAlign",void 0),ht([m(1)],$t.prototype,"strokeWidth",void 0),ht([m(!1)],$t.prototype,"strokeWidthFixed",void 0),ht([m("none")],$t.prototype,"strokeCap",void 0),ht([m("miter")],$t.prototype,"strokeJoin",void 0),ht([m()],$t.prototype,"dashPattern",void 0),ht([m()],$t.prototype,"dashOffset",void 0),ht([m(10)],$t.prototype,"miterLimit",void 0),ht([h(!1)],$t.prototype,"lazy",void 0),ht([S(1)],$t.prototype,"pixelRatio",void 0),ht([k()],$t.prototype,"path",void 0),ht([b()],$t.prototype,"windingRule",void 0),ht([b(!0)],$t.prototype,"closed",void 0),ht([xt("none")],$t.prototype,"startArrow",void 0),ht([xt("none")],$t.prototype,"endArrow",void 0),ht([b(0)],$t.prototype,"cornerRadius",void 0),ht([b()],$t.prototype,"cornerSmoothing",void 0),ht([mt()],$t.prototype,"shadow",void 0),ht([mt()],$t.prototype,"innerShadow",void 0),ht([mt()],$t.prototype,"blur",void 0),ht([mt()],$t.prototype,"backgroundBlur",void 0),ht([mt()],$t.prototype,"grayscale",void 0),ht([h()],$t.prototype,"normalStyle",void 0),ht([h()],$t.prototype,"hoverStyle",void 0),ht([h()],$t.prototype,"pressStyle",void 0),ht([h()],$t.prototype,"focusStyle",void 0),ht([h()],$t.prototype,"selectedStyle",void 0),ht([h()],$t.prototype,"disabledStyle",void 0),ht([B(A.prototype.reset)],$t.prototype,"reset",null),$t=Jt=ht([P(Ut),P(Xt),C()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:E.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;ht([n(Ct)],Kt.prototype,"__",void 0),Kt=ht([P(T),W()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{static get version(){return"1.0.0-rc.21"}get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&z.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&M.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=O.canvas(s);this.__controllers.push(this.renderer=O.renderer(this,o,s),this.watcher=O.watcher(this,s),this.layouter=O.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.updateLazyBounds(),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=O.selector(this),this.interaction=O.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=O.hitCanvasManager()),this.canvasManager=new N,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),V.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(H.RESTART):this.emitLeafer(H.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(H.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=M.copyAttrs({},t,Y);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.forceRender()}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=M.copyAttrs({},this.canvas,Y);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),M.copyAttrs(this.__,t,Y),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new j(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Y.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Y.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=M.copyAttrs({},this.canvas,Y);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(H.BEFORE_READY),this.emitLeafer(H.READY),this.emitLeafer(H.AFTER_READY),V.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(H.VIEW_READY),V.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){V.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(H.VIEW_COMPLETED),V.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new H(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(H.START,(()=>G.end(t))),this.once(J.END,(()=>this.__onReady())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_($.NEXT,this.__onNextRender,this),this.on_(J.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new H(H.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{z.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new I,ht([n(Dt)],Zt.prototype,"__",void 0),ht([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=ht([W()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};ht([n(Wt)],te.prototype,"__",void 0),te=ht([P(Gt),C(),W()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re}=Q;let ae=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){const t=this.__updateRectRenderSpread(),e=this.__.__drawAfterFill="hide"===this.__.overflow;return t||e?t:-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;oe(se,t),super.__updateRenderBounds(),re(t,se)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};ht([n(Ft)],ae.prototype,"__",void 0),ht([q("show")],ae.prototype,"overflow",void 0),ht([B(ee.__updateStrokeSpread)],ae.prototype,"__updateStrokeSpread",null),ht([B(ee.__updateRenderSpread)],ae.prototype,"__updateRectRenderSpread",null),ht([B(ee.__updateBoxBounds)],ae.prototype,"__updateRectBoxBounds",null),ht([B(ee.__updateStrokeBounds)],ae.prototype,"__updateStrokeBounds",null),ht([B(ee.__updateRenderBounds)],ae.prototype,"__updateRectRenderBounds",null),ht([B(ee.__updateChange)],ae.prototype,"__updateRectChange",null),ht([B(ee.__render)],ae.prototype,"__renderRect",null),ht([B(ie.__render)],ae.prototype,"__renderGroup",null),ae=ht([C(),W()],ae);let _e=class extends ae{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};ht([n(Lt)],_e.prototype,"__",void 0),ht([d("#FFFFFF")],_e.prototype,"fill",void 0),ht([q("hide")],_e.prototype,"overflow",void 0),_e=ht([W()],_e);const{moveTo:ne,closePath:he,ellipse:de}=tt;let pe=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,_=this.__.path=[];i?(s||o?(i<1&&de(_,r,a,r*i,a*i,0,s,o,!1),de(_,r,a,r,a,0,o,s,!0),i<1&&he(_)):(i<1&&(de(_,r,a,r*i,a*i),ne(_,t,a)),de(_,r,a,r,a,0,360,0,!0)),Z.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ne(_,r,a),de(_,r,a,r,a,0,s,o,!1),he(_)):de(_,r,a,r,a)}};ht([n(Tt)],pe.prototype,"__",void 0),ht([b(0)],pe.prototype,"innerRadius",void 0),ht([b(0)],pe.prototype,"startAngle",void 0),ht([b(0)],pe.prototype,"endAngle",void 0),pe=ht([W()],pe);const{moveTo:le,lineTo:ue,drawPoints:ce}=tt,{rotate:ye,getAngle:ve,getDistance:ge,defaultPoint:fe}=st,{toBounds:we}=ot;let xe=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=it();return t&&(i.x=t),e&&ye(i,e),i}set toPoint(t){this.width=ge(fe,t),this.rotation=ve(fe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?ce(t,this.__.points,this.__.closed):(le(t,0,0),ue(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ce(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&<.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?we(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};ht([n(Et)],xe.prototype,"__",void 0),ht([et("center")],xe.prototype,"strokeAlign",void 0),ht([v(0)],xe.prototype,"height",void 0),ht([b()],xe.prototype,"points",void 0),ht([b(0)],xe.prototype,"curve",void 0),ht([b(!1)],xe.prototype,"closed",void 0),xe=ht([W()],xe);const{sin:me,cos:Re,PI:Se}=Math,{moveTo:ke,lineTo:be,closePath:Be,drawPoints:Ae}=tt,Pe=xe.prototype;let Ce=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ae(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;ke(t,o,0);for(let e=1;e<s;e++)be(t,o+o*me(2*e*Se/s),r-r*Re(2*e*Se/s))}Be(t)}__updateRenderPath(){}__updateBoxBounds(){}};ht([n(It)],Ce.prototype,"__",void 0),ht([b(3)],Ce.prototype,"sides",void 0),ht([b()],Ce.prototype,"points",void 0),ht([b(0)],Ce.prototype,"curve",void 0),ht([B(Pe.__updateRenderPath)],Ce.prototype,"__updateRenderPath",null),ht([B(Pe.__updateBoxBounds)],Ce.prototype,"__updateBoxBounds",null),Ce=ht([C(),W()],Ce);const{sin:Fe,cos:De,PI:Le}=Math,{moveTo:Ee,lineTo:We,closePath:Te}=tt;let Ie=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Ee(a,o,0);for(let t=1;t<2*i;t++)We(a,o+(t%2==0?o:o*s)*Fe(t*Le/i),r-(t%2==0?r:r*s)*De(t*Le/i));Te(a)}};ht([n(zt)],Ie.prototype,"__",void 0),ht([b(5)],Ie.prototype,"corners",void 0),ht([b(.382)],Ie.prototype,"innerRadius",void 0),Ie=ht([W()],Ie);let ze=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(rt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};ht([n(Ht)],ze.prototype,"__",void 0),ht([v("")],ze.prototype,"url",void 0),ze=ht([W()],ze);let Me=class extends te{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=O.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new at(t.__world).invert(),r=new at;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};ht([n(Yt)],Me.prototype,"__",void 0),ht([Rt(100)],Me.prototype,"width",void 0),ht([Rt(100)],Me.prototype,"height",void 0),ht([Rt(Z.devicePixelRatio)],Me.prototype,"pixelRatio",void 0),ht([Rt(!0)],Me.prototype,"smooth",void 0),ht([Rt()],Me.prototype,"contextSettings",void 0),ht([x("all")],Me.prototype,"hitFill",void 0),Me=ht([W()],Me);const{copyAndSpread:Oe,includes:Ne,spread:Ve,setList:He}=Q;let Ye=class extends $t{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=dt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:_,textCase:n,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Pt.number(i,r),t.__letterSpacing=Pt.number(s,r),t.__padding=d?_t.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${_?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ve(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();_&&(c.width+=.16*r);const y=Ne(c,u)?c:u;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,He(t.__textBoxBounds={},[c,u])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Oe(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};ht([n(Vt)],Ye.prototype,"__",void 0),ht([v(0)],Ye.prototype,"width",void 0),ht([v(0)],Ye.prototype,"height",void 0),ht([v(0)],Ye.prototype,"padding",void 0),ht([d("#000000")],Ye.prototype,"fill",void 0),ht([et("outside")],Ye.prototype,"strokeAlign",void 0),ht([x("all")],Ye.prototype,"hitFill",void 0),ht([v("")],Ye.prototype,"text",void 0),ht([v("L")],Ye.prototype,"fontFamily",void 0),ht([v(12)],Ye.prototype,"fontSize",void 0),ht([v("normal")],Ye.prototype,"fontWeight",void 0),ht([v(!1)],Ye.prototype,"italic",void 0),ht([v("none")],Ye.prototype,"textCase",void 0),ht([v("none")],Ye.prototype,"textDecoration",void 0),ht([v(0)],Ye.prototype,"letterSpacing",void 0),ht([v({type:"percent",value:150})],Ye.prototype,"lineHeight",void 0),ht([v(0)],Ye.prototype,"paraIndent",void 0),ht([v(0)],Ye.prototype,"paraSpacing",void 0),ht([v("left")],Ye.prototype,"textAlign",void 0),ht([v("top")],Ye.prototype,"verticalAlign",void 0),ht([v("normal")],Ye.prototype,"textWrap",void 0),ht([v("show")],Ye.prototype,"textOverflow",void 0),Ye=ht([W()],Ye);let Ue=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};ht([n(Mt)],Ue.prototype,"__",void 0),ht([et("center")],Ue.prototype,"strokeAlign",void 0),Ue=ht([W()],Ue);let Xe=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ue(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,_){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,_){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}};ht([n(Ot)],Xe.prototype,"__",void 0),ht([(t,e)=>{s(t,e,{get(){return this.__path}})}],Xe.prototype,"path",void 0),Xe=ht([P(nt,["set","beginPath","path"]),W()],Xe);const je="1.0.0-rc.21";export{ae as Box,Ft as BoxData,Me as Canvas,Yt as CanvasData,pt as ColorConvert,vt as Effect,pe as Ellipse,Tt as EllipseData,gt as Export,_e as Frame,Lt as FrameData,Kt as Group,Ct as GroupData,ze as Image,Ht as ImageData,Zt as Leafer,Dt as LeaferData,xe as Line,Et as LineData,ut as Paint,yt as PaintGradient,ct as PaintImage,Ue as Path,lt as PathArrow,Mt as PathData,Xe as Pen,Ot as PenData,Ce as Polygon,It as PolygonData,te as Rect,Wt as RectData,Gt as RectRender,Ie as Star,zt as StarData,ft as State,Ye as Text,dt as TextConvert,Vt as TextData,$t as UI,Ut as UIBounds,At as UIData,Xt as UIRender,Pt as UnitConvert,xt as arrowType,mt as effectType,Rt as resizeType,wt as stateType,je as version,St as zoomLayerType};
|
|
1
|
+
import{decorateLeafAttr as t,attr as e,doStrokeType as i,defineKey as s,Debug as o,LeafData as r,PathConvert as a,OneRadian as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,sortType as l,maskType as u,eraserType as c,positionType as y,boundsType as v,scaleType as g,rotationType as f,autoLayoutType as w,naturalBoundsType as x,pathInputType as m,pathType as R,hitType as S,strokeType as k,cursorType as b,rewrite as B,Leaf as A,useModule as C,rewriteAble as P,pen as F,PathCorner as E,PathDrawer as D,UICreator as L,registerUI as T,Branch as W,LeafList as I,ImageManager as z,DataHelper as M,Creator as O,CanvasManager as N,WaitHelper as H,LeaferEvent as V,canvasSizeAttrs as Y,Bounds as X,ResizeEvent as U,AutoBounds as j,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as q,BoundsHelper as Q,Platform as Z,PathCommandDataHelper as tt,affectStrokeBoundsType as et,getPointData as it,PointHelper as st,PathBounds as ot,ImageEvent as rt,Matrix as at,MathHelper as nt,PathCreator as _t}from"@leafer/core";export*from"@leafer/core";function ht(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const dt={},pt={},lt={},ut={},ct={},yt={},vt={},gt={},ft={};function wt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{ft.setStyle&&ft.setStyle(this,t+"Style",e)}))}})))}function xt(s){return t(s,(t=>e({set(e){this.__setAttr(t,e);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow,i(this)}})))}function mt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Rt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function St(){return(t,e)=>{const i="_"+e;s(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:kt}=a,bt={},Bt=o.get("UIData");class At extends r{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=bt)):(this.__isFills&&(this.__removeInput("fill"),ct.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=bt)):(this.__isStrokes&&(this.__removeInput("stroke"),ct.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=kt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ut.compute("fill",this.__leaf),e&&ut.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Ct={number:(t,e)=>"object"==typeof t?"percent"===t.type?(t.value>49?t.value/100:t.value)*e:t.value:t};class Pt extends At{}class Ft extends Pt{get __boxStroke(){return!0}}class Et extends Pt{}class Dt extends Ft{}class Lt extends At{}class Tt extends At{get __boxStroke(){return!0}}class Wt extends At{get __boxStroke(){return!0}}class It extends At{}class zt extends At{}class Mt extends At{}class Ot extends Pt{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ht extends At{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Vt extends Tt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Tt{}const Xt={__updateStrokeSpread(){let t=0,e=0;const{stroke:i,hitStroke:s,strokeAlign:o,strokeWidth:r}=this.__;if((i||"all"===s)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:i}=this.__,s="Line"!==this.__tag?1/Math.sin(e*n/2)*Math.sqrt(r)-t:0,o="none"===i?0:r;t+=Math.max(s,o)}return this.__layout.strokeBoxSpread=e,this.__.__useArrow&&(t+=5*r),t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){jt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ut.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&vt.shadow(this,t,a),s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&vt.innerShadow(this,t,a),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t))}else i.__pathInputed?jt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ut.fills(o,this,t):ut.fill("#000000",this,t)),r&&!s&&(this.__.__pixelStroke?ut.strokes(r,this,t):ut.stroke("#000000",this,t))}}};function jt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ut.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ut.stroke(o,t,e)}const Gt={__drawFast(t,e){const{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,i,s);break;case"inside":t.strokeRect(a,a,i-o,s-o);break;case"outside":t.strokeRect(-a,-a,i+o,s+o)}}}};var Jt;let $t=Jt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return F.set(this.path=this.__.path||[]),F}get editConfig(){}get editOuter(){return"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;if(!i){const{width:t,height:e}=this.boxBounds;(t||e)&&(F.set(i=[]),this.__drawPathByBox(F))}return t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;t.lazy&&this.leafer&&this.leafer.created&&!this.leafer.lazyBounds.hit(this.__world)?t.__needComputePaint=!0:t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&<.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?D.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}export(t,e){return gt.export(this,t,e)}clone(){return Jt.one(this.toJSON())}static one(t,e,i,s,o){return L.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}};ht([_(At)],$t.prototype,"__",void 0),ht([St()],$t.prototype,"zoomLayer",void 0),ht([h("")],$t.prototype,"id",void 0),ht([h("")],$t.prototype,"name",void 0),ht([h("")],$t.prototype,"className",void 0),ht([d("pass-through")],$t.prototype,"blendMode",void 0),ht([p(1)],$t.prototype,"opacity",void 0),ht([p(!0)],$t.prototype,"visible",void 0),ht([wt(!1)],$t.prototype,"selected",void 0),ht([wt(!1)],$t.prototype,"disabled",void 0),ht([h(!1)],$t.prototype,"locked",void 0),ht([l(0)],$t.prototype,"zIndex",void 0),ht([u(!1)],$t.prototype,"mask",void 0),ht([d("pixel")],$t.prototype,"maskType",void 0),ht([c(!1)],$t.prototype,"eraser",void 0),ht([y(0,!0)],$t.prototype,"x",void 0),ht([y(0,!0)],$t.prototype,"y",void 0),ht([v(100,!0)],$t.prototype,"width",void 0),ht([v(100,!0)],$t.prototype,"height",void 0),ht([g(1,!0)],$t.prototype,"scaleX",void 0),ht([g(1,!0)],$t.prototype,"scaleY",void 0),ht([f(0,!0)],$t.prototype,"rotation",void 0),ht([f(0,!0)],$t.prototype,"skewX",void 0),ht([f(0,!0)],$t.prototype,"skewY",void 0),ht([y(0,!0)],$t.prototype,"offsetX",void 0),ht([y(0,!0)],$t.prototype,"offsetY",void 0),ht([y(0,!0)],$t.prototype,"scrollX",void 0),ht([y(0,!0)],$t.prototype,"scrollY",void 0),ht([w()],$t.prototype,"origin",void 0),ht([w()],$t.prototype,"around",void 0),ht([h(!1)],$t.prototype,"lazy",void 0),ht([x(1)],$t.prototype,"pixelRatio",void 0),ht([m()],$t.prototype,"path",void 0),ht([R()],$t.prototype,"windingRule",void 0),ht([R(!0)],$t.prototype,"closed",void 0),ht([w(!1)],$t.prototype,"flow",void 0),ht([v(0)],$t.prototype,"padding",void 0),ht([v(0)],$t.prototype,"gap",void 0),ht([v("top-left")],$t.prototype,"align",void 0),ht([v(!1)],$t.prototype,"wrap",void 0),ht([v("box")],$t.prototype,"itemBox",void 0),ht([v(!0)],$t.prototype,"inFlow",void 0),ht([v()],$t.prototype,"autoWidth",void 0),ht([v()],$t.prototype,"autoHeight",void 0),ht([v()],$t.prototype,"autoBox",void 0),ht([v()],$t.prototype,"widthRange",void 0),ht([v()],$t.prototype,"heightRange",void 0),ht([h(!1)],$t.prototype,"draggable",void 0),ht([h()],$t.prototype,"dragBounds",void 0),ht([h(!1)],$t.prototype,"editable",void 0),ht([S(!0)],$t.prototype,"hittable",void 0),ht([S("path")],$t.prototype,"hitFill",void 0),ht([k("path")],$t.prototype,"hitStroke",void 0),ht([S(!1)],$t.prototype,"hitBox",void 0),ht([S(!0)],$t.prototype,"hitChildren",void 0),ht([S(!0)],$t.prototype,"hitSelf",void 0),ht([S()],$t.prototype,"hitRadius",void 0),ht([b("")],$t.prototype,"cursor",void 0),ht([d()],$t.prototype,"fill",void 0),ht([k()],$t.prototype,"stroke",void 0),ht([k("inside")],$t.prototype,"strokeAlign",void 0),ht([k(1)],$t.prototype,"strokeWidth",void 0),ht([k(!1)],$t.prototype,"strokeWidthFixed",void 0),ht([k("none")],$t.prototype,"strokeCap",void 0),ht([k("miter")],$t.prototype,"strokeJoin",void 0),ht([k()],$t.prototype,"dashPattern",void 0),ht([k()],$t.prototype,"dashOffset",void 0),ht([k(10)],$t.prototype,"miterLimit",void 0),ht([xt("none")],$t.prototype,"startArrow",void 0),ht([xt("none")],$t.prototype,"endArrow",void 0),ht([R(0)],$t.prototype,"cornerRadius",void 0),ht([R()],$t.prototype,"cornerSmoothing",void 0),ht([mt()],$t.prototype,"shadow",void 0),ht([mt()],$t.prototype,"innerShadow",void 0),ht([mt()],$t.prototype,"blur",void 0),ht([mt()],$t.prototype,"backgroundBlur",void 0),ht([mt()],$t.prototype,"grayscale",void 0),ht([h()],$t.prototype,"normalStyle",void 0),ht([h()],$t.prototype,"hoverStyle",void 0),ht([h()],$t.prototype,"pressStyle",void 0),ht([h()],$t.prototype,"focusStyle",void 0),ht([h()],$t.prototype,"selectedStyle",void 0),ht([h()],$t.prototype,"disabledStyle",void 0),ht([B(A.prototype.reset)],$t.prototype,"reset",null),$t=Jt=ht([C(Xt),C(Ut),P()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:L.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;ht([_(Pt)],Kt.prototype,"__",void 0),Kt=ht([C(W),T()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&z.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&M.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=O.canvas(s);this.__controllers.push(this.renderer=O.renderer(this,o,s),this.watcher=O.watcher(this,s),this.layouter=O.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=O.selector(this),this.interaction=O.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=O.hitCanvasManager()),this.canvasManager=new N,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(V.RESTART):this.emitLeafer(V.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(V.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=M.copyAttrs({},t,Y);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=M.copyAttrs({},this.canvas,Y);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),M.copyAttrs(this.__,t,Y),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new j(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Y.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Y.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=M.copyAttrs({},this.canvas,Y);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(V.BEFORE_READY),this.emitLeafer(V.READY),this.emitLeafer(V.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(V.VIEW_READY),H.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(V.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new V(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(V.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once(J.END,(()=>this.__onReady())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_($.NEXT,this.__onNextRender,this),this.on_(J.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new V(V.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{z.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new I,ht([_(Et)],Zt.prototype,"__",void 0),ht([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=ht([T()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};ht([_(Tt)],te.prototype,"__",void 0),te=ht([C(Gt),P(),T()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re}=Q;let ae=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){const t=this.__updateRectRenderSpread(),e=this.__.__drawAfterFill="hide"===this.__.overflow;return t||e?t:-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;oe(se,t),super.__updateRenderBounds(),re(t,se)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};ht([_(Ft)],ae.prototype,"__",void 0),ht([q("show")],ae.prototype,"overflow",void 0),ht([B(ee.__updateStrokeSpread)],ae.prototype,"__updateStrokeSpread",null),ht([B(ee.__updateRenderSpread)],ae.prototype,"__updateRectRenderSpread",null),ht([B(ee.__updateBoxBounds)],ae.prototype,"__updateRectBoxBounds",null),ht([B(ee.__updateStrokeBounds)],ae.prototype,"__updateStrokeBounds",null),ht([B(ee.__updateRenderBounds)],ae.prototype,"__updateRectRenderBounds",null),ht([B(ee.__updateChange)],ae.prototype,"__updateRectChange",null),ht([B(ee.__render)],ae.prototype,"__renderRect",null),ht([B(ie.__render)],ae.prototype,"__renderGroup",null),ae=ht([P(),T()],ae);let ne=class extends ae{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};ht([_(Dt)],ne.prototype,"__",void 0),ht([d("#FFFFFF")],ne.prototype,"fill",void 0),ht([q("hide")],ne.prototype,"overflow",void 0),ne=ht([T()],ne);const{moveTo:_e,closePath:he,ellipse:de}=tt;let pe=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&de(n,r,a,r*i,a*i,0,s,o,!1),de(n,r,a,r,a,0,o,s,!0),i<1&&he(n)):(i<1&&(de(n,r,a,r*i,a*i),_e(n,t,a)),de(n,r,a,r,a,0,360,0,!0)),Z.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(_e(n,r,a),de(n,r,a,r,a,0,s,o,!1),he(n)):de(n,r,a,r,a)}};ht([_(Wt)],pe.prototype,"__",void 0),ht([R(0)],pe.prototype,"innerRadius",void 0),ht([R(0)],pe.prototype,"startAngle",void 0),ht([R(0)],pe.prototype,"endAngle",void 0),pe=ht([T()],pe);const{moveTo:le,lineTo:ue,drawPoints:ce}=tt,{rotate:ye,getAngle:ve,getDistance:ge,defaultPoint:fe}=st,{toBounds:we}=ot;let xe=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=it();return t&&(i.x=t),e&&ye(i,e),i}set toPoint(t){this.width=ge(fe,t),this.rotation=ve(fe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?ce(t,this.__.points,this.__.closed):(le(t,0,0),ue(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ce(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&<.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?we(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};ht([_(Lt)],xe.prototype,"__",void 0),ht([et("center")],xe.prototype,"strokeAlign",void 0),ht([v(0)],xe.prototype,"height",void 0),ht([R()],xe.prototype,"points",void 0),ht([R(0)],xe.prototype,"curve",void 0),ht([R(!1)],xe.prototype,"closed",void 0),xe=ht([T()],xe);const{sin:me,cos:Re,PI:Se}=Math,{moveTo:ke,lineTo:be,closePath:Be,drawPoints:Ae}=tt,Ce=xe.prototype;let Pe=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ae(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;ke(t,o,0);for(let e=1;e<s;e++)be(t,o+o*me(2*e*Se/s),r-r*Re(2*e*Se/s))}Be(t)}__updateRenderPath(){}__updateBoxBounds(){}};ht([_(It)],Pe.prototype,"__",void 0),ht([R(3)],Pe.prototype,"sides",void 0),ht([R()],Pe.prototype,"points",void 0),ht([R(0)],Pe.prototype,"curve",void 0),ht([B(Ce.__updateRenderPath)],Pe.prototype,"__updateRenderPath",null),ht([B(Ce.__updateBoxBounds)],Pe.prototype,"__updateBoxBounds",null),Pe=ht([P(),T()],Pe);const{sin:Fe,cos:Ee,PI:De}=Math,{moveTo:Le,lineTo:Te,closePath:We}=tt;let Ie=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Le(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*Fe(t*De/i),r-(t%2==0?r:r*s)*Ee(t*De/i));We(a)}};ht([_(zt)],Ie.prototype,"__",void 0),ht([R(5)],Ie.prototype,"corners",void 0),ht([R(.382)],Ie.prototype,"innerRadius",void 0),Ie=ht([T()],Ie);let ze=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(rt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};ht([_(Vt)],ze.prototype,"__",void 0),ht([v("")],ze.prototype,"url",void 0),ze=ht([T()],ze);let Me=class extends te{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=O.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new at(t.__world).invert(),r=new at;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};ht([_(Yt)],Me.prototype,"__",void 0),ht([Rt(100)],Me.prototype,"width",void 0),ht([Rt(100)],Me.prototype,"height",void 0),ht([Rt(Z.devicePixelRatio)],Me.prototype,"pixelRatio",void 0),ht([Rt(!0)],Me.prototype,"smooth",void 0),ht([Rt()],Me.prototype,"contextSettings",void 0),ht([S("all")],Me.prototype,"hitFill",void 0),Me=ht([T()],Me);const{copyAndSpread:Oe,includes:Ne,isSame:He,spread:Ve,setList:Ye}=Q;let Xe=class extends $t{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=dt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Ct.number(i,r),t.__letterSpacing=Ct.number(s,r),t.__padding=d?nt.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ve(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=Ne(c,u)?c:u;He(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Ye(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Oe(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};ht([_(Ht)],Xe.prototype,"__",void 0),ht([v(0)],Xe.prototype,"width",void 0),ht([v(0)],Xe.prototype,"height",void 0),ht([d("#000000")],Xe.prototype,"fill",void 0),ht([et("outside")],Xe.prototype,"strokeAlign",void 0),ht([S("all")],Xe.prototype,"hitFill",void 0),ht([v("")],Xe.prototype,"text",void 0),ht([v("L")],Xe.prototype,"fontFamily",void 0),ht([v(12)],Xe.prototype,"fontSize",void 0),ht([v("normal")],Xe.prototype,"fontWeight",void 0),ht([v(!1)],Xe.prototype,"italic",void 0),ht([v("none")],Xe.prototype,"textCase",void 0),ht([v("none")],Xe.prototype,"textDecoration",void 0),ht([v(0)],Xe.prototype,"letterSpacing",void 0),ht([v({type:"percent",value:150})],Xe.prototype,"lineHeight",void 0),ht([v(0)],Xe.prototype,"paraIndent",void 0),ht([v(0)],Xe.prototype,"paraSpacing",void 0),ht([v("left")],Xe.prototype,"textAlign",void 0),ht([v("top")],Xe.prototype,"verticalAlign",void 0),ht([v("normal")],Xe.prototype,"textWrap",void 0),ht([v("show")],Xe.prototype,"textOverflow",void 0),Xe=ht([T()],Xe);let Ue=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};ht([_(Mt)],Ue.prototype,"__",void 0),ht([et("center")],Ue.prototype,"strokeAlign",void 0),Ue=ht([T()],Ue);let je=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ue(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}};ht([_(Ot)],je.prototype,"__",void 0),ht([(t,e)=>{s(t,e,{get(){return this.__path}})}],je.prototype,"path",void 0),je=ht([C(_t,["set","beginPath","path"]),T()],je);const Ge="1.0.0-rc.23";export{ae as Box,Ft as BoxData,Me as Canvas,Yt as CanvasData,pt as ColorConvert,vt as Effect,pe as Ellipse,Wt as EllipseData,gt as Export,ne as Frame,Dt as FrameData,Kt as Group,Pt as GroupData,ze as Image,Vt as ImageData,Zt as Leafer,Et as LeaferData,xe as Line,Lt as LineData,ut as Paint,yt as PaintGradient,ct as PaintImage,Ue as Path,lt as PathArrow,Mt as PathData,je as Pen,Ot as PenData,Pe as Polygon,It as PolygonData,te as Rect,Tt as RectData,Gt as RectRender,Ie as Star,zt as StarData,ft as State,Xe as Text,dt as TextConvert,Ht as TextData,$t as UI,Xt as UIBounds,At as UIData,Ut as UIRender,Ct as UnitConvert,xt as arrowType,mt as effectType,Rt as resizeType,wt as stateType,Ge as version,St as zoomLayerType};
|
package/lib/draw.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}"function"==typeof SuppressedError&&SuppressedError;const s={},r={},o={},i={},a={},n={},p={};function h(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,e+"Style",t)}))}})))}function _(e){return t.decorateLeafAttr(e,(e=>t.attr({set(s){this.__setAttr(e,s);const r=this.__;r.__useArrow="none"!==r.startArrow||"none"!==r.endArrow,t.doStrokeType(this)}})))}function d(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function l(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function u(){return(e,s)=>{const r="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[r]=t)},get(){return this.isLeafer?this[r]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class v extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:s}=e.__nowWorld||e.__world;return s<0&&(s=-s),s>1?t/s:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&o.compute("fill",this.__leaf),e&&o.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class f extends v{}class w extends f{get __boxStroke(){return!0}}class T extends f{}class m extends w{}class I extends v{}class R extends v{get __boxStroke(){return!0}}class P extends v{get __boxStroke(){return!0}}class S extends v{}class b extends v{}class B extends v{}class k extends f{}const U={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class C extends v{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=U[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{}const D={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,this.__.__useArrow&&(e+=5*a),e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},E={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:i,__drawAfterFill:n}=s;if(this.__drawRenderPath(t),s.__useEffect){const p=o.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=s;h&&a.shadow(this,t,p),r&&(s.__isFills?o.fills(r,this,t):o.fill(r,this,t)),n&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,p),i&&(s.__isStrokes?o.strokes(i,this,t):o.stroke(i,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else r&&(s.__isFills?o.fills(r,this,t):o.fill(r,this,t)),n&&this.__drawAfterFill(t,e),i&&(s.__isStrokes?o.strokes(i,this,t):o.stroke(i,this,t))}else s.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,s,r){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:a}=this.__;this.__drawRenderPath(t),i&&!s&&(this.__.__pixelFill?o.fills(i,this,t):o.fill("#000000",this,t)),a&&!r&&(this.__.__pixelStroke?o.strokes(a,this,t):o.stroke("#000000",this,t))}}};function F(t,e,s){const{fill:r,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),r&&o.fill(r,t,e),a&&t.__drawAfterFill(e,s),i&&o.stroke(i,t,e)}const W={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return t.pen.set(this.path=this.__.path||[]),t.pen}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findOne(t,e){}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;if(!r){const{width:e,height:s}=this.boxBounds;(e||s)&&(t.pen.set(r=[]),this.__drawPathByBox(t.pen))}return e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const t=this.__;t.lazy&&this.leafer&&this.leafer.created&&!this.leafer.lazyBounds.hit(this.__world)?t.__needComputePaint=!0:t.__computePaint()}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&r.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return n.export(this,t,e)}clone(){return z.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.surfaceType("pixel")],exports.UI.prototype,"maskType",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.dataType()],exports.UI.prototype,"editorStyle",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(D),t.useModule(E),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),s.forEach((e=>{r=e.__?e:t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const H=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{static get version(){return"1.0.0-rc.21"}get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type);const i=this.canvas=t.Creator.canvas(o);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o),this.updateLazyBounds(),this.view=i.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(i),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.forceRender()}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:s}=this;if(!s||s.isSameSize(e))return;const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,r))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){return this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,s){e&&(t=t.bind(e));const r=this.__nextRenderWait;if(s){for(let e=0;e<r.length;e++)if(r[e]===t){r.splice(e,1);break}}else r.push(t)}zoom(t,e,s){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const s=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){H.error(t)}}};e?s():setTimeout(s)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(T)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,N=exports.Group.prototype,G={},{copy:V,add:j}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){const t=this.__updateRectRenderSpread(),e=this.__.__drawAfterFill="hide"===this.__.overflow;return t||e?t:-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;V(G,t),super.__updateRenderBounds(),j(t,G)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(N.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(m)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:Y,closePath:X,ellipse:J}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&J(p,a,n,a*r,n*r,0,o,i,!1),J(p,a,n,a,n,0,i,o,!0),r<1&&X(p)):(r<1&&(J(p,a,n,a*r,n*r),Y(p,e,n)),J(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(Y(p,a,n),J(p,a,n,a,n,0,o,i,!1),X(p)):J(p,a,n,a,n)}},e([t.dataProcessor(P)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:K,lineTo:$,drawPoints:q}=t.PathCommandDataHelper,{rotate:Q,getAngle:Z,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&Q(r,s),r}set toPoint(t){this.width=tt(et,t),this.rotation=Z(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?q(t,this.__.points,this.__.closed):(K(t,0,0),$(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(q(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&r.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?st(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(I)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:rt,cos:ot,PI:it}=Math,{moveTo:at,lineTo:nt,closePath:pt,drawPoints:ht}=t.PathCommandDataHelper,_t=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ht(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;at(t,o,0);for(let e=1;e<r;e++)nt(t,o+o*rt(2*e*it/r),i-i*ot(2*e*it/r))}pt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(S)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(_t.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(_t.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:dt,cos:lt,PI:ut}=Math,{moveTo:ct,lineTo:yt,closePath:xt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];ct(a,o,0);for(let t=1;t<2*s;t++)yt(a,o+(t%2==0?o:o*r)*dt(t*ut/s),i-(t%2==0?i:i*r)*lt(t*ut/s));xt(a)}},e([t.dataProcessor(b)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([l()],exports.Canvas.prototype,"contextSettings",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:vt,includes:gt,spread:ft,setList:wt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=s.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(r,a),e.__letterSpacing=g.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&ft(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(y.x-=o,y.width+=s+o),u&&(y.y-=t,y.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();p&&(y.width+=.16*a);const x=gt(y,c)?y:c;x!==s.contentBounds?(s.contentBounds=x,s.renderChanged=!0,wt(e.__textBoxBounds={},[y,c])):e.__textBoxBounds=x}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){vt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(k)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path"]),t.registerUI()],exports.Pen);exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=P,exports.Export=n,exports.FrameData=m,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=T,exports.LineData=I,exports.Paint=o,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=r,exports.PathData=B,exports.PenData=k,exports.PolygonData=S,exports.RectData=R,exports.RectRender=W,exports.StarData=b,exports.State=p,exports.TextConvert=s,exports.TextData=C,exports.UIBounds=D,exports.UIData=v,exports.UIRender=E,exports.UnitConvert=g,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.version="1.0.0-rc.21",exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core");function e(t,e,o,s){var r,i=arguments.length,a=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,s);else for(var p=t.length-1;p>=0;p--)(r=t[p])&&(a=(i<3?r(a):i>3?r(e,o,a):r(e,o))||a);return i>3&&a&&Object.defineProperty(e,o,a),a}"function"==typeof SuppressedError&&SuppressedError;const o={},s={},r={},i={},a={},p={},n={};function h(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.waitLeafer((()=>{n.setStyle&&n.setStyle(this,e+"Style",t)}))}})))}function _(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){this.__setAttr(e,o);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow,t.doStrokeType(this)}})))}function d(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function l(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function u(){return(e,o)=>{const s="_"+o;t.defineKey(e,o,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class v extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:o}=e.__nowWorld||e.__world;return o<0&&(o=-o),o>1?t/o:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&r.compute("fill",this.__leaf),e&&r.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?(t.value>49?t.value/100:t.value)*e:t.value:t};class f extends v{}class w extends f{get __boxStroke(){return!0}}class T extends f{}class m extends w{}class I extends v{}class R extends v{get __boxStroke(){return!0}}class b extends v{get __boxStroke(){return!0}}class P extends v{}class S extends v{}class U extends v{}class B extends f{}const k={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class C extends v{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=k[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{}const E={__updateStrokeSpread(){let e=0,o=0;const{stroke:s,hitStroke:r,strokeAlign:i,strokeWidth:a}=this.__;if((s||"all"===r)&&a&&"inside"!==i&&(o=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:o,strokeCap:s}=this.__,r="Line"!==this.__tag?1/Math.sin(o*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===s?0:a;e+=Math.max(r,i)}return this.__layout.strokeBoxSpread=o,this.__.__useArrow&&(e+=5*a),e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let i=t=Math.ceil(t);return o&&o.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(i=Math.max(i,r)),this.__layout.renderShapeSpread=i,t}},D={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;t.__useEffect=!!(e||o||s||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const o=this.__;if(o.__complex){o.__needComputePaint&&o.__computePaint();const{fill:s,stroke:i,__drawAfterFill:p}=o;if(this.__drawRenderPath(t),o.__useEffect){const n=r.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=o;h&&a.shadow(this,t,n),s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),p&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,n),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t)),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),p&&this.__drawAfterFill(t,e),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t))}else o.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,o,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:a}=this.__;this.__drawRenderPath(t),i&&!o&&(this.__.__pixelFill?r.fills(i,this,t):r.fill("#000000",this,t)),a&&!s&&(this.__.__pixelStroke?r.strokes(a,this,t):r.stroke("#000000",this,t))}}};function F(t,e,o){const{fill:s,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),s&&r.fill(s,t,e),a&&t.__drawAfterFill(e,o),i&&r.stroke(i,t,e)}const W={__drawFast(t,e){const{width:o,height:s,fill:r,stroke:i,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,o,s)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,__strokeWidth:r}=this.__;if(!r)return;t.setStroke(i,r,this.__);const a=r/2;switch(e){case"center":t.strokeRect(0,0,o,s);break;case"inside":t.strokeRect(a,a,o-r,s-r);break;case"outside":t.strokeRect(-a,-a,o+r,s+r)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return t.pen.set(this.path=this.__.path||[]),t.pen}get editConfig(){}get editOuter(){return"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,o){this.__layout.update();let s=o?this.__.__pathForRender:this.__.path;if(!s){const{width:e,height:o}=this.boxBounds;(e||o)&&(t.pen.set(s=[]),this.__drawPathByBox(t.pen))}return e?t.PathConvert.toCanvasData(s,!0):s}getPathString(e,o){return t.PathConvert.stringify(this.getPath(e,o))}__onUpdateSize(){if(this.__.__input){const t=this.__;t.lazy&&this.leafer&&this.leafer.created&&!this.leafer.lazyBounds.hit(this.__world)?t.__needComputePaint=!0:t.__computePaint()}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&s.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,o){o?t.PathDrawer.drawPathByData(e,o):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:o,width:s,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,o,s,r,"number"==typeof i?[i]:i)}else t.rect(e,o,s,r)}export(t,e){return p.export(this,t,e)}clone(){return z.one(this.toJSON())}static one(e,o,s,r,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,o,s,r,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.surfaceType("pixel")],exports.UI.prototype,"maskType",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.autoLayoutType(!1)],exports.UI.prototype,"flow",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.boundsType(0)],exports.UI.prototype,"gap",void 0),e([t.boundsType("top-left")],exports.UI.prototype,"align",void 0),e([t.boundsType(!1)],exports.UI.prototype,"wrap",void 0),e([t.boundsType("box")],exports.UI.prototype,"itemBox",void 0),e([t.boundsType(!0)],exports.UI.prototype,"inFlow",void 0),e([t.boundsType()],exports.UI.prototype,"autoWidth",void 0),e([t.boundsType()],exports.UI.prototype,"autoHeight",void 0),e([t.boundsType()],exports.UI.prototype,"autoBox",void 0),e([t.boundsType()],exports.UI.prototype,"widthRange",void 0),e([t.boundsType()],exports.UI.prototype,"heightRange",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(E),t.useModule(D),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e){if(e.children){const{children:o}=e;let s;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),o.forEach((e=>{s=e.__?e:t.UICreator.get(e.tag,e),this.add(s)})),e.children=o}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const H=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,o){if(this.canvas)return;let s;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:r}=this;this.initType(r.type);const i=this.canvas=t.Creator.canvas(r);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,r),this.watcher=t.Creator.watcher(this,r),this.layouter=t.Creator.layouter(this,r)),this.isApp&&this.__setApp(),this.__checkAutoLayout(r),this.view=i.view,o?(this.__bindApp(o),s=o.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,r),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,s=r.start),this.hittable=r.hittable,this.fill=r.fill,this.canvasManager.add(i),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const o=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(o).forEach((t=>this[t]=o[t]))}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:o}=this;if(!o||o.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);o.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,o){return this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,o):"fill"===e?this.__changeFill(o):"hittable"===e&&(this.canvas.hittable=o)),super.__setAttr(e,o)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,o){const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s[e]=this.config[e]=o,o&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,o){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(o){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,o){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.START,(()=>this.updateLazyBounds())),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const o=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){H.error(t)}}};e?o():setTimeout(o)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(T)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,N=exports.Group.prototype,G={},{copy:V,add:Y}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){const t=this.__updateRectRenderSpread(),e=this.__.__drawAfterFill="hide"===this.__.overflow;return t||e?t:-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;V(G,t),super.__updateRenderBounds(),Y(t,G)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(N.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(m)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:j,closePath:X,ellipse:J}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:o,innerRadius:s,startAngle:r,endAngle:i}=this.__,a=e/2,p=o/2,n=this.__.path=[];s?(r||i?(s<1&&J(n,a,p,a*s,p*s,0,r,i,!1),J(n,a,p,a,p,0,i,r,!0),s<1&&X(n)):(s<1&&(J(n,a,p,a*s,p*s),j(n,e,p)),J(n,a,p,a,p,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):r||i?(j(n,a,p),J(n,a,p,a,p,0,r,i,!1),X(n)):J(n,a,p,a,p)}},e([t.dataProcessor(b)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:K,lineTo:$,drawPoints:q}=t.PathCommandDataHelper,{rotate:Q,getAngle:Z,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:ot}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:o}=this.__,s=t.getPointData();return e&&(s.x=e),o&&Q(s,o),s}set toPoint(t){this.width=tt(et,t),this.rotation=Z(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?q(t,this.__.points,this.__.closed):(K(t,0,0),$(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(q(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&s.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?ot(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(I)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:st,cos:rt,PI:it}=Math,{moveTo:at,lineTo:pt,closePath:nt,drawPoints:ht}=t.PathCommandDataHelper,_t=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ht(t,this.__.points,!1,!0);else{const{width:e,height:o,sides:s}=this.__,r=e/2,i=o/2;at(t,r,0);for(let e=1;e<s;e++)pt(t,r+r*st(2*e*it/s),i-i*rt(2*e*it/s))}nt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(P)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(_t.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(_t.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:dt,cos:lt,PI:ut}=Math,{moveTo:ct,lineTo:yt,closePath:xt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:o,innerRadius:s}=this.__,r=t/2,i=e/2,a=this.__.path=[];ct(a,r,0);for(let t=1;t<2*o;t++)yt(a,r+(t%2==0?r:r*s)*dt(t*ut/o),i-(t%2==0?i:i*s)*lt(t*ut/o));xt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,o,s,r){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;o&&a.translate(o.x,o.y),s&&("number"==typeof s?a.scale(s):a.scale(s.x,s.y)),r&&a.rotate(r),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const o=this.canvas.view,{width:s,height:r}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,o.width,o.height,0,0,s,r),t.restore()):t.drawImage(this.canvas.view,0,0,o.width,o.height,0,0,s,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([l()],exports.Canvas.prototype,"contextSettings",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:vt,includes:gt,isSame:ft,spread:wt,setList:Tt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:o,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-o,s.width,e)))}__drawPathByData(t,e){const{x:o,y:s,width:r,height:i}=this.__layout.boxBounds;t.rect(o,s,r,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=o.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,o=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:i,fontSize:a,fontWeight:p,italic:n,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(s,a),e.__letterSpacing=g.number(r,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==p?p+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=o.boxBounds;if(e.__lineHeight<a&&wt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,o,s,r]=e.__padding;l&&(y.x-=r,y.width+=o+r),u&&(y.y-=t,y.height+=s+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(y.width+=.16*a);const x=gt(y,c)?y:c;ft(x,o.contentBounds)?e.__textBoxBounds=x:(o.contentBounds=x,o.renderChanged=!0,Tt(e.__textBoxBounds={},[y,c]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){vt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(U)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,o,s,r,i){return this}quadraticCurveTo(t,e,o,s){return this}closePath(){return this}rect(t,e,o,s){return this}roundRect(t,e,o,s,r){return this}ellipse(t,e,o,s,r,i,a,p){return this}arc(t,e,o,s,r,i){return this}arcTo(t,e,o,s,r){return this}drawEllipse(t,e,o,s,r,i,a,p){return this}drawArc(t,e,o,s,r,i){return this}drawPoints(t,e,o){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(B)],exports.Pen.prototype,"__",void 0),e([(e,o)=>{t.defineKey(e,o,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path"]),t.registerUI()],exports.Pen);exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=b,exports.Export=p,exports.FrameData=m,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=T,exports.LineData=I,exports.Paint=r,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=s,exports.PathData=U,exports.PenData=B,exports.PolygonData=P,exports.RectData=R,exports.RectRender=W,exports.StarData=S,exports.State=n,exports.TextConvert=o,exports.TextData=C,exports.UIBounds=E,exports.UIData=v,exports.UIRender=D,exports.UnitConvert=g,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.version="1.0.0-rc.23",exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/draw",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.23",
|
|
4
4
|
"description": "@leafer-ui/draw",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"leaferjs"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@leafer/core": "1.0.0-rc.
|
|
33
|
-
"@leafer-ui/display": "1.0.0-rc.
|
|
34
|
-
"@leafer-ui/display-module": "1.0.0-rc.
|
|
35
|
-
"@leafer-ui/decorator": "1.0.0-rc.
|
|
36
|
-
"@leafer-ui/external": "1.0.0-rc.
|
|
32
|
+
"@leafer/core": "1.0.0-rc.23",
|
|
33
|
+
"@leafer-ui/display": "1.0.0-rc.23",
|
|
34
|
+
"@leafer-ui/display-module": "1.0.0-rc.23",
|
|
35
|
+
"@leafer-ui/decorator": "1.0.0-rc.23",
|
|
36
|
+
"@leafer-ui/external": "1.0.0-rc.23"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/index.ts
CHANGED