@leafer-ui/draw 1.0.0-rc.19 → 1.0.0-rc.21
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 +107 -94
- package/lib/draw.esm.js +108 -96
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.min.cjs +1 -1
- package/package.json +6 -6
- package/src/index.ts +2 -0
- package/types/index.d.ts +4 -0
package/lib/draw.cjs
CHANGED
|
@@ -42,51 +42,42 @@ const Export = {};
|
|
|
42
42
|
const State = {};
|
|
43
43
|
|
|
44
44
|
function stateType(defaultValue) {
|
|
45
|
-
return (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
45
|
+
return core.decorateLeafAttr(defaultValue, (key) => core.attr({
|
|
46
|
+
set(value) {
|
|
47
|
+
this.__setAttr(key, value);
|
|
48
|
+
this.waitLeafer(() => { if (State.setStyle)
|
|
49
|
+
State.setStyle(this, key + 'Style', value); });
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
55
52
|
}
|
|
56
53
|
function arrowType(defaultValue) {
|
|
57
|
-
return (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
};
|
|
54
|
+
return core.decorateLeafAttr(defaultValue, (key) => core.attr({
|
|
55
|
+
set(value) {
|
|
56
|
+
this.__setAttr(key, value);
|
|
57
|
+
const data = this.__;
|
|
58
|
+
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
59
|
+
core.doStrokeType(this);
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
67
62
|
}
|
|
68
63
|
function effectType(defaultValue) {
|
|
69
|
-
return (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
};
|
|
64
|
+
return core.decorateLeafAttr(defaultValue, (key) => core.attr({
|
|
65
|
+
set(value) {
|
|
66
|
+
this.__setAttr(key, value);
|
|
67
|
+
if (value)
|
|
68
|
+
this.__.__useEffect = true;
|
|
69
|
+
this.__layout.renderChanged || this.__layout.renderChange();
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
79
72
|
}
|
|
80
73
|
function resizeType(defaultValue) {
|
|
81
|
-
return (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
};
|
|
74
|
+
return core.decorateLeafAttr(defaultValue, (key) => core.attr({
|
|
75
|
+
set(value) {
|
|
76
|
+
this.__setAttr(key, value);
|
|
77
|
+
this.__layout.boxChanged || this.__layout.boxChange();
|
|
78
|
+
this.__updateSize();
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
90
81
|
}
|
|
91
82
|
function zoomLayerType() {
|
|
92
83
|
return (target, key) => {
|
|
@@ -106,7 +97,8 @@ class UIData extends core.LeafData {
|
|
|
106
97
|
get __strokeWidth() {
|
|
107
98
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
108
99
|
if (strokeWidthFixed) {
|
|
109
|
-
|
|
100
|
+
const ui = this.__leaf;
|
|
101
|
+
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
110
102
|
if (scaleX < 0)
|
|
111
103
|
scaleX = -scaleX;
|
|
112
104
|
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
@@ -425,14 +417,14 @@ const UIRender = {
|
|
|
425
417
|
}
|
|
426
418
|
}
|
|
427
419
|
},
|
|
428
|
-
__renderShape(canvas, options) {
|
|
420
|
+
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
429
421
|
if (this.__worldOpacity) {
|
|
430
422
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
431
423
|
const { fill, stroke } = this.__;
|
|
432
424
|
this.__drawRenderPath(canvas);
|
|
433
|
-
if (fill)
|
|
425
|
+
if (fill && !ignoreFill)
|
|
434
426
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
435
|
-
if (stroke)
|
|
427
|
+
if (stroke && !ignoreStroke)
|
|
436
428
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
437
429
|
}
|
|
438
430
|
}
|
|
@@ -530,10 +522,7 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
530
522
|
__onUpdateSize() {
|
|
531
523
|
if (this.__.__input) {
|
|
532
524
|
const data = this.__;
|
|
533
|
-
data.__needComputePaint = true;
|
|
534
|
-
if (data.lazy && this.leafer && !this.leafer.canvas.bounds.hit(this.__world))
|
|
535
|
-
return;
|
|
536
|
-
data.__computePaint();
|
|
525
|
+
(data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
|
|
537
526
|
}
|
|
538
527
|
}
|
|
539
528
|
__updateRenderPath() {
|
|
@@ -635,31 +624,31 @@ __decorate([
|
|
|
635
624
|
core.eraserType(false)
|
|
636
625
|
], exports.UI.prototype, "eraser", void 0);
|
|
637
626
|
__decorate([
|
|
638
|
-
core.positionType(0)
|
|
627
|
+
core.positionType(0, true)
|
|
639
628
|
], exports.UI.prototype, "x", void 0);
|
|
640
629
|
__decorate([
|
|
641
|
-
core.positionType(0)
|
|
630
|
+
core.positionType(0, true)
|
|
642
631
|
], exports.UI.prototype, "y", void 0);
|
|
643
632
|
__decorate([
|
|
644
|
-
core.boundsType(100)
|
|
633
|
+
core.boundsType(100, true)
|
|
645
634
|
], exports.UI.prototype, "width", void 0);
|
|
646
635
|
__decorate([
|
|
647
|
-
core.boundsType(100)
|
|
636
|
+
core.boundsType(100, true)
|
|
648
637
|
], exports.UI.prototype, "height", void 0);
|
|
649
638
|
__decorate([
|
|
650
|
-
core.scaleType(1)
|
|
639
|
+
core.scaleType(1, true)
|
|
651
640
|
], exports.UI.prototype, "scaleX", void 0);
|
|
652
641
|
__decorate([
|
|
653
|
-
core.scaleType(1)
|
|
642
|
+
core.scaleType(1, true)
|
|
654
643
|
], exports.UI.prototype, "scaleY", void 0);
|
|
655
644
|
__decorate([
|
|
656
|
-
core.rotationType(0)
|
|
645
|
+
core.rotationType(0, true)
|
|
657
646
|
], exports.UI.prototype, "rotation", void 0);
|
|
658
647
|
__decorate([
|
|
659
|
-
core.rotationType(0)
|
|
648
|
+
core.rotationType(0, true)
|
|
660
649
|
], exports.UI.prototype, "skewX", void 0);
|
|
661
650
|
__decorate([
|
|
662
|
-
core.rotationType(0)
|
|
651
|
+
core.rotationType(0, true)
|
|
663
652
|
], exports.UI.prototype, "skewY", void 0);
|
|
664
653
|
__decorate([
|
|
665
654
|
core.autoLayoutType()
|
|
@@ -673,6 +662,9 @@ __decorate([
|
|
|
673
662
|
__decorate([
|
|
674
663
|
core.dataType('size')
|
|
675
664
|
], exports.UI.prototype, "editSize", void 0);
|
|
665
|
+
__decorate([
|
|
666
|
+
core.dataType()
|
|
667
|
+
], exports.UI.prototype, "editorStyle", void 0);
|
|
676
668
|
__decorate([
|
|
677
669
|
core.hitType(true)
|
|
678
670
|
], exports.UI.prototype, "hittable", void 0);
|
|
@@ -739,6 +731,9 @@ __decorate([
|
|
|
739
731
|
__decorate([
|
|
740
732
|
core.pathType()
|
|
741
733
|
], exports.UI.prototype, "windingRule", void 0);
|
|
734
|
+
__decorate([
|
|
735
|
+
core.pathType(true)
|
|
736
|
+
], exports.UI.prototype, "closed", void 0);
|
|
742
737
|
__decorate([
|
|
743
738
|
arrowType('none')
|
|
744
739
|
], exports.UI.prototype, "startArrow", void 0);
|
|
@@ -858,14 +853,17 @@ exports.Group = __decorate([
|
|
|
858
853
|
core.registerUI()
|
|
859
854
|
], exports.Group);
|
|
860
855
|
|
|
856
|
+
var Leafer_1;
|
|
861
857
|
const debug = core.Debug.get('Leafer');
|
|
862
|
-
exports.Leafer = class Leafer extends exports.Group {
|
|
858
|
+
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
859
|
+
static get version() { return '1.0.0-rc.21'; }
|
|
863
860
|
get __tag() { return 'Leafer'; }
|
|
864
861
|
get isApp() { return false; }
|
|
865
862
|
get app() { return this.parent || this; }
|
|
866
863
|
get isLeafer() { return true; }
|
|
867
864
|
get imageReady() { return this.viewReady && core.ImageManager.isComplete; }
|
|
868
865
|
get layoutLocked() { return !this.layouter.running; }
|
|
866
|
+
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
869
867
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
870
868
|
constructor(userConfig, data) {
|
|
871
869
|
super(data);
|
|
@@ -874,6 +872,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
874
872
|
start: true,
|
|
875
873
|
hittable: true,
|
|
876
874
|
smooth: true,
|
|
875
|
+
lazySpeard: 100,
|
|
877
876
|
zoom: {
|
|
878
877
|
min: 0.01,
|
|
879
878
|
max: 256
|
|
@@ -894,6 +893,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
894
893
|
this.userConfig = userConfig;
|
|
895
894
|
if (userConfig && (userConfig.view || userConfig.width))
|
|
896
895
|
this.init(userConfig);
|
|
896
|
+
Leafer_1.list.add(this);
|
|
897
897
|
}
|
|
898
898
|
init(userConfig, parentApp) {
|
|
899
899
|
if (this.canvas)
|
|
@@ -904,19 +904,20 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
904
904
|
let start;
|
|
905
905
|
const { config } = this;
|
|
906
906
|
this.initType(config.type);
|
|
907
|
-
this.canvas = core.Creator.canvas(config);
|
|
908
|
-
this.__controllers.push(this.renderer = core.Creator.renderer(this,
|
|
907
|
+
const canvas = this.canvas = core.Creator.canvas(config);
|
|
908
|
+
this.__controllers.push(this.renderer = core.Creator.renderer(this, canvas, config), this.watcher = core.Creator.watcher(this, config), this.layouter = core.Creator.layouter(this, config));
|
|
909
909
|
if (this.isApp)
|
|
910
910
|
this.__setApp();
|
|
911
911
|
this.__checkAutoLayout(config);
|
|
912
|
-
this.
|
|
912
|
+
this.updateLazyBounds();
|
|
913
|
+
this.view = canvas.view;
|
|
913
914
|
if (parentApp) {
|
|
914
915
|
this.__bindApp(parentApp);
|
|
915
916
|
start = parentApp.running;
|
|
916
917
|
}
|
|
917
918
|
else {
|
|
918
919
|
this.selector = core.Creator.selector(this);
|
|
919
|
-
this.interaction = core.Creator.interaction(this,
|
|
920
|
+
this.interaction = core.Creator.interaction(this, canvas, this.selector, config);
|
|
920
921
|
if (this.interaction) {
|
|
921
922
|
this.__controllers.unshift(this.interaction);
|
|
922
923
|
this.hitCanvasManager = core.Creator.hitCanvasManager();
|
|
@@ -926,23 +927,17 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
926
927
|
}
|
|
927
928
|
this.hittable = config.hittable;
|
|
928
929
|
this.fill = config.fill;
|
|
929
|
-
this.canvasManager.add(
|
|
930
|
+
this.canvasManager.add(canvas);
|
|
930
931
|
this.__listenEvents();
|
|
931
932
|
if (start)
|
|
932
933
|
this.__startTimer = setTimeout(this.start.bind(this));
|
|
934
|
+
core.WaitHelper.run(this.__initWait);
|
|
933
935
|
this.onInit();
|
|
934
936
|
}
|
|
935
937
|
onInit() { }
|
|
936
938
|
initType(_type) { }
|
|
937
939
|
set(data) {
|
|
938
|
-
|
|
939
|
-
setTimeout(() => {
|
|
940
|
-
super.set(data);
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
super.set(data);
|
|
945
|
-
}
|
|
940
|
+
this.waitInit(() => { super.set(data); });
|
|
946
941
|
}
|
|
947
942
|
start() {
|
|
948
943
|
clearTimeout(this.__startTimer);
|
|
@@ -987,11 +982,16 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
987
982
|
if (i)
|
|
988
983
|
cursor ? i.setCursor(cursor) : i.updateCursor();
|
|
989
984
|
}
|
|
985
|
+
updateLazyBounds() {
|
|
986
|
+
this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
|
|
987
|
+
}
|
|
990
988
|
__doResize(size) {
|
|
991
|
-
|
|
989
|
+
const { canvas } = this;
|
|
990
|
+
if (!canvas || canvas.isSameSize(size))
|
|
992
991
|
return;
|
|
993
992
|
const old = core.DataHelper.copyAttrs({}, this.canvas, core.canvasSizeAttrs);
|
|
994
|
-
|
|
993
|
+
canvas.resize(size);
|
|
994
|
+
this.updateLazyBounds();
|
|
995
995
|
this.__onResize(new core.ResizeEvent(size, old));
|
|
996
996
|
}
|
|
997
997
|
__onResize(event) {
|
|
@@ -1029,7 +1029,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1029
1029
|
this.canvas.hittable = newValue;
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
|
1032
|
-
super.__setAttr(attrName, newValue);
|
|
1032
|
+
return super.__setAttr(attrName, newValue);
|
|
1033
1033
|
}
|
|
1034
1034
|
__getAttr(attrName) {
|
|
1035
1035
|
if (this.canvas && core.canvasSizeAttrs.includes(attrName))
|
|
@@ -1096,6 +1096,13 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1096
1096
|
this.nextRender(() => this.interaction.updateCursor());
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
|
+
waitInit(item, bind) {
|
|
1100
|
+
if (bind)
|
|
1101
|
+
item = item.bind(bind);
|
|
1102
|
+
if (!this.__initWait)
|
|
1103
|
+
this.__initWait = [];
|
|
1104
|
+
this.canvas ? item() : this.__initWait.push(item);
|
|
1105
|
+
}
|
|
1099
1106
|
waitReady(item, bind) {
|
|
1100
1107
|
if (bind)
|
|
1101
1108
|
item = item.bind(bind);
|
|
@@ -1135,14 +1142,8 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1135
1142
|
}
|
|
1136
1143
|
}
|
|
1137
1144
|
zoom(_zoomType, _padding, _fixedScale) { return undefined; }
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
if (absScale < min)
|
|
1141
|
-
changeScale = min / scaleX;
|
|
1142
|
-
else if (absScale > max)
|
|
1143
|
-
changeScale = max / scaleX;
|
|
1144
|
-
return changeScale;
|
|
1145
|
-
}
|
|
1145
|
+
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
1146
|
+
getValidScale(changeScale) { return changeScale; }
|
|
1146
1147
|
__checkUpdateLayout() {
|
|
1147
1148
|
this.__layout.update();
|
|
1148
1149
|
}
|
|
@@ -1161,9 +1162,10 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1161
1162
|
this.off_(this.__eventIds);
|
|
1162
1163
|
this.__eventIds.length = 0;
|
|
1163
1164
|
}
|
|
1164
|
-
destroy() {
|
|
1165
|
-
|
|
1165
|
+
destroy(sync) {
|
|
1166
|
+
const doDestory = () => {
|
|
1166
1167
|
if (!this.destroyed) {
|
|
1168
|
+
Leafer_1.list.remove(this);
|
|
1167
1169
|
try {
|
|
1168
1170
|
this.stop();
|
|
1169
1171
|
this.emitEvent(new core.LeaferEvent(core.LeaferEvent.END, this));
|
|
@@ -1191,16 +1193,18 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1191
1193
|
debug.error(e);
|
|
1192
1194
|
}
|
|
1193
1195
|
}
|
|
1194
|
-
}
|
|
1196
|
+
};
|
|
1197
|
+
sync ? doDestory() : setTimeout(doDestory);
|
|
1195
1198
|
}
|
|
1196
1199
|
};
|
|
1200
|
+
exports.Leafer.list = new core.LeafList();
|
|
1197
1201
|
__decorate([
|
|
1198
1202
|
core.dataProcessor(LeaferData)
|
|
1199
1203
|
], exports.Leafer.prototype, "__", void 0);
|
|
1200
1204
|
__decorate([
|
|
1201
1205
|
core.boundsType()
|
|
1202
1206
|
], exports.Leafer.prototype, "pixelRatio", void 0);
|
|
1203
|
-
exports.Leafer = __decorate([
|
|
1207
|
+
exports.Leafer = Leafer_1 = __decorate([
|
|
1204
1208
|
core.registerUI()
|
|
1205
1209
|
], exports.Leafer);
|
|
1206
1210
|
|
|
@@ -1233,11 +1237,9 @@ exports.Box = class Box extends exports.Group {
|
|
|
1233
1237
|
__updateStrokeSpread() { return 0; }
|
|
1234
1238
|
__updateRectRenderSpread() { return 0; }
|
|
1235
1239
|
__updateRenderSpread() {
|
|
1236
|
-
|
|
1237
|
-
this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
1238
|
-
|
|
1239
|
-
width = this.__.__drawAfterFill ? 0 : 1;
|
|
1240
|
-
return width;
|
|
1240
|
+
const width = this.__updateRectRenderSpread();
|
|
1241
|
+
const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
1242
|
+
return (width || hide) ? width : -1;
|
|
1241
1243
|
}
|
|
1242
1244
|
__updateRectBoxBounds() { }
|
|
1243
1245
|
__updateBoxBounds() {
|
|
@@ -1431,7 +1433,7 @@ exports.Line = class Line extends exports.UI {
|
|
|
1431
1433
|
__updatePath() {
|
|
1432
1434
|
const path = this.__.path = [];
|
|
1433
1435
|
if (this.__.points) {
|
|
1434
|
-
drawPoints$1(path, this.__.points,
|
|
1436
|
+
drawPoints$1(path, this.__.points, this.__.closed);
|
|
1435
1437
|
}
|
|
1436
1438
|
else {
|
|
1437
1439
|
moveTo$2(path, 0, 0);
|
|
@@ -1441,7 +1443,7 @@ exports.Line = class Line extends exports.UI {
|
|
|
1441
1443
|
__updateRenderPath() {
|
|
1442
1444
|
const data = this.__;
|
|
1443
1445
|
if (!this.pathInputed && data.points && data.curve) {
|
|
1444
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve,
|
|
1446
|
+
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
1445
1447
|
if (data.__useArrow)
|
|
1446
1448
|
PathArrow.addArrows(this, false);
|
|
1447
1449
|
}
|
|
@@ -1473,6 +1475,9 @@ __decorate([
|
|
|
1473
1475
|
__decorate([
|
|
1474
1476
|
core.pathType(0)
|
|
1475
1477
|
], exports.Line.prototype, "curve", void 0);
|
|
1478
|
+
__decorate([
|
|
1479
|
+
core.pathType(false)
|
|
1480
|
+
], exports.Line.prototype, "closed", void 0);
|
|
1476
1481
|
exports.Line = __decorate([
|
|
1477
1482
|
core.registerUI()
|
|
1478
1483
|
], exports.Line);
|
|
@@ -1484,7 +1489,6 @@ exports.Polygon = class Polygon extends exports.UI {
|
|
|
1484
1489
|
get __tag() { return 'Polygon'; }
|
|
1485
1490
|
constructor(data) {
|
|
1486
1491
|
super(data);
|
|
1487
|
-
this.pathClosed = true;
|
|
1488
1492
|
}
|
|
1489
1493
|
__updatePath() {
|
|
1490
1494
|
const path = this.__.path = [];
|
|
@@ -1654,6 +1658,9 @@ __decorate([
|
|
|
1654
1658
|
__decorate([
|
|
1655
1659
|
resizeType(true)
|
|
1656
1660
|
], exports.Canvas.prototype, "smooth", void 0);
|
|
1661
|
+
__decorate([
|
|
1662
|
+
resizeType()
|
|
1663
|
+
], exports.Canvas.prototype, "contextSettings", void 0);
|
|
1657
1664
|
__decorate([
|
|
1658
1665
|
core.hitType('all')
|
|
1659
1666
|
], exports.Canvas.prototype, "hitFill", void 0);
|
|
@@ -1730,6 +1737,8 @@ exports.Text = class Text extends exports.UI {
|
|
|
1730
1737
|
else {
|
|
1731
1738
|
super.__updateBoxBounds();
|
|
1732
1739
|
}
|
|
1740
|
+
if (italic)
|
|
1741
|
+
b.width += fontSize * 0.16;
|
|
1733
1742
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1734
1743
|
if (contentBounds !== layout.contentBounds) {
|
|
1735
1744
|
layout.contentBounds = contentBounds;
|
|
@@ -1867,6 +1876,7 @@ exports.Pen = class Pen extends exports.Group {
|
|
|
1867
1876
|
drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
1868
1877
|
drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
1869
1878
|
drawPoints(_points, _curve, _close) { return this; }
|
|
1879
|
+
clearPath() { return this; }
|
|
1870
1880
|
paint() {
|
|
1871
1881
|
this.pathElement.forceUpdate('path');
|
|
1872
1882
|
}
|
|
@@ -1878,7 +1888,7 @@ __decorate([
|
|
|
1878
1888
|
penPathType()
|
|
1879
1889
|
], exports.Pen.prototype, "path", void 0);
|
|
1880
1890
|
exports.Pen = __decorate([
|
|
1881
|
-
core.useModule(core.PathCreator, ['beginPath', 'path']),
|
|
1891
|
+
core.useModule(core.PathCreator, ['set', 'beginPath', 'path']),
|
|
1882
1892
|
core.registerUI()
|
|
1883
1893
|
], exports.Pen);
|
|
1884
1894
|
function penPathType() {
|
|
@@ -1889,6 +1899,8 @@ function penPathType() {
|
|
|
1889
1899
|
};
|
|
1890
1900
|
}
|
|
1891
1901
|
|
|
1902
|
+
const version = "1.0.0-rc.21";
|
|
1903
|
+
|
|
1892
1904
|
exports.BoxData = BoxData;
|
|
1893
1905
|
exports.CanvasData = CanvasData;
|
|
1894
1906
|
exports.ColorConvert = ColorConvert;
|
|
@@ -1921,6 +1933,7 @@ exports.arrowType = arrowType;
|
|
|
1921
1933
|
exports.effectType = effectType;
|
|
1922
1934
|
exports.resizeType = resizeType;
|
|
1923
1935
|
exports.stateType = stateType;
|
|
1936
|
+
exports.version = version;
|
|
1924
1937
|
exports.zoomLayerType = zoomLayerType;
|
|
1925
1938
|
Object.keys(core).forEach(function (k) {
|
|
1926
1939
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/lib/draw.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decorateLeafAttr, attr, doStrokeType, defineKey, Debug, LeafData, PathConvert, OneRadian, dataProcessor, dataType, surfaceType, opacityType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, naturalBoundsType, pathInputType, pathType, 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
|
/******************************************************************************
|
|
@@ -41,51 +41,42 @@ const Export = {};
|
|
|
41
41
|
const State = {};
|
|
42
42
|
|
|
43
43
|
function stateType(defaultValue) {
|
|
44
|
-
return (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
44
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
45
|
+
set(value) {
|
|
46
|
+
this.__setAttr(key, value);
|
|
47
|
+
this.waitLeafer(() => { if (State.setStyle)
|
|
48
|
+
State.setStyle(this, key + 'Style', value); });
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
54
51
|
}
|
|
55
52
|
function arrowType(defaultValue) {
|
|
56
|
-
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
};
|
|
53
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
54
|
+
set(value) {
|
|
55
|
+
this.__setAttr(key, value);
|
|
56
|
+
const data = this.__;
|
|
57
|
+
data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
|
|
58
|
+
doStrokeType(this);
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
66
61
|
}
|
|
67
62
|
function effectType(defaultValue) {
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
63
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
64
|
+
set(value) {
|
|
65
|
+
this.__setAttr(key, value);
|
|
66
|
+
if (value)
|
|
67
|
+
this.__.__useEffect = true;
|
|
68
|
+
this.__layout.renderChanged || this.__layout.renderChange();
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
78
71
|
}
|
|
79
72
|
function resizeType(defaultValue) {
|
|
80
|
-
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
};
|
|
73
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
74
|
+
set(value) {
|
|
75
|
+
this.__setAttr(key, value);
|
|
76
|
+
this.__layout.boxChanged || this.__layout.boxChange();
|
|
77
|
+
this.__updateSize();
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
89
80
|
}
|
|
90
81
|
function zoomLayerType() {
|
|
91
82
|
return (target, key) => {
|
|
@@ -105,7 +96,8 @@ class UIData extends LeafData {
|
|
|
105
96
|
get __strokeWidth() {
|
|
106
97
|
const { strokeWidth, strokeWidthFixed } = this;
|
|
107
98
|
if (strokeWidthFixed) {
|
|
108
|
-
|
|
99
|
+
const ui = this.__leaf;
|
|
100
|
+
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
109
101
|
if (scaleX < 0)
|
|
110
102
|
scaleX = -scaleX;
|
|
111
103
|
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
@@ -424,14 +416,14 @@ const UIRender = {
|
|
|
424
416
|
}
|
|
425
417
|
}
|
|
426
418
|
},
|
|
427
|
-
__renderShape(canvas, options) {
|
|
419
|
+
__renderShape(canvas, options, ignoreFill, ignoreStroke) {
|
|
428
420
|
if (this.__worldOpacity) {
|
|
429
421
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
430
422
|
const { fill, stroke } = this.__;
|
|
431
423
|
this.__drawRenderPath(canvas);
|
|
432
|
-
if (fill)
|
|
424
|
+
if (fill && !ignoreFill)
|
|
433
425
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
434
|
-
if (stroke)
|
|
426
|
+
if (stroke && !ignoreStroke)
|
|
435
427
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
436
428
|
}
|
|
437
429
|
}
|
|
@@ -529,10 +521,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
529
521
|
__onUpdateSize() {
|
|
530
522
|
if (this.__.__input) {
|
|
531
523
|
const data = this.__;
|
|
532
|
-
data.__needComputePaint = true;
|
|
533
|
-
if (data.lazy && this.leafer && !this.leafer.canvas.bounds.hit(this.__world))
|
|
534
|
-
return;
|
|
535
|
-
data.__computePaint();
|
|
524
|
+
(data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
|
|
536
525
|
}
|
|
537
526
|
}
|
|
538
527
|
__updateRenderPath() {
|
|
@@ -634,31 +623,31 @@ __decorate([
|
|
|
634
623
|
eraserType(false)
|
|
635
624
|
], UI.prototype, "eraser", void 0);
|
|
636
625
|
__decorate([
|
|
637
|
-
positionType(0)
|
|
626
|
+
positionType(0, true)
|
|
638
627
|
], UI.prototype, "x", void 0);
|
|
639
628
|
__decorate([
|
|
640
|
-
positionType(0)
|
|
629
|
+
positionType(0, true)
|
|
641
630
|
], UI.prototype, "y", void 0);
|
|
642
631
|
__decorate([
|
|
643
|
-
boundsType(100)
|
|
632
|
+
boundsType(100, true)
|
|
644
633
|
], UI.prototype, "width", void 0);
|
|
645
634
|
__decorate([
|
|
646
|
-
boundsType(100)
|
|
635
|
+
boundsType(100, true)
|
|
647
636
|
], UI.prototype, "height", void 0);
|
|
648
637
|
__decorate([
|
|
649
|
-
scaleType(1)
|
|
638
|
+
scaleType(1, true)
|
|
650
639
|
], UI.prototype, "scaleX", void 0);
|
|
651
640
|
__decorate([
|
|
652
|
-
scaleType(1)
|
|
641
|
+
scaleType(1, true)
|
|
653
642
|
], UI.prototype, "scaleY", void 0);
|
|
654
643
|
__decorate([
|
|
655
|
-
rotationType(0)
|
|
644
|
+
rotationType(0, true)
|
|
656
645
|
], UI.prototype, "rotation", void 0);
|
|
657
646
|
__decorate([
|
|
658
|
-
rotationType(0)
|
|
647
|
+
rotationType(0, true)
|
|
659
648
|
], UI.prototype, "skewX", void 0);
|
|
660
649
|
__decorate([
|
|
661
|
-
rotationType(0)
|
|
650
|
+
rotationType(0, true)
|
|
662
651
|
], UI.prototype, "skewY", void 0);
|
|
663
652
|
__decorate([
|
|
664
653
|
autoLayoutType()
|
|
@@ -672,6 +661,9 @@ __decorate([
|
|
|
672
661
|
__decorate([
|
|
673
662
|
dataType('size')
|
|
674
663
|
], UI.prototype, "editSize", void 0);
|
|
664
|
+
__decorate([
|
|
665
|
+
dataType()
|
|
666
|
+
], UI.prototype, "editorStyle", void 0);
|
|
675
667
|
__decorate([
|
|
676
668
|
hitType(true)
|
|
677
669
|
], UI.prototype, "hittable", void 0);
|
|
@@ -738,6 +730,9 @@ __decorate([
|
|
|
738
730
|
__decorate([
|
|
739
731
|
pathType()
|
|
740
732
|
], UI.prototype, "windingRule", void 0);
|
|
733
|
+
__decorate([
|
|
734
|
+
pathType(true)
|
|
735
|
+
], UI.prototype, "closed", void 0);
|
|
741
736
|
__decorate([
|
|
742
737
|
arrowType('none')
|
|
743
738
|
], UI.prototype, "startArrow", void 0);
|
|
@@ -857,14 +852,17 @@ Group = __decorate([
|
|
|
857
852
|
registerUI()
|
|
858
853
|
], Group);
|
|
859
854
|
|
|
855
|
+
var Leafer_1;
|
|
860
856
|
const debug = Debug.get('Leafer');
|
|
861
|
-
let Leafer = class Leafer extends Group {
|
|
857
|
+
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
858
|
+
static get version() { return '1.0.0-rc.21'; }
|
|
862
859
|
get __tag() { return 'Leafer'; }
|
|
863
860
|
get isApp() { return false; }
|
|
864
861
|
get app() { return this.parent || this; }
|
|
865
862
|
get isLeafer() { return true; }
|
|
866
863
|
get imageReady() { return this.viewReady && ImageManager.isComplete; }
|
|
867
864
|
get layoutLocked() { return !this.layouter.running; }
|
|
865
|
+
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
868
866
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
869
867
|
constructor(userConfig, data) {
|
|
870
868
|
super(data);
|
|
@@ -873,6 +871,7 @@ let Leafer = class Leafer extends Group {
|
|
|
873
871
|
start: true,
|
|
874
872
|
hittable: true,
|
|
875
873
|
smooth: true,
|
|
874
|
+
lazySpeard: 100,
|
|
876
875
|
zoom: {
|
|
877
876
|
min: 0.01,
|
|
878
877
|
max: 256
|
|
@@ -893,6 +892,7 @@ let Leafer = class Leafer extends Group {
|
|
|
893
892
|
this.userConfig = userConfig;
|
|
894
893
|
if (userConfig && (userConfig.view || userConfig.width))
|
|
895
894
|
this.init(userConfig);
|
|
895
|
+
Leafer_1.list.add(this);
|
|
896
896
|
}
|
|
897
897
|
init(userConfig, parentApp) {
|
|
898
898
|
if (this.canvas)
|
|
@@ -903,19 +903,20 @@ let Leafer = class Leafer extends Group {
|
|
|
903
903
|
let start;
|
|
904
904
|
const { config } = this;
|
|
905
905
|
this.initType(config.type);
|
|
906
|
-
this.canvas = Creator.canvas(config);
|
|
907
|
-
this.__controllers.push(this.renderer = Creator.renderer(this,
|
|
906
|
+
const canvas = this.canvas = Creator.canvas(config);
|
|
907
|
+
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
908
908
|
if (this.isApp)
|
|
909
909
|
this.__setApp();
|
|
910
910
|
this.__checkAutoLayout(config);
|
|
911
|
-
this.
|
|
911
|
+
this.updateLazyBounds();
|
|
912
|
+
this.view = canvas.view;
|
|
912
913
|
if (parentApp) {
|
|
913
914
|
this.__bindApp(parentApp);
|
|
914
915
|
start = parentApp.running;
|
|
915
916
|
}
|
|
916
917
|
else {
|
|
917
918
|
this.selector = Creator.selector(this);
|
|
918
|
-
this.interaction = Creator.interaction(this,
|
|
919
|
+
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
919
920
|
if (this.interaction) {
|
|
920
921
|
this.__controllers.unshift(this.interaction);
|
|
921
922
|
this.hitCanvasManager = Creator.hitCanvasManager();
|
|
@@ -925,23 +926,17 @@ let Leafer = class Leafer extends Group {
|
|
|
925
926
|
}
|
|
926
927
|
this.hittable = config.hittable;
|
|
927
928
|
this.fill = config.fill;
|
|
928
|
-
this.canvasManager.add(
|
|
929
|
+
this.canvasManager.add(canvas);
|
|
929
930
|
this.__listenEvents();
|
|
930
931
|
if (start)
|
|
931
932
|
this.__startTimer = setTimeout(this.start.bind(this));
|
|
933
|
+
WaitHelper.run(this.__initWait);
|
|
932
934
|
this.onInit();
|
|
933
935
|
}
|
|
934
936
|
onInit() { }
|
|
935
937
|
initType(_type) { }
|
|
936
938
|
set(data) {
|
|
937
|
-
|
|
938
|
-
setTimeout(() => {
|
|
939
|
-
super.set(data);
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
else {
|
|
943
|
-
super.set(data);
|
|
944
|
-
}
|
|
939
|
+
this.waitInit(() => { super.set(data); });
|
|
945
940
|
}
|
|
946
941
|
start() {
|
|
947
942
|
clearTimeout(this.__startTimer);
|
|
@@ -986,11 +981,16 @@ let Leafer = class Leafer extends Group {
|
|
|
986
981
|
if (i)
|
|
987
982
|
cursor ? i.setCursor(cursor) : i.updateCursor();
|
|
988
983
|
}
|
|
984
|
+
updateLazyBounds() {
|
|
985
|
+
this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
|
|
986
|
+
}
|
|
989
987
|
__doResize(size) {
|
|
990
|
-
|
|
988
|
+
const { canvas } = this;
|
|
989
|
+
if (!canvas || canvas.isSameSize(size))
|
|
991
990
|
return;
|
|
992
991
|
const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
|
|
993
|
-
|
|
992
|
+
canvas.resize(size);
|
|
993
|
+
this.updateLazyBounds();
|
|
994
994
|
this.__onResize(new ResizeEvent(size, old));
|
|
995
995
|
}
|
|
996
996
|
__onResize(event) {
|
|
@@ -1028,7 +1028,7 @@ let Leafer = class Leafer extends Group {
|
|
|
1028
1028
|
this.canvas.hittable = newValue;
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
|
-
super.__setAttr(attrName, newValue);
|
|
1031
|
+
return super.__setAttr(attrName, newValue);
|
|
1032
1032
|
}
|
|
1033
1033
|
__getAttr(attrName) {
|
|
1034
1034
|
if (this.canvas && canvasSizeAttrs.includes(attrName))
|
|
@@ -1095,6 +1095,13 @@ let Leafer = class Leafer extends Group {
|
|
|
1095
1095
|
this.nextRender(() => this.interaction.updateCursor());
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
1098
|
+
waitInit(item, bind) {
|
|
1099
|
+
if (bind)
|
|
1100
|
+
item = item.bind(bind);
|
|
1101
|
+
if (!this.__initWait)
|
|
1102
|
+
this.__initWait = [];
|
|
1103
|
+
this.canvas ? item() : this.__initWait.push(item);
|
|
1104
|
+
}
|
|
1098
1105
|
waitReady(item, bind) {
|
|
1099
1106
|
if (bind)
|
|
1100
1107
|
item = item.bind(bind);
|
|
@@ -1134,14 +1141,8 @@ let Leafer = class Leafer extends Group {
|
|
|
1134
1141
|
}
|
|
1135
1142
|
}
|
|
1136
1143
|
zoom(_zoomType, _padding, _fixedScale) { return undefined; }
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
if (absScale < min)
|
|
1140
|
-
changeScale = min / scaleX;
|
|
1141
|
-
else if (absScale > max)
|
|
1142
|
-
changeScale = max / scaleX;
|
|
1143
|
-
return changeScale;
|
|
1144
|
-
}
|
|
1144
|
+
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
1145
|
+
getValidScale(changeScale) { return changeScale; }
|
|
1145
1146
|
__checkUpdateLayout() {
|
|
1146
1147
|
this.__layout.update();
|
|
1147
1148
|
}
|
|
@@ -1160,9 +1161,10 @@ let Leafer = class Leafer extends Group {
|
|
|
1160
1161
|
this.off_(this.__eventIds);
|
|
1161
1162
|
this.__eventIds.length = 0;
|
|
1162
1163
|
}
|
|
1163
|
-
destroy() {
|
|
1164
|
-
|
|
1164
|
+
destroy(sync) {
|
|
1165
|
+
const doDestory = () => {
|
|
1165
1166
|
if (!this.destroyed) {
|
|
1167
|
+
Leafer_1.list.remove(this);
|
|
1166
1168
|
try {
|
|
1167
1169
|
this.stop();
|
|
1168
1170
|
this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
|
|
@@ -1190,16 +1192,18 @@ let Leafer = class Leafer extends Group {
|
|
|
1190
1192
|
debug.error(e);
|
|
1191
1193
|
}
|
|
1192
1194
|
}
|
|
1193
|
-
}
|
|
1195
|
+
};
|
|
1196
|
+
sync ? doDestory() : setTimeout(doDestory);
|
|
1194
1197
|
}
|
|
1195
1198
|
};
|
|
1199
|
+
Leafer.list = new LeafList();
|
|
1196
1200
|
__decorate([
|
|
1197
1201
|
dataProcessor(LeaferData)
|
|
1198
1202
|
], Leafer.prototype, "__", void 0);
|
|
1199
1203
|
__decorate([
|
|
1200
1204
|
boundsType()
|
|
1201
1205
|
], Leafer.prototype, "pixelRatio", void 0);
|
|
1202
|
-
Leafer = __decorate([
|
|
1206
|
+
Leafer = Leafer_1 = __decorate([
|
|
1203
1207
|
registerUI()
|
|
1204
1208
|
], Leafer);
|
|
1205
1209
|
|
|
@@ -1232,11 +1236,9 @@ let Box = class Box extends Group {
|
|
|
1232
1236
|
__updateStrokeSpread() { return 0; }
|
|
1233
1237
|
__updateRectRenderSpread() { return 0; }
|
|
1234
1238
|
__updateRenderSpread() {
|
|
1235
|
-
|
|
1236
|
-
this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
1237
|
-
|
|
1238
|
-
width = this.__.__drawAfterFill ? 0 : 1;
|
|
1239
|
-
return width;
|
|
1239
|
+
const width = this.__updateRectRenderSpread();
|
|
1240
|
+
const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
|
|
1241
|
+
return (width || hide) ? width : -1;
|
|
1240
1242
|
}
|
|
1241
1243
|
__updateRectBoxBounds() { }
|
|
1242
1244
|
__updateBoxBounds() {
|
|
@@ -1430,7 +1432,7 @@ let Line = class Line extends UI {
|
|
|
1430
1432
|
__updatePath() {
|
|
1431
1433
|
const path = this.__.path = [];
|
|
1432
1434
|
if (this.__.points) {
|
|
1433
|
-
drawPoints$1(path, this.__.points,
|
|
1435
|
+
drawPoints$1(path, this.__.points, this.__.closed);
|
|
1434
1436
|
}
|
|
1435
1437
|
else {
|
|
1436
1438
|
moveTo$2(path, 0, 0);
|
|
@@ -1440,7 +1442,7 @@ let Line = class Line extends UI {
|
|
|
1440
1442
|
__updateRenderPath() {
|
|
1441
1443
|
const data = this.__;
|
|
1442
1444
|
if (!this.pathInputed && data.points && data.curve) {
|
|
1443
|
-
drawPoints$1(data.__pathForRender = [], data.points, data.curve,
|
|
1445
|
+
drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
|
|
1444
1446
|
if (data.__useArrow)
|
|
1445
1447
|
PathArrow.addArrows(this, false);
|
|
1446
1448
|
}
|
|
@@ -1472,6 +1474,9 @@ __decorate([
|
|
|
1472
1474
|
__decorate([
|
|
1473
1475
|
pathType(0)
|
|
1474
1476
|
], Line.prototype, "curve", void 0);
|
|
1477
|
+
__decorate([
|
|
1478
|
+
pathType(false)
|
|
1479
|
+
], Line.prototype, "closed", void 0);
|
|
1475
1480
|
Line = __decorate([
|
|
1476
1481
|
registerUI()
|
|
1477
1482
|
], Line);
|
|
@@ -1483,7 +1488,6 @@ let Polygon = class Polygon extends UI {
|
|
|
1483
1488
|
get __tag() { return 'Polygon'; }
|
|
1484
1489
|
constructor(data) {
|
|
1485
1490
|
super(data);
|
|
1486
|
-
this.pathClosed = true;
|
|
1487
1491
|
}
|
|
1488
1492
|
__updatePath() {
|
|
1489
1493
|
const path = this.__.path = [];
|
|
@@ -1653,6 +1657,9 @@ __decorate([
|
|
|
1653
1657
|
__decorate([
|
|
1654
1658
|
resizeType(true)
|
|
1655
1659
|
], Canvas.prototype, "smooth", void 0);
|
|
1660
|
+
__decorate([
|
|
1661
|
+
resizeType()
|
|
1662
|
+
], Canvas.prototype, "contextSettings", void 0);
|
|
1656
1663
|
__decorate([
|
|
1657
1664
|
hitType('all')
|
|
1658
1665
|
], Canvas.prototype, "hitFill", void 0);
|
|
@@ -1729,6 +1736,8 @@ let Text = class Text extends UI {
|
|
|
1729
1736
|
else {
|
|
1730
1737
|
super.__updateBoxBounds();
|
|
1731
1738
|
}
|
|
1739
|
+
if (italic)
|
|
1740
|
+
b.width += fontSize * 0.16;
|
|
1732
1741
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
1733
1742
|
if (contentBounds !== layout.contentBounds) {
|
|
1734
1743
|
layout.contentBounds = contentBounds;
|
|
@@ -1866,6 +1875,7 @@ let Pen = class Pen extends Group {
|
|
|
1866
1875
|
drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
1867
1876
|
drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
|
|
1868
1877
|
drawPoints(_points, _curve, _close) { return this; }
|
|
1878
|
+
clearPath() { return this; }
|
|
1869
1879
|
paint() {
|
|
1870
1880
|
this.pathElement.forceUpdate('path');
|
|
1871
1881
|
}
|
|
@@ -1877,7 +1887,7 @@ __decorate([
|
|
|
1877
1887
|
penPathType()
|
|
1878
1888
|
], Pen.prototype, "path", void 0);
|
|
1879
1889
|
Pen = __decorate([
|
|
1880
|
-
useModule(PathCreator, ['beginPath', 'path']),
|
|
1890
|
+
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
1881
1891
|
registerUI()
|
|
1882
1892
|
], Pen);
|
|
1883
1893
|
function penPathType() {
|
|
@@ -1888,4 +1898,6 @@ function penPathType() {
|
|
|
1888
1898
|
};
|
|
1889
1899
|
}
|
|
1890
1900
|
|
|
1891
|
-
|
|
1901
|
+
const version = "1.0.0-rc.21";
|
|
1902
|
+
|
|
1903
|
+
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{defineLeafAttr as t,doStrokeType as e,defineKey as i,Debug as s,LeafData as o,PathConvert as r,OneRadian as a,dataProcessor as _,dataType as n,surfaceType as h,opacityType as d,sortType as p,maskType as l,eraserType as u,positionType as c,boundsType as y,scaleType as v,rotationType as g,autoLayoutType as f,hitType as w,strokeType as x,cursorType as m,naturalBoundsType as R,pathInputType as S,pathType as k,rewrite as b,Leaf as B,useModule as A,rewriteAble as C,pen as P,PathCorner as F,PathDrawer as D,UICreator as E,registerUI as L,Branch as T,ImageManager as W,DataHelper as I,Creator as M,CanvasManager as z,LeaferEvent as O,canvasSizeAttrs as N,Bounds as H,ResizeEvent as V,AutoBounds as Y,WaitHelper as X,Run as U,LayoutEvent as j,RenderEvent as G,WatchEvent as J,affectRenderBoundsType as $,BoundsHelper as K,Platform as q,PathCommandDataHelper as Q,affectStrokeBoundsType as Z,getPointData as tt,PointHelper as et,PathBounds as it,ImageEvent as st,Matrix as ot,MathHelper as rt,PathCreator as at}from"@leafer/core";export*from"@leafer/core";function _t(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 nt={},ht={},dt={},pt={},lt={},ut={},ct={},yt={},vt={};function gt(e){return(i,s)=>{const o=s+"Style";t(i,s,e,{set(t){this.__setAttr(s,t),this.waitLeafer((()=>{vt.setStyle&&vt.setStyle(this,o,t)}))}})}}function ft(i){return(s,o)=>{t(s,o,i,{set(t){this.__setAttr(o,t);const i=this.__;i.__useArrow="none"!==i.startArrow||"none"!==i.endArrow,e(this)}})}}function wt(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function xt(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}function mt(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:Rt}=r,St={},kt=s.get("UIData");class bt extends o{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__nowWorld;return e<0&&(e=-e),e>1?t/e: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,kt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,kt.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=St)):(this.__isFills&&(this.__removeInput("fill"),lt.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=St)):(this.__isStrokes&&(this.__removeInput("stroke"),lt.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=Rt(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&&pt.compute("fill",this.__leaf),e&&pt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Bt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class At extends bt{}class Ct extends At{get __boxStroke(){return!0}}class Pt extends At{}class Ft extends Ct{}class Dt extends bt{}class Et extends bt{get __boxStroke(){return!0}}class Lt extends bt{get __boxStroke(){return!0}}class Tt extends bt{}class Wt extends bt{}class It extends bt{}class Mt extends At{}const zt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ot extends bt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=zt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Nt extends Et{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 Ht extends Et{}const Vt={__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*a/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}},Yt={__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){Xt(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=pt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:n}=i;_&&ct.shadow(this,t,a),s&&(i.__isFills?pt.fills(s,this,t):pt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),n&&ct.innerShadow(this,t,a),o&&(i.__isStrokes?pt.strokes(o,this,t):pt.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?pt.fills(s,this,t):pt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?pt.strokes(o,this,t):pt.stroke(o,this,t))}else i.__pathInputed?Xt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:s}=this.__;this.__drawRenderPath(t),i&&(this.__.__pixelFill?pt.fills(i,this,t):pt.fill("#000000",this,t)),s&&(this.__.__pixelStroke?pt.strokes(s,this,t):pt.stroke("#000000",this,t))}}};function Xt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&pt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&pt.stroke(o,t,e)}const Ut={__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 Gt=jt=class extends B{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 P.set(this.path=this.__.path||[]),P}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)&&(P.set(i=[]),this.__drawPathByBox(P))}return t?r.toCanvasData(i,!0):i}getPathString(t,e){return r.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&dt.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;this.__.cornerRadius?t.roundRect(e,i,s,o,this.__.cornerRadius):t.rect(e,i,s,o)}export(t,e){return yt.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(){L()(this)}static registerData(t){_(t)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}};_t([_(bt)],Gt.prototype,"__",void 0),_t([mt()],Gt.prototype,"zoomLayer",void 0),_t([n("")],Gt.prototype,"id",void 0),_t([n("")],Gt.prototype,"name",void 0),_t([n("")],Gt.prototype,"className",void 0),_t([h("pass-through")],Gt.prototype,"blendMode",void 0),_t([d(1)],Gt.prototype,"opacity",void 0),_t([d(!0)],Gt.prototype,"visible",void 0),_t([gt(!1)],Gt.prototype,"selected",void 0),_t([gt(!1)],Gt.prototype,"disabled",void 0),_t([n(!1)],Gt.prototype,"locked",void 0),_t([p(0)],Gt.prototype,"zIndex",void 0),_t([l(!1)],Gt.prototype,"mask",void 0),_t([h("pixel")],Gt.prototype,"maskType",void 0),_t([u(!1)],Gt.prototype,"eraser",void 0),_t([c(0)],Gt.prototype,"x",void 0),_t([c(0)],Gt.prototype,"y",void 0),_t([y(100)],Gt.prototype,"width",void 0),_t([y(100)],Gt.prototype,"height",void 0),_t([v(1)],Gt.prototype,"scaleX",void 0),_t([v(1)],Gt.prototype,"scaleY",void 0),_t([g(0)],Gt.prototype,"rotation",void 0),_t([g(0)],Gt.prototype,"skewX",void 0),_t([g(0)],Gt.prototype,"skewY",void 0),_t([f()],Gt.prototype,"around",void 0),_t([n(!1)],Gt.prototype,"draggable",void 0),_t([n(!1)],Gt.prototype,"editable",void 0),_t([n("size")],Gt.prototype,"editSize",void 0),_t([w(!0)],Gt.prototype,"hittable",void 0),_t([w("path")],Gt.prototype,"hitFill",void 0),_t([x("path")],Gt.prototype,"hitStroke",void 0),_t([w(!1)],Gt.prototype,"hitBox",void 0),_t([w(!0)],Gt.prototype,"hitChildren",void 0),_t([w(!0)],Gt.prototype,"hitSelf",void 0),_t([w()],Gt.prototype,"hitRadius",void 0),_t([m("")],Gt.prototype,"cursor",void 0),_t([h()],Gt.prototype,"fill",void 0),_t([x()],Gt.prototype,"stroke",void 0),_t([x("inside")],Gt.prototype,"strokeAlign",void 0),_t([x(1)],Gt.prototype,"strokeWidth",void 0),_t([x(!1)],Gt.prototype,"strokeWidthFixed",void 0),_t([x("none")],Gt.prototype,"strokeCap",void 0),_t([x("miter")],Gt.prototype,"strokeJoin",void 0),_t([x()],Gt.prototype,"dashPattern",void 0),_t([x()],Gt.prototype,"dashOffset",void 0),_t([x(10)],Gt.prototype,"miterLimit",void 0),_t([n(!1)],Gt.prototype,"lazy",void 0),_t([R(1)],Gt.prototype,"pixelRatio",void 0),_t([S()],Gt.prototype,"path",void 0),_t([k()],Gt.prototype,"windingRule",void 0),_t([ft("none")],Gt.prototype,"startArrow",void 0),_t([ft("none")],Gt.prototype,"endArrow",void 0),_t([k(0)],Gt.prototype,"cornerRadius",void 0),_t([k()],Gt.prototype,"cornerSmoothing",void 0),_t([wt()],Gt.prototype,"shadow",void 0),_t([wt()],Gt.prototype,"innerShadow",void 0),_t([wt()],Gt.prototype,"blur",void 0),_t([wt()],Gt.prototype,"backgroundBlur",void 0),_t([wt()],Gt.prototype,"grayscale",void 0),_t([n()],Gt.prototype,"normalStyle",void 0),_t([n()],Gt.prototype,"hoverStyle",void 0),_t([n()],Gt.prototype,"pressStyle",void 0),_t([n()],Gt.prototype,"focusStyle",void 0),_t([n()],Gt.prototype,"selectedStyle",void 0),_t([n()],Gt.prototype,"disabledStyle",void 0),_t([b(B.prototype.reset)],Gt.prototype,"reset",null),Gt=jt=_t([A(Vt),A(Yt),C()],Gt);let Jt=class extends Gt{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(){}};_t([_(At)],Jt.prototype,"__",void 0),Jt=_t([A(T),L()],Jt);const $t=s.get("Leafer");let Kt=class extends Jt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&W.isComplete}get layoutLocked(){return!this.layouter.running}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,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)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&I.assign(this.config,t);const{config:s}=this;this.initType(s.type),this.canvas=M.canvas(s),this.__controllers.push(this.renderer=M.renderer(this,this.canvas,s),this.watcher=M.watcher(this,s),this.layouter=M.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=this.canvas.view,e?(this.__bindApp(e),i=e.running):(this.selector=M.selector(this),this.interaction=M.interaction(this,this.canvas,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=M.hitCanvasManager()),this.canvasManager=new z,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(O.RESTART):this.emitLeafer(O.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(O.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=I.copyAttrs({},t,N);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.forceRender()}forceRender(t){this.renderer.addBlock(t?new H(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=I.copyAttrs({},this.canvas,N);this.canvas.resize(t),this.__onResize(new V(t,e))}__onResize(t){this.emitEvent(t),I.copyAttrs(this.__,t,N),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 Y(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(N.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&&N.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=I.copyAttrs({},this.canvas,N);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(O.BEFORE_READY),this.emitLeafer(O.READY),this.emitLeafer(O.AFTER_READY),X.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(O.VIEW_READY),X.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){X.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(O.VIEW_COMPLETED),X.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}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){}validScale(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s}=this.app.config.zoom,o=Math.abs(e*t);return o<i?t=i/e:o>s&&(t=s/e),t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new O(t,this))}__listenEvents(){const t=U.start("FirstCreate "+this.innerName);this.once(O.START,(()=>U.end(t))),this.once(j.END,(()=>this.__onReady())),this.once(G.START,(()=>this.__onCreated())),this.once(G.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(J.DATA,this.__onWatchData,this),this.on_(G.NEXT,this.__onNextRender,this),this.on_(j.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new O(O.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((()=>{W.clearRecycled()}),100)}catch(t){$t.error(t)}}))}};_t([_(Pt)],Kt.prototype,"__",void 0),_t([y()],Kt.prototype,"pixelRatio",void 0),Kt=_t([L()],Kt);let qt=class extends Gt{get __tag(){return"Rect"}constructor(t){super(t)}};_t([_(Et)],qt.prototype,"__",void 0),qt=_t([A(Ut),C(),L()],qt);const Qt=qt.prototype,Zt=Jt.prototype,te={},{copy:ee,add:ie}=K;let se=class extends Jt{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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__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;ee(te,t),super.__updateRenderBounds(),ie(t,te)}}__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)}};_t([_(Ct)],se.prototype,"__",void 0),_t([$("show")],se.prototype,"overflow",void 0),_t([b(Qt.__updateStrokeSpread)],se.prototype,"__updateStrokeSpread",null),_t([b(Qt.__updateRenderSpread)],se.prototype,"__updateRectRenderSpread",null),_t([b(Qt.__updateBoxBounds)],se.prototype,"__updateRectBoxBounds",null),_t([b(Qt.__updateStrokeBounds)],se.prototype,"__updateStrokeBounds",null),_t([b(Qt.__updateRenderBounds)],se.prototype,"__updateRectRenderBounds",null),_t([b(Qt.__updateChange)],se.prototype,"__updateRectChange",null),_t([b(Qt.__render)],se.prototype,"__renderRect",null),_t([b(Zt.__render)],se.prototype,"__renderGroup",null),se=_t([C(),L()],se);let oe=class extends se{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};_t([_(Ft)],oe.prototype,"__",void 0),_t([h("#FFFFFF")],oe.prototype,"fill",void 0),_t([$("hide")],oe.prototype,"overflow",void 0),oe=_t([L()],oe);const{moveTo:re,closePath:ae,ellipse:_e}=Q;let ne=class extends Gt{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&&_e(_,r,a,r*i,a*i,0,s,o,!1),_e(_,r,a,r,a,0,o,s,!0),i<1&&ae(_)):(i<1&&(_e(_,r,a,r*i,a*i),re(_,t,a)),_e(_,r,a,r,a,0,360,0,!0)),q.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(re(_,r,a),_e(_,r,a,r,a,0,s,o,!1),ae(_)):_e(_,r,a,r,a)}};_t([_(Lt)],ne.prototype,"__",void 0),_t([k(0)],ne.prototype,"innerRadius",void 0),_t([k(0)],ne.prototype,"startAngle",void 0),_t([k(0)],ne.prototype,"endAngle",void 0),ne=_t([L()],ne);const{moveTo:he,lineTo:de,drawPoints:pe}=Q,{rotate:le,getAngle:ue,getDistance:ce,defaultPoint:ye}=et,{toBounds:ve}=it;let ge=class extends Gt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=tt();return t&&(i.x=t),e&&le(i,e),i}set toPoint(t){this.width=ce(ye,t),this.rotation=ue(ye,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?pe(t,this.__.points,!1):(he(t,0,0),de(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(pe(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&dt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?ve(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};_t([_(Dt)],ge.prototype,"__",void 0),_t([Z("center")],ge.prototype,"strokeAlign",void 0),_t([y(0)],ge.prototype,"height",void 0),_t([k()],ge.prototype,"points",void 0),_t([k(0)],ge.prototype,"curve",void 0),ge=_t([L()],ge);const{sin:fe,cos:we,PI:xe}=Math,{moveTo:me,lineTo:Re,closePath:Se,drawPoints:ke}=Q,be=ge.prototype;let Be=class extends Gt{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)ke(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;me(t,o,0);for(let e=1;e<s;e++)Re(t,o+o*fe(2*e*xe/s),r-r*we(2*e*xe/s))}Se(t)}__updateRenderPath(){}__updateBoxBounds(){}};_t([_(Tt)],Be.prototype,"__",void 0),_t([k(3)],Be.prototype,"sides",void 0),_t([k()],Be.prototype,"points",void 0),_t([k(0)],Be.prototype,"curve",void 0),_t([b(be.__updateRenderPath)],Be.prototype,"__updateRenderPath",null),_t([b(be.__updateBoxBounds)],Be.prototype,"__updateBoxBounds",null),Be=_t([C(),L()],Be);const{sin:Ae,cos:Ce,PI:Pe}=Math,{moveTo:Fe,lineTo:De,closePath:Ee}=Q;let Le=class extends Gt{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=[];Fe(a,o,0);for(let t=1;t<2*i;t++)De(a,o+(t%2==0?o:o*s)*Ae(t*Pe/i),r-(t%2==0?r:r*s)*Ce(t*Pe/i));Ee(a)}};_t([_(Wt)],Le.prototype,"__",void 0),_t([k(5)],Le.prototype,"corners",void 0),_t([k(.382)],Le.prototype,"innerRadius",void 0),Le=_t([L()],Le);let Te=class extends qt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(st.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};_t([_(Nt)],Te.prototype,"__",void 0),_t([y("")],Te.prototype,"url",void 0),Te=_t([L()],Te);let We=class extends qt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=M.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new ot(t.__world).invert(),r=new ot;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()}};_t([_(Ht)],We.prototype,"__",void 0),_t([xt(100)],We.prototype,"width",void 0),_t([xt(100)],We.prototype,"height",void 0),_t([xt(q.devicePixelRatio)],We.prototype,"pixelRatio",void 0),_t([xt(!0)],We.prototype,"smooth",void 0),_t([w("all")],We.prototype,"hitFill",void 0),We=_t([L()],We);const{copyAndSpread:Ie,includes:Me,spread:ze,setList:Oe}=K;let Ne=class extends Gt{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=nt.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=Bt.number(i,r),t.__letterSpacing=Bt.number(s,r),t.__padding=d?rt.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&&ze(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();const y=Me(c,u)?c:u;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Oe(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(){Ie(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};_t([_(Ot)],Ne.prototype,"__",void 0),_t([y(0)],Ne.prototype,"width",void 0),_t([y(0)],Ne.prototype,"height",void 0),_t([y(0)],Ne.prototype,"padding",void 0),_t([h("#000000")],Ne.prototype,"fill",void 0),_t([Z("outside")],Ne.prototype,"strokeAlign",void 0),_t([w("all")],Ne.prototype,"hitFill",void 0),_t([y("")],Ne.prototype,"text",void 0),_t([y("L")],Ne.prototype,"fontFamily",void 0),_t([y(12)],Ne.prototype,"fontSize",void 0),_t([y("normal")],Ne.prototype,"fontWeight",void 0),_t([y(!1)],Ne.prototype,"italic",void 0),_t([y("none")],Ne.prototype,"textCase",void 0),_t([y("none")],Ne.prototype,"textDecoration",void 0),_t([y(0)],Ne.prototype,"letterSpacing",void 0),_t([y({type:"percent",value:150})],Ne.prototype,"lineHeight",void 0),_t([y(0)],Ne.prototype,"paraIndent",void 0),_t([y(0)],Ne.prototype,"paraSpacing",void 0),_t([y("left")],Ne.prototype,"textAlign",void 0),_t([y("top")],Ne.prototype,"verticalAlign",void 0),_t([y("normal")],Ne.prototype,"textWrap",void 0),_t([y("show")],Ne.prototype,"textOverflow",void 0),Ne=_t([L()],Ne);let He=class extends Gt{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};_t([_(It)],He.prototype,"__",void 0),_t([Z("center")],He.prototype,"strokeAlign",void 0),He=_t([L()],He);let Ve=class extends Jt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new He(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}paint(){this.pathElement.forceUpdate("path")}};_t([_(Mt)],Ve.prototype,"__",void 0),_t([(t,e)=>{i(t,e,{get(){return this.__path}})}],Ve.prototype,"path",void 0),Ve=_t([A(at,["beginPath","path"]),L()],Ve);export{se as Box,Ct as BoxData,We as Canvas,Ht as CanvasData,ht as ColorConvert,ct as Effect,ne as Ellipse,Lt as EllipseData,yt as Export,oe as Frame,Ft as FrameData,Jt as Group,At as GroupData,Te as Image,Nt as ImageData,Kt as Leafer,Pt as LeaferData,ge as Line,Dt as LineData,pt as Paint,ut as PaintGradient,lt as PaintImage,He as Path,dt as PathArrow,It as PathData,Ve as Pen,Mt as PenData,Be as Polygon,Tt as PolygonData,qt as Rect,Et as RectData,Ut as RectRender,Le as Star,Wt as StarData,vt as State,Ne as Text,nt as TextConvert,Ot as TextData,Gt as UI,Vt as UIBounds,bt as UIData,Yt as UIRender,Bt as UnitConvert,ft as arrowType,wt as effectType,xt as resizeType,gt as stateType,mt 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 _,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};
|
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(s,r)=>{const o=r+"Style";t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,o,t)}))}})}}function _(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(e){this.__setAttr(r,e);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow,t.doStrokeType(this)}})}}function d(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function l(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,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){let{scaleX:e}=this.__leaf.__nowWorld;return e<0&&(e=-e),e>1?t/e: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 m extends f{}class T extends w{}class I extends v{}class R extends v{get __boxStroke(){return!0}}class P extends v{get __boxStroke(){return!0}}class b extends v{}class S extends v{}class k extends v{}class B 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){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?o.fills(s,this,t):o.fill("#000000",this,t)),r&&(this.__.__pixelStroke?o.strokes(r,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 M;exports.UI=M=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.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;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 M.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)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(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.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([_("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=M=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 z=t.Debug.get("Leafer");exports.Leafer=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 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,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)}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),this.canvas=t.Creator.canvas(o),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,this.canvas,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(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{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())}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),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,s){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()))}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){}validScale(t){const{scaleX:e}=this.zoomLayer.__,{min:s,max:r}=this.app.config.zoom,o=Math.abs(e*t);return o<s?t=s/e:o>r&&(t=r/e),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(){setTimeout((()=>{if(!this.destroyed)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){z.error(t)}}))}},e([t.dataProcessor(m)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=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 H=exports.Rect.prototype,O=exports.Group.prototype,N={},{copy:G,add:V}=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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__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;G(N,t),super.__updateRenderBounds(),V(t,N)}}__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(H.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(H.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(H.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(H.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(H.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(H.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(H.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(O.__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(T)],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:Y,ellipse:X}=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&&X(p,a,n,a*r,n*r,0,o,i,!1),X(p,a,n,a,n,0,i,o,!0),r<1&&Y(p)):(r<1&&(X(p,a,n,a*r,n*r),j(p,e,n)),X(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(j(p,a,n),X(p,a,n,a,n,0,o,i,!1),Y(p)):X(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:J,lineTo:K,drawPoints:$}=t.PathCommandDataHelper,{rotate:q,getAngle:Q,getDistance:Z,defaultPoint:tt}=t.PointHelper,{toBounds:et}=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=Z(tt,t),this.rotation=Q(tt,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?$(t,this.__.points,!1):(J(t,0,0),K(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?($(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&r.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?et(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),exports.Line=e([t.registerUI()],exports.Line);const{sin:st,cos:rt,PI:ot}=Math,{moveTo:it,lineTo:at,closePath:nt,drawPoints:pt}=t.PathCommandDataHelper,ht=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)pt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;it(t,o,0);for(let e=1;e<r;e++)at(t,o+o*st(2*e*ot/r),i-i*rt(2*e*ot/r))}nt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(b)],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(ht.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(ht.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:_t,cos:dt,PI:lt}=Math,{moveTo:ut,lineTo:ct,closePath:yt}=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=[];ut(a,o,0);for(let t=1;t<2*s;t++)ct(a,o+(t%2==0?o:o*r)*_t(t*lt/s),i-(t%2==0?i:i*r)*dt(t*lt/s));yt(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,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([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:xt,includes:vt,spread:gt,setList:ft}=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&>(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();const x=vt(y,c)?y:c;x!==s.contentBounds?(s.contentBounds=x,s.renderChanged=!0,ft(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(){xt(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(k)],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}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(B)],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,["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=T,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=m,exports.LineData=I,exports.Paint=o,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=r,exports.PathData=k,exports.PenData=B,exports.PolygonData=b,exports.RectData=R,exports.RectRender=W,exports.StarData=S,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.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,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]}})}));
|
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.21",
|
|
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.21",
|
|
33
|
+
"@leafer-ui/display": "1.0.0-rc.21",
|
|
34
|
+
"@leafer-ui/display-module": "1.0.0-rc.21",
|
|
35
|
+
"@leafer-ui/decorator": "1.0.0-rc.21",
|
|
36
|
+
"@leafer-ui/external": "1.0.0-rc.21"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/index.ts
CHANGED