@leafer/worker 1.9.9 → 1.9.11

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
@@ -230,7 +230,7 @@ var LeaferUI = function(exports) {
230
230
  }
231
231
  }
232
232
  let tempA, tempB, tempTo;
233
- const {max: max$5} = Math, tempFour = [ 0, 0, 0, 0 ];
233
+ const {max: max$6} = Math, tempFour = [ 0, 0, 0, 0 ];
234
234
  const FourNumberHelper = {
235
235
  zero: [ ...tempFour ],
236
236
  tempFour: tempFour,
@@ -243,7 +243,7 @@ var LeaferUI = function(exports) {
243
243
  return to;
244
244
  },
245
245
  setTemp(top, right, bottom, left) {
246
- return set$1(tempFour, top, right, bottom, left);
246
+ return set$2(tempFour, top, right, bottom, left);
247
247
  },
248
248
  toTempAB(a, b, change) {
249
249
  tempTo = change ? isNumber(a) ? b : a : [];
@@ -281,23 +281,23 @@ var LeaferUI = function(exports) {
281
281
  return data;
282
282
  },
283
283
  max(t, other, change) {
284
- if (isNumber(t) && isNumber(other)) return max$5(t, other);
284
+ if (isNumber(t) && isNumber(other)) return max$6(t, other);
285
285
  toTempAB(t, other, change);
286
- return set$1(tempTo, max$5(tempA[0], tempB[0]), max$5(tempA[1], tempB[1]), max$5(tempA[2], tempB[2]), max$5(tempA[3], tempB[3]));
286
+ 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]));
287
287
  },
288
288
  add(t, other, change) {
289
289
  if (isNumber(t) && isNumber(other)) return t + other;
290
290
  toTempAB(t, other, change);
291
- return set$1(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
291
+ return set$2(tempTo, tempA[0] + tempB[0], tempA[1] + tempB[1], tempA[2] + tempB[2], tempA[3] + tempB[3]);
292
292
  },
293
293
  swapAndScale(t, scaleX, scaleY, change) {
294
294
  if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [ t * scaleY, t * scaleX ];
295
295
  const to = change ? t : [];
296
296
  const [top, right, bottom, left] = t.length === 4 ? t : get$5(t);
297
- return set$1(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
297
+ return set$2(to, bottom * scaleY, left * scaleX, top * scaleY, right * scaleX);
298
298
  }
299
299
  };
300
- const {set: set$1, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
300
+ const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
301
301
  const {round: round$6, pow: pow$2, PI: PI$4} = Math;
302
302
  const MathHelper = {
303
303
  within(value, min, max) {
@@ -682,7 +682,7 @@ var LeaferUI = function(exports) {
682
682
  };
683
683
  const M$b = MatrixHelper;
684
684
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
685
- const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
685
+ const {sin: sin$5, cos: cos$5, abs: abs$a, sqrt: sqrt$4, atan2: atan2$2, min: min$2, round: round$5} = Math;
686
686
  const PointHelper = {
687
687
  defaultPoint: getPointData(),
688
688
  tempPoint: {},
@@ -774,12 +774,12 @@ var LeaferUI = function(exports) {
774
774
  return getDistanceFrom(t.x, t.y, point.x, point.y);
775
775
  },
776
776
  getDistanceFrom(x1, y1, x2, y2) {
777
- const x = abs$7(x2 - x1);
778
- const y = abs$7(y2 - y1);
777
+ const x = abs$a(x2 - x1);
778
+ const y = abs$a(y2 - y1);
779
779
  return sqrt$4(x * x + y * y);
780
780
  },
781
781
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
782
- return min$1(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
782
+ return min$2(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3));
783
783
  },
784
784
  getAngle(t, to) {
785
785
  return getAtan2(t, to) / OneRadian;
@@ -2417,9 +2417,9 @@ var LeaferUI = function(exports) {
2417
2417
  data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2418
2418
  }
2419
2419
  };
2420
- const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2420
+ const {sin: sin$4, cos: cos$4, hypot: hypot, atan2: atan2$1, ceil: ceil$2, abs: abs$9, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2421
2421
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2422
- const {set: set, toNumberPoints: toNumberPoints$1} = PointHelper;
2422
+ const {set: set$1, toNumberPoints: toNumberPoints$1} = PointHelper;
2423
2423
  const {M: M$a, L: L$a, C: C$8, Q: Q$7, Z: Z$8} = PathCommandMap;
2424
2424
  const tempPoint$2 = {};
2425
2425
  const BezierHelper = {
@@ -2487,14 +2487,14 @@ var LeaferUI = function(exports) {
2487
2487
  const lenCB = hypot(CBx, CBy);
2488
2488
  let totalRadian = endRadian - startRadian;
2489
2489
  if (totalRadian < 0) totalRadian += PI2;
2490
- if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$6(totalRadian - PI$3) < 1e-12) {
2490
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$9(totalRadian - PI$3) < 1e-12) {
2491
2491
  if (data) data.push(L$a, x1, y1);
2492
2492
  if (setPointBounds) {
2493
2493
  setPoint$4(setPointBounds, fromX, fromY);
2494
2494
  addPoint$2(setPointBounds, x1, y1);
2495
2495
  }
2496
- if (setStartPoint) set(setStartPoint, fromX, fromY);
2497
- if (setEndPoint) set(setEndPoint, x1, y1);
2496
+ if (setStartPoint) set$1(setStartPoint, fromX, fromY);
2497
+ if (setEndPoint) set$1(setEndPoint, x1, y1);
2498
2498
  return;
2499
2499
  }
2500
2500
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
@@ -2520,7 +2520,7 @@ var LeaferUI = function(exports) {
2520
2520
  let totalRadian = endRadian - startRadian;
2521
2521
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2522
2522
  if (anticlockwise) totalRadian -= PI2;
2523
- const parts = ceil$2(abs$6(totalRadian / PI_2));
2523
+ const parts = ceil$2(abs$9(totalRadian / PI_2));
2524
2524
  const partRadian = totalRadian / parts;
2525
2525
  const partRadian4Sin = sin$4(partRadian / 4);
2526
2526
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -2534,7 +2534,7 @@ var LeaferUI = function(exports) {
2534
2534
  let fromX = cx + x, fromY = cy + y;
2535
2535
  if (data) data.push(data.length ? L$a : M$a, fromX, fromY);
2536
2536
  if (setPointBounds) setPoint$4(setPointBounds, fromX, fromY);
2537
- if (setStartPoint) set(setStartPoint, fromX, fromY);
2537
+ if (setStartPoint) set$1(setStartPoint, fromX, fromY);
2538
2538
  for (let i = 0; i < parts; i++) {
2539
2539
  endCos = cos$4(endRadian);
2540
2540
  endSin = sin$4(endRadian);
@@ -2553,7 +2553,7 @@ var LeaferUI = function(exports) {
2553
2553
  startRadian = endRadian;
2554
2554
  endRadian += partRadian;
2555
2555
  }
2556
- if (setEndPoint) set(setEndPoint, cx + x, cy + y);
2556
+ if (setEndPoint) set$1(setEndPoint, cx + x, cy + y);
2557
2557
  },
2558
2558
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2559
2559
  data.push(C$8, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
@@ -2973,7 +2973,7 @@ var LeaferUI = function(exports) {
2973
2973
  const {current: current, pushData: pushData, copyData: copyData} = PathConvert;
2974
2974
  const {M: M$8, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4} = PathCommandMap;
2975
2975
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
2976
- const {tan: tan, min: min, abs: abs$5} = Math;
2976
+ const {tan: tan, min: min$1, abs: abs$8} = Math;
2977
2977
  const startPoint = {};
2978
2978
  const PathCommandDataHelper = {
2979
2979
  beginPath(data) {
@@ -3029,7 +3029,7 @@ var LeaferUI = function(exports) {
3029
3029
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3030
3030
  if (!isUndefined(lastX)) {
3031
3031
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3032
- radius = min(radius, min(d / 2, d / 2 * abs$5(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3032
+ radius = min$1(radius, min$1(d / 2, d / 2 * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3033
3033
  }
3034
3034
  data.push(U$4, x1, y1, x2, y2, radius);
3035
3035
  },
@@ -3611,7 +3611,12 @@ var LeaferUI = function(exports) {
3611
3611
  runTask() {
3612
3612
  const task = this.list[this.index];
3613
3613
  if (!task) {
3614
- this.nextTask();
3614
+ this.timer = setTimeout(() => this.nextTask());
3615
+ return;
3616
+ }
3617
+ if (task.isCancel) {
3618
+ this.index++;
3619
+ this.runTask();
3615
3620
  return;
3616
3621
  }
3617
3622
  task.run().then(() => {
@@ -3642,16 +3647,15 @@ var LeaferUI = function(exports) {
3642
3647
  }
3643
3648
  setParallelList() {
3644
3649
  let task;
3650
+ const {config: config, list: list, index: index} = this;
3645
3651
  this.parallelList = [];
3646
3652
  this.parallelSuccessNumber = 0;
3647
- let end = this.index + this.config.parallel;
3648
- if (end > this.list.length) end = this.list.length;
3649
- for (let i = this.index; i < end; i++) {
3650
- task = this.list[i];
3651
- if (task.parallel) {
3652
- this.parallelList.push(task);
3653
- } else {
3654
- break;
3653
+ let end = index + config.parallel;
3654
+ if (end > list.length) end = list.length;
3655
+ if (config.parallel > 1) {
3656
+ for (let i = index; i < end; i++) {
3657
+ task = list[i];
3658
+ if (task.parallel) this.parallelList.push(task); else break;
3655
3659
  }
3656
3660
  }
3657
3661
  }
@@ -3787,7 +3791,7 @@ var LeaferUI = function(exports) {
3787
3791
  };
3788
3792
  const I$1 = ImageManager;
3789
3793
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3790
- const {floor: floor$2, max: max$4} = Math;
3794
+ const {floor: floor$2, max: max$5} = Math;
3791
3795
  class LeaferImage {
3792
3796
  get url() {
3793
3797
  return this.config.url;
@@ -3875,7 +3879,7 @@ var LeaferUI = function(exports) {
3875
3879
  }
3876
3880
  if (data) return data;
3877
3881
  }
3878
- const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
3882
+ const canvas = Platform.origin.createCanvas(max$5(floor$2(width + (xGap || 0)), 1), max$5(floor$2(height + (yGap || 0)), 1));
3879
3883
  const ctx = canvas.getContext("2d");
3880
3884
  if (opacity) ctx.globalAlpha = opacity;
3881
3885
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
@@ -6409,7 +6413,7 @@ var LeaferUI = function(exports) {
6409
6413
  this.levelMap = null;
6410
6414
  }
6411
6415
  }
6412
- const version = "1.9.9";
6416
+ const version = "1.9.11";
6413
6417
  class LeaferCanvas extends LeaferCanvasBase {
6414
6418
  get allowBackgroundColor() {
6415
6419
  return true;
@@ -7045,7 +7049,7 @@ var LeaferUI = function(exports) {
7045
7049
  children: [ target ]
7046
7050
  } : target);
7047
7051
  const {list: list} = this.findList;
7048
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
7052
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
7049
7053
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
7050
7054
  this.clear();
7051
7055
  return through ? {
@@ -7060,7 +7064,7 @@ var LeaferUI = function(exports) {
7060
7064
  hitPoint(hitPoint, hitRadius, options) {
7061
7065
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
7062
7066
  }
7063
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
7067
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
7064
7068
  const findList = this.findList = new LeafList;
7065
7069
  if (list.length) {
7066
7070
  let find;
@@ -7091,15 +7095,27 @@ var LeaferUI = function(exports) {
7091
7095
  if (findList.length) return findList.list[0];
7092
7096
  }
7093
7097
  }
7098
+ if (allowNull) return null;
7094
7099
  return ignoreHittable ? list[0] : list.find(item => LeafHelper.worldHittable(item));
7095
7100
  }
7096
7101
  getPath(leaf) {
7097
- const path = new LeafList;
7102
+ const path = new LeafList, syncList = [], {target: target} = this;
7098
7103
  while (leaf) {
7104
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
7099
7105
  path.add(leaf);
7100
7106
  leaf = leaf.parent;
7107
+ if (leaf === target) break;
7108
+ }
7109
+ if (syncList.length) {
7110
+ syncList.forEach(item => {
7111
+ while (item) {
7112
+ if (item.__.hittable) path.add(item);
7113
+ item = item.parent;
7114
+ if (item === target) break;
7115
+ }
7116
+ });
7101
7117
  }
7102
- if (this.target) path.add(this.target);
7118
+ if (target) path.add(target);
7103
7119
  return path;
7104
7120
  }
7105
7121
  getHitablePath(leaf) {
@@ -7556,12 +7572,12 @@ var LeaferUI = function(exports) {
7556
7572
  }
7557
7573
  __getData() {
7558
7574
  const data = super.__getData();
7559
- delete data.fill;
7575
+ if (data.url) delete data.fill;
7560
7576
  return data;
7561
7577
  }
7562
7578
  __getInputData(names, options) {
7563
7579
  const data = super.__getInputData(names, options);
7564
- delete data.fill;
7580
+ if (data.url) delete data.fill;
7565
7581
  return data;
7566
7582
  }
7567
7583
  }
@@ -7578,7 +7594,7 @@ var LeaferUI = function(exports) {
7578
7594
  return data;
7579
7595
  }
7580
7596
  }
7581
- const {max: max$3, add: add$1} = FourNumberHelper;
7597
+ const {max: max$4, add: add$1} = FourNumberHelper;
7582
7598
  const UIBounds = {
7583
7599
  __updateStrokeSpread() {
7584
7600
  let spread = 0, boxSpread = 0;
@@ -7593,7 +7609,7 @@ var LeaferUI = function(exports) {
7593
7609
  }
7594
7610
  if (data.__useArrow) spread += strokeWidth * 5;
7595
7611
  if (box) {
7596
- spread = max$3(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7612
+ spread = max$4(spread, box.__layout.strokeSpread = box.__updateStrokeSpread());
7597
7613
  boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread);
7598
7614
  }
7599
7615
  this.__layout.strokeBoxSpread = boxSpread;
@@ -7603,81 +7619,17 @@ var LeaferUI = function(exports) {
7603
7619
  let spread = 0;
7604
7620
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__, {strokeSpread: strokeSpread} = this.__layout, box = this.__box;
7605
7621
  if (shadow) spread = Effect.getShadowRenderSpread(this, shadow);
7606
- if (blur) spread = max$3(spread, blur);
7622
+ if (blur) spread = max$4(spread, blur);
7607
7623
  if (filter) spread = add$1(spread, Filter.getSpread(filter));
7608
7624
  if (renderSpread) spread = add$1(spread, renderSpread);
7609
7625
  if (strokeSpread) spread = add$1(spread, strokeSpread);
7610
7626
  let shapeSpread = spread;
7611
- if (innerShadow) shapeSpread = max$3(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7612
- if (backgroundBlur) shapeSpread = max$3(shapeSpread, backgroundBlur);
7627
+ if (innerShadow) shapeSpread = max$4(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow));
7628
+ if (backgroundBlur) shapeSpread = max$4(shapeSpread, backgroundBlur);
7613
7629
  this.__layout.renderShapeSpread = shapeSpread;
7614
- return box ? max$3(box.__updateRenderSpread(), spread) : spread;
7615
- }
7616
- };
7617
- const {float: float$1} = MathHelper;
7618
- const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7619
- const DragBoundsHelper = {
7620
- limitMove(leaf, move) {
7621
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7622
- if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, move, true);
7623
- D$2.axisMove(leaf, move);
7624
- },
7625
- limitScaleOf(leaf, origin, scale) {
7626
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7627
- if (dragBounds) D$2.getValidScaleOf(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7628
- },
7629
- axisMove(leaf, move) {
7630
- const {draggable: draggable} = leaf;
7631
- if (draggable === "x") move.y = 0;
7632
- if (draggable === "y") move.x = 0;
7633
- },
7634
- getDragBounds(leaf) {
7635
- const {dragBounds: dragBounds} = leaf;
7636
- return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7637
- },
7638
- isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7639
- return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7640
- },
7641
- getValidMove(content, dragBounds, dragBoundsType, move, change) {
7642
- const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7643
- const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7644
- if (!change) move = Object.assign({}, move);
7645
- if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7646
- if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7647
- } else {
7648
- if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7649
- }
7650
- if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7651
- if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7652
- } else {
7653
- if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7654
- }
7655
- move.x = float$1(move.x);
7656
- move.y = float$1(move.y);
7657
- return move;
7658
- },
7659
- getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7660
- if (!change) scale = Object.assign({}, scale);
7661
- let fitScaleX, fitScaleY;
7662
- tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7663
- tempMerge.set(tempContent).add(dragBounds);
7664
- tempIntersect.set(tempContent).intersect(dragBounds);
7665
- if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7666
- fitScaleX = tempMerge.width / tempContent.width;
7667
- } else {
7668
- fitScaleX = tempIntersect.width / tempContent.width;
7669
- }
7670
- if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7671
- fitScaleY = tempMerge.height / tempContent.height;
7672
- } else {
7673
- fitScaleY = tempIntersect.height / tempContent.height;
7674
- }
7675
- scale.x = float$1(tempIntersect.width) ? scale.x * fitScaleX : 1;
7676
- scale.y = float$1(tempIntersect.height) ? scale.y * fitScaleY : 1;
7677
- return scale;
7630
+ return box ? max$4(box.__updateRenderSpread(), spread) : spread;
7678
7631
  }
7679
7632
  };
7680
- const D$2 = DragBoundsHelper;
7681
7633
  const {stintSet: stintSet$1} = DataHelper;
7682
7634
  const UIRender = {
7683
7635
  __updateChange() {
@@ -9134,6 +9086,102 @@ var LeaferUI = function(exports) {
9134
9086
  EventCreator.changeName(oldName, newName);
9135
9087
  }
9136
9088
  }
9089
+ const {min: min, max: max$3, abs: abs$7} = Math, {float: float$1, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9090
+ const tempContent = new Bounds, tempDragBounds = new Bounds;
9091
+ const DragBoundsHelper = {
9092
+ limitMove(leaf, move) {
9093
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
9094
+ if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, move, true);
9095
+ D$2.axisMove(leaf, move);
9096
+ },
9097
+ limitScaleOf(leaf, origin, scale, lockRatio) {
9098
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
9099
+ if (dragBounds) D$2.getValidScaleOf(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, lockRatio, true);
9100
+ },
9101
+ axisMove(leaf, move) {
9102
+ const {draggable: draggable} = leaf;
9103
+ if (draggable === "x") move.y = 0;
9104
+ if (draggable === "y") move.x = 0;
9105
+ },
9106
+ getDragBounds(leaf) {
9107
+ const {dragBounds: dragBounds} = leaf;
9108
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
9109
+ },
9110
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
9111
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
9112
+ },
9113
+ getValidMove(content, dragBounds, dragBoundsType, move, change) {
9114
+ const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
9115
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9116
+ if (!change) move = Object.assign({}, move);
9117
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9118
+ if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
9119
+ } else {
9120
+ if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
9121
+ }
9122
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9123
+ if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
9124
+ } else {
9125
+ if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
9126
+ }
9127
+ move.x = float$1(move.x);
9128
+ move.y = float$1(move.y);
9129
+ return move;
9130
+ },
9131
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
9132
+ if (!change) scale = Object.assign({}, scale);
9133
+ tempDragBounds.set(dragBounds);
9134
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y);
9135
+ const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
9136
+ const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
9137
+ let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9138
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9139
+ if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9140
+ aSize = float$1(tempContent.minX - tempDragBounds.minX);
9141
+ bSize = float$1(tempDragBounds.maxX - tempContent.maxX);
9142
+ aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9143
+ bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9144
+ correctScaleX *= max$3(aScale, bScale);
9145
+ } else {
9146
+ if (scale.x < 0) {
9147
+ if (float$1(minX(content) - minX(dragBounds)) <= 0 || float$1(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9148
+ tempContent.unsign();
9149
+ }
9150
+ aSize = float$1(tempDragBounds.minX - tempContent.minX);
9151
+ bSize = float$1(tempContent.maxX - tempDragBounds.maxX);
9152
+ aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
9153
+ bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
9154
+ correctScaleX *= min(aScale, bScale);
9155
+ }
9156
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9157
+ if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9158
+ aSize = float$1(tempContent.minY - tempDragBounds.minY);
9159
+ bSize = float$1(tempDragBounds.maxY - tempContent.maxY);
9160
+ aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
9161
+ bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
9162
+ correctScaleY *= max$3(aScale, bScale);
9163
+ if (lockRatio) {
9164
+ aScale = max$3(abs$7(correctScaleX), abs$7(correctScaleY));
9165
+ correctScaleX = sign$2(correctScaleX) * aScale;
9166
+ correctScaleY = sign$2(correctScaleY) * aScale;
9167
+ }
9168
+ } else {
9169
+ if (scale.y < 0) {
9170
+ if (float$1(minY(content) - minY(dragBounds)) <= 0 || float$1(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9171
+ tempContent.unsign();
9172
+ }
9173
+ aSize = float$1(tempDragBounds.minY - tempContent.minY);
9174
+ bSize = float$1(tempContent.maxY - tempDragBounds.maxY);
9175
+ aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
9176
+ bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
9177
+ correctScaleY *= min(aScale, bScale);
9178
+ }
9179
+ scale.x *= isFinite(correctScaleX) ? correctScaleX : 1;
9180
+ scale.y *= isFinite(correctScaleY) ? correctScaleY : 1;
9181
+ return scale;
9182
+ }
9183
+ };
9184
+ const D$2 = DragBoundsHelper;
9137
9185
  exports.PointerEvent = class PointerEvent extends UIEvent {};
9138
9186
  exports.PointerEvent.POINTER = "pointer";
9139
9187
  exports.PointerEvent.BEFORE_DOWN = "pointer.before_down";
@@ -10105,9 +10153,9 @@ var LeaferUI = function(exports) {
10105
10153
  const ui$5 = exports.UI.prototype;
10106
10154
  ui$5.__updateHitCanvas = function() {
10107
10155
  if (this.__box) this.__box.__updateHitCanvas();
10108
- const leafer = this.leafer || this.parent && this.parent.leafer;
10109
- if (!leafer) return;
10110
- const data = this.__, {hitCanvasManager: hitCanvasManager} = leafer;
10156
+ const {hitCanvasManager: hitCanvasManager} = this.leafer || this.parent && this.parent.leafer || {};
10157
+ if (!hitCanvasManager) return;
10158
+ const data = this.__;
10111
10159
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === "pixel";
10112
10160
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === "pixel";
10113
10161
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10545,7 +10593,13 @@ var LeaferUI = function(exports) {
10545
10593
  shape: shape
10546
10594
  };
10547
10595
  let origin$1 = {}, tempMatrix$1 = getMatrixData();
10548
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
10596
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
10597
+ function stretchMode(data, box, scaleX, scaleY) {
10598
+ const transform = get$3();
10599
+ translate$1(transform, box.x, box.y);
10600
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
10601
+ data.transform = transform;
10602
+ }
10549
10603
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10550
10604
  const transform = get$3();
10551
10605
  translate$1(transform, box.x + x, box.y + y);
@@ -10560,8 +10614,11 @@ var LeaferUI = function(exports) {
10560
10614
  const transform = get$3();
10561
10615
  layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew);
10562
10616
  if (clipScaleX) {
10563
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
10564
- multiplyParent(transform, tempMatrix$1);
10617
+ if (rotation || skew) {
10618
+ set(tempMatrix$1);
10619
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
10620
+ multiplyParent(transform, tempMatrix$1);
10621
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
10565
10622
  }
10566
10623
  data.transform = transform;
10567
10624
  }
@@ -10649,7 +10706,10 @@ var LeaferUI = function(exports) {
10649
10706
  if (offset) PointHelper.move(tempImage, offset);
10650
10707
  switch (mode) {
10651
10708
  case "stretch":
10652
- if (!sameBox) width = box.width, height = box.height;
10709
+ if (!sameBox) {
10710
+ scaleX = box.width / width, scaleY = box.height / height;
10711
+ stretchMode(data, box, scaleX, scaleY);
10712
+ }
10653
10713
  break;
10654
10714
 
10655
10715
  case "normal":
@@ -10658,7 +10718,7 @@ var LeaferUI = function(exports) {
10658
10718
  let clipScaleX, clipScaleY;
10659
10719
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
10660
10720
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
10661
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10721
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
10662
10722
  }
10663
10723
  break;
10664
10724
 
@@ -10675,17 +10735,14 @@ var LeaferUI = function(exports) {
10675
10735
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10676
10736
  }
10677
10737
  if (!data.transform) {
10678
- if (box.x || box.y) {
10679
- data.transform = get$2();
10680
- translate(data.transform, box.x, box.y);
10681
- }
10738
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
10682
10739
  }
10683
- if (scaleX && mode !== "stretch") {
10740
+ data.width = width;
10741
+ data.height = height;
10742
+ if (scaleX) {
10684
10743
  data.scaleX = scaleX;
10685
10744
  data.scaleY = scaleY;
10686
10745
  }
10687
- data.width = width;
10688
- data.height = height;
10689
10746
  if (opacity) data.opacity = opacity;
10690
10747
  if (filters) data.filters = filters;
10691
10748
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -10804,7 +10861,7 @@ var LeaferUI = function(exports) {
10804
10861
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
10805
10862
  }
10806
10863
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
10807
- const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$4} = Math;
10864
+ const {floor: floor$1, ceil: ceil$1, max: max$2, abs: abs$6} = Math;
10808
10865
  function createPattern(ui, paint, pixelRatio) {
10809
10866
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
10810
10867
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -10814,8 +10871,8 @@ var LeaferUI = function(exports) {
10814
10871
  scaleX *= pixelRatio;
10815
10872
  scaleY *= pixelRatio;
10816
10873
  if (sx) {
10817
- sx = abs$4(sx);
10818
- sy = abs$4(sy);
10874
+ sx = abs$6(sx);
10875
+ sy = abs$6(sy);
10819
10876
  imageMatrix = get$1();
10820
10877
  copy$4(imageMatrix, transform);
10821
10878
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -10953,6 +11010,7 @@ var LeaferUI = function(exports) {
10953
11010
  recycleImage: recycleImage,
10954
11011
  createData: createData,
10955
11012
  getPatternData: getPatternData,
11013
+ stretchMode: stretchMode,
10956
11014
  fillOrFitMode: fillOrFitMode,
10957
11015
  clipMode: clipMode,
10958
11016
  repeatMode: repeatMode
@@ -11044,7 +11102,7 @@ var LeaferUI = function(exports) {
11044
11102
  conicGradient: conicGradient,
11045
11103
  getTransform: getTransform
11046
11104
  };
11047
- const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$1} = Math;
11105
+ const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$1, abs: abs$5} = Math;
11048
11106
  const tempBounds = {}, tempMatrix = new Matrix;
11049
11107
  const offsetOutBounds$1 = {};
11050
11108
  function shadow$1(ui, current, shape) {
@@ -11084,7 +11142,7 @@ var LeaferUI = function(exports) {
11084
11142
  function getShadowRenderSpread(_ui, shadow) {
11085
11143
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
11086
11144
  shadow.forEach(item => {
11087
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
11145
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs$5(item.spread || 0);
11088
11146
  top = max$1(top, spread + blur - y);
11089
11147
  right = max$1(right, spread + blur + x);
11090
11148
  bottom = max$1(bottom, spread + blur + y);
@@ -11094,11 +11152,11 @@ var LeaferUI = function(exports) {
11094
11152
  }
11095
11153
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11096
11154
  if (shadow.spread) {
11097
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11155
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
11098
11156
  tempMatrix.set().scaleOfOuter({
11099
11157
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11100
11158
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11101
- }, spreadScale);
11159
+ }, 1 + spread / width, 1 + spread / height);
11102
11160
  return tempMatrix;
11103
11161
  }
11104
11162
  return undefined;
@@ -11776,7 +11834,10 @@ var LeaferUI = function(exports) {
11776
11834
  t.setDimOthers(false);
11777
11835
  t.setBright(false);
11778
11836
  if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
11779
- if (t.single) t.element.syncEventer = null;
11837
+ if (t.single) {
11838
+ delete t.element.syncEventer;
11839
+ delete t.element.__world.ignorePixelSnap;
11840
+ }
11780
11841
  }
11781
11842
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11782
11843
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
@@ -11796,7 +11857,15 @@ var LeaferUI = function(exports) {
11796
11857
  defineKey(target, key, {
11797
11858
  get() {
11798
11859
  const {config: config, element: element, dragPoint: dragPoint, editBox: editBox, app: app} = this, mergeConfig = Object.assign({}, config);
11799
- if (element && element.editConfig) Object.assign(mergeConfig, element.editConfig);
11860
+ if (element && element.editConfig) {
11861
+ let {editConfig: editConfig} = element;
11862
+ if (editConfig.hover || editConfig.hoverStyle) {
11863
+ editConfig = Object.assign({}, editConfig);
11864
+ delete editConfig.hover;
11865
+ delete editConfig.hoverStyle;
11866
+ }
11867
+ Object.assign(mergeConfig, editConfig);
11868
+ }
11800
11869
  if (editBox.config) Object.assign(mergeConfig, editBox.config);
11801
11870
  if (dragPoint) {
11802
11871
  if (dragPoint.editConfig) Object.assign(mergeConfig, dragPoint.editConfig);
@@ -11812,7 +11881,7 @@ var LeaferUI = function(exports) {
11812
11881
  });
11813
11882
  };
11814
11883
  }
11815
- const {abs: abs$3} = Math;
11884
+ const {abs: abs$4} = Math;
11816
11885
  const {copy: copy$2, scale: scale$1} = MatrixHelper;
11817
11886
  const {setListWithFn: setListWithFn} = BoundsHelper;
11818
11887
  const {worldBounds: worldBounds} = LeafBoundsHelper;
@@ -11849,7 +11918,7 @@ var LeaferUI = function(exports) {
11849
11918
  leaf = list[i];
11850
11919
  const {worldTransform: worldTransform, worldRenderBounds: worldRenderBounds} = leaf;
11851
11920
  if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
11852
- const aScaleX = abs$3(worldTransform.scaleX), aScaleY = abs$3(worldTransform.scaleY);
11921
+ const aScaleX = abs$4(worldTransform.scaleX), aScaleY = abs$4(worldTransform.scaleY);
11853
11922
  copy$2(matrix$1, worldTransform);
11854
11923
  matrix$1.half = strokeWidth % 2;
11855
11924
  if (aScaleX !== aScaleY) {
@@ -11863,7 +11932,7 @@ var LeaferUI = function(exports) {
11863
11932
  canvas.setWorld(matrix$1, options.matrix);
11864
11933
  canvas.beginPath();
11865
11934
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
11866
- data.strokeWidth = strokeWidth / abs$3(worldTransform.scaleX);
11935
+ data.strokeWidth = strokeWidth / abs$4(worldTransform.scaleX);
11867
11936
  }
11868
11937
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
11869
11938
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
@@ -11968,8 +12037,10 @@ var LeaferUI = function(exports) {
11968
12037
  onHover() {
11969
12038
  const {editor: editor} = this;
11970
12039
  if (this.running && !this.dragging && !editor.dragging) {
11971
- const {stroke: stroke, strokeWidth: strokeWidth, hover: hover, hoverStyle: hoverStyle} = editor.mergeConfig;
11972
- this.hoverStroker.setTarget(hover ? this.editor.hoverTarget : null, Object.assign({
12040
+ const {hoverTarget: hoverTarget, mergeConfig: mergeConfig} = editor, config = Object.assign({}, mergeConfig);
12041
+ if (hoverTarget && hoverTarget.editConfig) Object.assign(config, hoverTarget.editConfig);
12042
+ const {stroke: stroke, strokeWidth: strokeWidth, hover: hover, hoverStyle: hoverStyle} = config;
12043
+ this.hoverStroker.setTarget(hover ? hoverTarget : null, Object.assign({
11973
12044
  stroke: stroke,
11974
12045
  strokeWidth: strokeWidth
11975
12046
  }, hoverStyle || {}));
@@ -12147,11 +12218,10 @@ var LeaferUI = function(exports) {
12147
12218
  }
12148
12219
  }
12149
12220
  const {topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottomRight: bottomRight, bottom: bottom$1, bottomLeft: bottomLeft, left: left$2} = exports.Direction9;
12150
- const {toPoint: toPoint} = AroundHelper;
12151
- const {within: within$3, sign: sign$1} = MathHelper;
12221
+ const {toPoint: toPoint} = AroundHelper, {within: within$3, sign: sign$1} = MathHelper, {abs: abs$3} = Math;
12152
12222
  const EditDataHelper = {
12153
12223
  getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
12154
- let align, origin = {}, scaleX = 1, scaleY = 1;
12224
+ let align, origin = {}, scaleX = 1, scaleY = 1, lockScale;
12155
12225
  const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
12156
12226
  const {width: width, height: height} = startBounds;
12157
12227
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
@@ -12221,23 +12291,22 @@ var LeaferUI = function(exports) {
12221
12291
  if (lockRatio === "corner" && direction % 2) {
12222
12292
  lockRatio = false;
12223
12293
  } else {
12224
- let scale;
12225
12294
  switch (direction) {
12226
12295
  case top$1:
12227
12296
  case bottom$1:
12228
- scale = scaleY;
12297
+ scaleX = scaleY;
12229
12298
  break;
12230
12299
 
12231
12300
  case left$2:
12232
12301
  case right$2:
12233
- scale = scaleX;
12302
+ scaleY = scaleX;
12234
12303
  break;
12235
12304
 
12236
12305
  default:
12237
- scale = Math.sqrt(Math.abs(scaleX * scaleY));
12306
+ lockScale = Math.sqrt(abs$3(scaleX * scaleY));
12307
+ scaleX = sign$1(scaleX) * lockScale;
12308
+ scaleY = sign$1(scaleY) * lockScale;
12238
12309
  }
12239
- scaleX = scaleX < 0 ? -scale : scale;
12240
- scaleY = scaleY < 0 ? -scale : scale;
12241
12310
  }
12242
12311
  }
12243
12312
  }
@@ -12255,7 +12324,7 @@ var LeaferUI = function(exports) {
12255
12324
  x: scaleX,
12256
12325
  y: scaleY
12257
12326
  };
12258
- DragBoundsHelper.limitScaleOf(target, origin, scaleData);
12327
+ DragBoundsHelper.limitScaleOf(target, origin, scaleData, lockRatio);
12259
12328
  scaleX = scaleData.x;
12260
12329
  scaleY = scaleData.y;
12261
12330
  }
@@ -12267,9 +12336,13 @@ var LeaferUI = function(exports) {
12267
12336
  const nowHeight = boxBounds.height * target.scaleY;
12268
12337
  scaleY = within$3(nowHeight * scaleY, heightRange) / nowHeight;
12269
12338
  }
12270
- if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = sign$1(scaleX) / worldBoxBounds.width;
12271
- if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = sign$1(scaleY) / worldBoxBounds.height;
12272
- if (lockRatio && scaleX !== scaleY) scaleY = scaleX = Math.min(scaleX, scaleY);
12339
+ if (useScaleX && abs$3(scaleX * worldBoxBounds.width) < 1) scaleX = sign$1(scaleX) / worldBoxBounds.width;
12340
+ if (useScaleY && abs$3(scaleY * worldBoxBounds.height) < 1) scaleY = sign$1(scaleY) / worldBoxBounds.height;
12341
+ if (lockRatio && scaleX !== scaleY) {
12342
+ lockScale = Math.min(abs$3(scaleX), abs$3(scaleY));
12343
+ scaleX = sign$1(scaleX) * lockScale;
12344
+ scaleY = sign$1(scaleY) * lockScale;
12345
+ }
12273
12346
  return {
12274
12347
  origin: origin,
12275
12348
  scaleX: scaleX,
@@ -12512,7 +12585,7 @@ var LeaferUI = function(exports) {
12512
12585
  return this.scaleX * this.scaleY < 0;
12513
12586
  }
12514
12587
  get canUse() {
12515
- return this.visible && this.view.visible;
12588
+ return this.app && this.editor.editing;
12516
12589
  }
12517
12590
  get canGesture() {
12518
12591
  if (!this.canUse) return false;
@@ -12593,7 +12666,7 @@ var LeaferUI = function(exports) {
12593
12666
  }
12594
12667
  load() {
12595
12668
  const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
12596
- const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine} = mergeConfig;
12669
+ const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
12597
12670
  const pointsStyle = this.getPointsStyle();
12598
12671
  const middlePointsStyle = this.getMiddlePointsStyle();
12599
12672
  this.visible = !target.locked;
@@ -12613,16 +12686,16 @@ var LeaferUI = function(exports) {
12613
12686
  strokeWidth: strokeWidth,
12614
12687
  editConfig: editConfig
12615
12688
  }, mergeConfig.rect || {}));
12616
- const syncEventer = single && this.transformTool.editTool;
12617
- rect.hittable = !syncEventer;
12618
- rect.syncEventer = syncEventer && this.editor;
12619
- if (syncEventer) {
12689
+ const rectThrough = isNull(mergeConfig.rectThrough) ? single : mergeConfig.rectThrough;
12690
+ rect.hittable = !rectThrough;
12691
+ if (rectThrough) {
12620
12692
  target.syncEventer = rect;
12621
12693
  this.app.interaction.bottomList = [ {
12622
12694
  target: rect,
12623
12695
  proxy: target
12624
12696
  } ];
12625
12697
  }
12698
+ if (single) DataHelper.stintSet(target.__world, "ignorePixelSnap", ignorePixelSnap);
12626
12699
  updateMoveCursor(this);
12627
12700
  }
12628
12701
  update() {
@@ -12786,29 +12859,25 @@ var LeaferUI = function(exports) {
12786
12859
  this.dragPoint = null;
12787
12860
  }
12788
12861
  onTransformStart(e) {
12789
- if (this.canUse) {
12790
- if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
12791
- if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
12792
- const {dragStartData: dragStartData, target: target} = this;
12793
- dragStartData.x = e.x;
12794
- dragStartData.y = e.y;
12795
- dragStartData.totalOffset = getPointData();
12796
- dragStartData.point = {
12797
- x: target.x,
12798
- y: target.y
12799
- };
12800
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12801
- dragStartData.rotation = target.rotation;
12802
- }
12862
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
12863
+ if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
12864
+ const {dragStartData: dragStartData, target: target} = this;
12865
+ dragStartData.x = e.x;
12866
+ dragStartData.y = e.y;
12867
+ dragStartData.totalOffset = getPointData();
12868
+ dragStartData.point = {
12869
+ x: target.x,
12870
+ y: target.y
12871
+ };
12872
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12873
+ dragStartData.rotation = target.rotation;
12803
12874
  }
12804
12875
  onTransformEnd(e) {
12805
- if (this.canUse) {
12806
- if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
12807
- if (this.resizing) ResizeEvent.resizingKeys = null;
12808
- this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12809
- this.editor.opacity = 1;
12810
- this.update();
12811
- }
12876
+ if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
12877
+ if (this.resizing) ResizeEvent.resizingKeys = null;
12878
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12879
+ this.editor.opacity = 1;
12880
+ this.editor.update();
12812
12881
  }
12813
12882
  onMove(e) {
12814
12883
  if (this.canGesture && e.moveType !== "drag") {
@@ -12837,6 +12906,12 @@ var LeaferUI = function(exports) {
12837
12906
  }
12838
12907
  }
12839
12908
  }
12909
+ onGestureStart(e) {
12910
+ if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
12911
+ }
12912
+ onGestureEnd(e) {
12913
+ if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
12914
+ }
12840
12915
  isHoldRotateKey(e) {
12841
12916
  const {rotateKey: rotateKey} = this.mergedConfig;
12842
12917
  if (rotateKey) return e.isHoldKeys(rotateKey);
@@ -12906,7 +12981,7 @@ var LeaferUI = function(exports) {
12906
12981
  const {rect: rect, editor: editor, __eventIds: events} = this;
12907
12982
  events.push(rect.on_([ [ exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ exports.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
12908
12983
  this.waitLeafer(() => {
12909
- events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ [ exports.MoveEvent.START, exports.MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ exports.ZoomEvent.START, exports.ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ exports.RotateEvent.START, exports.RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onTransformEnd, this ] ]));
12984
+ events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ [ exports.MoveEvent.START, exports.ZoomEvent.START, exports.RotateEvent.START ], this.onGestureStart, this ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onGestureEnd, this ] ]));
12910
12985
  });
12911
12986
  }
12912
12987
  __removeListenEvents() {
@@ -15195,6 +15270,68 @@ var LeaferUI = function(exports) {
15195
15270
  this.__htmlChanged = true;
15196
15271
  }
15197
15272
  }
15273
+ const unicodeEntities = {
15274
+ lt: "<",
15275
+ gt: ">",
15276
+ amp: "&",
15277
+ quot: '"',
15278
+ apos: "'",
15279
+ nbsp: " ",
15280
+ ensp: " ",
15281
+ emsp: " ",
15282
+ thinsp: " ",
15283
+ ndash: "–",
15284
+ mdash: "—",
15285
+ hellip: "…",
15286
+ middot: "·",
15287
+ bull: "•",
15288
+ laquo: "«",
15289
+ raquo: "»",
15290
+ lsquo: "‘",
15291
+ rsquo: "’",
15292
+ ldquo: "“",
15293
+ rdquo: "”",
15294
+ cent: "¢",
15295
+ pound: "£",
15296
+ yen: "¥",
15297
+ euro: "€",
15298
+ times: "×",
15299
+ divide: "÷",
15300
+ plusmn: "±",
15301
+ minus: "−",
15302
+ frac12: "½",
15303
+ frac14: "¼",
15304
+ frac34: "¾",
15305
+ sup2: "²",
15306
+ sup3: "³",
15307
+ deg: "°",
15308
+ reg: "®",
15309
+ copy: "©",
15310
+ trade: "™",
15311
+ section: "§",
15312
+ para: "¶",
15313
+ dagger: "†",
15314
+ Dagger: "‡",
15315
+ larr: "←",
15316
+ uarr: "↑",
15317
+ rarr: "→",
15318
+ darr: "↓",
15319
+ harr: "↔",
15320
+ alpha: "α",
15321
+ beta: "β",
15322
+ gamma: "γ",
15323
+ delta: "δ",
15324
+ pi: "π",
15325
+ sigma: "σ",
15326
+ omega: "ω",
15327
+ Omega: "Ω",
15328
+ micro: "µ",
15329
+ infinity: "∞",
15330
+ not: "¬",
15331
+ equiv: "≡",
15332
+ le: "≤",
15333
+ ge: "≥"
15334
+ };
15198
15335
  exports.HTMLText = class HTMLText extends exports.Image {
15199
15336
  get __tag() {
15200
15337
  return "HTMLText";
@@ -15214,7 +15351,7 @@ var LeaferUI = function(exports) {
15214
15351
  document.body.appendChild(div);
15215
15352
  const {width: width, height: height} = div.getBoundingClientRect();
15216
15353
  const realWidth = width + 10;
15217
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${realWidth}" height="${height}">\n <foreignObject width="${realWidth}" height="${height}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;
15354
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${realWidth}" height="${height}">\n <foreignObject width="${realWidth}" height="${height}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.decodeText(this.text)}\n </body>\n </foreignObject>\n </svg>`;
15218
15355
  data.__setImageFill("data:image/svg+xml," + encodeURIComponent(svg));
15219
15356
  data.__naturalWidth = realWidth / data.pixelRatio;
15220
15357
  data.__naturalHeight = height / data.pixelRatio;
@@ -15227,6 +15364,29 @@ var LeaferUI = function(exports) {
15227
15364
  if (this.textEditing && !options.exporting) return;
15228
15365
  super.__draw(canvas, options, originCanvas);
15229
15366
  }
15367
+ decodeText(text) {
15368
+ if (!text.includes("&")) return text;
15369
+ let result = "", i = 0, entity, value;
15370
+ while (i < text.length) {
15371
+ if (text[i] === "&") {
15372
+ const semicolonIndex = text.indexOf(";", i + 1);
15373
+ if (semicolonIndex > i + 1) {
15374
+ entity = text.slice(i + 1, semicolonIndex);
15375
+ value = unicodeEntities[entity];
15376
+ if (value !== undefined) {
15377
+ result += value;
15378
+ i = semicolonIndex + 1;
15379
+ continue;
15380
+ }
15381
+ }
15382
+ }
15383
+ result += text[i++];
15384
+ }
15385
+ return result;
15386
+ }
15387
+ static addUnicodeEntity(entity, unicode) {
15388
+ if (isString(entity)) unicodeEntities[entity] = unicode; else Object.assign(unicodeEntities, entity);
15389
+ }
15230
15390
  };
15231
15391
  __decorate([ dataProcessor(HTMLTextData) ], exports.HTMLText.prototype, "__", void 0);
15232
15392
  __decorate([ boundsType("") ], exports.HTMLText.prototype, "text", void 0);