@leafer/miniapp 1.12.4 → 2.0.1

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.
@@ -58,8 +58,8 @@ function isEmptyData(value) {
58
58
 
59
59
  const DataHelper = {
60
60
  default(t, defaultData) {
61
- assign$1(defaultData, t);
62
- assign$1(t, defaultData);
61
+ assign$2(defaultData, t);
62
+ assign$2(t, defaultData);
63
63
  return t;
64
64
  },
65
65
  assign(t, merge, exclude) {
@@ -67,9 +67,9 @@ const DataHelper = {
67
67
  Object.keys(merge).forEach(key => {
68
68
  var _a, _b;
69
69
  value = merge[key];
70
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$1(t[key], merge[key], exclude && exclude[key]);
70
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$2(t[key], merge[key], exclude && exclude[key]);
71
71
  if (exclude && key in exclude) {
72
- if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$1(t[key] = {}, merge[key], exclude[key]);
72
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$2(t[key] = {}, merge[key], exclude[key]);
73
73
  return;
74
74
  }
75
75
  t[key] = merge[key];
@@ -95,7 +95,7 @@ const DataHelper = {
95
95
  }
96
96
  };
97
97
 
98
- const {assign: assign$1} = DataHelper;
98
+ const {assign: assign$2} = DataHelper;
99
99
 
100
100
  class LeafData {
101
101
  get __useNaturalRatio() {
@@ -216,59 +216,6 @@ class LeafData {
216
216
  }
217
217
  }
218
218
 
219
- const {floor: floor$3, max: max$7} = Math;
220
-
221
- const Platform = {
222
- toURL(text, fileType) {
223
- let url = encodeURIComponent(text);
224
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
225
- return url;
226
- },
227
- image: {
228
- hitCanvasSize: 100,
229
- maxCacheSize: 2560 * 1600,
230
- maxPatternSize: 4096 * 2160,
231
- crossOrigin: "anonymous",
232
- isLarge(size, scaleX, scaleY, largeSize) {
233
- return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
234
- },
235
- isSuperLarge(size, scaleX, scaleY) {
236
- return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
237
- },
238
- getRealURL(url) {
239
- const {prefix: prefix, suffix: suffix} = Platform.image;
240
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
241
- if (prefix && url[0] === "/") url = prefix + url;
242
- return url;
243
- },
244
- resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
245
- const canvas = Platform.origin.createCanvas(max$7(floor$3(width + (xGap || 0)), 1), max$7(floor$3(height + (yGap || 0)), 1));
246
- const ctx = canvas.getContext("2d");
247
- if (opacity) ctx.globalAlpha = opacity;
248
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
249
- if (image) {
250
- if (clip) {
251
- const scaleX = width / clip.width, scaleY = height / clip.height;
252
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
253
- ctx.drawImage(image, 0, 0, image.width, image.height);
254
- } else ctx.drawImage(image, 0, 0, width, height);
255
- }
256
- return canvas;
257
- },
258
- setPatternTransform(pattern, transform, paint) {
259
- try {
260
- if (transform && pattern.setTransform) {
261
- pattern.setTransform(transform);
262
- transform = undefined;
263
- }
264
- } catch (_a) {}
265
- if (paint) DataHelper.stintSet(paint, "transform", transform);
266
- }
267
- }
268
- };
269
-
270
- const {image: image$1} = Platform;
271
-
272
219
  const IncrementId = {
273
220
  RUNTIME: "runtime",
274
221
  LEAF: "leaf",
@@ -291,7 +238,7 @@ const I$2 = IncrementId;
291
238
 
292
239
  let tempA, tempB, tempTo;
293
240
 
294
- const {max: max$6} = Math, tempFour = [ 0, 0, 0, 0 ];
241
+ const {max: max$7} = Math, tempFour = [ 0, 0, 0, 0 ];
295
242
 
296
243
  const FourNumberHelper = {
297
244
  zero: [ ...tempFour ],
@@ -343,9 +290,9 @@ const FourNumberHelper = {
343
290
  return data;
344
291
  },
345
292
  max(t, other, change) {
346
- if (isNumber(t) && isNumber(other)) return max$6(t, other);
293
+ if (isNumber(t) && isNumber(other)) return max$7(t, other);
347
294
  toTempAB(t, other, change);
348
- return set$2(tempTo, max$6(tempA[0], tempB[0]), max$6(tempA[1], tempB[1]), max$6(tempA[2], tempB[2]), max$6(tempA[3], tempB[3]));
295
+ return set$2(tempTo, max$7(tempA[0], tempB[0]), max$7(tempA[1], tempB[1]), max$7(tempA[2], tempB[2]), max$7(tempA[3], tempB[3]));
349
296
  },
350
297
  add(t, other, change) {
351
298
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -362,7 +309,7 @@ const FourNumberHelper = {
362
309
 
363
310
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
364
311
 
365
- const {round: round$6, pow: pow$2, max: max$5, floor: floor$2, PI: PI$4} = Math;
312
+ const {round: round$6, pow: pow$2, max: max$6, floor: floor$3, PI: PI$4} = Math;
366
313
 
367
314
  const MathHelper = {
368
315
  within(value, min, max) {
@@ -416,7 +363,7 @@ const MathHelper = {
416
363
  }
417
364
  },
418
365
  getFloorScale(num, min = 1) {
419
- return max$5(floor$2(num), min) / num;
366
+ return max$6(floor$3(num), min) / num;
420
367
  },
421
368
  randInt: randInt,
422
369
  randColor(opacity) {
@@ -463,7 +410,7 @@ function getMatrixData() {
463
410
 
464
411
  const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
465
412
 
466
- const {float: float$5} = MathHelper;
413
+ const {float: float$6} = MathHelper;
467
414
 
468
415
  const tempPoint$5 = {};
469
416
 
@@ -714,12 +661,12 @@ const MatrixHelper = {
714
661
  const cosR = c / scaleY;
715
662
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
716
663
  }
717
- const cosR = float$5(cos$6(rotation));
664
+ const cosR = float$6(cos$6(rotation));
718
665
  const sinR = sin$6(rotation);
719
- scaleX = float$5(scaleX), scaleY = float$5(scaleY);
720
- skewX = cosR ? float$5((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
721
- skewY = cosR ? float$5((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
722
- rotation = float$5(rotation / OneRadian);
666
+ scaleX = float$6(scaleX), scaleY = float$6(scaleY);
667
+ skewX = cosR ? float$6((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
668
+ skewY = cosR ? float$6((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
669
+ rotation = float$6(rotation / OneRadian);
723
670
  } else {
724
671
  scaleX = a;
725
672
  scaleY = d;
@@ -763,7 +710,7 @@ const MatrixHelper = {
763
710
 
764
711
  const M$b = MatrixHelper;
765
712
 
766
- const {float: float$4} = MathHelper;
713
+ const {float: float$5} = MathHelper;
767
714
 
768
715
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
769
716
 
@@ -904,7 +851,7 @@ const PointHelper = {
904
851
  return points;
905
852
  },
906
853
  isSame(t, point) {
907
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
854
+ return float$5(t.x) === float$5(point.x) && float$5(t.y) === float$5(point.y);
908
855
  },
909
856
  reset(t) {
910
857
  P$7.reset(t);
@@ -1259,9 +1206,9 @@ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPo
1259
1206
 
1260
1207
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1261
1208
 
1262
- const {float: float$3, fourNumber: fourNumber$1} = MathHelper;
1209
+ const {float: float$4, fourNumber: fourNumber$1} = MathHelper;
1263
1210
 
1264
- const {floor: floor$1, ceil: ceil$2} = Math;
1211
+ const {floor: floor$2, ceil: ceil$2} = Math;
1265
1212
 
1266
1213
  let right$4, bottom$3, boundsRight, boundsBottom;
1267
1214
 
@@ -1269,10 +1216,10 @@ const point$2 = {};
1269
1216
 
1270
1217
  const toPoint$5 = {};
1271
1218
 
1272
- const tempBounds$3 = {};
1219
+ const tempBounds$4 = {};
1273
1220
 
1274
1221
  const BoundsHelper = {
1275
- tempBounds: tempBounds$3,
1222
+ tempBounds: tempBounds$4,
1276
1223
  set(t, x = 0, y = 0, width = 0, height = 0) {
1277
1224
  t.x = x;
1278
1225
  t.y = y;
@@ -1341,9 +1288,9 @@ const BoundsHelper = {
1341
1288
  t.height *= scaleY;
1342
1289
  },
1343
1290
  tempToOuterOf(t, matrix) {
1344
- B.copy(tempBounds$3, t);
1345
- B.toOuterOf(tempBounds$3, matrix);
1346
- return tempBounds$3;
1291
+ B.copy(tempBounds$4, t);
1292
+ B.toOuterOf(tempBounds$4, matrix);
1293
+ return tempBounds$4;
1347
1294
  },
1348
1295
  getOuterOf(t, matrix) {
1349
1296
  t = Object.assign({}, t);
@@ -1401,9 +1348,9 @@ const BoundsHelper = {
1401
1348
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1402
1349
  to || (to = put);
1403
1350
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1404
- tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1405
- tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1406
- AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1351
+ tempBounds$4.width = changeSize ? put.width *= putScale : put.width * putScale;
1352
+ tempBounds$4.height = changeSize ? put.height *= putScale : put.height * putScale;
1353
+ AlignHelper.toPoint(align, tempBounds$4, t, to, true, true);
1407
1354
  },
1408
1355
  getSpread(t, spread, side) {
1409
1356
  const n = {};
@@ -1418,8 +1365,8 @@ const BoundsHelper = {
1418
1365
  },
1419
1366
  ceil(t) {
1420
1367
  const {x: x, y: y} = t;
1421
- t.x = floor$1(t.x);
1422
- t.y = floor$1(t.y);
1368
+ t.x = floor$2(t.x);
1369
+ t.y = floor$2(t.y);
1423
1370
  t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1424
1371
  t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1425
1372
  },
@@ -1434,10 +1381,10 @@ const BoundsHelper = {
1434
1381
  }
1435
1382
  },
1436
1383
  float(t, maxLength) {
1437
- t.x = float$3(t.x, maxLength);
1438
- t.y = float$3(t.y, maxLength);
1439
- t.width = float$3(t.width, maxLength);
1440
- t.height = float$3(t.height, maxLength);
1384
+ t.x = float$4(t.x, maxLength);
1385
+ t.y = float$4(t.y, maxLength);
1386
+ t.width = float$4(t.width, maxLength);
1387
+ t.height = float$4(t.height, maxLength);
1441
1388
  },
1442
1389
  add(t, bounds, isPoint) {
1443
1390
  right$4 = t.x + t.width;
@@ -1551,6 +1498,9 @@ const BoundsHelper = {
1551
1498
  isEmpty(t) {
1552
1499
  return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
1553
1500
  },
1501
+ hasSize(t) {
1502
+ return t.width && t.height;
1503
+ },
1554
1504
  reset(t) {
1555
1505
  B.set(t);
1556
1506
  }
@@ -1703,7 +1653,7 @@ class Bounds {
1703
1653
  }
1704
1654
  }
1705
1655
 
1706
- const tempBounds$2 = new Bounds;
1656
+ const tempBounds$3 = new Bounds;
1707
1657
 
1708
1658
  class AutoBounds {
1709
1659
  constructor(top, right, bottom, left, width, height) {
@@ -1727,6 +1677,12 @@ class AutoBounds {
1727
1677
  }
1728
1678
  }
1729
1679
 
1680
+ const UnitConvertHelper = {
1681
+ number(value, percentRefer) {
1682
+ return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
1683
+ }
1684
+ };
1685
+
1730
1686
  const StringNumberMap = {
1731
1687
  0: 1,
1732
1688
  1: 1,
@@ -1743,6 +1699,69 @@ const StringNumberMap = {
1743
1699
  E: 1
1744
1700
  };
1745
1701
 
1702
+ const {floor: floor$1, max: max$5} = Math;
1703
+
1704
+ const Platform = {
1705
+ toURL(text, fileType) {
1706
+ let url = encodeURIComponent(text);
1707
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
1708
+ return url;
1709
+ },
1710
+ image: {
1711
+ hitCanvasSize: 100,
1712
+ maxCacheSize: 2560 * 1600,
1713
+ maxPatternSize: 4096 * 2160,
1714
+ crossOrigin: "anonymous",
1715
+ isLarge(size, scaleX, scaleY, largeSize) {
1716
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
1717
+ },
1718
+ isSuperLarge(size, scaleX, scaleY) {
1719
+ return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
1720
+ },
1721
+ getRealURL(url) {
1722
+ const {prefix: prefix, suffix: suffix} = image$1;
1723
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
1724
+ if (prefix && url[0] === "/") url = prefix + url;
1725
+ return url;
1726
+ },
1727
+ resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1728
+ const realWidth = max$5(floor$1(width + (xGap || 0)), 1), realHeight = max$5(floor$1(height + (yGap || 0)), 1);
1729
+ let interlaceX, interlaceY, interlaceOffset;
1730
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1731
+ const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1732
+ const ctx = canvas.getContext("2d");
1733
+ if (opacity) ctx.globalAlpha = opacity;
1734
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
1735
+ if (image$1.canUse(view)) {
1736
+ if (clip) {
1737
+ const scaleX = width / clip.width, scaleY = height / clip.height;
1738
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
1739
+ ctx.drawImage(view, 0, 0, view.width, view.height);
1740
+ } else ctx.drawImage(view, 0, 0, width, height);
1741
+ if (interlaceOffset) {
1742
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
1743
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
1744
+ }
1745
+ }
1746
+ return canvas;
1747
+ },
1748
+ canUse(view) {
1749
+ return view && view.width && !view.__closed;
1750
+ },
1751
+ setPatternTransform(pattern, transform, paint) {
1752
+ try {
1753
+ if (transform && pattern.setTransform) {
1754
+ pattern.setTransform(transform);
1755
+ transform = undefined;
1756
+ }
1757
+ } catch (_a) {}
1758
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
1759
+ }
1760
+ }
1761
+ };
1762
+
1763
+ const {image: image$1} = Platform;
1764
+
1746
1765
  const {randColor: randColor} = MathHelper;
1747
1766
 
1748
1767
  class Debug {
@@ -2912,7 +2931,7 @@ const PathCommandNodeHelper = {
2912
2931
  }
2913
2932
  };
2914
2933
 
2915
- const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2934
+ const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S$1, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2916
2935
 
2917
2936
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2918
2937
 
@@ -3045,10 +3064,10 @@ const PathConvert = {
3045
3064
  old[i + 2] += y;
3046
3065
  old[i + 3] += x;
3047
3066
  old[i + 4] += y;
3048
- command = S;
3067
+ command = S$1;
3049
3068
 
3050
- case S:
3051
- smooth = lastCommand === C$7 || lastCommand === S;
3069
+ case S$1:
3070
+ smooth = lastCommand === C$7 || lastCommand === S$1;
3052
3071
  x1 = smooth ? x * 2 - controlX : old[i + 1];
3053
3072
  y1 = smooth ? y * 2 - controlY : old[i + 2];
3054
3073
  controlX = old[i + 1];
@@ -3298,10 +3317,10 @@ const PathCommandDataHelper = {
3298
3317
  data.push(O$5, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3299
3318
  }
3300
3319
  },
3301
- arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3320
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
3302
3321
  if (!isUndefined(lastX)) {
3303
- const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3304
- radius = min$2(radius, min$2(d / 2, d / 2 * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3322
+ const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
3323
+ radius = min$2(radius, min$2(r, r * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3305
3324
  }
3306
3325
  data.push(U$4, x1, y1, x2, y2, radius);
3307
3326
  },
@@ -3645,7 +3664,7 @@ const PathCorner = {
3645
3664
  let command, lastCommand, commandLen;
3646
3665
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3647
3666
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3648
- const len = data.length;
3667
+ const len = data.length, three = len === 9;
3649
3668
  const smooth = [];
3650
3669
  while (i < len) {
3651
3670
  command = data[i];
@@ -3657,7 +3676,7 @@ const PathCorner = {
3657
3676
  if (data[i] === L$5) {
3658
3677
  secondX = data[i + 1];
3659
3678
  secondY = data[i + 2];
3660
- smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3679
+ three ? smooth.push(M$5, startX, startY) : smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3661
3680
  } else {
3662
3681
  smooth.push(M$5, startX, startY);
3663
3682
  }
@@ -3669,11 +3688,11 @@ const PathCorner = {
3669
3688
  i += 3;
3670
3689
  switch (data[i]) {
3671
3690
  case L$5:
3672
- arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3691
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
3673
3692
  break;
3674
3693
 
3675
3694
  case Z$3:
3676
- arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3695
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
3677
3696
  break;
3678
3697
 
3679
3698
  default:
@@ -3685,7 +3704,7 @@ const PathCorner = {
3685
3704
 
3686
3705
  case Z$3:
3687
3706
  if (lastCommand !== Z$3) {
3688
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3707
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
3689
3708
  smooth.push(Z$3);
3690
3709
  }
3691
3710
  i += 1;
@@ -3785,9 +3804,10 @@ class TaskItem {
3785
3804
  run() {
3786
3805
  return __awaiter(this, void 0, void 0, function*() {
3787
3806
  try {
3788
- if (this.isComplete) return;
3807
+ if (this.isComplete || this.runing) return;
3808
+ this.runing = true;
3789
3809
  if (this.canUse && !this.canUse()) return this.cancel();
3790
- if (this.task && this.parent.running) yield this.task();
3810
+ if (this.task) yield this.task();
3791
3811
  } catch (error) {
3792
3812
  debug$c.error(error);
3793
3813
  }
@@ -3903,7 +3923,7 @@ class TaskProcessor {
3903
3923
  stop() {
3904
3924
  this.isComplete = true;
3905
3925
  this.list.forEach(task => {
3906
- if (!task.isComplete) task.cancel();
3926
+ if (!task.isComplete) task.run();
3907
3927
  });
3908
3928
  this.pause();
3909
3929
  this.empty();
@@ -4193,7 +4213,7 @@ class LeaferImage {
4193
4213
  getFull(_filters) {
4194
4214
  return this.view;
4195
4215
  }
4196
- getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
4216
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
4197
4217
  width || (width = this.width);
4198
4218
  height || (height = this.height);
4199
4219
  if (this.cache) {
@@ -4206,7 +4226,7 @@ class LeaferImage {
4206
4226
  }
4207
4227
  if (data) return data;
4208
4228
  }
4209
- const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
4229
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
4210
4230
  this.cache = this.use > 1 ? {
4211
4231
  data: canvas,
4212
4232
  params: arguments
@@ -6098,7 +6118,7 @@ const LeafRender = {
6098
6118
  }
6099
6119
  };
6100
6120
 
6101
- const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper;
6121
+ const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
6102
6122
 
6103
6123
  const BranchRender = {
6104
6124
  __updateChange() {
@@ -6110,8 +6130,8 @@ const BranchRender = {
6110
6130
  this.__.__checkSingle();
6111
6131
  },
6112
6132
  __render(canvas, options) {
6113
- this.__nowWorld = this.__getNowWorld(options);
6114
- if (this.__worldOpacity) {
6133
+ const nowWorld = this.__nowWorld = this.__getNowWorld(options);
6134
+ if (this.__worldOpacity && hasSize(nowWorld)) {
6115
6135
  const data = this.__;
6116
6136
  if (data.__useDim) {
6117
6137
  if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
@@ -6120,7 +6140,6 @@ const BranchRender = {
6120
6140
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
6121
6141
  const tempCanvas = canvas.getSameCanvas(false, true);
6122
6142
  this.__renderBranch(tempCanvas, options);
6123
- const nowWorld = this.__nowWorld;
6124
6143
  canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
6125
6144
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
6126
6145
  tempCanvas.recycle(nowWorld);
@@ -6960,7 +6979,7 @@ class LeafLevelList {
6960
6979
  }
6961
6980
  }
6962
6981
 
6963
- const version = "1.12.4";
6982
+ const version = "2.0.1";
6964
6983
 
6965
6984
  class LeaferCanvas extends LeaferCanvasBase {
6966
6985
  get allowBackgroundColor() {
@@ -7540,6 +7559,7 @@ class Renderer {
7540
7559
  this.times = 0;
7541
7560
  this.config = {
7542
7561
  usePartRender: true,
7562
+ ceilPartPixel: true,
7543
7563
  maxFPS: 120
7544
7564
  };
7545
7565
  this.frames = [];
@@ -7648,8 +7668,9 @@ class Renderer {
7648
7668
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
7649
7669
  canvas.save();
7650
7670
  bounds.spread(Renderer.clipSpread).ceil();
7651
- canvas.clearWorld(bounds);
7652
- canvas.clipWorld(bounds);
7671
+ const {ceilPartPixel: ceilPartPixel} = this.config;
7672
+ canvas.clipWorld(bounds, ceilPartPixel);
7673
+ canvas.clearWorld(bounds, ceilPartPixel);
7653
7674
  this.__render(bounds, realBounds);
7654
7675
  canvas.restore();
7655
7676
  Run.end(t);
@@ -8048,11 +8069,7 @@ const ColorConvert = {
8048
8069
  hasTransparent: hasTransparent$3
8049
8070
  };
8050
8071
 
8051
- const UnitConvert = {
8052
- number(value, percentRefer) {
8053
- return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
8054
- }
8055
- };
8072
+ const UnitConvert = UnitConvertHelper;
8056
8073
 
8057
8074
  const PathArrow = {};
8058
8075
 
@@ -8129,16 +8146,16 @@ class UIData extends LeafData {
8129
8146
  return t.fill || t.stroke;
8130
8147
  }
8131
8148
  get __autoWidth() {
8132
- return !this._width;
8149
+ return this._width == null;
8133
8150
  }
8134
8151
  get __autoHeight() {
8135
- return !this._height;
8152
+ return this._height == null;
8136
8153
  }
8137
8154
  get __autoSide() {
8138
- return !this._width || !this._height;
8155
+ return this._width == null || this._height == null;
8139
8156
  }
8140
8157
  get __autoSize() {
8141
- return !this._width && !this._height;
8158
+ return this._width == null && this._height == null;
8142
8159
  }
8143
8160
  setVisible(value) {
8144
8161
  this._visible = value;
@@ -9422,9 +9439,10 @@ let Ellipse = class Ellipse extends UI {
9422
9439
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9423
9440
  const rx = width / 2, ry = height / 2;
9424
9441
  const path = this.__.path = [];
9442
+ let open;
9425
9443
  if (innerRadius) {
9426
9444
  if (startAngle || endAngle) {
9427
- if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
9445
+ if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false); else open = true;
9428
9446
  ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
9429
9447
  } else {
9430
9448
  if (innerRadius < 1) {
@@ -9441,7 +9459,7 @@ let Ellipse = class Ellipse extends UI {
9441
9459
  ellipse(path, rx, ry, rx, ry);
9442
9460
  }
9443
9461
  }
9444
- closePath$2(path);
9462
+ if (!open) closePath$2(path);
9445
9463
  if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
9446
9464
  }
9447
9465
  };
@@ -10093,7 +10111,7 @@ class UIEvent extends Event {
10093
10111
  }
10094
10112
  }
10095
10113
 
10096
- const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$2, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
10114
+ const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$3, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
10097
10115
 
10098
10116
  const tempContent = new Bounds, tempDragBounds = new Bounds;
10099
10117
 
@@ -10133,8 +10151,8 @@ const DragBoundsHelper = {
10133
10151
  } else {
10134
10152
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
10135
10153
  }
10136
- move.x = float$2(move.x);
10137
- move.y = float$2(move.y);
10154
+ move.x = float$3(move.x);
10155
+ move.y = float$3(move.y);
10138
10156
  return move;
10139
10157
  },
10140
10158
  getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
@@ -10146,26 +10164,26 @@ const DragBoundsHelper = {
10146
10164
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
10147
10165
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
10148
10166
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10149
- aSize = float$2(tempContent.minX - tempDragBounds.minX);
10150
- bSize = float$2(tempDragBounds.maxX - tempContent.maxX);
10167
+ aSize = float$3(tempContent.minX - tempDragBounds.minX);
10168
+ bSize = float$3(tempDragBounds.maxX - tempContent.maxX);
10151
10169
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
10152
10170
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
10153
10171
  correctScaleX *= max$3(aScale, bScale);
10154
10172
  } else {
10155
10173
  if (scale.x < 0) {
10156
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10174
+ if (float$3(minX(content) - minX(dragBounds)) <= 0 || float$3(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10157
10175
  tempContent.unsign();
10158
10176
  }
10159
- aSize = float$2(tempDragBounds.minX - tempContent.minX);
10160
- bSize = float$2(tempContent.maxX - tempDragBounds.maxX);
10177
+ aSize = float$3(tempDragBounds.minX - tempContent.minX);
10178
+ bSize = float$3(tempContent.maxX - tempDragBounds.maxX);
10161
10179
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
10162
10180
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
10163
10181
  correctScaleX *= min$1(aScale, bScale);
10164
10182
  }
10165
10183
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
10166
10184
  if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10167
- aSize = float$2(tempContent.minY - tempDragBounds.minY);
10168
- bSize = float$2(tempDragBounds.maxY - tempContent.maxY);
10185
+ aSize = float$3(tempContent.minY - tempDragBounds.minY);
10186
+ bSize = float$3(tempDragBounds.maxY - tempContent.maxY);
10169
10187
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
10170
10188
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
10171
10189
  correctScaleY *= max$3(aScale, bScale);
@@ -10176,11 +10194,11 @@ const DragBoundsHelper = {
10176
10194
  }
10177
10195
  } else {
10178
10196
  if (scale.y < 0) {
10179
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10197
+ if (float$3(minY(content) - minY(dragBounds)) <= 0 || float$3(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10180
10198
  tempContent.unsign();
10181
10199
  }
10182
- aSize = float$2(tempDragBounds.minY - tempContent.minY);
10183
- bSize = float$2(tempContent.maxY - tempDragBounds.maxY);
10200
+ aSize = float$3(tempDragBounds.minY - tempContent.minY);
10201
+ bSize = float$3(tempContent.maxY - tempDragBounds.maxY);
10184
10202
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
10185
10203
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
10186
10204
  correctScaleY *= min$1(aScale, bScale);
@@ -10701,7 +10719,7 @@ function exclude(leaf, excludePath) {
10701
10719
  return excludePath && excludePath.has(leaf);
10702
10720
  }
10703
10721
 
10704
- const config$1 = {
10722
+ const config$2 = {
10705
10723
  wheel: {
10706
10724
  zoomSpeed: .5,
10707
10725
  moveSpeed: .5,
@@ -10775,7 +10793,7 @@ class InteractionBase {
10775
10793
  return this.p.hitRadius;
10776
10794
  }
10777
10795
  constructor(target, canvas, selector, userConfig) {
10778
- this.config = DataHelper.clone(config$1);
10796
+ this.config = DataHelper.clone(config$2);
10779
10797
  this.tapCount = 0;
10780
10798
  this.downKeyMap = {};
10781
10799
  this.target = target;
@@ -11295,8 +11313,8 @@ ui$5.__updateHitCanvas = function() {
11295
11313
  if (isHitPixel) {
11296
11314
  const {renderBounds: renderBounds} = this.__layout;
11297
11315
  const size = Platform.image.hitCanvasSize;
11298
- const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11299
- const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
11316
+ const scale = h.hitScale = tempBounds$3.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11317
+ const {x: x, y: y, width: width, height: height} = tempBounds$3.set(renderBounds).scale(scale);
11300
11318
  h.resize({
11301
11319
  width: width,
11302
11320
  height: height,
@@ -11306,6 +11324,7 @@ ui$5.__updateHitCanvas = function() {
11306
11324
  ImageManager.patternLocked = true;
11307
11325
  this.__renderShape(h, {
11308
11326
  matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y),
11327
+ snapshot: true,
11309
11328
  ignoreFill: !isHitPixelFill,
11310
11329
  ignoreStroke: !isHitPixelStroke
11311
11330
  });
@@ -11355,13 +11374,13 @@ ui$5.__hit = function(inner, forceHitFill) {
11355
11374
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
11356
11375
  };
11357
11376
 
11358
- const ui$4 = UI.prototype, rect = Rect.prototype, box$2 = Box.prototype;
11377
+ const ui$4 = UI.prototype, rect = Rect.prototype, box$3 = Box.prototype;
11359
11378
 
11360
- rect.__updateHitCanvas = box$2.__updateHitCanvas = function() {
11379
+ rect.__updateHitCanvas = box$3.__updateHitCanvas = function() {
11361
11380
  if (this.stroke || this.cornerRadius || (this.fill || this.__.__isCanvas) && this.hitFill === "pixel" || this.hitStroke === "all") ui$4.__updateHitCanvas.call(this); else if (this.__hitCanvas) this.__hitCanvas = null;
11362
11381
  };
11363
11382
 
11364
- rect.__hitFill = box$2.__hitFill = function(inner) {
11383
+ rect.__hitFill = box$3.__hitFill = function(inner) {
11365
11384
  return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
11366
11385
  };
11367
11386
 
@@ -11393,8 +11412,8 @@ canvas$1.hitStroke = function(point, strokeWidth) {
11393
11412
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
11394
11413
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
11395
11414
  if (offset) x -= offset.x, y -= offset.y;
11396
- tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11397
- const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
11415
+ tempBounds$3.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11416
+ const {data: data} = this.context.getImageData(tempBounds$3.x, tempBounds$3.y, tempBounds$3.width || 1, tempBounds$3.height || 1);
11398
11417
  for (let i = 0, len = data.length; i < len; i += 4) {
11399
11418
  if (data[i + 3] > 0) return true;
11400
11419
  }
@@ -11709,14 +11728,14 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
11709
11728
 
11710
11729
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11711
11730
 
11712
- const tempBounds$1 = {};
11731
+ const tempBounds$2 = {};
11713
11732
 
11714
11733
  function shape(ui, current, options) {
11715
11734
  const canvas = current.getSameCanvas();
11716
11735
  const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11717
11736
  const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11718
- toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11719
- tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11737
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$2, layout.boxBounds, layout.strokeSpread),
11738
+ tempBounds$2) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11720
11739
  let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11721
11740
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11722
11741
  if (currentBounds.includes(nowWorldShapeBounds)) {
@@ -11868,7 +11887,7 @@ const PaintModule = {
11868
11887
  shape: shape
11869
11888
  };
11870
11889
 
11871
- let cache$1, box$1 = new Bounds;
11890
+ let cache$1, box$2 = new Bounds;
11872
11891
 
11873
11892
  const {isSame: isSame} = BoundsHelper;
11874
11893
 
@@ -11886,7 +11905,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11886
11905
  cache$1 = image.use > 1 ? {
11887
11906
  leafPaint: leafPaint,
11888
11907
  paint: paint,
11889
- boxBounds: box$1.set(boxBounds)
11908
+ boxBounds: box$2.set(boxBounds)
11890
11909
  } : null;
11891
11910
  }
11892
11911
  if (firstUse || image.loading) event = {
@@ -11991,7 +12010,7 @@ function getPatternData(paint, box, image) {
11991
12010
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11992
12011
  if (paint.mode === "strench") paint.mode = "stretch";
11993
12012
  const {width: width, height: height} = image;
11994
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
12013
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
11995
12014
  const sameBox = box.width === width && box.height === height;
11996
12015
  const data = {
11997
12016
  mode: mode
@@ -12057,6 +12076,10 @@ function getPatternData(paint, box, image) {
12057
12076
  if (opacity && opacity < 1) data.opacity = opacity;
12058
12077
  if (filters) data.filters = filters;
12059
12078
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
12079
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
12080
+ type: "x",
12081
+ offset: interlace
12082
+ } : interlace;
12060
12083
  return data;
12061
12084
  }
12062
12085
 
@@ -12190,7 +12213,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12190
12213
  if (transform) copy$4(imageMatrix, transform);
12191
12214
  scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
12192
12215
  }
12193
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
12216
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12194
12217
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12195
12218
  paint.style = pattern;
12196
12219
  paint.patternId = id;
@@ -12212,8 +12235,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
12212
12235
 
12213
12236
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12214
12237
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
12215
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
12216
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
12238
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
12239
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
12217
12240
  return false;
12218
12241
  } else {
12219
12242
  if (drawImage) {
@@ -12418,7 +12441,7 @@ const PaintGradientModule = {
12418
12441
 
12419
12442
  const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$2, abs: abs$5} = Math;
12420
12443
 
12421
- const tempBounds = {}, tempMatrix = new Matrix;
12444
+ const tempBounds$1 = {}, tempMatrix = new Matrix;
12422
12445
 
12423
12446
  const offsetOutBounds$1 = {};
12424
12447
 
@@ -12485,9 +12508,9 @@ function drawWorldShadow(canvas, outBounds, shape) {
12485
12508
  const {shapeBounds: shapeBounds} = shape;
12486
12509
  let from, to;
12487
12510
  if (Platform.fullImageShadow) {
12488
- copy$3(tempBounds, canvas.bounds);
12489
- move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12490
- from = canvas.bounds, to = tempBounds;
12511
+ copy$3(tempBounds$1, canvas.bounds);
12512
+ move$6(tempBounds$1, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12513
+ from = canvas.bounds, to = tempBounds$1;
12491
12514
  } else {
12492
12515
  from = shapeBounds, to = outBounds;
12493
12516
  }
@@ -12887,7 +12910,7 @@ const TextMode = 2;
12887
12910
 
12888
12911
  function layoutChar(drawData, style, width, _height) {
12889
12912
  const {rows: rows} = drawData;
12890
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12913
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
12891
12914
  const justifyLast = width && textAlign.includes("both");
12892
12915
  const justify = justifyLast || width && textAlign.includes("justify");
12893
12916
  const justifyLetter = justify && textAlign.includes("letter");
@@ -12900,8 +12923,8 @@ function layoutChar(drawData, style, width, _height) {
12900
12923
  remainingWidth = width - row.width - indentWidth;
12901
12924
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12902
12925
  }
12903
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12904
- if (row.isOverflow && !letterSpacing) row.textMode = true;
12926
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12927
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
12905
12928
  if (mode === TextMode) {
12906
12929
  row.x += indentWidth;
12907
12930
  toTextChar$1(row);
@@ -12970,7 +12993,7 @@ function layoutText(drawData, style) {
12970
12993
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12971
12994
  let starY = __baseLine;
12972
12995
  if (__clipText && realHeight > height) {
12973
- realHeight = Math.max(height, __lineHeight);
12996
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
12974
12997
  if (countRows > 1) drawData.overflow = countRows;
12975
12998
  } else if (height || autoSizeAlign) {
12976
12999
  switch (verticalAlign) {
@@ -13027,10 +13050,10 @@ function layoutText(drawData, style) {
13027
13050
  }
13028
13051
 
13029
13052
  function clipText(drawData, style, x, width) {
13030
- if (!width) return;
13031
13053
  const {rows: rows, overflow: overflow} = drawData;
13032
13054
  let {textOverflow: textOverflow} = style;
13033
- rows.splice(overflow);
13055
+ if (overflow) rows.splice(overflow);
13056
+ if (!width) return;
13034
13057
  if (textOverflow && textOverflow !== "show") {
13035
13058
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
13036
13059
  let char, charRight;
@@ -13355,8 +13378,13 @@ class Stroker extends UI {
13355
13378
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
13356
13379
  }
13357
13380
  data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
13381
+ if (data.shadow) {
13382
+ const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
13383
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
13384
+ }
13358
13385
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
13359
13386
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
13387
+ if (data.shadow) canvas.restore();
13360
13388
  }
13361
13389
  }
13362
13390
  data.strokeWidth = strokeWidth;
@@ -14520,7 +14548,7 @@ const rotateSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/s
14520
14548
 
14521
14549
  const skewSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${filterStyle$1}\n</filter>\n</defs>\n</svg>\n`;
14522
14550
 
14523
- const config = {
14551
+ const config$1 = {
14524
14552
  editSize: "size",
14525
14553
  keyEvent: true,
14526
14554
  stroke: "#836DFF",
@@ -15165,7 +15193,7 @@ let Editor = class Editor extends Group {
15165
15193
  this.selector = new EditSelect(this);
15166
15194
  this.editMask = new EditMask(this);
15167
15195
  this.targetEventIds = [];
15168
- let mergedConfig = DataHelper.clone(config);
15196
+ let mergedConfig = DataHelper.clone(config$1);
15169
15197
  if (userConfig) mergedConfig = DataHelper.default(userConfig, mergedConfig);
15170
15198
  this.mergedConfig = this.config = mergedConfig;
15171
15199
  this.addMany(this.editMask, this.selector, this.editBox);
@@ -15447,7 +15475,10 @@ class InnerEditor {
15447
15475
  return "focus";
15448
15476
  }
15449
15477
  get editBox() {
15450
- return this.editor.editBox;
15478
+ return this._editBox || this.editor.editBox;
15479
+ }
15480
+ set editBox(value) {
15481
+ this._editBox = value;
15451
15482
  }
15452
15483
  constructor(editor) {
15453
15484
  this.eventIds = [];
@@ -15638,7 +15669,7 @@ let LineEditTool = class LineEditTool extends EditTool {
15638
15669
  onSkew(_e) {}
15639
15670
  onUpdate() {
15640
15671
  const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
15641
- const line = this.editor.element;
15672
+ const line = editBox.target;
15642
15673
  let fromTo, leftOrRight;
15643
15674
  if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
15644
15675
  if (fromTo) {
@@ -16255,13 +16286,14 @@ leafer.initType = function(type) {
16255
16286
  };
16256
16287
 
16257
16288
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
16258
- const {disabled: disabled} = this.app.config.move;
16289
+ const {disabled: disabled, scrollSpread: scrollSpread} = this.app.config.move;
16259
16290
  move$4.set(moveX, moveY);
16260
16291
  const scrollType = getScrollType(this);
16261
16292
  if (scrollType) {
16262
16293
  if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0; else Math.abs(move$4.x) > Math.abs(move$4.y) ? move$4.y = 0 : move$4.x = 0;
16263
16294
  if (checkLimit && scrollType.includes("limit")) {
16264
16295
  bounds.set(this.__world).addPoint(this.zoomLayer);
16296
+ if (scrollSpread) bounds.spread(scrollSpread);
16265
16297
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
16266
16298
  if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
16267
16299
  }
@@ -17539,7 +17571,7 @@ function autoBoundsType(defaultValue) {
17539
17571
 
17540
17572
  Plugin.add("flow", "resize");
17541
17573
 
17542
- const box = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17574
+ const box$1 = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17543
17575
 
17544
17576
  UI.addAttr("flow", false, autoLayoutType);
17545
17577
 
@@ -17561,7 +17593,7 @@ UI.addAttr("autoBox", undefined, boundsType);
17561
17593
 
17562
17594
  const {copyAndSpread: copyAndSpread} = BoundsHelper;
17563
17595
 
17564
- box.__updateFlowLayout = function() {
17596
+ box$1.__updateFlowLayout = function() {
17565
17597
  const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
17566
17598
  if (leaferIsCreated) this.leafer.created = false;
17567
17599
  switch (flow) {
@@ -17585,7 +17617,7 @@ box.__updateFlowLayout = function() {
17585
17617
  if (leaferIsCreated) this.leafer.created = true;
17586
17618
  };
17587
17619
 
17588
- box.__updateContentBounds = function() {
17620
+ box$1.__updateContentBounds = function() {
17589
17621
  const {padding: padding} = this.__;
17590
17622
  const layout = this.__layout;
17591
17623
  const same = layout.contentBounds === layout.boxBounds;
@@ -17597,7 +17629,7 @@ box.__updateContentBounds = function() {
17597
17629
  }
17598
17630
  };
17599
17631
 
17600
- box.__updateBoxBounds = function(secondLayout) {
17632
+ box$1.__updateBoxBounds = function(secondLayout) {
17601
17633
  if (this.children.length && !this.pathInputed) {
17602
17634
  const data = this.__, {flow: flow} = data;
17603
17635
  if (data.__autoSide) {
@@ -18399,7 +18431,7 @@ const hslMatch = /^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i;
18399
18431
 
18400
18432
  const hslaMatch = /^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i;
18401
18433
 
18402
- const int = parseInt, float$1 = parseFloat, {round: round$1} = Math;
18434
+ const int = parseInt, float$2 = parseFloat, {round: round$1} = Math;
18403
18435
 
18404
18436
  let cache = {}, totalCache = 0;
18405
18437
 
@@ -18512,18 +18544,18 @@ function rgbaToRGBA(color) {
18512
18544
  r: int(match[1]),
18513
18545
  g: int(match[2]),
18514
18546
  b: int(match[3]),
18515
- a: float$1(match[4])
18547
+ a: float$2(match[4])
18516
18548
  };
18517
18549
  }
18518
18550
 
18519
18551
  function hslToRGBA(color) {
18520
18552
  const match = hslMatch.exec(color);
18521
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), 1);
18553
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), 1);
18522
18554
  }
18523
18555
 
18524
18556
  function hslaToRGBA(color) {
18525
18557
  const match = hslaMatch.exec(color);
18526
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), float$1(match[4]));
18558
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), float$2(match[4]));
18527
18559
  }
18528
18560
 
18529
18561
  const n1 = 1 / 6, n2 = .5, n3 = 2 / 3, n4 = 1 / 3;
@@ -18762,7 +18794,7 @@ const HighBezierHelper = {
18762
18794
 
18763
18795
  const {getDistance: getDistance} = HighBezierHelper;
18764
18796
 
18765
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
18797
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float$1} = MathHelper;
18766
18798
 
18767
18799
  const tempPoint = {}, tempFrom = {};
18768
18800
 
@@ -18917,7 +18949,7 @@ const HighCurveHelper = {
18917
18949
  tempFrom.y = y;
18918
18950
  to.x = toX;
18919
18951
  to.y = toY;
18920
- cutDistance = float(motionDistance - total);
18952
+ cutDistance = float$1(motionDistance - total);
18921
18953
  if (cutDistance) {
18922
18954
  PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
18923
18955
  path.push(command, to.x, to.y);
@@ -18936,7 +18968,7 @@ const HighCurveHelper = {
18936
18968
  toY = data[i + 6];
18937
18969
  distance = segments[index];
18938
18970
  if (total + distance > motionDistance) {
18939
- cutDistance = float(motionDistance - total);
18971
+ cutDistance = float$1(motionDistance - total);
18940
18972
  if (cutDistance) {
18941
18973
  t = HighBezierHelper.getT(cutDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
18942
18974
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
@@ -19155,21 +19187,21 @@ function getStyle(leaf) {
19155
19187
  const style = {}, button = findParentButton(leaf);
19156
19188
  const state = button ? leaf.state || button.state : leaf.state;
19157
19189
  const stateStyle = state && leaf.states[state];
19158
- if (stateStyle && State.isState(state, leaf, button)) exist = assign(style, stateStyle);
19190
+ if (stateStyle && State.isState(state, leaf, button)) exist = assign$1(style, stateStyle);
19159
19191
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
19160
- if (selectedStyle && State.isSelected(leaf, button)) exist = assign(style, selectedStyle);
19192
+ if (selectedStyle && State.isSelected(leaf, button)) exist = assign$1(style, selectedStyle);
19161
19193
  const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
19162
- if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign(style, placeholderStyle);
19194
+ if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign$1(style, placeholderStyle);
19163
19195
  if (State.isDisabled(leaf, button)) {
19164
19196
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
19165
- if (disabledStyle) exist = assign(style, disabledStyle);
19197
+ if (disabledStyle) exist = assign$1(style, disabledStyle);
19166
19198
  } else {
19167
19199
  const focusStyle = style.focusStyle || leaf.focusStyle;
19168
- if (focusStyle && State.isFocus(leaf, button)) exist = assign(style, focusStyle);
19200
+ if (focusStyle && State.isFocus(leaf, button)) exist = assign$1(style, focusStyle);
19169
19201
  const hoverStyle = style.hoverStyle || leaf.hoverStyle;
19170
- if (hoverStyle && State.isHover(leaf, button)) exist = assign(style, hoverStyle);
19202
+ if (hoverStyle && State.isHover(leaf, button)) exist = assign$1(style, hoverStyle);
19171
19203
  const pressStyle = style.pressStyle || leaf.pressStyle;
19172
- if (pressStyle && State.isPress(leaf, button)) exist = assign(style, pressStyle);
19204
+ if (pressStyle && State.isPress(leaf, button)) exist = assign$1(style, pressStyle);
19173
19205
  }
19174
19206
  return exist ? style : undefined;
19175
19207
  }
@@ -19200,7 +19232,7 @@ function getTransition(type, style, data) {
19200
19232
  return isNull(style[name]) ? data[name] : style[name];
19201
19233
  }
19202
19234
 
19203
- function assign(style, stateStyle) {
19235
+ function assign$1(style, stateStyle) {
19204
19236
  Object.assign(style, stateStyle);
19205
19237
  return true;
19206
19238
  }
@@ -19826,7 +19858,13 @@ const ExportModule = {
19826
19858
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
19827
19859
  let pixelRatio = options.pixelRatio || 1;
19828
19860
  let {x: x, y: y, width: width, height: height} = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
19829
- if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
19861
+ if (clip) {
19862
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
19863
+ if (clip.rotation) matrix.rotateOfInner({
19864
+ x: x,
19865
+ y: y
19866
+ }, -clip.rotation);
19867
+ }
19830
19868
  const renderOptions = {
19831
19869
  exporting: true,
19832
19870
  matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
@@ -20015,4 +20053,258 @@ Plugin.add("bright");
20015
20053
 
20016
20054
  UI.addAttr("bright", false, dimType);
20017
20055
 
20018
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
20056
+ const config = {
20057
+ theme: "light",
20058
+ style: {
20059
+ dragBoundsType: "outer",
20060
+ strokeAlign: "center",
20061
+ strokeWidthFixed: "zoom-in",
20062
+ width: 6,
20063
+ height: 6,
20064
+ opacity: .5,
20065
+ cornerRadius: 3,
20066
+ hoverStyle: {
20067
+ opacity: .6
20068
+ },
20069
+ pressStyle: {
20070
+ opacity: .66
20071
+ }
20072
+ },
20073
+ size: 6,
20074
+ endsMargin: 2,
20075
+ sideMargin: 2,
20076
+ minSize: 10,
20077
+ scaleFixed: "zoom-in",
20078
+ scrollType: "both",
20079
+ hideOnActionEnd: "hover"
20080
+ };
20081
+
20082
+ const tempBounds = new Bounds, {float: float} = MathHelper, {clone: clone, assign: assign} = DataHelper;
20083
+
20084
+ class Scroller extends Group {
20085
+ get canUse() {
20086
+ return this.target.hasScroller;
20087
+ }
20088
+ constructor(target) {
20089
+ super();
20090
+ this.targetWorldBounds = new Bounds;
20091
+ this.viewportBounds = new Bounds;
20092
+ this.contentBounds = new Bounds;
20093
+ this.scrollXBounds = new Bounds;
20094
+ this.scrollYBounds = new Bounds;
20095
+ this.target = target;
20096
+ this.config = clone(config);
20097
+ this.updateConfig();
20098
+ this.__listenEvents();
20099
+ target.waitLeafer(() => {
20100
+ this.parent = target;
20101
+ this.__bindLeafer(target.leafer);
20102
+ });
20103
+ if (this.mergedConfig.hideOnActionEnd) this.opacity = 0;
20104
+ }
20105
+ static registerTheme(theme, themeConfig) {
20106
+ S.themeMap[theme] = themeConfig;
20107
+ }
20108
+ static getTheme(theme) {
20109
+ return theme && S.themeMap[theme];
20110
+ }
20111
+ static hasTheme(theme) {
20112
+ return theme && !!S.themeMap[theme];
20113
+ }
20114
+ updateConfig() {
20115
+ const {scrollConfig: scrollConfig} = this.target;
20116
+ const themeConfig = S.getTheme(scrollConfig && S.hasTheme(scrollConfig.theme) && scrollConfig.theme || this.config.theme);
20117
+ const mergedConfig = this.mergedConfig = clone(this.config);
20118
+ assign(mergedConfig, themeConfig);
20119
+ if (scrollConfig) assign(mergedConfig, scrollConfig);
20120
+ this.updateStyle(mergedConfig.style);
20121
+ }
20122
+ updateStyle(style) {
20123
+ if (!this.scrollXBar) this.addMany(this.scrollXBar = new Box, this.scrollYBar = new Box);
20124
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20125
+ scrollXBar.set(style);
20126
+ scrollYBar.set(style);
20127
+ scrollXBar.draggable = "x";
20128
+ scrollYBar.draggable = "y";
20129
+ }
20130
+ update(check = true) {
20131
+ if (this.dragScrolling) return;
20132
+ const {target: target, targetOverflow: targetOverflow, targetWorldBounds: targetWorldBounds, viewportBounds: viewportBounds, contentBounds: contentBounds} = this, layout = target.__layout, {overflow: overflow} = target.__;
20133
+ const {childrenRenderBounds: childrenRenderBounds} = layout;
20134
+ const {boxBounds: boxBounds, worldBoxBounds: worldBoxBounds} = layout;
20135
+ const isSameWorldBounds = check && targetOverflow === overflow && targetWorldBounds.isSame(worldBoxBounds);
20136
+ const isSameConfig = layout.scrollConfigChanged ? (this.updateConfig(), layout.scrollConfigChanged = false) : true;
20137
+ const nowContentBounds = tempBounds.set(viewportBounds).add(childrenRenderBounds);
20138
+ if (isSameWorldBounds && isSameConfig && contentBounds.isSame(nowContentBounds)) return;
20139
+ this.targetOverflow = overflow;
20140
+ viewportBounds.set(boxBounds);
20141
+ targetWorldBounds.set(worldBoxBounds);
20142
+ contentBounds.set(nowContentBounds);
20143
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this, {size: size, endsMargin: endsMargin, minSize: minSize} = this.mergedConfig, {width: width, height: height} = viewportBounds;
20144
+ this.contentRealX = contentBounds.x - target.scrollX;
20145
+ this.contentRealY = contentBounds.y - target.scrollY;
20146
+ this.ratioX = viewportBounds.width / contentBounds.width;
20147
+ this.ratioY = viewportBounds.height / contentBounds.height;
20148
+ const min = size + endsMargin * 2 + minSize;
20149
+ scrollXBar.visible = float(contentBounds.width) > float(width) && overflow !== "y-scroll" && width > min;
20150
+ scrollYBar.visible = float(contentBounds.height) > float(height) && overflow !== "x-scroll" && height > min;
20151
+ this.updateScrollBar();
20152
+ }
20153
+ updateScrollBar() {
20154
+ const {target: target, viewportBounds: viewportBounds, contentBounds: contentBounds, ratioX: ratioX, ratioY: ratioY, scrollXBar: scrollXBar, scrollYBar: scrollYBar, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20155
+ let {size: size, cornerRadius: cornerRadius, endsMargin: endsMargin, sideMargin: sideMargin, minSize: minSize, scaleFixed: scaleFixed, scrollType: scrollType} = this.mergedConfig;
20156
+ const scale = scaleFixed ? target.getClampRenderScale() : 1;
20157
+ endsMargin /= scale;
20158
+ sideMargin /= scale;
20159
+ size /= scale;
20160
+ if (isUndefined(cornerRadius)) cornerRadius = size / 2;
20161
+ if (scrollXBar.visible) {
20162
+ scrollXBounds.set(viewportBounds).shrink([ endsMargin, scrollYBar.visible ? size + sideMargin : endsMargin, sideMargin, endsMargin ]);
20163
+ const scrollRatioX = this.scrollRatioX = scrollXBounds.width / contentBounds.width;
20164
+ scrollXBar.set({
20165
+ x: scrollXBounds.x - contentBounds.x * scrollRatioX,
20166
+ y: scrollXBounds.maxY - size,
20167
+ width: Math.max(scrollXBounds.width * ratioX, minSize),
20168
+ height: size,
20169
+ cornerRadius: cornerRadius,
20170
+ dragBounds: scrollXBounds,
20171
+ hittable: scrollType !== "move"
20172
+ });
20173
+ }
20174
+ if (scrollYBar.visible) {
20175
+ scrollYBounds.set(viewportBounds).shrink([ endsMargin, sideMargin, scrollXBar.visible ? size + sideMargin : endsMargin, endsMargin ]);
20176
+ const scrollRatioY = this.scrollRatioY = scrollYBounds.height / contentBounds.height;
20177
+ scrollYBar.set({
20178
+ x: scrollYBounds.maxX - size,
20179
+ y: scrollYBounds.y - contentBounds.y * scrollRatioY,
20180
+ width: size,
20181
+ height: Math.max(scrollYBounds.height * ratioY, minSize),
20182
+ cornerRadius: cornerRadius,
20183
+ dragBounds: scrollYBounds,
20184
+ hittable: scrollType !== "move"
20185
+ });
20186
+ }
20187
+ this.x = -this.target.scrollX;
20188
+ this.y = -this.target.scrollY;
20189
+ LeafHelper.updateAllMatrix(this);
20190
+ BranchHelper.updateBounds(this);
20191
+ LeafHelper.updateAllChange(this);
20192
+ }
20193
+ onDrag(e) {
20194
+ if (this.mergedConfig.scrollType === "move") return;
20195
+ this.dragScrolling = true;
20196
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20197
+ const scrollX = e.current === scrollXBar;
20198
+ if (scrollX) target.scrollX = -((scrollXBar.x - scrollXBounds.x) / this.scrollRatioX + this.contentRealX); else target.scrollY = -((scrollYBar.y - scrollYBounds.y) / this.scrollRatioY + this.contentRealY);
20199
+ }
20200
+ onDragEnd() {
20201
+ if (this.mergedConfig.scrollType === "move") return;
20202
+ this.dragScrolling = false;
20203
+ }
20204
+ onMove(e) {
20205
+ if (!this.canUse) return;
20206
+ this.onEnter();
20207
+ const {scrollType: scrollType, stopDefault: stopDefault} = this.mergedConfig;
20208
+ if (scrollType === "drag") return;
20209
+ const {viewportBounds: viewportBounds, contentBounds: contentBounds, scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20210
+ if (scrollXBar.visible || scrollYBar.visible) {
20211
+ const move = e.getInnerMove(this.target);
20212
+ DragBoundsHelper.getValidMove(contentBounds, viewportBounds, "inner", move, true);
20213
+ let needStop;
20214
+ if (move.x && scrollXBar.visible) this.target.scrollX += move.x, needStop = true;
20215
+ if (move.y && scrollYBar.visible) this.target.scrollY += move.y, needStop = true;
20216
+ if (needStop || stopDefault) e.stop();
20217
+ if (stopDefault) e.stopDefault();
20218
+ }
20219
+ }
20220
+ onMoveEnd(e) {
20221
+ if (!this.canUse) return;
20222
+ if (!this.target.hit(e)) this.onLeave();
20223
+ }
20224
+ onEnter() {
20225
+ if (!this.canUse) return;
20226
+ clearTimeout(this.hideTimer);
20227
+ this.killAnimate();
20228
+ this.opacity = 1;
20229
+ }
20230
+ onLeave() {
20231
+ if (!this.canUse) return;
20232
+ clearTimeout(this.hideTimer);
20233
+ if (this.mergedConfig.hideOnActionEnd) this.hideTimer = setTimeout(() => {
20234
+ this.set({
20235
+ opacity: 0
20236
+ }, Plugin.has("animate"));
20237
+ }, 600);
20238
+ }
20239
+ onResize() {
20240
+ if (this.canUse) this.update();
20241
+ }
20242
+ __listenEvents() {
20243
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target} = this;
20244
+ this.__eventIds = [ scrollXBar.on_(DragEvent.DRAG, this.onDrag, this), scrollXBar.on_(DragEvent.END, this.onDragEnd, this), scrollYBar.on_(DragEvent.DRAG, this.onDrag, this), scrollYBar.on_(DragEvent.END, this.onDragEnd, this), target.on_(PointerEvent.ENTER, this.onEnter, this), target.on_(PointerEvent.LEAVE, this.onLeave, this), target.on_(MoveEvent.BEFORE_MOVE, this.onMove, this), target.on_(MoveEvent.END, this.onMoveEnd, this), target.on_(BoundsEvent.WORLD, this.onResize, this), target.on_(ChildEvent.DESTROY, this.destroy, this) ];
20245
+ }
20246
+ __removeListenEvents() {
20247
+ this.off_(this.__eventIds);
20248
+ }
20249
+ destroy() {
20250
+ if (!this.destroyed) {
20251
+ this.__removeListenEvents();
20252
+ const {target: target} = this;
20253
+ target.scroller = target.topChildren = target.hasScroller = undefined;
20254
+ this.target = this.config = null;
20255
+ super.destroy();
20256
+ }
20257
+ }
20258
+ }
20259
+
20260
+ Scroller.themeMap = {};
20261
+
20262
+ const S = Scroller;
20263
+
20264
+ function scrollConfigType(defaultValue) {
20265
+ return decorateLeafAttr(defaultValue, key => attr({
20266
+ set(value) {
20267
+ if (this.__setAttr(key, value)) {
20268
+ const layout = this.__layout;
20269
+ layout.scrollConfigChanged = true;
20270
+ doBoundsType(this);
20271
+ }
20272
+ }
20273
+ }));
20274
+ }
20275
+
20276
+ Plugin.add("scroller");
20277
+
20278
+ const box = Box.prototype;
20279
+
20280
+ Box.addAttr("scrollConfig", undefined, scrollConfigType);
20281
+
20282
+ box.__checkScroll = function(isScrollMode) {
20283
+ if (isScrollMode && this.isOverflow) {
20284
+ if (!this.scroller) {
20285
+ this.scroller = new Scroller(this);
20286
+ if (!this.topChildren) this.topChildren = [];
20287
+ this.topChildren.push(this.scroller);
20288
+ }
20289
+ this.hasScroller = true;
20290
+ } else {
20291
+ if (this.hasScroller && !this.scroller.dragScrolling) {
20292
+ this.hasScroller = undefined;
20293
+ this.scroller.update();
20294
+ }
20295
+ }
20296
+ };
20297
+
20298
+ Scroller.registerTheme("light", {
20299
+ style: {
20300
+ fill: "black"
20301
+ }
20302
+ });
20303
+
20304
+ Scroller.registerTheme("dark", {
20305
+ style: {
20306
+ fill: "white"
20307
+ }
20308
+ });
20309
+
20310
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, Scroller, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$3 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };