@leafer/worker 1.9.4 → 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.
@@ -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;
@@ -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
1144
  const {float: float$1, 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) {
@@ -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 = {
@@ -5734,7 +5741,7 @@ const {updateBounds: updateBounds$2} = BranchHelper;
5734
5741
 
5735
5742
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$7} = BoundsHelper;
5736
5743
 
5737
- const {toBounds: toBounds$2} = PathBounds;
5744
+ const {toBounds: toBounds$1} = PathBounds;
5738
5745
 
5739
5746
  const LeafBounds = {
5740
5747
  __updateWorldBounds() {
@@ -5806,8 +5813,8 @@ const LeafBounds = {
5806
5813
  __updateBoxBounds(_secondLayout, _bounds) {
5807
5814
  const b = this.__layout.boxBounds;
5808
5815
  const data = this.__;
5809
- if (data.__pathInputed) {
5810
- toBounds$2(data.path, b);
5816
+ if (data.__usePathBox) {
5817
+ toBounds$1(data.path, b);
5811
5818
  } else {
5812
5819
  b.x = 0;
5813
5820
  b.y = 0;
@@ -6742,7 +6749,7 @@ class LeafLevelList {
6742
6749
  }
6743
6750
  }
6744
6751
 
6745
- const version = "1.9.4";
6752
+ const version = "1.9.5";
6746
6753
 
6747
6754
  class LeaferCanvas extends LeaferCanvasBase {
6748
6755
  get allowBackgroundColor() {
@@ -7165,7 +7172,7 @@ class Renderer {
7165
7172
  this.times = 0;
7166
7173
  this.config = {
7167
7174
  usePartRender: true,
7168
- maxFPS: 60
7175
+ maxFPS: 120
7169
7176
  };
7170
7177
  this.target = target;
7171
7178
  this.canvas = canvas;
@@ -7320,11 +7327,15 @@ class Renderer {
7320
7327
  if (this.requestTime || !target) return;
7321
7328
  if (target.parentApp) return target.parentApp.requestRender(false);
7322
7329
  const requestTime = this.requestTime = Date.now();
7323
- Platform.requestRender(() => {
7324
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7330
+ const render = () => {
7331
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7332
+ const {maxFPS: maxFPS} = this.config;
7333
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7334
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7325
7335
  this.requestTime = 0;
7326
7336
  this.checkRender();
7327
- });
7337
+ };
7338
+ Platform.requestRender(render);
7328
7339
  }
7329
7340
  __onResize(e) {
7330
7341
  if (this.canvas.unreal) return;
@@ -7367,7 +7378,8 @@ class Renderer {
7367
7378
  if (this.target) {
7368
7379
  this.stop();
7369
7380
  this.__removeListenEvents();
7370
- this.target = this.canvas = this.config = null;
7381
+ this.config = {};
7382
+ this.target = this.canvas = null;
7371
7383
  }
7372
7384
  }
7373
7385
  }
@@ -7858,7 +7870,11 @@ class LeaferData extends GroupData {
7858
7870
 
7859
7871
  class FrameData extends BoxData {}
7860
7872
 
7861
- class LineData extends UIData {}
7873
+ class LineData extends UIData {
7874
+ get __usePathBox() {
7875
+ return this.points || this.__pathInputed;
7876
+ }
7877
+ }
7862
7878
 
7863
7879
  class RectData extends UIData {
7864
7880
  get __boxStroke() {
@@ -7872,7 +7888,7 @@ class EllipseData extends UIData {
7872
7888
  }
7873
7889
  }
7874
7890
 
7875
- class PolygonData extends UIData {}
7891
+ class PolygonData extends LineData {}
7876
7892
 
7877
7893
  class StarData extends UIData {}
7878
7894
 
@@ -8182,20 +8198,9 @@ let UI = UI_1 = class UI extends Leaf {
8182
8198
  if (!path) this.__drawPathByBox(pen);
8183
8199
  return pen;
8184
8200
  }
8185
- constructor(data) {
8186
- super(data);
8187
- }
8188
8201
  reset(_data) {}
8189
- set(data, transition) {
8190
- if (data) {
8191
- if (transition) {
8192
- if (transition === "temp") {
8193
- this.lockNormalStyle = true;
8194
- Object.assign(this, data);
8195
- this.lockNormalStyle = false;
8196
- } else this.animate(data, transition);
8197
- } else Object.assign(this, data);
8198
- }
8202
+ set(data, _transition) {
8203
+ if (data) Object.assign(this, data);
8199
8204
  }
8200
8205
  get(name) {
8201
8206
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -8241,7 +8246,7 @@ let UI = UI_1 = class UI extends Leaf {
8241
8246
  const data = this.__;
8242
8247
  if (data.path) {
8243
8248
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8244
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8249
+ if (data.__useArrow) PathArrow.addArrows(this);
8245
8250
  } else data.__pathForRender && (data.__pathForRender = undefined);
8246
8251
  }
8247
8252
  __drawRenderPath(canvas) {
@@ -8265,7 +8270,8 @@ let UI = UI_1 = class UI extends Leaf {
8265
8270
  drawImagePlaceholder(canvas, _image) {
8266
8271
  Paint.fill(this.__.placeholderColor, this, canvas);
8267
8272
  }
8268
- animate(_keyframe, _options, _type, _isTemp) {
8273
+ animate(keyframe, _options, _type, _isTemp) {
8274
+ this.set(keyframe);
8269
8275
  return Plugin.need("animate");
8270
8276
  }
8271
8277
  killAnimate(_type, _nextStyle) {}
@@ -8454,9 +8460,6 @@ let Group = class Group extends UI {
8454
8460
  get isBranch() {
8455
8461
  return true;
8456
8462
  }
8457
- constructor(data) {
8458
- super(data);
8459
- }
8460
8463
  reset(data) {
8461
8464
  this.__setBranch();
8462
8465
  super.reset(data);
@@ -8581,7 +8584,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8581
8584
  const canvas = this.canvas = Creator.canvas(config);
8582
8585
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8583
8586
  if (this.isApp) this.__setApp();
8584
- this.__checkAutoLayout(config, parentApp);
8587
+ this.__checkAutoLayout();
8585
8588
  this.view = canvas.view;
8586
8589
  if (!parentApp) {
8587
8590
  this.selector = Creator.selector(this);
@@ -8680,7 +8683,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8680
8683
  this.leafer = leafer;
8681
8684
  this.__level = 1;
8682
8685
  }
8683
- __checkAutoLayout(config, parentApp) {
8686
+ __checkAutoLayout() {
8687
+ const {config: config, parentApp: parentApp} = this;
8684
8688
  if (!parentApp) {
8685
8689
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8686
8690
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8706,9 +8710,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8706
8710
  return super.__getAttr(attrName);
8707
8711
  }
8708
8712
  __changeCanvasSize(attrName, newValue) {
8709
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8710
- data[attrName] = this.config[attrName] = newValue;
8711
- if (newValue) this.canvas.stopAutoLayout();
8713
+ const {config: config, canvas: canvas} = this;
8714
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8715
+ data[attrName] = config[attrName] = newValue;
8716
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8712
8717
  this.__doResize(data);
8713
8718
  }
8714
8719
  __changeFill(newValue) {
@@ -8855,9 +8860,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8855
8860
  if (!this.parent) {
8856
8861
  if (this.selector) this.selector.destroy();
8857
8862
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8858
- this.canvasManager.destroy();
8863
+ if (this.canvasManager) this.canvasManager.destroy();
8859
8864
  }
8860
- this.canvas.destroy();
8865
+ if (this.canvas) this.canvas.destroy();
8861
8866
  this.config.view = this.view = this.parentApp = null;
8862
8867
  if (this.userConfig) this.userConfig.view = null;
8863
8868
  super.destroy();
@@ -8885,9 +8890,6 @@ let Rect = class Rect extends UI {
8885
8890
  get __tag() {
8886
8891
  return "Rect";
8887
8892
  }
8888
- constructor(data) {
8889
- super(data);
8890
- }
8891
8893
  };
8892
8894
 
8893
8895
  __decorate([ dataProcessor(RectData) ], Rect.prototype, "__", void 0);
@@ -9019,9 +9021,6 @@ let Frame = class Frame extends Box {
9019
9021
  get isFrame() {
9020
9022
  return true;
9021
9023
  }
9022
- constructor(data) {
9023
- super(data);
9024
- }
9025
9024
  };
9026
9025
 
9027
9026
  __decorate([ dataProcessor(FrameData) ], Frame.prototype, "__", void 0);
@@ -9038,9 +9037,6 @@ let Ellipse = class Ellipse extends UI {
9038
9037
  get __tag() {
9039
9038
  return "Ellipse";
9040
9039
  }
9041
- constructor(data) {
9042
- super(data);
9043
- }
9044
9040
  __updatePath() {
9045
9041
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9046
9042
  const rx = width / 2, ry = height / 2;
@@ -9084,8 +9080,6 @@ const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathComma
9084
9080
 
9085
9081
  const {rotate: rotate$3, getAngle: getAngle$2, getDistance: getDistance$3, defaultPoint: defaultPoint} = PointHelper;
9086
9082
 
9087
- const {toBounds: toBounds$1} = PathBounds;
9088
-
9089
9083
  let Line = class Line extends UI {
9090
9084
  get __tag() {
9091
9085
  return "Line";
@@ -9102,31 +9096,16 @@ let Line = class Line extends UI {
9102
9096
  this.rotation = getAngle$2(defaultPoint, value);
9103
9097
  if (this.height) this.height = 0;
9104
9098
  }
9105
- constructor(data) {
9106
- super(data);
9107
- }
9108
9099
  __updatePath() {
9109
9100
  const data = this.__;
9110
9101
  const path = data.path = [];
9111
9102
  if (data.points) {
9112
- drawPoints$1(path, data.points, false, data.closed);
9103
+ drawPoints$1(path, data.points, data.curve, data.closed);
9113
9104
  } else {
9114
9105
  moveTo$2(path, 0, 0);
9115
9106
  lineTo$2(path, this.width, 0);
9116
9107
  }
9117
9108
  }
9118
- __updateRenderPath() {
9119
- const data = this.__;
9120
- if (!this.pathInputed && data.points && data.curve) {
9121
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
9122
- if (data.__useArrow) PathArrow.addArrows(this, false);
9123
- } else super.__updateRenderPath();
9124
- }
9125
- __updateBoxBounds() {
9126
- if (this.points) {
9127
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
9128
- } else super.__updateBoxBounds();
9129
- }
9130
9109
  };
9131
9110
 
9132
9111
  __decorate([ dataProcessor(LineData) ], Line.prototype, "__", void 0);
@@ -9153,15 +9132,13 @@ let Polygon = class Polygon extends UI {
9153
9132
  get __tag() {
9154
9133
  return "Polygon";
9155
9134
  }
9156
- constructor(data) {
9157
- super(data);
9158
- }
9159
9135
  __updatePath() {
9160
- const path = this.__.path = [];
9161
- if (this.__.points) {
9162
- drawPoints(path, this.__.points, false, true);
9136
+ const data = this.__;
9137
+ const path = data.path = [];
9138
+ if (data.points) {
9139
+ drawPoints(path, data.points, data.curve, true);
9163
9140
  } else {
9164
- const {width: width, height: height, sides: sides} = this.__;
9141
+ const {width: width, height: height, sides: sides} = data;
9165
9142
  const rx = width / 2, ry = height / 2;
9166
9143
  moveTo$1(path, rx, 0);
9167
9144
  for (let i = 1; i < sides; i++) {
@@ -9196,9 +9173,6 @@ let Star = class Star extends UI {
9196
9173
  get __tag() {
9197
9174
  return "Star";
9198
9175
  }
9199
- constructor(data) {
9200
- super(data);
9201
- }
9202
9176
  __updatePath() {
9203
9177
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
9204
9178
  const rx = width / 2, ry = height / 2;
@@ -9231,9 +9205,6 @@ let Image = class Image extends Rect {
9231
9205
  const {fill: fill} = this.__;
9232
9206
  return isArray(fill) && fill[0].image;
9233
9207
  }
9234
- constructor(data) {
9235
- super(data);
9236
- }
9237
9208
  };
9238
9209
 
9239
9210
  __decorate([ dataProcessor(ImageData) ], Image.prototype, "__", void 0);
@@ -9333,9 +9304,6 @@ let Text = class Text extends UI {
9333
9304
  this.updateLayout();
9334
9305
  return this.__.__textDrawData;
9335
9306
  }
9336
- constructor(data) {
9337
- super(data);
9338
- }
9339
9307
  __updateTextDrawData() {
9340
9308
  const data = this.__;
9341
9309
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -9468,9 +9436,6 @@ let Path = class Path extends UI {
9468
9436
  get __tag() {
9469
9437
  return "Path";
9470
9438
  }
9471
- constructor(data) {
9472
- super(data);
9473
- }
9474
9439
  };
9475
9440
 
9476
9441
  __decorate([ dataProcessor(PathData) ], Path.prototype, "__", void 0);
@@ -9483,9 +9448,6 @@ let Pen = class Pen extends Group {
9483
9448
  get __tag() {
9484
9449
  return "Pen";
9485
9450
  }
9486
- constructor(data) {
9487
- super(data);
9488
- }
9489
9451
  setStyle(data) {
9490
9452
  const path = this.pathElement = new Path(data);
9491
9453
  this.pathStyle = data;
@@ -11570,7 +11532,7 @@ function ignoreRender(ui, value) {
11570
11532
 
11571
11533
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11572
11534
 
11573
- const {floor: floor$1, max: max$1, abs: abs$4} = Math;
11535
+ const {floor: floor$1, ceil: ceil$1, max: max$1, abs: abs$4} = Math;
11574
11536
 
11575
11537
  function createPattern(ui, paint, pixelRatio) {
11576
11538
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11580,8 +11542,6 @@ function createPattern(ui, paint, pixelRatio) {
11580
11542
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11581
11543
  scaleX *= pixelRatio;
11582
11544
  scaleY *= pixelRatio;
11583
- const xGap = gap && gap.x * scaleX;
11584
- const yGap = gap && gap.y * scaleY;
11585
11545
  if (sx) {
11586
11546
  sx = abs$4(sx);
11587
11547
  sy = abs$4(sy);
@@ -11598,7 +11558,10 @@ function createPattern(ui, paint, pixelRatio) {
11598
11558
  if (size > Platform.image.maxCacheSize) return false;
11599
11559
  }
11600
11560
  let maxSize = Platform.image.maxPatternSize;
11601
- if (!image.isSVG) {
11561
+ if (image.isSVG) {
11562
+ const ws = width / image.width;
11563
+ if (ws > 1) imageScale = ws / ceil$1(ws);
11564
+ } else {
11602
11565
  const imageSize = image.width * image.height;
11603
11566
  if (maxSize > imageSize) maxSize = imageSize;
11604
11567
  }
@@ -11613,18 +11576,20 @@ function createPattern(ui, paint, pixelRatio) {
11613
11576
  scaleX /= sx;
11614
11577
  scaleY /= sy;
11615
11578
  }
11579
+ const xGap = gap && gap.x * scaleX;
11580
+ const yGap = gap && gap.y * scaleY;
11616
11581
  if (transform || scaleX !== 1 || scaleY !== 1) {
11582
+ const canvasWidth = width + (xGap || 0);
11583
+ const canvasHeight = height + (yGap || 0);
11584
+ scaleX /= canvasWidth / max$1(floor$1(canvasWidth), 1);
11585
+ scaleY /= canvasHeight / max$1(floor$1(canvasHeight), 1);
11617
11586
  if (!imageMatrix) {
11618
11587
  imageMatrix = get$1();
11619
11588
  if (transform) copy$4(imageMatrix, transform);
11620
11589
  }
11621
11590
  scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11622
11591
  }
11623
- if (imageMatrix) {
11624
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11625
- scale$2(imageMatrix, canvasWidth / max$1(floor$1(canvasWidth), 1), canvasHeight / max$1(floor$1(canvasHeight), 1));
11626
- }
11627
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11592
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11628
11593
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11629
11594
  paint.style = pattern;
11630
11595
  paint.patternId = id;
@@ -15600,7 +15565,8 @@ const WheelEventHelper = {
15600
15565
  if (zoom) {
15601
15566
  zoomSpeed = within$2(zoomSpeed, 0, 1);
15602
15567
  const min = event.deltaY ? config.delta.y : config.delta.x;
15603
- scale = within$2(1 - delta / (min * 4) * zoomSpeed, .5, 1.5);
15568
+ const absScale = within$2(1 - abs$2(delta) / (min * 4) * zoomSpeed, .5, 2);
15569
+ scale = delta > 0 ? absScale : 1 / absScale;
15604
15570
  }
15605
15571
  return scale;
15606
15572
  }
@@ -16155,6 +16121,9 @@ let Arrow = class Arrow extends Line {
16155
16121
  super(data);
16156
16122
  this.__.__useArrow = true;
16157
16123
  }
16124
+ static registerArrow(name, data) {
16125
+ PathArrow.register(name, data);
16126
+ }
16158
16127
  };
16159
16128
 
16160
16129
  __decorate([ dataProcessor(ArrowData) ], Arrow.prototype, "__", void 0);
@@ -16336,9 +16305,18 @@ const arrows = {
16336
16305
  mark: mark
16337
16306
  };
16338
16307
 
16339
- function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
16308
+ function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
16309
+ let pathData, scale;
16340
16310
  const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
16341
- const {offset: offset, connect: connect, path: path, dashPath: dashPath} = isObject(arrow) ? arrow : arrows[arrow];
16311
+ if (isObject(arrow)) {
16312
+ if (arrow.type) {
16313
+ scale = arrow.scale;
16314
+ pathData = arrows[arrow.type];
16315
+ } else pathData = arrow;
16316
+ } else {
16317
+ pathData = arrows[arrow];
16318
+ }
16319
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
16342
16320
  let connectX = connect ? connect.x : 0;
16343
16321
  let offsetX = offset ? offset.x : 0;
16344
16322
  const data = [ ...path ];
@@ -16347,9 +16325,10 @@ function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern)
16347
16325
  if (offset) {
16348
16326
  if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
16349
16327
  }
16328
+ if (scale) layout$2(data, 0, 0, scale, scale);
16350
16329
  if (offsetX) layout$2(data, offsetX, 0);
16351
- layout$2(data, to.x, to.y, scale, scale, getAngle(from, to));
16352
- connectOffset.x = (connectX + offsetX) * scale;
16330
+ layout$2(data, to.x, to.y, size, size, getAngle(from, to));
16331
+ connectOffset.x = (connectX + offsetX) * size;
16353
16332
  return data;
16354
16333
  }
16355
16334
 
@@ -16365,8 +16344,9 @@ const last = {}, now = {};
16365
16344
 
16366
16345
  const PathArrowModule = {
16367
16346
  list: arrows,
16368
- addArrows(ui, changeRenderPath) {
16369
- const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
16347
+ addArrows(ui) {
16348
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
16349
+ const clonePathForArrow = !cornerRadius;
16370
16350
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
16371
16351
  while (i < len) {
16372
16352
  command = data[i];
@@ -16381,12 +16361,12 @@ const PathArrowModule = {
16381
16361
  break;
16382
16362
 
16383
16363
  case C$1:
16384
- if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
16364
+ if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
16385
16365
  i += 7;
16386
16366
  break;
16387
16367
 
16388
16368
  case Q:
16389
- if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
16369
+ if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
16390
16370
  i += 5;
16391
16371
  break;
16392
16372
 
@@ -16422,7 +16402,13 @@ const PathArrowModule = {
16422
16402
  break;
16423
16403
 
16424
16404
  case U:
16425
- if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
16405
+ if (count === 1 || i + 6 >= len - 3) {
16406
+ copyPoints(data, last, now, i + 1);
16407
+ if (i + 6 !== len) {
16408
+ now.x -= (now.x - last.x) / 10;
16409
+ now.y -= (now.y - last.y) / 10;
16410
+ }
16411
+ }
16426
16412
  i += 6;
16427
16413
  break;
16428
16414
  }
@@ -16430,7 +16416,7 @@ const PathArrowModule = {
16430
16416
  if (count === 1 && command !== M$1) return;
16431
16417
  if (count === 2 && useStartArrow) copy(second, command === L$1 ? now : last);
16432
16418
  if (i === len) {
16433
- const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
16419
+ const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
16434
16420
  const pathForArrow = ui.__.__pathForArrow = [];
16435
16421
  if (useStartArrow) {
16436
16422
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -16471,6 +16457,12 @@ const PathArrowModule = {
16471
16457
  copy(last, now);
16472
16458
  }
16473
16459
  }
16460
+ },
16461
+ register(name, data) {
16462
+ this.list[name] = data;
16463
+ },
16464
+ get(name) {
16465
+ return this.list[name];
16474
16466
  }
16475
16467
  };
16476
16468
 
@@ -18036,6 +18028,18 @@ UI.addAttr("transition", true, dataType);
18036
18028
 
18037
18029
  UI.addAttr("transitionOut", undefined, dataType);
18038
18030
 
18031
+ ui$3.set = function(data, transition) {
18032
+ if (data) {
18033
+ if (transition) {
18034
+ if (transition === "temp") {
18035
+ this.lockNormalStyle = true;
18036
+ Object.assign(this, data);
18037
+ this.lockNormalStyle = false;
18038
+ } else this.animate(data, transition);
18039
+ } else Object.assign(this, data);
18040
+ }
18041
+ };
18042
+
18039
18043
  ui$3.animate = function(keyframe, options, kill, isTemp) {
18040
18044
  if (isUndefined(keyframe)) return this.__animate;
18041
18045
  const isAnimationList = isArray(keyframe) && !options && kill;
@@ -19352,4 +19356,4 @@ Object.assign(Filter, {
19352
19356
  }
19353
19357
  });
19354
19358
 
19355
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
19359
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };