@leafer/worker 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() {
@@ -7387,6 +7406,7 @@ class Renderer {
7387
7406
  this.times = 0;
7388
7407
  this.config = {
7389
7408
  usePartRender: true,
7409
+ ceilPartPixel: true,
7390
7410
  maxFPS: 120
7391
7411
  };
7392
7412
  this.frames = [];
@@ -7495,8 +7515,9 @@ class Renderer {
7495
7515
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
7496
7516
  canvas.save();
7497
7517
  bounds.spread(Renderer.clipSpread).ceil();
7498
- canvas.clearWorld(bounds);
7499
- canvas.clipWorld(bounds);
7518
+ const {ceilPartPixel: ceilPartPixel} = this.config;
7519
+ canvas.clipWorld(bounds, ceilPartPixel);
7520
+ canvas.clearWorld(bounds, ceilPartPixel);
7500
7521
  this.__render(bounds, realBounds);
7501
7522
  canvas.restore();
7502
7523
  Run.end(t);
@@ -7895,11 +7916,7 @@ const ColorConvert = {
7895
7916
  hasTransparent: hasTransparent$3
7896
7917
  };
7897
7918
 
7898
- const UnitConvert = {
7899
- number(value, percentRefer) {
7900
- return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
7901
- }
7902
- };
7919
+ const UnitConvert = UnitConvertHelper;
7903
7920
 
7904
7921
  const PathArrow = {};
7905
7922
 
@@ -7976,16 +7993,16 @@ class UIData extends LeafData {
7976
7993
  return t.fill || t.stroke;
7977
7994
  }
7978
7995
  get __autoWidth() {
7979
- return !this._width;
7996
+ return this._width == null;
7980
7997
  }
7981
7998
  get __autoHeight() {
7982
- return !this._height;
7999
+ return this._height == null;
7983
8000
  }
7984
8001
  get __autoSide() {
7985
- return !this._width || !this._height;
8002
+ return this._width == null || this._height == null;
7986
8003
  }
7987
8004
  get __autoSize() {
7988
- return !this._width && !this._height;
8005
+ return this._width == null && this._height == null;
7989
8006
  }
7990
8007
  setVisible(value) {
7991
8008
  this._visible = value;
@@ -9269,9 +9286,10 @@ let Ellipse = class Ellipse extends UI {
9269
9286
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9270
9287
  const rx = width / 2, ry = height / 2;
9271
9288
  const path = this.__.path = [];
9289
+ let open;
9272
9290
  if (innerRadius) {
9273
9291
  if (startAngle || endAngle) {
9274
- if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
9292
+ if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false); else open = true;
9275
9293
  ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
9276
9294
  } else {
9277
9295
  if (innerRadius < 1) {
@@ -9288,7 +9306,7 @@ let Ellipse = class Ellipse extends UI {
9288
9306
  ellipse(path, rx, ry, rx, ry);
9289
9307
  }
9290
9308
  }
9291
- closePath$2(path);
9309
+ if (!open) closePath$2(path);
9292
9310
  if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
9293
9311
  }
9294
9312
  };
@@ -9940,7 +9958,7 @@ class UIEvent extends Event {
9940
9958
  }
9941
9959
  }
9942
9960
 
9943
- 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;
9961
+ 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;
9944
9962
 
9945
9963
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9946
9964
 
@@ -9980,8 +9998,8 @@ const DragBoundsHelper = {
9980
9998
  } else {
9981
9999
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
9982
10000
  }
9983
- move.x = float$2(move.x);
9984
- move.y = float$2(move.y);
10001
+ move.x = float$3(move.x);
10002
+ move.y = float$3(move.y);
9985
10003
  return move;
9986
10004
  },
9987
10005
  getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
@@ -9993,26 +10011,26 @@ const DragBoundsHelper = {
9993
10011
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9994
10012
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9995
10013
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9996
- aSize = float$2(tempContent.minX - tempDragBounds.minX);
9997
- bSize = float$2(tempDragBounds.maxX - tempContent.maxX);
10014
+ aSize = float$3(tempContent.minX - tempDragBounds.minX);
10015
+ bSize = float$3(tempDragBounds.maxX - tempContent.maxX);
9998
10016
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9999
10017
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
10000
10018
  correctScaleX *= max$3(aScale, bScale);
10001
10019
  } else {
10002
10020
  if (scale.x < 0) {
10003
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10021
+ if (float$3(minX(content) - minX(dragBounds)) <= 0 || float$3(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10004
10022
  tempContent.unsign();
10005
10023
  }
10006
- aSize = float$2(tempDragBounds.minX - tempContent.minX);
10007
- bSize = float$2(tempContent.maxX - tempDragBounds.maxX);
10024
+ aSize = float$3(tempDragBounds.minX - tempContent.minX);
10025
+ bSize = float$3(tempContent.maxX - tempDragBounds.maxX);
10008
10026
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
10009
10027
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
10010
10028
  correctScaleX *= min$1(aScale, bScale);
10011
10029
  }
10012
10030
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
10013
10031
  if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10014
- aSize = float$2(tempContent.minY - tempDragBounds.minY);
10015
- bSize = float$2(tempDragBounds.maxY - tempContent.maxY);
10032
+ aSize = float$3(tempContent.minY - tempDragBounds.minY);
10033
+ bSize = float$3(tempDragBounds.maxY - tempContent.maxY);
10016
10034
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
10017
10035
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
10018
10036
  correctScaleY *= max$3(aScale, bScale);
@@ -10023,11 +10041,11 @@ const DragBoundsHelper = {
10023
10041
  }
10024
10042
  } else {
10025
10043
  if (scale.y < 0) {
10026
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10044
+ if (float$3(minY(content) - minY(dragBounds)) <= 0 || float$3(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10027
10045
  tempContent.unsign();
10028
10046
  }
10029
- aSize = float$2(tempDragBounds.minY - tempContent.minY);
10030
- bSize = float$2(tempContent.maxY - tempDragBounds.maxY);
10047
+ aSize = float$3(tempDragBounds.minY - tempContent.minY);
10048
+ bSize = float$3(tempContent.maxY - tempDragBounds.maxY);
10031
10049
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
10032
10050
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
10033
10051
  correctScaleY *= min$1(aScale, bScale);
@@ -10548,7 +10566,7 @@ function exclude(leaf, excludePath) {
10548
10566
  return excludePath && excludePath.has(leaf);
10549
10567
  }
10550
10568
 
10551
- const config$1 = {
10569
+ const config$2 = {
10552
10570
  wheel: {
10553
10571
  zoomSpeed: .5,
10554
10572
  moveSpeed: .5,
@@ -10622,7 +10640,7 @@ class InteractionBase {
10622
10640
  return this.p.hitRadius;
10623
10641
  }
10624
10642
  constructor(target, canvas, selector, userConfig) {
10625
- this.config = DataHelper.clone(config$1);
10643
+ this.config = DataHelper.clone(config$2);
10626
10644
  this.tapCount = 0;
10627
10645
  this.downKeyMap = {};
10628
10646
  this.target = target;
@@ -11142,8 +11160,8 @@ ui$5.__updateHitCanvas = function() {
11142
11160
  if (isHitPixel) {
11143
11161
  const {renderBounds: renderBounds} = this.__layout;
11144
11162
  const size = Platform.image.hitCanvasSize;
11145
- const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11146
- const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
11163
+ const scale = h.hitScale = tempBounds$3.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11164
+ const {x: x, y: y, width: width, height: height} = tempBounds$3.set(renderBounds).scale(scale);
11147
11165
  h.resize({
11148
11166
  width: width,
11149
11167
  height: height,
@@ -11153,6 +11171,7 @@ ui$5.__updateHitCanvas = function() {
11153
11171
  ImageManager.patternLocked = true;
11154
11172
  this.__renderShape(h, {
11155
11173
  matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y),
11174
+ snapshot: true,
11156
11175
  ignoreFill: !isHitPixelFill,
11157
11176
  ignoreStroke: !isHitPixelStroke
11158
11177
  });
@@ -11202,13 +11221,13 @@ ui$5.__hit = function(inner, forceHitFill) {
11202
11221
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
11203
11222
  };
11204
11223
 
11205
- const ui$4 = UI.prototype, rect = Rect.prototype, box$2 = Box.prototype;
11224
+ const ui$4 = UI.prototype, rect = Rect.prototype, box$3 = Box.prototype;
11206
11225
 
11207
- rect.__updateHitCanvas = box$2.__updateHitCanvas = function() {
11226
+ rect.__updateHitCanvas = box$3.__updateHitCanvas = function() {
11208
11227
  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;
11209
11228
  };
11210
11229
 
11211
- rect.__hitFill = box$2.__hitFill = function(inner) {
11230
+ rect.__hitFill = box$3.__hitFill = function(inner) {
11212
11231
  return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
11213
11232
  };
11214
11233
 
@@ -11240,8 +11259,8 @@ canvas$1.hitStroke = function(point, strokeWidth) {
11240
11259
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
11241
11260
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
11242
11261
  if (offset) x -= offset.x, y -= offset.y;
11243
- tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11244
- const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
11262
+ tempBounds$3.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11263
+ const {data: data} = this.context.getImageData(tempBounds$3.x, tempBounds$3.y, tempBounds$3.width || 1, tempBounds$3.height || 1);
11245
11264
  for (let i = 0, len = data.length; i < len; i += 4) {
11246
11265
  if (data[i + 3] > 0) return true;
11247
11266
  }
@@ -11444,14 +11463,14 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
11444
11463
 
11445
11464
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11446
11465
 
11447
- const tempBounds$1 = {};
11466
+ const tempBounds$2 = {};
11448
11467
 
11449
11468
  function shape(ui, current, options) {
11450
11469
  const canvas = current.getSameCanvas();
11451
11470
  const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11452
11471
  const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11453
- toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11454
- tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11472
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$2, layout.boxBounds, layout.strokeSpread),
11473
+ tempBounds$2) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11455
11474
  let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11456
11475
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11457
11476
  if (currentBounds.includes(nowWorldShapeBounds)) {
@@ -11603,7 +11622,7 @@ const PaintModule = {
11603
11622
  shape: shape
11604
11623
  };
11605
11624
 
11606
- let cache$1, box$1 = new Bounds;
11625
+ let cache$1, box$2 = new Bounds;
11607
11626
 
11608
11627
  const {isSame: isSame} = BoundsHelper;
11609
11628
 
@@ -11621,7 +11640,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11621
11640
  cache$1 = image.use > 1 ? {
11622
11641
  leafPaint: leafPaint,
11623
11642
  paint: paint,
11624
- boxBounds: box$1.set(boxBounds)
11643
+ boxBounds: box$2.set(boxBounds)
11625
11644
  } : null;
11626
11645
  }
11627
11646
  if (firstUse || image.loading) event = {
@@ -11726,7 +11745,7 @@ function getPatternData(paint, box, image) {
11726
11745
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11727
11746
  if (paint.mode === "strench") paint.mode = "stretch";
11728
11747
  const {width: width, height: height} = image;
11729
- 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;
11748
+ 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;
11730
11749
  const sameBox = box.width === width && box.height === height;
11731
11750
  const data = {
11732
11751
  mode: mode
@@ -11792,6 +11811,10 @@ function getPatternData(paint, box, image) {
11792
11811
  if (opacity && opacity < 1) data.opacity = opacity;
11793
11812
  if (filters) data.filters = filters;
11794
11813
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11814
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
11815
+ type: "x",
11816
+ offset: interlace
11817
+ } : interlace;
11795
11818
  return data;
11796
11819
  }
11797
11820
 
@@ -11925,7 +11948,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
11925
11948
  if (transform) copy$4(imageMatrix, transform);
11926
11949
  scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
11927
11950
  }
11928
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11951
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11929
11952
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11930
11953
  paint.style = pattern;
11931
11954
  paint.patternId = id;
@@ -11947,8 +11970,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
11947
11970
 
11948
11971
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11949
11972
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11950
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
11951
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11973
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
11974
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
11952
11975
  return false;
11953
11976
  } else {
11954
11977
  if (drawImage) {
@@ -12153,7 +12176,7 @@ const PaintGradientModule = {
12153
12176
 
12154
12177
  const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$2, abs: abs$5} = Math;
12155
12178
 
12156
- const tempBounds = {}, tempMatrix = new Matrix;
12179
+ const tempBounds$1 = {}, tempMatrix = new Matrix;
12157
12180
 
12158
12181
  const offsetOutBounds$1 = {};
12159
12182
 
@@ -12220,9 +12243,9 @@ function drawWorldShadow(canvas, outBounds, shape) {
12220
12243
  const {shapeBounds: shapeBounds} = shape;
12221
12244
  let from, to;
12222
12245
  if (Platform.fullImageShadow) {
12223
- copy$3(tempBounds, canvas.bounds);
12224
- move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12225
- from = canvas.bounds, to = tempBounds;
12246
+ copy$3(tempBounds$1, canvas.bounds);
12247
+ move$6(tempBounds$1, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12248
+ from = canvas.bounds, to = tempBounds$1;
12226
12249
  } else {
12227
12250
  from = shapeBounds, to = outBounds;
12228
12251
  }
@@ -12622,7 +12645,7 @@ const TextMode = 2;
12622
12645
 
12623
12646
  function layoutChar(drawData, style, width, _height) {
12624
12647
  const {rows: rows} = drawData;
12625
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
12648
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
12626
12649
  const justifyLast = width && textAlign.includes("both");
12627
12650
  const justify = justifyLast || width && textAlign.includes("justify");
12628
12651
  const justifyLetter = justify && textAlign.includes("letter");
@@ -12635,8 +12658,8 @@ function layoutChar(drawData, style, width, _height) {
12635
12658
  remainingWidth = width - row.width - indentWidth;
12636
12659
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
12637
12660
  }
12638
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12639
- if (row.isOverflow && !letterSpacing) row.textMode = true;
12661
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
12662
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
12640
12663
  if (mode === TextMode) {
12641
12664
  row.x += indentWidth;
12642
12665
  toTextChar$1(row);
@@ -12705,7 +12728,7 @@ function layoutText(drawData, style) {
12705
12728
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12706
12729
  let starY = __baseLine;
12707
12730
  if (__clipText && realHeight > height) {
12708
- realHeight = Math.max(height, __lineHeight);
12731
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
12709
12732
  if (countRows > 1) drawData.overflow = countRows;
12710
12733
  } else if (height || autoSizeAlign) {
12711
12734
  switch (verticalAlign) {
@@ -12762,10 +12785,10 @@ function layoutText(drawData, style) {
12762
12785
  }
12763
12786
 
12764
12787
  function clipText(drawData, style, x, width) {
12765
- if (!width) return;
12766
12788
  const {rows: rows, overflow: overflow} = drawData;
12767
12789
  let {textOverflow: textOverflow} = style;
12768
- rows.splice(overflow);
12790
+ if (overflow) rows.splice(overflow);
12791
+ if (!width) return;
12769
12792
  if (textOverflow && textOverflow !== "show") {
12770
12793
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
12771
12794
  let char, charRight;
@@ -13084,8 +13107,13 @@ class Stroker extends UI {
13084
13107
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
13085
13108
  }
13086
13109
  data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
13110
+ if (data.shadow) {
13111
+ const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
13112
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
13113
+ }
13087
13114
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
13088
13115
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
13116
+ if (data.shadow) canvas.restore();
13089
13117
  }
13090
13118
  }
13091
13119
  data.strokeWidth = strokeWidth;
@@ -14249,7 +14277,7 @@ const rotateSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/s
14249
14277
 
14250
14278
  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`;
14251
14279
 
14252
- const config = {
14280
+ const config$1 = {
14253
14281
  editSize: "size",
14254
14282
  keyEvent: true,
14255
14283
  stroke: "#836DFF",
@@ -14894,7 +14922,7 @@ let Editor = class Editor extends Group {
14894
14922
  this.selector = new EditSelect(this);
14895
14923
  this.editMask = new EditMask(this);
14896
14924
  this.targetEventIds = [];
14897
- let mergedConfig = DataHelper.clone(config);
14925
+ let mergedConfig = DataHelper.clone(config$1);
14898
14926
  if (userConfig) mergedConfig = DataHelper.default(userConfig, mergedConfig);
14899
14927
  this.mergedConfig = this.config = mergedConfig;
14900
14928
  this.addMany(this.editMask, this.selector, this.editBox);
@@ -15176,7 +15204,10 @@ class InnerEditor {
15176
15204
  return "focus";
15177
15205
  }
15178
15206
  get editBox() {
15179
- return this.editor.editBox;
15207
+ return this._editBox || this.editor.editBox;
15208
+ }
15209
+ set editBox(value) {
15210
+ this._editBox = value;
15180
15211
  }
15181
15212
  constructor(editor) {
15182
15213
  this.eventIds = [];
@@ -15367,7 +15398,7 @@ let LineEditTool = class LineEditTool extends EditTool {
15367
15398
  onSkew(_e) {}
15368
15399
  onUpdate() {
15369
15400
  const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
15370
- const line = this.editor.element;
15401
+ const line = editBox.target;
15371
15402
  let fromTo, leftOrRight;
15372
15403
  if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
15373
15404
  if (fromTo) {
@@ -16238,13 +16269,14 @@ leafer.initType = function(type) {
16238
16269
  };
16239
16270
 
16240
16271
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
16241
- const {disabled: disabled} = this.app.config.move;
16272
+ const {disabled: disabled, scrollSpread: scrollSpread} = this.app.config.move;
16242
16273
  move$4.set(moveX, moveY);
16243
16274
  const scrollType = getScrollType(this);
16244
16275
  if (scrollType) {
16245
16276
  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;
16246
16277
  if (checkLimit && scrollType.includes("limit")) {
16247
16278
  bounds.set(this.__world).addPoint(this.zoomLayer);
16279
+ if (scrollSpread) bounds.spread(scrollSpread);
16248
16280
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
16249
16281
  if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
16250
16282
  }
@@ -17661,7 +17693,7 @@ function autoBoundsType(defaultValue) {
17661
17693
 
17662
17694
  Plugin.add("flow", "resize");
17663
17695
 
17664
- const box = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17696
+ const box$1 = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17665
17697
 
17666
17698
  UI.addAttr("flow", false, autoLayoutType);
17667
17699
 
@@ -17683,7 +17715,7 @@ UI.addAttr("autoBox", undefined, boundsType);
17683
17715
 
17684
17716
  const {copyAndSpread: copyAndSpread} = BoundsHelper;
17685
17717
 
17686
- box.__updateFlowLayout = function() {
17718
+ box$1.__updateFlowLayout = function() {
17687
17719
  const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
17688
17720
  if (leaferIsCreated) this.leafer.created = false;
17689
17721
  switch (flow) {
@@ -17707,7 +17739,7 @@ box.__updateFlowLayout = function() {
17707
17739
  if (leaferIsCreated) this.leafer.created = true;
17708
17740
  };
17709
17741
 
17710
- box.__updateContentBounds = function() {
17742
+ box$1.__updateContentBounds = function() {
17711
17743
  const {padding: padding} = this.__;
17712
17744
  const layout = this.__layout;
17713
17745
  const same = layout.contentBounds === layout.boxBounds;
@@ -17719,7 +17751,7 @@ box.__updateContentBounds = function() {
17719
17751
  }
17720
17752
  };
17721
17753
 
17722
- box.__updateBoxBounds = function(secondLayout) {
17754
+ box$1.__updateBoxBounds = function(secondLayout) {
17723
17755
  if (this.children.length && !this.pathInputed) {
17724
17756
  const data = this.__, {flow: flow} = data;
17725
17757
  if (data.__autoSide) {
@@ -18521,7 +18553,7 @@ const hslMatch = /^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i;
18521
18553
 
18522
18554
  const hslaMatch = /^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i;
18523
18555
 
18524
- const int = parseInt, float$1 = parseFloat, {round: round$1} = Math;
18556
+ const int = parseInt, float$2 = parseFloat, {round: round$1} = Math;
18525
18557
 
18526
18558
  let cache = {}, totalCache = 0;
18527
18559
 
@@ -18634,18 +18666,18 @@ function rgbaToRGBA(color) {
18634
18666
  r: int(match[1]),
18635
18667
  g: int(match[2]),
18636
18668
  b: int(match[3]),
18637
- a: float$1(match[4])
18669
+ a: float$2(match[4])
18638
18670
  };
18639
18671
  }
18640
18672
 
18641
18673
  function hslToRGBA(color) {
18642
18674
  const match = hslMatch.exec(color);
18643
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), 1);
18675
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), 1);
18644
18676
  }
18645
18677
 
18646
18678
  function hslaToRGBA(color) {
18647
18679
  const match = hslaMatch.exec(color);
18648
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), float$1(match[4]));
18680
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), float$2(match[4]));
18649
18681
  }
18650
18682
 
18651
18683
  const n1 = 1 / 6, n2 = .5, n3 = 2 / 3, n4 = 1 / 3;
@@ -18884,7 +18916,7 @@ const HighBezierHelper = {
18884
18916
 
18885
18917
  const {getDistance: getDistance} = HighBezierHelper;
18886
18918
 
18887
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
18919
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float$1} = MathHelper;
18888
18920
 
18889
18921
  const tempPoint = {}, tempFrom = {};
18890
18922
 
@@ -19039,7 +19071,7 @@ const HighCurveHelper = {
19039
19071
  tempFrom.y = y;
19040
19072
  to.x = toX;
19041
19073
  to.y = toY;
19042
- cutDistance = float(motionDistance - total);
19074
+ cutDistance = float$1(motionDistance - total);
19043
19075
  if (cutDistance) {
19044
19076
  PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
19045
19077
  path.push(command, to.x, to.y);
@@ -19058,7 +19090,7 @@ const HighCurveHelper = {
19058
19090
  toY = data[i + 6];
19059
19091
  distance = segments[index];
19060
19092
  if (total + distance > motionDistance) {
19061
- cutDistance = float(motionDistance - total);
19093
+ cutDistance = float$1(motionDistance - total);
19062
19094
  if (cutDistance) {
19063
19095
  t = HighBezierHelper.getT(cutDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
19064
19096
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
@@ -19277,21 +19309,21 @@ function getStyle(leaf) {
19277
19309
  const style = {}, button = findParentButton(leaf);
19278
19310
  const state = button ? leaf.state || button.state : leaf.state;
19279
19311
  const stateStyle = state && leaf.states[state];
19280
- if (stateStyle && State.isState(state, leaf, button)) exist = assign(style, stateStyle);
19312
+ if (stateStyle && State.isState(state, leaf, button)) exist = assign$1(style, stateStyle);
19281
19313
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
19282
- if (selectedStyle && State.isSelected(leaf, button)) exist = assign(style, selectedStyle);
19314
+ if (selectedStyle && State.isSelected(leaf, button)) exist = assign$1(style, selectedStyle);
19283
19315
  const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
19284
- if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign(style, placeholderStyle);
19316
+ if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign$1(style, placeholderStyle);
19285
19317
  if (State.isDisabled(leaf, button)) {
19286
19318
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
19287
- if (disabledStyle) exist = assign(style, disabledStyle);
19319
+ if (disabledStyle) exist = assign$1(style, disabledStyle);
19288
19320
  } else {
19289
19321
  const focusStyle = style.focusStyle || leaf.focusStyle;
19290
- if (focusStyle && State.isFocus(leaf, button)) exist = assign(style, focusStyle);
19322
+ if (focusStyle && State.isFocus(leaf, button)) exist = assign$1(style, focusStyle);
19291
19323
  const hoverStyle = style.hoverStyle || leaf.hoverStyle;
19292
- if (hoverStyle && State.isHover(leaf, button)) exist = assign(style, hoverStyle);
19324
+ if (hoverStyle && State.isHover(leaf, button)) exist = assign$1(style, hoverStyle);
19293
19325
  const pressStyle = style.pressStyle || leaf.pressStyle;
19294
- if (pressStyle && State.isPress(leaf, button)) exist = assign(style, pressStyle);
19326
+ if (pressStyle && State.isPress(leaf, button)) exist = assign$1(style, pressStyle);
19295
19327
  }
19296
19328
  return exist ? style : undefined;
19297
19329
  }
@@ -19322,7 +19354,7 @@ function getTransition(type, style, data) {
19322
19354
  return isNull(style[name]) ? data[name] : style[name];
19323
19355
  }
19324
19356
 
19325
- function assign(style, stateStyle) {
19357
+ function assign$1(style, stateStyle) {
19326
19358
  Object.assign(style, stateStyle);
19327
19359
  return true;
19328
19360
  }
@@ -19948,7 +19980,13 @@ const ExportModule = {
19948
19980
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
19949
19981
  let pixelRatio = options.pixelRatio || 1;
19950
19982
  let {x: x, y: y, width: width, height: height} = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
19951
- if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
19983
+ if (clip) {
19984
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
19985
+ if (clip.rotation) matrix.rotateOfInner({
19986
+ x: x,
19987
+ y: y
19988
+ }, -clip.rotation);
19989
+ }
19952
19990
  const renderOptions = {
19953
19991
  exporting: true,
19954
19992
  matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
@@ -20137,4 +20175,258 @@ Plugin.add("bright");
20137
20175
 
20138
20176
  UI.addAttr("bright", false, dimType);
20139
20177
 
20140
- 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, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, TextEditor, 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 };
20178
+ const config = {
20179
+ theme: "light",
20180
+ style: {
20181
+ dragBoundsType: "outer",
20182
+ strokeAlign: "center",
20183
+ strokeWidthFixed: "zoom-in",
20184
+ width: 6,
20185
+ height: 6,
20186
+ opacity: .5,
20187
+ cornerRadius: 3,
20188
+ hoverStyle: {
20189
+ opacity: .6
20190
+ },
20191
+ pressStyle: {
20192
+ opacity: .66
20193
+ }
20194
+ },
20195
+ size: 6,
20196
+ endsMargin: 2,
20197
+ sideMargin: 2,
20198
+ minSize: 10,
20199
+ scaleFixed: "zoom-in",
20200
+ scrollType: "both",
20201
+ hideOnActionEnd: "hover"
20202
+ };
20203
+
20204
+ const tempBounds = new Bounds, {float: float} = MathHelper, {clone: clone, assign: assign} = DataHelper;
20205
+
20206
+ class Scroller extends Group {
20207
+ get canUse() {
20208
+ return this.target.hasScroller;
20209
+ }
20210
+ constructor(target) {
20211
+ super();
20212
+ this.targetWorldBounds = new Bounds;
20213
+ this.viewportBounds = new Bounds;
20214
+ this.contentBounds = new Bounds;
20215
+ this.scrollXBounds = new Bounds;
20216
+ this.scrollYBounds = new Bounds;
20217
+ this.target = target;
20218
+ this.config = clone(config);
20219
+ this.updateConfig();
20220
+ this.__listenEvents();
20221
+ target.waitLeafer(() => {
20222
+ this.parent = target;
20223
+ this.__bindLeafer(target.leafer);
20224
+ });
20225
+ if (this.mergedConfig.hideOnActionEnd) this.opacity = 0;
20226
+ }
20227
+ static registerTheme(theme, themeConfig) {
20228
+ S.themeMap[theme] = themeConfig;
20229
+ }
20230
+ static getTheme(theme) {
20231
+ return theme && S.themeMap[theme];
20232
+ }
20233
+ static hasTheme(theme) {
20234
+ return theme && !!S.themeMap[theme];
20235
+ }
20236
+ updateConfig() {
20237
+ const {scrollConfig: scrollConfig} = this.target;
20238
+ const themeConfig = S.getTheme(scrollConfig && S.hasTheme(scrollConfig.theme) && scrollConfig.theme || this.config.theme);
20239
+ const mergedConfig = this.mergedConfig = clone(this.config);
20240
+ assign(mergedConfig, themeConfig);
20241
+ if (scrollConfig) assign(mergedConfig, scrollConfig);
20242
+ this.updateStyle(mergedConfig.style);
20243
+ }
20244
+ updateStyle(style) {
20245
+ if (!this.scrollXBar) this.addMany(this.scrollXBar = new Box, this.scrollYBar = new Box);
20246
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20247
+ scrollXBar.set(style);
20248
+ scrollYBar.set(style);
20249
+ scrollXBar.draggable = "x";
20250
+ scrollYBar.draggable = "y";
20251
+ }
20252
+ update(check = true) {
20253
+ if (this.dragScrolling) return;
20254
+ const {target: target, targetOverflow: targetOverflow, targetWorldBounds: targetWorldBounds, viewportBounds: viewportBounds, contentBounds: contentBounds} = this, layout = target.__layout, {overflow: overflow} = target.__;
20255
+ const {childrenRenderBounds: childrenRenderBounds} = layout;
20256
+ const {boxBounds: boxBounds, worldBoxBounds: worldBoxBounds} = layout;
20257
+ const isSameWorldBounds = check && targetOverflow === overflow && targetWorldBounds.isSame(worldBoxBounds);
20258
+ const isSameConfig = layout.scrollConfigChanged ? (this.updateConfig(), layout.scrollConfigChanged = false) : true;
20259
+ const nowContentBounds = tempBounds.set(viewportBounds).add(childrenRenderBounds);
20260
+ if (isSameWorldBounds && isSameConfig && contentBounds.isSame(nowContentBounds)) return;
20261
+ this.targetOverflow = overflow;
20262
+ viewportBounds.set(boxBounds);
20263
+ targetWorldBounds.set(worldBoxBounds);
20264
+ contentBounds.set(nowContentBounds);
20265
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this, {size: size, endsMargin: endsMargin, minSize: minSize} = this.mergedConfig, {width: width, height: height} = viewportBounds;
20266
+ this.contentRealX = contentBounds.x - target.scrollX;
20267
+ this.contentRealY = contentBounds.y - target.scrollY;
20268
+ this.ratioX = viewportBounds.width / contentBounds.width;
20269
+ this.ratioY = viewportBounds.height / contentBounds.height;
20270
+ const min = size + endsMargin * 2 + minSize;
20271
+ scrollXBar.visible = float(contentBounds.width) > float(width) && overflow !== "y-scroll" && width > min;
20272
+ scrollYBar.visible = float(contentBounds.height) > float(height) && overflow !== "x-scroll" && height > min;
20273
+ this.updateScrollBar();
20274
+ }
20275
+ updateScrollBar() {
20276
+ const {target: target, viewportBounds: viewportBounds, contentBounds: contentBounds, ratioX: ratioX, ratioY: ratioY, scrollXBar: scrollXBar, scrollYBar: scrollYBar, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20277
+ let {size: size, cornerRadius: cornerRadius, endsMargin: endsMargin, sideMargin: sideMargin, minSize: minSize, scaleFixed: scaleFixed, scrollType: scrollType} = this.mergedConfig;
20278
+ const scale = scaleFixed ? target.getClampRenderScale() : 1;
20279
+ endsMargin /= scale;
20280
+ sideMargin /= scale;
20281
+ size /= scale;
20282
+ if (isUndefined(cornerRadius)) cornerRadius = size / 2;
20283
+ if (scrollXBar.visible) {
20284
+ scrollXBounds.set(viewportBounds).shrink([ endsMargin, scrollYBar.visible ? size + sideMargin : endsMargin, sideMargin, endsMargin ]);
20285
+ const scrollRatioX = this.scrollRatioX = scrollXBounds.width / contentBounds.width;
20286
+ scrollXBar.set({
20287
+ x: scrollXBounds.x - contentBounds.x * scrollRatioX,
20288
+ y: scrollXBounds.maxY - size,
20289
+ width: Math.max(scrollXBounds.width * ratioX, minSize),
20290
+ height: size,
20291
+ cornerRadius: cornerRadius,
20292
+ dragBounds: scrollXBounds,
20293
+ hittable: scrollType !== "move"
20294
+ });
20295
+ }
20296
+ if (scrollYBar.visible) {
20297
+ scrollYBounds.set(viewportBounds).shrink([ endsMargin, sideMargin, scrollXBar.visible ? size + sideMargin : endsMargin, endsMargin ]);
20298
+ const scrollRatioY = this.scrollRatioY = scrollYBounds.height / contentBounds.height;
20299
+ scrollYBar.set({
20300
+ x: scrollYBounds.maxX - size,
20301
+ y: scrollYBounds.y - contentBounds.y * scrollRatioY,
20302
+ width: size,
20303
+ height: Math.max(scrollYBounds.height * ratioY, minSize),
20304
+ cornerRadius: cornerRadius,
20305
+ dragBounds: scrollYBounds,
20306
+ hittable: scrollType !== "move"
20307
+ });
20308
+ }
20309
+ this.x = -this.target.scrollX;
20310
+ this.y = -this.target.scrollY;
20311
+ LeafHelper.updateAllMatrix(this);
20312
+ BranchHelper.updateBounds(this);
20313
+ LeafHelper.updateAllChange(this);
20314
+ }
20315
+ onDrag(e) {
20316
+ if (this.mergedConfig.scrollType === "move") return;
20317
+ this.dragScrolling = true;
20318
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20319
+ const scrollX = e.current === scrollXBar;
20320
+ if (scrollX) target.scrollX = -((scrollXBar.x - scrollXBounds.x) / this.scrollRatioX + this.contentRealX); else target.scrollY = -((scrollYBar.y - scrollYBounds.y) / this.scrollRatioY + this.contentRealY);
20321
+ }
20322
+ onDragEnd() {
20323
+ if (this.mergedConfig.scrollType === "move") return;
20324
+ this.dragScrolling = false;
20325
+ }
20326
+ onMove(e) {
20327
+ if (!this.canUse) return;
20328
+ this.onEnter();
20329
+ const {scrollType: scrollType, stopDefault: stopDefault} = this.mergedConfig;
20330
+ if (scrollType === "drag") return;
20331
+ const {viewportBounds: viewportBounds, contentBounds: contentBounds, scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20332
+ if (scrollXBar.visible || scrollYBar.visible) {
20333
+ const move = e.getInnerMove(this.target);
20334
+ DragBoundsHelper.getValidMove(contentBounds, viewportBounds, "inner", move, true);
20335
+ let needStop;
20336
+ if (move.x && scrollXBar.visible) this.target.scrollX += move.x, needStop = true;
20337
+ if (move.y && scrollYBar.visible) this.target.scrollY += move.y, needStop = true;
20338
+ if (needStop || stopDefault) e.stop();
20339
+ if (stopDefault) e.stopDefault();
20340
+ }
20341
+ }
20342
+ onMoveEnd(e) {
20343
+ if (!this.canUse) return;
20344
+ if (!this.target.hit(e)) this.onLeave();
20345
+ }
20346
+ onEnter() {
20347
+ if (!this.canUse) return;
20348
+ clearTimeout(this.hideTimer);
20349
+ this.killAnimate();
20350
+ this.opacity = 1;
20351
+ }
20352
+ onLeave() {
20353
+ if (!this.canUse) return;
20354
+ clearTimeout(this.hideTimer);
20355
+ if (this.mergedConfig.hideOnActionEnd) this.hideTimer = setTimeout(() => {
20356
+ this.set({
20357
+ opacity: 0
20358
+ }, Plugin.has("animate"));
20359
+ }, 600);
20360
+ }
20361
+ onResize() {
20362
+ if (this.canUse) this.update();
20363
+ }
20364
+ __listenEvents() {
20365
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target} = this;
20366
+ 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) ];
20367
+ }
20368
+ __removeListenEvents() {
20369
+ this.off_(this.__eventIds);
20370
+ }
20371
+ destroy() {
20372
+ if (!this.destroyed) {
20373
+ this.__removeListenEvents();
20374
+ const {target: target} = this;
20375
+ target.scroller = target.topChildren = target.hasScroller = undefined;
20376
+ this.target = this.config = null;
20377
+ super.destroy();
20378
+ }
20379
+ }
20380
+ }
20381
+
20382
+ Scroller.themeMap = {};
20383
+
20384
+ const S = Scroller;
20385
+
20386
+ function scrollConfigType(defaultValue) {
20387
+ return decorateLeafAttr(defaultValue, key => attr({
20388
+ set(value) {
20389
+ if (this.__setAttr(key, value)) {
20390
+ const layout = this.__layout;
20391
+ layout.scrollConfigChanged = true;
20392
+ doBoundsType(this);
20393
+ }
20394
+ }
20395
+ }));
20396
+ }
20397
+
20398
+ Plugin.add("scroller");
20399
+
20400
+ const box = Box.prototype;
20401
+
20402
+ Box.addAttr("scrollConfig", undefined, scrollConfigType);
20403
+
20404
+ box.__checkScroll = function(isScrollMode) {
20405
+ if (isScrollMode && this.isOverflow) {
20406
+ if (!this.scroller) {
20407
+ this.scroller = new Scroller(this);
20408
+ if (!this.topChildren) this.topChildren = [];
20409
+ this.topChildren.push(this.scroller);
20410
+ }
20411
+ this.hasScroller = true;
20412
+ } else {
20413
+ if (this.hasScroller && !this.scroller.dragScrolling) {
20414
+ this.hasScroller = undefined;
20415
+ this.scroller.update();
20416
+ }
20417
+ }
20418
+ };
20419
+
20420
+ Scroller.registerTheme("light", {
20421
+ style: {
20422
+ fill: "black"
20423
+ }
20424
+ });
20425
+
20426
+ Scroller.registerTheme("dark", {
20427
+ style: {
20428
+ fill: "white"
20429
+ }
20430
+ });
20431
+
20432
+ 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, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, TextEditor, 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 };