@leafer/worker 1.9.4 → 1.9.6

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.
@@ -136,6 +136,9 @@ class LeafData {
136
136
  const {path: path} = this;
137
137
  return path && path.length === 6 && path[0] === 1;
138
138
  }
139
+ get __usePathBox() {
140
+ return this.__pathInputed;
141
+ }
139
142
  get __blendMode() {
140
143
  if (this.eraser && this.eraser !== "path") return "destination-out";
141
144
  const {blendMode: blendMode} = this;
@@ -369,7 +372,7 @@ function getMatrixData() {
369
372
 
370
373
  const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
371
374
 
372
- const {float: float$2} = MathHelper;
375
+ const {float: float$3} = MathHelper;
373
376
 
374
377
  const tempPoint$4 = {};
375
378
 
@@ -611,12 +614,12 @@ const MatrixHelper = {
611
614
  const cosR = c / scaleY;
612
615
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
613
616
  }
614
- const cosR = float$2(cos$6(rotation));
617
+ const cosR = float$3(cos$6(rotation));
615
618
  const sinR = sin$6(rotation);
616
- scaleX = float$2(scaleX), scaleY = float$2(scaleY);
617
- skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
618
- skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
619
- rotation = float$2(rotation / OneRadian);
619
+ scaleX = float$3(scaleX), scaleY = float$3(scaleY);
620
+ skewX = cosR ? float$3((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
621
+ skewY = cosR ? float$3((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
622
+ rotation = float$3(rotation / OneRadian);
620
623
  } else {
621
624
  scaleX = a;
622
625
  scaleY = d;
@@ -1134,13 +1137,13 @@ const AlignHelper = {
1134
1137
  }
1135
1138
  };
1136
1139
 
1137
- const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$4} = TwoPointBoundsHelper;
1140
+ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$3} = TwoPointBoundsHelper;
1138
1141
 
1139
1142
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1140
1143
 
1141
- const {float: float$1, fourNumber: fourNumber$1} = MathHelper;
1144
+ const {float: float$2, fourNumber: fourNumber$1} = MathHelper;
1142
1145
 
1143
- const {floor: floor$3, ceil: ceil$2} = Math;
1146
+ const {floor: floor$3, ceil: ceil$3} = Math;
1144
1147
 
1145
1148
  let right$4, bottom$3, boundsRight, boundsBottom;
1146
1149
 
@@ -1269,7 +1272,7 @@ const BoundsHelper = {
1269
1272
  point$2.x = t.x;
1270
1273
  toOuterPoint$2(matrix, point$2, toPoint$5);
1271
1274
  addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
1272
- toBounds$4(tempPointBounds$1, to);
1275
+ toBounds$3(tempPointBounds$1, to);
1273
1276
  }
1274
1277
  },
1275
1278
  toInnerOf(t, matrix, to) {
@@ -1307,8 +1310,8 @@ const BoundsHelper = {
1307
1310
  const {x: x, y: y} = t;
1308
1311
  t.x = floor$3(t.x);
1309
1312
  t.y = floor$3(t.y);
1310
- t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1311
- t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1313
+ t.width = x > t.x ? ceil$3(t.width + x - t.x) : ceil$3(t.width);
1314
+ t.height = y > t.y ? ceil$3(t.height + y - t.y) : ceil$3(t.height);
1312
1315
  },
1313
1316
  unsign(t) {
1314
1317
  if (t.width < 0) {
@@ -1321,10 +1324,10 @@ const BoundsHelper = {
1321
1324
  }
1322
1325
  },
1323
1326
  float(t, maxLength) {
1324
- t.x = float$1(t.x, maxLength);
1325
- t.y = float$1(t.y, maxLength);
1326
- t.width = float$1(t.width, maxLength);
1327
- t.height = float$1(t.height, maxLength);
1327
+ t.x = float$2(t.x, maxLength);
1328
+ t.y = float$2(t.y, maxLength);
1329
+ t.width = float$2(t.width, maxLength);
1330
+ t.height = float$2(t.height, maxLength);
1328
1331
  },
1329
1332
  add(t, bounds, isPoint) {
1330
1333
  right$4 = t.x + t.width;
@@ -1368,7 +1371,7 @@ const BoundsHelper = {
1368
1371
  },
1369
1372
  setPoints(t, points) {
1370
1373
  points.forEach((point, index) => index === 0 ? setPoint$5(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
1371
- toBounds$4(tempPointBounds$1, t);
1374
+ toBounds$3(tempPointBounds$1, t);
1372
1375
  },
1373
1376
  setPoint(t, point) {
1374
1377
  B.set(t, point.x, point.y);
@@ -2221,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
2221
2224
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2222
2225
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2223
2226
  this.bounds = new Bounds(0, 0, this.width, this.height);
2224
- if (this.context && !this.unreal) {
2225
- this.updateViewSize();
2226
- this.smooth = this.config.smooth;
2227
- }
2227
+ this.updateViewSize();
2228
2228
  this.updateClientBounds();
2229
- if (this.context && !this.unreal && takeCanvas) {
2230
- this.clearWorld(takeCanvas.bounds);
2231
- this.copyWorld(takeCanvas);
2232
- takeCanvas.recycle();
2229
+ if (this.context) {
2230
+ this.smooth = this.config.smooth;
2231
+ if (!this.unreal && takeCanvas) {
2232
+ this.clearWorld(takeCanvas.bounds);
2233
+ this.copyWorld(takeCanvas);
2234
+ takeCanvas.recycle();
2235
+ }
2233
2236
  }
2234
2237
  }
2235
2238
  updateViewSize() {}
@@ -2543,7 +2546,7 @@ const RectHelper = {
2543
2546
  }
2544
2547
  };
2545
2548
 
2546
- const {sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$1, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2549
+ 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;
2547
2550
 
2548
2551
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2549
2552
 
@@ -2614,9 +2617,11 @@ const BezierHelper = {
2614
2617
  const CBy = toY - y1;
2615
2618
  let startRadian = atan2$1(BAy, BAx);
2616
2619
  let endRadian = atan2$1(CBy, CBx);
2620
+ const lenBA = hypot(BAx, BAy);
2621
+ const lenCB = hypot(CBx, CBy);
2617
2622
  let totalRadian = endRadian - startRadian;
2618
2623
  if (totalRadian < 0) totalRadian += PI2;
2619
- if (totalRadian === PI$3 || abs$6(BAx + BAy) < 1e-12 || abs$6(CBx + CBy) < 1e-12) {
2624
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$6(totalRadian - PI$3) < 1e-12) {
2620
2625
  if (data) data.push(L$a, x1, y1);
2621
2626
  if (setPointBounds) {
2622
2627
  setPoint$4(setPointBounds, fromX, fromY);
@@ -2649,7 +2654,7 @@ const BezierHelper = {
2649
2654
  let totalRadian = endRadian - startRadian;
2650
2655
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2651
2656
  if (anticlockwise) totalRadian -= PI2;
2652
- const parts = ceil$1(abs$6(totalRadian / PI_2));
2657
+ const parts = ceil$2(abs$6(totalRadian / PI_2));
2653
2658
  const partRadian = totalRadian / parts;
2654
2659
  const partRadian4Sin = sin$4(partRadian / 4);
2655
2660
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -3208,11 +3213,7 @@ class PathCreator {
3208
3213
  this.set(path);
3209
3214
  }
3210
3215
  set(path) {
3211
- if (path) {
3212
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3213
- } else {
3214
- this.__path = [];
3215
- }
3216
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3216
3217
  return this;
3217
3218
  }
3218
3219
  beginPath() {
@@ -3380,7 +3381,7 @@ const {M: M$5, L: L$6, C: C$4, Q: Q$3, Z: Z$4, N: N$2, D: D$3, X: X$2, G: G$2, F
3380
3381
 
3381
3382
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3382
3383
 
3383
- const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$3} = TwoPointBoundsHelper;
3384
+ const {addPointBounds: addPointBounds, copy: copy$a, addPoint: addPoint$1, setPoint: setPoint$3, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3384
3385
 
3385
3386
  const debug$d = Debug.get("PathBounds");
3386
3387
 
@@ -3395,7 +3396,7 @@ const setEndPoint = {};
3395
3396
  const PathBounds = {
3396
3397
  toBounds(data, setBounds) {
3397
3398
  PathBounds.toTwoPointBounds(data, setPointBounds);
3398
- toBounds$3(setPointBounds, setBounds);
3399
+ toBounds$2(setPointBounds, setBounds);
3399
3400
  },
3400
3401
  toTwoPointBounds(data, setPointBounds) {
3401
3402
  if (!data || !data.length) return setPoint$3(setPointBounds, 0, 0);
@@ -3582,14 +3583,18 @@ const PathCorner = {
3582
3583
  }
3583
3584
  };
3584
3585
 
3585
- PathHelper.creator = new PathCreator;
3586
+ function path(path) {
3587
+ return new PathCreator(path);
3588
+ }
3589
+
3590
+ const pen = path();
3591
+
3592
+ PathHelper.creator = path();
3586
3593
 
3587
3594
  PathHelper.parse = PathConvert.parse;
3588
3595
 
3589
3596
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3590
3597
 
3591
- const pen = new PathCreator;
3592
-
3593
3598
  const {drawRoundRect: drawRoundRect} = RectHelper;
3594
3599
 
3595
3600
  function roundRect(drawer) {
@@ -3954,7 +3959,7 @@ const ImageManager = {
3954
3959
  return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3955
3960
  },
3956
3961
  isFormat(format, config) {
3957
- if (config.format === format) return true;
3962
+ if (config.format) return config.format === format;
3958
3963
  const {url: url} = config;
3959
3964
  if (url.startsWith("data:")) {
3960
3965
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -4048,7 +4053,7 @@ class LeaferImage {
4048
4053
  getFull(_filters) {
4049
4054
  return this.view;
4050
4055
  }
4051
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
4056
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4052
4057
  width || (width = this.width);
4053
4058
  height || (height = this.height);
4054
4059
  if (this.cache) {
@@ -4064,6 +4069,7 @@ class LeaferImage {
4064
4069
  const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
4065
4070
  const ctx = canvas.getContext("2d");
4066
4071
  if (opacity) ctx.globalAlpha = opacity;
4072
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
4067
4073
  ctx.drawImage(this.view, 0, 0, width, height);
4068
4074
  this.cache = this.use > 1 ? {
4069
4075
  data: canvas,
@@ -4715,8 +4721,9 @@ const L$4 = LeafHelper;
4715
4721
 
4716
4722
  const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$4, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L$4;
4717
4723
 
4718
- function getTempLocal(t, world) {
4719
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world;
4724
+ function getTempLocal(t, worldPoint) {
4725
+ t.updateLayout();
4726
+ return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
4720
4727
  }
4721
4728
 
4722
4729
  const LeafBoundsHelper = {
@@ -5456,6 +5463,8 @@ LeaferEvent.RESTART = "leafer.restart";
5456
5463
 
5457
5464
  LeaferEvent.END = "leafer.end";
5458
5465
 
5466
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5467
+
5459
5468
  LeaferEvent.TRANSFORM = "leafer.transform";
5460
5469
 
5461
5470
  LeaferEvent.MOVE = "leafer.move";
@@ -5734,7 +5743,7 @@ const {updateBounds: updateBounds$2} = BranchHelper;
5734
5743
 
5735
5744
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
5736
5745
 
5737
- const {toBounds: toBounds$2} = PathBounds;
5746
+ const {toBounds: toBounds$1} = PathBounds;
5738
5747
 
5739
5748
  const LeafBounds = {
5740
5749
  __updateWorldBounds() {
@@ -5806,8 +5815,8 @@ const LeafBounds = {
5806
5815
  __updateBoxBounds(_secondLayout, _bounds) {
5807
5816
  const b = this.__layout.boxBounds;
5808
5817
  const data = this.__;
5809
- if (data.__pathInputed) {
5810
- toBounds$2(data.path, b);
5818
+ if (data.__usePathBox) {
5819
+ toBounds$1(data.path, b);
5811
5820
  } else {
5812
5821
  b.x = 0;
5813
5822
  b.y = 0;
@@ -6742,7 +6751,7 @@ class LeafLevelList {
6742
6751
  }
6743
6752
  }
6744
6753
 
6745
- const version = "1.9.4";
6754
+ const version = "1.9.6";
6746
6755
 
6747
6756
  class LeaferCanvas extends LeaferCanvasBase {
6748
6757
  get allowBackgroundColor() {
@@ -7165,7 +7174,7 @@ class Renderer {
7165
7174
  this.times = 0;
7166
7175
  this.config = {
7167
7176
  usePartRender: true,
7168
- maxFPS: 60
7177
+ maxFPS: 120
7169
7178
  };
7170
7179
  this.target = target;
7171
7180
  this.canvas = canvas;
@@ -7320,11 +7329,15 @@ class Renderer {
7320
7329
  if (this.requestTime || !target) return;
7321
7330
  if (target.parentApp) return target.parentApp.requestRender(false);
7322
7331
  const requestTime = this.requestTime = Date.now();
7323
- Platform.requestRender(() => {
7324
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7332
+ const render = () => {
7333
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7334
+ const {maxFPS: maxFPS} = this.config;
7335
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7336
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7325
7337
  this.requestTime = 0;
7326
7338
  this.checkRender();
7327
- });
7339
+ };
7340
+ Platform.requestRender(render);
7328
7341
  }
7329
7342
  __onResize(e) {
7330
7343
  if (this.canvas.unreal) return;
@@ -7367,7 +7380,8 @@ class Renderer {
7367
7380
  if (this.target) {
7368
7381
  this.stop();
7369
7382
  this.__removeListenEvents();
7370
- this.target = this.canvas = this.config = null;
7383
+ this.config = {};
7384
+ this.target = this.canvas = null;
7371
7385
  }
7372
7386
  }
7373
7387
  }
@@ -7463,7 +7477,7 @@ class Picker {
7463
7477
  item = path.list[i];
7464
7478
  if (!item.__.hittable) break;
7465
7479
  hittablePath.addAt(item, 0);
7466
- if (!item.__.hitChildren) break;
7480
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
7467
7481
  }
7468
7482
  return hittablePath;
7469
7483
  }
@@ -7858,7 +7872,11 @@ class LeaferData extends GroupData {
7858
7872
 
7859
7873
  class FrameData extends BoxData {}
7860
7874
 
7861
- class LineData extends UIData {}
7875
+ class LineData extends UIData {
7876
+ get __usePathBox() {
7877
+ return this.points || this.__pathInputed;
7878
+ }
7879
+ }
7862
7880
 
7863
7881
  class RectData extends UIData {
7864
7882
  get __boxStroke() {
@@ -7872,7 +7890,7 @@ class EllipseData extends UIData {
7872
7890
  }
7873
7891
  }
7874
7892
 
7875
- class PolygonData extends UIData {}
7893
+ class PolygonData extends LineData {}
7876
7894
 
7877
7895
  class StarData extends UIData {}
7878
7896
 
@@ -7916,8 +7934,6 @@ class TextData extends UIData {
7916
7934
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7917
7935
  box.set(value);
7918
7936
  if (boxLayout.strokeChanged) layout.strokeChange();
7919
- if (boxLayout.renderChanged) layout.renderChange();
7920
- box.__updateChange();
7921
7937
  } else if (box) {
7922
7938
  t.__box = box.parent = null;
7923
7939
  box.destroy();
@@ -7987,7 +8003,7 @@ const UIBounds = {
7987
8003
  __updateRenderSpread() {
7988
8004
  let width = 0;
7989
8005
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7990
- if (shadow) shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
8006
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7991
8007
  if (blur) width = Math.max(width, blur);
7992
8008
  if (filter) width += Filter.getSpread(filter);
7993
8009
  if (renderSpread) width += renderSpread;
@@ -8000,36 +8016,69 @@ const UIBounds = {
8000
8016
  }
8001
8017
  };
8002
8018
 
8019
+ const {float: float$1} = MathHelper;
8020
+
8021
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
8022
+
8003
8023
  const DragBoundsHelper = {
8024
+ limitMove(leaf, move) {
8025
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8026
+ if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, move, true);
8027
+ D$2.axisMove(leaf, move);
8028
+ },
8029
+ limitScaleOf(leaf, origin, scale) {
8030
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8031
+ if (dragBounds) D$2.getValidScaleOf(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
8032
+ },
8033
+ axisMove(leaf, move) {
8034
+ const {draggable: draggable} = leaf;
8035
+ if (draggable === "x") move.y = 0;
8036
+ if (draggable === "y") move.x = 0;
8037
+ },
8038
+ getDragBounds(leaf) {
8039
+ const {dragBounds: dragBounds} = leaf;
8040
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
8041
+ },
8042
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
8043
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
8044
+ },
8004
8045
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
8005
8046
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
8006
8047
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8007
8048
  if (!change) move = Object.assign({}, move);
8008
- const isBiggerWidth = content.width > dragBounds.width;
8009
- const isBiggerHeight = content.height > dragBounds.height;
8010
- if (isBiggerWidth && dragBoundsType !== "outer") {
8049
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8011
8050
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
8012
8051
  } else {
8013
8052
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
8014
8053
  }
8015
- if (isBiggerHeight && dragBoundsType !== "outer") {
8054
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8016
8055
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
8017
8056
  } else {
8018
8057
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
8019
8058
  }
8020
- move.x = MathHelper.float(move.x);
8021
- move.y = MathHelper.float(move.y);
8059
+ move.x = float$1(move.x);
8060
+ move.y = float$1(move.y);
8022
8061
  return move;
8023
8062
  },
8024
- axisMove(leaf, move) {
8025
- const {draggable: draggable} = leaf;
8026
- if (draggable === "x") move.y = 0;
8027
- if (draggable === "y") move.x = 0;
8028
- },
8029
- limitMove(leaf, move) {
8030
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8031
- if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
8032
- D$2.axisMove(leaf, move);
8063
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
8064
+ if (!change) scale = Object.assign({}, scale);
8065
+ let fitScaleX, fitScaleY;
8066
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
8067
+ tempMerge.set(tempContent).add(dragBounds);
8068
+ tempIntersect.set(tempContent).intersect(dragBounds);
8069
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8070
+ fitScaleX = tempMerge.width / tempContent.width;
8071
+ } else {
8072
+ fitScaleX = tempIntersect.width / tempContent.width;
8073
+ }
8074
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8075
+ fitScaleY = tempMerge.height / tempContent.height;
8076
+ } else {
8077
+ fitScaleY = tempIntersect.height / tempContent.height;
8078
+ }
8079
+ scale.x = float$1(tempIntersect.width) ? scale.x * fitScaleX : 1;
8080
+ scale.y = float$1(tempIntersect.height) ? scale.y * fitScaleY : 1;
8081
+ return scale;
8033
8082
  }
8034
8083
  };
8035
8084
 
@@ -8047,7 +8096,7 @@ const UIRender = {
8047
8096
  }
8048
8097
  if (data.__useEffect) {
8049
8098
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8050
- stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8099
+ stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
8051
8100
  data.__useEffect = !!(shadow || otherEffect);
8052
8101
  }
8053
8102
  data.__checkSingle();
@@ -8182,20 +8231,9 @@ let UI = UI_1 = class UI extends Leaf {
8182
8231
  if (!path) this.__drawPathByBox(pen);
8183
8232
  return pen;
8184
8233
  }
8185
- constructor(data) {
8186
- super(data);
8187
- }
8188
8234
  reset(_data) {}
8189
- set(data, transition) {
8190
- if (data) {
8191
- if (transition) {
8192
- if (transition === "temp") {
8193
- this.lockNormalStyle = true;
8194
- Object.assign(this, data);
8195
- this.lockNormalStyle = false;
8196
- } else this.animate(data, transition);
8197
- } else Object.assign(this, data);
8198
- }
8235
+ set(data, _transition) {
8236
+ if (data) Object.assign(this, data);
8199
8237
  }
8200
8238
  get(name) {
8201
8239
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8241,7 +8279,7 @@ let UI = UI_1 = class UI extends Leaf {
8241
8279
  const data = this.__;
8242
8280
  if (data.path) {
8243
8281
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8244
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8282
+ if (data.__useArrow) PathArrow.addArrows(this);
8245
8283
  } else data.__pathForRender && (data.__pathForRender = undefined);
8246
8284
  }
8247
8285
  __drawRenderPath(canvas) {
@@ -8265,7 +8303,8 @@ let UI = UI_1 = class UI extends Leaf {
8265
8303
  drawImagePlaceholder(canvas, _image) {
8266
8304
  Paint.fill(this.__.placeholderColor, this, canvas);
8267
8305
  }
8268
- animate(_keyframe, _options, _type, _isTemp) {
8306
+ animate(keyframe, _options, _type, _isTemp) {
8307
+ this.set(keyframe);
8269
8308
  return Plugin.need("animate");
8270
8309
  }
8271
8310
  killAnimate(_type, _nextStyle) {}
@@ -8454,9 +8493,6 @@ let Group = class Group extends UI {
8454
8493
  get isBranch() {
8455
8494
  return true;
8456
8495
  }
8457
- constructor(data) {
8458
- super(data);
8459
- }
8460
8496
  reset(data) {
8461
8497
  this.__setBranch();
8462
8498
  super.reset(data);
@@ -8581,7 +8617,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8581
8617
  const canvas = this.canvas = Creator.canvas(config);
8582
8618
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8583
8619
  if (this.isApp) this.__setApp();
8584
- this.__checkAutoLayout(config, parentApp);
8620
+ this.__checkAutoLayout();
8585
8621
  this.view = canvas.view;
8586
8622
  if (!parentApp) {
8587
8623
  this.selector = Creator.selector(this);
@@ -8680,7 +8716,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8680
8716
  this.leafer = leafer;
8681
8717
  this.__level = 1;
8682
8718
  }
8683
- __checkAutoLayout(config, parentApp) {
8719
+ __checkAutoLayout() {
8720
+ const {config: config, parentApp: parentApp} = this;
8684
8721
  if (!parentApp) {
8685
8722
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8686
8723
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8697,7 +8734,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8697
8734
  } else if (attrName === "zIndex") {
8698
8735
  this.canvas.zIndex = newValue;
8699
8736
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8700
- }
8737
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8738
+ mode: newValue
8739
+ });
8701
8740
  }
8702
8741
  return super.__setAttr(attrName, newValue);
8703
8742
  }
@@ -8706,9 +8745,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8706
8745
  return super.__getAttr(attrName);
8707
8746
  }
8708
8747
  __changeCanvasSize(attrName, newValue) {
8709
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8710
- data[attrName] = this.config[attrName] = newValue;
8711
- if (newValue) this.canvas.stopAutoLayout();
8748
+ const {config: config, canvas: canvas} = this;
8749
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8750
+ data[attrName] = config[attrName] = newValue;
8751
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8712
8752
  this.__doResize(data);
8713
8753
  }
8714
8754
  __changeFill(newValue) {
@@ -8855,9 +8895,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8855
8895
  if (!this.parent) {
8856
8896
  if (this.selector) this.selector.destroy();
8857
8897
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8858
- this.canvasManager.destroy();
8898
+ if (this.canvasManager) this.canvasManager.destroy();
8859
8899
  }
8860
- this.canvas.destroy();
8900
+ if (this.canvas) this.canvas.destroy();
8861
8901
  this.config.view = this.view = this.parentApp = null;
8862
8902
  if (this.userConfig) this.userConfig.view = null;
8863
8903
  super.destroy();
@@ -8879,15 +8919,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
8879
8919
 
8880
8920
  __decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
8881
8921
 
8922
+ __decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
8923
+
8882
8924
  Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
8883
8925
 
8884
8926
  let Rect = class Rect extends UI {
8885
8927
  get __tag() {
8886
8928
  return "Rect";
8887
8929
  }
8888
- constructor(data) {
8889
- super(data);
8890
- }
8891
8930
  };
8892
8931
 
8893
8932
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9019,9 +9058,6 @@ let Frame = class Frame extends Box {
9019
9058
  get isFrame() {
9020
9059
  return true;
9021
9060
  }
9022
- constructor(data) {
9023
- super(data);
9024
- }
9025
9061
  };
9026
9062
 
9027
9063
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9038,9 +9074,6 @@ let Ellipse = class Ellipse extends UI {
9038
9074
  get __tag() {
9039
9075
  return "Ellipse";
9040
9076
  }
9041
- constructor(data) {
9042
- super(data);
9043
- }
9044
9077
  __updatePath() {
9045
9078
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9046
9079
  const rx = width / 2, ry = height / 2;
@@ -9080,98 +9113,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
9080
9113
 
9081
9114
  Ellipse = __decorate([ registerUI() ], Ellipse);
9082
9115
 
9083
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
9084
-
9085
- const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9086
-
9087
- const {toBounds: toBounds$1} = PathBounds;
9088
-
9089
- let Line = class Line extends UI {
9090
- get __tag() {
9091
- return "Line";
9092
- }
9093
- get toPoint() {
9094
- const {width: width, rotation: rotation} = this.__;
9095
- const to = getPointData();
9096
- if (width) to.x = width;
9097
- if (rotation) rotate$3(to, rotation);
9098
- return to;
9099
- }
9100
- set toPoint(value) {
9101
- this.width = getDistance$3(defaultPoint, value);
9102
- this.rotation = getAngle$2(defaultPoint, value);
9103
- if (this.height) this.height = 0;
9104
- }
9105
- constructor(data) {
9106
- super(data);
9107
- }
9108
- __updatePath() {
9109
- const data = this.__;
9110
- const path = data.path = [];
9111
- if (data.points) {
9112
- drawPoints$1(path, data.points, false, data.closed);
9113
- } else {
9114
- moveTo$2(path, 0, 0);
9115
- lineTo$2(path, this.width, 0);
9116
- }
9117
- }
9118
- __updateRenderPath() {
9119
- const data = this.__;
9120
- if (!this.pathInputed && data.points && data.curve) {
9121
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9122
- if (data.__useArrow) PathArrow.addArrows(this, false);
9123
- } else super.__updateRenderPath();
9124
- }
9125
- __updateBoxBounds() {
9126
- if (this.points) {
9127
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
9128
- } else super.__updateBoxBounds();
9129
- }
9130
- };
9131
-
9132
- __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9133
-
9134
- __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9135
-
9136
- __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9137
-
9138
- __decorate([ pathType() ], Line.prototype, "points", void 0);
9139
-
9140
- __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9141
-
9142
- __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9143
-
9144
- Line = __decorate([ registerUI() ], Line);
9145
-
9146
9116
  const {sin: sin$2, cos: cos$2, PI: PI$2} = Math;
9147
9117
 
9148
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
9149
-
9150
- const line = Line.prototype;
9118
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
9151
9119
 
9152
9120
  let Polygon = class Polygon extends UI {
9153
9121
  get __tag() {
9154
9122
  return "Polygon";
9155
9123
  }
9156
- constructor(data) {
9157
- super(data);
9158
- }
9159
9124
  __updatePath() {
9160
- const path = this.__.path = [];
9161
- if (this.__.points) {
9162
- drawPoints(path, this.__.points, false, true);
9125
+ const data = this.__;
9126
+ const path = data.path = [];
9127
+ if (data.points) {
9128
+ drawPoints$1(path, data.points, data.curve, true);
9163
9129
  } else {
9164
- const {width: width, height: height, sides: sides} = this.__;
9130
+ const {width: width, height: height, sides: sides} = data;
9165
9131
  const rx = width / 2, ry = height / 2;
9166
- moveTo$1(path, rx, 0);
9132
+ moveTo$2(path, rx, 0);
9167
9133
  for (let i = 1; i < sides; i++) {
9168
- lineTo$1(path, rx + rx * sin$2(i * 2 * PI$2 / sides), ry - ry * cos$2(i * 2 * PI$2 / sides));
9134
+ lineTo$2(path, rx + rx * sin$2(i * 2 * PI$2 / sides), ry - ry * cos$2(i * 2 * PI$2 / sides));
9169
9135
  }
9170
9136
  closePath$1(path);
9171
9137
  }
9172
9138
  }
9173
- __updateRenderPath() {}
9174
- __updateBoxBounds() {}
9175
9139
  };
9176
9140
 
9177
9141
  __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
@@ -9182,30 +9146,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9182
9146
 
9183
9147
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
9184
9148
 
9185
- __decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
9186
-
9187
- __decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
9188
-
9189
9149
  Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
9190
9150
 
9191
9151
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
9192
9152
 
9193
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
9153
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
9194
9154
 
9195
9155
  let Star = class Star extends UI {
9196
9156
  get __tag() {
9197
9157
  return "Star";
9198
9158
  }
9199
- constructor(data) {
9200
- super(data);
9201
- }
9202
9159
  __updatePath() {
9203
9160
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9204
9161
  const rx = width / 2, ry = height / 2;
9205
9162
  const path = this.__.path = [];
9206
- moveTo(path, rx, 0);
9163
+ moveTo$1(path, rx, 0);
9207
9164
  for (let i = 1; i < corners * 2; i++) {
9208
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin$1(i * PI$1 / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos$1(i * PI$1 / corners));
9165
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin$1(i * PI$1 / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos$1(i * PI$1 / corners));
9209
9166
  }
9210
9167
  closePath(path);
9211
9168
  }
@@ -9219,6 +9176,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9219
9176
 
9220
9177
  Star = __decorate([ registerUI() ], Star);
9221
9178
 
9179
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9180
+
9181
+ const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9182
+
9183
+ let Line = class Line extends UI {
9184
+ get __tag() {
9185
+ return "Line";
9186
+ }
9187
+ get toPoint() {
9188
+ const {width: width, rotation: rotation} = this.__;
9189
+ const to = getPointData();
9190
+ if (width) to.x = width;
9191
+ if (rotation) rotate$3(to, rotation);
9192
+ return to;
9193
+ }
9194
+ set toPoint(value) {
9195
+ this.width = getDistance$3(defaultPoint, value);
9196
+ this.rotation = getAngle$2(defaultPoint, value);
9197
+ if (this.height) this.height = 0;
9198
+ }
9199
+ __updatePath() {
9200
+ const data = this.__;
9201
+ const path = data.path = [];
9202
+ if (data.points) {
9203
+ drawPoints(path, data.points, data.curve, data.closed);
9204
+ } else {
9205
+ moveTo(path, 0, 0);
9206
+ lineTo(path, this.width, 0);
9207
+ }
9208
+ }
9209
+ };
9210
+
9211
+ __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9212
+
9213
+ __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9214
+
9215
+ __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9216
+
9217
+ __decorate([ pathType() ], Line.prototype, "points", void 0);
9218
+
9219
+ __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9220
+
9221
+ __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9222
+
9223
+ Line = __decorate([ registerUI() ], Line);
9224
+
9222
9225
  let Image = class Image extends Rect {
9223
9226
  get __tag() {
9224
9227
  return "Image";
@@ -9231,9 +9234,6 @@ let Image = class Image extends Rect {
9231
9234
  const {fill: fill} = this.__;
9232
9235
  return isArray(fill) && fill[0].image;
9233
9236
  }
9234
- constructor(data) {
9235
- super(data);
9236
- }
9237
9237
  };
9238
9238
 
9239
9239
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9333,9 +9333,6 @@ let Text = class Text extends UI {
9333
9333
  this.updateLayout();
9334
9334
  return this.__.__textDrawData;
9335
9335
  }
9336
- constructor(data) {
9337
- super(data);
9338
- }
9339
9336
  __updateTextDrawData() {
9340
9337
  const data = this.__;
9341
9338
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9372,10 +9369,6 @@ let Text = class Text extends UI {
9372
9369
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9373
9370
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9374
9371
  }
9375
- __onUpdateSize() {
9376
- if (this.__box) this.__box.__onUpdateSize();
9377
- super.__onUpdateSize();
9378
- }
9379
9372
  __updateRenderSpread() {
9380
9373
  let width = super.__updateRenderSpread();
9381
9374
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -9386,6 +9379,11 @@ let Text = class Text extends UI {
9386
9379
  copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
9387
9380
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9388
9381
  }
9382
+ __updateChange() {
9383
+ super.__updateChange();
9384
+ const box = this.__box;
9385
+ if (box) box.__onUpdateSize(), box.__updateChange();
9386
+ }
9389
9387
  __drawRenderPath(canvas) {
9390
9388
  canvas.font = this.__.__font;
9391
9389
  }
@@ -9468,9 +9466,6 @@ let Path = class Path extends UI {
9468
9466
  get __tag() {
9469
9467
  return "Path";
9470
9468
  }
9471
- constructor(data) {
9472
- super(data);
9473
- }
9474
9469
  };
9475
9470
 
9476
9471
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9483,9 +9478,6 @@ let Pen = class Pen extends Group {
9483
9478
  get __tag() {
9484
9479
  return "Pen";
9485
9480
  }
9486
- constructor(data) {
9487
- super(data);
9488
- }
9489
9481
  setStyle(data) {
9490
9482
  const path = this.pathElement = new Path(data);
9491
9483
  this.pathStyle = data;
@@ -11570,7 +11562,7 @@ function ignoreRender(ui, value) {
11570
11562
 
11571
11563
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11572
11564
 
11573
- const {floor: floor$1, max: max$1, abs: abs$4} = Math;
11565
+ const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
11574
11566
 
11575
11567
  function createPattern(ui, paint, pixelRatio) {
11576
11568
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11580,8 +11572,6 @@ function createPattern(ui, paint, pixelRatio) {
11580
11572
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11581
11573
  scaleX *= pixelRatio;
11582
11574
  scaleY *= pixelRatio;
11583
- const xGap = gap && gap.x * scaleX;
11584
- const yGap = gap && gap.y * scaleY;
11585
11575
  if (sx) {
11586
11576
  sx = abs$4(sx);
11587
11577
  sy = abs$4(sy);
@@ -11598,7 +11588,10 @@ function createPattern(ui, paint, pixelRatio) {
11598
11588
  if (size > Platform.image.maxCacheSize) return false;
11599
11589
  }
11600
11590
  let maxSize = Platform.image.maxPatternSize;
11601
- if (!image.isSVG) {
11591
+ if (image.isSVG) {
11592
+ const ws = width / image.width;
11593
+ if (ws > 1) imageScale = ws / ceil$1(ws);
11594
+ } else {
11602
11595
  const imageSize = image.width * image.height;
11603
11596
  if (maxSize > imageSize) maxSize = imageSize;
11604
11597
  }
@@ -11613,18 +11606,20 @@ function createPattern(ui, paint, pixelRatio) {
11613
11606
  scaleX /= sx;
11614
11607
  scaleY /= sy;
11615
11608
  }
11609
+ const xGap = gap && gap.x * scaleX;
11610
+ const yGap = gap && gap.y * scaleY;
11616
11611
  if (transform || scaleX !== 1 || scaleY !== 1) {
11612
+ const canvasWidth = width + (xGap || 0);
11613
+ const canvasHeight = height + (yGap || 0);
11614
+ scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
11615
+ scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
11617
11616
  if (!imageMatrix) {
11618
11617
  imageMatrix = get$1();
11619
11618
  if (transform) copy$4(imageMatrix, transform);
11620
11619
  }
11621
11620
  scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11622
11621
  }
11623
- if (imageMatrix) {
11624
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11625
- scale$2(imageMatrix, canvasWidth / max$1(floor$1(canvasWidth), 1), canvasHeight / max$1(floor$1(canvasHeight), 1));
11626
- }
11627
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11622
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11628
11623
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11629
11624
  paint.style = pattern;
11630
11625
  paint.patternId = id;
@@ -11866,12 +11861,18 @@ function shadow$1(ui, current, shape) {
11866
11861
  }
11867
11862
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11868
11863
  }
11869
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11864
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11870
11865
  if (end && index < end) other.clearWorld(copyBounds);
11871
11866
  });
11872
11867
  other.recycle(copyBounds);
11873
11868
  }
11874
11869
 
11870
+ function getShadowSpread(_ui, shadow) {
11871
+ let width = 0;
11872
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
11873
+ return width;
11874
+ }
11875
+
11875
11876
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11876
11877
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11877
11878
  if (Platform.fullImageShadow) {
@@ -11949,7 +11950,11 @@ const EffectModule = {
11949
11950
  shadow: shadow$1,
11950
11951
  innerShadow: innerShadow,
11951
11952
  blur: blur,
11952
- backgroundBlur: backgroundBlur
11953
+ backgroundBlur: backgroundBlur,
11954
+ getShadowSpread: getShadowSpread,
11955
+ isTransformShadow(_shadow) {
11956
+ return undefined;
11957
+ }
11953
11958
  };
11954
11959
 
11955
11960
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -12457,16 +12462,17 @@ function toTextChar(row) {
12457
12462
  }
12458
12463
 
12459
12464
  function decorationText(drawData, style) {
12460
- let type;
12465
+ let type, offset = 0;
12461
12466
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
12462
12467
  drawData.decorationHeight = fontSize / 11;
12463
12468
  if (isObject(textDecoration)) {
12464
12469
  type = textDecoration.type;
12465
12470
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
12471
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
12466
12472
  } else type = textDecoration;
12467
12473
  switch (type) {
12468
12474
  case "under":
12469
- drawData.decorationY = [ fontSize * .15 ];
12475
+ drawData.decorationY = [ fontSize * .15 + offset ];
12470
12476
  break;
12471
12477
 
12472
12478
  case "delete":
@@ -12474,7 +12480,7 @@ function decorationText(drawData, style) {
12474
12480
  break;
12475
12481
 
12476
12482
  case "under-delete":
12477
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
12483
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
12478
12484
  }
12479
12485
  }
12480
12486
 
@@ -12813,7 +12819,7 @@ class EditSelect extends Group {
12813
12819
  }
12814
12820
  get running() {
12815
12821
  const {editor: editor} = this;
12816
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector;
12822
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
12817
12823
  }
12818
12824
  get isMoveMode() {
12819
12825
  return this.app && this.app.interaction.moveMode;
@@ -13115,17 +13121,13 @@ const EditDataHelper = {
13115
13121
  }
13116
13122
  toPoint(around || align, boxBounds, origin, true);
13117
13123
  if (dragBounds) {
13118
- const allowBounds = dragBounds === "parent" ? target.parent.boxBounds : dragBounds;
13119
- const childBounds = new Bounds(target.__localBoxBounds);
13120
- if (BoundsHelper.includes(new Bounds(allowBounds).spread(.1), childBounds)) {
13121
- childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
13122
- if (!BoundsHelper.includes(allowBounds, childBounds)) {
13123
- const realBounds = childBounds.getIntersect(allowBounds);
13124
- const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
13125
- if (useScaleX) scaleX *= fitScaleX;
13126
- if (useScaleY) scaleY *= fitScaleY;
13127
- }
13128
- }
13124
+ const scaleData = {
13125
+ x: scaleX,
13126
+ y: scaleY
13127
+ };
13128
+ DragBoundsHelper.limitScaleOf(target, origin, scaleData);
13129
+ scaleX = scaleData.x;
13130
+ scaleY = scaleData.y;
13129
13131
  }
13130
13132
  if (useScaleX && widthRange) {
13131
13133
  const nowWidth = boxBounds.width * target.scaleX;
@@ -14686,7 +14688,9 @@ let Editor = class Editor extends Group {
14686
14688
  listenTargetEvents() {
14687
14689
  if (!this.targetEventIds.length) {
14688
14690
  const {app: app, leafer: leafer, targetLeafer: targetLeafer, editMask: editMask} = this;
14689
- this.targetEventIds = [ leafer.on_(RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this) ];
14691
+ this.targetEventIds = [ leafer.on_(RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this), app.on_(LeaferEvent.UPDATE_MODE, data => {
14692
+ if (data.mode && data.mode !== "normal") this.cancel();
14693
+ }) ];
14690
14694
  if (editMask.visible) editMask.forceRender();
14691
14695
  }
14692
14696
  }
@@ -15600,7 +15604,8 @@ const WheelEventHelper = {
15600
15604
  if (zoom) {
15601
15605
  zoomSpeed = within$2(zoomSpeed, 0, 1);
15602
15606
  const min = event.deltaY ? config.delta.y : config.delta.x;
15603
- scale = within$2(1 - delta / (min * 4) * zoomSpeed, .5, 1.5);
15607
+ const absScale = within$2(1 - abs$2(delta) / (min * 4) * zoomSpeed, .5, 2);
15608
+ scale = delta > 0 ? absScale : 1 / absScale;
15604
15609
  }
15605
15610
  return scale;
15606
15611
  }
@@ -16155,6 +16160,9 @@ let Arrow = class Arrow extends Line {
16155
16160
  super(data);
16156
16161
  this.__.__useArrow = true;
16157
16162
  }
16163
+ static registerArrow(name, data) {
16164
+ PathArrow.register(name, data);
16165
+ }
16158
16166
  };
16159
16167
 
16160
16168
  __decorate([ dataProcessor(ArrowData) ], Arrow.prototype, "__", void 0);
@@ -16336,9 +16344,18 @@ const arrows = {
16336
16344
  mark: mark
16337
16345
  };
16338
16346
 
16339
- function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
16347
+ function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
16348
+ let pathData, scale;
16340
16349
  const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
16341
- const {offset: offset, connect: connect, path: path, dashPath: dashPath} = isObject(arrow) ? arrow : arrows[arrow];
16350
+ if (isObject(arrow)) {
16351
+ if (arrow.type) {
16352
+ scale = arrow.scale;
16353
+ pathData = arrows[arrow.type];
16354
+ } else pathData = arrow;
16355
+ } else {
16356
+ pathData = arrows[arrow];
16357
+ }
16358
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
16342
16359
  let connectX = connect ? connect.x : 0;
16343
16360
  let offsetX = offset ? offset.x : 0;
16344
16361
  const data = [ ...path ];
@@ -16347,9 +16364,10 @@ function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern)
16347
16364
  if (offset) {
16348
16365
  if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
16349
16366
  }
16367
+ if (scale) layout$2(data, 0, 0, scale, scale);
16350
16368
  if (offsetX) layout$2(data, offsetX, 0);
16351
- layout$2(data, to.x, to.y, scale, scale, getAngle(from, to));
16352
- connectOffset.x = (connectX + offsetX) * scale;
16369
+ layout$2(data, to.x, to.y, size, size, getAngle(from, to));
16370
+ connectOffset.x = (connectX + offsetX) * size;
16353
16371
  return data;
16354
16372
  }
16355
16373
 
@@ -16365,8 +16383,9 @@ const last = {}, now = {};
16365
16383
 
16366
16384
  const PathArrowModule = {
16367
16385
  list: arrows,
16368
- addArrows(ui, changeRenderPath) {
16369
- const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
16386
+ addArrows(ui) {
16387
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
16388
+ const clonePathForArrow = !cornerRadius;
16370
16389
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
16371
16390
  while (i < len) {
16372
16391
  command = data[i];
@@ -16381,12 +16400,12 @@ const PathArrowModule = {
16381
16400
  break;
16382
16401
 
16383
16402
  case C$1:
16384
- if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
16403
+ if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
16385
16404
  i += 7;
16386
16405
  break;
16387
16406
 
16388
16407
  case Q:
16389
- if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
16408
+ if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
16390
16409
  i += 5;
16391
16410
  break;
16392
16411
 
@@ -16422,7 +16441,13 @@ const PathArrowModule = {
16422
16441
  break;
16423
16442
 
16424
16443
  case U:
16425
- if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
16444
+ if (count === 1 || i + 6 >= len - 3) {
16445
+ copyPoints(data, last, now, i + 1);
16446
+ if (i + 6 !== len) {
16447
+ now.x -= (now.x - last.x) / 10;
16448
+ now.y -= (now.y - last.y) / 10;
16449
+ }
16450
+ }
16426
16451
  i += 6;
16427
16452
  break;
16428
16453
  }
@@ -16430,7 +16455,7 @@ const PathArrowModule = {
16430
16455
  if (count === 1 && command !== M$1) return;
16431
16456
  if (count === 2 && useStartArrow) copy(second, command === L$1 ? now : last);
16432
16457
  if (i === len) {
16433
- const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
16458
+ const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
16434
16459
  const pathForArrow = ui.__.__pathForArrow = [];
16435
16460
  if (useStartArrow) {
16436
16461
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -16471,6 +16496,12 @@ const PathArrowModule = {
16471
16496
  copy(last, now);
16472
16497
  }
16473
16498
  }
16499
+ },
16500
+ register(name, data) {
16501
+ this.list[name] = data;
16502
+ },
16503
+ get(name) {
16504
+ return this.list[name];
16474
16505
  }
16475
16506
  };
16476
16507
 
@@ -18036,6 +18067,18 @@ UI.addAttr("transition", true, dataType);
18036
18067
 
18037
18068
  UI.addAttr("transitionOut", undefined, dataType);
18038
18069
 
18070
+ ui$3.set = function(data, transition) {
18071
+ if (data) {
18072
+ if (transition) {
18073
+ if (transition === "temp") {
18074
+ this.lockNormalStyle = true;
18075
+ Object.assign(this, data);
18076
+ this.lockNormalStyle = false;
18077
+ } else this.animate(data, transition);
18078
+ } else Object.assign(this, data);
18079
+ }
18080
+ };
18081
+
18039
18082
  ui$3.animate = function(keyframe, options, kill, isTemp) {
18040
18083
  if (isUndefined(keyframe)) return this.__animate;
18041
18084
  const isAnimationList = isArray(keyframe) && !options && kill;
@@ -19235,6 +19278,8 @@ const ExportModule = {
19235
19278
  renderBounds: renderBounds,
19236
19279
  trimBounds: trimBounds
19237
19280
  };
19281
+ const app = leafer && leafer.app;
19282
+ if (app && app.canvasManager) app.canvasManager.clearRecycled();
19238
19283
  }
19239
19284
  } catch (error) {
19240
19285
  result = {
@@ -19352,4 +19397,4 @@ Object.assign(Filter, {
19352
19397
  }
19353
19398
  });
19354
19399
 
19355
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
19400
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };