@leafer/miniapp 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() {
@@ -6796,6 +6805,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6796
6805
  this.view = Platform.origin.createCanvas(1, 1);
6797
6806
  }
6798
6807
  updateViewSize() {
6808
+ if (this.unreal) return;
6799
6809
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6800
6810
  this.view.width = Math.ceil(width * pixelRatio);
6801
6811
  this.view.height = Math.ceil(height * pixelRatio);
@@ -6807,6 +6817,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6807
6817
  });
6808
6818
  }
6809
6819
  startAutoLayout(autoBounds, listener) {
6820
+ if (this.resizeListener) return;
6810
6821
  this.resizeListener = listener;
6811
6822
  if (autoBounds) {
6812
6823
  this.checkSize = this.checkSize.bind(this);
@@ -7316,7 +7327,7 @@ class Renderer {
7316
7327
  this.times = 0;
7317
7328
  this.config = {
7318
7329
  usePartRender: true,
7319
- maxFPS: 60
7330
+ maxFPS: 120
7320
7331
  };
7321
7332
  this.target = target;
7322
7333
  this.canvas = canvas;
@@ -7471,11 +7482,15 @@ class Renderer {
7471
7482
  if (this.requestTime || !target) return;
7472
7483
  if (target.parentApp) return target.parentApp.requestRender(false);
7473
7484
  const requestTime = this.requestTime = Date.now();
7474
- Platform.requestRender(() => {
7475
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7485
+ const render = () => {
7486
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7487
+ const {maxFPS: maxFPS} = this.config;
7488
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7489
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7476
7490
  this.requestTime = 0;
7477
7491
  this.checkRender();
7478
- });
7492
+ };
7493
+ Platform.requestRender(render);
7479
7494
  }
7480
7495
  __onResize(e) {
7481
7496
  if (this.canvas.unreal) return;
@@ -7518,7 +7533,8 @@ class Renderer {
7518
7533
  if (this.target) {
7519
7534
  this.stop();
7520
7535
  this.__removeListenEvents();
7521
- this.target = this.canvas = this.config = null;
7536
+ this.config = {};
7537
+ this.target = this.canvas = null;
7522
7538
  }
7523
7539
  }
7524
7540
  }
@@ -7614,7 +7630,7 @@ class Picker {
7614
7630
  item = path.list[i];
7615
7631
  if (!item.__.hittable) break;
7616
7632
  hittablePath.addAt(item, 0);
7617
- if (!item.__.hitChildren) break;
7633
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
7618
7634
  }
7619
7635
  return hittablePath;
7620
7636
  }
@@ -8009,7 +8025,11 @@ class LeaferData extends GroupData {
8009
8025
 
8010
8026
  class FrameData extends BoxData {}
8011
8027
 
8012
- class LineData extends UIData {}
8028
+ class LineData extends UIData {
8029
+ get __usePathBox() {
8030
+ return this.points || this.__pathInputed;
8031
+ }
8032
+ }
8013
8033
 
8014
8034
  class RectData extends UIData {
8015
8035
  get __boxStroke() {
@@ -8023,7 +8043,7 @@ class EllipseData extends UIData {
8023
8043
  }
8024
8044
  }
8025
8045
 
8026
- class PolygonData extends UIData {}
8046
+ class PolygonData extends LineData {}
8027
8047
 
8028
8048
  class StarData extends UIData {}
8029
8049
 
@@ -8067,8 +8087,6 @@ class TextData extends UIData {
8067
8087
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
8068
8088
  box.set(value);
8069
8089
  if (boxLayout.strokeChanged) layout.strokeChange();
8070
- if (boxLayout.renderChanged) layout.renderChange();
8071
- box.__updateChange();
8072
8090
  } else if (box) {
8073
8091
  t.__box = box.parent = null;
8074
8092
  box.destroy();
@@ -8138,7 +8156,7 @@ const UIBounds = {
8138
8156
  __updateRenderSpread() {
8139
8157
  let width = 0;
8140
8158
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
8141
- 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));
8159
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
8142
8160
  if (blur) width = Math.max(width, blur);
8143
8161
  if (filter) width += Filter.getSpread(filter);
8144
8162
  if (renderSpread) width += renderSpread;
@@ -8151,36 +8169,69 @@ const UIBounds = {
8151
8169
  }
8152
8170
  };
8153
8171
 
8172
+ const {float: float$1} = MathHelper;
8173
+
8174
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
8175
+
8154
8176
  const DragBoundsHelper = {
8177
+ limitMove(leaf, move) {
8178
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8179
+ if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, move, true);
8180
+ D$2.axisMove(leaf, move);
8181
+ },
8182
+ limitScaleOf(leaf, origin, scale) {
8183
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8184
+ if (dragBounds) D$2.getValidScaleOf(leaf.__localBoxBounds, D$2.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
8185
+ },
8186
+ axisMove(leaf, move) {
8187
+ const {draggable: draggable} = leaf;
8188
+ if (draggable === "x") move.y = 0;
8189
+ if (draggable === "y") move.x = 0;
8190
+ },
8191
+ getDragBounds(leaf) {
8192
+ const {dragBounds: dragBounds} = leaf;
8193
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
8194
+ },
8195
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
8196
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
8197
+ },
8155
8198
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
8156
8199
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
8157
8200
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8158
8201
  if (!change) move = Object.assign({}, move);
8159
- const isBiggerWidth = content.width > dragBounds.width;
8160
- const isBiggerHeight = content.height > dragBounds.height;
8161
- if (isBiggerWidth && dragBoundsType !== "outer") {
8202
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8162
8203
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
8163
8204
  } else {
8164
8205
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
8165
8206
  }
8166
- if (isBiggerHeight && dragBoundsType !== "outer") {
8207
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8167
8208
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
8168
8209
  } else {
8169
8210
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
8170
8211
  }
8171
- move.x = MathHelper.float(move.x);
8172
- move.y = MathHelper.float(move.y);
8212
+ move.x = float$1(move.x);
8213
+ move.y = float$1(move.y);
8173
8214
  return move;
8174
8215
  },
8175
- axisMove(leaf, move) {
8176
- const {draggable: draggable} = leaf;
8177
- if (draggable === "x") move.y = 0;
8178
- if (draggable === "y") move.x = 0;
8179
- },
8180
- limitMove(leaf, move) {
8181
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
8182
- if (dragBounds) D$2.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
8183
- D$2.axisMove(leaf, move);
8216
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
8217
+ if (!change) scale = Object.assign({}, scale);
8218
+ let fitScaleX, fitScaleY;
8219
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
8220
+ tempMerge.set(tempContent).add(dragBounds);
8221
+ tempIntersect.set(tempContent).intersect(dragBounds);
8222
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
8223
+ fitScaleX = tempMerge.width / tempContent.width;
8224
+ } else {
8225
+ fitScaleX = tempIntersect.width / tempContent.width;
8226
+ }
8227
+ if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
8228
+ fitScaleY = tempMerge.height / tempContent.height;
8229
+ } else {
8230
+ fitScaleY = tempIntersect.height / tempContent.height;
8231
+ }
8232
+ scale.x = float$1(tempIntersect.width) ? scale.x * fitScaleX : 1;
8233
+ scale.y = float$1(tempIntersect.height) ? scale.y * fitScaleY : 1;
8234
+ return scale;
8184
8235
  }
8185
8236
  };
