@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.
package/dist/worker.js CHANGED
@@ -44,8 +44,8 @@ var LeaferUI = function(exports) {
44
44
  }
45
45
  const DataHelper = {
46
46
  default(t, defaultData) {
47
- assign$1(defaultData, t);
48
- assign$1(t, defaultData);
47
+ assign$2(defaultData, t);
48
+ assign$2(t, defaultData);
49
49
  return t;
50
50
  },
51
51
  assign(t, merge, exclude) {
@@ -53,9 +53,9 @@ var LeaferUI = function(exports) {
53
53
  Object.keys(merge).forEach(key => {
54
54
  var _a, _b;
55
55
  value = merge[key];
56
- 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]);
56
+ 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]);
57
57
  if (exclude && key in exclude) {
58
- if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$1(t[key] = {}, merge[key], exclude[key]);
58
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$2(t[key] = {}, merge[key], exclude[key]);
59
59
  return;
60
60
  }
61
61
  t[key] = merge[key];
@@ -80,7 +80,7 @@ var LeaferUI = function(exports) {
80
80
  data[attrName] !== value && (data[attrName] = value);
81
81
  }
82
82
  };
83
- const {assign: assign$1} = DataHelper;
83
+ const {assign: assign$2} = DataHelper;
84
84
  class LeafData {
85
85
  get __useNaturalRatio() {
86
86
  return true;
@@ -199,56 +199,6 @@ var LeaferUI = function(exports) {
199
199
  this.__input = this.__middle = null;
200
200
  }
201
201
  }
202
- const {floor: floor$3, max: max$7} = Math;
203
- const Platform = {
204
- toURL(text, fileType) {
205
- let url = encodeURIComponent(text);
206
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
207
- return url;
208
- },
209
- image: {
210
- hitCanvasSize: 100,
211
- maxCacheSize: 2560 * 1600,
212
- maxPatternSize: 4096 * 2160,
213
- crossOrigin: "anonymous",
214
- isLarge(size, scaleX, scaleY, largeSize) {
215
- return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
216
- },
217
- isSuperLarge(size, scaleX, scaleY) {
218
- return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
219
- },
220
- getRealURL(url) {
221
- const {prefix: prefix, suffix: suffix} = Platform.image;
222
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
223
- if (prefix && url[0] === "/") url = prefix + url;
224
- return url;
225
- },
226
- resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
227
- const canvas = Platform.origin.createCanvas(max$7(floor$3(width + (xGap || 0)), 1), max$7(floor$3(height + (yGap || 0)), 1));
228
- const ctx = canvas.getContext("2d");
229
- if (opacity) ctx.globalAlpha = opacity;
230
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
231
- if (image) {
232
- if (clip) {
233
- const scaleX = width / clip.width, scaleY = height / clip.height;
234
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
235
- ctx.drawImage(image, 0, 0, image.width, image.height);
236
- } else ctx.drawImage(image, 0, 0, width, height);
237
- }
238
- return canvas;
239
- },
240
- setPatternTransform(pattern, transform, paint) {
241
- try {
242
- if (transform && pattern.setTransform) {
243
- pattern.setTransform(transform);
244
- transform = undefined;
245
- }
246
- } catch (_a) {}
247
- if (paint) DataHelper.stintSet(paint, "transform", transform);
248
- }
249
- }
250
- };
251
- const {image: image$1} = Platform;
252
202
  const IncrementId = {
253
203
  RUNTIME: "runtime",
254
204
  LEAF: "leaf",
@@ -268,7 +218,7 @@ var LeaferUI = function(exports) {
268
218
  };
269
219
  const I$2 = IncrementId;
270
220
  let tempA, tempB, tempTo;
271
- const {max: max$6} = Math, tempFour = [ 0, 0, 0, 0 ];
221
+ const {max: max$7} = Math, tempFour = [ 0, 0, 0, 0 ];
272
222
  const FourNumberHelper = {
273
223
  zero: [ ...tempFour ],
274
224
  tempFour: tempFour,
@@ -319,9 +269,9 @@ var LeaferUI = function(exports) {
319
269
  return data;
320
270
  },
321
271
  max(t, other, change) {
322
- if (isNumber(t) && isNumber(other)) return max$6(t, other);
272
+ if (isNumber(t) && isNumber(other)) return max$7(t, other);
323
273
  toTempAB(t, other, change);
324
- 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]));
274
+ 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]));
325
275
  },
326
276
  add(t, other, change) {
327
277
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -336,7 +286,7 @@ var LeaferUI = function(exports) {
336
286
  }
337
287
  };
