@leafer-ui/core 1.0.0-rc.6 → 1.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCorner, UICreator, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, PathBounds, affectStrokeBoundsType, PointHelper, ImageEvent, Creator, Matrix, PathCreator, DataHelper, CanvasManager, HitCanvasManager, PluginManager, LeaferEvent, canvasSizeAttrs, ResizeEvent, AutoBounds, WaitHelper, ImageManager, Run, LayoutEvent, RenderEvent, WatchEvent, PropertyEvent } from '@leafer/core';
1
+ import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCorner, UICreator, MatrixHelper, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, affectStrokeBoundsType, PathScaler, PointHelper, PathBounds, ImageEvent, Creator, Matrix, MathHelper, PathCreator, DataHelper, CanvasManager, HitCanvasManager, PluginManager, LeaferEvent, canvasSizeAttrs, ResizeEvent, AutoBounds, WaitHelper, ImageManager, Run, LayoutEvent, RenderEvent, WatchEvent, PropertyEvent } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -39,7 +39,7 @@ function design(leafer) {
39
39
  if (leafer.isApp)
40
40
  return;
41
41
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
42
- const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
42
+ const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
43
43
  let { scale } = e;
44
44
  if (scale * Math.abs(scaleX) < min)
45
45
  scale = min / scaleX;
@@ -86,6 +86,9 @@ const Export = {};
86
86
  const emptyPaint = {};
87
87
  const debug$1 = Debug.get('UIData');
88
88
  class UIData extends LeafData {
89
+ get __autoWidth() { return !this._width; }
90
+ get __autoHeight() { return !this._height; }
91
+ get __autoBounds() { return !this._width && !this._height; }
89
92
  setVisible(value) {
90
93
  if (this.__leaf.leafer)
91
94
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -262,6 +265,9 @@ class TextData extends UIData {
262
265
  class ImageData extends RectData {
263
266
  }
264
267
 
268
+ class CanvasData extends RectData {
269
+ }
270
+
265
271
  function effectType(defaultValue) {
266
272
  return (target, key) => {
267
273
  defineLeafAttr(target, key, defaultValue, {
@@ -472,6 +478,7 @@ const RectRender = {
472
478
 
473
479
  var UI_1;
474
480
  let UI = UI_1 = class UI extends Leaf {
481
+ get app() { return this.leafer && this.leafer.app; }
475
482
  set scale(value) {
476
483
  if (typeof value === 'number') {
477
484
  this.scaleX = this.scaleY = value;
@@ -485,22 +492,25 @@ let UI = UI_1 = class UI extends Leaf {
485
492
  const { scaleX, scaleY } = this;
486
493
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
487
494
  }
495
+ constructor(data) {
496
+ super(data);
497
+ }
488
498
  reset(_data) { }
489
499
  set(data) {
490
500
  Object.assign(this, data);
491
501
  }
492
- get(options) {
493
- return this.__.__getInputData(options);
502
+ get() {
503
+ return this.__.__getInputData();
494
504
  }
495
- getProxyData() { return undefined; }
496
- find(condition) {
497
- return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
505
+ createProxyData() { return undefined; }
506
+ find(condition, options) {
507
+ return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
498
508
  }
499
- findOne(condition) {
500
- return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
509
+ findOne(condition, options) {
510
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
501
511
  }
502
512
  getPath(curve) {
503
- const path = this.__.path;
513
+ const { path } = this.__;
504
514
  if (!path)
505
515
  return [];
506
516
  return curve ? PathConvert.toCanvasData(path, true) : path;
@@ -532,6 +542,15 @@ let UI = UI_1 = class UI extends Leaf {
532
542
  this.__drawPathByData(canvas, this.__.path);
533
543
  }
534
544
  __drawPathByData(_drawer, _data) { }
545
+ __drawPathByBox(drawer) {
546
+ const { x, y, width, height } = this.__layout.boxBounds;
547
+ if (this.__.cornerRadius) {
548
+ drawer.roundRect(x, y, width, height, this.__.cornerRadius);
549
+ }
550
+ else {
551
+ drawer.rect(x, y, width, height);
552
+ }
553
+ }
535
554
  export(filename, options) {
536
555
  return Export.export(this, filename, options);
537
556
  }
@@ -573,12 +592,12 @@ __decorate([
573
592
  __decorate([
574
593
  eraserType(false)
575
594
  ], UI.prototype, "isEraser", void 0);
595
+ __decorate([
596
+ dataType(false)
597
+ ], UI.prototype, "locked", void 0);
576
598
  __decorate([
577
599
  sortType(0)
578
600
  ], UI.prototype, "zIndex", void 0);
579
- __decorate([
580
- dataType()
581
- ], UI.prototype, "locked", void 0);
582
601
  __decorate([
583
602
  positionType(0)
584
603
  ], UI.prototype, "x", void 0);
@@ -607,11 +626,17 @@ __decorate([
607
626
  rotationType(0)
608
627
  ], UI.prototype, "skewY", void 0);
609
628
  __decorate([
610
- positionType()
629
+ autoLayoutType()
611
630
  ], UI.prototype, "around", void 0);
612
631
  __decorate([
613
632
  dataType(false)
614
633
  ], UI.prototype, "draggable", void 0);
634
+ __decorate([
635
+ dataType(false)
636
+ ], UI.prototype, "editable", void 0);
637
+ __decorate([
638
+ dataType('size')
639
+ ], UI.prototype, "editSize", void 0);
615
640
  __decorate([
616
641
  hitType(true)
617
642
  ], UI.prototype, "hittable", void 0);
@@ -664,7 +689,7 @@ __decorate([
664
689
  strokeType(10)
665
690
  ], UI.prototype, "miterLimit", void 0);
666
691
  __decorate([
667
- pathType()
692
+ pathType(0)
668
693
  ], UI.prototype, "cornerRadius", void 0);
669
694
  __decorate([
670
695
  pathType()
@@ -697,9 +722,9 @@ UI = UI_1 = __decorate([
697
722
  rewriteAble()
698
723
  ], UI);
699
724
 
725
+ const matrix = MatrixHelper.get();
700
726
  let Group = class Group extends UI {
701
727
  get __tag() { return 'Group'; }
702
- get resizeable() { return false; }
703
728
  set mask(child) {
704
729
  if (this.__hasMask)
705
730
  this.__removeMask();
@@ -747,6 +772,14 @@ let Group = class Group extends UI {
747
772
  data.children = this.children.map(child => child.toJSON());
748
773
  return data;
749
774
  }
775
+ __scaleResize(scaleX, scaleY) {
776
+ const { children } = this;
777
+ for (let i = 0; i < children.length; i++) {
778
+ matrix.a = scaleX;
779
+ matrix.d = scaleY;
780
+ children[i].transform(matrix, true);
781
+ }
782
+ }
750
783
  addAt(child, index) {
751
784
  this.add(child, index);
752
785
  }
@@ -774,21 +807,17 @@ let Rect = class Rect extends UI {
774
807
  constructor(data) {
775
808
  super(data);
776
809
  }
777
- __drawPathByData(drawer, _data) {
778
- const { width, height, cornerRadius } = this.__;
779
- if (cornerRadius) {
780
- drawer.roundRect(0, 0, width, height, cornerRadius);
781
- }
782
- else {
783
- drawer.rect(0, 0, width, height);
784
- }
785
- }
810
+ __drawPathByData(_drawer, _data) { }
786
811
  };
787
812
  __decorate([
788
813
  dataProcessor(RectData)
789
814
  ], Rect.prototype, "__", void 0);
815
+ __decorate([
816
+ rewrite(UI.prototype.__drawPathByBox)
817
+ ], Rect.prototype, "__drawPathByData", null);
790
818
  Rect = __decorate([
791
819
  useModule(RectRender),
820
+ rewriteAble(),
792
821
  registerUI()
793
822
  ], Rect);
794
823
 
@@ -798,12 +827,20 @@ const bounds = {};
798
827
  const { copy, add } = BoundsHelper;
799
828
  let Box = class Box extends Group {
800
829
  get __tag() { return 'Box'; }
801
- get resizeable() { return true; }
802
830
  constructor(data) {
803
831
  super(data);
804
832
  this.isBranchLeaf = true;
805
833
  this.__layout.renderChanged || this.__layout.renderChange();
806
834
  }
835
+ __scaleResize(scaleX, scaleY) {
836
+ if (this.__.__autoBounds && this.children.length) {
837
+ super.__scaleResize(scaleX, scaleY);
838
+ }
839
+ else {
840
+ this.width *= scaleX;
841
+ this.height *= scaleY;
842
+ }
843
+ }
807
844
  __updateStrokeSpread() { return 0; }
808
845
  __updateRectRenderSpread() { return 0; }
809
846
  __updateRenderSpread() {
@@ -813,7 +850,15 @@ let Box = class Box extends Group {
813
850
  width = this.__.__drawAfterFill ? 0 : 1;
814
851
  return width;
815
852
  }
816
- __updateBoxBounds() { }
853
+ __updateRectBoxBounds() { }
854
+ __updateBoxBounds() {
855
+ if (this.__.__autoBounds && this.children.length) {
856
+ super.__updateBoxBounds();
857
+ }
858
+ else {
859
+ this.__updateRectBoxBounds();
860
+ }
861
+ }
817
862
  __updateStrokeBounds() { }
818
863
  __updateRenderBounds() {
819
864
  this.__updateRectRenderBounds();
@@ -865,7 +910,7 @@ __decorate([
865
910
  ], Box.prototype, "__updateRectRenderSpread", null);
866
911
  __decorate([
867
912
  rewrite(rect.__updateBoxBounds)
868
- ], Box.prototype, "__updateBoxBounds", null);
913
+ ], Box.prototype, "__updateRectBoxBounds", null);
869
914
  __decorate([
870
915
  rewrite(rect.__updateStrokeBounds)
871
916
  ], Box.prototype, "__updateStrokeBounds", null);
@@ -893,6 +938,7 @@ let Frame = class Frame extends Box {
893
938
  get __tag() { return 'Frame'; }
894
939
  constructor(data) {
895
940
  super(data);
941
+ this.isFrame = true;
896
942
  if (!this.__.fill)
897
943
  this.__.fill = '#FFFFFF';
898
944
  }
@@ -933,7 +979,7 @@ let Ellipse = class Ellipse extends UI {
933
979
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
934
980
  }
935
981
  if (Platform.ellipseToCurve)
936
- this.__.path = PathConvert.toCanvasData(path, true);
982
+ this.__.path = this.getPath(true);
937
983
  }
938
984
  else {
939
985
  if (startAngle || endAngle) {
@@ -963,47 +1009,118 @@ Ellipse = __decorate([
963
1009
  registerUI()
964
1010
  ], Ellipse);
965
1011
 
966
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
967
- const { moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1 } = PathCommandDataHelper;
968
- const { toBounds: toBounds$2 } = PathBounds;
969
- let Polygon = class Polygon extends UI {
970
- get __tag() { return 'Polygon'; }
971
- get resizeable() { return !this.points; }
1012
+ const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
1013
+ const { rotate, getAngle, getDistance, defaultPoint } = PointHelper;
1014
+ const { toBounds: toBounds$1 } = PathBounds;
1015
+ let Line = class Line extends UI {
1016
+ get __tag() { return 'Line'; }
1017
+ get toPoint() {
1018
+ const { width, rotation } = this.__;
1019
+ const to = { x: 0, y: 0 };
1020
+ if (width)
1021
+ to.x = width;
1022
+ if (rotation)
1023
+ rotate(to, rotation);
1024
+ return to;
1025
+ }
1026
+ set toPoint(value) {
1027
+ this.width = getDistance(defaultPoint, value);
1028
+ this.rotation = getAngle(defaultPoint, value);
1029
+ if (this.height)
1030
+ this.height = 0;
1031
+ }
972
1032
  constructor(data) {
973
1033
  super(data);
974
1034
  }
975
1035
  __updatePath() {
976
1036
  const path = this.__.path = [];
977
1037
  if (this.__.points) {
978
- drawPoints$1(path, this.__.points, false, true);
1038
+ drawPoints$1(path, this.__.points, false);
979
1039
  }
980
1040
  else {
981
- const { width, height, sides } = this.__;
982
- const rx = width / 2, ry = height / 2;
983
- moveTo$2(path, rx, 0);
984
- for (let i = 1; i < sides; i++) {
985
- lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
986
- }
1041
+ moveTo$2(path, 0, 0);
1042
+ lineTo$2(path, this.width, 0);
987
1043
  }
988
- closePath$1(path);
989
1044
  }
990
1045
  __updateRenderPath() {
991
1046
  if (this.__.points && this.__.curve) {
992
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
1047
+ drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
993
1048
  }
994
1049
  else {
995
1050
  super.__updateRenderPath();
996
1051
  }
997
1052
  }
998
1053
  __updateBoxBounds() {
999
- if (this.__.points) {
1000
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
1001
- this.__updateNaturalSize();
1054
+ if (this.points) {
1055
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
1002
1056
  }
1003
1057
  else {
1004
1058
  super.__updateBoxBounds();
1005
1059
  }
1006
1060
  }
1061
+ __scaleResize(scaleX, scaleY) {
1062
+ if (this.points) {
1063
+ PathScaler.scalePoints(this.__.points, scaleX, scaleY);
1064
+ this.points = this.__.points;
1065
+ }
1066
+ else {
1067
+ if (this.__tag === 'Line') {
1068
+ const point = this.toPoint;
1069
+ point.x *= scaleX;
1070
+ point.y *= scaleY;
1071
+ this.toPoint = point;
1072
+ }
1073
+ else {
1074
+ super.__scaleResize(scaleX, scaleY);
1075
+ }
1076
+ }
1077
+ }
1078
+ };
1079
+ __decorate([
1080
+ dataProcessor(LineData)
1081
+ ], Line.prototype, "__", void 0);
1082
+ __decorate([
1083
+ affectStrokeBoundsType('center')
1084
+ ], Line.prototype, "strokeAlign", void 0);
1085
+ __decorate([
1086
+ boundsType(0)
1087
+ ], Line.prototype, "height", void 0);
1088
+ __decorate([
1089
+ pathType()
1090
+ ], Line.prototype, "points", void 0);
1091
+ __decorate([
1092
+ pathType(0)
1093
+ ], Line.prototype, "curve", void 0);
1094
+ Line = __decorate([
1095
+ registerUI()
1096
+ ], Line);
1097
+
1098
+ const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
1099
+ const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = PathCommandDataHelper;
1100
+ const line = Line.prototype;
1101
+ let Polygon = class Polygon extends UI {
1102
+ get __tag() { return 'Polygon'; }
1103
+ constructor(data) {
1104
+ super(data);
1105
+ }
1106
+ __updatePath() {
1107
+ const path = this.__.path = [];
1108
+ if (this.__.points) {
1109
+ drawPoints(path, this.__.points, false, true);
1110
+ }
1111
+ else {
1112
+ const { width, height, sides } = this.__;
1113
+ const rx = width / 2, ry = height / 2;
1114
+ moveTo$1(path, rx, 0);
1115
+ for (let i = 1; i < sides; i++) {
1116
+ lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
1117
+ }
1118
+ }
1119
+ closePath$1(path);
1120
+ }
1121
+ __updateRenderPath() { }
1122
+ __updateBoxBounds() { }
1123
+ __scaleResize(_scaleX, _scaleY) { }
1007
1124
  };
1008
1125
  __decorate([
1009
1126
  dataProcessor(PolygonData)
@@ -1017,12 +1134,22 @@ __decorate([
1017
1134
  __decorate([
1018
1135
  pathType(0)
1019
1136
  ], Polygon.prototype, "curve", void 0);
1137
+ __decorate([
1138
+ rewrite(line.__updateRenderPath)
1139
+ ], Polygon.prototype, "__updateRenderPath", null);
1140
+ __decorate([
1141
+ rewrite(line.__updateBoxBounds)
1142
+ ], Polygon.prototype, "__updateBoxBounds", null);
1143
+ __decorate([
1144
+ rewrite(line.__scaleResize)
1145
+ ], Polygon.prototype, "__scaleResize", null);
1020
1146
  Polygon = __decorate([
1147
+ rewriteAble(),
1021
1148
  registerUI()
1022
1149
  ], Polygon);
1023
1150
 
1024
1151
  const { sin, cos, PI } = Math;
1025
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath } = PathCommandDataHelper;
1152
+ const { moveTo, lineTo, closePath } = PathCommandDataHelper;
1026
1153
  let Star = class Star extends UI {
1027
1154
  get __tag() { return 'Star'; }
1028
1155
  constructor(data) {
@@ -1032,9 +1159,9 @@ let Star = class Star extends UI {
1032
1159
  const { width, height, corners, innerRadius } = this.__;
1033
1160
  const rx = width / 2, ry = height / 2;
1034
1161
  const path = this.__.path = [];
1035
- moveTo$1(path, rx, 0);
1162
+ moveTo(path, rx, 0);
1036
1163
  for (let i = 1; i < corners * 2; i++) {
1037
- lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
1164
+ lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
1038
1165
  }
1039
1166
  closePath(path);
1040
1167
  }
@@ -1052,77 +1179,6 @@ Star = __decorate([
1052
1179
  registerUI()
1053
1180
  ], Star);
1054
1181
 
1055
- const { moveTo, lineTo, drawPoints } = PathCommandDataHelper;
1056
- const { rotate, getAngle, getDistance, defaultPoint } = PointHelper;
1057
- const { toBounds: toBounds$1 } = PathBounds;
1058
- let Line = class Line extends UI {
1059
- get __tag() { return 'Line'; }
1060
- get resizeable() { return !this.points; }
1061
- get toPoint() {
1062
- const { width, rotation } = this.__;
1063
- const to = { x: 0, y: 0 };
1064
- if (width)
1065
- to.x = width;
1066
- if (rotation)
1067
- rotate(to, rotation);
1068
- return to;
1069
- }
1070
- set toPoint(value) {
1071
- this.width = getDistance(defaultPoint, value);
1072
- this.rotation = getAngle(defaultPoint, value);
1073
- if (this.height)
1074
- this.height = 0;
1075
- }
1076
- constructor(data) {
1077
- super(data);
1078
- }
1079
- __updatePath() {
1080
- const path = this.__.path = [];
1081
- if (this.__.points) {
1082
- drawPoints(path, this.__.points, false);
1083
- }
1084
- else {
1085
- moveTo(path, 0, 0);
1086
- lineTo(path, this.width, 0);
1087
- }
1088
- }
1089
- __updateRenderPath() {
1090
- if (this.__.points && this.__.curve) {
1091
- drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
1092
- }
1093
- else {
1094
- super.__updateRenderPath();
1095
- }
1096
- }
1097
- __updateBoxBounds() {
1098
- if (this.points) {
1099
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
1100
- this.__updateNaturalSize();
1101
- }
1102
- else {
1103
- super.__updateBoxBounds();
1104
- }
1105
- }
1106
- };
1107
- __decorate([
1108
- dataProcessor(LineData)
1109
- ], Line.prototype, "__", void 0);
1110
- __decorate([
1111
- affectStrokeBoundsType('center')
1112
- ], Line.prototype, "strokeAlign", void 0);
1113
- __decorate([
1114
- boundsType(0)
1115
- ], Line.prototype, "height", void 0);
1116
- __decorate([
1117
- pathType()
1118
- ], Line.prototype, "points", void 0);
1119
- __decorate([
1120
- pathType(0)
1121
- ], Line.prototype, "curve", void 0);
1122
- Line = __decorate([
1123
- registerUI()
1124
- ], Line);
1125
-
1126
1182
  let Image = class Image extends Rect {
1127
1183
  get __tag() { return 'Image'; }
1128
1184
  get ready() { return this.image ? this.image.ready : false; }
@@ -1173,7 +1229,7 @@ let Canvas = class Canvas extends Rect {
1173
1229
  this.__.__drawAfterFill = true;
1174
1230
  }
1175
1231
  draw(ui, offset, scale, rotation) {
1176
- ui.__layout.checkUpdate();
1232
+ ui.__layout.update();
1177
1233
  const matrix = new Matrix(ui.__world);
1178
1234
  matrix.invert();
1179
1235
  const m = new Matrix();
@@ -1183,7 +1239,7 @@ let Canvas = class Canvas extends Rect {
1183
1239
  typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
1184
1240
  if (rotation)
1185
1241
  m.rotate(rotation);
1186
- matrix.preMultiply(m);
1242
+ matrix.multiplyParent(m);
1187
1243
  ui.__render(this.canvas, { matrix });
1188
1244
  this.paint();
1189
1245
  }
@@ -1243,11 +1299,11 @@ Canvas = __decorate([
1243
1299
  registerUI()
1244
1300
  ], Canvas);
1245
1301
 
1246
- const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
1302
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
1247
1303
  let Text = class Text extends UI {
1248
1304
  get __tag() { return 'Text'; }
1249
1305
  get textDrawData() {
1250
- this.__layout.checkUpdate();
1306
+ this.__layout.update();
1251
1307
  return this.__.__textDrawData;
1252
1308
  }
1253
1309
  constructor(data) {
@@ -1278,33 +1334,45 @@ let Text = class Text extends UI {
1278
1334
  const data = this.__;
1279
1335
  const layout = this.__layout;
1280
1336
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
1281
- const width = data.__getInput('width');
1282
- const height = data.__getInput('height');
1337
+ const autoWidth = data.__autoWidth;
1338
+ const autoHeight = data.__autoHeight;
1283
1339
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1284
1340
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1285
1341
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1286
1342
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1287
- data.__clipText = textOverflow !== 'show' && (width || height);
1343
+ data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
1288
1344
  this.__updateTextDrawData();
1289
1345
  const { bounds } = data.__textDrawData;
1290
1346
  const b = layout.boxBounds;
1291
1347
  if (data.__lineHeight < fontSize)
1292
1348
  spread(bounds, fontSize / 2);
1293
- if (width && height) {
1294
- super.__updateBoxBounds();
1349
+ if (autoWidth || autoHeight) {
1350
+ b.x = autoWidth ? bounds.x : 0;
1351
+ b.y = autoHeight ? bounds.y : 0;
1352
+ b.width = autoWidth ? bounds.width : data.width;
1353
+ b.height = autoHeight ? bounds.height : data.height;
1354
+ const { padding } = data;
1355
+ if (padding) {
1356
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
1357
+ if (autoWidth) {
1358
+ b.x -= left;
1359
+ b.width += (right + left);
1360
+ }
1361
+ if (autoHeight) {
1362
+ b.y -= top;
1363
+ b.height += (bottom + top);
1364
+ }
1365
+ }
1366
+ this.__updateNaturalSize();
1295
1367
  }
1296
1368
  else {
1297
- b.x = width ? 0 : bounds.x;
1298
- b.y = height ? 0 : bounds.y;
1299
- b.width = width ? width : bounds.width;
1300
- b.height = height ? height : bounds.height;
1301
- this.__updateNaturalSize();
1369
+ super.__updateBoxBounds();
1302
1370
  }
1303
1371
  const contentBounds = includes(b, bounds) ? b : bounds;
1304
1372
  if (contentBounds !== layout.contentBounds) {
1305
1373
  layout.contentBounds = contentBounds;
1306
1374
  layout.renderChanged = true;
1307
- setByList(data.__textBoxBounds = {}, [b, bounds]);
1375
+ setList(data.__textBoxBounds = {}, [b, bounds]);
1308
1376
  }
1309
1377
  else {
1310
1378
  data.__textBoxBounds = contentBounds;
@@ -1332,6 +1400,9 @@ __decorate([
1332
1400
  __decorate([
1333
1401
  boundsType(0)
1334
1402
  ], Text.prototype, "padding", void 0);
1403
+ __decorate([
1404
+ surfaceType('#000000')
1405
+ ], Text.prototype, "fill", void 0);
1335
1406
  __decorate([
1336
1407
  affectStrokeBoundsType('outside')
1337
1408
  ], Text.prototype, "strokeAlign", void 0);
@@ -1390,13 +1461,15 @@ Text = __decorate([
1390
1461
  const { toBounds } = PathBounds;
1391
1462
  let Path = class Path extends UI {
1392
1463
  get __tag() { return 'Path'; }
1393
- get resizeable() { return false; }
1394
1464
  constructor(data) {
1395
1465
  super(data);
1396
1466
  }
1467
+ __scaleResize(scaleX, scaleY) {
1468
+ PathScaler.scale(this.__.path, scaleX, scaleY);
1469
+ this.path = this.__.path;
1470
+ }
1397
1471
  __updateBoxBounds() {
1398
1472
  toBounds(this.__.path, this.__layout.boxBounds);
1399
- this.__updateNaturalSize();
1400
1473
  }
1401
1474
  };
1402
1475
  __decorate([
@@ -1465,6 +1538,7 @@ let Leafer = class Leafer extends Group {
1465
1538
  get __tag() { return 'Leafer'; }
1466
1539
  get isApp() { return false; }
1467
1540
  get app() { return this.parent || this; }
1541
+ get layoutLocked() { return !this.layouter.running; }
1468
1542
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
1469
1543
  constructor(userConfig, data) {
1470
1544
  super(data);
@@ -1557,13 +1631,18 @@ let Leafer = class Leafer extends Group {
1557
1631
  this.emitLeafer(LeaferEvent.STOP);
1558
1632
  }
1559
1633
  }
1634
+ unlockLayout() {
1635
+ this.layouter.start();
1636
+ this.updateLayout();
1637
+ }
1638
+ lockLayout() {
1639
+ this.updateLayout();
1640
+ this.layouter.stop();
1641
+ }
1560
1642
  resize(size) {
1561
1643
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
1562
1644
  Object.keys(data).forEach(key => this[key] = data[key]);
1563
1645
  }
1564
- forceLayout() {
1565
- this.__layout.checkUpdate(true);
1566
- }
1567
1646
  forceFullRender() {
1568
1647
  this.renderer.addBlock(this.canvas.bounds);
1569
1648
  if (this.viewReady)
@@ -1709,7 +1788,7 @@ let Leafer = class Leafer extends Group {
1709
1788
  }
1710
1789
  }
1711
1790
  __checkUpdateLayout() {
1712
- this.__layout.checkUpdate();
1791
+ this.__layout.update();
1713
1792
  }
1714
1793
  emitLeafer(type) {
1715
1794
  this.emitEvent(new LeaferEvent(type, this));
@@ -1769,6 +1848,22 @@ Leafer = __decorate([
1769
1848
  let App = class App extends Leafer {
1770
1849
  get __tag() { return 'App'; }
1771
1850
  get isApp() { return true; }
1851
+ constructor(userConfig, data) {
1852
+ super(userConfig, data);
1853
+ if (userConfig) {
1854
+ const { ground, tree, sky, editor } = userConfig;
1855
+ if (ground)
1856
+ this.ground = this.addLeafer(ground);
1857
+ if (tree || editor)
1858
+ this.tree = this.addLeafer(tree);
1859
+ if (sky || editor)
1860
+ this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
1861
+ if (editor) {
1862
+ this.editor = Creator.editor(editor);
1863
+ this.sky.add(this.editor);
1864
+ }
1865
+ }
1866
+ }
1772
1867
  __setApp() {
1773
1868
  const { canvas } = this;
1774
1869
  const { realCanvas, view } = this.config;
@@ -1785,12 +1880,20 @@ let App = class App extends Leafer {
1785
1880
  }
1786
1881
  start() {
1787
1882
  super.start();
1788
- this.children.forEach(leafer => { leafer.start(); });
1883
+ this.children.forEach(leafer => leafer.start());
1789
1884
  }
1790
1885
  stop() {
1791
- this.children.forEach(leafer => { leafer.stop(); });
1886
+ this.children.forEach(leafer => leafer.stop());
1792
1887
  super.stop();
1793
1888
  }
1889
+ unlockLayout() {
1890
+ super.unlockLayout();
1891
+ this.children.forEach(leafer => leafer.unlockLayout());
1892
+ }
1893
+ lockLayout() {
1894
+ super.lockLayout();
1895
+ this.children.forEach(leafer => leafer.lockLayout());
1896
+ }
1794
1897
  addLeafer(merge) {
1795
1898
  const leafer = new Leafer(merge);
1796
1899
  this.add(leafer);
@@ -1809,7 +1912,7 @@ let App = class App extends Leafer {
1809
1912
  }
1810
1913
  __onPropertyChange() {
1811
1914
  if (Debug.showHitView)
1812
- this.children.forEach(leafer => { leafer.forceUpdate('surface'); });
1915
+ this.children.forEach(leafer => leafer.forceUpdate('surface'));
1813
1916
  }
1814
1917
  __onCreated() {
1815
1918
  this.created = this.children.every(child => child.created);
@@ -1831,14 +1934,14 @@ let App = class App extends Leafer {
1831
1934
  this.renderer.update();
1832
1935
  }
1833
1936
  __render(canvas, _options) {
1834
- this.children.forEach(leafer => { canvas.copyWorld(leafer.canvas); });
1937
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
1835
1938
  }
1836
1939
  __onResize(event) {
1837
- this.children.forEach(leafer => { leafer.resize(event); });
1940
+ this.children.forEach(leafer => leafer.resize(event));
1838
1941
  super.__onResize(event);
1839
1942
  }
1840
1943
  __checkUpdateLayout() {
1841
- this.children.forEach(leafer => { leafer.__layout.checkUpdate(); });
1944
+ this.children.forEach(leafer => leafer.__layout.update());
1842
1945
  }
1843
1946
  __getChildConfig(userConfig) {
1844
1947
  let config = Object.assign({}, this.config);
@@ -1863,4 +1966,4 @@ App = __decorate([
1863
1966
  registerUI()
1864
1967
  ], App);
1865
1968
 
1866
- export { Animate, App, Box, Canvas, ColorConvert, Effect, Ellipse, Export, Frame, Group, Image, Leafer, LeaferTypeCreator, Line, Paint, Path, Pen, Polygon, Rect, RectRender, Star, Text, TextConvert, UI, UIBounds, UIHit, UIRender, effectType, resizeType };
1969
+ export { Animate, App, Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, LeaferTypeCreator, Line, LineData, Paint, Path, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIHit, UIRender, UnitConvert, effectType, resizeType };