@leafer/miniapp 1.9.3 → 1.9.5

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.
@@ -54,7 +54,7 @@ function isUndefined(value) {
54
54
  }
55
55
 
56
56
  function isNull(value) {
57
- return value === undefined || value === null;
57
+ return value == null;
58
58
  }
59
59
 
60
60
  function isString(value) {
@@ -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;
@@ -304,6 +307,9 @@ const MathHelper = {
304
307
  num = round$6(num * a) / a;
305
308
  return num === -0 ? 0 : num;
306
309
  },
310
+ sign(num) {
311
+ return num < 0 ? -1 : 1;
312
+ },
307
313
  getScaleData(scale, size, originSize, scaleData) {
308
314
  if (!scaleData) scaleData = {};
309
315
  if (size) {
@@ -659,7 +665,7 @@ const M$a = MatrixHelper;
659
665
 
660
666
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
661
667
 
662
- const {sin: sin$5, cos: cos$5, abs: abs$6, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
668
+ const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
663
669
 
664
670
  const PointHelper = {
665
671
  defaultPoint: getPointData(),
@@ -752,8 +758,8 @@ const PointHelper = {
752
758
  return getDistanceFrom(t.x, t.y, point.x, point.y);
753
759
  },
754
760
  getDistanceFrom(x1, y1, x2, y2) {
755
- const x = abs$6(x2 - x1);
756
- const y = abs$6(y2 - y1);
761
+ const x = abs$7(x2 - x1);
762
+ const y = abs$7(y2 - y1);
757
763
  return sqrt$4(x * x + y * y);
758
764
  },
759
765
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -1131,13 +1137,13 @@ const AlignHelper = {
1131
1137
  }
1132
1138
  };
1133
1139
 
1134
- 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;
1135
1141
 
1136
1142
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1137
1143
 
1138
1144
  const {float: float$1, fourNumber: fourNumber$1} = MathHelper;
1139
1145
 
1140
- const {floor: floor$3, ceil: ceil$2} = Math;
1146
+ const {floor: floor$3, ceil: ceil$3} = Math;
1141
1147
 
1142
1148
  let right$4, bottom$3, boundsRight, boundsBottom;
1143
1149
 
@@ -1266,7 +1272,7 @@ const BoundsHelper = {
1266
1272
  point$2.x = t.x;
1267
1273
  toOuterPoint$2(matrix, point$2, toPoint$5);
1268
1274
  addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
1269
- toBounds$4(tempPointBounds$1, to);
1275
+ toBounds$3(tempPointBounds$1, to);
1270
1276
  }
1271
1277
  },
1272
1278
  toInnerOf(t, matrix, to) {
@@ -1304,8 +1310,8 @@ const BoundsHelper = {
1304
1310
  const {x: x, y: y} = t;
1305
1311
  t.x = floor$3(t.x);
1306
1312
  t.y = floor$3(t.y);
1307
- t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1308
- 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);
1309
1315
  },
1310
1316
  unsign(t) {
1311
1317
  if (t.width < 0) {
@@ -1365,7 +1371,7 @@ const BoundsHelper = {
1365
1371
  },
1366
1372
  setPoints(t, points) {
1367
1373
  points.forEach((point, index) => index === 0 ? setPoint$5(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
1368
- toBounds$4(tempPointBounds$1, t);
1374
+ toBounds$3(tempPointBounds$1, t);
1369
1375
  },
1370
1376
  setPoint(t, point) {
1371
1377
  B.set(t, point.x, point.y);
@@ -2218,15 +2224,15 @@ class LeaferCanvasBase extends Canvas$1 {
2218
2224
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2219
2225
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2220
2226
  this.bounds = new Bounds(0, 0, this.width, this.height);
2221
- if (this.context && !this.unreal) {
2222
- this.updateViewSize();
2223
- this.smooth = this.config.smooth;
2224
- }
2227
+ this.updateViewSize();
2225
2228
  this.updateClientBounds();
2226
- if (this.context && !this.unreal && takeCanvas) {
2227
- this.clearWorld(takeCanvas.bounds);
2228
- this.copyWorld(takeCanvas);
2229
- 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
+ }
2230
2236
  }
2231
2237
  }
2232
2238
  updateViewSize() {}
@@ -2540,7 +2546,7 @@ const RectHelper = {
2540
2546
  }
2541
2547
  };
2542
2548
 
2543
- const {sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$1, abs: abs$5, 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;
2544
2550
 
2545
2551
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2546
2552
 
@@ -2611,9 +2617,11 @@ const BezierHelper = {
2611
2617
  const CBy = toY - y1;
2612
2618
  let startRadian = atan2$1(BAy, BAx);
2613
2619
  let endRadian = atan2$1(CBy, CBx);
2620
+ const lenBA = hypot(BAx, BAy);
2621
+ const lenCB = hypot(CBx, CBy);
2614
2622
  let totalRadian = endRadian - startRadian;
2615
2623
  if (totalRadian < 0) totalRadian += PI2;
2616
- if (totalRadian === PI$3 || abs$5(BAx + BAy) < 1e-12 || abs$5(CBx + CBy) < 1e-12) {
2624
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$6(totalRadian - PI$3) < 1e-12) {
2617
2625
  if (data) data.push(L$a, x1, y1);
2618
2626
  if (setPointBounds) {
2619
2627
  setPoint$4(setPointBounds, fromX, fromY);
@@ -2646,7 +2654,7 @@ const BezierHelper = {
2646
2654
  let totalRadian = endRadian - startRadian;
2647
2655
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2648
2656
  if (anticlockwise) totalRadian -= PI2;
2649
- const parts = ceil$1(abs$5(totalRadian / PI_2));
2657
+ const parts = ceil$2(abs$6(totalRadian / PI_2));
2650
2658
  const partRadian = totalRadian / parts;
2651
2659
  const partRadian4Sin = sin$4(partRadian / 4);
2652
2660
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -3113,7 +3121,7 @@ const {M: M$7, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F
3113
3121
 
3114
3122
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
3115
3123
 
3116
- const {tan: tan, min: min, abs: abs$4} = Math;
3124
+ const {tan: tan, min: min, abs: abs$5} = Math;
3117
3125
 
3118
3126
  const startPoint = {};
3119
3127
 
@@ -3171,7 +3179,7 @@ const PathCommandDataHelper = {
3171
3179
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3172
3180
  if (!isUndefined(lastX)) {
3173
3181
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3174
- radius = min(radius, min(d / 2, d / 2 * abs$4(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3182
+ radius = min(radius, min(d / 2, d / 2 * abs$5(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3175
3183
  }
3176
3184
  data.push(U$4, x1, y1, x2, y2, radius);
3177
3185
  },
@@ -3205,11 +3213,7 @@ class PathCreator {
3205
3213
  this.set(path);
3206
3214
  }
3207
3215
  set(path) {
3208
- if (path) {
3209
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3210
- } else {
3211
- this.__path = [];
3212
- }
3216
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3213
3217
  return this;
3214
3218
  }
3215
3219
  beginPath() {
@@ -3377,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
3377
3381
 
3378
3382
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3379
3383
 
3380
- 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;
3381
3385
 
3382
3386
  const debug$d = Debug.get("PathBounds");
3383
3387
 
@@ -3392,7 +3396,7 @@ const setEndPoint = {};
3392
3396
  const PathBounds = {
3393
3397
  toBounds(data, setBounds) {
3394
3398
  PathBounds.toTwoPointBounds(data, setPointBounds);
3395
- toBounds$3(setPointBounds, setBounds);
3399
+ toBounds$2(setPointBounds, setBounds);
3396
3400
  },
3397
3401
  toTwoPointBounds(data, setPointBounds) {
3398
3402
  if (!data || !data.length) return setPoint$3(setPointBounds, 0, 0);
@@ -3579,14 +3583,18 @@ const PathCorner = {
3579
3583
  }
3580
3584
  };
3581
3585
 
3582
- PathHelper.creator = new PathCreator;
3586
+ function path(path) {
3587
+ return new PathCreator(path);
3588
+ }
3589
+
3590
+ const pen = path();
3591
+
3592
+ PathHelper.creator = path();
3583
3593
 
3584
3594
  PathHelper.parse = PathConvert.parse;
3585
3595
 
3586
3596
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3587
3597
 
3588
- const pen = new PathCreator;
3589
-
3590
3598
  const {drawRoundRect: drawRoundRect} = RectHelper;
3591
3599
 
3592
3600
  function roundRect(drawer) {
@@ -3951,7 +3959,7 @@ const ImageManager = {
3951
3959
  return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3952
3960
  },
3953
3961
  isFormat(format, config) {
3954
- if (config.format === format) return true;
3962
+ if (config.format) return config.format === format;
3955
3963
  const {url: url} = config;
3956
3964
  if (url.startsWith("data:")) {
3957
3965
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -3969,7 +3977,7 @@ const I$1 = ImageManager;
3969
3977
 
3970
3978
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3971
3979
 
3972
- const {floor: floor$2, max: max$1} = Math;
3980
+ const {floor: floor$2, max: max$2} = Math;
3973
3981
 
3974
3982
  class LeaferImage {
3975
3983
  get url() {
@@ -4045,7 +4053,7 @@ class LeaferImage {
4045
4053
  getFull(_filters) {
4046
4054
  return this.view;
4047
4055
  }
4048
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
4056
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
4049
4057
  width || (width = this.width);
4050
4058
  height || (height = this.height);
4051
4059
  if (this.cache) {
@@ -4058,9 +4066,10 @@ class LeaferImage {
4058
4066
  }
4059
4067
  if (data) return data;
4060
4068
  }
4061
- const canvas = Platform.origin.createCanvas(max$1(floor$2(width + (xGap || 0)), 1), max$1(floor$2(height + (yGap || 0)), 1));
4069
+ const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
4062
4070
  const ctx = canvas.getContext("2d");
4063
4071
  if (opacity) ctx.globalAlpha = opacity;
4072
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
4064
4073
  ctx.drawImage(this.view, 0, 0, width, height);
4065
4074
  this.cache = this.use > 1 ? {
4066
4075
  data: canvas,
@@ -4102,7 +4111,7 @@ function createDescriptor(key, defaultValue) {
4102
4111
  return {
4103
4112
  get() {
4104
4113
  const v = this[privateKey];
4105
- return isUndefined(v) ? defaultValue : v;
4114
+ return v == null ? defaultValue : v;
4106
4115
  },
4107
4116
  set(value) {
4108
4117
  this[privateKey] = value;
@@ -4388,21 +4397,21 @@ function defineDataProcessor(target, key, defaultValue) {
4388
4397
  };
4389
4398
  } else if (typeof defaultValue === "function") {
4390
4399
  property.get = function() {
4391
- let v = this[computedKey];
4392
- return v === undefined ? defaultValue(this.__leaf) : v;
4400
+ const v = this[computedKey];
4401
+ return v == null ? defaultValue(this.__leaf) : v;
4393
4402
  };
4394
4403
  } else if (isObject(defaultValue)) {
4395
4404
  const isEmpty = isEmptyData(defaultValue);
4396
4405
  property.get = function() {
4397
- let v = this[computedKey];
4398
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4406
+ const v = this[computedKey];
4407
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4399
4408
  };
4400
4409
  }
4401
4410
  const isBox = target.isBranchLeaf;
4402
4411
  if (key === "width") {
4403
4412
  property.get = function() {
4404
4413
  const v = this[computedKey];
4405
- if (v === undefined) {
4414
+ if (v == null) {
4406
4415
  const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4407
4416
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width;
4408
4417
  if (naturalWidth) return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
@@ -4412,7 +4421,7 @@ function defineDataProcessor(target, key, defaultValue) {
4412
4421
  } else if (key === "height") {
4413
4422
  property.get = function() {
4414
4423
  const v = this[computedKey];
4415
- if (v === undefined) {
4424
+ if (v == null) {
4416
4425
  const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4417
4426
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height;
4418
4427
  if (naturalHeight) return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
@@ -4712,8 +4721,9 @@ const L$4 = LeafHelper;
4712
4721
 
4713
4722
  const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$4, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L$4;
4714
4723
 
4715
- function getTempLocal(t, world) {
4716
- 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;
4717
4727
  }
4718
4728
 
4719
4729
  const LeafBoundsHelper = {
@@ -5172,7 +5182,7 @@ class LeafLayout {
5172
5182
  }
5173
5183
  boxChange() {
5174
5184
  this.boxChanged = true;
5175
- this.localBoxChanged || this.localBoxChange();
5185
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5176
5186
  this.hitCanvasChanged = true;
5177
5187
  }
5178
5188
  localBoxChange() {
@@ -5206,7 +5216,7 @@ class LeafLayout {
5206
5216
  }
5207
5217
  matrixChange() {
5208
5218
  this.matrixChanged = true;
5209
- this.localBoxChanged || this.localBoxChange();
5219
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5210
5220
  }
5211
5221
  surfaceChange() {
5212
5222
  this.surfaceChanged = true;
@@ -5731,7 +5741,7 @@ const {updateBounds: updateBounds$2} = BranchHelper;
5731
5741
 
5732
5742
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
5733
5743
 
5734
- const {toBounds: toBounds$2} = PathBounds;
5744
+ const {toBounds: toBounds$1} = PathBounds;
5735
5745
 
5736
5746
  const LeafBounds = {
5737
5747
  __updateWorldBounds() {
@@ -5803,8 +5813,8 @@ const LeafBounds = {
5803
5813
  __updateBoxBounds(_secondLayout, _bounds) {
5804
5814
  const b = this.__layout.boxBounds;
5805
5815
  const data = this.__;
5806
- if (data.__pathInputed) {
5807
- toBounds$2(data.path, b);
5816
+ if (data.__usePathBox) {
5817
+ toBounds$1(data.path, b);
5808
5818
  } else {
5809
5819
  b.x = 0;
5810
5820
  b.y = 0;
@@ -6272,10 +6282,10 @@ let Leaf = class Leaf {
6272
6282
  relative.innerToWorld(world, to, distance);
6273
6283
  world = to ? to : world;
6274
6284
  }
6275
- toInnerPoint(this.worldTransform, world, to, distance);
6285
+ toInnerPoint(this.scrollWorldTransform, world, to, distance);
6276
6286
  }
6277
6287
  innerToWorld(inner, to, distance, relative) {
6278
- toOuterPoint(this.worldTransform, inner, to, distance);
6288
+ toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6279
6289
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6280
6290
  }
6281
6291
  getBoxPoint(world, relative, distance, change) {
@@ -6739,7 +6749,7 @@ class LeafLevelList {
6739
6749
  }
6740
6750
  }
6741
6751
 
6742
- const version = "1.9.3";
6752
+ const version = "1.9.5";
6743
6753
 
6744
6754
  class LeaferCanvas extends LeaferCanvasBase {
6745
6755
  get allowBackgroundColor() {
@@ -6793,6 +6803,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6793
6803
  this.view = Platform.origin.createCanvas(1, 1);
6794
6804
  }
6795
6805
  updateViewSize() {
6806
+ if (this.unreal) return;
6796
6807
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6797
6808
  this.view.width = Math.ceil(width * pixelRatio);
6798
6809
  this.view.height = Math.ceil(height * pixelRatio);
@@ -6804,6 +6815,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6804
6815
  });
6805
6816
  }
6806
6817
  startAutoLayout(autoBounds, listener) {
6818
+ if (this.resizeListener) return;
6807
6819
  this.resizeListener = listener;
6808
6820
  if (autoBounds) {
6809
6821
  this.checkSize = this.checkSize.bind(this);
@@ -7313,7 +7325,7 @@ class Renderer {
7313
7325
  this.times = 0;
7314
7326
  this.config = {
7315
7327
  usePartRender: true,
7316
- maxFPS: 60
7328
+ maxFPS: 120
7317
7329
  };
7318
7330
  this.target = target;
7319
7331
  this.canvas = canvas;
@@ -7468,11 +7480,15 @@ class Renderer {
7468
7480
  if (this.requestTime || !target) return;
7469
7481
  if (target.parentApp) return target.parentApp.requestRender(false);
7470
7482
  const requestTime = this.requestTime = Date.now();
7471
- Platform.requestRender(() => {
7472
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7483
+ const render = () => {
7484
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7485
+ const {maxFPS: maxFPS} = this.config;
7486
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7487
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7473
7488
  this.requestTime = 0;
7474
7489
  this.checkRender();
7475
- });
7490
+ };
7491
+ Platform.requestRender(render);
7476
7492
  }
7477
7493
  __onResize(e) {
7478
7494
  if (this.canvas.unreal) return;
@@ -7515,7 +7531,8 @@ class Renderer {
7515
7531
  if (this.target) {
7516
7532
  this.stop();
7517
7533
  this.__removeListenEvents();
7518
- this.target = this.canvas = this.config = null;
7534
+ this.config = {};
7535
+ this.target = this.canvas = null;
7519
7536
  }
7520
7537
  }
7521
7538
  }
@@ -8006,7 +8023,11 @@ class LeaferData extends GroupData {
8006
8023
 
8007
8024
  class FrameData extends BoxData {}
8008
8025
 
8009
- class LineData extends UIData {}
8026
+ class LineData extends UIData {
8027
+ get __usePathBox() {
8028
+ return this.points || this.__pathInputed;
8029
+ }
8030
+ }
8010
8031
 
8011
8032
  class RectData extends UIData {
8012
8033
  get __boxStroke() {
@@ -8020,7 +8041,7 @@ class EllipseData extends UIData {
8020
8041
  }
8021
8042
  }
8022
8043
 
8023
- class PolygonData extends UIData {}
8044
+ class PolygonData extends LineData {}
8024
8045
 
8025
8046
  class StarData extends UIData {}
8026
8047
 
@@ -8330,20 +8351,9 @@ let UI = UI_1 = class UI extends Leaf {
8330
8351
  if (!path) this.__drawPathByBox(pen);
8331
8352
  return pen;
8332
8353
  }
8333
- constructor(data) {
8334
- super(data);
8335
- }
8336
8354
  reset(_data) {}
8337
- set(data, transition) {
8338
- if (data) {
8339
- if (transition) {
8340
- if (transition === "temp") {
8341
- this.lockNormalStyle = true;
8342
- Object.assign(this, data);
8343
- this.lockNormalStyle = false;
8344
- } else this.animate(data, transition);
8345
- } else Object.assign(this, data);
8346
- }
8355
+ set(data, _transition) {
8356
+ if (data) Object.assign(this, data);
8347
8357
  }
8348
8358
  get(name) {
8349
8359
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8389,7 +8399,7 @@ let UI = UI_1 = class UI extends Leaf {
8389
8399
  const data = this.__;
8390
8400
  if (data.path) {
8391
8401
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8392
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8402
+ if (data.__useArrow) PathArrow.addArrows(this);
8393
8403
  } else data.__pathForRender && (data.__pathForRender = undefined);
8394
8404
  }
8395
8405
  __drawRenderPath(canvas) {
@@ -8413,7 +8423,8 @@ let UI = UI_1 = class UI extends Leaf {
8413
8423
  drawImagePlaceholder(canvas, _image) {
8414
8424
  Paint.fill(this.__.placeholderColor, this, canvas);
8415
8425
  }
8416
- animate(_keyframe, _options, _type, _isTemp) {
8426
+ animate(keyframe, _options, _type, _isTemp) {
8427
+ this.set(keyframe);
8417
8428
  return Plugin.need("animate");
8418
8429
  }
8419
8430
  killAnimate(_type, _nextStyle) {}
@@ -8602,9 +8613,6 @@ let Group = class Group extends UI {
8602
8613
  get isBranch() {
8603
8614
  return true;
8604
8615
  }
8605
- constructor(data) {
8606
- super(data);
8607
- }
8608
8616
  reset(data) {
8609
8617
  this.__setBranch();
8610
8618
  super.reset(data);
@@ -8729,7 +8737,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8729
8737
  const canvas = this.canvas = Creator.canvas(config);
8730
8738
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8731
8739
  if (this.isApp) this.__setApp();
8732
- this.__checkAutoLayout(config, parentApp);
8740
+ this.__checkAutoLayout();
8733
8741
  this.view = canvas.view;
8734
8742
  if (!parentApp) {
8735
8743
  this.selector = Creator.selector(this);
@@ -8828,7 +8836,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8828
8836
  this.leafer = leafer;
8829
8837
  this.__level = 1;
8830
8838
  }
8831
- __checkAutoLayout(config, parentApp) {
8839
+ __checkAutoLayout() {
8840
+ const {config: config, parentApp: parentApp} = this;
8832
8841
  if (!parentApp) {
8833
8842
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8834
8843
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8854,9 +8863,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8854
8863
  return super.__getAttr(attrName);
8855
8864
  }
8856
8865
  __changeCanvasSize(attrName, newValue) {
8857
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8858
- data[attrName] = this.config[attrName] = newValue;
8859
- if (newValue) this.canvas.stopAutoLayout();
8866
+ const {config: config, canvas: canvas} = this;
8867
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8868
+ data[attrName] = config[attrName] = newValue;
8869
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8860
8870
  this.__doResize(data);
8861
8871
  }
8862
8872
  __changeFill(newValue) {
@@ -9003,9 +9013,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9003
9013
  if (!this.parent) {
9004
9014
  if (this.selector) this.selector.destroy();
9005
9015
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
9006
- this.canvasManager.destroy();
9016
+ if (this.canvasManager) this.canvasManager.destroy();
9007
9017
  }
9008
- this.canvas.destroy();
9018
+ if (this.canvas) this.canvas.destroy();
9009
9019
  this.config.view = this.view = this.parentApp = null;
9010
9020
  if (this.userConfig) this.userConfig.view = null;
9011
9021
  super.destroy();
@@ -9033,9 +9043,6 @@ let Rect = class Rect extends UI {
9033
9043
  get __tag() {
9034
9044
  return "Rect";
9035
9045
  }
9036
- constructor(data) {
9037
- super(data);
9038
- }
9039
9046
  };
9040
9047
 
9041
9048
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9089,29 +9096,24 @@ let Box = class Box extends Group {
9089
9096
  }
9090
9097
  __updateStrokeBounds() {}
9091
9098
  __updateRenderBounds() {
9092
- let isOverflow;
9099
+ let isOverflow, isScrollMode;
9093
9100
  if (this.children.length) {
9094
- const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout;
9101
+ const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout, {overflow: overflow} = data;
9095
9102
  const childrenRenderBounds = layout.childrenRenderBounds || (layout.childrenRenderBounds = getBoundsData());
9096
9103
  super.__updateRenderBounds(childrenRenderBounds);
9097
- if (data.overflow.includes("scroll")) {
9104
+ if (isScrollMode = overflow.includes("scroll")) {
9098
9105
  add(childrenRenderBounds, boxBounds);
9099
9106
  scroll(childrenRenderBounds, data);
9100
9107
  }
9101
9108
  this.__updateRectRenderBounds();
9102
9109
  isOverflow = !includes$1(boxBounds, childrenRenderBounds);
9103
- if (isOverflow && data.overflow === "show") add(renderBounds, childrenRenderBounds);
9110
+ if (isOverflow && overflow === "show") add(renderBounds, childrenRenderBounds);
9104
9111
  } else this.__updateRectRenderBounds();
9105
9112
  DataHelper.stintSet(this, "isOverflow", isOverflow);
9106
- this.__checkScroll();
9113
+ this.__checkScroll(isScrollMode);
9107
9114
  }
9108
9115
  __updateRectRenderBounds() {}
9109
- __updateWorldBounds() {
9110
- if (this.hasScroller) this.__updateScroll();
9111
- super.__updateWorldBounds();
9112
- }
9113
- __checkScroll() {}
9114
- __updateScroll() {}
9116
+ __checkScroll(_isScrollMode) {}
9115
9117
  __updateRectChange() {}
9116
9118
  __updateChange() {
9117
9119
  super.__updateChange();
@@ -9172,9 +9174,6 @@ let Frame = class Frame extends Box {
9172
9174
  get isFrame() {
9173
9175
  return true;
9174
9176
  }
9175
- constructor(data) {
9176
- super(data);
9177
- }
9178
9177
  };
9179
9178
 
9180
9179
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9191,9 +9190,6 @@ let Ellipse = class Ellipse extends UI {
9191
9190
  get __tag() {
9192
9191
  return "Ellipse";
9193
9192
  }
9194
- constructor(data) {
9195
- super(data);
9196
- }
9197
9193
  __updatePath() {
9198
9194
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9199
9195
  const rx = width / 2, ry = height / 2;
@@ -9237,8 +9233,6 @@ const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathComma
9237
9233
 
9238
9234
  const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9239
9235
 
9240
- const {toBounds: toBounds$1} = PathBounds;
9241
-
9242
9236
  let Line = class Line extends UI {
9243
9237
  get __tag() {
9244
9238
  return "Line";
@@ -9255,31 +9249,16 @@ let Line = class Line extends UI {
9255
9249
  this.rotation = getAngle$2(defaultPoint, value);
9256
9250
  if (this.height) this.height = 0;
9257
9251
  }
9258
- constructor(data) {
9259
- super(data);
9260
- }
9261
9252
  __updatePath() {
9262
9253
  const data = this.__;
9263
9254
  const path = data.path = [];
9264
9255
  if (data.points) {
9265
- drawPoints$1(path, data.points, false, data.closed);
9256
+ drawPoints$1(path, data.points, data.curve, data.closed);
9266
9257
  } else {
9267
9258
  moveTo$2(path, 0, 0);
9268
9259
  lineTo$2(path, this.width, 0);
9269
9260
  }
9270
9261
  }
9271
- __updateRenderPath() {
9272
- const data = this.__;
9273
- if (!this.pathInputed && data.points && data.curve) {
9274
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9275
- if (data.__useArrow) PathArrow.addArrows(this, false);
9276
- } else super.__updateRenderPath();
9277
- }
9278
- __updateBoxBounds() {
9279
- if (this.points) {
9280
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
9281
- } else super.__updateBoxBounds();
9282
- }
9283
9262
  };
9284
9263
 
9285
9264
  __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
@@ -9306,15 +9285,13 @@ let Polygon = class Polygon extends UI {
9306
9285
  get __tag() {
9307
9286
  return "Polygon";
9308
9287
  }
9309
- constructor(data) {
9310
- super(data);
9311
- }
9312
9288
  __updatePath() {
9313
- const path = this.__.path = [];
9314
- if (this.__.points) {
9315
- drawPoints(path, this.__.points, false, true);
9289
+ const data = this.__;
9290
+ const path = data.path = [];
9291
+ if (data.points) {
9292
+ drawPoints(path, data.points, data.curve, true);
9316
9293
  } else {
9317
- const {width: width, height: height, sides: sides} = this.__;
9294
+ const {width: width, height: height, sides: sides} = data;
9318
9295
  const rx = width / 2, ry = height / 2;
9319
9296
  moveTo$1(path, rx, 0);
9320
9297
  for (let i = 1; i < sides; i++) {
@@ -9349,9 +9326,6 @@ let Star = class Star extends UI {
9349
9326
  get __tag() {
9350
9327
  return "Star";
9351
9328
  }
9352
- constructor(data) {
9353
- super(data);
9354
- }
9355
9329
  __updatePath() {
9356
9330
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9357
9331
  const rx = width / 2, ry = height / 2;
@@ -9384,9 +9358,6 @@ let Image = class Image extends Rect {
9384
9358
  const {fill: fill} = this.__;
9385
9359
  return isArray(fill) && fill[0].image;
9386
9360
  }
9387
- constructor(data) {
9388
- super(data);
9389
- }
9390
9361
  };
9391
9362
 
9392
9363
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9486,9 +9457,6 @@ let Text = class Text extends UI {
9486
9457
  this.updateLayout();
9487
9458
  return this.__.__textDrawData;
9488
9459
  }
9489
- constructor(data) {
9490
- super(data);
9491
- }
9492
9460
  __updateTextDrawData() {
9493
9461
  const data = this.__;
9494
9462
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9621,9 +9589,6 @@ let Path = class Path extends UI {
9621
9589
  get __tag() {
9622
9590
  return "Path";
9623
9591
  }
9624
- constructor(data) {
9625
- super(data);
9626
- }
9627
9592
  };
9628
9593
 
9629
9594
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9636,9 +9601,6 @@ let Pen = class Pen extends Group {
9636
9601
  get __tag() {
9637
9602
  return "Pen";
9638
9603
  }
9639
- constructor(data) {
9640
- super(data);
9641
- }
9642
9604
  setStyle(data) {
9643
9605
  const path = this.pathElement = new Path(data);
9644
9606
  this.pathStyle = data;
@@ -11835,7 +11797,7 @@ function ignoreRender(ui, value) {
11835
11797
 
11836
11798
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11837
11799
 
11838
- const {floor: floor$1, max: max, abs: abs$3} = Math;
11800
+ const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
11839
11801
 
11840
11802
  function createPattern(ui, paint, pixelRatio) {
11841
11803
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11845,11 +11807,9 @@ function createPattern(ui, paint, pixelRatio) {
11845
11807
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11846
11808
  scaleX *= pixelRatio;
11847
11809
  scaleY *= pixelRatio;
11848
- const xGap = gap && gap.x * scaleX;
11849
- const yGap = gap && gap.y * scaleY;
11850
11810
  if (sx) {
11851
- sx = abs$3(sx);
11852
- sy = abs$3(sy);
11811
+ sx = abs$4(sx);
11812
+ sy = abs$4(sy);
11853
11813
  imageMatrix = get$1();
11854
11814
  copy$4(imageMatrix, transform);
11855
11815
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -11863,7 +11823,10 @@ function createPattern(ui, paint, pixelRatio) {
11863
11823
  if (size > Platform.image.maxCacheSize) return false;
11864
11824
  }
11865
11825
  let maxSize = Platform.image.maxPatternSize;
11866
- if (!image.isSVG) {
11826
+ if (image.isSVG) {
11827
+ const ws = width / image.width;
11828
+ if (ws > 1) imageScale = ws / ceil$1(ws);
11829
+ } else {
11867
11830
  const imageSize = image.width * image.height;
11868
11831
  if (maxSize > imageSize) maxSize = imageSize;
11869
11832
  }
@@ -11878,18 +11841,20 @@ function createPattern(ui, paint, pixelRatio) {
11878
11841
  scaleX /= sx;
11879
11842
  scaleY /= sy;
11880
11843
  }
11844
+ const xGap = gap && gap.x * scaleX;
11845
+ const yGap = gap && gap.y * scaleY;
11881
11846
  if (transform || scaleX !== 1 || scaleY !== 1) {
11847
+ const canvasWidth = width + (xGap || 0);
11848
+ const canvasHeight = height + (yGap || 0);
11849
+ scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
11850
+ scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
11882
11851
  if (!imageMatrix) {
11883
11852
  imageMatrix = get$1();
11884
11853
  if (transform) copy$4(imageMatrix, transform);
11885
11854
  }
11886
11855
  scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11887
11856
  }
11888
- if (imageMatrix) {
11889
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11890
- scale$2(imageMatrix, canvasWidth / max(floor$1(canvasWidth), 1), canvasHeight / max(floor$1(canvasHeight), 1));
11891
- }
11892
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11857
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11893
11858
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11894
11859
  paint.style = pattern;
11895
11860
  paint.patternId = id;
@@ -12917,7 +12882,7 @@ function mergeConfigAttr() {
12917
12882
  return (target, key) => {
12918
12883
  defineKey(target, key, {
12919
12884
  get() {
12920
- const {config: config, element: element, dragPoint: dragPoint, editBox: editBox} = this, mergeConfig = Object.assign({}, config);
12885
+ const {config: config, element: element, dragPoint: dragPoint, editBox: editBox, app: app} = this, mergeConfig = Object.assign({}, config);
12921
12886
  if (element && element.editConfig) Object.assign(mergeConfig, element.editConfig);
12922
12887
  if (editBox.config) Object.assign(mergeConfig, editBox.config);
12923
12888
  if (dragPoint) {
@@ -12928,13 +12893,14 @@ function mergeConfigAttr() {
12928
12893
  isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
12929
12894
  }
12930
12895
  }
12896
+ if (isUndefined(mergeConfig.dragLimitAnimate)) mergeConfig.dragLimitAnimate = app && app.config.pointer.dragLimitAnimate;
12931
12897
  return this.mergedConfig = mergeConfig;
12932
12898
  }
12933
12899
  });
12934
12900
  };
12935
12901
  }
12936
12902
 
12937
- const {abs: abs$2} = Math;
12903
+ const {abs: abs$3} = Math;
12938
12904
 
12939
12905
  const {copy: copy$2, scale: scale$1} = MatrixHelper;
12940
12906
 
@@ -12977,7 +12943,7 @@ class Stroker extends UI {
12977
12943
  leaf = list[i];
12978
12944
  const {worldTransform: worldTransform, worldRenderBounds: worldRenderBounds} = leaf;
12979
12945
  if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
12980
- const aScaleX = abs$2(worldTransform.scaleX), aScaleY = abs$2(worldTransform.scaleY);
12946
+ const aScaleX = abs$3(worldTransform.scaleX), aScaleY = abs$3(worldTransform.scaleY);
12981
12947
  copy$2(matrix$1, worldTransform);
12982
12948
  matrix$1.half = strokeWidth % 2;
12983
12949
  if (aScaleX !== aScaleY) {
@@ -12991,7 +12957,7 @@ class Stroker extends UI {
12991
12957
  canvas.setWorld(matrix$1, options.matrix);
12992
12958
  canvas.beginPath();
12993
12959
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12994
- data.strokeWidth = strokeWidth / abs$2(worldTransform.scaleX);
12960
+ data.strokeWidth = strokeWidth / abs$3(worldTransform.scaleX);
12995
12961
  }
12996
12962
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
12997
12963
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
@@ -13285,7 +13251,7 @@ const {topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bot
13285
13251
 
13286
13252
  const {toPoint: toPoint} = AroundHelper;
13287
13253
 
13288
- const {within: within$2} = MathHelper;
13254
+ const {within: within$3, sign: sign$1} = MathHelper;
13289
13255
 
13290
13256
  const EditDataHelper = {
13291
13257
  getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
@@ -13298,8 +13264,8 @@ const EditDataHelper = {
13298
13264
  }
13299
13265
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
13300
13266
  const originChangedScaleY = target.scaleY / startBounds.scaleY;
13301
- const signX = originChangedScaleX < 0 ? -1 : 1;
13302
- const signY = originChangedScaleY < 0 ? -1 : 1;
13267
+ const signX = sign$1(originChangedScaleX);
13268
+ const signY = sign$1(originChangedScaleY);
13303
13269
  const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
13304
13270
  const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
13305
13271
  totalMove.x *= scaleMode ? originChangedScaleX : signX;
@@ -13399,14 +13365,14 @@ const EditDataHelper = {
13399
13365
  }
13400
13366
  if (useScaleX && widthRange) {
13401
13367
  const nowWidth = boxBounds.width * target.scaleX;
13402
- scaleX = within$2(nowWidth * scaleX, widthRange) / nowWidth;
13368
+ scaleX = within$3(nowWidth * scaleX, widthRange) / nowWidth;
13403
13369
  }
13404
13370
  if (useScaleY && heightRange) {
13405
13371
  const nowHeight = boxBounds.height * target.scaleY;
13406
- scaleY = within$2(nowHeight * scaleY, heightRange) / nowHeight;
13372
+ scaleY = within$3(nowHeight * scaleY, heightRange) / nowHeight;
13407
13373
  }
13408
- if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width;
13409
- if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height;
13374
+ if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = sign$1(scaleX) / worldBoxBounds.width;
13375
+ if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = sign$1(scaleY) / worldBoxBounds.height;
13410
13376
  if (lockRatio && scaleX !== scaleY) scaleY = scaleX = Math.min(scaleX, scaleY);
13411
13377
  return {
13412
13378
  origin: origin,
@@ -13908,7 +13874,7 @@ class EditBox extends Group {
13908
13874
  if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
13909
13875
  }
13910
13876
  onDragEnd(e) {
13911
- if (this.moving) this.transformTool.onMove(e);
13877
+ if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
13912
13878
  this.dragPoint = null;
13913
13879
  this.resetDoing();
13914
13880
  const {name: name, pointType: pointType} = e.current;
@@ -14428,9 +14394,8 @@ EditorSkewEvent.SKEW = "editor.skew";
14428
14394
 
14429
14395
  class TransformTool {
14430
14396
  onMove(e) {
14431
- const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData, app: app} = this.editBox;
14397
+ const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
14432
14398
  let move, {dragLimitAnimate: dragLimitAnimate} = mergeConfig;
14433
- if (isUndefined(dragLimitAnimate)) dragLimitAnimate = app && app.config.pointer.dragLimitAnimate;
14434
14399
  const isMoveEnd = e.type === MoveEvent.END || e.type === DragEvent.END;
14435
14400
  const axisDrag = isString(target.draggable);
14436
14401
  const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
@@ -15584,6 +15549,8 @@ const MultiTouchHelper = {
15584
15549
  }
15585
15550
  };
15586
15551
 
15552
+ const {abs: abs$2, max: max} = Math, {sign: sign, within: within$2} = MathHelper;
15553
+
15587
15554
  const WheelEventHelper = {
15588
15555
  getMove(event, config) {
15589
15556
  let {moveSpeed: moveSpeed} = config;
@@ -15592,8 +15559,9 @@ const WheelEventHelper = {
15592
15559
  deltaX = deltaY;
15593
15560
  deltaY = 0;
15594
15561
  }
15595
- if (deltaX > 50) deltaX = Math.max(50, deltaX / 3);
15596
- if (deltaY > 50) deltaY = Math.max(50, deltaY / 3);
15562
+ const absX = abs$2(deltaX), absY = abs$2(deltaY);
15563
+ if (absX > 50) deltaX = max(50, absX / 3) * sign(deltaX);
15564
+ if (absY > 50) deltaY = max(50, absY / 3) * sign(deltaY);
15597
15565
  return {
15598
15566
  x: -deltaX * moveSpeed * 2,
15599
15567
  y: -deltaY * moveSpeed * 2
@@ -15611,11 +15579,10 @@ const WheelEventHelper = {
15611
15579
  zoom = !event.shiftKey && (event.metaKey || event.ctrlKey);
15612
15580
  }
15613
15581
  if (zoom) {
15614
- zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
15582
+ zoomSpeed = within$2(zoomSpeed, 0, 1);
15615
15583
  const min = event.deltaY ? config.delta.y : config.delta.x;
15616
- scale = 1 - delta / (min * 4) * zoomSpeed;
15617
- if (scale < .5) scale = .5;
15618
- if (scale >= 1.5) scale = 1.5;
15584
+ const absScale = within$2(1 - abs$2(delta) / (min * 4) * zoomSpeed, .5, 2);
15585
+ scale = delta > 0 ? absScale : 1 / absScale;
15619
15586
  }
15620
15587
  return scale;
15621
15588
  }
@@ -16117,6 +16084,9 @@ let Arrow = class Arrow extends Line {
16117
16084
  super(data);
16118
16085
  this.__.__useArrow = true;
16119
16086
  }
16087
+ static registerArrow(name, data) {
16088
+ PathArrow.register(name, data);
16089
+ }
16120
16090
  };
16121
16091
 
16122
16092
  __decorate([ dataProcessor(ArrowData) ], Arrow.prototype, "__", void 0);
@@ -16298,9 +16268,18 @@ const arrows = {
16298
16268
  mark: mark
16299
16269
  };
16300
16270
 
16301
- function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
16271
+ function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
16272
+ let pathData, scale;
16302
16273
  const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
16303
- const {offset: offset, connect: connect, path: path, dashPath: dashPath} = isObject(arrow) ? arrow : arrows[arrow];
16274
+ if (isObject(arrow)) {
16275
+ if (arrow.type) {
16276
+ scale = arrow.scale;
16277
+ pathData = arrows[arrow.type];
16278
+ } else pathData = arrow;
16279
+ } else {
16280
+ pathData = arrows[arrow];
16281
+ }
16282
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
16304
16283
  let connectX = connect ? connect.x : 0;
16305
16284
  let offsetX = offset ? offset.x : 0;
16306
16285
  const data = [ ...path ];
@@ -16309,9 +16288,10 @@ function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern)
16309
16288
  if (offset) {
16310
16289
  if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
16311
16290
  }
16291
+ if (scale) layout$2(data, 0, 0, scale, scale);
16312
16292
  if (offsetX) layout$2(data, offsetX, 0);
16313
- layout$2(data, to.x, to.y, scale, scale, getAngle(from, to));
16314
- connectOffset.x = (connectX + offsetX) * scale;
16293
+ layout$2(data, to.x, to.y, size, size, getAngle(from, to));
16294
+ connectOffset.x = (connectX + offsetX) * size;
16315
16295
  return data;
16316
16296
  }
16317
16297
 
@@ -16327,8 +16307,9 @@ const last = {}, now = {};
16327
16307
 
16328
16308
  const PathArrowModule = {
16329
16309
  list: arrows,
16330
- addArrows(ui, changeRenderPath) {
16331
- const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
16310
+ addArrows(ui) {
16311
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
16312
+ const clonePathForArrow = !cornerRadius;
16332
16313
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
16333
16314
  while (i < len) {
16334
16315
  command = data[i];
@@ -16343,12 +16324,12 @@ const PathArrowModule = {
16343
16324
  break;
16344
16325
 
16345
16326
  case C$1:
16346
- if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
16327
+ if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
16347
16328
  i += 7;
16348
16329
  break;
16349
16330
 
16350
16331
  case Q:
16351
- if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
16332
+ if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
16352
16333
  i += 5;
16353
16334
  break;
16354
16335
 
@@ -16384,7 +16365,13 @@ const PathArrowModule = {
16384
16365
  break;
16385
16366
 
16386
16367
  case U:
16387
- if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
16368
+ if (count === 1 || i + 6 >= len - 3) {
16369
+ copyPoints(data, last, now, i + 1);
16370
+ if (i + 6 !== len) {
16371
+ now.x -= (now.x - last.x) / 10;
16372
+ now.y -= (now.y - last.y) / 10;
16373
+ }
16374
+ }
16388
16375
  i += 6;
16389
16376
  break;
16390
16377
  }
@@ -16392,7 +16379,7 @@ const PathArrowModule = {
16392
16379
  if (count === 1 && command !== M$1) return;
16393
16380
  if (count === 2 && useStartArrow) copy(second, command === L$1 ? now : last);
16394
16381
  if (i === len) {
16395
- const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
16382
+ const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
16396
16383
  const pathForArrow = ui.__.__pathForArrow = [];
16397
16384
  if (useStartArrow) {
16398
16385
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -16433,6 +16420,12 @@ const PathArrowModule = {
16433
16420
  copy(last, now);
16434
16421
  }
16435
16422
  }
16423
+ },
16424
+ register(name, data) {
16425
+ this.list[name] = data;
16426
+ },
16427
+ get(name) {
16428
+ return this.list[name];
16436
16429
  }
16437
16430
  };
16438
16431
 
@@ -17998,6 +17991,18 @@ UI.addAttr("transition", true, dataType);
17998
17991
 
17999
17992
  UI.addAttr("transitionOut", undefined, dataType);
18000
17993
 
17994
+ ui$3.set = function(data, transition) {
17995
+ if (data) {
17996
+ if (transition) {
17997
+ if (transition === "temp") {
17998
+ this.lockNormalStyle = true;
17999
+ Object.assign(this, data);
18000
+ this.lockNormalStyle = false;
18001
+ } else this.animate(data, transition);
18002
+ } else Object.assign(this, data);
18003
+ }
18004
+ };
18005
+
18001
18006
  ui$3.animate = function(keyframe, options, kill, isTemp) {
18002
18007
  if (isUndefined(keyframe)) return this.__animate;
18003
18008
  const isAnimationList = isArray(keyframe) && !options && kill;
@@ -19314,4 +19319,4 @@ Object.assign(Filter, {
19314
19319
  }
19315
19320
  });
19316
19321
 
19317
- 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 };
19322
+ 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 };