338
288
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
339
- const {round: round$6, pow: pow$2, max: max$5, floor: floor$2, PI: PI$4} = Math;
289
+ const {round: round$6, pow: pow$2, max: max$6, floor: floor$3, PI: PI$4} = Math;
340
290
  const MathHelper = {
341
291
  within(value, min, max) {
342
292
  if (isObject(min)) max = min.max, min = min.min;
@@ -389,7 +339,7 @@ var LeaferUI = function(exports) {
389
339
  }
390
340
  },
391
341
  getFloorScale(num, min = 1) {
392
- return max$5(floor$2(num), min) / num;
342
+ return max$6(floor$3(num), min) / num;
393
343
  },
394
344
  randInt: randInt,
395
345
  randColor(opacity) {
@@ -427,7 +377,7 @@ var LeaferUI = function(exports) {
427
377
  };
428
378
  }
429
379
  const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
430
- const {float: float$5} = MathHelper;
380
+ const {float: float$6} = MathHelper;
431
381
  const tempPoint$5 = {};
432
382
  function getWorld() {
433
383
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
@@ -675,12 +625,12 @@ var LeaferUI = function(exports) {
675
625
  const cosR = c / scaleY;
676
626
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
677
627
  }
678
- const cosR = float$5(cos$6(rotation));
628
+ const cosR = float$6(cos$6(rotation));
679
629
  const sinR = sin$6(rotation);
680
- scaleX = float$5(scaleX), scaleY = float$5(scaleY);
681
- skewX = cosR ? float$5((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
682
- skewY = cosR ? float$5((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
683
- rotation = float$5(rotation / OneRadian);
630
+ scaleX = float$6(scaleX), scaleY = float$6(scaleY);
631
+ skewX = cosR ? float$6((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
632
+ skewY = cosR ? float$6((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
633
+ rotation = float$6(rotation / OneRadian);
684
634
  } else {
685
635
  scaleX = a;
686
636
  scaleY = d;
@@ -722,7 +672,7 @@ var LeaferUI = function(exports) {
722
672
  }
723
673
  };
724
674
  const M$b = MatrixHelper;
725
- const {float: float$4} = MathHelper;
675
+ const {float: float$5} = MathHelper;
726
676
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
727
677
  const {sin: sin$5, cos: cos$5, abs: abs$a, sqrt: sqrt$4, atan2: atan2$2, min: min$3, round: round$5} = Math;
728
678
  const PointHelper = {
@@ -860,7 +810,7 @@ var LeaferUI = function(exports) {
860
810
  return points;
861
811
  },
862
812
  isSame(t, point) {
863
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
813
+ return float$5(t.x) === float$5(point.x) && float$5(t.y) === float$5(point.y);
864
814
  },
865
815
  reset(t) {
866
816
  P$7.reset(t);
@@ -1194,14 +1144,14 @@ var LeaferUI = function(exports) {
1194
1144
  };
1195
1145
  const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$3} = TwoPointBoundsHelper;
1196
1146
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1197
- const {float: float$3, fourNumber: fourNumber$1} = MathHelper;
1198
- const {floor: floor$1, ceil: ceil$2} = Math;
1147
+ const {float: float$4, fourNumber: fourNumber$1} = MathHelper;
1148
+ const {floor: floor$2, ceil: ceil$2} = Math;
1199
1149
  let right$4, bottom$3, boundsRight, boundsBottom;
1200
1150
  const point$2 = {};
1201
1151
  const toPoint$5 = {};
1202
- const tempBounds$3 = {};
1152
+ const tempBounds$4 = {};
1203
1153
  const BoundsHelper = {
1204
- tempBounds: tempBounds$3,
1154
+ tempBounds: tempBounds$4,
1205
1155
  set(t, x = 0, y = 0, width = 0, height = 0) {
1206
1156
  t.x = x;
1207
1157
  t.y = y;
@@ -1270,9 +1220,9 @@ var LeaferUI = function(exports) {
1270
1220
  t.height *= scaleY;
1271
1221
  },
1272
1222
  tempToOuterOf(t, matrix) {
1273
- B.copy(tempBounds$3, t);
1274
- B.toOuterOf(tempBounds$3, matrix);
1275
- return tempBounds$3;
1223
+ B.copy(tempBounds$4, t);
1224
+ B.toOuterOf(tempBounds$4, matrix);
1225
+ return tempBounds$4;
1276
1226
  },
1277
1227
  getOuterOf(t, matrix) {
1278
1228
  t = Object.assign({}, t);
@@ -1330,9 +1280,9 @@ var LeaferUI = function(exports) {
1330
1280
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1331
1281
  to || (to = put);
1332
1282
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1333
- tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1334
- tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1335
- AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1283
+ tempBounds$4.width = changeSize ? put.width *= putScale : put.width * putScale;
1284
+ tempBounds$4.height = changeSize ? put.height *= putScale : put.height * putScale;
1285
+ AlignHelper.toPoint(align, tempBounds$4, t, to, true, true);
1336
1286
  },
1337
1287
  getSpread(t, spread, side) {
1338
1288
  const n = {};
@@ -1347,8 +1297,8 @@ var LeaferUI = function(exports) {
1347
1297
  },
1348
1298
  ceil(t) {
1349
1299
  const {x: x, y: y} = t;
1350
- t.x = floor$1(t.x);
1351
- t.y = floor$1(t.y);
1300
+ t.x = floor$2(t.x);
1301
+ t.y = floor$2(t.y);
1352
1302
  t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1353
1303
  t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1354
1304
  },
@@ -1363,10 +1313,10 @@ var LeaferUI = function(exports) {
1363
1313
  }
1364
1314
  },
1365
1315
  float(t, maxLength) {
1366
- t.x = float$3(t.x, maxLength);
1367
- t.y = float$3(t.y, maxLength);
1368
- t.width = float$3(t.width, maxLength);
1369
- t.height = float$3(t.height, maxLength);
1316
+ t.x = float$4(t.x, maxLength);
1317
+ t.y = float$4(t.y, maxLength);
1318
+ t.width = float$4(t.width, maxLength);
1319
+ t.height = float$4(t.height, maxLength);
1370
1320
  },
1371
1321
  add(t, bounds, isPoint) {
1372
1322
  right$4 = t.x + t.width;
@@ -1480,6 +1430,9 @@ var LeaferUI = function(exports) {
1480
1430
  isEmpty(t) {
1481
1431
  return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
1482
1432
  },
1433
+ hasSize(t) {
1434
+ return t.width && t.height;
1435
+ },
1483
1436
  reset(t) {
1484
1437
  B.set(t);
1485
1438
  }
@@ -1628,7 +1581,7 @@ var LeaferUI = function(exports) {
1628
1581
  BoundsHelper.reset(this);
1629
1582
  }
1630
1583
  }
1631
- const tempBounds$2 = new Bounds;
1584
+ const tempBounds$3 = new Bounds;
1632
1585
  class AutoBounds {
1633
1586
  constructor(top, right, bottom, left, width, height) {
1634
1587
  isObject(top) ? this.copy(top) : this.set(top, right, bottom, left, width, height);
@@ -1650,6 +1603,11 @@ var LeaferUI = function(exports) {
1650
1603
  return new Bounds(left, top, width ? width : parent.width - left - right, height ? height : parent.height - top - bottom);
1651
1604
  }
1652
1605
  }
1606
+ const UnitConvertHelper = {
1607
+ number(value, percentRefer) {
1608
+ return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
1609
+ }
1610
+ };
1653
1611
  const StringNumberMap = {
1654
1612
  0: 1,
1655
1613
  1: 1,
@@ -1665,6 +1623,66 @@ var LeaferUI = function(exports) {
1665
1623
  e: 1,
1666
1624
  E: 1
1667
1625
  };
1626
+ const {floor: floor$1, max: max$5} = Math;
1627
+ const Platform = {
1628
+ toURL(text, fileType) {
1629
+ let url = encodeURIComponent(text);
1630
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
1631
+ return url;
1632
+ },
1633
+ image: {
1634
+ hitCanvasSize: 100,
1635
+ maxCacheSize: 2560 * 1600,
1636
+ maxPatternSize: 4096 * 2160,
1637
+ crossOrigin: "anonymous",
1638
+ isLarge(size, scaleX, scaleY, largeSize) {
1639
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
1640
+ },
1641
+ isSuperLarge(size, scaleX, scaleY) {
1642
+ return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
1643
+ },
1644
+ getRealURL(url) {
1645
+ const {prefix: prefix, suffix: suffix} = image$1;
1646
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
1647
+ if (prefix && url[0] === "/") url = prefix + url;
1648
+ return url;
1649
+ },
1650
+ resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1651
+ const realWidth = max$5(floor$1(width + (xGap || 0)), 1), realHeight = max$5(floor$1(height + (yGap || 0)), 1);
1652
+ let interlaceX, interlaceY, interlaceOffset;
1653
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1654
+ const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1655
+ const ctx = canvas.getContext("2d");
1656
+ if (opacity) ctx.globalAlpha = opacity;
1657
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
1658
+ if (image$1.canUse(view)) {
1659
+ if (clip) {
1660
+ const scaleX = width / clip.width, scaleY = height / clip.height;
1661
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
1662
+ ctx.drawImage(view, 0, 0, view.width, view.height);
1663
+ } else ctx.drawImage(view, 0, 0, width, height);
1664
+ if (interlaceOffset) {
1665
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
1666
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
1667
+ }
1668
+ }
1669
+ return canvas;
1670
+ },
1671
+ canUse(view) {
1672
+ return view && view.width && !view.__closed;
1673
+ },
1674
+ setPatternTransform(pattern, transform, paint) {
1675
+ try {
1676
+ if (transform && pattern.setTransform) {
1677
+ pattern.setTransform(transform);
1678
+ transform = undefined;
1679
+ }
1680
+ } catch (_a) {}
1681
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
1682
+ }
1683
+ }
1684
+ };
1685
+ const {image: image$1} = Platform;
1668
1686
  const {randColor: randColor} = MathHelper;
1669
1687
  class Debug {
1670
1688
  constructor(name) {
@@ -2721,7 +2739,7 @@ var LeaferUI = function(exports) {
2721
2739
  return [];
2722
2740
  }
2723
2741
  };
2724
- 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;
2742
+ 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;
2725
2743
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2726
2744
  const {ellipticalArc: ellipticalArc} = EllipseHelper;
2727
2745
  const debug$f = Debug.get("PathConvert");
@@ -2849,10 +2867,10 @@ var LeaferUI = function(exports) {
2849
2867
  old[i + 2] += y;
2850
2868
  old[i + 3] += x;
2851
2869
  old[i + 4] += y;
2852
- command = S;
2870
+ command = S$1;
2853
2871
 
2854
- case S:
2855
- smooth = lastCommand === C$7 || lastCommand === S;
2872
+ case S$1:
2873
+ smooth = lastCommand === C$7 || lastCommand === S$1;
2856
2874
  x1 = smooth ? x * 2 - controlX : old[i + 1];
2857
2875
  y1 = smooth ? y * 2 - controlY : old[i + 2];
2858
2876
  controlX = old[i + 1];
@@ -3096,10 +3114,10 @@ var LeaferUI = function(exports) {
3096
3114
  data.push(O$5, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3097
3115
  }
3098
3116
  },
3099
- arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3117
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
3100
3118
  if (!isUndefined(lastX)) {
3101
- const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3102
- radius = min$2(radius, min$2(d / 2, d / 2 * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3119
+ const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
3120
+ radius = min$2(radius, min$2(r, r * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3103
3121
  }
3104
3122
  data.push(U$4, x1, y1, x2, y2, radius);
3105
3123
  },
@@ -3424,7 +3442,7 @@ var LeaferUI = function(exports) {
3424
3442
  let command, lastCommand, commandLen;
3425
3443
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3426
3444
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3427
- const len = data.length;
3445
+ const len = data.length, three = len === 9;
3428
3446
  const smooth = [];
3429
3447
  while (i < len) {
3430
3448
  command = data[i];
@@ -3436,7 +3454,7 @@ var LeaferUI = function(exports) {
3436
3454
  if (data[i] === L$5) {
3437
3455
  secondX = data[i + 1];
3438
3456
  secondY = data[i + 2];
3439
- smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3457
+ three ? smooth.push(M$5, startX, startY) : smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3440
3458
  } else {
3441
3459
  smooth.push(M$5, startX, startY);
3442
3460
  }
@@ -3448,11 +3466,11 @@ var LeaferUI = function(exports) {
3448
3466
  i += 3;
3449
3467
  switch (data[i]) {
3450
3468
  case L$5:
3451
- arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3469
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
3452
3470
  break;
3453
3471
 
3454
3472
  case Z$3:
3455
- arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3473
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
3456
3474
  break;
3457
3475
 
3458
3476
  default:
@@ -3464,7 +3482,7 @@ var LeaferUI = function(exports) {
3464
3482
 
3465
3483
  case Z$3:
3466
3484
  if (lastCommand !== Z$3) {
3467
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3485
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
3468
3486
  smooth.push(Z$3);
3469
3487
  }
3470
3488
  i += 1;
@@ -3551,9 +3569,10 @@ var LeaferUI = function(exports) {
3551
3569
  run() {
3552
3570
  return __awaiter(this, void 0, void 0, function*() {
3553
3571
  try {
3554
- if (this.isComplete) return;
3572
+ if (this.isComplete || this.runing) return;
3573
+ this.runing = true;
3555
3574
  if (this.canUse && !this.canUse()) return this.cancel();
3556
- if (this.task && this.parent.running) yield this.task();
3575
+ if (this.task) yield this.task();
3557
3576
  } catch (error) {
3558
3577
  debug$c.error(error);
3559
3578
  }
@@ -3668,7 +3687,7 @@ var LeaferUI = function(exports) {
3668
3687
  stop() {
3669
3688
  this.isComplete = true;
3670
3689
  this.list.forEach(task => {
3671
- if (!task.isComplete) task.cancel();
3690
+ if (!task.isComplete) task.run();
3672
3691
  });
3673
3692
  this.pause();
3674
3693
  this.empty();
@@ -3951,7 +3970,7 @@ var LeaferUI = function(exports) {
3951
3970
  getFull(_filters) {
3952
3971
  return this.view;
3953
3972
  }
3954
- getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
3973
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
3955
3974
  width || (width = this.width);
3956
3975
  height || (height = this.height);
3957
3976
  if (this.cache) {
@@ -3964,7 +3983,7 @@ var LeaferUI = function(exports) {
3964
3983
  }
3965
3984
  if (data) return data;
3966
3985
  }
3967
- const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
3986
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
3968
3987
  this.cache = this.use > 1 ? {
3969
3988
  data: canvas,
3970
3989
  params: arguments
@@ -5706,7 +5725,7 @@ var LeaferUI = function(exports) {
5706
5725
  if (this.__layout.opacityChanged) this.__layout.opacityChanged = false;
5707
5726
  }
5708
5727
  };
5709
- const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper;
5728
+ const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
5710
5729
  const BranchRender = {
5711
5730
  __updateChange() {
5712
5731
  const {__layout: layout} = this;
@@ -5717,8 +5736,8 @@ var LeaferUI = function(exports) {
5717
5736
  this.__.__checkSingle();
5718
5737
  },
5719
5738
  __render(canvas, options) {
5720
- this.__nowWorld = this.__getNowWorld(options);
5721
- if (this.__worldOpacity) {
5739
+ const nowWorld = this.__nowWorld = this.__getNowWorld(options);
5740
+ if (this.__worldOpacity && hasSize(nowWorld)) {
5722
5741
  const data = this.__;
5723
5742
  if (data.__useDim) {
5724
5743
  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);
@@ -5727,7 +5746,6 @@ var LeaferUI = function(exports) {
5727
5746
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5728
5747
  const tempCanvas = canvas.getSameCanvas(false, true);
5729
5748
  this.__renderBranch(tempCanvas, options);
5730
- const nowWorld = this.__nowWorld;
5731
5749
  canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5732
5750
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
5733
5751
  tempCanvas.recycle(nowWorld);
@@ -6549,7 +6567,7 @@ var LeaferUI = function(exports) {
6549
6567
  this.levelMap = null;
6550
6568
  }
6551
6569
  }
6552
- const version = "1.12.4";
6570
+ const version = "2.0.1";
6553
6571
  class LeaferCanvas extends LeaferCanvasBase {
6554
6572
  get allowBackgroundColor() {
6555
6573
  return true;
@@ -6949,6 +6967,7 @@ var LeaferUI = function(exports) {
6949
6967
  this.times = 0;
6950
6968
  this.config = {
6951
6969
  usePartRender: true,
6970
+ ceilPartPixel: true,
6952
6971
  maxFPS: 120
6953
6972
  };
6954
6973
  this.frames = [];
@@ -7057,8 +7076,9 @@ var LeaferUI = function(exports) {
7057
7076
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
7058
7077
  canvas.save();
7059
7078
  bounds.spread(Renderer.clipSpread).ceil();
7060
- canvas.clearWorld(bounds);
7061
- canvas.clipWorld(bounds);
7079
+ const {ceilPartPixel: ceilPartPixel} = this.config;
7080
+ canvas.clipWorld(bounds, ceilPartPixel);
7081
+ canvas.clearWorld(bounds, ceilPartPixel);
7062
7082
  this.__render(bounds, realBounds);
7063
7083
  canvas.restore();
7064
7084
  Run.end(t);
@@ -7440,11 +7460,7 @@ var LeaferUI = function(exports) {
7440
7460
  const ColorConvert = {
7441
7461
  hasTransparent: hasTransparent$3
7442
7462
  };
7443
- const UnitConvert = {
7444
- number(value, percentRefer) {
7445
- return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
7446
- }
7447
- };
7463
+ const UnitConvert = UnitConvertHelper;
7448
7464
  const PathArrow = {};
7449
7465
  const Paint = {};
7450
7466
  const PaintImage = {};
@@ -7507,16 +7523,16 @@ var LeaferUI = function(exports) {
7507
7523
  return t.fill || t.stroke;
7508
7524
  }
7509
7525
  get __autoWidth() {
7510
- return !this._width;
7526
+ return this._width == null;
7511
7527
  }
7512
7528
  get __autoHeight() {
7513
- return !this._height;
7529
+ return this._height == null;
7514
7530
  }
7515
7531
  get __autoSide() {
7516
- return !this._width || !this._height;
7532
+ return this._width == null || this._height == null;
7517
7533
  }
7518
7534
  get __autoSize() {
7519
- return !this._width && !this._height;
7535
+ return this._width == null && this._height == null;
7520
7536
  }
7521
7537
  setVisible(value) {
7522
7538
  this._visible = value;
@@ -8662,9 +8678,10 @@ var LeaferUI = function(exports) {
8662
8678
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8663
8679
  const rx = width / 2, ry = height / 2;
8664
8680
  const path = this.__.path = [];
8681
+ let open;
8665
8682
  if (innerRadius) {
8666
8683
  if (startAngle || endAngle) {
8667
- if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
8684
+ if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false); else open = true;
8668
8685
  ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
8669
8686
  } else {
8670
8687
  if (innerRadius < 1) {
@@ -8681,7 +8698,7 @@ var LeaferUI = function(exports) {
8681
8698
  ellipse(path, rx, ry, rx, ry);
8682
8699
  }
8683
8700
  }
8684
- closePath$2(path);
8701
+ if (!open) closePath$2(path);
8685
8702
  if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
8686
8703
  }
8687
8704
  };
@@ -9243,7 +9260,7 @@ var LeaferUI = function(exports) {
9243
9260
  EventCreator.changeName(oldName, newName);
9244
9261
  }
9245
9262
  }
9246
- 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;
9263
+ 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;
9247
9264
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9248
9265
  const DragBoundsHelper = {
9249
9266
  limitMove(leaf, move) {
@@ -9281,8 +9298,8 @@ var LeaferUI = function(exports) {
9281
9298
  } else {
9282
9299
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
9283
9300
  }
9284
- move.x = float$2(move.x);
9285
- move.y = float$2(move.y);
9301
+ move.x = float$3(move.x);
9302
+ move.y = float$3(move.y);
9286
9303
  return move;
9287
9304
  },
9288
9305
  getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
@@ -9294,26 +9311,26 @@ var LeaferUI = function(exports) {
9294
9311
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9295
9312
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9296
9313
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9297
- aSize = float$2(tempContent.minX - tempDragBounds.minX);
9298
- bSize = float$2(tempDragBounds.maxX - tempContent.maxX);
9314
+ aSize = float$3(tempContent.minX - tempDragBounds.minX);
9315
+ bSize = float$3(tempDragBounds.maxX - tempContent.maxX);
9299
9316
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9300
9317
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9301
9318
  correctScaleX *= max$3(aScale, bScale);
9302
9319
  } else {
9303
9320
  if (scale.x < 0) {
9304
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9321
+ if (float$3(minX(content) - minX(dragBounds)) <= 0 || float$3(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9305
9322
  tempContent.unsign();
9306
9323
  }
9307
- aSize = float$2(tempDragBounds.minX - tempContent.minX);
9308
- bSize = float$2(tempContent.maxX - tempDragBounds.maxX);
9324
+ aSize = float$3(tempDragBounds.minX - tempContent.minX);
9325
+ bSize = float$3(tempContent.maxX - tempDragBounds.maxX);
9309
9326
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
9310
9327
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
9311
9328
  correctScaleX *= min$1(aScale, bScale);
9312
9329
  }
9313
9330
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9314
9331
  if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9315
- aSize = float$2(tempContent.minY - tempDragBounds.minY);
9316
- bSize = float$2(tempDragBounds.maxY - tempContent.maxY);
9332
+ aSize = float$3(tempContent.minY - tempDragBounds.minY);
9333
+ bSize = float$3(tempDragBounds.maxY - tempContent.maxY);
9317
9334
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
9318
9335
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
9319
9336
  correctScaleY *= max$3(aScale, bScale);
@@ -9324,11 +9341,11 @@ var LeaferUI = function(exports) {
9324
9341
  }
9325
9342
  } else {
9326
9343
  if (scale.y < 0) {
9327
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9344
+ if (float$3(minY(content) - minY(dragBounds)) <= 0 || float$3(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9328
9345
  tempContent.unsign();
9329
9346
  }
9330
- aSize = float$2(tempDragBounds.minY - tempContent.minY);
9331
- bSize = float$2(tempContent.maxY - tempDragBounds.maxY);
9347
+ aSize = float$3(tempDragBounds.minY - tempContent.minY);
9348
+ bSize = float$3(tempContent.maxY - tempDragBounds.maxY);
9332
9349
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
9333
9350
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
9334
9351
  correctScaleY *= min$1(aScale, bScale);
@@ -9761,7 +9778,7 @@ var LeaferUI = function(exports) {
9761
9778
  function exclude(leaf, excludePath) {
9762
9779
  return excludePath && excludePath.has(leaf);
9763
9780
  }
9764
- const config$1 = {
9781
+ const config$2 = {
9765
9782
  wheel: {
9766
9783
  zoomSpeed: .5,
9767
9784
  moveSpeed: .5,
@@ -9833,7 +9850,7 @@ var LeaferUI = function(exports) {
9833
9850
  return this.p.hitRadius;
9834
9851
  }
9835
9852
  constructor(target, canvas, selector, userConfig) {
9836
- this.config = DataHelper.clone(config$1);
9853
+ this.config = DataHelper.clone(config$2);
9837
9854
  this.tapCount = 0;
9838
9855
  this.downKeyMap = {};
9839
9856
  this.target = target;
@@ -10336,8 +10353,8 @@ var LeaferUI = function(exports) {
10336
10353
  if (isHitPixel) {
10337
10354
  const {renderBounds: renderBounds} = this.__layout;
10338
10355
  const size = Platform.image.hitCanvasSize;
10339
- const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10340
- const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
10356
+ const scale = h.hitScale = tempBounds$3.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10357
+ const {x: x, y: y, width: width, height: height} = tempBounds$3.set(renderBounds).scale(scale);
10341
10358
  h.resize({
10342
10359
  width: width,
10343
10360
  height: height,
@@ -10347,6 +10364,7 @@ var LeaferUI = function(exports) {
10347
10364
  ImageManager.patternLocked = true;
10348
10365
  this.__renderShape(h, {
10349
10366
  matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y),
10367
+ snapshot: true,
10350
10368
  ignoreFill: !isHitPixelFill,
10351
10369
  ignoreStroke: !isHitPixelStroke
10352
10370
  });
@@ -10394,11 +10412,11 @@ var LeaferUI = function(exports) {
10394
10412
  }
10395
10413
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10396
10414
  };
10397
- const ui$4 = exports.UI.prototype, rect = exports.Rect.prototype, box$2 = exports.Box.prototype;
10398
- rect.__updateHitCanvas = box$2.__updateHitCanvas = function() {
10415
+ const ui$4 = exports.UI.prototype, rect = exports.Rect.prototype, box$3 = exports.Box.prototype;
10416
+ rect.__updateHitCanvas = box$3.__updateHitCanvas = function() {
10399
10417
  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;
10400
10418
  };
10401
- rect.__hitFill = box$2.__hitFill = function(inner) {
10419
+ rect.__hitFill = box$3.__hitFill = function(inner) {
10402
10420
  return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10403
10421
  };
10404
10422
  exports.Text.prototype.__drawHitPath = function(canvas) {
@@ -10424,8 +10442,8 @@ var LeaferUI = function(exports) {
10424
10442
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
10425
10443
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
10426
10444
  if (offset) x -= offset.x, y -= offset.y;
10427
- tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10428
- const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
10445
+ tempBounds$3.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
10446
+ const {data: data} = this.context.getImageData(tempBounds$3.x, tempBounds$3.y, tempBounds$3.width || 1, tempBounds$3.height || 1);
10429
10447
  for (let i = 0, len = data.length; i < len; i += 4) {
10430
10448
  if (data[i + 3] > 0) return true;
10431
10449
  }
@@ -10612,13 +10630,13 @@ var LeaferUI = function(exports) {
10612
10630
  }
10613
10631
  }
10614
10632
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
10615
- const tempBounds$1 = {};
10633
+ const tempBounds$2 = {};
10616
10634
  function shape(ui, current, options) {
10617
10635
  const canvas = current.getSameCanvas();
10618
10636
  const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
10619
10637
  const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
10620
- toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
10621
- tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
10638
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$2, layout.boxBounds, layout.strokeSpread),
10639
+ tempBounds$2) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
10622
10640
  let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
10623
10641
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10624
10642
  if (currentBounds.includes(nowWorldShapeBounds)) {
@@ -10764,7 +10782,7 @@ var LeaferUI = function(exports) {
10764
10782
  drawStrokesStyle: drawStrokesStyle,
10765
10783
  shape: shape
10766
10784
  };
10767
- let cache$1, box$1 = new Bounds;
10785
+ let cache$1, box$2 = new Bounds;
10768
10786
  const {isSame: isSame} = BoundsHelper;
10769
10787
  function image(ui, attrName, paint, boxBounds, firstUse) {
10770
10788
  let leafPaint, event;
@@ -10780,7 +10798,7 @@ var LeaferUI = function(exports) {
10780
10798
  cache$1 = image.use > 1 ? {
10781
10799
  leafPaint: leafPaint,
10782
10800
  paint: paint,
10783
- boxBounds: box$1.set(boxBounds)
10801
+ boxBounds: box$2.set(boxBounds)
10784
10802
  } : null;
10785
10803
  }
10786
10804
  if (firstUse || image.loading) event = {
@@ -10873,7 +10891,7 @@ var LeaferUI = function(exports) {
10873
10891
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
10874
10892
  if (paint.mode === "strench") paint.mode = "stretch";
10875
10893
  const {width: width, height: height} = image;
10876
- 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;
10894
+ 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;
10877
10895
  const sameBox = box.width === width && box.height === height;
10878
10896
  const data = {
10879
10897
  mode: mode
@@ -10939,6 +10957,10 @@ var LeaferUI = function(exports) {
10939
10957
  if (opacity && opacity < 1) data.opacity = opacity;
10940
10958
  if (filters) data.filters = filters;
10941
10959
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
10960
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
10961
+ type: "x",
10962
+ offset: interlace
10963
+ } : interlace;
10942
10964
  return data;
10943
10965
  }
10944
10966
  function getGapData(gap, repeat, width, height, box) {
@@ -11059,7 +11081,7 @@ var LeaferUI = function(exports) {
11059
11081
  if (transform) copy$4(imageMatrix, transform);
11060
11082
  scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
11061
11083
  }
11062
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11084
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11063
11085
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11064
11086
  paint.style = pattern;
11065
11087
  paint.patternId = id;
@@ -11079,8 +11101,8 @@ var LeaferUI = function(exports) {
11079
11101
  }
11080
11102
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11081
11103
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11082
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
11083
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
11104
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
11105
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
11084
11106
  return false;
11085
11107
  } else {
11086
11108
  if (drawImage) {
@@ -11261,7 +11283,7 @@ var LeaferUI = function(exports) {
11261
11283
  getTransform: getTransform
11262
11284
  };
11263
11285
  const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$2, abs: abs$5} = Math;
11264
- const tempBounds = {}, tempMatrix = new Matrix;
11286
+ const tempBounds$1 = {}, tempMatrix = new Matrix;
11265
11287
  const offsetOutBounds$1 = {};
11266
11288
  function shadow$1(ui, current, shape) {
11267
11289
  let copyBounds, transform;
@@ -11323,9 +11345,9 @@ var LeaferUI = function(exports) {
11323
11345
  const {shapeBounds: shapeBounds} = shape;
11324
11346
  let from, to;
11325
11347
  if (Platform.fullImageShadow) {
11326
- copy$3(tempBounds, canvas.bounds);
11327
- move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11328
- from = canvas.bounds, to = tempBounds;
11348
+ copy$3(tempBounds$1, canvas.bounds);
11349
+ move$6(tempBounds$1, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
11350
+ from = canvas.bounds, to = tempBounds$1;
11329
11351
  } else {
11330
11352
  from = shapeBounds, to = outBounds;
11331
11353
  }
@@ -11673,7 +11695,7 @@ var LeaferUI = function(exports) {
11673
11695
  const TextMode = 2;
11674
11696
  function layoutChar(drawData, style, width, _height) {
11675
11697
  const {rows: rows} = drawData;
11676
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
11698
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
11677
11699
  const justifyLast = width && textAlign.includes("both");
11678
11700
  const justify = justifyLast || width && textAlign.includes("justify");
11679
11701
  const justifyLetter = justify && textAlign.includes("letter");
@@ -11686,8 +11708,8 @@ var LeaferUI = function(exports) {
11686
11708
  remainingWidth = width - row.width - indentWidth;
11687
11709
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
11688
11710
  }
11689
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11690
- if (row.isOverflow && !letterSpacing) row.textMode = true;
11711
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
11712
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
11691
11713
  if (mode === TextMode) {
11692
11714
  row.x += indentWidth;
11693
11715
  toTextChar$1(row);
@@ -11752,7 +11774,7 @@ var LeaferUI = function(exports) {
11752
11774
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11753
11775
  let starY = __baseLine;
11754
11776
  if (__clipText && realHeight > height) {
11755
- realHeight = Math.max(height, __lineHeight);
11777
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
11756
11778
  if (countRows > 1) drawData.overflow = countRows;
11757
11779
  } else if (height || autoSizeAlign) {
11758
11780
  switch (verticalAlign) {
@@ -11808,10 +11830,10 @@ var LeaferUI = function(exports) {
11808
11830
  bounds.height = realHeight;
11809
11831
  }
11810
11832
  function clipText(drawData, style, x, width) {
11811
- if (!width) return;
11812
11833
  const {rows: rows, overflow: overflow} = drawData;
11813
11834
  let {textOverflow: textOverflow} = style;
11814
- rows.splice(overflow);
11835
+ if (overflow) rows.splice(overflow);
11836
+ if (!width) return;
11815
11837
  if (textOverflow && textOverflow !== "show") {
11816
11838
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
11817
11839
  let char, charRight;
@@ -12097,8 +12119,13 @@ var LeaferUI = function(exports) {
12097
12119
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12098
12120
  }
12099
12121
  data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
12122
+ if (data.shadow) {
12123
+ const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
12124
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
12125
+ }
12100
12126
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
12101
12127
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
12128
+ if (data.shadow) canvas.restore();
12102
12129
  }
12103
12130
  }
12104
12131
  data.strokeWidth = strokeWidth;
@@ -13237,7 +13264,7 @@ var LeaferUI = function(exports) {
13237
13264
  const resizeSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${filterStyle$1}\n</filter>\n</defs>\n</svg>\n`;
13238
13265
  const rotateSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${filterStyle$1}\n</filter>\n</defs>\n</svg>\n`;
13239
13266
  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`;
13240
- const config = {
13267
+ const config$1 = {
13241
13268
  editSize: "size",
13242
13269
  keyEvent: true,
13243
13270
  stroke: "#836DFF",
@@ -13839,7 +13866,7 @@ var LeaferUI = function(exports) {
13839
13866
  this.selector = new EditSelect(this);
13840
13867
  this.editMask = new EditMask(this);
13841
13868
  this.targetEventIds = [];
13842
- let mergedConfig = DataHelper.clone(config);
13869
+ let mergedConfig = DataHelper.clone(config$1);
13843
13870
  if (userConfig) mergedConfig = DataHelper.default(userConfig, mergedConfig);
13844
13871
  this.mergedConfig = this.config = mergedConfig;
13845
13872
  this.addMany(this.editMask, this.selector, this.editBox);
@@ -14116,7 +14143,10 @@ var LeaferUI = function(exports) {
14116
14143
  return "focus";
14117
14144
  }
14118
14145
  get editBox() {
14119
- return this.editor.editBox;
14146
+ return this._editBox || this.editor.editBox;
14147
+ }
14148
+ set editBox(value) {
14149
+ this._editBox = value;
14120
14150
  }
14121
14151
  constructor(editor) {
14122
14152
  this.eventIds = [];
@@ -14302,7 +14332,7 @@ var LeaferUI = function(exports) {
14302
14332
  onSkew(_e) {}
14303
14333
  onUpdate() {
14304
14334
  const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
14305
- const line = this.editor.element;
14335
+ const line = editBox.target;
14306
14336
  let fromTo, leftOrRight;
14307
14337
  if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
14308
14338
  if (fromTo) {
@@ -15108,13 +15138,14 @@ var LeaferUI = function(exports) {
15108
15138
  LeaferTypeCreator.run(type, this);
15109
15139
  };
15110
15140
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
15111
- const {disabled: disabled} = this.app.config.move;
15141
+ const {disabled: disabled, scrollSpread: scrollSpread} = this.app.config.move;
15112
15142
  move$4.set(moveX, moveY);
15113
15143
  const scrollType = getScrollType(this);
15114
15144
  if (scrollType) {
15115
15145
  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;
15116
15146
  if (checkLimit && scrollType.includes("limit")) {
15117
15147
  bounds.set(this.__world).addPoint(this.zoomLayer);
15148
+ if (scrollSpread) bounds.spread(scrollSpread);
15118
15149
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
15119
15150
  if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
15120
15151
  }
@@ -16410,7 +16441,7 @@ var LeaferUI = function(exports) {
16410
16441
  }));
16411
16442
  }
16412
16443
  Plugin.add("flow", "resize");
16413
- const box = exports.Box.prototype, {__updateBoxBounds: __updateBoxBounds} = exports.Group.prototype;
16444
+ const box$1 = exports.Box.prototype, {__updateBoxBounds: __updateBoxBounds} = exports.Group.prototype;
16414
16445
  exports.UI.addAttr("flow", false, autoLayoutType);
16415
16446
  exports.UI.addAttr("gap", 0, boundsType);
16416
16447
  exports.UI.addAttr("flowAlign", "top-left", boundsType);
@@ -16421,7 +16452,7 @@ var LeaferUI = function(exports) {
16421
16452
  exports.UI.addAttr("autoHeight", undefined, autoBoundsType);
16422
16453
  exports.UI.addAttr("autoBox", undefined, boundsType);
16423
16454
  const {copyAndSpread: copyAndSpread} = BoundsHelper;
16424
- box.__updateFlowLayout = function() {
16455
+ box$1.__updateFlowLayout = function() {
16425
16456
  const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
16426
16457
  if (leaferIsCreated) this.leafer.created = false;
16427
16458
  switch (flow) {
@@ -16444,7 +16475,7 @@ var LeaferUI = function(exports) {
16444
16475
  }
16445
16476
  if (leaferIsCreated) this.leafer.created = true;
16446
16477
  };
16447
- box.__updateContentBounds = function() {
16478
+ box$1.__updateContentBounds = function() {
16448
16479
  const {padding: padding} = this.__;
16449
16480
  const layout = this.__layout;
16450
16481
  const same = layout.contentBounds === layout.boxBounds;
@@ -16455,7 +16486,7 @@ var LeaferUI = function(exports) {
16455
16486
  if (!same) layout.shrinkContentCancel();
16456
16487
  }
16457
16488
  };
16458
- box.__updateBoxBounds = function(secondLayout) {
16489
+ box$1.__updateBoxBounds = function(secondLayout) {
16459
16490
  if (this.children.length && !this.pathInputed) {
16460
16491
  const data = this.__, {flow: flow} = data;
16461
16492
  if (data.__autoSide) {
@@ -17209,7 +17240,7 @@ var LeaferUI = function(exports) {
17209
17240
  const rgbaMatch = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)/i;
17210
17241
  const hslMatch = /^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i;
17211
17242
  const hslaMatch = /^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i;
17212
- const int = parseInt, float$1 = parseFloat, {round: round$1} = Math;
17243
+ const int = parseInt, float$2 = parseFloat, {round: round$1} = Math;
17213
17244
  let cache = {}, totalCache = 0;
17214
17245
  function colorToRGBA(color, opacity) {
17215
17246
  let RGBA;
@@ -17317,16 +17348,16 @@ var LeaferUI = function(exports) {
17317
17348
  r: int(match[1]),
17318
17349
  g: int(match[2]),
17319
17350
  b: int(match[3]),
17320
- a: float$1(match[4])
17351
+ a: float$2(match[4])
17321
17352
  };
17322
17353
  }
17323
17354
  function hslToRGBA(color) {
17324
17355
  const match = hslMatch.exec(color);
17325
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), 1);
17356
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), 1);
17326
17357
  }
17327
17358
  function hslaToRGBA(color) {
17328
17359
  const match = hslaMatch.exec(color);
17329
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), float$1(match[4]));
17360
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), float$2(match[4]));
17330
17361
  }
17331
17362
  const n1 = 1 / 6, n2 = .5, n3 = 2 / 3, n4 = 1 / 3;
17332
17363
  function hue(p, q, t) {
@@ -17529,7 +17560,7 @@ var LeaferUI = function(exports) {
17529
17560
  }
17530
17561
  };
17531
17562
  const {getDistance: getDistance} = HighBezierHelper;
17532
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
17563
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float$1} = MathHelper;
17533
17564
  const tempPoint = {}, tempFrom = {};
17534
17565
  const HighCurveHelper = {
17535
17566
  transform(data, matrix) {
@@ -17682,7 +17713,7 @@ var LeaferUI = function(exports) {
17682
17713
  tempFrom.y = y;
17683
17714
  to.x = toX;
17684
17715
  to.y = toY;
17685
- cutDistance = float(motionDistance - total);
17716
+ cutDistance = float$1(motionDistance - total);
17686
17717
  if (cutDistance) {
17687
17718
  PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
17688
17719
  path.push(command, to.x, to.y);
@@ -17701,7 +17732,7 @@ var LeaferUI = function(exports) {
17701
17732
  toY = data[i + 6];
17702
17733
  distance = segments[index];
17703
17734
  if (total + distance > motionDistance) {
17704
- cutDistance = float(motionDistance - total);
17735
+ cutDistance = float$1(motionDistance - total);
17705
17736
  if (cutDistance) {
17706
17737
  t = HighBezierHelper.getT(cutDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
17707
17738
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
@@ -17894,21 +17925,21 @@ var LeaferUI = function(exports) {
17894
17925
  const style = {}, button = findParentButton(leaf);
17895
17926
  const state = button ? leaf.state || button.state : leaf.state;
17896
17927
  const stateStyle = state && leaf.states[state];
17897
- if (stateStyle && State.isState(state, leaf, button)) exist = assign(style, stateStyle);
17928
+ if (stateStyle && State.isState(state, leaf, button)) exist = assign$1(style, stateStyle);
17898
17929
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
17899
- if (selectedStyle && State.isSelected(leaf, button)) exist = assign(style, selectedStyle);
17930
+ if (selectedStyle && State.isSelected(leaf, button)) exist = assign$1(style, selectedStyle);
17900
17931
  const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
17901
- if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign(style, placeholderStyle);
17932
+ if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign$1(style, placeholderStyle);
17902
17933
  if (State.isDisabled(leaf, button)) {
17903
17934
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
17904
- if (disabledStyle) exist = assign(style, disabledStyle);
17935
+ if (disabledStyle) exist = assign$1(style, disabledStyle);
17905
17936
  } else {
17906
17937
  const focusStyle = style.focusStyle || leaf.focusStyle;
17907
- if (focusStyle && State.isFocus(leaf, button)) exist = assign(style, focusStyle);
17938
+ if (focusStyle && State.isFocus(leaf, button)) exist = assign$1(style, focusStyle);
17908
17939
  const hoverStyle = style.hoverStyle || leaf.hoverStyle;
17909
- if (hoverStyle && State.isHover(leaf, button)) exist = assign(style, hoverStyle);
17940
+ if (hoverStyle && State.isHover(leaf, button)) exist = assign$1(style, hoverStyle);
17910
17941
  const pressStyle = style.pressStyle || leaf.pressStyle;
17911
- if (pressStyle && State.isPress(leaf, button)) exist = assign(style, pressStyle);
17942
+ if (pressStyle && State.isPress(leaf, button)) exist = assign$1(style, pressStyle);
17912
17943
  }
17913
17944
  return exist ? style : undefined;
17914
17945
  }
@@ -17934,7 +17965,7 @@ var LeaferUI = function(exports) {
17934
17965
  if (type === "out" && isNull(data[name]) && isNull(style[name])) name = "transition";
17935
17966
  return isNull(style[name]) ? data[name] : style[name];
17936
17967
  }
17937
- function assign(style, stateStyle) {
17968
+ function assign$1(style, stateStyle) {
17938
17969
  Object.assign(style, stateStyle);
17939
17970
  return true;
17940
17971
  }
@@ -18494,7 +18525,13 @@ var LeaferUI = function(exports) {
18494
18525
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18495
18526
  let pixelRatio = options.pixelRatio || 1;
18496
18527
  let {x: x, y: y, width: width, height: height} = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18497
- if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18528
+ if (clip) {
18529
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18530
+ if (clip.rotation) matrix.rotateOfInner({
18531
+ x: x,
18532
+ y: y
18533
+ }, -clip.rotation);
18534
+ }
18498
18535
  const renderOptions = {
18499
18536
  exporting: true,
18500
18537
  matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
@@ -18665,6 +18702,248 @@ var LeaferUI = function(exports) {
18665
18702
  });
18666
18703
  Plugin.add("bright");
18667
18704
  exports.UI.addAttr("bright", false, dimType);
18705
+ const config = {
18706
+ theme: "light",
18707
+ style: {
18708
+ dragBoundsType: "outer",
18709
+ strokeAlign: "center",
18710
+ strokeWidthFixed: "zoom-in",
18711
+ width: 6,
18712
+ height: 6,
18713
+ opacity: .5,
18714
+ cornerRadius: 3,
18715
+ hoverStyle: {
18716
+ opacity: .6
18717
+ },
18718
+ pressStyle: {
18719
+ opacity: .66
18720
+ }
18721
+ },
18722
+ size: 6,
18723
+ endsMargin: 2,
18724
+ sideMargin: 2,
18725
+ minSize: 10,
18726
+ scaleFixed: "zoom-in",
18727
+ scrollType: "both",
18728
+ hideOnActionEnd: "hover"
18729
+ };
18730
+ const tempBounds = new Bounds, {float: float} = MathHelper, {clone: clone, assign: assign} = DataHelper;
18731
+ class Scroller extends exports.Group {
18732
+ get canUse() {
18733
+ return this.target.hasScroller;
18734
+ }
18735
+ constructor(target) {
18736
+ super();
18737
+ this.targetWorldBounds = new Bounds;
18738
+ this.viewportBounds = new Bounds;
18739
+ this.contentBounds = new Bounds;
18740
+ this.scrollXBounds = new Bounds;
18741
+ this.scrollYBounds = new Bounds;
18742
+ this.target = target;
18743
+ this.config = clone(config);
18744
+ this.updateConfig();
18745
+ this.__listenEvents();
18746
+ target.waitLeafer(() => {
18747
+ this.parent = target;
18748
+ this.__bindLeafer(target.leafer);
18749
+ });
18750
+ if (this.mergedConfig.hideOnActionEnd) this.opacity = 0;
18751
+ }
18752
+ static registerTheme(theme, themeConfig) {
18753
+ S.themeMap[theme] = themeConfig;
18754
+ }
18755
+ static getTheme(theme) {
18756
+ return theme && S.themeMap[theme];
18757
+ }
18758
+ static hasTheme(theme) {
18759
+ return theme && !!S.themeMap[theme];
18760
+ }
18761
+ updateConfig() {
18762
+ const {scrollConfig: scrollConfig} = this.target;
18763
+ const themeConfig = S.getTheme(scrollConfig && S.hasTheme(scrollConfig.theme) && scrollConfig.theme || this.config.theme);
18764
+ const mergedConfig = this.mergedConfig = clone(this.config);
18765
+ assign(mergedConfig, themeConfig);
18766
+ if (scrollConfig) assign(mergedConfig, scrollConfig);
18767
+ this.updateStyle(mergedConfig.style);
18768
+ }
18769
+ updateStyle(style) {
18770
+ if (!this.scrollXBar) this.addMany(this.scrollXBar = new exports.Box, this.scrollYBar = new exports.Box);
18771
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
18772
+ scrollXBar.set(style);
18773
+ scrollYBar.set(style);
18774
+ scrollXBar.draggable = "x";
18775
+ scrollYBar.draggable = "y";
18776
+ }
18777
+ update(check = true) {
18778
+ if (this.dragScrolling) return;
18779
+ const {target: target, targetOverflow: targetOverflow, targetWorldBounds: targetWorldBounds, viewportBounds: viewportBounds, contentBounds: contentBounds} = this, layout = target.__layout, {overflow: overflow} = target.__;
18780
+ const {childrenRenderBounds: childrenRenderBounds} = layout;
18781
+ const {boxBounds: boxBounds, worldBoxBounds: worldBoxBounds} = layout;
18782
+ const isSameWorldBounds = check && targetOverflow === overflow && targetWorldBounds.isSame(worldBoxBounds);
18783
+ const isSameConfig = layout.scrollConfigChanged ? (this.updateConfig(), layout.scrollConfigChanged = false) : true;
18784
+ const nowContentBounds = tempBounds.set(viewportBounds).add(childrenRenderBounds);
18785
+ if (isSameWorldBounds && isSameConfig && contentBounds.isSame(nowContentBounds)) return;
18786
+ this.targetOverflow = overflow;
18787
+ viewportBounds.set(boxBounds);
18788
+ targetWorldBounds.set(worldBoxBounds);
18789
+ contentBounds.set(nowContentBounds);
18790
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this, {size: size, endsMargin: endsMargin, minSize: minSize} = this.mergedConfig, {width: width, height: height} = viewportBounds;
18791
+ this.contentRealX = contentBounds.x - target.scrollX;
18792
+ this.contentRealY = contentBounds.y - target.scrollY;
18793
+ this.ratioX = viewportBounds.width / contentBounds.width;
18794
+ this.ratioY = viewportBounds.height / contentBounds.height;
18795
+ const min = size + endsMargin * 2 + minSize;
18796
+ scrollXBar.visible = float(contentBounds.width) > float(width) && overflow !== "y-scroll" && width > min;
18797
+ scrollYBar.visible = float(contentBounds.height) > float(height) && overflow !== "x-scroll" && height > min;
18798
+ this.updateScrollBar();
18799
+ }
18800
+ updateScrollBar() {
18801
+ const {target: target, viewportBounds: viewportBounds, contentBounds: contentBounds, ratioX: ratioX, ratioY: ratioY, scrollXBar: scrollXBar, scrollYBar: scrollYBar, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
18802
+ let {size: size, cornerRadius: cornerRadius, endsMargin: endsMargin, sideMargin: sideMargin, minSize: minSize, scaleFixed: scaleFixed, scrollType: scrollType} = this.mergedConfig;
18803
+ const scale = scaleFixed ? target.getClampRenderScale() : 1;
18804
+ endsMargin /= scale;
18805
+ sideMargin /= scale;
18806
+ size /= scale;
18807
+ if (isUndefined(cornerRadius)) cornerRadius = size / 2;
18808
+ if (scrollXBar.visible) {
18809
+ scrollXBounds.set(viewportBounds).shrink([ endsMargin, scrollYBar.visible ? size + sideMargin : endsMargin, sideMargin, endsMargin ]);
18810
+ const scrollRatioX = this.scrollRatioX = scrollXBounds.width / contentBounds.width;
18811
+ scrollXBar.set({
18812
+ x: scrollXBounds.x - contentBounds.x * scrollRatioX,
18813
+ y: scrollXBounds.maxY - size,
18814
+ width: Math.max(scrollXBounds.width * ratioX, minSize),
18815
+ height: size,
18816
+ cornerRadius: cornerRadius,
18817
+ dragBounds: scrollXBounds,
18818
+ hittable: scrollType !== "move"
18819
+ });
18820
+ }
18821
+ if (scrollYBar.visible) {
18822
+ scrollYBounds.set(viewportBounds).shrink([ endsMargin, sideMargin, scrollXBar.visible ? size + sideMargin : endsMargin, endsMargin ]);
18823
+ const scrollRatioY = this.scrollRatioY = scrollYBounds.height / contentBounds.height;
18824
+ scrollYBar.set({
18825
+ x: scrollYBounds.maxX - size,
18826
+ y: scrollYBounds.y - contentBounds.y * scrollRatioY,
18827
+ width: size,
18828
+ height: Math.max(scrollYBounds.height * ratioY, minSize),
18829
+ cornerRadius: cornerRadius,
18830
+ dragBounds: scrollYBounds,
18831
+ hittable: scrollType !== "move"
18832
+ });
18833
+ }
18834
+ this.x = -this.target.scrollX;
18835
+ this.y = -this.target.scrollY;
18836
+ LeafHelper.updateAllMatrix(this);
18837
+ BranchHelper.updateBounds(this);
18838
+ LeafHelper.updateAllChange(this);
18839
+ }
18840
+ onDrag(e) {
18841
+ if (this.mergedConfig.scrollType === "move") return;
18842
+ this.dragScrolling = true;
18843
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
18844
+ const scrollX = e.current === scrollXBar;
18845
+ if (scrollX) target.scrollX = -((scrollXBar.x - scrollXBounds.x) / this.scrollRatioX + this.contentRealX); else target.scrollY = -((scrollYBar.y - scrollYBounds.y) / this.scrollRatioY + this.contentRealY);
18846
+ }
18847
+ onDragEnd() {
18848
+ if (this.mergedConfig.scrollType === "move") return;
18849
+ this.dragScrolling = false;
18850
+ }
18851
+ onMove(e) {
18852
+ if (!this.canUse) return;
18853
+ this.onEnter();
18854
+ const {scrollType: scrollType, stopDefault: stopDefault} = this.mergedConfig;
18855
+ if (scrollType === "drag") return;
18856
+ const {viewportBounds: viewportBounds, contentBounds: contentBounds, scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
18857
+ if (scrollXBar.visible || scrollYBar.visible) {
18858
+ const move = e.getInnerMove(this.target);
18859
+ DragBoundsHelper.getValidMove(contentBounds, viewportBounds, "inner", move, true);
18860
+ let needStop;
18861
+ if (move.x && scrollXBar.visible) this.target.scrollX += move.x, needStop = true;
18862
+ if (move.y && scrollYBar.visible) this.target.scrollY += move.y, needStop = true;
18863
+ if (needStop || stopDefault) e.stop();
18864
+ if (stopDefault) e.stopDefault();
18865
+ }
18866
+ }
18867
+ onMoveEnd(e) {
18868
+ if (!this.canUse) return;
18869
+ if (!this.target.hit(e)) this.onLeave();
18870
+ }
18871
+ onEnter() {
18872
+ if (!this.canUse) return;
18873
+ clearTimeout(this.hideTimer);
18874
+ this.killAnimate();
18875
+ this.opacity = 1;
18876
+ }
18877
+ onLeave() {
18878
+ if (!this.canUse) return;
18879
+ clearTimeout(this.hideTimer);
18880
+ if (this.mergedConfig.hideOnActionEnd) this.hideTimer = setTimeout(() => {
18881
+ this.set({
18882
+ opacity: 0
18883
+ }, Plugin.has("animate"));
18884
+ }, 600);
18885
+ }
18886
+ onResize() {
18887
+ if (this.canUse) this.update();
18888
+ }
18889
+ __listenEvents() {
18890
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target} = this;
18891
+ this.__eventIds = [ scrollXBar.on_(exports.DragEvent.DRAG, this.onDrag, this), scrollXBar.on_(exports.DragEvent.END, this.onDragEnd, this), scrollYBar.on_(exports.DragEvent.DRAG, this.onDrag, this), scrollYBar.on_(exports.DragEvent.END, this.onDragEnd, this), target.on_(exports.PointerEvent.ENTER, this.onEnter, this), target.on_(exports.PointerEvent.LEAVE, this.onLeave, this), target.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this), target.on_(exports.MoveEvent.END, this.onMoveEnd, this), target.on_(BoundsEvent.WORLD, this.onResize, this), target.on_(ChildEvent.DESTROY, this.destroy, this) ];
18892
+ }
18893
+ __removeListenEvents() {
18894
+ this.off_(this.__eventIds);
18895
+ }
18896
+ destroy() {
18897
+ if (!this.destroyed) {
18898
+ this.__removeListenEvents();
18899
+ const {target: target} = this;
18900
+ target.scroller = target.topChildren = target.hasScroller = undefined;
18901
+ this.target = this.config = null;
18902
+ super.destroy();
18903
+ }
18904
+ }
18905
+ }
18906
+ Scroller.themeMap = {};
18907
+ const S = Scroller;
18908
+ function scrollConfigType(defaultValue) {
18909
+ return decorateLeafAttr(defaultValue, key => attr({
18910
+ set(value) {
18911
+ if (this.__setAttr(key, value)) {
18912
+ const layout = this.__layout;
18913
+ layout.scrollConfigChanged = true;
18914
+ doBoundsType(this);
18915
+ }
18916
+ }
18917
+ }));
18918
+ }
18919
+ Plugin.add("scroller");
18920
+ const box = exports.Box.prototype;
18921
+ exports.Box.addAttr("scrollConfig", undefined, scrollConfigType);
18922
+ box.__checkScroll = function(isScrollMode) {
18923
+ if (isScrollMode && this.isOverflow) {
18924
+ if (!this.scroller) {
18925
+ this.scroller = new Scroller(this);
18926
+ if (!this.topChildren) this.topChildren = [];
18927
+ this.topChildren.push(this.scroller);
18928
+ }
18929
+ this.hasScroller = true;
18930
+ } else {
18931
+ if (this.hasScroller && !this.scroller.dragScrolling) {
18932
+ this.hasScroller = undefined;
18933
+ this.scroller.update();
18934
+ }
18935
+ }
18936
+ };
18937
+ Scroller.registerTheme("light", {
18938
+ style: {
18939
+ fill: "black"
18940
+ }
18941
+ });
18942
+ Scroller.registerTheme("dark", {
18943
+ style: {
18944
+ fill: "white"
18945
+ }
18946
+ });
18668
18947
  exports.AlignHelper = AlignHelper;
18669
18948
  exports.AnimateEasing = AnimateEasing;
18670
18949
  exports.AnimateEvent = AnimateEvent;
@@ -18797,6 +19076,7 @@ var LeaferUI = function(exports) {
18797
19076
  exports.RobotData = RobotData;
18798
19077
  exports.Run = Run;
18799
19078
  exports.ScrollBar = ScrollBar;
19079
+ exports.Scroller = Scroller;
18800
19080
  exports.SelectArea = SelectArea;
18801
19081
  exports.Selector = Selector;
18802
19082
  exports.StarData = StarData;
@@ -18817,6 +19097,7 @@ var LeaferUI = function(exports) {
18817
19097
  exports.UIEvent = UIEvent;
18818
19098
  exports.UIRender = UIRender;
18819
19099
  exports.UnitConvert = UnitConvert;
19100
+ exports.UnitConvertHelper = UnitConvertHelper;
18820
19101
  exports.WaitHelper = WaitHelper;
18821
19102
  exports.WatchEvent = WatchEvent;
18822
19103
  exports.Watcher = Watcher;
@@ -18892,7 +19173,7 @@ var LeaferUI = function(exports) {
18892
19173
  exports.stateType = stateType;
18893
19174
  exports.strokeType = strokeType;
18894
19175
  exports.surfaceType = surfaceType;
18895
- exports.tempBounds = tempBounds$2;
19176
+ exports.tempBounds = tempBounds$3;
18896
19177
  exports.tempMatrix = tempMatrix$2;
18897
19178
  exports.tempPoint = tempPoint$4;
18898
19179
  exports.tryToNumber = tryToNumber;