@leafer-ui/core 1.0.0-rc.5 → 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,6 +492,9 @@ 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);
@@ -492,8 +502,15 @@ let UI = UI_1 = class UI extends Leaf {
492
502
  get() {
493
503
  return this.__.__getInputData();
494
504
  }
505
+ createProxyData() { return undefined; }
506
+ find(condition, options) {
507
+ return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
508
+ }
509
+ findOne(condition, options) {
510
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
511
+ }
495
512
  getPath(curve) {
496
- const path = this.__.path;
513
+ const { path } = this.__;
497
514
  if (!path)
498
515
  return [];
499
516
  return curve ? PathConvert.toCanvasData(path, true) : path;
@@ -525,6 +542,15 @@ let UI = UI_1 = class UI extends Leaf {
525
542
  this.__drawPathByData(canvas, this.__.path);
526
543
  }
527
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
+ }
528
554
  export(filename, options) {
529
555
  return Export.export(this, filename, options);
530
556
  }
@@ -566,12 +592,12 @@ __decorate([
566
592
  __decorate([
567
593
  eraserType(false)
568
594
  ], UI.prototype, "isEraser", void 0);
595
+ __decorate([
596
+ dataType(false)
597
+ ], UI.prototype, "locked", void 0);
569
598
  __decorate([
570
599
  sortType(0)
571
600
  ], UI.prototype, "zIndex", void 0);
572
- __decorate([
573
- dataType()
574
- ], UI.prototype, "locked", void 0);
575
601
  __decorate([
576
602
  positionType(0)
577
603
  ], UI.prototype, "x", void 0);
@@ -600,11 +626,17 @@ __decorate([
600
626
  rotationType(0)
601
627
  ], UI.prototype, "skewY", void 0);
602
628
  __decorate([
603
- positionType()
629
+ autoLayoutType()
604
630
  ], UI.prototype, "around", void 0);
605
631
  __decorate([
606
632
  dataType(false)
607
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);
608
640
  __decorate([
609
641
  hitType(true)
610
642
  ], UI.prototype, "hittable", void 0);
@@ -614,6 +646,9 @@ __decorate([
614
646
  __decorate([
615
647
  strokeType('path')
616
648
  ], UI.prototype, "hitStroke", void 0);
649
+ __decorate([
650
+ hitType(false)
651
+ ], UI.prototype, "hitBox", void 0);
617
652
  __decorate([
618
653
  hitType(true)
619
654
  ], UI.prototype, "hitChildren", void 0);
@@ -654,7 +689,7 @@ __decorate([
654
689
  strokeType(10)
655
690
  ], UI.prototype, "miterLimit", void 0);
656
691
  __decorate([
657
- pathType()
692
+ pathType(0)
658
693
  ], UI.prototype, "cornerRadius", void 0);
659
694
  __decorate([
660
695
  pathType()
@@ -687,9 +722,9 @@ UI = UI_1 = __decorate([
687
722
  rewriteAble()
688
723
  ], UI);
689
724
 
725
+ const matrix = MatrixHelper.get();
690
726
  let Group = class Group extends UI {
691
727
  get __tag() { return 'Group'; }
692
- get resizeable() { return false; }
693
728
  set mask(child) {
694
729
  if (this.__hasMask)
695
730
  this.__removeMask();
@@ -737,6 +772,14 @@ let Group = class Group extends UI {
737
772
  data.children = this.children.map(child => child.toJSON());
738
773
  return data;
739
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
+ }
740
783
  addAt(child, index) {
741
784
  this.add(child, index);
742
785
  }
@@ -764,21 +807,17 @@ let Rect = class Rect extends UI {
764
807
  constructor(data) {
765
808
  super(data);
766
809
  }
767
- __drawPathByData(drawer, _data) {
768
- const { width, height, cornerRadius } = this.__;
769
- if (cornerRadius) {
770
- drawer.roundRect(0, 0, width, height, cornerRadius);
771
- }
772
- else {
773
- drawer.rect(0, 0, width, height);
774
- }
775
- }
810
+ __drawPathByData(_drawer, _data) { }
776
811
  };
777
812
  __decorate([
778
813
  dataProcessor(RectData)
779
814
  ], Rect.prototype, "__", void 0);
815
+ __decorate([
816
+ rewrite(UI.prototype.__drawPathByBox)
817
+ ], Rect.prototype, "__drawPathByData", null);
780
818
  Rect = __decorate([
781
819
  useModule(RectRender),
820
+ rewriteAble(),
782
821
  registerUI()
783
822
  ], Rect);
784
823
 
@@ -788,12 +827,20 @@ const bounds = {};
788
827
  const { copy, add } = BoundsHelper;
789
828
  let Box = class Box extends Group {
790
829
  get __tag() { return 'Box'; }
791
- get resizeable() { return true; }
792
830
  constructor(data) {
793
831
  super(data);
794
832
  this.isBranchLeaf = true;
795
833
  this.__layout.renderChanged || this.__layout.renderChange();
796
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
+ }
797
844
  __updateStrokeSpread() { return 0; }
798
845
  __updateRectRenderSpread() { return 0; }
799
846
  __updateRenderSpread() {
@@ -803,7 +850,15 @@ let Box = class Box extends Group {
803
850
  width = this.__.__drawAfterFill ? 0 : 1;
804
851
  return width;
805
852
  }
806
- __updateBoxBounds() { }
853
+ __updateRectBoxBounds() { }
854
+ __updateBoxBounds() {
855
+ if (this.__.__autoBounds && this.children.length) {
856
+ super.__updateBoxBounds();
857
+ }
858
+ else {
859
+ this.__updateRectBoxBounds();
860
+ }
861
+ }
807
862
  __updateStrokeBounds() { }
808
863
  __updateRenderBounds() {
809
864
  this.__updateRectRenderBounds();
@@ -855,7 +910,7 @@ __decorate([
855
910
  ], Box.prototype, "__updateRectRenderSpread", null);
856
911
  __decorate([
857
912
  rewrite(rect.__updateBoxBounds)
858
- ], Box.prototype, "__updateBoxBounds", null);
913
+ ], Box.prototype, "__updateRectBoxBounds", null);
859
914
  __decorate([
860
915
  rewrite(rect.__updateStrokeBounds)
861
916
  ], Box.prototype, "__updateStrokeBounds", null);
@@ -883,6 +938,7 @@ let Frame = class Frame extends Box {
883
938
  get __tag() { return 'Frame'; }
884
939
  constructor(data) {
885
940
  super(data);
941
+ this.isFrame = true;
886
942
  if (!this.__.fill)
887
943
  this.__.fill = '#FFFFFF';
888
944
  }
@@ -922,8 +978,8 @@ let Ellipse = class Ellipse extends UI {
922
978
  }
923
979
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
924
980
  }
925
- if (Platform.name === 'node')
926
- this.__.path = PathConvert.toCanvasData(path, true);
981
+ if (Platform.ellipseToCurve)
982
+ this.__.path = this.getPath(true);
927
983
  }
928
984
  else {
929
985
  if (startAngle || endAngle) {
@@ -953,47 +1009,118 @@ Ellipse = __decorate([
953
1009
  registerUI()
954
1010
  ], Ellipse);
955
1011
 
956
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
957
- const { moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1 } = PathCommandDataHelper;
958
- const { toBounds: toBounds$2 } = PathBounds;
959
- let Polygon = class Polygon extends UI {
960
- get __tag() { return 'Polygon'; }
961
- 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
+ }
962
1032
  constructor(data) {
963
1033
  super(data);
964
1034
  }
965
1035
  __updatePath() {
966
1036
  const path = this.__.path = [];
967
1037
  if (this.__.points) {
968
- drawPoints$1(path, this.__.points, false, true);
1038
+ drawPoints$1(path, this.__.points, false);
969
1039
  }
970
1040
  else {
971
- const { width, height, sides } = this.__;
972
- const rx = width / 2, ry = height / 2;
973
- moveTo$2(path, rx, 0);
974
- for (let i = 1; i < sides; i++) {
975
- lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
976
- }
1041
+ moveTo$2(path, 0, 0);
1042
+ lineTo$2(path, this.width, 0);
977
1043
  }
978
- closePath$1(path);
979
1044
  }
980
1045
  __updateRenderPath() {
981
1046
  if (this.__.points && this.__.curve) {
982
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
1047
+ drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
983
1048
  }
984
1049
  else {
985
1050
  super.__updateRenderPath();
986
1051
  }
987
1052
  }
988
1053
  __updateBoxBounds() {
989
- if (this.__.points) {
990
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
991
- this.__updateNaturalSize();
1054
+ if (this.points) {
1055
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
992
1056
  }
993
1057
  else {
994
1058
  super.__updateBoxBounds();
995
1059
  }
996
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) { }
997
1124
  };
998
1125
  __decorate([
999
1126
  dataProcessor(PolygonData)
@@ -1007,12 +1134,22 @@ __decorate([
1007
1134
  __decorate([
1008
1135
  pathType(0)
1009
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);
1010
1146
  Polygon = __decorate([
1147
+ rewriteAble(),
1011
1148
  registerUI()
1012
1149
  ], Polygon);
1013
1150
 
1014
1151
  const { sin, cos, PI } = Math;
1015
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath } = PathCommandDataHelper;
1152
+ const { moveTo, lineTo, closePath } = PathCommandDataHelper;
1016
1153
  let Star = class Star extends UI {
1017
1154
  get __tag() { return 'Star'; }
1018
1155
  constructor(data) {
@@ -1022,9 +1159,9 @@ let Star = class Star extends UI {
1022
1159
  const { width, height, corners, innerRadius } = this.__;
1023
1160
  const rx = width / 2, ry = height / 2;
1024
1161
  const path = this.__.path = [];
1025
- moveTo$1(path, rx, 0);
1162
+ moveTo(path, rx, 0);
1026
1163
  for (let i = 1; i < corners * 2; i++) {
1027
- 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));
1028
1165
  }
1029
1166
  closePath(path);
1030
1167
  }
@@ -1042,77 +1179,6 @@ Star = __decorate([
1042
1179
  registerUI()
1043
1180
  ], Star);
1044
1181
 
1045
- const { moveTo, lineTo, drawPoints } = PathCommandDataHelper;
1046
- const { rotate, getAngle, getDistance, defaultPoint } = PointHelper;
1047
- const { toBounds: toBounds$1 } = PathBounds;
1048
- let Line = class Line extends UI {
1049
- get __tag() { return 'Line'; }
1050
- get resizeable() { return !this.points; }
1051
- get toPoint() {
1052
- const { width, rotation } = this.__;
1053
- const to = { x: 0, y: 0 };
1054
- if (width)
1055
- to.x = width;
1056
- if (rotation)
1057
- rotate(to, rotation);
1058
- return to;
1059
- }
1060
- set toPoint(value) {
1061
- this.width = getDistance(defaultPoint, value);
1062
- this.rotation = getAngle(defaultPoint, value);
1063
- if (this.height)
1064
- this.height = 0;
1065
- }
1066
- constructor(data) {
1067
- super(data);
1068
- }
1069
- __updatePath() {
1070
- const path = this.__.path = [];
1071
- if (this.__.points) {
1072
- drawPoints(path, this.__.points, false);
1073
- }
1074
- else {
1075
- moveTo(path, 0, 0);
1076
- lineTo(path, this.width, 0);
1077
- }
1078
- }
1079
- __updateRenderPath() {
1080
- if (this.__.points && this.__.curve) {
1081
- drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
1082
- }
1083
- else {
1084
- super.__updateRenderPath();
1085
- }
1086
- }
1087
- __updateBoxBounds() {
1088
- if (this.points) {
1089
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
1090
- this.__updateNaturalSize();
1091
- }
1092
- else {
1093
- super.__updateBoxBounds();
1094
- }
1095
- }
1096
- };
1097
- __decorate([
1098
- dataProcessor(LineData)
1099
- ], Line.prototype, "__", void 0);
1100
- __decorate([
1101
- affectStrokeBoundsType('center')
1102
- ], Line.prototype, "strokeAlign", void 0);
1103
- __decorate([
1104
- boundsType(0)
1105
- ], Line.prototype, "height", void 0);
1106
- __decorate([
1107
- pathType()
1108
- ], Line.prototype, "points", void 0);
1109
- __decorate([
1110
- pathType(0)
1111
- ], Line.prototype, "curve", void 0);
1112
- Line = __decorate([
1113
- registerUI()
1114
- ], Line);
1115
-
1116
1182
  let Image = class Image extends Rect {
1117
1183
  get __tag() { return 'Image'; }
1118
1184
  get ready() { return this.image ? this.image.ready : false; }
@@ -1163,7 +1229,7 @@ let Canvas = class Canvas extends Rect {
1163
1229
  this.__.__drawAfterFill = true;
1164
1230
  }
1165
1231
  draw(ui, offset, scale, rotation) {
1166
- ui.__layout.checkUpdate();
1232
+ ui.__layout.update();
1167
1233
  const matrix = new Matrix(ui.__world);
1168
1234
  matrix.invert();
1169
1235
  const m = new Matrix();
@@ -1173,7 +1239,7 @@ let Canvas = class Canvas extends Rect {
1173
1239
  typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
1174
1240
  if (rotation)
1175
1241
  m.rotate(rotation);
1176
- matrix.preMultiply(m);
1242
+ matrix.multiplyParent(m);
1177
1243
  ui.__render(this.canvas, { matrix });
1178
1244
  this.paint();
1179
1245
  }
@@ -1233,11 +1299,11 @@ Canvas = __decorate([
1233
1299
  registerUI()
1234
1300
  ], Canvas);
1235
1301
 
1236
- const { copyAndSpread, includes, spread } = BoundsHelper;
1302
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
1237
1303
  let Text = class Text extends UI {
1238
1304
  get __tag() { return 'Text'; }
1239
1305
  get textDrawData() {
1240
- this.__layout.checkUpdate();
1306
+ this.__layout.update();
1241
1307
  return this.__.__textDrawData;
1242
1308
  }
1243
1309
  constructor(data) {
@@ -1267,32 +1333,49 @@ let Text = class Text extends UI {
1267
1333
  __updateBoxBounds() {
1268
1334
  const data = this.__;
1269
1335
  const layout = this.__layout;
1270
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
1336
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
1337
+ const autoWidth = data.__autoWidth;
1338
+ const autoHeight = data.__autoHeight;
1271
1339
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1272
1340
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1273
1341
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1274
1342
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1343
+ data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
1275
1344
  this.__updateTextDrawData();
1276
1345
  const { bounds } = data.__textDrawData;
1277
1346
  const b = layout.boxBounds;
1278
1347
  if (data.__lineHeight < fontSize)
1279
1348
  spread(bounds, fontSize / 2);
1280
- const width = data.__getInput('width');
1281
- const height = data.__getInput('height');
1282
- if (width && height) {
1283
- 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();
1284
1367
  }
1285
1368
  else {
1286
- b.x = width ? 0 : bounds.x;
1287
- b.y = height ? 0 : bounds.y;
1288
- b.width = width ? width : bounds.width;
1289
- b.height = height ? height : bounds.height;
1290
- this.__updateNaturalSize();
1369
+ super.__updateBoxBounds();
1291
1370
  }
1292
1371
  const contentBounds = includes(b, bounds) ? b : bounds;
1293
1372
  if (contentBounds !== layout.contentBounds) {
1294
1373
  layout.contentBounds = contentBounds;
1295
1374
  layout.renderChanged = true;
1375
+ setList(data.__textBoxBounds = {}, [b, bounds]);
1376
+ }
1377
+ else {
1378
+ data.__textBoxBounds = contentBounds;
1296
1379
  }
1297
1380
  }
1298
1381
  __updateRenderSpread() {
@@ -1302,7 +1385,7 @@ let Text = class Text extends UI {
1302
1385
  return width;
1303
1386
  }
1304
1387
  __updateRenderBounds() {
1305
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread);
1388
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
1306
1389
  }
1307
1390
  };
1308
1391
  __decorate([
@@ -1317,9 +1400,15 @@ __decorate([
1317
1400
  __decorate([
1318
1401
  boundsType(0)
1319
1402
  ], Text.prototype, "padding", void 0);
1403
+ __decorate([
1404
+ surfaceType('#000000')
1405
+ ], Text.prototype, "fill", void 0);
1320
1406
  __decorate([
1321
1407
  affectStrokeBoundsType('outside')
1322
1408
  ], Text.prototype, "strokeAlign", void 0);
1409
+ __decorate([
1410
+ hitType('all')
1411
+ ], Text.prototype, "hitFill", void 0);
1323
1412
  __decorate([
1324
1413
  boundsType('')
1325
1414
  ], Text.prototype, "text", void 0);
@@ -1359,6 +1448,9 @@ __decorate([
1359
1448
  __decorate([
1360
1449
  boundsType('top')
1361
1450
  ], Text.prototype, "verticalAlign", void 0);
1451
+ __decorate([
1452
+ boundsType('normal')
1453
+ ], Text.prototype, "textWrap", void 0);
1362
1454
  __decorate([
1363
1455
  boundsType('show')
1364
1456
  ], Text.prototype, "textOverflow", void 0);
@@ -1369,13 +1461,15 @@ Text = __decorate([
1369
1461
  const { toBounds } = PathBounds;
1370
1462
  let Path = class Path extends UI {
1371
1463
  get __tag() { return 'Path'; }
1372
- get resizeable() { return false; }
1373
1464
  constructor(data) {
1374
1465
  super(data);
1375
1466
  }
1467
+ __scaleResize(scaleX, scaleY) {
1468
+ PathScaler.scale(this.__.path, scaleX, scaleY);
1469
+ this.path = this.__.path;
1470
+ }
1376
1471
  __updateBoxBounds() {
1377
1472
  toBounds(this.__.path, this.__layout.boxBounds);
1378
- this.__updateNaturalSize();
1379
1473
  }
1380
1474
  };
1381
1475
  __decorate([
@@ -1444,6 +1538,7 @@ let Leafer = class Leafer extends Group {
1444
1538
  get __tag() { return 'Leafer'; }
1445
1539
  get isApp() { return false; }
1446
1540
  get app() { return this.parent || this; }
1541
+ get layoutLocked() { return !this.layouter.running; }
1447
1542
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
1448
1543
  constructor(userConfig, data) {
1449
1544
  super(data);
@@ -1536,13 +1631,18 @@ let Leafer = class Leafer extends Group {
1536
1631
  this.emitLeafer(LeaferEvent.STOP);
1537
1632
  }
1538
1633
  }
1634
+ unlockLayout() {
1635
+ this.layouter.start();
1636
+ this.updateLayout();
1637
+ }
1638
+ lockLayout() {
1639
+ this.updateLayout();
1640
+ this.layouter.stop();
1641
+ }
1539
1642
  resize(size) {
1540
1643
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
1541
1644
  Object.keys(data).forEach(key => this[key] = data[key]);
1542
1645
  }
1543
- forceLayout() {
1544
- this.__layout.checkUpdate(true);
1545
- }
1546
1646
  forceFullRender() {
1547
1647
  this.renderer.addBlock(this.canvas.bounds);
1548
1648
  if (this.viewReady)
@@ -1688,7 +1788,7 @@ let Leafer = class Leafer extends Group {
1688
1788
  }
1689
1789
  }
1690
1790
  __checkUpdateLayout() {
1691
- this.__layout.checkUpdate();
1791
+ this.__layout.update();
1692
1792
  }
1693
1793
  emitLeafer(type) {
1694
1794
  this.emitEvent(new LeaferEvent(type, this));
@@ -1748,6 +1848,22 @@ Leafer = __decorate([
1748
1848
  let App = class App extends Leafer {
1749
1849
  get __tag() { return 'App'; }
1750
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
+ }
1751
1867
  __setApp() {
1752
1868
  const { canvas } = this;
1753
1869
  const { realCanvas, view } = this.config;
@@ -1764,12 +1880,20 @@ let App = class App extends Leafer {
1764
1880
  }
1765
1881
  start() {
1766
1882
  super.start();
1767
- this.children.forEach(leafer => { leafer.start(); });
1883
+ this.children.forEach(leafer => leafer.start());
1768
1884
  }
1769
1885
  stop() {
1770
- this.children.forEach(leafer => { leafer.stop(); });
1886
+ this.children.forEach(leafer => leafer.stop());
1771
1887
  super.stop();
1772
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
+ }
1773
1897
  addLeafer(merge) {
1774
1898
  const leafer = new Leafer(merge);
1775
1899
  this.add(leafer);
@@ -1788,7 +1912,7 @@ let App = class App extends Leafer {
1788
1912
  }
1789
1913
  __onPropertyChange() {
1790
1914
  if (Debug.showHitView)
1791
- this.children.forEach(leafer => { leafer.forceUpdate('surface'); });
1915
+ this.children.forEach(leafer => leafer.forceUpdate('surface'));
1792
1916
  }
1793
1917
  __onCreated() {
1794
1918
  this.created = this.children.every(child => child.created);
@@ -1810,14 +1934,14 @@ let App = class App extends Leafer {
1810
1934
  this.renderer.update();
1811
1935
  }
1812
1936
  __render(canvas, _options) {
1813
- this.children.forEach(leafer => { canvas.copyWorld(leafer.canvas); });
1937
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
1814
1938
  }
1815
1939
  __onResize(event) {
1816
- this.children.forEach(leafer => { leafer.resize(event); });
1940
+ this.children.forEach(leafer => leafer.resize(event));
1817
1941
  super.__onResize(event);
1818
1942
  }
1819
1943
  __checkUpdateLayout() {
1820
- this.children.forEach(leafer => { leafer.__layout.checkUpdate(); });
1944
+ this.children.forEach(leafer => leafer.__layout.update());
1821
1945
  }
1822
1946
  __getChildConfig(userConfig) {
1823
1947
  let config = Object.assign({}, this.config);
@@ -1842,4 +1966,4 @@ App = __decorate([
1842
1966
  registerUI()
1843
1967
  ], App);
1844
1968
 
1845
- 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 };