leafer-ui 1.0.0-rc.21 → 1.0.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ const Platform = {
3
3
  hitCanvasSize: 100,
4
4
  maxCacheSize: 2560 * 1600,
5
5
  maxPatternSize: 4096 * 2160,
6
- suffix: 'leaf',
6
+ suffix: '',
7
7
  crossOrigin: 'anonymous'
8
8
  }
9
9
  };
@@ -33,24 +33,12 @@ const I$2 = IncrementId;
33
33
  const { round, pow: pow$1, PI: PI$4 } = Math;
34
34
  const MathHelper = {
35
35
  within(value, min, max) {
36
- if (value < min)
36
+ if (min !== undefined && value < min)
37
37
  value = min;
38
- if (value > max)
38
+ if (max !== undefined && value > max)
39
39
  value = max;
40
40
  return value;
41
41
  },
42
- minus(value, isFourNumber) {
43
- if (value instanceof Array) {
44
- if (isFourNumber)
45
- value = MathHelper.fourNumber(value, 0);
46
- for (let i = 0; i < value.length; i++)
47
- value[i] = -value[i];
48
- }
49
- else {
50
- value = -value;
51
- }
52
- return value;
53
- },
54
42
  fourNumber(num, maxValue) {
55
43
  let data;
56
44
  if (num instanceof Array) {
@@ -117,7 +105,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
117
105
 
118
106
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
119
107
  const { float: float$1 } = MathHelper;
120
- const tempPoint$3 = {};
108
+ const tempPoint$4 = {};
121
109
  function getWorld() {
122
110
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
123
111
  }
@@ -147,9 +135,11 @@ const MatrixHelper = {
147
135
  t.e += x;
148
136
  t.f += y;
149
137
  },
150
- translateInner(t, x, y) {
138
+ translateInner(t, x, y, isMoveOrigin) {
151
139
  t.e += t.a * x + t.c * y;
152
140
  t.f += t.b * x + t.d * y;
141
+ if (isMoveOrigin)
142
+ t.e -= x, t.f -= y;
153
143
  },
154
144
  scale(t, scaleX, scaleY = scaleX) {
155
145
  t.a *= scaleX;
@@ -158,8 +148,8 @@ const MatrixHelper = {
158
148
  t.d *= scaleY;
159
149
  },
160
150
  scaleOfOuter(t, origin, scaleX, scaleY) {
161
- M$6.toInnerPoint(t, origin, tempPoint$3);
162
- M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
151
+ M$6.toInnerPoint(t, origin, tempPoint$4);
152
+ M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
163
153
  },
164
154
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
165
155
  M$6.translateInner(t, origin.x, origin.y);
@@ -177,8 +167,8 @@ const MatrixHelper = {
177
167
  t.d = c * sinR + d * cosR;
178
168
  },
179
169
  rotateOfOuter(t, origin, rotation) {
180
- M$6.toInnerPoint(t, origin, tempPoint$3);
181
- M$6.rotateOfInner(t, tempPoint$3, rotation);
170
+ M$6.toInnerPoint(t, origin, tempPoint$4);
171
+ M$6.rotateOfInner(t, tempPoint$4, rotation);
182
172
  },
183
173
  rotateOfInner(t, origin, rotation) {
184
174
  M$6.translateInner(t, origin.x, origin.y);
@@ -199,8 +189,8 @@ const MatrixHelper = {
199
189
  }
200
190
  },
201
191
  skewOfOuter(t, origin, skewX, skewY) {
202
- M$6.toInnerPoint(t, origin, tempPoint$3);
203
- M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
192
+ M$6.toInnerPoint(t, origin, tempPoint$4);
193
+ M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
204
194
  },
205
195
  skewOfInner(t, origin, skewX, skewY = 0) {
206
196
  M$6.translateInner(t, origin.x, origin.y);
@@ -216,8 +206,10 @@ const MatrixHelper = {
216
206
  t.e = child.e * a + child.f * c + e;
217
207
  t.f = child.e * b + child.f * d + f;
218
208
  },
219
- multiplyParent(t, parent, to, abcdChanged, childScaleData) {
220
- const { e, f } = t;
209
+ multiplyParent(t, parent, to, abcdChanged, childScaleData, scrollData) {
210
+ let { e, f } = t;
211
+ if (scrollData)
212
+ e += scrollData.scrollX, f += scrollData.scrollY;
221
213
  to || (to = t);
222
214
  if (abcdChanged === undefined)
223
215
  abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
@@ -338,7 +330,7 @@ const MatrixHelper = {
338
330
  t.e = x;
339
331
  t.f = y;
340
332
  if (origin)
341
- M$6.translateInner(t, -origin.x, -origin.y);
333
+ M$6.translateInner(t, -origin.x, -origin.y, true);
342
334
  },
343
335
  getLayout(t, origin, firstSkewY) {
344
336
  const { a, b, c, d, e, f } = t;
@@ -594,7 +586,7 @@ class Point {
594
586
  return this;
595
587
  }
596
588
  }
597
- const tempPoint$2 = new Point();
589
+ const tempPoint$3 = new Point();
598
590
 
599
591
  class Matrix {
600
592
  constructor(a, b, c, d, e, f) {
@@ -758,7 +750,7 @@ const { float, fourNumber } = MathHelper;
758
750
  const { floor, ceil: ceil$2 } = Math;
759
751
  let right$1, bottom$1, boundsRight, boundsBottom;
760
752
  const point = {};
761
- const toPoint$1 = {};
753
+ const toPoint$2 = {};
762
754
  const BoundsHelper = {
763
755
  tempBounds: {},
764
756
  set(t, x = 0, y = 0, width = 0, height = 0) {
@@ -773,15 +765,17 @@ const BoundsHelper = {
773
765
  t.width = bounds.width;
774
766
  t.height = bounds.height;
775
767
  },
776
- copyAndSpread(t, bounds, spreadX, spreadY) {
777
- if (spreadX instanceof Array) {
778
- const four = fourNumber(spreadX);
779
- B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
768
+ copyAndSpread(t, bounds, spread, isShrink) {
769
+ if (spread instanceof Array) {
770
+ const four = fourNumber(spread);
771
+ isShrink
772
+ ? B.set(t, bounds.x + four[3], bounds.y + four[0], bounds.width - four[1] - four[3], bounds.height - four[2] - four[0])
773
+ : B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
780
774
  }
781
775
  else {
782
- if (!spreadY)
783
- spreadY = spreadX;
784
- B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
776
+ if (isShrink)
777
+ spread = -spread;
778
+ B.set(t, bounds.x - spread, bounds.y - spread, bounds.width + spread * 2, bounds.height + spread * 2);
785
779
  }
786
780
  },
787
781
  minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
@@ -858,17 +852,17 @@ const BoundsHelper = {
858
852
  else {
859
853
  point.x = t.x;
860
854
  point.y = t.y;
861
- toOuterPoint$1(matrix, point, toPoint$1);
862
- setPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
855
+ toOuterPoint$1(matrix, point, toPoint$2);
856
+ setPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
863
857
  point.x = t.x + t.width;
864
- toOuterPoint$1(matrix, point, toPoint$1);
865
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
858
+ toOuterPoint$1(matrix, point, toPoint$2);
859
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
866
860
  point.y = t.y + t.height;
867
- toOuterPoint$1(matrix, point, toPoint$1);
868
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
861
+ toOuterPoint$1(matrix, point, toPoint$2);
862
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
869
863
  point.x = t.x;
870
- toOuterPoint$1(matrix, point, toPoint$1);
871
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
864
+ toOuterPoint$1(matrix, point, toPoint$2);
865
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
872
866
  toBounds$4(tempPointBounds$1, to);
873
867
  }
874
868
  },
@@ -881,13 +875,16 @@ const BoundsHelper = {
881
875
  const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
882
876
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
883
877
  },
884
- getSpread(t, spreadX, spreadY) {
878
+ getSpread(t, spread) {
885
879
  const n = {};
886
- B.copyAndSpread(n, t, spreadX, spreadY);
880
+ B.copyAndSpread(n, t, spread);
887
881
  return n;
888
882
  },
889
- spread(t, spreadX, spreadY = spreadX) {
890
- B.copyAndSpread(t, t, spreadX, spreadY);
883
+ spread(t, spread) {
884
+ B.copyAndSpread(t, t, spread);
885
+ },
886
+ shrink(t, shrink) {
887
+ B.copyAndSpread(t, t, shrink, true);
891
888
  },
892
889
  ceil(t) {
893
890
  const { x, y } = t;
@@ -1067,12 +1064,12 @@ class Bounds {
1067
1064
  getFitMatrix(put, baseScale) {
1068
1065
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1069
1066
  }
1070
- spread(fourNumber, spreadY) {
1071
- BoundsHelper.spread(this, fourNumber, spreadY);
1067
+ spread(fourNumber) {
1068
+ BoundsHelper.spread(this, fourNumber);
1072
1069
  return this;
1073
1070
  }
1074
1071
  shrink(fourNumber) {
1075
- BoundsHelper.spread(this, MathHelper.minus(fourNumber, true));
1072
+ BoundsHelper.shrink(this, fourNumber);
1076
1073
  return this;
1077
1074
  }
1078
1075
  ceil() {
@@ -1189,6 +1186,10 @@ var Direction9;
1189
1186
  Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1190
1187
  Direction9[Direction9["left"] = 7] = "left";
1191
1188
  Direction9[Direction9["center"] = 8] = "center";
1189
+ Direction9[Direction9["top-left"] = 0] = "top-left";
1190
+ Direction9[Direction9["top-right"] = 2] = "top-right";
1191
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1192
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1192
1193
  })(Direction9 || (Direction9 = {}));
1193
1194
 
1194
1195
  const directionData = [
@@ -1202,15 +1203,28 @@ const directionData = [
1202
1203
  { x: 0, y: 0.5 },
1203
1204
  { x: 0.5, y: 0.5 }
1204
1205
  ];
1206
+ directionData.forEach(item => item.type = 'percent');
1205
1207
  const AroundHelper = {
1206
1208
  directionData,
1207
1209
  tempPoint: {},
1208
1210
  get: get$5,
1209
- toPoint(around, bounds, to, onlySize) {
1211
+ toPoint(around, bounds, to, onlySize, pointBounds) {
1210
1212
  to || (to = {});
1211
1213
  const point = get$5(around);
1212
- to.x = point.x * bounds.width;
1213
- to.y = point.y * bounds.height;
1214
+ to.x = point.x;
1215
+ to.y = point.y;
1216
+ if (point.type === 'percent') {
1217
+ to.x *= bounds.width;
1218
+ to.y *= bounds.height;
1219
+ if (pointBounds) {
1220
+ to.x -= pointBounds.x;
1221
+ to.y -= pointBounds.y;
1222
+ if (point.x)
1223
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1224
+ if (point.y)
1225
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1226
+ }
1227
+ }
1214
1228
  if (!onlySize) {
1215
1229
  to.x += bounds.x;
1216
1230
  to.y += bounds.y;
@@ -1221,6 +1235,13 @@ function get$5(around) {
1221
1235
  return typeof around === 'string' ? directionData[Direction9[around]] : around;
1222
1236
  }
1223
1237
 
1238
+ const { toPoint: toPoint$1 } = AroundHelper;
1239
+ const AlignHelper = {
1240
+ toPoint(align, contentBounds, bounds, to, onlySize) {
1241
+ toPoint$1(align, bounds, to, onlySize, contentBounds);
1242
+ }
1243
+ };
1244
+
1224
1245
  const StringNumberMap = {
1225
1246
  '0': 1,
1226
1247
  '1': 1,
@@ -1453,13 +1474,19 @@ const DataHelper = {
1453
1474
  },
1454
1475
  clone(data) {
1455
1476
  return JSON.parse(JSON.stringify(data));
1477
+ },
1478
+ toMap(list) {
1479
+ const map = {};
1480
+ for (let i = 0, len = list.length; i < len; i++)
1481
+ map[list[i]] = true;
1482
+ return map;
1456
1483
  }
1457
1484
  };
1458
1485
  const { assign } = DataHelper;
1459
1486
 
1460
1487
  class LeafData {
1461
1488
  get __blendMode() {
1462
- if (this.eraser)
1489
+ if (this.eraser && this.eraser !== 'path')
1463
1490
  return 'destination-out';
1464
1491
  const { blendMode } = this;
1465
1492
  return blendMode === 'pass-through' ? null : blendMode;
@@ -2089,7 +2116,7 @@ class LeaferCanvasBase extends Canvas$1 {
2089
2116
  }
2090
2117
  clear() {
2091
2118
  const { pixelRatio } = this;
2092
- this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
2119
+ this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2093
2120
  }
2094
2121
  isSameSize(size) {
2095
2122
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
@@ -2208,7 +2235,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2208
2235
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2209
2236
  const { set: set$2 } = PointHelper;
2210
2237
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2211
- const tempPoint$1 = {};
2238
+ const tempPoint$2 = {};
2212
2239
  const BezierHelper = {
2213
2240
  points(data, points, curve, close) {
2214
2241
  data.push(M$5, points[0], points[1]);
@@ -2398,8 +2425,8 @@ const BezierHelper = {
2398
2425
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2399
2426
  addPoint$2(pointBounds, toX, toY);
2400
2427
  for (let i = 0, len = tList.length; i < len; i++) {
2401
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2402
- addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2428
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2429
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2403
2430
  }
2404
2431
  },
2405
2432
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2469,7 +2496,7 @@ const EllipseHelper = {
2469
2496
  };
2470
2497
 
2471
2498
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2472
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2499
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2473
2500
  const { ellipticalArc } = EllipseHelper;
2474
2501
  const debug$d = Debug.get('PathConvert');
2475
2502
  const setEndPoint$1 = {};
@@ -2662,7 +2689,7 @@ const PathConvert = {
2662
2689
  case N$3:
2663
2690
  x = old[i + 1];
2664
2691
  y = old[i + 2];
2665
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2692
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2666
2693
  i += 5;
2667
2694
  break;
2668
2695
  case D$3:
@@ -2819,7 +2846,7 @@ const PathCommandDataHelper = {
2819
2846
  };
2820
2847
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2821
2848
 
2822
- const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2849
+ const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2823
2850
  class PathCreator {
2824
2851
  set path(value) { this.__path = value; }
2825
2852
  get path() { return this.__path; }
@@ -2861,7 +2888,7 @@ class PathCreator {
2861
2888
  return this;
2862
2889
  }
2863
2890
  rect(x, y, width, height) {
2864
- rect$1(this.__path, x, y, width, height);
2891
+ rect$2(this.__path, x, y, width, height);
2865
2892
  return this;
2866
2893
  }
2867
2894
  roundRect(x, y, width, height, cornerRadius) {
@@ -3745,6 +3772,8 @@ function maskType(defaultValue) {
3745
3772
  this.__setAttr(key, value);
3746
3773
  this.__layout.boxChanged || this.__layout.boxChange();
3747
3774
  this.waitParent(() => { this.parent.__updateMask(value); });
3775
+ if (typeof value === 'string')
3776
+ this.maskType = value;
3748
3777
  }
3749
3778
  }));
3750
3779
  }
@@ -3956,15 +3985,21 @@ const LeafHelper = {
3956
3985
  }
3957
3986
  return true;
3958
3987
  },
3959
- moveWorld(t, x, y) {
3960
- const local = { x, y };
3988
+ moveWorld(t, x, y = 0) {
3989
+ const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
3961
3990
  if (t.parent)
3962
3991
  toInnerPoint$1(t.parent.worldTransform, local, local, true);
3963
3992
  L.moveLocal(t, local.x, local.y);
3964
3993
  },
3965
3994
  moveLocal(t, x, y = 0) {
3966
- t.x += x;
3967
- t.y += y;
3995
+ if (typeof x === 'object') {
3996
+ t.x += x.x;
3997
+ t.y += x.y;
3998
+ }
3999
+ else {
4000
+ t.x += x;
4001
+ t.y += y;
4002
+ }
3968
4003
  },
3969
4004
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3970
4005
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4168,11 +4203,19 @@ const WaitHelper = {
4168
4203
 
4169
4204
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4170
4205
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
4206
+ const localContent = '_localContentBounds';
4207
+ const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
4171
4208
  class LeafLayout {
4209
+ get contentBounds() { return this._contentBounds || this.boxBounds; }
4210
+ set contentBounds(bounds) { this._contentBounds = bounds; }
4172
4211
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4173
4212
  get renderBounds() { return this._renderBounds || this.boxBounds; }
4213
+ get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
4174
4214
  get localStrokeBounds() { return this._localStrokeBounds || this; }
4175
4215
  get localRenderBounds() { return this._localRenderBounds || this; }
4216
+ get worldContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {})); return this[worldContent]; }
4217
+ get worldBoxBounds() { toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {})); return this[worldBox]; }
4218
+ get worldStrokeBounds() { toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {})); return this[worldStroke]; }
4176
4219
  get a() { return 1; }
4177
4220
  get b() { return 0; }
4178
4221
  get c() { return 0; }
@@ -4255,7 +4298,6 @@ class LeafLayout {
4255
4298
  case 'content':
4256
4299
  if (this.contentBounds)
4257
4300
  return this.contentBounds;
4258
- case 'margin':
4259
4301
  case 'box':
4260
4302
  return this.boxBounds;
4261
4303
  case 'stroke':
@@ -4268,8 +4310,9 @@ class LeafLayout {
4268
4310
  return this.localRenderBounds;
4269
4311
  case 'stroke':
4270
4312
  return this.localStrokeBounds;
4271
- case 'margin':
4272
4313
  case 'content':
4314
+ if (this.contentBounds)
4315
+ return this.localContentBounds;
4273
4316
  case 'box':
4274
4317
  return this.leaf.__localBoxBounds;
4275
4318
  }
@@ -4278,15 +4321,13 @@ class LeafLayout {
4278
4321
  switch (type) {
4279
4322
  case 'render':
4280
4323
  return this.leaf.__world;
4324
+ case 'stroke':
4325
+ return this.worldStrokeBounds;
4281
4326
  case 'content':
4282
4327
  if (this.contentBounds)
4283
- return this.getWorldContentBounds();
4284
- case 'margin':
4328
+ return this.worldContentBounds;
4285
4329
  case 'box':
4286
- return this.getWorldBoxBounds();
4287
- case 'margin':
4288
- case 'stroke':
4289
- return this.getWorldStrokeBounds();
4330
+ return this.worldBoxBounds;
4290
4331
  }
4291
4332
  }
4292
4333
  getLayoutBounds(type, relative = 'world', unscale) {
@@ -4349,20 +4390,24 @@ class LeafLayout {
4349
4390
  points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
4350
4391
  return points;
4351
4392
  }
4352
- getWorldContentBounds() {
4353
- this._worldContentBounds || (this._worldContentBounds = {});
4354
- toOuterOf$2(this.contentBounds, this.leaf.__world, this._worldContentBounds);
4355
- return this._worldContentBounds;
4393
+ shrinkContent() {
4394
+ const { x, y, width, height } = this.boxBounds;
4395
+ this._contentBounds = { x, y, width, height };
4396
+ }
4397
+ spreadStroke() {
4398
+ const { x, y, width, height } = this.strokeBounds;
4399
+ this._strokeBounds = { x, y, width, height };
4400
+ this._localStrokeBounds = { x, y, width, height };
4401
+ if (!this.renderSpread)
4402
+ this.spreadRenderCancel();
4356
4403
  }
4357
- getWorldBoxBounds() {
4358
- this._worldBoxBounds || (this._worldBoxBounds = {});
4359
- toOuterOf$2(this.boxBounds, this.leaf.__world, this._worldBoxBounds);
4360
- return this._worldBoxBounds;
4404
+ spreadRender() {
4405
+ const { x, y, width, height } = this.renderBounds;
4406
+ this._renderBounds = { x, y, width, height };
4407
+ this._localRenderBounds = { x, y, width, height };
4361
4408
  }
4362
- getWorldStrokeBounds() {
4363
- this._worldStrokeBounds || (this._worldStrokeBounds = {});
4364
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
4365
- return this._worldStrokeBounds;
4409
+ shrinkContentCancel() {
4410
+ this._contentBounds = undefined;
4366
4411
  }
4367
4412
  spreadStrokeCancel() {
4368
4413
  const same = this.renderBounds === this.strokeBounds;
@@ -4375,18 +4420,6 @@ class LeafLayout {
4375
4420
  this._renderBounds = this._strokeBounds;
4376
4421
  this._localRenderBounds = this._localStrokeBounds;
4377
4422
  }
4378
- spreadStroke() {
4379
- const { x, y, width, height } = this.strokeBounds;
4380
- this._strokeBounds = { x, y, width, height };
4381
- this._localStrokeBounds = { x, y, width, height };
4382
- if (!this.renderSpread)
4383
- this.spreadRenderCancel();
4384
- }
4385
- spreadRender() {
4386
- const { x, y, width, height } = this.renderBounds;
4387
- this._renderBounds = { x, y, width, height };
4388
- this._localRenderBounds = { x, y, width, height };
4389
- }
4390
4423
  boxChange() {
4391
4424
  this.boxChanged = true;
4392
4425
  this.localBoxChanged || this.localBoxChange();
@@ -4473,24 +4506,40 @@ const LeafEventer = {
4473
4506
  });
4474
4507
  },
4475
4508
  off(type, listener, options) {
4476
- let capture;
4477
- if (options)
4478
- capture = typeof options === 'boolean' ? options : options.capture;
4479
- let events, index;
4480
- const map = __getListenerMap(this, capture);
4481
- const typeList = typeof type === 'string' ? type.split(' ') : type;
4482
- typeList.forEach(type => {
4483
- if (type) {
4484
- events = map[type];
4485
- if (events) {
4486
- index = events.findIndex(item => item.listener === listener);
4487
- if (index > -1)
4488
- events.splice(index, 1);
4489
- if (!events.length)
4490
- delete map[type];
4491
- }
4509
+ if (type) {
4510
+ const typeList = typeof type === 'string' ? type.split(' ') : type;
4511
+ if (listener) {
4512
+ let capture;
4513
+ if (options)
4514
+ capture = typeof options === 'boolean' ? options : options.capture;
4515
+ let events, index;
4516
+ const map = __getListenerMap(this, capture);
4517
+ typeList.forEach(type => {
4518
+ if (type) {
4519
+ events = map[type];
4520
+ if (events) {
4521
+ index = events.findIndex(item => item.listener === listener);
4522
+ if (index > -1)
4523
+ events.splice(index, 1);
4524
+ if (!events.length)
4525
+ delete map[type];
4526
+ }
4527
+ }
4528
+ });
4492
4529
  }
4493
- });
4530
+ else {
4531
+ const { __bubbleMap: b, __captureMap: c } = this;
4532
+ typeList.forEach(type => {
4533
+ if (b)
4534
+ delete b[type];
4535
+ if (c)
4536
+ delete c[type];
4537
+ });
4538
+ }
4539
+ }
4540
+ else {
4541
+ this.__bubbleMap = this.__captureMap = undefined;
4542
+ }
4494
4543
  },
4495
4544
  on_(type, listener, bind, options) {
4496
4545
  if (bind)
@@ -4526,12 +4575,15 @@ const LeafEventer = {
4526
4575
  break;
4527
4576
  }
4528
4577
  }
4578
+ this.syncEventer && this.syncEventer.emitEvent(event, capture);
4529
4579
  },
4530
4580
  emitEvent(event, capture) {
4531
4581
  event.current = this;
4532
4582
  this.emit(event.type, event, capture);
4533
4583
  },
4534
4584
  hasEvent(type, capture) {
4585
+ if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
4586
+ return true;
4535
4587
  const { __bubbleMap: b, __captureMap: c } = this;
4536
4588
  const hasB = b && b[type], hasC = c && c[type];
4537
4589
  return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
@@ -4751,10 +4803,10 @@ const LeafDataProxy = {
4751
4803
  };
4752
4804
 
4753
4805
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4754
- const { toPoint, tempPoint } = AroundHelper;
4806
+ const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4755
4807
  const LeafMatrix = {
4756
4808
  __updateWorldMatrix() {
4757
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4809
+ multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
4758
4810
  },
4759
4811
  __updateLocalMatrix() {
4760
4812
  if (this.__local) {
@@ -4765,11 +4817,11 @@ const LeafMatrix = {
4765
4817
  layout.scaleChanged = layout.rotationChanged = false;
4766
4818
  }
4767
4819
  }
4768
- local.e = data.x;
4769
- local.f = data.y;
4770
- if (data.around) {
4771
- toPoint(data.around, layout.boxBounds, tempPoint);
4772
- translateInner(local, -tempPoint.x, -tempPoint.y);
4820
+ local.e = data.x + data.offsetX;
4821
+ local.f = data.y + data.offsetY;
4822
+ if (data.around || data.origin) {
4823
+ toPoint(data.around || data.origin, layout.boxBounds, tempPoint$1);
4824
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4773
4825
  }
4774
4826
  }
4775
4827
  this.__layout.matrixChanged = false;
@@ -4875,6 +4927,8 @@ const LeafBounds = {
4875
4927
  if (this.isBranch) {
4876
4928
  if (this.leafer)
4877
4929
  this.leafer.layouter.addExtra(this);
4930
+ if (this.__.flow)
4931
+ this.__updateFlowLayout();
4878
4932
  if (hasParentAutoLayout(this)) {
4879
4933
  updateMatrix$1(this);
4880
4934
  }
@@ -4907,6 +4961,8 @@ const LeafRender = {
4907
4961
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
4908
4962
  canvas.opacity = this.__.opacity;
4909
4963
  if (this.__.__single) {
4964
+ if (this.__.eraser === 'path')
4965
+ return this.__renderEraser(canvas, options);
4910
4966
  const tempCanvas = canvas.getSameCanvas(true, true);
4911
4967
  this.__draw(tempCanvas, options);
4912
4968
  if (this.__worldFlipped) {
@@ -4949,6 +5005,8 @@ const BranchRender = {
4949
5005
  __render(canvas, options) {
4950
5006
  if (this.__worldOpacity) {
4951
5007
  if (this.__.__single) {
5008
+ if (this.__.eraser === 'path')
5009
+ return this.__renderEraser(canvas, options);
4952
5010
  const tempCanvas = canvas.getSameCanvas(false, true);
4953
5011
  this.__renderBranch(tempCanvas, options);
4954
5012
  const nowWorld = this.__getNowWorld(options);
@@ -5088,7 +5146,9 @@ let Leaf = class Leaf {
5088
5146
  setProxyAttr(_attrName, _newValue) { }
5089
5147
  getProxyAttr(_attrName) { return undefined; }
5090
5148
  find(_condition, _options) { return undefined; }
5149
+ findTag(_tag) { return undefined; }
5091
5150
  findOne(_condition, _options) { return undefined; }
5151
+ findId(_id) { return undefined; }
5092
5152
  focus(_value) { }
5093
5153
  forceUpdate(attrName) {
5094
5154
  if (attrName === undefined)
@@ -5110,9 +5170,11 @@ let Leaf = class Leaf {
5110
5170
  __updateLocalStrokeBounds() { }
5111
5171
  __updateLocalRenderBounds() { }
5112
5172
  __updateBoxBounds() { }
5173
+ __updateContentBounds() { }
5113
5174
  __updateStrokeBounds() { }
5114
5175
  __updateRenderBounds() { }
5115
5176
  __updateAutoLayout() { }
5177
+ __updateFlowLayout() { }
5116
5178
  __updateNaturalSize() { }
5117
5179
  __updateStrokeSpread() { return 0; }
5118
5180
  __updateRenderSpread() { return 0; }
@@ -5120,6 +5182,13 @@ let Leaf = class Leaf {
5120
5182
  __updateEraser(value) {
5121
5183
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
5122
5184
  }
5185
+ __renderEraser(canvas, options) {
5186
+ canvas.save();
5187
+ this.__clip(canvas, options);
5188
+ const { renderBounds: r } = this.__layout;
5189
+ canvas.clearRect(r.x, r.y, r.width, r.height);
5190
+ canvas.restore();
5191
+ }
5123
5192
  __updateMask(value) {
5124
5193
  this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5125
5194
  }
@@ -5300,8 +5369,8 @@ let Leaf = class Leaf {
5300
5369
  emit(_type, _event, _capture) { }
5301
5370
  emitEvent(_event, _capture) { }
5302
5371
  hasEvent(_type, _capture) { return false; }
5303
- static changeAttr(attrName, defaultValue) {
5304
- defineDataProcessor(this.prototype, attrName, defaultValue);
5372
+ static changeAttr(attrName, defaultValue, fn) {
5373
+ fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5305
5374
  }
5306
5375
  static addAttr(attrName, defaultValue, fn) {
5307
5376
  if (!fn)
@@ -5798,7 +5867,7 @@ function useCanvas(_canvasType, _power) {
5798
5867
  }
5799
5868
  img.onload = () => { resolve(img); };
5800
5869
  img.onerror = (e) => { reject(e); };
5801
- if (!src.startsWith('data:') && !src.startsWith('blob:') && suffix)
5870
+ if (suffix && !src.startsWith('data:') && !src.startsWith('blob:'))
5802
5871
  src += (src.includes("?") ? "&" : "?") + suffix;
5803
5872
  img.src = src;
5804
5873
  });
@@ -6360,8 +6429,11 @@ class Renderer {
6360
6429
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
6361
6430
  this.addBlock(this.canvas.bounds);
6362
6431
  this.target.forceUpdate('surface');
6432
+ return;
6363
6433
  }
6364
6434
  }
6435
+ this.addBlock(new Bounds(0, 0, 1, 1));
6436
+ this.changed = true;
6365
6437
  }
6366
6438
  __onLayoutEnd(event) {
6367
6439
  if (event.data)
@@ -6420,32 +6492,38 @@ class Picker {
6420
6492
  const target = options.target || this.target;
6421
6493
  this.exclude = options.exclude || null;
6422
6494
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6423
- this.findList = options.findList || [];
6495
+ this.findList = new LeafList(options.findList);
6424
6496
  if (!options.findList)
6425
- this.eachFind(target.children, target.__onlyHitMask);
6426
- const list = this.findList;
6427
- const leaf = this.getBestMatchLeaf();
6497
+ this.hitBranch(target);
6498
+ const { list } = this.findList;
6499
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6428
6500
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6429
6501
  this.clear();
6430
6502
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6431
6503
  }
6432
- getBestMatchLeaf() {
6433
- const { findList: targets } = this;
6434
- if (targets.length > 1) {
6504
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6505
+ if (list.length) {
6435
6506
  let find;
6436
- this.findList = [];
6507
+ this.findList = new LeafList();
6437
6508
  const { x, y } = this.point;
6438
6509
  const point = { x, y, radiusX: 0, radiusY: 0 };
6439
- for (let i = 0, len = targets.length; i < len; i++) {
6440
- find = targets[i];
6441
- if (LeafHelper.worldHittable(find)) {
6510
+ for (let i = 0, len = list.length; i < len; i++) {
6511
+ find = list[i];
6512
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6442
6513
  this.hitChild(find, point);
6443
6514
  if (this.findList.length)
6444
- return this.findList[0];
6515
+ return this.findList.list[0];
6445
6516
  }
6446
6517
  }
6447
6518
  }
6448
- return targets[0];
6519
+ if (bottomList) {
6520
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6521
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6522
+ if (this.findList.length)
6523
+ return this.findList.list[0];
6524
+ }
6525
+ }
6526
+ return list[0];
6449
6527
  }
6450
6528
  getPath(leaf) {
6451
6529
  const path = new LeafList();
@@ -6487,6 +6565,9 @@ class Picker {
6487
6565
  }
6488
6566
  return throughPath;
6489
6567
  }
6568
+ hitBranch(branch) {
6569
+ this.eachFind(branch.children, branch.__onlyHitMask);
6570
+ }
6490
6571
  eachFind(children, hitMask) {
6491
6572
  let child, hit;
6492
6573
  const { point } = this, len = children.length;
@@ -6508,11 +6589,11 @@ class Picker {
6508
6589
  }
6509
6590
  }
6510
6591
  }
6511
- hitChild(child, point) {
6592
+ hitChild(child, point, proxy) {
6512
6593
  if (this.exclude && this.exclude.has(child))
6513
6594
  return;
6514
6595
  if (child.__hitWorld(point))
6515
- this.findList.push(child);
6596
+ this.findList.add(proxy || child);
6516
6597
  }
6517
6598
  clear() {
6518
6599
  this.point = null;
@@ -6525,6 +6606,7 @@ class Picker {
6525
6606
  }
6526
6607
 
6527
6608
  const { Yes, NoAndSkip, YesAndSkip } = Answer;
6609
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
6528
6610
  class Selector {
6529
6611
  constructor(target, userConfig) {
6530
6612
  this.config = {};
@@ -6534,7 +6616,8 @@ class Selector {
6534
6616
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6535
6617
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6536
6618
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6537
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6619
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6620
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
6538
6621
  };
6539
6622
  this.target = target;
6540
6623
  if (userConfig)
@@ -6550,12 +6633,25 @@ class Selector {
6550
6633
  case 'string':
6551
6634
  switch (condition[0]) {
6552
6635
  case '#':
6553
- const leaf = this.getById(condition.substring(1), branch);
6554
- return one ? leaf : (leaf ? [leaf] : []);
6636
+ idCondition.id = condition.substring(1), condition = idCondition;
6637
+ break;
6555
6638
  case '.':
6556
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
6639
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
6640
+ break;
6557
6641
  default:
6558
- return this.getByMethod(this.methods.tag, branch, one, condition);
6642
+ tagCondition.tag = condition, condition = tagCondition;
6643
+ }
6644
+ case 'object':
6645
+ if (condition.id !== undefined) {
6646
+ const leaf = this.getById(condition.id, branch);
6647
+ return one ? leaf : (leaf ? [leaf] : []);
6648
+ }
6649
+ else if (condition.tag) {
6650
+ const { tag } = condition, isArray = tag instanceof Array;
6651
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
6652
+ }
6653
+ else {
6654
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
6559
6655
  }
6560
6656
  case 'function':
6561
6657
  return this.getByMethod(condition, branch, one, options);
@@ -6710,7 +6806,11 @@ function zoomLayerType() {
6710
6806
  defineKey(target, key, {
6711
6807
  set(value) { if (this.isLeafer)
6712
6808
  this[privateKey] = value; },
6713
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6809
+ get() {
6810
+ return this.isApp
6811
+ ? this.tree.zoomLayer
6812
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6813
+ }
6714
6814
  });
6715
6815
  };
6716
6816
  }
@@ -6850,7 +6950,7 @@ class UIData extends LeafData {
6850
6950
  const UnitConvert = {
6851
6951
  number(value, percentRefer) {
6852
6952
  if (typeof value === 'object')
6853
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
6953
+ return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
6854
6954
  return value;
6855
6955
  }
6856
6956
  };
@@ -7116,6 +7216,9 @@ let UI = UI_1 = class UI extends Leaf {
7116
7216
  pen.set(this.path = this.__.path || []);
7117
7217
  return pen;
7118
7218
  }
7219
+ get editConfig() { return undefined; }
7220
+ get editOuter() { return 'EditTool'; }
7221
+ get editInner() { return 'PathEditor'; }
7119
7222
  constructor(data) {
7120
7223
  super(data);
7121
7224
  }
@@ -7128,7 +7231,9 @@ let UI = UI_1 = class UI extends Leaf {
7128
7231
  }
7129
7232
  createProxyData() { return undefined; }
7130
7233
  find(_condition, _options) { return undefined; }
7234
+ findTag(tag) { return this.find({ tag }); }
7131
7235
  findOne(_condition, _options) { return undefined; }
7236
+ findId(id) { return this.findOne({ id }); }
7132
7237
  getPath(curve, pathForRender) {
7133
7238
  this.__layout.update();
7134
7239
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
@@ -7177,7 +7282,8 @@ let UI = UI_1 = class UI extends Leaf {
7177
7282
  __drawPathByBox(drawer) {
7178
7283
  const { x, y, width, height } = this.__layout.boxBounds;
7179
7284
  if (this.__.cornerRadius) {
7180
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7285
+ const { cornerRadius } = this.__;
7286
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7181
7287
  }
7182
7288
  else {
7183
7289
  drawer.rect(x, y, width, height);
@@ -7198,6 +7304,9 @@ let UI = UI_1 = class UI extends Leaf {
7198
7304
  static registerData(data) {
7199
7305
  dataProcessor(data)(this.prototype);
7200
7306
  }
7307
+ static setEditConfig(_config) { }
7308
+ static setEditOuter(_toolName) { }
7309
+ static setEditInner(_editorName) { }
7201
7310
  destroy() {
7202
7311
  this.fill = this.stroke = null;
7203
7312
  super.destroy();
@@ -7275,21 +7384,84 @@ __decorate([
7275
7384
  __decorate([
7276
7385
  rotationType(0, true)
7277
7386
  ], UI.prototype, "skewY", void 0);
7387
+ __decorate([
7388
+ positionType(0, true)
7389
+ ], UI.prototype, "offsetX", void 0);
7390
+ __decorate([
7391
+ positionType(0, true)
7392
+ ], UI.prototype, "offsetY", void 0);
7393
+ __decorate([
7394
+ positionType(0, true)
7395
+ ], UI.prototype, "scrollX", void 0);
7396
+ __decorate([
7397
+ positionType(0, true)
7398
+ ], UI.prototype, "scrollY", void 0);
7399
+ __decorate([
7400
+ autoLayoutType()
7401
+ ], UI.prototype, "origin", void 0);
7278
7402
  __decorate([
7279
7403
  autoLayoutType()
7280
7404
  ], UI.prototype, "around", void 0);
7281
7405
  __decorate([
7282
7406
  dataType(false)
7283
- ], UI.prototype, "draggable", void 0);
7407
+ ], UI.prototype, "lazy", void 0);
7284
7408
  __decorate([
7285
- dataType(false)
7286
- ], UI.prototype, "editable", void 0);
7409
+ naturalBoundsType(1)
7410
+ ], UI.prototype, "pixelRatio", void 0);
7411
+ __decorate([
7412
+ pathInputType()
7413
+ ], UI.prototype, "path", void 0);
7414
+ __decorate([
7415
+ pathType()
7416
+ ], UI.prototype, "windingRule", void 0);
7417
+ __decorate([
7418
+ pathType(true)
7419
+ ], UI.prototype, "closed", void 0);
7420
+ __decorate([
7421
+ autoLayoutType(false)
7422
+ ], UI.prototype, "flow", void 0);
7423
+ __decorate([
7424
+ boundsType(0)
7425
+ ], UI.prototype, "padding", void 0);
7426
+ __decorate([
7427
+ boundsType(0)
7428
+ ], UI.prototype, "gap", void 0);
7429
+ __decorate([
7430
+ boundsType('top-left')
7431
+ ], UI.prototype, "align", void 0);
7432
+ __decorate([
7433
+ boundsType(false)
7434
+ ], UI.prototype, "wrap", void 0);
7435
+ __decorate([
7436
+ boundsType('box')
7437
+ ], UI.prototype, "itemBox", void 0);
7287
7438
  __decorate([
7288
- dataType('size')
7289
- ], UI.prototype, "editSize", void 0);
7439
+ boundsType(true)
7440
+ ], UI.prototype, "inFlow", void 0);
7441
+ __decorate([
7442
+ boundsType()
7443
+ ], UI.prototype, "autoWidth", void 0);
7444
+ __decorate([
7445
+ boundsType()
7446
+ ], UI.prototype, "autoHeight", void 0);
7447
+ __decorate([
7448
+ boundsType()
7449
+ ], UI.prototype, "autoBox", void 0);
7450
+ __decorate([
7451
+ boundsType()
7452
+ ], UI.prototype, "widthRange", void 0);
7453
+ __decorate([
7454
+ boundsType()
7455
+ ], UI.prototype, "heightRange", void 0);
7456
+ __decorate([
7457
+ dataType(false)
7458
+ ], UI.prototype, "draggable", void 0);
7290
7459
  __decorate([
7291
7460
  dataType()
7292
- ], UI.prototype, "editorStyle", void 0);
7461
+ ], UI.prototype, "dragBounds", void 0);
7462
+ __decorate([
7463
+ dataType(false)
7464
+ ], UI.prototype, "editable", void 0);
7293
7465
  __decorate([
7294
7466
  hitType(true)
7295
7467
  ], UI.prototype, "hittable", void 0);
@@ -7344,21 +7516,6 @@ __decorate([
7344
7516
  __decorate([
7345
7517
  strokeType(10)
7346
7518
  ], UI.prototype, "miterLimit", void 0);
7347
- __decorate([
7348
- dataType(false)
7349
- ], UI.prototype, "lazy", void 0);
7350
- __decorate([
7351
- naturalBoundsType(1)
7352
- ], UI.prototype, "pixelRatio", void 0);
7353
- __decorate([
7354
- pathInputType()
7355
- ], UI.prototype, "path", void 0);
7356
- __decorate([
7357
- pathType()
7358
- ], UI.prototype, "windingRule", void 0);
7359
- __decorate([
7360
- pathType(true)
7361
- ], UI.prototype, "closed", void 0);
7362
7519
  __decorate([
7363
7520
  arrowType('none')
7364
7521
  ], UI.prototype, "startArrow", void 0);
@@ -7481,7 +7638,6 @@ Group = __decorate([
7481
7638
  var Leafer_1;
7482
7639
  const debug$3 = Debug.get('Leafer');
7483
7640
  let Leafer = Leafer_1 = class Leafer extends Group {
7484
- static get version() { return '1.0.0-rc.21'; }
7485
7641
  get __tag() { return 'Leafer'; }
7486
7642
  get isApp() { return false; }
7487
7643
  get app() { return this.parent || this; }
@@ -7534,7 +7690,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7534
7690
  if (this.isApp)
7535
7691
  this.__setApp();
7536
7692
  this.__checkAutoLayout(config);
7537
- this.updateLazyBounds();
7538
7693
  this.view = canvas.view;
7539
7694
  if (parentApp) {
7540
7695
  this.__bindApp(parentApp);
@@ -7594,9 +7749,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7594
7749
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7595
7750
  Object.keys(data).forEach(key => this[key] = data[key]);
7596
7751
  }
7597
- forceFullRender() {
7598
- this.forceRender();
7599
- }
7600
7752
  forceRender(bounds) {
7601
7753
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7602
7754
  if (this.viewReady)
@@ -7674,7 +7826,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7674
7826
  this.canvas.backgroundColor = newValue;
7675
7827
  }
7676
7828
  else {
7677
- this.forceFullRender();
7829
+ this.forceRender();
7678
7830
  }
7679
7831
  }
7680
7832
  __onCreated() {
@@ -7778,6 +7930,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7778
7930
  __listenEvents() {
7779
7931
  const runId = Run.start('FirstCreate ' + this.innerName);
7780
7932
  this.once(LeaferEvent.START, () => Run.end(runId));
7933
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7781
7934
  this.once(LayoutEvent.END, () => this.__onReady());
7782
7935
  this.once(RenderEvent.START, () => this.__onCreated());
7783
7936
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7848,8 +8001,8 @@ Rect = __decorate([
7848
8001
  registerUI()
7849
8002
  ], Rect);
7850
8003
 
7851
- const rect = Rect.prototype;
7852
- const group = Group.prototype;
8004
+ const rect$1 = Rect.prototype;
8005
+ const group$1 = Group.prototype;
7853
8006
  const bounds$1 = {};
7854
8007
  const { copy: copy$3, add } = BoundsHelper;
7855
8008
  let Box = class Box extends Group {
@@ -7884,6 +8037,8 @@ let Box = class Box extends Group {
7884
8037
  else {
7885
8038
  this.__updateRectBoxBounds();
7886
8039
  }
8040
+ if (data.flow)
8041
+ this.__updateContentBounds();
7887
8042
  }
7888
8043
  __updateStrokeBounds() { }
7889
8044
  __updateRenderBounds() {
@@ -7928,28 +8083,28 @@ __decorate([
7928
8083
  affectRenderBoundsType('show')
7929
8084
  ], Box.prototype, "overflow", void 0);
7930
8085
  __decorate([
7931
- rewrite(rect.__updateStrokeSpread)
8086
+ rewrite(rect$1.__updateStrokeSpread)
7932
8087
  ], Box.prototype, "__updateStrokeSpread", null);
7933
8088
  __decorate([
7934
- rewrite(rect.__updateRenderSpread)
8089
+ rewrite(rect$1.__updateRenderSpread)
7935
8090
  ], Box.prototype, "__updateRectRenderSpread", null);
7936
8091
  __decorate([
7937
- rewrite(rect.__updateBoxBounds)
8092
+ rewrite(rect$1.__updateBoxBounds)
7938
8093
  ], Box.prototype, "__updateRectBoxBounds", null);
7939
8094
  __decorate([
7940
- rewrite(rect.__updateStrokeBounds)
8095
+ rewrite(rect$1.__updateStrokeBounds)
7941
8096
  ], Box.prototype, "__updateStrokeBounds", null);
7942
8097
  __decorate([
7943
- rewrite(rect.__updateRenderBounds)
8098
+ rewrite(rect$1.__updateRenderBounds)
7944
8099
  ], Box.prototype, "__updateRectRenderBounds", null);
7945
8100
  __decorate([
7946
- rewrite(rect.__updateChange)
8101
+ rewrite(rect$1.__updateChange)
7947
8102
  ], Box.prototype, "__updateRectChange", null);
7948
8103
  __decorate([
7949
- rewrite(rect.__render)
8104
+ rewrite(rect$1.__render)
7950
8105
  ], Box.prototype, "__renderRect", null);
7951
8106
  __decorate([
7952
- rewrite(group.__render)
8107
+ rewrite(group$1.__render)
7953
8108
  ], Box.prototype, "__renderGroup", null);
7954
8109
  Box = __decorate([
7955
8110
  rewriteAble(),
@@ -8293,9 +8448,10 @@ Canvas = __decorate([
8293
8448
  registerUI()
8294
8449
  ], Canvas);
8295
8450
 
8296
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8451
+ const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8297
8452
  let Text = class Text extends UI {
8298
8453
  get __tag() { return 'Text'; }
8454
+ get editInner() { return 'TextEditor'; }
8299
8455
  get textDrawData() {
8300
8456
  this.__layout.update();
8301
8457
  return this.__.__textDrawData;
@@ -8365,7 +8521,7 @@ let Text = class Text extends UI {
8365
8521
  if (italic)
8366
8522
  b.width += fontSize * 0.16;
8367
8523
  const contentBounds = includes(b, bounds) ? b : bounds;
8368
- if (contentBounds !== layout.contentBounds) {
8524
+ if (!isSame$1(contentBounds, layout.contentBounds)) {
8369
8525
  layout.contentBounds = contentBounds;
8370
8526
  layout.renderChanged = true;
8371
8527
  setList(data.__textBoxBounds = {}, [b, bounds]);
@@ -8393,9 +8549,6 @@ __decorate([
8393
8549
  __decorate([
8394
8550
  boundsType(0)
8395
8551
  ], Text.prototype, "height", void 0);
8396
- __decorate([
8397
- boundsType(0)
8398
- ], Text.prototype, "padding", void 0);
8399
8552
  __decorate([
8400
8553
  surfaceType('#000000')
8401
8554
  ], Text.prototype, "fill", void 0);
@@ -8524,7 +8677,7 @@ function penPathType() {
8524
8677
  };
8525
8678
  }
8526
8679
 
8527
- const version = "1.0.0-rc.21";
8680
+ const version = "1.0.0-rc.23";
8528
8681
 
8529
8682
  let App = class App extends Leafer {
8530
8683
  get __tag() { return 'App'; }
@@ -8618,7 +8771,10 @@ let App = class App extends Leafer {
8618
8771
  this.renderer.update();
8619
8772
  }
8620
8773
  __render(canvas, options) {
8621
- canvas.setWorld(options.matrix || this.__world);
8774
+ if (options.matrix) {
8775
+ const { a, b, c, d, e, f } = options.matrix;
8776
+ canvas.setTransform(a, b, c, d, e, f);
8777
+ }
8622
8778
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8623
8779
  }
8624
8780
  __onResize(event) {
@@ -8740,6 +8896,35 @@ let DragEvent = class DragEvent extends PointerEvent {
8740
8896
  static setData(data) {
8741
8897
  this.data = data;
8742
8898
  }
8899
+ static getValidMove(leaf, start, total) {
8900
+ const { draggable, dragBounds, x, y } = leaf;
8901
+ const move = leaf.getLocalPoint(total, null, true);
8902
+ move.x += start.x - x;
8903
+ move.y += start.y - y;
8904
+ if (dragBounds)
8905
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8906
+ if (draggable === 'x')
8907
+ move.y = 0;
8908
+ if (draggable === 'y')
8909
+ move.x = 0;
8910
+ return move;
8911
+ }
8912
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8913
+ const x = box.x + move.x, y = box.y + move.y;
8914
+ const right = x + box.width, bottom = y + box.height;
8915
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8916
+ if (!change)
8917
+ move = Object.assign({}, move);
8918
+ if (x < dragBounds.x)
8919
+ move.x += dragBounds.x - x;
8920
+ else if (right > boundsRight)
8921
+ move.x += boundsRight - right;
8922
+ if (y < dragBounds.y)
8923
+ move.y += dragBounds.y - y;
8924
+ else if (bottom > boundsBottom)
8925
+ move.y += boundsBottom - bottom;
8926
+ return move;
8927
+ }
8743
8928
  getPageMove(total) {
8744
8929
  this.assignMove(total);
8745
8930
  return this.current.getPagePoint(move, null, true);
@@ -8849,9 +9034,7 @@ function addInteractionWindow(leafer) {
8849
9034
  if (leafer.isApp)
8850
9035
  return;
8851
9036
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
8852
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8853
- if (x || y)
8854
- leafer.zoomLayer.move(x, y);
9037
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8855
9038
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
8856
9039
  const { zoomLayer } = leafer;
8857
9040
  const changeScale = leafer.getValidScale(e.scale);
@@ -9120,9 +9303,14 @@ class Dragger {
9120
9303
  if (this.dragging) {
9121
9304
  this.interaction.emit(DragEvent.START, this.dragData);
9122
9305
  this.getDragableList(this.dragData.path);
9306
+ this.setDragStartPoints(this.realDragableList = this.getList());
9123
9307
  }
9124
9308
  }
9125
9309
  }
9310
+ setDragStartPoints(list) {
9311
+ this.dragStartPoints = {};
9312
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9313
+ }
9126
9314
  getDragableList(path) {
9127
9315
  let leaf;
9128
9316
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9152,10 +9340,10 @@ class Dragger {
9152
9340
  }
9153
9341
  dragReal() {
9154
9342
  const { running } = this.interaction;
9155
- const list = this.getList();
9343
+ const list = this.realDragableList;
9156
9344
  if (list.length && running) {
9157
- const { moveX, moveY } = this.dragData;
9158
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9345
+ const { totalX, totalY } = this.dragData;
9346
+ list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9159
9347
  }
9160
9348
  }
9161
9349
  dragOverOrOut(data) {
@@ -9624,7 +9812,8 @@ class InteractionBase {
9624
9812
  }
9625
9813
  findPath(data, options) {
9626
9814
  const { hitRadius, through } = this.config.pointer;
9627
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9815
+ const { bottomList } = this;
9816
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9628
9817
  if (find.throughPath)
9629
9818
  data.throughPath = find.throughPath;
9630
9819
  data.path = find.path;
@@ -9637,7 +9826,7 @@ class InteractionBase {
9637
9826
  const app = this.target.app;
9638
9827
  if (!app || !app.isApp)
9639
9828
  return false;
9640
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9829
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9641
9830
  }
9642
9831
  checkPath(data, useDefaultPath) {
9643
9832
  if (useDefaultPath || this.canMove(data))
@@ -9703,7 +9892,7 @@ class InteractionBase {
9703
9892
  const { path } = data;
9704
9893
  for (let i = 0, len = path.length; i < len; i++) {
9705
9894
  leaf = path.list[i];
9706
- cursor = leaf.cursor;
9895
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9707
9896
  if (cursor)
9708
9897
  break;
9709
9898
  }
@@ -9861,6 +10050,8 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9861
10050
  const inner = {};
9862
10051
  const leaf = Leaf.prototype;
9863
10052
  leaf.__hitWorld = function (point) {
10053
+ if (!this.__.hitSelf)
10054
+ return false;
9864
10055
  if (this.__.hitRadius) {
9865
10056
  copy$2(inner, point), point = inner;
9866
10057
  setRadius(point, this.__.hitRadius);
@@ -9888,8 +10079,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
9888
10079
  this.__drawRenderPath(canvas); };
9889
10080
 
9890
10081
  const matrix = new Matrix();
9891
- const ui$1 = UI.prototype;
9892
- ui$1.__updateHitCanvas = function () {
10082
+ const ui$2 = UI.prototype;
10083
+ ui$2.__updateHitCanvas = function () {
9893
10084
  const data = this.__, { hitCanvasManager } = this.leafer;
9894
10085
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9895
10086
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9916,7 +10107,7 @@ ui$1.__updateHitCanvas = function () {
9916
10107
  this.__drawHitPath(h);
9917
10108
  h.setStrokeOptions(data);
9918
10109
  };
9919
- ui$1.__hit = function (inner) {
10110
+ ui$2.__hit = function (inner) {
9920
10111
  if (Platform.name === 'miniapp')
9921
10112
  this.__drawHitPath(this.__hitCanvas);
9922
10113
  const data = this.__;
@@ -9956,22 +10147,24 @@ ui$1.__hit = function (inner) {
9956
10147
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9957
10148
  };
9958
10149
 
9959
- const ui = new UI();
9960
- Rect.prototype.__updateHitCanvas = function () {
10150
+ const ui$1 = new UI();
10151
+ const rect = Rect.prototype;
10152
+ rect.__updateHitCanvas = function () {
9961
10153
  if (this.stroke || this.cornerRadius)
9962
- ui.__updateHitCanvas.call(this);
10154
+ ui$1.__updateHitCanvas.call(this);
9963
10155
  };
9964
- Rect.prototype.__hitFill = function (inner) {
9965
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10156
+ rect.__hitFill = function (inner) {
10157
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9966
10158
  };
9967
10159
 
9968
- UI.prototype.find = function (condition, options) {
10160
+ const ui = UI.prototype, group = Group.prototype;
10161
+ ui.find = function (condition, options) {
9969
10162
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9970
10163
  };
9971
- UI.prototype.findOne = function (condition, options) {
10164
+ ui.findOne = function (condition, options) {
9972
10165
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9973
10166
  };
9974
- Group.prototype.pick = function (hitPoint, options) {
10167
+ group.pick = function (hitPoint, options) {
9975
10168
  this.__layout.update();
9976
10169
  if (!options)
9977
10170
  options = {};
@@ -10544,7 +10737,7 @@ function shape(ui, current, options) {
10544
10737
  }
10545
10738
  else {
10546
10739
  const { renderShapeSpread: spread } = ui.__layout;
10547
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
10740
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
10548
10741
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
10549
10742
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
10550
10743
  if (fitMatrix.a < 1) {
@@ -10627,79 +10820,75 @@ const PaintModule = {
10627
10820
 
10628
10821
  let origin = {};
10629
10822
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10630
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10823
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10631
10824
  const transform = get$4();
10632
- const swap = rotation && rotation !== 180;
10633
- const sw = box.width / (swap ? height : width);
10634
- const sh = box.height / (swap ? width : height);
10635
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10636
- const x = box.x + (box.width - width * scale) / 2;
10637
- const y = box.y + (box.height - height * scale) / 2;
10638
- translate$1(transform, x, y);
10639
- scaleHelper(transform, scale);
10825
+ translate$1(transform, box.x + x, box.y + y);
10826
+ scaleHelper(transform, scaleX, scaleY);
10640
10827
  if (rotation)
10641
10828
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10642
- data.scaleX = data.scaleY = scale;
10643
10829
  data.transform = transform;
10644
10830
  }
10645
10831
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10646
10832
  const transform = get$4();
10647
- translate$1(transform, box.x, box.y);
10648
- if (x || y)
10649
- translate$1(transform, x, y);
10650
- if (scaleX) {
10833
+ translate$1(transform, box.x + x, box.y + y);
10834
+ if (scaleX)
10651
10835
  scaleHelper(transform, scaleX, scaleY);
10652
- data.scaleX = transform.a;
10653
- data.scaleY = transform.d;
10654
- }
10655
10836
  if (rotation)
10656
10837
  rotate(transform, rotation);
10657
10838
  data.transform = transform;
10658
10839
  }
10659
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10840
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
10660
10841
  const transform = get$4();
10661
10842
  if (rotation) {
10662
- rotate(transform, rotation);
10663
- switch (rotation) {
10664
- case 90:
10665
- translate$1(transform, height, 0);
10666
- break;
10667
- case 180:
10668
- translate$1(transform, width, height);
10669
- break;
10670
- case 270:
10671
- translate$1(transform, 0, width);
10672
- break;
10843
+ if (align === 'center') {
10844
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10845
+ }
10846
+ else {
10847
+ rotate(transform, rotation);
10848
+ switch (rotation) {
10849
+ case 90:
10850
+ translate$1(transform, height, 0);
10851
+ break;
10852
+ case 180:
10853
+ translate$1(transform, width, height);
10854
+ break;
10855
+ case 270:
10856
+ translate$1(transform, 0, width);
10857
+ break;
10858
+ }
10673
10859
  }
10674
10860
  }
10675
- origin.x = box.x;
10676
- origin.y = box.y;
10677
- if (x || y)
10678
- origin.x += x, origin.y += y;
10861
+ origin.x = box.x + x;
10862
+ origin.y = box.y + y;
10679
10863
  translate$1(transform, origin.x, origin.y);
10680
- if (scaleX) {
10864
+ if (scaleX)
10681
10865
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10682
- data.scaleX = scaleX;
10683
- data.scaleY = scaleY;
10684
- }
10685
10866
  data.transform = transform;
10686
10867
  }
10687
10868
 
10688
10869
  const { get: get$3, translate } = MatrixHelper;
10689
10870
  const tempBox = new Bounds();
10871
+ const tempPoint = {};
10690
10872
  function createData(leafPaint, image, paint, box) {
10691
10873
  let { width, height } = image;
10692
10874
  if (paint.padding)
10693
10875
  box = tempBox.set(box).shrink(paint.padding);
10694
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10876
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
10695
10877
  const sameBox = box.width === width && box.height === height;
10696
10878
  if (blendMode)
10697
10879
  leafPaint.blendMode = blendMode;
10698
10880
  const data = leafPaint.data = { mode };
10699
- let x, y, scaleX, scaleY;
10700
- if (offset)
10701
- x = offset.x, y = offset.y;
10702
- if (size) {
10881
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10882
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10883
+ let x = 0, y = 0, scaleX, scaleY;
10884
+ if (!mode || mode === 'cover' || mode === 'fit') {
10885
+ if (!sameBox || rotation) {
10886
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10887
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10888
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10889
+ }
10890
+ }
10891
+ else if (size) {
10703
10892
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10704
10893
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10705
10894
  }
@@ -10707,26 +10896,36 @@ function createData(leafPaint, image, paint, box) {
10707
10896
  scaleX = typeof scale === 'number' ? scale : scale.x;
10708
10897
  scaleY = typeof scale === 'number' ? scale : scale.y;
10709
10898
  }
10899
+ if (align) {
10900
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10901
+ if (scaleX)
10902
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10903
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
10904
+ x += tempPoint.x, y += tempPoint.y;
10905
+ }
10906
+ if (offset)
10907
+ x += offset.x, y += offset.y;
10710
10908
  switch (mode) {
10711
10909
  case 'strench':
10712
10910
  if (!sameBox)
10713
10911
  width = box.width, height = box.height;
10714
10912
  break;
10913
+ case 'normal':
10715
10914
  case 'clip':
10716
- if (offset || scaleX || rotation)
10915
+ if (x || y || scaleX || rotation)
10717
10916
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10718
10917
  break;
10719
10918
  case 'repeat':
10720
10919
  if (!sameBox || scaleX || rotation)
10721
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10920
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10722
10921
  if (!repeat)
10723
10922
  data.repeat = 'repeat';
10724
10923
  break;
10725
10924
  case 'fit':
10726
10925
  case 'cover':
10727
10926
  default:
10728
- if (!sameBox || rotation)
10729
- fillOrFitMode(data, mode, box, width, height, rotation);
10927
+ if (scaleX)
10928
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10730
10929
  }
10731
10930
  if (!data.transform) {
10732
10931
  if (box.x || box.y) {
@@ -10734,6 +10933,10 @@ function createData(leafPaint, image, paint, box) {
10734
10933
  translate(data.transform, box.x, box.y);
10735
10934
  }
10736
10935
  }
10936
+ if (scaleX && mode !== 'strench') {
10937
+ data.scaleX = scaleX;
10938
+ data.scaleY = scaleY;
10939
+ }
10737
10940
  data.width = width;
10738
10941
  data.height = height;
10739
10942
  if (opacity)
@@ -11631,11 +11834,13 @@ function clipText(drawData, style) {
11631
11834
  const { rows, overflow } = drawData;
11632
11835
  let { textOverflow } = style;
11633
11836
  rows.splice(overflow);
11634
- if (textOverflow !== 'hide') {
11635
- if (textOverflow === 'ellipsis')
11837
+ if (textOverflow && textOverflow !== 'show') {
11838
+ if (textOverflow === 'hide')
11839
+ textOverflow = '';
11840
+ else if (textOverflow === 'ellipsis')
11636
11841
  textOverflow = '...';
11637
11842
  let char, charRight;
11638
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
11843
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
11639
11844
  const right = style.x + style.width - ellipsisWidth;
11640
11845
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
11641
11846
  list.forEach(row => {
@@ -11789,6 +11994,13 @@ const ExportModule = {
11789
11994
  resolve();
11790
11995
  this.running = false;
11791
11996
  };
11997
+ if (filename === 'json') {
11998
+ return over({ data: leaf.toJSON() });
11999
+ }
12000
+ else if (FileHelper.fileType(filename) === 'json') {
12001
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
12002
+ return over({ data: true });
12003
+ }
11792
12004
  const { leafer } = leaf;
11793
12005
  if (leafer) {
11794
12006
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -11796,8 +12008,12 @@ const ExportModule = {
11796
12008
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11797
12009
  const { worldTransform, isLeafer, isFrame } = leaf;
11798
12010
  const { slice, trim, onCanvas } = options;
11799
- const scale = options.scale || 1;
11800
- const pixelRatio = options.pixelRatio || 1;
12011
+ let scale = options.scale || 1;
12012
+ let pixelRatio = options.pixelRatio || 1;
12013
+ if (leaf.isApp) {
12014
+ scale *= pixelRatio;
12015
+ pixelRatio = leaf.app.pixelRatio;
12016
+ }
11801
12017
  const screenshot = options.screenshot || leaf.isApp;
11802
12018
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11803
12019
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -11938,4 +12154,4 @@ window.addEventListener('unload', () => {
11938
12154
  ImageManager.destroy();
11939
12155
  });
11940
12156
 
11941
- export { AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, zoomLayerType };
12157
+ export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, zoomLayerType };