8186
8237
 
@@ -8198,7 +8249,7 @@ const UIRender = {
8198
8249
  }
8199
8250
  if (data.__useEffect) {
8200
8251
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
8201
- 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"));
8252
+ 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"));
8202
8253
  data.__useEffect = !!(shadow || otherEffect);
8203
8254
  }
8204
8255
  data.__checkSingle();
@@ -8333,20 +8384,9 @@ let UI = UI_1 = class UI extends Leaf {
8333
8384
  if (!path) this.__drawPathByBox(pen);
8334
8385
  return pen;
8335
8386
  }
8336
- constructor(data) {
8337
- super(data);
8338
- }
8339
8387
  reset(_data) {}
8340
- set(data, transition) {
8341
- if (data) {
8342
- if (transition) {
8343
- if (transition === "temp") {
8344
- this.lockNormalStyle = true;
8345
- Object.assign(this, data);
8346
- this.lockNormalStyle = false;
8347
- } else this.animate(data, transition);
8348
- } else Object.assign(this, data);
8349
- }
8388
+ set(data, _transition) {
8389
+ if (data) Object.assign(this, data);
8350
8390
  }
8351
8391
  get(name) {
8352
8392
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8392,7 +8432,7 @@ let UI = UI_1 = class UI extends Leaf {
8392
8432
  const data = this.__;
8393
8433
  if (data.path) {
8394
8434
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8395
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8435
+ if (data.__useArrow) PathArrow.addArrows(this);
8396
8436
  } else data.__pathForRender && (data.__pathForRender = undefined);
8397
8437
  }
8398
8438
  __drawRenderPath(canvas) {
@@ -8416,7 +8456,8 @@ let UI = UI_1 = class UI extends Leaf {
8416
8456
  drawImagePlaceholder(canvas, _image) {
8417
8457
  Paint.fill(this.__.placeholderColor, this, canvas);
8418
8458
  }
8419
- animate(_keyframe, _options, _type, _isTemp) {
8459
+ animate(keyframe, _options, _type, _isTemp) {
8460
+ this.set(keyframe);
8420
8461
  return Plugin.need("animate");
8421
8462
  }
8422
8463
  killAnimate(_type, _nextStyle) {}
@@ -8605,9 +8646,6 @@ let Group = class Group extends UI {
8605
8646
  get isBranch() {
8606
8647
  return true;
8607
8648
  }
8608
- constructor(data) {
8609
- super(data);
8610
- }
8611
8649
  reset(data) {
8612
8650
  this.__setBranch();
8613
8651
  super.reset(data);
@@ -8732,7 +8770,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8732
8770
  const canvas = this.canvas = Creator.canvas(config);
8733
8771
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8734
8772
  if (this.isApp) this.__setApp();
8735
- this.__checkAutoLayout(config, parentApp);
8773
+ this.__checkAutoLayout();
8736
8774
  this.view = canvas.view;
8737
8775
  if (!parentApp) {
8738
8776
  this.selector = Creator.selector(this);
@@ -8831,7 +8869,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8831
8869
  this.leafer = leafer;
8832
8870
  this.__level = 1;
8833
8871
  }
8834
- __checkAutoLayout(config, parentApp) {
8872
+ __checkAutoLayout() {
8873
+ const {config: config, parentApp: parentApp} = this;
8835
8874
  if (!parentApp) {
8836
8875
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8837
8876
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8848,7 +8887,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8848
8887
  } else if (attrName === "zIndex") {
8849
8888
  this.canvas.zIndex = newValue;
8850
8889
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8851
- }
8890
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8891
+ mode: newValue
8892
+ });
8852
8893
  }
8853
8894
  return super.__setAttr(attrName, newValue);
8854
8895
  }
@@ -8857,9 +8898,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8857
8898
  return super.__getAttr(attrName);
8858
8899
  }
8859
8900
  __changeCanvasSize(attrName, newValue) {
8860
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8861
- data[attrName] = this.config[attrName] = newValue;
8862
- if (newValue) this.canvas.stopAutoLayout();
8901
+ const {config: config, canvas: canvas} = this;
8902
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8903
+ data[attrName] = config[attrName] = newValue;
8904
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8863
8905
  this.__doResize(data);
8864
8906
  }
8865
8907
  __changeFill(newValue) {
@@ -9006,9 +9048,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9006
9048
  if (!this.parent) {
9007
9049
  if (this.selector) this.selector.destroy();
9008
9050
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
9009
- this.canvasManager.destroy();
9051
+ if (this.canvasManager) this.canvasManager.destroy();
9010
9052
  }
9011
- this.canvas.destroy();
9053
+ if (this.canvas) this.canvas.destroy();
9012
9054
  this.config.view = this.view = this.parentApp = null;
9013
9055
  if (this.userConfig) this.userConfig.view = null;
9014
9056
  super.destroy();
@@ -9030,15 +9072,14 @@ __decorate([ dataProcessor(LeaferData) ], Leafer.prototype, "__", void 0);
9030
9072
 
9031
9073
  __decorate([ boundsType() ], Leafer.prototype, "pixelRatio", void 0);
9032
9074
 
9075
+ __decorate([ dataType("normal") ], Leafer.prototype, "mode", void 0);
9076
+
9033
9077
  Leafer = Leafer_1 = __decorate([ registerUI() ], Leafer);
9034
9078
 
9035
9079
  let Rect = class Rect extends UI {
9036
9080
  get __tag() {
9037
9081
  return "Rect";
9038
9082
  }
9039
- constructor(data) {
9040
- super(data);
9041
- }
9042
9083
  };
9043
9084
 
9044
9085
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9170,9 +9211,6 @@ let Frame = class Frame extends Box {
9170
9211
  get isFrame() {
9171
9212
  return true;
9172
9213
  }
9173
- constructor(data) {
9174
- super(data);
9175
- }
9176
9214
  };
9177
9215
 
9178
9216
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9189,9 +9227,6 @@ let Ellipse = class Ellipse extends UI {
9189
9227
  get __tag() {
9190
9228
  return "Ellipse";
9191
9229
  }
9192
- constructor(data) {
9193
- super(data);
9194
- }
9195
9230
  __updatePath() {
9196
9231
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9197
9232
  const rx = width / 2, ry = height / 2;
@@ -9231,98 +9266,29 @@ __decorate([ pathType(0) ], Ellipse.prototype, "endAngle", void 0);
9231
9266
 
9232
9267
  Ellipse = __decorate([ registerUI() ], Ellipse);
9233
9268
 
9234
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
9235
-
9236
- const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9237
-
9238
- const {toBounds: toBounds$1} = PathBounds;
9239
-
9240
- let Line = class Line extends UI {
9241
- get __tag() {
9242
- return "Line";
9243
- }
9244
- get toPoint() {
9245
- const {width: width, rotation: rotation} = this.__;
9246
- const to = getPointData();
9247
- if (width) to.x = width;
9248
- if (rotation) rotate$3(to, rotation);
9249
- return to;
9250
- }
9251
- set toPoint(value) {
9252
- this.width = getDistance$3(defaultPoint, value);
9253
- this.rotation = getAngle$2(defaultPoint, value);
9254
- if (this.height) this.height = 0;
9255
- }
9256
- constructor(data) {
9257
- super(data);
9258
- }
9259
- __updatePath() {
9260
- const data = this.__;
9261
- const path = data.path = [];
9262
- if (data.points) {
9263
- drawPoints$1(path, data.points, false, data.closed);
9264
- } else {
9265
- moveTo$2(path, 0, 0);
9266
- lineTo$2(path, this.width, 0);
9267
- }
9268
- }
9269
- __updateRenderPath() {
9270
- const data = this.__;
9271
- if (!this.pathInputed && data.points && data.curve) {
9272
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9273
- if (data.__useArrow) PathArrow.addArrows(this, false);
9274
- } else super.__updateRenderPath();
9275
- }
9276
- __updateBoxBounds() {
9277
- if (this.points) {
9278
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
9279
- } else super.__updateBoxBounds();
9280
- }
9281
- };
9282
-
9283
- __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9284
-
9285
- __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9286
-
9287
- __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9288
-
9289
- __decorate([ pathType() ], Line.prototype, "points", void 0);
9290
-
9291
- __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9292
-
9293
- __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9294
-
9295
- Line = __decorate([ registerUI() ], Line);
9296
-
9297
9269
  const {sin: sin$2, cos: cos$2, PI: PI$2} = Math;
9298
9270
 
9299
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
9300
-
9301
- const line = Line.prototype;
9271
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
9302
9272
 
9303
9273
  let Polygon = class Polygon extends UI {
9304
9274
  get __tag() {
9305
9275
  return "Polygon";
9306
9276
  }
9307
- constructor(data) {
9308
- super(data);
9309
- }
9310
9277
  __updatePath() {
9311
- const path = this.__.path = [];
9312
- if (this.__.points) {
9313
- drawPoints(path, this.__.points, false, true);
9278
+ const data = this.__;
9279
+ const path = data.path = [];
9280
+ if (data.points) {
9281
+ drawPoints$1(path, data.points, data.curve, true);
9314
9282
  } else {
9315
- const {width: width, height: height, sides: sides} = this.__;
9283
+ const {width: width, height: height, sides: sides} = data;
9316
9284
  const rx = width / 2, ry = height / 2;
9317
- moveTo$1(path, rx, 0);
9285
+ moveTo$2(path, rx, 0);
9318
9286
  for (let i = 1; i < sides; i++) {
9319
- lineTo$1(path, rx + rx * sin$2(i * 2 * PI$2 / sides), ry - ry * cos$2(i * 2 * PI$2 / sides));
9287
+ lineTo$2(path, rx + rx * sin$2(i * 2 * PI$2 / sides), ry - ry * cos$2(i * 2 * PI$2 / sides));
9320
9288
  }
9321
9289
  closePath$1(path);
9322
9290
  }
9323
9291
  }
9324
- __updateRenderPath() {}
9325
- __updateBoxBounds() {}
9326
9292
  };
9327
9293
 
9328
9294
  __decorate([ dataProcessor(PolygonData) ], Polygon.prototype, "__", void 0);
@@ -9333,30 +9299,23 @@ __decorate([ pathType() ], Polygon.prototype, "points", void 0);
9333
9299
 
9334
9300
  __decorate([ pathType(0) ], Polygon.prototype, "curve", void 0);
9335
9301
 
9336
- __decorate([ rewrite(line.__updateRenderPath) ], Polygon.prototype, "__updateRenderPath", null);
9337
-
9338
- __decorate([ rewrite(line.__updateBoxBounds) ], Polygon.prototype, "__updateBoxBounds", null);
9339
-
9340
9302
  Polygon = __decorate([ rewriteAble(), registerUI() ], Polygon);
9341
9303
 
9342
9304
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
9343
9305
 
9344
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
9306
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
9345
9307
 
9346
9308
  let Star = class Star extends UI {
9347
9309
  get __tag() {
9348
9310
  return "Star";
9349
9311
  }
9350
- constructor(data) {
9351
- super(data);
9352
- }
9353
9312
  __updatePath() {
9354
9313
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9355
9314
  const rx = width / 2, ry = height / 2;
9356
9315
  const path = this.__.path = [];
9357
- moveTo(path, rx, 0);
9316
+ moveTo$1(path, rx, 0);
9358
9317
  for (let i = 1; i < corners * 2; i++) {
9359
- 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));
9318
+ 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));
9360
9319
  }
9361
9320
  closePath(path);
9362
9321
  }
@@ -9370,6 +9329,52 @@ __decorate([ pathType(.382) ], Star.prototype, "innerRadius", void 0);
9370
9329
 
9371
9330
  Star = __decorate([ registerUI() ], Star);
9372
9331
 
9332
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
9333
+
9334
+ const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9335
+
9336
+ let Line = class Line extends UI {
9337
+ get __tag() {
9338
+ return "Line";
9339
+ }
9340
+ get toPoint() {
9341
+ const {width: width, rotation: rotation} = this.__;
9342
+ const to = getPointData();
9343
+ if (width) to.x = width;
9344
+ if (rotation) rotate$3(to, rotation);
9345
+ return to;
9346
+ }
9347
+ set toPoint(value) {
9348
+ this.width = getDistance$3(defaultPoint, value);
9349
+ this.rotation = getAngle$2(defaultPoint, value);
9350
+ if (this.height) this.height = 0;
9351
+ }
9352
+ __updatePath() {
9353
+ const data = this.__;
9354
+ const path = data.path = [];
9355
+ if (data.points) {
9356
+ drawPoints(path, data.points, data.curve, data.closed);
9357
+ } else {
9358
+ moveTo(path, 0, 0);
9359
+ lineTo(path, this.width, 0);
9360
+ }
9361
+ }
9362
+ };
9363
+
9364
+ __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
9365
+
9366
+ __decorate([ affectStrokeBoundsType("center") ], Line.prototype, "strokeAlign", void 0);
9367
+
9368
+ __decorate([ boundsType(0) ], Line.prototype, "height", void 0);
9369
+
9370
+ __decorate([ pathType() ], Line.prototype, "points", void 0);
9371
+
9372
+ __decorate([ pathType(0) ], Line.prototype, "curve", void 0);
9373
+
9374
+ __decorate([ pathType(false) ], Line.prototype, "closed", void 0);
9375
+
9376
+ Line = __decorate([ registerUI() ], Line);
9377
+
9373
9378
  let Image = class Image extends Rect {
9374
9379
  get __tag() {
9375
9380
  return "Image";
@@ -9382,9 +9387,6 @@ let Image = class Image extends Rect {
9382
9387
  const {fill: fill} = this.__;
9383
9388
  return isArray(fill) && fill[0].image;
9384
9389
  }
9385
- constructor(data) {
9386
- super(data);
9387
- }
9388
9390
  };
9389
9391
 
9390
9392
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9484,9 +9486,6 @@ let Text = class Text extends UI {
9484
9486
  this.updateLayout();
9485
9487
  return this.__.__textDrawData;
9486
9488
  }
9487
- constructor(data) {
9488
- super(data);
9489
- }
9490
9489
  __updateTextDrawData() {
9491
9490
  const data = this.__;
9492
9491
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9523,10 +9522,6 @@ let Text = class Text extends UI {
9523
9522
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9524
9523
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9525
9524
  }
9526
- __onUpdateSize() {
9527
- if (this.__box) this.__box.__onUpdateSize();
9528
- super.__onUpdateSize();
9529
- }
9530
9525
  __updateRenderSpread() {
9531
9526
  let width = super.__updateRenderSpread();
9532
9527
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -9537,6 +9532,11 @@ let Text = class Text extends UI {
9537
9532
  copyAndSpread$1(renderBounds, this.__.__textBoxBounds, renderSpread);
9538
9533
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
9539
9534
  }
9535
+ __updateChange() {
9536
+ super.__updateChange();
9537
+ const box = this.__box;
9538
+ if (box) box.__onUpdateSize(), box.__updateChange();
9539
+ }
9540
9540
  __drawRenderPath(canvas) {
9541
9541
  canvas.font = this.__.__font;
9542
9542
  }
@@ -9619,9 +9619,6 @@ let Path = class Path extends UI {
9619
9619
  get __tag() {
9620
9620
  return "Path";
9621
9621
  }
9622
- constructor(data) {
9623
- super(data);
9624
- }
9625
9622
  };
9626
9623
 
9627
9624
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9634,9 +9631,6 @@ let Pen = class Pen extends Group {
9634
9631
  get __tag() {
9635
9632
  return "Pen";
9636
9633
  }
9637
- constructor(data) {
9638
- super(data);
9639
- }
9640
9634
  setStyle(data) {
9641
9635
  const path = this.pathElement = new Path(data);
9642
9636
  this.pathStyle = data;
@@ -11833,7 +11827,7 @@ function ignoreRender(ui, value) {
11833
11827
 
11834
11828
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11835
11829
 
11836
- const {floor: floor$1, max: max$1, abs: abs$4} = Math;
11830
+ const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
11837
11831
 
11838
11832
  function createPattern(ui, paint, pixelRatio) {
11839
11833
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11843,8 +11837,6 @@ function createPattern(ui, paint, pixelRatio) {
11843
11837
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11844
11838
  scaleX *= pixelRatio;
11845
11839
  scaleY *= pixelRatio;
11846
- const xGap = gap && gap.x * scaleX;
11847
- const yGap = gap && gap.y * scaleY;
11848
11840
  if (sx) {
11849
11841
  sx = abs$4(sx);
11850
11842
  sy = abs$4(sy);
@@ -11861,7 +11853,10 @@ function createPattern(ui, paint, pixelRatio) {
11861
11853
  if (size > Platform.image.maxCacheSize) return false;
11862
11854
  }
11863
11855
  let maxSize = Platform.image.maxPatternSize;
11864
- if (!image.isSVG) {
11856
+ if (image.isSVG) {
11857
+ const ws = width / image.width;
11858
+ if (ws > 1) imageScale = ws / ceil$1(ws);
11859
+ } else {
11865
11860
  const imageSize = image.width * image.height;
11866
11861
  if (maxSize > imageSize) maxSize = imageSize;
11867
11862
  }
@@ -11876,18 +11871,20 @@ function createPattern(ui, paint, pixelRatio) {
11876
11871
  scaleX /= sx;
11877
11872
  scaleY /= sy;
11878
11873
  }
11874
+ const xGap = gap && gap.x * scaleX;
11875
+ const yGap = gap && gap.y * scaleY;
11879
11876
  if (transform || scaleX !== 1 || scaleY !== 1) {
11877
+ const canvasWidth = width + (xGap || 0);
11878
+ const canvasHeight = height + (yGap || 0);
11879
+ scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
11880
+ scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
11880
11881
  if (!imageMatrix) {
11881
11882
  imageMatrix = get$1();
11882
11883
  if (transform) copy$4(imageMatrix, transform);
11883
11884
  }
11884
11885
  scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11885
11886
  }
11886
- if (imageMatrix) {
11887
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11888
- scale$2(imageMatrix, canvasWidth / max$1(floor$1(canvasWidth), 1), canvasHeight / max$1(floor$1(canvasHeight), 1));
11889
- }
11890
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11887
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11891
11888
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11892
11889
  paint.style = pattern;
11893
11890
  paint.patternId = id;
@@ -12129,12 +12126,18 @@ function shadow$1(ui, current, shape) {
12129
12126
  }
12130
12127
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
12131
12128
  }
12132
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12129
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
12133
12130
  if (end && index < end) other.clearWorld(copyBounds);
12134
12131
  });
12135
12132
  other.recycle(copyBounds);
12136
12133
  }
12137
12134
 
12135
+ function getShadowSpread(_ui, shadow) {
12136
+ let width = 0;
12137
+ 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));
12138
+ return width;
12139
+ }
12140
+
12138
12141
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
12139
12142
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
12140
12143
  if (Platform.fullImageShadow) {
@@ -12212,7 +12215,11 @@ const EffectModule = {
12212
12215
  shadow: shadow$1,
12213
12216
  innerShadow: innerShadow,
12214
12217
  blur: blur,
12215
- backgroundBlur: backgroundBlur
12218
+ backgroundBlur: backgroundBlur,
12219
+ getShadowSpread: getShadowSpread,
12220
+ isTransformShadow(_shadow) {
12221
+ return undefined;
12222
+ }
12216
12223
  };
12217
12224
 
12218
12225
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -12720,16 +12727,17 @@ function toTextChar(row) {
12720
12727
  }
12721
12728
 
12722
12729
  function decorationText(drawData, style) {
12723
- let type;
12730
+ let type, offset = 0;
12724
12731
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
12725
12732
  drawData.decorationHeight = fontSize / 11;
12726
12733
  if (isObject(textDecoration)) {
12727
12734
  type = textDecoration.type;
12728
12735
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
12736
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
12729
12737
  } else type = textDecoration;
12730
12738
  switch (type) {
12731
12739
  case "under":
12732
- drawData.decorationY = [ fontSize * .15 ];
12740
+ drawData.decorationY = [ fontSize * .15 + offset ];
12733
12741
  break;
12734
12742
 
12735
12743
  case "delete":
@@ -12737,7 +12745,7 @@ function decorationText(drawData, style) {
12737
12745
  break;
12738
12746
 
12739
12747
  case "under-delete":
12740
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
12748
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
12741
12749
  }
12742
12750
  }
12743
12751
 
@@ -13082,7 +13090,7 @@ class EditSelect extends Group {
13082
13090
  }
13083
13091
  get running() {
13084
13092
  const {editor: editor} = this;
13085
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector;
13093
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
13086
13094
  }
13087
13095
  get isMoveMode() {
13088
13096
  return this.app && this.app.interaction.moveMode;
@@ -13384,17 +13392,13 @@ const EditDataHelper = {
13384
13392
  }
13385
13393
  toPoint(around || align, boxBounds, origin, true);
13386
13394
  if (dragBounds) {
13387
- const allowBounds = dragBounds === "parent" ? target.parent.boxBounds : dragBounds;
13388
- const childBounds = new Bounds(target.__localBoxBounds);
13389
- if (BoundsHelper.includes(new Bounds(allowBounds).spread(.1), childBounds)) {
13390
- childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
13391
- if (!BoundsHelper.includes(allowBounds, childBounds)) {
13392
- const realBounds = childBounds.getIntersect(allowBounds);
13393
- const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
13394
- if (useScaleX) scaleX *= fitScaleX;
13395
- if (useScaleY) scaleY *= fitScaleY;
13396
- }
13397
- }
13395
+ const scaleData = {
13396
+ x: scaleX,
13397
+ y: scaleY
13398
+ };
13399
+ DragBoundsHelper.limitScaleOf(target, origin, scaleData);
13400
+ scaleX = scaleData.x;
13401
+ scaleY = scaleData.y;
13398
13402
  }
13399
13403
  if (useScaleX && widthRange) {
13400
13404
  const nowWidth = boxBounds.width * target.scaleX;
@@ -14955,7 +14959,9 @@ let Editor = class Editor extends Group {
14955
14959
  listenTargetEvents() {
14956
14960
  if (!this.targetEventIds.length) {
14957
14961
  const {app: app, leafer: leafer, targetLeafer: targetLeafer, editMask: editMask} = this;
14958
- 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) ];
14962
+ 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 => {
14963
+ if (data.mode && data.mode !== "normal") this.cancel();
14964
+ }) ];
14959
14965
  if (editMask.visible) editMask.forceRender();
14960
14966
  }
14961
14967
  }
@@ -15614,7 +15620,8 @@ const WheelEventHelper = {
15614
15620
  if (zoom) {
15615
15621
  zoomSpeed = within$2(zoomSpeed, 0, 1);
15616
15622
  const min = event.deltaY ? config.delta.y : config.delta.x;
15617
- scale = within$2(1 - delta / (min * 4) * zoomSpeed, .5, 1.5);
15623
+ const absScale = within$2(1 - abs$2(delta) / (min * 4) * zoomSpeed, .5, 2);
15624
+ scale = delta > 0 ? absScale : 1 / absScale;
15618
15625
  }
15619
15626
  return scale;
15620
15627
  }
@@ -16116,6 +16123,9 @@ let Arrow = class Arrow extends Line {
16116
16123
  super(data);
16117
16124
  this.__.__useArrow = true;
16118
16125
  }
16126
+ static registerArrow(name, data) {
16127
+ PathArrow.register(name, data);
16128
+ }
16119
16129
  };
16120
16130
 
16121
16131
  __decorate([ dataProcessor(ArrowData) ], Arrow.prototype, "__", void 0);
@@ -16297,9 +16307,18 @@ const arrows = {
16297
16307
  mark: mark
16298
16308
  };
16299
16309
 
16300
- function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
16310
+ function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
16311
+ let pathData, scale;
16301
16312
  const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
16302
- const {offset: offset, connect: connect, path: path, dashPath: dashPath} = isObject(arrow) ? arrow : arrows[arrow];
16313
+ if (isObject(arrow)) {
16314
+ if (arrow.type) {
16315
+ scale = arrow.scale;
16316
+ pathData = arrows[arrow.type];
16317
+ } else pathData = arrow;
16318
+ } else {
16319
+ pathData = arrows[arrow];
16320
+ }
16321
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
16303
16322
  let connectX = connect ? connect.x : 0;
16304
16323
  let offsetX = offset ? offset.x : 0;
16305
16324
  const data = [ ...path ];
@@ -16308,9 +16327,10 @@ function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern)
16308
16327
  if (offset) {
16309
16328
  if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
16310
16329
  }
16330
+ if (scale) layout$2(data, 0, 0, scale, scale);
16311
16331
  if (offsetX) layout$2(data, offsetX, 0);
16312
- layout$2(data, to.x, to.y, scale, scale, getAngle(from, to));
16313
- connectOffset.x = (connectX + offsetX) * scale;
16332
+ layout$2(data, to.x, to.y, size, size, getAngle(from, to));
16333
+ connectOffset.x = (connectX + offsetX) * size;
16314
16334
  return data;
16315
16335
  }
16316
16336
 
@@ -16326,8 +16346,9 @@ const last = {}, now = {};
16326
16346
 
16327
16347
  const PathArrowModule = {
16328
16348
  list: arrows,
16329
- addArrows(ui, changeRenderPath) {
16330
- const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
16349
+ addArrows(ui) {
16350
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
16351
+ const clonePathForArrow = !cornerRadius;
16331
16352
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
16332
16353
  while (i < len) {
16333
16354
  command = data[i];
@@ -16342,12 +16363,12 @@ const PathArrowModule = {
16342
16363
  break;
16343
16364
 
16344
16365
  case C$1:
16345
- if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
16366
+ if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
16346
16367
  i += 7;
16347
16368
  break;
16348
16369
 
16349
16370
  case Q:
16350
- if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
16371
+ if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
16351
16372
  i += 5;
16352
16373
  break;
16353
16374
 
@@ -16383,7 +16404,13 @@ const PathArrowModule = {
16383
16404
  break;
16384
16405
 
16385
16406
  case U:
16386
- if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
16407
+ if (count === 1 || i + 6 >= len - 3) {
16408
+ copyPoints(data, last, now, i + 1);
16409
+ if (i + 6 !== len) {
16410
+ now.x -= (now.x - last.x) / 10;
16411
+ now.y -= (now.y - last.y) / 10;
16412
+ }
16413
+ }
16387
16414
  i += 6;
16388
16415
  break;
16389
16416
  }
@@ -16391,7 +16418,7 @@ const PathArrowModule = {
16391
16418
  if (count === 1 && command !== M$1) return;
16392
16419
  if (count === 2 && useStartArrow) copy(second, command === L$1 ? now : last);
16393
16420
  if (i === len) {
16394
- const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
16421
+ const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
16395
16422
  const pathForArrow = ui.__.__pathForArrow = [];
16396
16423
  if (useStartArrow) {
16397
16424
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -16432,6 +16459,12 @@ const PathArrowModule = {
16432
16459
  copy(last, now);
16433
16460
  }
16434
16461
  }
16462
+ },
16463
+ register(name, data) {
16464
+ this.list[name] = data;
16465
+ },
16466
+ get(name) {
16467
+ return this.list[name];
16435
16468
  }
16436
16469
  };
16437
16470
 
@@ -17997,6 +18030,18 @@ UI.addAttr("transition", true, dataType);
17997
18030
 
17998
18031
  UI.addAttr("transitionOut", undefined, dataType);
17999
18032
 
18033
+ ui$3.set = function(data, transition) {
18034
+ if (data) {
18035
+ if (transition) {
18036
+ if (transition === "temp") {
18037
+ this.lockNormalStyle = true;
18038
+ Object.assign(this, data);
18039
+ this.lockNormalStyle = false;
18040
+ } else this.animate(data, transition);
18041
+ } else Object.assign(this, data);
18042
+ }
18043
+ };
18044
+
18000
18045
  ui$3.animate = function(keyframe, options, kill, isTemp) {
18001
18046
  if (isUndefined(keyframe)) return this.__animate;
18002
18047
  const isAnimationList = isArray(keyframe) && !options && kill;
@@ -19196,6 +19241,8 @@ const ExportModule = {
19196
19241
  renderBounds: renderBounds,
19197
19242
  trimBounds: trimBounds
19198
19243
  };
19244
+ const app = leafer && leafer.app;
19245
+ if (app && app.canvasManager) app.canvasManager.clearRecycled();
19199
19246
  }
19200
19247
  } catch (error) {
19201
19248
  result = {
@@ -19313,4 +19360,4 @@ Object.assign(Filter, {
19313
19360
  }
19314
19361
  });
19315
19362
 
19316
- 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, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, 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, 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 };
19363
+ 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, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, 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, 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 };