@leafer-ui/miniapp 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$c = 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)
@@ -6347,8 +6416,11 @@ class Renderer {
6347
6416
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
6348
6417
  this.addBlock(this.canvas.bounds);
6349
6418
  this.target.forceUpdate('surface');
6419
+ return;
6350
6420
  }
6351
6421
  }
6422
+ this.addBlock(new Bounds(0, 0, 1, 1));
6423
+ this.changed = true;
6352
6424
  }
6353
6425
  __onLayoutEnd(event) {
6354
6426
  if (event.data)
@@ -6407,32 +6479,38 @@ class Picker {
6407
6479
  const target = options.target || this.target;
6408
6480
  this.exclude = options.exclude || null;
6409
6481
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6410
- this.findList = options.findList || [];
6482
+ this.findList = new LeafList(options.findList);
6411
6483
  if (!options.findList)
6412
- this.eachFind(target.children, target.__onlyHitMask);
6413
- const list = this.findList;
6414
- const leaf = this.getBestMatchLeaf();
6484
+ this.hitBranch(target);
6485
+ const { list } = this.findList;
6486
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6415
6487
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6416
6488
  this.clear();
6417
6489
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6418
6490
  }
6419
- getBestMatchLeaf() {
6420
- const { findList: targets } = this;
6421
- if (targets.length > 1) {
6491
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6492
+ if (list.length) {
6422
6493
  let find;
6423
- this.findList = [];
6494
+ this.findList = new LeafList();
6424
6495
  const { x, y } = this.point;
6425
6496
  const point = { x, y, radiusX: 0, radiusY: 0 };
6426
- for (let i = 0, len = targets.length; i < len; i++) {
6427
- find = targets[i];
6428
- if (LeafHelper.worldHittable(find)) {
6497
+ for (let i = 0, len = list.length; i < len; i++) {
6498
+ find = list[i];
6499
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6429
6500
  this.hitChild(find, point);
6430
6501
  if (this.findList.length)
6431
- return this.findList[0];
6502
+ return this.findList.list[0];
6432
6503
  }
6433
6504
  }
6434
6505
  }
6435
- return targets[0];
6506
+ if (bottomList) {
6507
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6508
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6509
+ if (this.findList.length)
6510
+ return this.findList.list[0];
6511
+ }
6512
+ }
6513
+ return list[0];
6436
6514
  }
6437
6515
  getPath(leaf) {
6438
6516
  const path = new LeafList();
@@ -6474,6 +6552,9 @@ class Picker {
6474
6552
  }
6475
6553
  return throughPath;
6476
6554
  }
6555
+ hitBranch(branch) {
6556
+ this.eachFind(branch.children, branch.__onlyHitMask);
6557
+ }
6477
6558
  eachFind(children, hitMask) {
6478
6559
  let child, hit;
6479
6560
  const { point } = this, len = children.length;
@@ -6495,11 +6576,11 @@ class Picker {
6495
6576
  }
6496
6577
  }
6497
6578
  }
6498
- hitChild(child, point) {
6579
+ hitChild(child, point, proxy) {
6499
6580
  if (this.exclude && this.exclude.has(child))
6500
6581
  return;
6501
6582
  if (child.__hitWorld(point))
6502
- this.findList.push(child);
6583
+ this.findList.add(proxy || child);
6503
6584
  }
6504
6585
  clear() {
6505
6586
  this.point = null;
@@ -6512,6 +6593,7 @@ class Picker {
6512
6593
  }
6513
6594
 
6514
6595
  const { Yes, NoAndSkip, YesAndSkip } = Answer;
6596
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
6515
6597
  class Selector {
6516
6598
  constructor(target, userConfig) {
6517
6599
  this.config = {};
@@ -6521,7 +6603,8 @@ class Selector {
6521
6603
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6522
6604
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6523
6605
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6524
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6606
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6607
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
6525
6608
  };
6526
6609
  this.target = target;
6527
6610
  if (userConfig)
@@ -6537,12 +6620,25 @@ class Selector {
6537
6620
  case 'string':
6538
6621
  switch (condition[0]) {
6539
6622
  case '#':
6540
- const leaf = this.getById(condition.substring(1), branch);
6541
- return one ? leaf : (leaf ? [leaf] : []);
6623
+ idCondition.id = condition.substring(1), condition = idCondition;
6624
+ break;
6542
6625
  case '.':
6543
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
6626
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
6627
+ break;
6544
6628
  default:
6545
- return this.getByMethod(this.methods.tag, branch, one, condition);
6629
+ tagCondition.tag = condition, condition = tagCondition;
6630
+ }
6631
+ case 'object':
6632
+ if (condition.id !== undefined) {
6633
+ const leaf = this.getById(condition.id, branch);
6634
+ return one ? leaf : (leaf ? [leaf] : []);
6635
+ }
6636
+ else if (condition.tag) {
6637
+ const { tag } = condition, isArray = tag instanceof Array;
6638
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
6639
+ }
6640
+ else {
6641
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
6546
6642
  }
6547
6643
  case 'function':
6548
6644
  return this.getByMethod(condition, branch, one, options);
@@ -6697,7 +6793,11 @@ function zoomLayerType() {
6697
6793
  defineKey(target, key, {
6698
6794
  set(value) { if (this.isLeafer)
6699
6795
  this[privateKey] = value; },
6700
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6796
+ get() {
6797
+ return this.isApp
6798
+ ? this.tree.zoomLayer
6799
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6800
+ }
6701
6801
  });
6702
6802
  };
6703
6803
  }
@@ -6837,7 +6937,7 @@ class UIData extends LeafData {
6837
6937
  const UnitConvert = {
6838
6938
  number(value, percentRefer) {
6839
6939
  if (typeof value === 'object')
6840
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
6940
+ return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
6841
6941
  return value;
6842
6942
  }
6843
6943
  };
@@ -7103,6 +7203,9 @@ let UI = UI_1 = class UI extends Leaf {
7103
7203
  pen.set(this.path = this.__.path || []);
7104
7204
  return pen;
7105
7205
  }
7206
+ get editConfig() { return undefined; }
7207
+ get editOuter() { return 'EditTool'; }
7208
+ get editInner() { return 'PathEditor'; }
7106
7209
  constructor(data) {
7107
7210
  super(data);
7108
7211
  }
@@ -7115,7 +7218,9 @@ let UI = UI_1 = class UI extends Leaf {
7115
7218
  }
7116
7219
  createProxyData() { return undefined; }
7117
7220
  find(_condition, _options) { return undefined; }
7221
+ findTag(tag) { return this.find({ tag }); }
7118
7222
  findOne(_condition, _options) { return undefined; }
7223
+ findId(id) { return this.findOne({ id }); }
7119
7224
  getPath(curve, pathForRender) {
7120
7225
  this.__layout.update();
7121
7226
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
@@ -7164,7 +7269,8 @@ let UI = UI_1 = class UI extends Leaf {
7164
7269
  __drawPathByBox(drawer) {
7165
7270
  const { x, y, width, height } = this.__layout.boxBounds;
7166
7271
  if (this.__.cornerRadius) {
7167
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7272
+ const { cornerRadius } = this.__;
7273
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7168
7274
  }
7169
7275
  else {
7170
7276
  drawer.rect(x, y, width, height);
@@ -7185,6 +7291,9 @@ let UI = UI_1 = class UI extends Leaf {
7185
7291
  static registerData(data) {
7186
7292
  dataProcessor(data)(this.prototype);
7187
7293
  }
7294
+ static setEditConfig(_config) { }
7295
+ static setEditOuter(_toolName) { }
7296
+ static setEditInner(_editorName) { }
7188
7297
  destroy() {
7189
7298
  this.fill = this.stroke = null;
7190
7299
  super.destroy();
@@ -7262,21 +7371,84 @@ __decorate([
7262
7371
  __decorate([
7263
7372
  rotationType(0, true)
7264
7373
  ], UI.prototype, "skewY", void 0);
7374
+ __decorate([
7375
+ positionType(0, true)
7376
+ ], UI.prototype, "offsetX", void 0);
7377
+ __decorate([
7378
+ positionType(0, true)
7379
+ ], UI.prototype, "offsetY", void 0);
7380
+ __decorate([
7381
+ positionType(0, true)
7382
+ ], UI.prototype, "scrollX", void 0);
7383
+ __decorate([
7384
+ positionType(0, true)
7385
+ ], UI.prototype, "scrollY", void 0);
7386
+ __decorate([
7387
+ autoLayoutType()
7388
+ ], UI.prototype, "origin", void 0);
7265
7389
  __decorate([
7266
7390
  autoLayoutType()
7267
7391
  ], UI.prototype, "around", void 0);
7268
7392
  __decorate([
7269
7393
  dataType(false)
7270
- ], UI.prototype, "draggable", void 0);
7394
+ ], UI.prototype, "lazy", void 0);
7271
7395
  __decorate([
7272
- dataType(false)
7273
- ], UI.prototype, "editable", void 0);
7396
+ naturalBoundsType(1)
7397
+ ], UI.prototype, "pixelRatio", void 0);
7398
+ __decorate([
7399
+ pathInputType()
7400
+ ], UI.prototype, "path", void 0);
7401
+ __decorate([
7402
+ pathType()
7403
+ ], UI.prototype, "windingRule", void 0);
7404
+ __decorate([
7405
+ pathType(true)
7406
+ ], UI.prototype, "closed", void 0);
7407
+ __decorate([
7408
+ autoLayoutType(false)
7409
+ ], UI.prototype, "flow", void 0);
7410
+ __decorate([
7411
+ boundsType(0)
7412
+ ], UI.prototype, "padding", void 0);
7413
+ __decorate([
7414
+ boundsType(0)
7415
+ ], UI.prototype, "gap", void 0);
7416
+ __decorate([
7417
+ boundsType('top-left')
7418
+ ], UI.prototype, "align", void 0);
7419
+ __decorate([
7420
+ boundsType(false)
7421
+ ], UI.prototype, "wrap", void 0);
7422
+ __decorate([
7423
+ boundsType('box')
7424
+ ], UI.prototype, "itemBox", void 0);
7274
7425
  __decorate([
7275
- dataType('size')
7276
- ], UI.prototype, "editSize", void 0);
7426
+ boundsType(true)
7427
+ ], UI.prototype, "inFlow", void 0);
7428
+ __decorate([
7429
+ boundsType()
7430
+ ], UI.prototype, "autoWidth", void 0);
7431
+ __decorate([
7432
+ boundsType()
7433
+ ], UI.prototype, "autoHeight", void 0);
7434
+ __decorate([
7435
+ boundsType()
7436
+ ], UI.prototype, "autoBox", void 0);
7437
+ __decorate([
7438
+ boundsType()
7439
+ ], UI.prototype, "widthRange", void 0);
7440
+ __decorate([
7441
+ boundsType()
7442
+ ], UI.prototype, "heightRange", void 0);
7443
+ __decorate([
7444
+ dataType(false)
7445
+ ], UI.prototype, "draggable", void 0);
7277
7446
  __decorate([
7278
7447
  dataType()
7279
- ], UI.prototype, "editorStyle", void 0);
7448
+ ], UI.prototype, "dragBounds", void 0);
7449
+ __decorate([
7450
+ dataType(false)
7451
+ ], UI.prototype, "editable", void 0);
7280
7452
  __decorate([
7281
7453
  hitType(true)
7282
7454
  ], UI.prototype, "hittable", void 0);
@@ -7331,21 +7503,6 @@ __decorate([
7331
7503
  __decorate([
7332
7504
  strokeType(10)
7333
7505
  ], UI.prototype, "miterLimit", void 0);
7334
- __decorate([
7335
- dataType(false)
7336
- ], UI.prototype, "lazy", void 0);
7337
- __decorate([
7338
- naturalBoundsType(1)
7339
- ], UI.prototype, "pixelRatio", void 0);
7340
- __decorate([
7341
- pathInputType()
7342
- ], UI.prototype, "path", void 0);
7343
- __decorate([
7344
- pathType()
7345
- ], UI.prototype, "windingRule", void 0);
7346
- __decorate([
7347
- pathType(true)
7348
- ], UI.prototype, "closed", void 0);
7349
7506
  __decorate([
7350
7507
  arrowType('none')
7351
7508
  ], UI.prototype, "startArrow", void 0);
@@ -7468,7 +7625,6 @@ Group = __decorate([
7468
7625
  var Leafer_1;
7469
7626
  const debug$3 = Debug.get('Leafer');
7470
7627
  let Leafer = Leafer_1 = class Leafer extends Group {
7471
- static get version() { return '1.0.0-rc.21'; }
7472
7628
  get __tag() { return 'Leafer'; }
7473
7629
  get isApp() { return false; }
7474
7630
  get app() { return this.parent || this; }
@@ -7521,7 +7677,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7521
7677
  if (this.isApp)
7522
7678
  this.__setApp();
7523
7679
  this.__checkAutoLayout(config);
7524
- this.updateLazyBounds();
7525
7680
  this.view = canvas.view;
7526
7681
  if (parentApp) {
7527
7682
  this.__bindApp(parentApp);
@@ -7581,9 +7736,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7581
7736
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7582
7737
  Object.keys(data).forEach(key => this[key] = data[key]);
7583
7738
  }
7584
- forceFullRender() {
7585
- this.forceRender();
7586
- }
7587
7739
  forceRender(bounds) {
7588
7740
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7589
7741
  if (this.viewReady)
@@ -7661,7 +7813,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7661
7813
  this.canvas.backgroundColor = newValue;
7662
7814
  }
7663
7815
  else {
7664
- this.forceFullRender();
7816
+ this.forceRender();
7665
7817
  }
7666
7818
  }
7667
7819
  __onCreated() {
@@ -7765,6 +7917,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7765
7917
  __listenEvents() {
7766
7918
  const runId = Run.start('FirstCreate ' + this.innerName);
7767
7919
  this.once(LeaferEvent.START, () => Run.end(runId));
7920
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7768
7921
  this.once(LayoutEvent.END, () => this.__onReady());
7769
7922
  this.once(RenderEvent.START, () => this.__onCreated());
7770
7923
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7835,8 +7988,8 @@ Rect = __decorate([
7835
7988
  registerUI()
7836
7989
  ], Rect);
7837
7990
 
7838
- const rect = Rect.prototype;
7839
- const group = Group.prototype;
7991
+ const rect$1 = Rect.prototype;
7992
+ const group$1 = Group.prototype;
7840
7993
  const bounds$1 = {};
7841
7994
  const { copy: copy$3, add } = BoundsHelper;
7842
7995
  let Box = class Box extends Group {
@@ -7871,6 +8024,8 @@ let Box = class Box extends Group {
7871
8024
  else {
7872
8025
  this.__updateRectBoxBounds();
7873
8026
  }
8027
+ if (data.flow)
8028
+ this.__updateContentBounds();
7874
8029
  }
7875
8030
  __updateStrokeBounds() { }
7876
8031
  __updateRenderBounds() {
@@ -7915,28 +8070,28 @@ __decorate([
7915
8070
  affectRenderBoundsType('show')
7916
8071
  ], Box.prototype, "overflow", void 0);
7917
8072
  __decorate([
7918
- rewrite(rect.__updateStrokeSpread)
8073
+ rewrite(rect$1.__updateStrokeSpread)
7919
8074
  ], Box.prototype, "__updateStrokeSpread", null);
7920
8075
  __decorate([
7921
- rewrite(rect.__updateRenderSpread)
8076
+ rewrite(rect$1.__updateRenderSpread)
7922
8077
  ], Box.prototype, "__updateRectRenderSpread", null);
7923
8078
  __decorate([
7924
- rewrite(rect.__updateBoxBounds)
8079
+ rewrite(rect$1.__updateBoxBounds)
7925
8080
  ], Box.prototype, "__updateRectBoxBounds", null);
7926
8081
  __decorate([
7927
- rewrite(rect.__updateStrokeBounds)
8082
+ rewrite(rect$1.__updateStrokeBounds)
7928
8083
  ], Box.prototype, "__updateStrokeBounds", null);
7929
8084
  __decorate([
7930
- rewrite(rect.__updateRenderBounds)
8085
+ rewrite(rect$1.__updateRenderBounds)
7931
8086
  ], Box.prototype, "__updateRectRenderBounds", null);
7932
8087
  __decorate([
7933
- rewrite(rect.__updateChange)
8088
+ rewrite(rect$1.__updateChange)
7934
8089
  ], Box.prototype, "__updateRectChange", null);
7935
8090
  __decorate([
7936
- rewrite(rect.__render)
8091
+ rewrite(rect$1.__render)
7937
8092
  ], Box.prototype, "__renderRect", null);
7938
8093
  __decorate([
7939
- rewrite(group.__render)
8094
+ rewrite(group$1.__render)
7940
8095
  ], Box.prototype, "__renderGroup", null);
7941
8096
  Box = __decorate([
7942
8097
  rewriteAble(),
@@ -8280,9 +8435,10 @@ Canvas = __decorate([
8280
8435
  registerUI()
8281
8436
  ], Canvas);
8282
8437
 
8283
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8438
+ const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8284
8439
  let Text = class Text extends UI {
8285
8440
  get __tag() { return 'Text'; }
8441
+ get editInner() { return 'TextEditor'; }
8286
8442
  get textDrawData() {
8287
8443
  this.__layout.update();
8288
8444
  return this.__.__textDrawData;
@@ -8352,7 +8508,7 @@ let Text = class Text extends UI {
8352
8508
  if (italic)
8353
8509
  b.width += fontSize * 0.16;
8354
8510
  const contentBounds = includes(b, bounds) ? b : bounds;
8355
- if (contentBounds !== layout.contentBounds) {
8511
+ if (!isSame$1(contentBounds, layout.contentBounds)) {
8356
8512
  layout.contentBounds = contentBounds;
8357
8513
  layout.renderChanged = true;
8358
8514
  setList(data.__textBoxBounds = {}, [b, bounds]);
@@ -8380,9 +8536,6 @@ __decorate([
8380
8536
  __decorate([
8381
8537
  boundsType(0)
8382
8538
  ], Text.prototype, "height", void 0);
8383
- __decorate([
8384
- boundsType(0)
8385
- ], Text.prototype, "padding", void 0);
8386
8539
  __decorate([
8387
8540
  surfaceType('#000000')
8388
8541
  ], Text.prototype, "fill", void 0);
@@ -8511,7 +8664,7 @@ function penPathType() {
8511
8664
  };
8512
8665
  }
8513
8666
 
8514
- const version = "1.0.0-rc.21";
8667
+ const version = "1.0.0-rc.23";
8515
8668
 
8516
8669
  let App = class App extends Leafer {
8517
8670
  get __tag() { return 'App'; }
@@ -8605,7 +8758,10 @@ let App = class App extends Leafer {
8605
8758
  this.renderer.update();
8606
8759
  }
8607
8760
  __render(canvas, options) {
8608
- canvas.setWorld(options.matrix || this.__world);
8761
+ if (options.matrix) {
8762
+ const { a, b, c, d, e, f } = options.matrix;
8763
+ canvas.setTransform(a, b, c, d, e, f);
8764
+ }
8609
8765
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8610
8766
  }
8611
8767
  __onResize(event) {
@@ -8727,6 +8883,35 @@ let DragEvent = class DragEvent extends PointerEvent {
8727
8883
  static setData(data) {
8728
8884
  this.data = data;
8729
8885
  }
8886
+ static getValidMove(leaf, start, total) {
8887
+ const { draggable, dragBounds, x, y } = leaf;
8888
+ const move = leaf.getLocalPoint(total, null, true);
8889
+ move.x += start.x - x;
8890
+ move.y += start.y - y;
8891
+ if (dragBounds)
8892
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8893
+ if (draggable === 'x')
8894
+ move.y = 0;
8895
+ if (draggable === 'y')
8896
+ move.x = 0;
8897
+ return move;
8898
+ }
8899
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8900
+ const x = box.x + move.x, y = box.y + move.y;
8901
+ const right = x + box.width, bottom = y + box.height;
8902
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8903
+ if (!change)
8904
+ move = Object.assign({}, move);
8905
+ if (x < dragBounds.x)
8906
+ move.x += dragBounds.x - x;
8907
+ else if (right > boundsRight)
8908
+ move.x += boundsRight - right;
8909
+ if (y < dragBounds.y)
8910
+ move.y += dragBounds.y - y;
8911
+ else if (bottom > boundsBottom)
8912
+ move.y += boundsBottom - bottom;
8913
+ return move;
8914
+ }
8730
8915
  getPageMove(total) {
8731
8916
  this.assignMove(total);
8732
8917
  return this.current.getPagePoint(move, null, true);
@@ -8836,9 +9021,7 @@ function addInteractionWindow(leafer) {
8836
9021
  if (leafer.isApp)
8837
9022
  return;
8838
9023
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
8839
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8840
- if (x || y)
8841
- leafer.zoomLayer.move(x, y);
9024
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8842
9025
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
8843
9026
  const { zoomLayer } = leafer;
8844
9027
  const changeScale = leafer.getValidScale(e.scale);
@@ -9107,9 +9290,14 @@ class Dragger {
9107
9290
  if (this.dragging) {
9108
9291
  this.interaction.emit(DragEvent.START, this.dragData);
9109
9292
  this.getDragableList(this.dragData.path);
9293
+ this.setDragStartPoints(this.realDragableList = this.getList());
9110
9294
  }
9111
9295
  }
9112
9296
  }
9297
+ setDragStartPoints(list) {
9298
+ this.dragStartPoints = {};
9299
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9300
+ }
9113
9301
  getDragableList(path) {
9114
9302
  let leaf;
9115
9303
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9139,10 +9327,10 @@ class Dragger {
9139
9327
  }
9140
9328
  dragReal() {
9141
9329
  const { running } = this.interaction;
9142
- const list = this.getList();
9330
+ const list = this.realDragableList;
9143
9331
  if (list.length && running) {
9144
- const { moveX, moveY } = this.dragData;
9145
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9332
+ const { totalX, totalY } = this.dragData;
9333
+ list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9146
9334
  }
9147
9335
  }
9148
9336
  dragOverOrOut(data) {
@@ -9611,7 +9799,8 @@ class InteractionBase {
9611
9799
  }
9612
9800
  findPath(data, options) {
9613
9801
  const { hitRadius, through } = this.config.pointer;
9614
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9802
+ const { bottomList } = this;
9803
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9615
9804
  if (find.throughPath)
9616
9805
  data.throughPath = find.throughPath;
9617
9806
  data.path = find.path;
@@ -9624,7 +9813,7 @@ class InteractionBase {
9624
9813
  const app = this.target.app;
9625
9814
  if (!app || !app.isApp)
9626
9815
  return false;
9627
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9816
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9628
9817
  }
9629
9818
  checkPath(data, useDefaultPath) {
9630
9819
  if (useDefaultPath || this.canMove(data))
@@ -9690,7 +9879,7 @@ class InteractionBase {
9690
9879
  const { path } = data;
9691
9880
  for (let i = 0, len = path.length; i < len; i++) {
9692
9881
  leaf = path.list[i];
9693
- cursor = leaf.cursor;
9882
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9694
9883
  if (cursor)
9695
9884
  break;
9696
9885
  }
@@ -9848,6 +10037,8 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9848
10037
  const inner = {};
9849
10038
  const leaf = Leaf.prototype;
9850
10039
  leaf.__hitWorld = function (point) {
10040
+ if (!this.__.hitSelf)
10041
+ return false;
9851
10042
  if (this.__.hitRadius) {
9852
10043
  copy$2(inner, point), point = inner;
9853
10044
  setRadius(point, this.__.hitRadius);
@@ -9875,8 +10066,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
9875
10066
  this.__drawRenderPath(canvas); };
9876
10067
 
9877
10068
  const matrix = new Matrix();
9878
- const ui$1 = UI.prototype;
9879
- ui$1.__updateHitCanvas = function () {
10069
+ const ui$2 = UI.prototype;
10070
+ ui$2.__updateHitCanvas = function () {
9880
10071
  const data = this.__, { hitCanvasManager } = this.leafer;
9881
10072
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9882
10073
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9903,7 +10094,7 @@ ui$1.__updateHitCanvas = function () {
9903
10094
  this.__drawHitPath(h);
9904
10095
  h.setStrokeOptions(data);
9905
10096
  };
9906
- ui$1.__hit = function (inner) {
10097
+ ui$2.__hit = function (inner) {
9907
10098
  if (Platform.name === 'miniapp')
9908
10099
  this.__drawHitPath(this.__hitCanvas);
9909
10100
  const data = this.__;
@@ -9943,22 +10134,24 @@ ui$1.__hit = function (inner) {
9943
10134
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9944
10135
  };
9945
10136
 
9946
- const ui = new UI();
9947
- Rect.prototype.__updateHitCanvas = function () {
10137
+ const ui$1 = new UI();
10138
+ const rect = Rect.prototype;
10139
+ rect.__updateHitCanvas = function () {
9948
10140
  if (this.stroke || this.cornerRadius)
9949
- ui.__updateHitCanvas.call(this);
10141
+ ui$1.__updateHitCanvas.call(this);
9950
10142
  };
9951
- Rect.prototype.__hitFill = function (inner) {
9952
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10143
+ rect.__hitFill = function (inner) {
10144
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9953
10145
  };
9954
10146
 
9955
- UI.prototype.find = function (condition, options) {
10147
+ const ui = UI.prototype, group = Group.prototype;
10148
+ ui.find = function (condition, options) {
9956
10149
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9957
10150
  };
9958
- UI.prototype.findOne = function (condition, options) {
10151
+ ui.findOne = function (condition, options) {
9959
10152
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9960
10153
  };
9961
- Group.prototype.pick = function (hitPoint, options) {
10154
+ group.pick = function (hitPoint, options) {
9962
10155
  this.__layout.update();
9963
10156
  if (!options)
9964
10157
  options = {};
@@ -10292,7 +10485,7 @@ function shape(ui, current, options) {
10292
10485
  }
10293
10486
  else {
10294
10487
  const { renderShapeSpread: spread } = ui.__layout;
10295
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
10488
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
10296
10489
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
10297
10490
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
10298
10491
  if (fitMatrix.a < 1) {
@@ -10375,79 +10568,75 @@ const PaintModule = {
10375
10568
 
10376
10569
  let origin = {};
10377
10570
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10378
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10571
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10379
10572
  const transform = get$4();
10380
- const swap = rotation && rotation !== 180;
10381
- const sw = box.width / (swap ? height : width);
10382
- const sh = box.height / (swap ? width : height);
10383
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10384
- const x = box.x + (box.width - width * scale) / 2;
10385
- const y = box.y + (box.height - height * scale) / 2;
10386
- translate$1(transform, x, y);
10387
- scaleHelper(transform, scale);
10573
+ translate$1(transform, box.x + x, box.y + y);
10574
+ scaleHelper(transform, scaleX, scaleY);
10388
10575
  if (rotation)
10389
10576
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10390
- data.scaleX = data.scaleY = scale;
10391
10577
  data.transform = transform;
10392
10578
  }
10393
10579
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10394
10580
  const transform = get$4();
10395
- translate$1(transform, box.x, box.y);
10396
- if (x || y)
10397
- translate$1(transform, x, y);
10398
- if (scaleX) {
10581
+ translate$1(transform, box.x + x, box.y + y);
10582
+ if (scaleX)
10399
10583
  scaleHelper(transform, scaleX, scaleY);
10400
- data.scaleX = transform.a;
10401
- data.scaleY = transform.d;
10402
- }
10403
10584
  if (rotation)
10404
10585
  rotate(transform, rotation);
10405
10586
  data.transform = transform;
10406
10587
  }
10407
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10588
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
10408
10589
  const transform = get$4();
10409
10590
  if (rotation) {
10410
- rotate(transform, rotation);
10411
- switch (rotation) {
10412
- case 90:
10413
- translate$1(transform, height, 0);
10414
- break;
10415
- case 180:
10416
- translate$1(transform, width, height);
10417
- break;
10418
- case 270:
10419
- translate$1(transform, 0, width);
10420
- break;
10591
+ if (align === 'center') {
10592
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10593
+ }
10594
+ else {
10595
+ rotate(transform, rotation);
10596
+ switch (rotation) {
10597
+ case 90:
10598
+ translate$1(transform, height, 0);
10599
+ break;
10600
+ case 180:
10601
+ translate$1(transform, width, height);
10602
+ break;
10603
+ case 270:
10604
+ translate$1(transform, 0, width);
10605
+ break;
10606
+ }
10421
10607
  }
10422
10608
  }
10423
- origin.x = box.x;
10424
- origin.y = box.y;
10425
- if (x || y)
10426
- origin.x += x, origin.y += y;
10609
+ origin.x = box.x + x;
10610
+ origin.y = box.y + y;
10427
10611
  translate$1(transform, origin.x, origin.y);
10428
- if (scaleX) {
10612
+ if (scaleX)
10429
10613
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10430
- data.scaleX = scaleX;
10431
- data.scaleY = scaleY;
10432
- }
10433
10614
  data.transform = transform;
10434
10615
  }
10435
10616
 
10436
10617
  const { get: get$3, translate } = MatrixHelper;
10437
10618
  const tempBox = new Bounds();
10619
+ const tempPoint = {};
10438
10620
  function createData(leafPaint, image, paint, box) {
10439
10621
  let { width, height } = image;
10440
10622
  if (paint.padding)
10441
10623
  box = tempBox.set(box).shrink(paint.padding);
10442
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10624
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
10443
10625
  const sameBox = box.width === width && box.height === height;
10444
10626
  if (blendMode)
10445
10627
  leafPaint.blendMode = blendMode;
10446
10628
  const data = leafPaint.data = { mode };
10447
- let x, y, scaleX, scaleY;
10448
- if (offset)
10449
- x = offset.x, y = offset.y;
10450
- if (size) {
10629
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10630
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10631
+ let x = 0, y = 0, scaleX, scaleY;
10632
+ if (!mode || mode === 'cover' || mode === 'fit') {
10633
+ if (!sameBox || rotation) {
10634
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10635
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10636
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10637
+ }
10638
+ }
10639
+ else if (size) {
10451
10640
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10452
10641
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10453
10642
  }
@@ -10455,26 +10644,36 @@ function createData(leafPaint, image, paint, box) {
10455
10644
  scaleX = typeof scale === 'number' ? scale : scale.x;
10456
10645
  scaleY = typeof scale === 'number' ? scale : scale.y;
10457
10646
  }
10647
+ if (align) {
10648
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10649
+ if (scaleX)
10650
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10651
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
10652
+ x += tempPoint.x, y += tempPoint.y;
10653
+ }
10654
+ if (offset)
10655
+ x += offset.x, y += offset.y;
10458
10656
  switch (mode) {
10459
10657
  case 'strench':
10460
10658
  if (!sameBox)
10461
10659
  width = box.width, height = box.height;
10462
10660
  break;
10661
+ case 'normal':
10463
10662
  case 'clip':
10464
- if (offset || scaleX || rotation)
10663
+ if (x || y || scaleX || rotation)
10465
10664
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10466
10665
  break;
10467
10666
  case 'repeat':
10468
10667
  if (!sameBox || scaleX || rotation)
10469
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10668
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10470
10669
  if (!repeat)
10471
10670
  data.repeat = 'repeat';
10472
10671
  break;
10473
10672
  case 'fit':
10474
10673
  case 'cover':
10475
10674
  default:
10476
- if (!sameBox || rotation)
10477
- fillOrFitMode(data, mode, box, width, height, rotation);
10675
+ if (scaleX)
10676
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10478
10677
  }
10479
10678
  if (!data.transform) {
10480
10679
  if (box.x || box.y) {
@@ -10482,6 +10681,10 @@ function createData(leafPaint, image, paint, box) {
10482
10681
  translate(data.transform, box.x, box.y);
10483
10682
  }
10484
10683
  }
10684
+ if (scaleX && mode !== 'strench') {
10685
+ data.scaleX = scaleX;
10686
+ data.scaleY = scaleY;
10687
+ }
10485
10688
  data.width = width;
10486
10689
  data.height = height;
10487
10690
  if (opacity)
@@ -11379,11 +11582,13 @@ function clipText(drawData, style) {
11379
11582
  const { rows, overflow } = drawData;
11380
11583
  let { textOverflow } = style;
11381
11584
  rows.splice(overflow);
11382
- if (textOverflow !== 'hide') {
11383
- if (textOverflow === 'ellipsis')
11585
+ if (textOverflow && textOverflow !== 'show') {
11586
+ if (textOverflow === 'hide')
11587
+ textOverflow = '';
11588
+ else if (textOverflow === 'ellipsis')
11384
11589
  textOverflow = '...';
11385
11590
  let char, charRight;
11386
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
11591
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
11387
11592
  const right = style.x + style.width - ellipsisWidth;
11388
11593
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
11389
11594
  list.forEach(row => {
@@ -11537,6 +11742,13 @@ const ExportModule = {
11537
11742
  resolve();
11538
11743
  this.running = false;
11539
11744
  };
11745
+ if (filename === 'json') {
11746
+ return over({ data: leaf.toJSON() });
11747
+ }
11748
+ else if (FileHelper.fileType(filename) === 'json') {
11749
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
11750
+ return over({ data: true });
11751
+ }
11540
11752
  const { leafer } = leaf;
11541
11753
  if (leafer) {
11542
11754
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -11544,8 +11756,12 @@ const ExportModule = {
11544
11756
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11545
11757
  const { worldTransform, isLeafer, isFrame } = leaf;
11546
11758
  const { slice, trim, onCanvas } = options;
11547
- const scale = options.scale || 1;
11548
- const pixelRatio = options.pixelRatio || 1;
11759
+ let scale = options.scale || 1;
11760
+ let pixelRatio = options.pixelRatio || 1;
11761
+ if (leaf.isApp) {
11762
+ scale *= pixelRatio;
11763
+ pixelRatio = leaf.app.pixelRatio;
11764
+ }
11549
11765
  const screenshot = options.screenshot || leaf.isApp;
11550
11766
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11551
11767
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -11713,4 +11929,4 @@ LeaferCanvas.prototype.updateViewSize = function () {
11713
11929
  }
11714
11930
  };
11715
11931
 
11716
- 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, 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 };
11932
+ 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, 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 };