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.
package/dist/web.js CHANGED
@@ -6,7 +6,7 @@ var LeaferUI = (function (exports) {
6
6
  hitCanvasSize: 100,
7
7
  maxCacheSize: 2560 * 1600,
8
8
  maxPatternSize: 4096 * 2160,
9
- suffix: 'leaf',
9
+ suffix: '',
10
10
  crossOrigin: 'anonymous'
11
11
  }
12
12
  };
@@ -36,24 +36,12 @@ var LeaferUI = (function (exports) {
36
36
  const { round, pow: pow$1, PI: PI$4 } = Math;
37
37
  const MathHelper = {
38
38
  within(value, min, max) {
39
- if (value < min)
39
+ if (min !== undefined && value < min)
40
40
  value = min;
41
- if (value > max)
41
+ if (max !== undefined && value > max)
42
42
  value = max;
43
43
  return value;
44
44
  },
45
- minus(value, isFourNumber) {
46
- if (value instanceof Array) {
47
- if (isFourNumber)
48
- value = MathHelper.fourNumber(value, 0);
49
- for (let i = 0; i < value.length; i++)
50
- value[i] = -value[i];
51
- }
52
- else {
53
- value = -value;
54
- }
55
- return value;
56
- },
57
45
  fourNumber(num, maxValue) {
58
46
  let data;
59
47
  if (num instanceof Array) {
@@ -120,7 +108,7 @@ var LeaferUI = (function (exports) {
120
108
 
121
109
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
122
110
  const { float: float$1 } = MathHelper;
123
- const tempPoint$3 = {};
111
+ const tempPoint$4 = {};
124
112
  function getWorld() {
125
113
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
126
114
  }
@@ -150,9 +138,11 @@ var LeaferUI = (function (exports) {
150
138
  t.e += x;
151
139
  t.f += y;
152
140
  },
153
- translateInner(t, x, y) {
141
+ translateInner(t, x, y, isMoveOrigin) {
154
142
  t.e += t.a * x + t.c * y;
155
143
  t.f += t.b * x + t.d * y;
144
+ if (isMoveOrigin)
145
+ t.e -= x, t.f -= y;
156
146
  },
157
147
  scale(t, scaleX, scaleY = scaleX) {
158
148
  t.a *= scaleX;
@@ -161,8 +151,8 @@ var LeaferUI = (function (exports) {
161
151
  t.d *= scaleY;
162
152
  },
163
153
  scaleOfOuter(t, origin, scaleX, scaleY) {
164
- M$6.toInnerPoint(t, origin, tempPoint$3);
165
- M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
154
+ M$6.toInnerPoint(t, origin, tempPoint$4);
155
+ M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
166
156
  },
167
157
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
168
158
  M$6.translateInner(t, origin.x, origin.y);
@@ -180,8 +170,8 @@ var LeaferUI = (function (exports) {
180
170
  t.d = c * sinR + d * cosR;
181
171
  },
182
172
  rotateOfOuter(t, origin, rotation) {
183
- M$6.toInnerPoint(t, origin, tempPoint$3);
184
- M$6.rotateOfInner(t, tempPoint$3, rotation);
173
+ M$6.toInnerPoint(t, origin, tempPoint$4);
174
+ M$6.rotateOfInner(t, tempPoint$4, rotation);
185
175
  },
186
176
  rotateOfInner(t, origin, rotation) {
187
177
  M$6.translateInner(t, origin.x, origin.y);
@@ -202,8 +192,8 @@ var LeaferUI = (function (exports) {
202
192
  }
203
193
  },
204
194
  skewOfOuter(t, origin, skewX, skewY) {
205
- M$6.toInnerPoint(t, origin, tempPoint$3);
206
- M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
195
+ M$6.toInnerPoint(t, origin, tempPoint$4);
196
+ M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
207
197
  },
208
198
  skewOfInner(t, origin, skewX, skewY = 0) {
209
199
  M$6.translateInner(t, origin.x, origin.y);
@@ -219,8 +209,10 @@ var LeaferUI = (function (exports) {
219
209
  t.e = child.e * a + child.f * c + e;
220
210
  t.f = child.e * b + child.f * d + f;
221
211
  },
222
- multiplyParent(t, parent, to, abcdChanged, childScaleData) {
223
- const { e, f } = t;
212
+ multiplyParent(t, parent, to, abcdChanged, childScaleData, scrollData) {
213
+ let { e, f } = t;
214
+ if (scrollData)
215
+ e += scrollData.scrollX, f += scrollData.scrollY;
224
216
  to || (to = t);
225
217
  if (abcdChanged === undefined)
226
218
  abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
@@ -341,7 +333,7 @@ var LeaferUI = (function (exports) {
341
333
  t.e = x;
342
334
  t.f = y;
343
335
  if (origin)
344
- M$6.translateInner(t, -origin.x, -origin.y);
336
+ M$6.translateInner(t, -origin.x, -origin.y, true);
345
337
  },
346
338
  getLayout(t, origin, firstSkewY) {
347
339
  const { a, b, c, d, e, f } = t;
@@ -597,7 +589,7 @@ var LeaferUI = (function (exports) {
597
589
  return this;
598
590
  }
599
591
  }
600
- const tempPoint$2 = new Point();
592
+ const tempPoint$3 = new Point();
601
593
 
602
594
  class Matrix {
603
595
  constructor(a, b, c, d, e, f) {
@@ -761,7 +753,7 @@ var LeaferUI = (function (exports) {
761
753
  const { floor, ceil: ceil$2 } = Math;
762
754
  let right$1, bottom$1, boundsRight, boundsBottom;
763
755
  const point = {};
764
- const toPoint$1 = {};
756
+ const toPoint$2 = {};
765
757
  const BoundsHelper = {
766
758
  tempBounds: {},
767
759
  set(t, x = 0, y = 0, width = 0, height = 0) {
@@ -776,15 +768,17 @@ var LeaferUI = (function (exports) {
776
768
  t.width = bounds.width;
777
769
  t.height = bounds.height;
778
770
  },
779
- copyAndSpread(t, bounds, spreadX, spreadY) {
780
- if (spreadX instanceof Array) {
781
- const four = fourNumber(spreadX);
782
- B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
771
+ copyAndSpread(t, bounds, spread, isShrink) {
772
+ if (spread instanceof Array) {
773
+ const four = fourNumber(spread);
774
+ isShrink
775
+ ? B.set(t, bounds.x + four[3], bounds.y + four[0], bounds.width - four[1] - four[3], bounds.height - four[2] - four[0])
776
+ : B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
783
777
  }
784
778
  else {
785
- if (!spreadY)
786
- spreadY = spreadX;
787
- B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
779
+ if (isShrink)
780
+ spread = -spread;
781
+ B.set(t, bounds.x - spread, bounds.y - spread, bounds.width + spread * 2, bounds.height + spread * 2);
788
782
  }
789
783
  },
790
784
  minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
@@ -861,17 +855,17 @@ var LeaferUI = (function (exports) {
861
855
  else {
862
856
  point.x = t.x;
863
857
  point.y = t.y;
864
- toOuterPoint$1(matrix, point, toPoint$1);
865
- setPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
858
+ toOuterPoint$1(matrix, point, toPoint$2);
859
+ setPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
866
860
  point.x = t.x + t.width;
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.y = t.y + t.height;
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
  point.x = t.x;
873
- toOuterPoint$1(matrix, point, toPoint$1);
874
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
867
+ toOuterPoint$1(matrix, point, toPoint$2);
868
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.y);
875
869
  toBounds$4(tempPointBounds$1, to);
876
870
  }
877
871
  },
@@ -884,13 +878,16 @@ var LeaferUI = (function (exports) {
884
878
  const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
885
879
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
886
880
  },
887
- getSpread(t, spreadX, spreadY) {
881
+ getSpread(t, spread) {
888
882
  const n = {};
889
- B.copyAndSpread(n, t, spreadX, spreadY);
883
+ B.copyAndSpread(n, t, spread);
890
884
  return n;
891
885
  },
892
- spread(t, spreadX, spreadY = spreadX) {
893
- B.copyAndSpread(t, t, spreadX, spreadY);
886
+ spread(t, spread) {
887
+ B.copyAndSpread(t, t, spread);
888
+ },
889
+ shrink(t, shrink) {
890
+ B.copyAndSpread(t, t, shrink, true);
894
891
  },
895
892
  ceil(t) {
896
893
  const { x, y } = t;
@@ -1070,12 +1067,12 @@ var LeaferUI = (function (exports) {
1070
1067
  getFitMatrix(put, baseScale) {
1071
1068
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1072
1069
  }
1073
- spread(fourNumber, spreadY) {
1074
- BoundsHelper.spread(this, fourNumber, spreadY);
1070
+ spread(fourNumber) {
1071
+ BoundsHelper.spread(this, fourNumber);
1075
1072
  return this;
1076
1073
  }
1077
1074
  shrink(fourNumber) {
1078
- BoundsHelper.spread(this, MathHelper.minus(fourNumber, true));
1075
+ BoundsHelper.shrink(this, fourNumber);
1079
1076
  return this;
1080
1077
  }
1081
1078
  ceil() {
@@ -1192,6 +1189,10 @@ var LeaferUI = (function (exports) {
1192
1189
  Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1193
1190
  Direction9[Direction9["left"] = 7] = "left";
1194
1191
  Direction9[Direction9["center"] = 8] = "center";
1192
+ Direction9[Direction9["top-left"] = 0] = "top-left";
1193
+ Direction9[Direction9["top-right"] = 2] = "top-right";
1194
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1195
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1195
1196
  })(exports.Direction9 || (exports.Direction9 = {}));
1196
1197
 
1197
1198
  const directionData = [
@@ -1205,15 +1206,28 @@ var LeaferUI = (function (exports) {
1205
1206
  { x: 0, y: 0.5 },
1206
1207
  { x: 0.5, y: 0.5 }
1207
1208
  ];
1209
+ directionData.forEach(item => item.type = 'percent');
1208
1210
  const AroundHelper = {
1209
1211
  directionData,
1210
1212
  tempPoint: {},
1211
1213
  get: get$5,
1212
- toPoint(around, bounds, to, onlySize) {
1214
+ toPoint(around, bounds, to, onlySize, pointBounds) {
1213
1215
  to || (to = {});
1214
1216
  const point = get$5(around);
1215
- to.x = point.x * bounds.width;
1216
- to.y = point.y * bounds.height;
1217
+ to.x = point.x;
1218
+ to.y = point.y;
1219
+ if (point.type === 'percent') {
1220
+ to.x *= bounds.width;
1221
+ to.y *= bounds.height;
1222
+ if (pointBounds) {
1223
+ to.x -= pointBounds.x;
1224
+ to.y -= pointBounds.y;
1225
+ if (point.x)
1226
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1227
+ if (point.y)
1228
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1229
+ }
1230
+ }
1217
1231
  if (!onlySize) {
1218
1232
  to.x += bounds.x;
1219
1233
  to.y += bounds.y;
@@ -1224,6 +1238,13 @@ var LeaferUI = (function (exports) {
1224
1238
  return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
1225
1239
  }
1226
1240
 
1241
+ const { toPoint: toPoint$1 } = AroundHelper;
1242
+ const AlignHelper = {
1243
+ toPoint(align, contentBounds, bounds, to, onlySize) {
1244
+ toPoint$1(align, bounds, to, onlySize, contentBounds);
1245
+ }
1246
+ };
1247
+
1227
1248
  const StringNumberMap = {
1228
1249
  '0': 1,
1229
1250
  '1': 1,
@@ -1456,13 +1477,19 @@ var LeaferUI = (function (exports) {
1456
1477
  },
1457
1478
  clone(data) {
1458
1479
  return JSON.parse(JSON.stringify(data));
1480
+ },
1481
+ toMap(list) {
1482
+ const map = {};
1483
+ for (let i = 0, len = list.length; i < len; i++)
1484
+ map[list[i]] = true;
1485
+ return map;
1459
1486
  }
1460
1487
  };
1461
1488
  const { assign } = DataHelper;
1462
1489
 
1463
1490
  class LeafData {
1464
1491
  get __blendMode() {
1465
- if (this.eraser)
1492
+ if (this.eraser && this.eraser !== 'path')
1466
1493
  return 'destination-out';
1467
1494
  const { blendMode } = this;
1468
1495
  return blendMode === 'pass-through' ? null : blendMode;
@@ -2092,7 +2119,7 @@ var LeaferUI = (function (exports) {
2092
2119
  }
2093
2120
  clear() {
2094
2121
  const { pixelRatio } = this;
2095
- this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
2122
+ this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2096
2123
  }
2097
2124
  isSameSize(size) {
2098
2125
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
@@ -2211,7 +2238,7 @@ var LeaferUI = (function (exports) {
2211
2238
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2212
2239
  const { set: set$2 } = PointHelper;
2213
2240
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2214
- const tempPoint$1 = {};
2241
+ const tempPoint$2 = {};
2215
2242
  const BezierHelper = {
2216
2243
  points(data, points, curve, close) {
2217
2244
  data.push(M$5, points[0], points[1]);
@@ -2401,8 +2428,8 @@ var LeaferUI = (function (exports) {
2401
2428
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2402
2429
  addPoint$2(pointBounds, toX, toY);
2403
2430
  for (let i = 0, len = tList.length; i < len; i++) {
2404
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2405
- addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2431
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2432
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2406
2433
  }
2407
2434
  },
2408
2435
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2472,7 +2499,7 @@ var LeaferUI = (function (exports) {
2472
2499
  };
2473
2500
 
2474
2501
  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;
2475
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2502
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2476
2503
  const { ellipticalArc } = EllipseHelper;
2477
2504
  const debug$d = Debug.get('PathConvert');
2478
2505
  const setEndPoint$1 = {};
@@ -2665,7 +2692,7 @@ var LeaferUI = (function (exports) {
2665
2692
  case N$3:
2666
2693
  x = old[i + 1];
2667
2694
  y = old[i + 2];
2668
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2695
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2669
2696
  i += 5;
2670
2697
  break;
2671
2698
  case D$3:
@@ -2822,7 +2849,7 @@ var LeaferUI = (function (exports) {
2822
2849
  };
2823
2850
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2824
2851
 
2825
- 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;
2852
+ 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;
2826
2853
  class PathCreator {
2827
2854
  set path(value) { this.__path = value; }
2828
2855
  get path() { return this.__path; }
@@ -2864,7 +2891,7 @@ var LeaferUI = (function (exports) {
2864
2891
  return this;
2865
2892
  }
2866
2893
  rect(x, y, width, height) {
2867
- rect$1(this.__path, x, y, width, height);
2894
+ rect$2(this.__path, x, y, width, height);
2868
2895
  return this;
2869
2896
  }
2870
2897
  roundRect(x, y, width, height, cornerRadius) {
@@ -3748,6 +3775,8 @@ var LeaferUI = (function (exports) {
3748
3775
  this.__setAttr(key, value);
3749
3776
  this.__layout.boxChanged || this.__layout.boxChange();
3750
3777
  this.waitParent(() => { this.parent.__updateMask(value); });
3778
+ if (typeof value === 'string')
3779
+ this.maskType = value;
3751
3780
  }
3752
3781
  }));
3753
3782
  }
@@ -3959,15 +3988,21 @@ var LeaferUI = (function (exports) {
3959
3988
  }
3960
3989
  return true;
3961
3990
  },
3962
- moveWorld(t, x, y) {
3963
- const local = { x, y };
3991
+ moveWorld(t, x, y = 0) {
3992
+ const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
3964
3993
  if (t.parent)
3965
3994
  toInnerPoint$1(t.parent.worldTransform, local, local, true);
3966
3995
  L.moveLocal(t, local.x, local.y);
3967
3996
  },
3968
3997
  moveLocal(t, x, y = 0) {
3969
- t.x += x;
3970
- t.y += y;
3998
+ if (typeof x === 'object') {
3999
+ t.x += x.x;
4000
+ t.y += x.y;
4001
+ }
4002
+ else {
4003
+ t.x += x;
4004
+ t.y += y;
4005
+ }
3971
4006
  },
3972
4007
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3973
4008
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4171,11 +4206,19 @@ var LeaferUI = (function (exports) {
4171
4206
 
4172
4207
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4173
4208
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
4209
+ const localContent = '_localContentBounds';
4210
+ const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
4174
4211
  class LeafLayout {
4212
+ get contentBounds() { return this._contentBounds || this.boxBounds; }
4213
+ set contentBounds(bounds) { this._contentBounds = bounds; }
4175
4214
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4176
4215
  get renderBounds() { return this._renderBounds || this.boxBounds; }
4216
+ get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
4177
4217
  get localStrokeBounds() { return this._localStrokeBounds || this; }
4178
4218
  get localRenderBounds() { return this._localRenderBounds || this; }
4219
+ get worldContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {})); return this[worldContent]; }
4220
+ get worldBoxBounds() { toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {})); return this[worldBox]; }
4221
+ get worldStrokeBounds() { toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {})); return this[worldStroke]; }
4179
4222
  get a() { return 1; }
4180
4223
  get b() { return 0; }
4181
4224
  get c() { return 0; }
@@ -4258,7 +4301,6 @@ var LeaferUI = (function (exports) {
4258
4301
  case 'content':
4259
4302
  if (this.contentBounds)
4260
4303
  return this.contentBounds;
4261
- case 'margin':
4262
4304
  case 'box':
4263
4305
  return this.boxBounds;
4264
4306
  case 'stroke':
@@ -4271,8 +4313,9 @@ var LeaferUI = (function (exports) {
4271
4313
  return this.localRenderBounds;
4272
4314
  case 'stroke':
4273
4315
  return this.localStrokeBounds;
4274
- case 'margin':
4275
4316
  case 'content':
4317
+ if (this.contentBounds)
4318
+ return this.localContentBounds;
4276
4319
  case 'box':
4277
4320
  return this.leaf.__localBoxBounds;
4278
4321
  }
@@ -4281,15 +4324,13 @@ var LeaferUI = (function (exports) {
4281
4324
  switch (type) {
4282
4325
  case 'render':
4283
4326
  return this.leaf.__world;
4327
+ case 'stroke':
4328
+ return this.worldStrokeBounds;
4284
4329
  case 'content':
4285
4330
  if (this.contentBounds)
4286
- return this.getWorldContentBounds();
4287
- case 'margin':
4331
+ return this.worldContentBounds;
4288
4332
  case 'box':
4289
- return this.getWorldBoxBounds();
4290
- case 'margin':
4291
- case 'stroke':
4292
- return this.getWorldStrokeBounds();
4333
+ return this.worldBoxBounds;
4293
4334
  }
4294
4335
  }
4295
4336
  getLayoutBounds(type, relative = 'world', unscale) {
@@ -4352,20 +4393,24 @@ var LeaferUI = (function (exports) {
4352
4393
  points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
4353
4394
  return points;
4354
4395
  }
4355
- getWorldContentBounds() {
4356
- this._worldContentBounds || (this._worldContentBounds = {});
4357
- toOuterOf$2(this.contentBounds, this.leaf.__world, this._worldContentBounds);
4358
- return this._worldContentBounds;
4396
+ shrinkContent() {
4397
+ const { x, y, width, height } = this.boxBounds;
4398
+ this._contentBounds = { x, y, width, height };
4399
+ }
4400
+ spreadStroke() {
4401
+ const { x, y, width, height } = this.strokeBounds;
4402
+ this._strokeBounds = { x, y, width, height };
4403
+ this._localStrokeBounds = { x, y, width, height };
4404
+ if (!this.renderSpread)
4405
+ this.spreadRenderCancel();
4359
4406
  }
4360
- getWorldBoxBounds() {
4361
- this._worldBoxBounds || (this._worldBoxBounds = {});
4362
- toOuterOf$2(this.boxBounds, this.leaf.__world, this._worldBoxBounds);
4363
- return this._worldBoxBounds;
4407
+ spreadRender() {
4408
+ const { x, y, width, height } = this.renderBounds;
4409
+ this._renderBounds = { x, y, width, height };
4410
+ this._localRenderBounds = { x, y, width, height };
4364
4411
  }
4365
- getWorldStrokeBounds() {
4366
- this._worldStrokeBounds || (this._worldStrokeBounds = {});
4367
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
4368
- return this._worldStrokeBounds;
4412
+ shrinkContentCancel() {
4413
+ this._contentBounds = undefined;
4369
4414
  }
4370
4415
  spreadStrokeCancel() {
4371
4416
  const same = this.renderBounds === this.strokeBounds;
@@ -4378,18 +4423,6 @@ var LeaferUI = (function (exports) {
4378
4423
  this._renderBounds = this._strokeBounds;
4379
4424
  this._localRenderBounds = this._localStrokeBounds;
4380
4425
  }
4381
- spreadStroke() {
4382
- const { x, y, width, height } = this.strokeBounds;
4383
- this._strokeBounds = { x, y, width, height };
4384
- this._localStrokeBounds = { x, y, width, height };
4385
- if (!this.renderSpread)
4386
- this.spreadRenderCancel();
4387
- }
4388
- spreadRender() {
4389
- const { x, y, width, height } = this.renderBounds;
4390
- this._renderBounds = { x, y, width, height };
4391
- this._localRenderBounds = { x, y, width, height };
4392
- }
4393
4426
  boxChange() {
4394
4427
  this.boxChanged = true;
4395
4428
  this.localBoxChanged || this.localBoxChange();
@@ -4476,24 +4509,40 @@ var LeaferUI = (function (exports) {
4476
4509
  });
4477
4510
  },
4478
4511
  off(type, listener, options) {
4479
- let capture;
4480
- if (options)
4481
- capture = typeof options === 'boolean' ? options : options.capture;
4482
- let events, index;
4483
- const map = __getListenerMap(this, capture);
4484
- const typeList = typeof type === 'string' ? type.split(' ') : type;
4485
- typeList.forEach(type => {
4486
- if (type) {
4487
- events = map[type];
4488
- if (events) {
4489
- index = events.findIndex(item => item.listener === listener);
4490
- if (index > -1)
4491
- events.splice(index, 1);
4492
- if (!events.length)
4493
- delete map[type];
4494
- }
4512
+ if (type) {
4513
+ const typeList = typeof type === 'string' ? type.split(' ') : type;
4514
+ if (listener) {
4515
+ let capture;
4516
+ if (options)
4517
+ capture = typeof options === 'boolean' ? options : options.capture;
4518
+ let events, index;
4519
+ const map = __getListenerMap(this, capture);
4520
+ typeList.forEach(type => {
4521
+ if (type) {
4522
+ events = map[type];
4523
+ if (events) {
4524
+ index = events.findIndex(item => item.listener === listener);
4525
+ if (index > -1)
4526
+ events.splice(index, 1);
4527
+ if (!events.length)
4528
+ delete map[type];
4529
+ }
4530
+ }
4531
+ });
4495
4532
  }
4496
- });
4533
+ else {
4534
+ const { __bubbleMap: b, __captureMap: c } = this;
4535
+ typeList.forEach(type => {
4536
+ if (b)
4537
+ delete b[type];
4538
+ if (c)
4539
+ delete c[type];
4540
+ });
4541
+ }
4542
+ }
4543
+ else {
4544
+ this.__bubbleMap = this.__captureMap = undefined;
4545
+ }
4497
4546
  },
4498
4547
  on_(type, listener, bind, options) {
4499
4548
  if (bind)
@@ -4529,12 +4578,15 @@ var LeaferUI = (function (exports) {
4529
4578
  break;
4530
4579
  }
4531
4580
  }
4581
+ this.syncEventer && this.syncEventer.emitEvent(event, capture);
4532
4582
  },
4533
4583
  emitEvent(event, capture) {
4534
4584
  event.current = this;
4535
4585
  this.emit(event.type, event, capture);
4536
4586
  },
4537
4587
  hasEvent(type, capture) {
4588
+ if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
4589
+ return true;
4538
4590
  const { __bubbleMap: b, __captureMap: c } = this;
4539
4591
  const hasB = b && b[type], hasC = c && c[type];
4540
4592
  return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
@@ -4754,10 +4806,10 @@ var LeaferUI = (function (exports) {
4754
4806
  };
4755
4807
 
4756
4808
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4757
- const { toPoint, tempPoint } = AroundHelper;
4809
+ const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4758
4810
  const LeafMatrix = {
4759
4811
  __updateWorldMatrix() {
4760
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4812
+ multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
4761
4813
  },
4762
4814
  __updateLocalMatrix() {
4763
4815
  if (this.__local) {
@@ -4768,11 +4820,11 @@ var LeaferUI = (function (exports) {
4768
4820
  layout.scaleChanged = layout.rotationChanged = false;
4769
4821
  }
4770
4822
  }
4771
- local.e = data.x;
4772
- local.f = data.y;
4773
- if (data.around) {
4774
- toPoint(data.around, layout.boxBounds, tempPoint);
4775
- translateInner(local, -tempPoint.x, -tempPoint.y);
4823
+ local.e = data.x + data.offsetX;
4824
+ local.f = data.y + data.offsetY;
4825
+ if (data.around || data.origin) {
4826
+ toPoint(data.around || data.origin, layout.boxBounds, tempPoint$1);
4827
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4776
4828
  }
4777
4829
  }
4778
4830
  this.__layout.matrixChanged = false;
@@ -4878,6 +4930,8 @@ var LeaferUI = (function (exports) {
4878
4930
  if (this.isBranch) {
4879
4931
  if (this.leafer)
4880
4932
  this.leafer.layouter.addExtra(this);
4933
+ if (this.__.flow)
4934
+ this.__updateFlowLayout();
4881
4935
  if (hasParentAutoLayout(this)) {
4882
4936
  updateMatrix$1(this);
4883
4937
  }
@@ -4910,6 +4964,8 @@ var LeaferUI = (function (exports) {
4910
4964
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
4911
4965
  canvas.opacity = this.__.opacity;
4912
4966
  if (this.__.__single) {
4967
+ if (this.__.eraser === 'path')
4968
+ return this.__renderEraser(canvas, options);
4913
4969
  const tempCanvas = canvas.getSameCanvas(true, true);
4914
4970
  this.__draw(tempCanvas, options);
4915
4971
  if (this.__worldFlipped) {
@@ -4952,6 +5008,8 @@ var LeaferUI = (function (exports) {
4952
5008
  __render(canvas, options) {
4953
5009
  if (this.__worldOpacity) {
4954
5010
  if (this.__.__single) {
5011
+ if (this.__.eraser === 'path')
5012
+ return this.__renderEraser(canvas, options);
4955
5013
  const tempCanvas = canvas.getSameCanvas(false, true);
4956
5014
  this.__renderBranch(tempCanvas, options);
4957
5015
  const nowWorld = this.__getNowWorld(options);
@@ -5091,7 +5149,9 @@ var LeaferUI = (function (exports) {
5091
5149
  setProxyAttr(_attrName, _newValue) { }
5092
5150
  getProxyAttr(_attrName) { return undefined; }
5093
5151
  find(_condition, _options) { return undefined; }
5152
+ findTag(_tag) { return undefined; }
5094
5153
  findOne(_condition, _options) { return undefined; }
5154
+ findId(_id) { return undefined; }
5095
5155
  focus(_value) { }
5096
5156
  forceUpdate(attrName) {
5097
5157
  if (attrName === undefined)
@@ -5113,9 +5173,11 @@ var LeaferUI = (function (exports) {
5113
5173
  __updateLocalStrokeBounds() { }
5114
5174
  __updateLocalRenderBounds() { }
5115
5175
  __updateBoxBounds() { }
5176
+ __updateContentBounds() { }
5116
5177
  __updateStrokeBounds() { }
5117
5178
  __updateRenderBounds() { }
5118
5179
  __updateAutoLayout() { }
5180
+ __updateFlowLayout() { }
5119
5181
  __updateNaturalSize() { }
5120
5182
  __updateStrokeSpread() { return 0; }
5121
5183
  __updateRenderSpread() { return 0; }
@@ -5123,6 +5185,13 @@ var LeaferUI = (function (exports) {
5123
5185
  __updateEraser(value) {
5124
5186
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
5125
5187
  }
5188
+ __renderEraser(canvas, options) {
5189
+ canvas.save();
5190
+ this.__clip(canvas, options);
5191
+ const { renderBounds: r } = this.__layout;
5192
+ canvas.clearRect(r.x, r.y, r.width, r.height);
5193
+ canvas.restore();
5194
+ }
5126
5195
  __updateMask(value) {
5127
5196
  this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5128
5197
  }
@@ -5303,8 +5372,8 @@ var LeaferUI = (function (exports) {
5303
5372
  emit(_type, _event, _capture) { }
5304
5373
  emitEvent(_event, _capture) { }
5305
5374
  hasEvent(_type, _capture) { return false; }
5306
- static changeAttr(attrName, defaultValue) {
5307
- defineDataProcessor(this.prototype, attrName, defaultValue);
5375
+ static changeAttr(attrName, defaultValue, fn) {
5376
+ fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5308
5377
  }
5309
5378
  static addAttr(attrName, defaultValue, fn) {
5310
5379
  if (!fn)
@@ -5801,7 +5870,7 @@ var LeaferUI = (function (exports) {
5801
5870
  }
5802
5871
  img.onload = () => { resolve(img); };
5803
5872
  img.onerror = (e) => { reject(e); };
5804
- if (!src.startsWith('data:') && !src.startsWith('blob:') && suffix)
5873
+ if (suffix && !src.startsWith('data:') && !src.startsWith('blob:'))
5805
5874
  src += (src.includes("?") ? "&" : "?") + suffix;
5806
5875
  img.src = src;
5807
5876
  });
@@ -6363,8 +6432,11 @@ var LeaferUI = (function (exports) {
6363
6432
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
6364
6433
  this.addBlock(this.canvas.bounds);
6365
6434
  this.target.forceUpdate('surface');
6435
+ return;
6366
6436
  }
6367
6437
  }
6438
+ this.addBlock(new Bounds(0, 0, 1, 1));
6439
+ this.changed = true;
6368
6440
  }
6369
6441
  __onLayoutEnd(event) {
6370
6442
  if (event.data)
@@ -6423,32 +6495,38 @@ var LeaferUI = (function (exports) {
6423
6495
  const target = options.target || this.target;
6424
6496
  this.exclude = options.exclude || null;
6425
6497
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6426
- this.findList = options.findList || [];
6498
+ this.findList = new LeafList(options.findList);
6427
6499
  if (!options.findList)
6428
- this.eachFind(target.children, target.__onlyHitMask);
6429
- const list = this.findList;
6430
- const leaf = this.getBestMatchLeaf();
6500
+ this.hitBranch(target);
6501
+ const { list } = this.findList;
6502
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6431
6503
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6432
6504
  this.clear();
6433
6505
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6434
6506
  }
6435
- getBestMatchLeaf() {
6436
- const { findList: targets } = this;
6437
- if (targets.length > 1) {
6507
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6508
+ if (list.length) {
6438
6509
  let find;
6439
- this.findList = [];
6510
+ this.findList = new LeafList();
6440
6511
  const { x, y } = this.point;
6441
6512
  const point = { x, y, radiusX: 0, radiusY: 0 };
6442
- for (let i = 0, len = targets.length; i < len; i++) {
6443
- find = targets[i];
6444
- if (LeafHelper.worldHittable(find)) {
6513
+ for (let i = 0, len = list.length; i < len; i++) {
6514
+ find = list[i];
6515
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6445
6516
  this.hitChild(find, point);
6446
6517
  if (this.findList.length)
6447
- return this.findList[0];
6518
+ return this.findList.list[0];
6448
6519
  }
6449
6520
  }
6450
6521
  }
6451
- return targets[0];
6522
+ if (bottomList) {
6523
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6524
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6525
+ if (this.findList.length)
6526
+ return this.findList.list[0];
6527
+ }
6528
+ }
6529
+ return list[0];
6452
6530
  }
6453
6531
  getPath(leaf) {
6454
6532
  const path = new LeafList();
@@ -6490,6 +6568,9 @@ var LeaferUI = (function (exports) {
6490
6568
  }
6491
6569
  return throughPath;
6492
6570
  }
6571
+ hitBranch(branch) {
6572
+ this.eachFind(branch.children, branch.__onlyHitMask);
6573
+ }
6493
6574
  eachFind(children, hitMask) {
6494
6575
  let child, hit;
6495
6576
  const { point } = this, len = children.length;
@@ -6511,11 +6592,11 @@ var LeaferUI = (function (exports) {
6511
6592
  }
6512
6593
  }
6513
6594
  }
6514
- hitChild(child, point) {
6595
+ hitChild(child, point, proxy) {
6515
6596
  if (this.exclude && this.exclude.has(child))
6516
6597
  return;
6517
6598
  if (child.__hitWorld(point))
6518
- this.findList.push(child);
6599
+ this.findList.add(proxy || child);
6519
6600
  }
6520
6601
  clear() {
6521
6602
  this.point = null;
@@ -6528,6 +6609,7 @@ var LeaferUI = (function (exports) {
6528
6609
  }
6529
6610
 
6530
6611
  const { Yes, NoAndSkip, YesAndSkip } = exports.Answer;
6612
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
6531
6613
  class Selector {
6532
6614
  constructor(target, userConfig) {
6533
6615
  this.config = {};
@@ -6537,7 +6619,8 @@ var LeaferUI = (function (exports) {
6537
6619
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6538
6620
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6539
6621
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6540
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6622
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6623
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
6541
6624
  };
6542
6625
  this.target = target;
6543
6626
  if (userConfig)
@@ -6553,12 +6636,25 @@ var LeaferUI = (function (exports) {
6553
6636
  case 'string':
6554
6637
  switch (condition[0]) {
6555
6638
  case '#':
6556
- const leaf = this.getById(condition.substring(1), branch);
6557
- return one ? leaf : (leaf ? [leaf] : []);
6639
+ idCondition.id = condition.substring(1), condition = idCondition;
6640
+ break;
6558
6641
  case '.':
6559
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
6642
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
6643
+ break;
6560
6644
  default:
6561
- return this.getByMethod(this.methods.tag, branch, one, condition);
6645
+ tagCondition.tag = condition, condition = tagCondition;
6646
+ }
6647
+ case 'object':
6648
+ if (condition.id !== undefined) {
6649
+ const leaf = this.getById(condition.id, branch);
6650
+ return one ? leaf : (leaf ? [leaf] : []);
6651
+ }
6652
+ else if (condition.tag) {
6653
+ const { tag } = condition, isArray = tag instanceof Array;
6654
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
6655
+ }
6656
+ else {
6657
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
6562
6658
  }
6563
6659
  case 'function':
6564
6660
  return this.getByMethod(condition, branch, one, options);
@@ -6713,7 +6809,11 @@ var LeaferUI = (function (exports) {
6713
6809
  defineKey(target, key, {
6714
6810
  set(value) { if (this.isLeafer)
6715
6811
  this[privateKey] = value; },
6716
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6812
+ get() {
6813
+ return this.isApp
6814
+ ? this.tree.zoomLayer
6815
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6816
+ }
6717
6817
  });
6718
6818
  };
6719
6819
  }
@@ -6853,7 +6953,7 @@ var LeaferUI = (function (exports) {
6853
6953
  const UnitConvert = {
6854
6954
  number(value, percentRefer) {
6855
6955
  if (typeof value === 'object')
6856
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
6956
+ return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
6857
6957
  return value;
6858
6958
  }
6859
6959
  };
@@ -7119,6 +7219,9 @@ var LeaferUI = (function (exports) {
7119
7219
  pen.set(this.path = this.__.path || []);
7120
7220
  return pen;
7121
7221
  }
7222
+ get editConfig() { return undefined; }
7223
+ get editOuter() { return 'EditTool'; }
7224
+ get editInner() { return 'PathEditor'; }
7122
7225
  constructor(data) {
7123
7226
  super(data);
7124
7227
  }
@@ -7131,7 +7234,9 @@ var LeaferUI = (function (exports) {
7131
7234
  }
7132
7235
  createProxyData() { return undefined; }
7133
7236
  find(_condition, _options) { return undefined; }
7237
+ findTag(tag) { return this.find({ tag }); }
7134
7238
  findOne(_condition, _options) { return undefined; }
7239
+ findId(id) { return this.findOne({ id }); }
7135
7240
  getPath(curve, pathForRender) {
7136
7241
  this.__layout.update();
7137
7242
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
@@ -7180,7 +7285,8 @@ var LeaferUI = (function (exports) {
7180
7285
  __drawPathByBox(drawer) {
7181
7286
  const { x, y, width, height } = this.__layout.boxBounds;
7182
7287
  if (this.__.cornerRadius) {
7183
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7288
+ const { cornerRadius } = this.__;
7289
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7184
7290
  }
7185
7291
  else {
7186
7292
  drawer.rect(x, y, width, height);
@@ -7201,6 +7307,9 @@ var LeaferUI = (function (exports) {
7201
7307
  static registerData(data) {
7202
7308
  dataProcessor(data)(this.prototype);
7203
7309
  }
7310
+ static setEditConfig(_config) { }
7311
+ static setEditOuter(_toolName) { }
7312
+ static setEditInner(_editorName) { }
7204
7313
  destroy() {
7205
7314
  this.fill = this.stroke = null;
7206
7315
  super.destroy();
@@ -7278,21 +7387,84 @@ var LeaferUI = (function (exports) {
7278
7387
  __decorate([
7279
7388
  rotationType(0, true)
7280
7389
  ], exports.UI.prototype, "skewY", void 0);
7390
+ __decorate([
7391
+ positionType(0, true)
7392
+ ], exports.UI.prototype, "offsetX", void 0);
7393
+ __decorate([
7394
+ positionType(0, true)
7395
+ ], exports.UI.prototype, "offsetY", void 0);
7396
+ __decorate([
7397
+ positionType(0, true)
7398
+ ], exports.UI.prototype, "scrollX", void 0);
7399
+ __decorate([
7400
+ positionType(0, true)
7401
+ ], exports.UI.prototype, "scrollY", void 0);
7402
+ __decorate([
7403
+ autoLayoutType()
7404
+ ], exports.UI.prototype, "origin", void 0);
7281
7405
  __decorate([
7282
7406
  autoLayoutType()
7283
7407
  ], exports.UI.prototype, "around", void 0);
7284
7408
  __decorate([
7285
7409
  dataType(false)
7286
- ], exports.UI.prototype, "draggable", void 0);
7410
+ ], exports.UI.prototype, "lazy", void 0);
7287
7411
  __decorate([
7288
- dataType(false)
7289
- ], exports.UI.prototype, "editable", void 0);
7412
+ naturalBoundsType(1)
7413
+ ], exports.UI.prototype, "pixelRatio", void 0);
7414
+ __decorate([
7415
+ pathInputType()
7416
+ ], exports.UI.prototype, "path", void 0);
7417
+ __decorate([
7418
+ pathType()
7419
+ ], exports.UI.prototype, "windingRule", void 0);
7420
+ __decorate([
7421
+ pathType(true)
7422
+ ], exports.UI.prototype, "closed", void 0);
7423
+ __decorate([
7424
+ autoLayoutType(false)
7425
+ ], exports.UI.prototype, "flow", void 0);
7426
+ __decorate([
7427
+ boundsType(0)
7428
+ ], exports.UI.prototype, "padding", void 0);
7429
+ __decorate([
7430
+ boundsType(0)
7431
+ ], exports.UI.prototype, "gap", void 0);
7432
+ __decorate([
7433
+ boundsType('top-left')
7434
+ ], exports.UI.prototype, "align", void 0);
7435
+ __decorate([
7436
+ boundsType(false)
7437
+ ], exports.UI.prototype, "wrap", void 0);
7438
+ __decorate([
7439
+ boundsType('box')
7440
+ ], exports.UI.prototype, "itemBox", void 0);
7290
7441
  __decorate([
7291
- dataType('size')
7292
- ], exports.UI.prototype, "editSize", void 0);
7442
+ boundsType(true)
7443
+ ], exports.UI.prototype, "inFlow", void 0);
7444
+ __decorate([
7445
+ boundsType()
7446
+ ], exports.UI.prototype, "autoWidth", void 0);
7447
+ __decorate([
7448
+ boundsType()
7449
+ ], exports.UI.prototype, "autoHeight", void 0);
7450
+ __decorate([
7451
+ boundsType()
7452
+ ], exports.UI.prototype, "autoBox", void 0);
7453
+ __decorate([
7454
+ boundsType()
7455
+ ], exports.UI.prototype, "widthRange", void 0);
7456
+ __decorate([
7457
+ boundsType()
7458
+ ], exports.UI.prototype, "heightRange", void 0);
7459
+ __decorate([
7460
+ dataType(false)
7461
+ ], exports.UI.prototype, "draggable", void 0);
7293
7462
  __decorate([
7294
7463
  dataType()
7295
- ], exports.UI.prototype, "editorStyle", void 0);
7464
+ ], exports.UI.prototype, "dragBounds", void 0);
7465
+ __decorate([
7466
+ dataType(false)
7467
+ ], exports.UI.prototype, "editable", void 0);
7296
7468
  __decorate([
7297
7469
  hitType(true)
7298
7470
  ], exports.UI.prototype, "hittable", void 0);
@@ -7347,21 +7519,6 @@ var LeaferUI = (function (exports) {
7347
7519
  __decorate([
7348
7520
  strokeType(10)
7349
7521
  ], exports.UI.prototype, "miterLimit", void 0);
7350
- __decorate([
7351
- dataType(false)
7352
- ], exports.UI.prototype, "lazy", void 0);
7353
- __decorate([
7354
- naturalBoundsType(1)
7355
- ], exports.UI.prototype, "pixelRatio", void 0);
7356
- __decorate([
7357
- pathInputType()
7358
- ], exports.UI.prototype, "path", void 0);
7359
- __decorate([
7360
- pathType()
7361
- ], exports.UI.prototype, "windingRule", void 0);
7362
- __decorate([
7363
- pathType(true)
7364
- ], exports.UI.prototype, "closed", void 0);
7365
7522
  __decorate([
7366
7523
  arrowType('none')
7367
7524
  ], exports.UI.prototype, "startArrow", void 0);
@@ -7484,7 +7641,6 @@ var LeaferUI = (function (exports) {
7484
7641
  var Leafer_1;
7485
7642
  const debug$3 = Debug.get('Leafer');
7486
7643
  exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7487
- static get version() { return '1.0.0-rc.21'; }
7488
7644
  get __tag() { return 'Leafer'; }
7489
7645
  get isApp() { return false; }
7490
7646
  get app() { return this.parent || this; }
@@ -7537,7 +7693,6 @@ var LeaferUI = (function (exports) {
7537
7693
  if (this.isApp)
7538
7694
  this.__setApp();
7539
7695
  this.__checkAutoLayout(config);
7540
- this.updateLazyBounds();
7541
7696
  this.view = canvas.view;
7542
7697
  if (parentApp) {
7543
7698
  this.__bindApp(parentApp);
@@ -7597,9 +7752,6 @@ var LeaferUI = (function (exports) {
7597
7752
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7598
7753
  Object.keys(data).forEach(key => this[key] = data[key]);
7599
7754
  }
7600
- forceFullRender() {
7601
- this.forceRender();
7602
- }
7603
7755
  forceRender(bounds) {
7604
7756
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7605
7757
  if (this.viewReady)
@@ -7677,7 +7829,7 @@ var LeaferUI = (function (exports) {
7677
7829
  this.canvas.backgroundColor = newValue;
7678
7830
  }
7679
7831
  else {
7680
- this.forceFullRender();
7832
+ this.forceRender();
7681
7833
  }
7682
7834
  }
7683
7835
  __onCreated() {
@@ -7781,6 +7933,7 @@ var LeaferUI = (function (exports) {
7781
7933
  __listenEvents() {
7782
7934
  const runId = Run.start('FirstCreate ' + this.innerName);
7783
7935
  this.once(LeaferEvent.START, () => Run.end(runId));
7936
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7784
7937
  this.once(LayoutEvent.END, () => this.__onReady());
7785
7938
  this.once(RenderEvent.START, () => this.__onCreated());
7786
7939
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7851,8 +8004,8 @@ var LeaferUI = (function (exports) {
7851
8004
  registerUI()
7852
8005
  ], exports.Rect);
7853
8006
 
7854
- const rect = exports.Rect.prototype;
7855
- const group = exports.Group.prototype;
8007
+ const rect$1 = exports.Rect.prototype;
8008
+ const group$1 = exports.Group.prototype;
7856
8009
  const bounds$1 = {};
7857
8010
  const { copy: copy$3, add } = BoundsHelper;
7858
8011
  exports.Box = class Box extends exports.Group {
@@ -7887,6 +8040,8 @@ var LeaferUI = (function (exports) {
7887
8040
  else {
7888
8041
  this.__updateRectBoxBounds();
7889
8042
  }
8043
+ if (data.flow)
8044
+ this.__updateContentBounds();
7890
8045
  }
7891
8046
  __updateStrokeBounds() { }
7892
8047
  __updateRenderBounds() {
@@ -7931,28 +8086,28 @@ var LeaferUI = (function (exports) {
7931
8086
  affectRenderBoundsType('show')
7932
8087
  ], exports.Box.prototype, "overflow", void 0);
7933
8088
  __decorate([
7934
- rewrite(rect.__updateStrokeSpread)
8089
+ rewrite(rect$1.__updateStrokeSpread)
7935
8090
  ], exports.Box.prototype, "__updateStrokeSpread", null);
7936
8091
  __decorate([
7937
- rewrite(rect.__updateRenderSpread)
8092
+ rewrite(rect$1.__updateRenderSpread)
7938
8093
  ], exports.Box.prototype, "__updateRectRenderSpread", null);
7939
8094
  __decorate([
7940
- rewrite(rect.__updateBoxBounds)
8095
+ rewrite(rect$1.__updateBoxBounds)
7941
8096
  ], exports.Box.prototype, "__updateRectBoxBounds", null);
7942
8097
  __decorate([
7943
- rewrite(rect.__updateStrokeBounds)
8098
+ rewrite(rect$1.__updateStrokeBounds)
7944
8099
  ], exports.Box.prototype, "__updateStrokeBounds", null);
7945
8100
  __decorate([
7946
- rewrite(rect.__updateRenderBounds)
8101
+ rewrite(rect$1.__updateRenderBounds)
7947
8102
  ], exports.Box.prototype, "__updateRectRenderBounds", null);
7948
8103
  __decorate([
7949
- rewrite(rect.__updateChange)
8104
+ rewrite(rect$1.__updateChange)
7950
8105
  ], exports.Box.prototype, "__updateRectChange", null);
7951
8106
  __decorate([
7952
- rewrite(rect.__render)
8107
+ rewrite(rect$1.__render)
7953
8108
  ], exports.Box.prototype, "__renderRect", null);
7954
8109
  __decorate([
7955
- rewrite(group.__render)
8110
+ rewrite(group$1.__render)
7956
8111
  ], exports.Box.prototype, "__renderGroup", null);
7957
8112
  exports.Box = __decorate([
7958
8113
  rewriteAble(),
@@ -8296,9 +8451,10 @@ var LeaferUI = (function (exports) {
8296
8451
  registerUI()
8297
8452
  ], exports.Canvas);
8298
8453
 
8299
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8454
+ const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8300
8455
  exports.Text = class Text extends exports.UI {
8301
8456
  get __tag() { return 'Text'; }
8457
+ get editInner() { return 'TextEditor'; }
8302
8458
  get textDrawData() {
8303
8459
  this.__layout.update();
8304
8460
  return this.__.__textDrawData;
@@ -8368,7 +8524,7 @@ var LeaferUI = (function (exports) {
8368
8524
  if (italic)
8369
8525
  b.width += fontSize * 0.16;
8370
8526
  const contentBounds = includes(b, bounds) ? b : bounds;
8371
- if (contentBounds !== layout.contentBounds) {
8527
+ if (!isSame$1(contentBounds, layout.contentBounds)) {
8372
8528
  layout.contentBounds = contentBounds;
8373
8529
  layout.renderChanged = true;
8374
8530
  setList(data.__textBoxBounds = {}, [b, bounds]);
@@ -8396,9 +8552,6 @@ var LeaferUI = (function (exports) {
8396
8552
  __decorate([
8397
8553
  boundsType(0)
8398
8554
  ], exports.Text.prototype, "height", void 0);
8399
- __decorate([
8400
- boundsType(0)
8401
- ], exports.Text.prototype, "padding", void 0);
8402
8555
  __decorate([
8403
8556
  surfaceType('#000000')
8404
8557
  ], exports.Text.prototype, "fill", void 0);
@@ -8527,7 +8680,7 @@ var LeaferUI = (function (exports) {
8527
8680
  };
8528
8681
  }
8529
8682
 
8530
- const version = "1.0.0-rc.21";
8683
+ const version = "1.0.0-rc.23";
8531
8684
 
8532
8685
  exports.App = class App extends exports.Leafer {
8533
8686
  get __tag() { return 'App'; }
@@ -8621,7 +8774,10 @@ var LeaferUI = (function (exports) {
8621
8774
  this.renderer.update();
8622
8775
  }
8623
8776
  __render(canvas, options) {
8624
- canvas.setWorld(options.matrix || this.__world);
8777
+ if (options.matrix) {
8778
+ const { a, b, c, d, e, f } = options.matrix;
8779
+ canvas.setTransform(a, b, c, d, e, f);
8780
+ }
8625
8781
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8626
8782
  }
8627
8783
  __onResize(event) {
@@ -8743,6 +8899,35 @@ var LeaferUI = (function (exports) {
8743
8899
  static setData(data) {
8744
8900
  this.data = data;
8745
8901
  }
8902
+ static getValidMove(leaf, start, total) {
8903
+ const { draggable, dragBounds, x, y } = leaf;
8904
+ const move = leaf.getLocalPoint(total, null, true);
8905
+ move.x += start.x - x;
8906
+ move.y += start.y - y;
8907
+ if (dragBounds)
8908
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8909
+ if (draggable === 'x')
8910
+ move.y = 0;
8911
+ if (draggable === 'y')
8912
+ move.x = 0;
8913
+ return move;
8914
+ }
8915
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8916
+ const x = box.x + move.x, y = box.y + move.y;
8917
+ const right = x + box.width, bottom = y + box.height;
8918
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8919
+ if (!change)
8920
+ move = Object.assign({}, move);
8921
+ if (x < dragBounds.x)
8922
+ move.x += dragBounds.x - x;
8923
+ else if (right > boundsRight)
8924
+ move.x += boundsRight - right;
8925
+ if (y < dragBounds.y)
8926
+ move.y += dragBounds.y - y;
8927
+ else if (bottom > boundsBottom)
8928
+ move.y += boundsBottom - bottom;
8929
+ return move;
8930
+ }
8746
8931
  getPageMove(total) {
8747
8932
  this.assignMove(total);
8748
8933
  return this.current.getPagePoint(move, null, true);
@@ -8852,9 +9037,7 @@ var LeaferUI = (function (exports) {
8852
9037
  if (leafer.isApp)
8853
9038
  return;
8854
9039
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
8855
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8856
- if (x || y)
8857
- leafer.zoomLayer.move(x, y);
9040
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8858
9041
  }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
8859
9042
  const { zoomLayer } = leafer;
8860
9043
  const changeScale = leafer.getValidScale(e.scale);
@@ -9123,9 +9306,14 @@ var LeaferUI = (function (exports) {
9123
9306
  if (this.dragging) {
9124
9307
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9125
9308
  this.getDragableList(this.dragData.path);
9309
+ this.setDragStartPoints(this.realDragableList = this.getList());
9126
9310
  }
9127
9311
  }
9128
9312
  }
9313
+ setDragStartPoints(list) {
9314
+ this.dragStartPoints = {};
9315
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9316
+ }
9129
9317
  getDragableList(path) {
9130
9318
  let leaf;
9131
9319
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9155,10 +9343,10 @@ var LeaferUI = (function (exports) {
9155
9343
  }
9156
9344
  dragReal() {
9157
9345
  const { running } = this.interaction;
9158
- const list = this.getList();
9346
+ const list = this.realDragableList;
9159
9347
  if (list.length && running) {
9160
- const { moveX, moveY } = this.dragData;
9161
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9348
+ const { totalX, totalY } = this.dragData;
9349
+ list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9162
9350
  }
9163
9351
  }
9164
9352
  dragOverOrOut(data) {
@@ -9627,7 +9815,8 @@ var LeaferUI = (function (exports) {
9627
9815
  }
9628
9816
  findPath(data, options) {
9629
9817
  const { hitRadius, through } = this.config.pointer;
9630
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9818
+ const { bottomList } = this;
9819
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9631
9820
  if (find.throughPath)
9632
9821
  data.throughPath = find.throughPath;
9633
9822
  data.path = find.path;
@@ -9640,7 +9829,7 @@ var LeaferUI = (function (exports) {
9640
9829
  const app = this.target.app;
9641
9830
  if (!app || !app.isApp)
9642
9831
  return false;
9643
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9832
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9644
9833
  }
9645
9834
  checkPath(data, useDefaultPath) {
9646
9835
  if (useDefaultPath || this.canMove(data))
@@ -9706,7 +9895,7 @@ var LeaferUI = (function (exports) {
9706
9895
  const { path } = data;
9707
9896
  for (let i = 0, len = path.length; i < len; i++) {
9708
9897
  leaf = path.list[i];
9709
- cursor = leaf.cursor;
9898
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9710
9899
  if (cursor)
9711
9900
  break;
9712
9901
  }
@@ -9864,6 +10053,8 @@ var LeaferUI = (function (exports) {
9864
10053
  const inner = {};
9865
10054
  const leaf = exports.Leaf.prototype;
9866
10055
  leaf.__hitWorld = function (point) {
10056
+ if (!this.__.hitSelf)
10057
+ return false;
9867
10058
  if (this.__.hitRadius) {
9868
10059
  copy$2(inner, point), point = inner;
9869
10060
  setRadius(point, this.__.hitRadius);
@@ -9891,8 +10082,8 @@ var LeaferUI = (function (exports) {
9891
10082
  this.__drawRenderPath(canvas); };
9892
10083
 
9893
10084
  const matrix = new Matrix();
9894
- const ui$1 = exports.UI.prototype;
9895
- ui$1.__updateHitCanvas = function () {
10085
+ const ui$2 = exports.UI.prototype;
10086
+ ui$2.__updateHitCanvas = function () {
9896
10087
  const data = this.__, { hitCanvasManager } = this.leafer;
9897
10088
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9898
10089
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9919,7 +10110,7 @@ var LeaferUI = (function (exports) {
9919
10110
  this.__drawHitPath(h);
9920
10111
  h.setStrokeOptions(data);
9921
10112
  };
9922
- ui$1.__hit = function (inner) {
10113
+ ui$2.__hit = function (inner) {
9923
10114
  if (Platform.name === 'miniapp')
9924
10115
  this.__drawHitPath(this.__hitCanvas);
9925
10116
  const data = this.__;
@@ -9959,22 +10150,24 @@ var LeaferUI = (function (exports) {
9959
10150
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9960
10151
  };
9961
10152
 
9962
- const ui = new exports.UI();
9963
- exports.Rect.prototype.__updateHitCanvas = function () {
10153
+ const ui$1 = new exports.UI();
10154
+ const rect = exports.Rect.prototype;
10155
+ rect.__updateHitCanvas = function () {
9964
10156
  if (this.stroke || this.cornerRadius)
9965
- ui.__updateHitCanvas.call(this);
10157
+ ui$1.__updateHitCanvas.call(this);
9966
10158
  };
9967
- exports.Rect.prototype.__hitFill = function (inner) {
9968
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10159
+ rect.__hitFill = function (inner) {
10160
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9969
10161
  };
9970
10162
 
9971
- exports.UI.prototype.find = function (condition, options) {
10163
+ const ui = exports.UI.prototype, group = exports.Group.prototype;
10164
+ ui.find = function (condition, options) {
9972
10165
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9973
10166
  };
9974
- exports.UI.prototype.findOne = function (condition, options) {
10167
+ ui.findOne = function (condition, options) {
9975
10168
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9976
10169
  };
9977
- exports.Group.prototype.pick = function (hitPoint, options) {
10170
+ group.pick = function (hitPoint, options) {
9978
10171
  this.__layout.update();
9979
10172
  if (!options)
9980
10173
  options = {};
@@ -10547,7 +10740,7 @@ var LeaferUI = (function (exports) {
10547
10740
  }
10548
10741
  else {
10549
10742
  const { renderShapeSpread: spread } = ui.__layout;
10550
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
10743
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
10551
10744
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
10552
10745
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
10553
10746
  if (fitMatrix.a < 1) {
@@ -10630,79 +10823,75 @@ var LeaferUI = (function (exports) {
10630
10823
 
10631
10824
  let origin = {};
10632
10825
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10633
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10826
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10634
10827
  const transform = get$4();
10635
- const swap = rotation && rotation !== 180;
10636
- const sw = box.width / (swap ? height : width);
10637
- const sh = box.height / (swap ? width : height);
10638
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10639
- const x = box.x + (box.width - width * scale) / 2;
10640
- const y = box.y + (box.height - height * scale) / 2;
10641
- translate$1(transform, x, y);
10642
- scaleHelper(transform, scale);
10828
+ translate$1(transform, box.x + x, box.y + y);
10829
+ scaleHelper(transform, scaleX, scaleY);
10643
10830
  if (rotation)
10644
10831
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10645
- data.scaleX = data.scaleY = scale;
10646
10832
  data.transform = transform;
10647
10833
  }
10648
10834
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10649
10835
  const transform = get$4();
10650
- translate$1(transform, box.x, box.y);
10651
- if (x || y)
10652
- translate$1(transform, x, y);
10653
- if (scaleX) {
10836
+ translate$1(transform, box.x + x, box.y + y);
10837
+ if (scaleX)
10654
10838
  scaleHelper(transform, scaleX, scaleY);
10655
- data.scaleX = transform.a;
10656
- data.scaleY = transform.d;
10657
- }
10658
10839
  if (rotation)
10659
10840
  rotate(transform, rotation);
10660
10841
  data.transform = transform;
10661
10842
  }
10662
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10843
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
10663
10844
  const transform = get$4();
10664
10845
  if (rotation) {
10665
- rotate(transform, rotation);
10666
- switch (rotation) {
10667
- case 90:
10668
- translate$1(transform, height, 0);
10669
- break;
10670
- case 180:
10671
- translate$1(transform, width, height);
10672
- break;
10673
- case 270:
10674
- translate$1(transform, 0, width);
10675
- break;
10846
+ if (align === 'center') {
10847
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10848
+ }
10849
+ else {
10850
+ rotate(transform, rotation);
10851
+ switch (rotation) {
10852
+ case 90:
10853
+ translate$1(transform, height, 0);
10854
+ break;
10855
+ case 180:
10856
+ translate$1(transform, width, height);
10857
+ break;
10858
+ case 270:
10859
+ translate$1(transform, 0, width);
10860
+ break;
10861
+ }
10676
10862
  }
10677
10863
  }
10678
- origin.x = box.x;
10679
- origin.y = box.y;
10680
- if (x || y)
10681
- origin.x += x, origin.y += y;
10864
+ origin.x = box.x + x;
10865
+ origin.y = box.y + y;
10682
10866
  translate$1(transform, origin.x, origin.y);
10683
- if (scaleX) {
10867
+ if (scaleX)
10684
10868
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10685
- data.scaleX = scaleX;
10686
- data.scaleY = scaleY;
10687
- }
10688
10869
  data.transform = transform;
10689
10870
  }
10690
10871
 
10691
10872
  const { get: get$3, translate } = MatrixHelper;
10692
10873
  const tempBox = new Bounds();
10874
+ const tempPoint = {};
10693
10875
  function createData(leafPaint, image, paint, box) {
10694
10876
  let { width, height } = image;
10695
10877
  if (paint.padding)
10696
10878
  box = tempBox.set(box).shrink(paint.padding);
10697
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10879
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
10698
10880
  const sameBox = box.width === width && box.height === height;
10699
10881
  if (blendMode)
10700
10882
  leafPaint.blendMode = blendMode;
10701
10883
  const data = leafPaint.data = { mode };
10702
- let x, y, scaleX, scaleY;
10703
- if (offset)
10704
- x = offset.x, y = offset.y;
10705
- if (size) {
10884
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10885
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10886
+ let x = 0, y = 0, scaleX, scaleY;
10887
+ if (!mode || mode === 'cover' || mode === 'fit') {
10888
+ if (!sameBox || rotation) {
10889
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10890
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10891
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10892
+ }
10893
+ }
10894
+ else if (size) {
10706
10895
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10707
10896
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10708
10897
  }
@@ -10710,26 +10899,36 @@ var LeaferUI = (function (exports) {
10710
10899
  scaleX = typeof scale === 'number' ? scale : scale.x;
10711
10900
  scaleY = typeof scale === 'number' ? scale : scale.y;
10712
10901
  }
10902
+ if (align) {
10903
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10904
+ if (scaleX)
10905
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10906
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
10907
+ x += tempPoint.x, y += tempPoint.y;
10908
+ }
10909
+ if (offset)
10910
+ x += offset.x, y += offset.y;
10713
10911
  switch (mode) {
10714
10912
  case 'strench':
10715
10913
  if (!sameBox)
10716
10914
  width = box.width, height = box.height;
10717
10915
  break;
10916
+ case 'normal':
10718
10917
  case 'clip':
10719
- if (offset || scaleX || rotation)
10918
+ if (x || y || scaleX || rotation)
10720
10919
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10721
10920
  break;
10722
10921
  case 'repeat':
10723
10922
  if (!sameBox || scaleX || rotation)
10724
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10923
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10725
10924
  if (!repeat)
10726
10925
  data.repeat = 'repeat';
10727
10926
  break;
10728
10927
  case 'fit':
10729
10928
  case 'cover':
10730
10929
  default:
10731
- if (!sameBox || rotation)
10732
- fillOrFitMode(data, mode, box, width, height, rotation);
10930
+ if (scaleX)
10931
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10733
10932
  }
10734
10933
  if (!data.transform) {
10735
10934
  if (box.x || box.y) {
@@ -10737,6 +10936,10 @@ var LeaferUI = (function (exports) {
10737
10936
  translate(data.transform, box.x, box.y);
10738
10937
  }
10739
10938
  }
10939
+ if (scaleX && mode !== 'strench') {
10940
+ data.scaleX = scaleX;
10941
+ data.scaleY = scaleY;
10942
+ }
10740
10943
  data.width = width;
10741
10944
  data.height = height;
10742
10945
  if (opacity)
@@ -11634,11 +11837,13 @@ var LeaferUI = (function (exports) {
11634
11837
  const { rows, overflow } = drawData;
11635
11838
  let { textOverflow } = style;
11636
11839
  rows.splice(overflow);
11637
- if (textOverflow !== 'hide') {
11638
- if (textOverflow === 'ellipsis')
11840
+ if (textOverflow && textOverflow !== 'show') {
11841
+ if (textOverflow === 'hide')
11842
+ textOverflow = '';
11843
+ else if (textOverflow === 'ellipsis')
11639
11844
  textOverflow = '...';
11640
11845
  let char, charRight;
11641
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
11846
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
11642
11847
  const right = style.x + style.width - ellipsisWidth;
11643
11848
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
11644
11849
  list.forEach(row => {
@@ -11792,6 +11997,13 @@ var LeaferUI = (function (exports) {
11792
11997
  resolve();
11793
11998
  this.running = false;
11794
11999
  };
12000
+ if (filename === 'json') {
12001
+ return over({ data: leaf.toJSON() });
12002
+ }
12003
+ else if (FileHelper.fileType(filename) === 'json') {
12004
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
12005
+ return over({ data: true });
12006
+ }
11795
12007
  const { leafer } = leaf;
11796
12008
  if (leafer) {
11797
12009
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -11799,8 +12011,12 @@ var LeaferUI = (function (exports) {
11799
12011
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11800
12012
  const { worldTransform, isLeafer, isFrame } = leaf;
11801
12013
  const { slice, trim, onCanvas } = options;
11802
- const scale = options.scale || 1;
11803
- const pixelRatio = options.pixelRatio || 1;
12014
+ let scale = options.scale || 1;
12015
+ let pixelRatio = options.pixelRatio || 1;
12016
+ if (leaf.isApp) {
12017
+ scale *= pixelRatio;
12018
+ pixelRatio = leaf.app.pixelRatio;
12019
+ }
11804
12020
  const screenshot = options.screenshot || leaf.isApp;
11805
12021
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11806
12022
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -11941,6 +12157,7 @@ var LeaferUI = (function (exports) {
11941
12157
  ImageManager.destroy();
11942
12158
  });
11943
12159
 
12160
+ exports.AlignHelper = AlignHelper;
11944
12161
  exports.AnimateEvent = AnimateEvent;
11945
12162
  exports.AroundHelper = AroundHelper;
11946
12163
  exports.AutoBounds = AutoBounds;
@@ -12097,7 +12314,7 @@ var LeaferUI = (function (exports) {
12097
12314
  exports.surfaceType = surfaceType;
12098
12315
  exports.tempBounds = tempBounds$1;
12099
12316
  exports.tempMatrix = tempMatrix;
12100
- exports.tempPoint = tempPoint$2;
12317
+ exports.tempPoint = tempPoint$3;
12101
12318
  exports.useCanvas = useCanvas;
12102
12319
  exports.useModule = useModule;
12103
12320
  exports.version = version;