leafer-ui 1.9.4 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -119,6 +119,9 @@ var LeaferUI = function(exports) {
119
119
  const {path: path} = this;
120
120
  return path && path.length === 6 && path[0] === 1;
121
121
  }
122
+ get __usePathBox() {
123
+ return this.__pathInputed;
124
+ }
122
125
  get __blendMode() {
123
126
  if (this.eraser && this.eraser !== "path") return "destination-out";
124
127
  const {blendMode: blendMode} = this;
@@ -341,7 +344,7 @@ var LeaferUI = function(exports) {
341
344
  };
342
345
  }
343
346
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
344
- const {float: float$1} = MathHelper;
347
+ const {float: float$2} = MathHelper;
345
348
  const tempPoint$3 = {};
346
349
  function getWorld() {
347
350
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
@@ -580,12 +583,12 @@ var LeaferUI = function(exports) {
580
583
  const cosR = c / scaleY;
581
584
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
582
585
  }
583
- const cosR = float$1(cos$5(rotation));
586
+ const cosR = float$2(cos$5(rotation));
584
587
  const sinR = sin$5(rotation);
585
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
586
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
587
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
588
- rotation = float$1(rotation / OneRadian);
588
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
589
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
590
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
591
+ rotation = float$2(rotation / OneRadian);
589
592
  } else {
590
593
  scaleX = a;
591
594
  scaleY = d;
@@ -1080,10 +1083,10 @@ var LeaferUI = function(exports) {
1080
1083
  toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
1081
1084
  }
1082
1085
  };
1083
- const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3} = TwoPointBoundsHelper;
1086
+ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1084
1087
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1085
- const {float: float, fourNumber: fourNumber} = MathHelper;
1086
- const {floor: floor$2, ceil: ceil$1} = Math;
1088
+ const {float: float$1, fourNumber: fourNumber} = MathHelper;
1089
+ const {floor: floor$2, ceil: ceil$2} = Math;
1087
1090
  let right$1, bottom$1, boundsRight, boundsBottom;
1088
1091
  const point = {};
1089
1092
  const toPoint$4 = {};
@@ -1207,7 +1210,7 @@ var LeaferUI = function(exports) {
1207
1210
  point.x = t.x;
1208
1211
  toOuterPoint$2(matrix, point, toPoint$4);
1209
1212
  addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
1210
- toBounds$3(tempPointBounds$1, to);
1213
+ toBounds$2(tempPointBounds$1, to);
1211
1214
  }
1212
1215
  },
1213
1216
  toInnerOf(t, matrix, to) {
@@ -1245,8 +1248,8 @@ var LeaferUI = function(exports) {
1245
1248
  const {x: x, y: y} = t;
1246
1249
  t.x = floor$2(t.x);
1247
1250
  t.y = floor$2(t.y);
1248
- t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1249
- t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1251
+ t.width = x > t.x ? ceil$2(t.width + x - t.x) : ceil$2(t.width);
1252
+ t.height = y > t.y ? ceil$2(t.height + y - t.y) : ceil$2(t.height);
1250
1253
  },
1251
1254
  unsign(t) {
1252
1255
  if (t.width < 0) {
@@ -1259,10 +1262,10 @@ var LeaferUI = function(exports) {
1259
1262
  }
1260
1263
  },
1261
1264
  float(t, maxLength) {
1262
- t.x = float(t.x, maxLength);
1263
- t.y = float(t.y, maxLength);
1264
- t.width = float(t.width, maxLength);
1265
- t.height = float(t.height, maxLength);
1265
+ t.x = float$1(t.x, maxLength);
1266
+ t.y = float$1(t.y, maxLength);
1267
+ t.width = float$1(t.width, maxLength);
1268
+ t.height = float$1(t.height, maxLength);
1266
1269
  },
1267
1270
  add(t, bounds, isPoint) {
1268
1271
  right$1 = t.x + t.width;
@@ -1306,7 +1309,7 @@ var LeaferUI = function(exports) {
1306
1309
  },
1307
1310
  setPoints(t, points) {
1308
1311
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1309
- toBounds$3(tempPointBounds$1, t);
1312
+ toBounds$2(tempPointBounds$1, t);
1310
1313
  },
1311
1314
  setPoint(t, point) {
1312
1315
  B.set(t, point.x, point.y);
@@ -2063,15 +2066,15 @@ var LeaferUI = function(exports) {
2063
2066
  DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2064
2067
  canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2065
2068
  this.bounds = new Bounds(0, 0, this.width, this.height);
2066
- if (this.context && !this.unreal) {
2067
- this.updateViewSize();
2068
- this.smooth = this.config.smooth;
2069
- }
2069
+ this.updateViewSize();
2070
2070
  this.updateClientBounds();
2071
- if (this.context && !this.unreal && takeCanvas) {
2072
- this.clearWorld(takeCanvas.bounds);
2073
- this.copyWorld(takeCanvas);
2074
- takeCanvas.recycle();
2071
+ if (this.context) {
2072
+ this.smooth = this.config.smooth;
2073
+ if (!this.unreal && takeCanvas) {
2074
+ this.clearWorld(takeCanvas.bounds);
2075
+ this.copyWorld(takeCanvas);
2076
+ takeCanvas.recycle();
2077
+ }
2075
2078
  }
2076
2079
  }
2077
2080
  updateViewSize() {}
@@ -2372,7 +2375,7 @@ var LeaferUI = function(exports) {
2372
2375
  data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2373
2376
  }
2374
2377
  };
2375
- const {sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2378
+ const {sin: sin$3, cos: cos$3, hypot: hypot, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow: pow} = Math;
2376
2379
  const {setPoint: setPoint$1, addPoint: addPoint$1} = TwoPointBoundsHelper;
2377
2380
  const {set: set, toNumberPoints: toNumberPoints} = PointHelper;
2378
2381
  const {M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5} = PathCommandMap;
@@ -2438,9 +2441,11 @@ var LeaferUI = function(exports) {
2438
2441
  const CBy = toY - y1;
2439
2442
  let startRadian = atan2$1(BAy, BAx);
2440
2443
  let endRadian = atan2$1(CBy, CBx);
2444
+ const lenBA = hypot(BAx, BAy);
2445
+ const lenCB = hypot(CBx, CBy);
2441
2446
  let totalRadian = endRadian - startRadian;
2442
2447
  if (totalRadian < 0) totalRadian += PI2;
2443
- if (totalRadian === PI$2 || abs$2(BAx + BAy) < 1e-12 || abs$2(CBx + CBy) < 1e-12) {
2448
+ if (lenBA < 1e-12 || lenCB < 1e-12 || totalRadian < 1e-12 || abs$2(totalRadian - PI$2) < 1e-12) {
2444
2449
  if (data) data.push(L$6, x1, y1);
2445
2450
  if (setPointBounds) {
2446
2451
  setPoint$1(setPointBounds, fromX, fromY);
@@ -2473,7 +2478,7 @@ var LeaferUI = function(exports) {
2473
2478
  let totalRadian = endRadian - startRadian;
2474
2479
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2475
2480
  if (anticlockwise) totalRadian -= PI2;
2476
- const parts = ceil(abs$2(totalRadian / PI_2));
2481
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2477
2482
  const partRadian = totalRadian / parts;
2478
2483
  const partRadian4Sin = sin$3(partRadian / 4);
2479
2484
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -3013,11 +3018,7 @@ var LeaferUI = function(exports) {
3013
3018
  this.set(path);
3014
3019
  }
3015
3020
  set(path) {
3016
- if (path) {
3017
- this.__path = isString(path) ? PathHelper.parse(path) : path;
3018
- } else {
3019
- this.__path = [];
3020
- }
3021
+ this.__path = path ? isString(path) ? PathHelper.parse(path) : path : [];
3021
3022
  return this;
3022
3023
  }
3023
3024
  beginPath() {
@@ -3179,7 +3180,7 @@ var LeaferUI = function(exports) {
3179
3180
  };
3180
3181
  const {M: M$1, L: L$2, C: C, Q: Q, Z: Z$1, N: N, D: D$1, X: X, G: G, F: F$1, O: O, P: P, U: U} = PathCommandMap;
3181
3182
  const {toTwoPointBounds: toTwoPointBounds, toTwoPointBoundsByQuadraticCurve: toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc: arc, ellipse: ellipse$1} = BezierHelper;
3182
- const {addPointBounds: addPointBounds, copy: copy$7, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$2} = TwoPointBoundsHelper;
3183
+ const {addPointBounds: addPointBounds, copy: copy$7, addPoint: addPoint, setPoint: setPoint, addBounds: addBounds, toBounds: toBounds$1} = TwoPointBoundsHelper;
3183
3184
  const debug$b = Debug.get("PathBounds");
3184
3185
  let radius, radiusX, radiusY;
3185
3186
  const tempPointBounds = {};
@@ -3188,7 +3189,7 @@ var LeaferUI = function(exports) {
3188
3189
  const PathBounds = {
3189
3190
  toBounds(data, setBounds) {
3190
3191
  PathBounds.toTwoPointBounds(data, setPointBounds);
3191
- toBounds$2(setPointBounds, setBounds);
3192
+ toBounds$1(setPointBounds, setBounds);
3192
3193
  },
3193
3194
  toTwoPointBounds(data, setPointBounds) {
3194
3195
  if (!data || !data.length) return setPoint(setPointBounds, 0, 0);
@@ -3370,10 +3371,13 @@ var LeaferUI = function(exports) {
3370
3371
  return smooth;
3371
3372
  }
3372
3373
  };
3373
- PathHelper.creator = new PathCreator;
3374
+ function path(path) {
3375
+ return new PathCreator(path);
3376
+ }
3377
+ const pen = path();
3378
+ PathHelper.creator = path();
3374
3379
  PathHelper.parse = PathConvert.parse;
3375
3380
  PathHelper.convertToCanvasData = PathConvert.toCanvasData;
3376
- const pen = new PathCreator;
3377
3381
  const {drawRoundRect: drawRoundRect} = RectHelper;
3378
3382
  function roundRect(drawer) {
3379
3383
  if (drawer && !drawer.roundRect) {
@@ -3726,7 +3730,7 @@ var LeaferUI = function(exports) {
3726
3730
  return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3727
3731
  },
3728
3732
  isFormat(format, config) {
3729
- if (config.format === format) return true;
3733
+ if (config.format) return config.format === format;
3730
3734
  const {url: url} = config;
3731
3735
  if (url.startsWith("data:")) {
3732
3736
  if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
@@ -3816,7 +3820,7 @@ var LeaferUI = function(exports) {
3816
3820
  getFull(_filters) {
3817
3821
  return this.view;
3818
3822
  }
3819
- getCanvas(width, height, opacity, _filters, xGap, yGap) {
3823
+ getCanvas(width, height, opacity, _filters, xGap, yGap, smooth) {
3820
3824
  width || (width = this.width);
3821
3825
  height || (height = this.height);
3822
3826
  if (this.cache) {
@@ -3832,6 +3836,7 @@ var LeaferUI = function(exports) {
3832
3836
  const canvas = Platform.origin.createCanvas(max$1(floor$1(width + (xGap || 0)), 1), max$1(floor$1(height + (yGap || 0)), 1));
3833
3837
  const ctx = canvas.getContext("2d");
3834
3838
  if (opacity) ctx.globalAlpha = opacity;
3839
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
3835
3840
  ctx.drawImage(this.view, 0, 0, width, height);
3836
3841
  this.cache = this.use > 1 ? {
3837
3842
  data: canvas,
@@ -4431,8 +4436,9 @@ var LeaferUI = function(exports) {
4431
4436
  };
4432
4437
  const L = LeafHelper;
4433
4438
  const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
4434
- function getTempLocal(t, world) {
4435
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world;
4439
+ function getTempLocal(t, worldPoint) {
4440
+ t.updateLayout();
4441
+ return t.parent ? PointHelper.tempToInnerOf(worldPoint, t.parent.scrollWorldTransform) : worldPoint;
4436
4442
  }
4437
4443
  const LeafBoundsHelper = {
4438
4444
  worldBounds(target) {
@@ -5099,6 +5105,7 @@ var LeaferUI = function(exports) {
5099
5105
  LeaferEvent.STOP = "leafer.stop";
5100
5106
  LeaferEvent.RESTART = "leafer.restart";
5101
5107
  LeaferEvent.END = "leafer.end";
5108
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5102
5109
  LeaferEvent.TRANSFORM = "leafer.transform";
5103
5110
  LeaferEvent.MOVE = "leafer.move";
5104
5111
  LeaferEvent.SCALE = "leafer.scale";
@@ -5357,7 +5364,7 @@ var LeaferUI = function(exports) {
5357
5364
  const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
5358
5365
  const {updateBounds: updateBounds$1} = BranchHelper;
5359
5366
  const {toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4} = BoundsHelper;
5360
- const {toBounds: toBounds$1} = PathBounds;
5367
+ const {toBounds: toBounds} = PathBounds;
5361
5368
  const LeafBounds = {
5362
5369
  __updateWorldBounds() {
5363
5370
  const layout = this.__layout;
@@ -5428,8 +5435,8 @@ var LeaferUI = function(exports) {
5428
5435
  __updateBoxBounds(_secondLayout, _bounds) {
5429
5436
  const b = this.__layout.boxBounds;
5430
5437
  const data = this.__;
5431
- if (data.__pathInputed) {
5432
- toBounds$1(data.path, b);
5438
+ if (data.__usePathBox) {
5439
+ toBounds(data.path, b);
5433
5440
  } else {
5434
5441
  b.x = 0;
5435
5442
  b.y = 0;
@@ -6344,7 +6351,7 @@ var LeaferUI = function(exports) {
6344
6351
  this.levelMap = null;
6345
6352
  }
6346
6353
  }
6347
- const version = "1.9.4";
6354
+ const version = "1.9.6";
6348
6355
  const debug$5 = Debug.get("LeaferCanvas");
6349
6356
  class LeaferCanvas extends LeaferCanvasBase {
6350
6357
  set zIndex(zIndex) {
@@ -6433,10 +6440,22 @@ var LeaferUI = function(exports) {
6433
6440
  updateViewSize() {
6434
6441
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
6435
6442
  const {style: style} = this.view;
6436
- style.width = width + "px";
6437
- style.height = height + "px";
6438
- this.view.width = Math.ceil(width * pixelRatio);
6439
- this.view.height = Math.ceil(height * pixelRatio);
6443
+ if (this.unreal) {
6444
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
6445
+ if (config.width) {
6446
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
6447
+ style.width = config.width + "px";
6448
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
6449
+ if (config.height) {
6450
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
6451
+ style.height = config.height + "px";
6452
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
6453
+ } else {
6454
+ style.width = width + "px";
6455
+ style.height = height + "px";
6456
+ this.view.width = Math.ceil(width * pixelRatio);
6457
+ this.view.height = Math.ceil(height * pixelRatio);
6458
+ }
6440
6459
  }
6441
6460
  updateClientBounds() {
6442
6461
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -6445,6 +6464,7 @@ var LeaferUI = function(exports) {
6445
6464
  this.resizeListener = listener;
6446
6465
  if (autoBounds) {
6447
6466
  this.autoBounds = autoBounds;
6467
+ if (this.resizeObserver) return;
6448
6468
  try {
6449
6469
  this.resizeObserver = new ResizeObserver(entries => {
6450
6470
  this.updateClientBounds();
@@ -6461,18 +6481,10 @@ var LeaferUI = function(exports) {
6461
6481
  } catch (_a) {
6462
6482
  this.imitateResizeObserver();
6463
6483
  }
6484
+ this.stopListenPixelRatio();
6464
6485
  } else {
6465
- window.addEventListener("resize", this.windowListener = () => {
6466
- const pixelRatio = Platform.devicePixelRatio;
6467
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6468
- const {width: width, height: height} = this;
6469
- this.emitResize({
6470
- width: width,
6471
- height: height,
6472
- pixelRatio: pixelRatio
6473
- });
6474
- }
6475
- });
6486
+ this.listenPixelRatio();
6487
+ if (this.unreal) this.updateViewSize();
6476
6488
  }
6477
6489
  }
6478
6490
  imitateResizeObserver() {
@@ -6481,6 +6493,25 @@ var LeaferUI = function(exports) {
6481
6493
  Platform.requestRender(this.imitateResizeObserver.bind(this));
6482
6494
  }
6483
6495
  }
6496
+ listenPixelRatio() {
6497
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
6498
+ const pixelRatio = Platform.devicePixelRatio;
6499
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
6500
+ const {width: width, height: height} = this;
6501
+ this.emitResize({
6502
+ width: width,
6503
+ height: height,
6504
+ pixelRatio: pixelRatio
6505
+ });
6506
+ }
6507
+ });
6508
+ }
6509
+ stopListenPixelRatio() {
6510
+ if (this.windowListener) {
6511
+ window.removeEventListener("resize", this.windowListener);
6512
+ this.windowListener = null;
6513
+ }
6514
+ }
6484
6515
  checkAutoBounds(parentSize) {
6485
6516
  const view = this.view;
6486
6517
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -6518,10 +6549,7 @@ var LeaferUI = function(exports) {
6518
6549
  destroy() {
6519
6550
  if (this.view) {
6520
6551
  this.stopAutoLayout();
6521
- if (this.windowListener) {
6522
- window.removeEventListener("resize", this.windowListener);
6523
- this.windowListener = null;
6524
- }
6552
+ this.stopListenPixelRatio();
6525
6553
  if (!this.unreal) {
6526
6554
  const view = this.view;
6527
6555
  if (view.parentElement) view.remove();
@@ -6925,7 +6953,7 @@ var LeaferUI = function(exports) {
6925
6953
  this.times = 0;
6926
6954
  this.config = {
6927
6955
  usePartRender: true,
6928
- maxFPS: 60
6956
+ maxFPS: 120
6929
6957
  };
6930
6958
  this.target = target;
6931
6959
  this.canvas = canvas;
@@ -7080,11 +7108,15 @@ var LeaferUI = function(exports) {
7080
7108
  if (this.requestTime || !target) return;
7081
7109
  if (target.parentApp) return target.parentApp.requestRender(false);
7082
7110
  const requestTime = this.requestTime = Date.now();
7083
- Platform.requestRender(() => {
7084
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
7111
+ const render = () => {
7112
+ const nowFPS = 1e3 / (Date.now() - requestTime);
7113
+ const {maxFPS: maxFPS} = this.config;
7114
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
7115
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
7085
7116
  this.requestTime = 0;
7086
7117
  this.checkRender();
7087
- });
7118
+ };
7119
+ Platform.requestRender(render);
7088
7120
  }
7089
7121
  __onResize(e) {
7090
7122
  if (this.canvas.unreal) return;
@@ -7127,7 +7159,8 @@ var LeaferUI = function(exports) {
7127
7159
  if (this.target) {
7128
7160
  this.stop();
7129
7161
  this.__removeListenEvents();
7130
- this.target = this.canvas = this.config = null;
7162
+ this.config = {};
7163
+ this.target = this.canvas = null;
7131
7164
  }
7132
7165
  }
7133
7166
  }
@@ -7220,7 +7253,7 @@ var LeaferUI = function(exports) {
7220
7253
  item = path.list[i];
7221
7254
  if (!item.__.hittable) break;
7222
7255
  hittablePath.addAt(item, 0);
7223
- if (!item.__.hitChildren) break;
7256
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
7224
7257
  }
7225
7258
  return hittablePath;
7226
7259
  }
@@ -7584,7 +7617,11 @@ var LeaferUI = function(exports) {
7584
7617
  }
7585
7618
  }
7586
7619
  class FrameData extends BoxData {}
7587
- class LineData extends UIData {}
7620
+ class LineData extends UIData {
7621
+ get __usePathBox() {
7622
+ return this.points || this.__pathInputed;
7623
+ }
7624
+ }
7588
7625
  class RectData extends UIData {
7589
7626
  get __boxStroke() {
7590
7627
  return !this.__pathInputed;
@@ -7595,7 +7632,7 @@ var LeaferUI = function(exports) {
7595
7632
  return !this.__pathInputed;
7596
7633
  }
7597
7634
  }
7598
- class PolygonData extends UIData {}
7635
+ class PolygonData extends LineData {}
7599
7636
  class StarData extends UIData {}
7600
7637
  class PathData extends UIData {
7601
7638
  get __pathInputed() {
@@ -7634,8 +7671,6 @@ var LeaferUI = function(exports) {
7634
7671
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7635
7672
  box.set(value);
7636
7673
  if (boxLayout.strokeChanged) layout.strokeChange();
7637
- if (boxLayout.renderChanged) layout.renderChange();
7638
- box.__updateChange();
7639
7674
  } else if (box) {
7640
7675
  t.__box = box.parent = null;
7641
7676
  box.destroy();
@@ -7702,7 +7737,7 @@ var LeaferUI = function(exports) {
7702
7737
  __updateRenderSpread() {
7703
7738
  let width = 0;
7704
7739
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7705
- if (shadow) shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
7740
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7706
7741
  if (blur) width = Math.max(width, blur);
7707
7742
  if (filter) width += Filter.getSpread(filter);
7708
7743
  if (renderSpread) width += renderSpread;
@@ -7714,36 +7749,67 @@ var LeaferUI = function(exports) {
7714
7749
  return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7715
7750
  }
7716
7751
  };
7752
+ const {float: float} = MathHelper;
7753
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7717
7754
  const DragBoundsHelper = {
7755
+ limitMove(leaf, move) {
7756
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7757
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7758
+ D.axisMove(leaf, move);
7759
+ },
7760
+ limitScaleOf(leaf, origin, scale) {
7761
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7762
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7763
+ },
7764
+ axisMove(leaf, move) {
7765
+ const {draggable: draggable} = leaf;
7766
+ if (draggable === "x") move.y = 0;
7767
+ if (draggable === "y") move.x = 0;
7768
+ },
7769
+ getDragBounds(leaf) {
7770
+ const {dragBounds: dragBounds} = leaf;
7771
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7772
+ },
7773
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7774
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7775
+ },
7718
7776
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7719
7777
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7720
7778
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7721
7779
  if (!change) move = Object.assign({}, move);
7722
- const isBiggerWidth = content.width > dragBounds.width;
7723
- const isBiggerHeight = content.height > dragBounds.height;
7724
- if (isBiggerWidth && dragBoundsType !== "outer") {
7780
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7725
7781
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7726
7782
  } else {
7727
7783
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7728
7784
  }
7729
- if (isBiggerHeight && dragBoundsType !== "outer") {
7785
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7730
7786
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7731
7787
  } else {
7732
7788
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7733
7789
  }
7734
- move.x = MathHelper.float(move.x);
7735
- move.y = MathHelper.float(move.y);
7790
+ move.x = float(move.x);
7791
+ move.y = float(move.y);
7736
7792
  return move;
7737
7793
  },
7738
- axisMove(leaf, move) {
7739
- const {draggable: draggable} = leaf;
7740
- if (draggable === "x") move.y = 0;
7741
- if (draggable === "y") move.x = 0;
7742
- },
7743
- limitMove(leaf, move) {
7744
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7745
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
7746
- D.axisMove(leaf, move);
7794
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7795
+ if (!change) scale = Object.assign({}, scale);
7796
+ let fitScaleX, fitScaleY;
7797
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7798
+ tempMerge.set(tempContent).add(dragBounds);
7799
+ tempIntersect.set(tempContent).intersect(dragBounds);
7800
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7801
+ fitScaleX = tempMerge.width / tempContent.width;
7802
+ } else {
7803
+ fitScaleX = tempIntersect.width / tempContent.width;
7804
+ }
7805
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7806
+ fitScaleY = tempMerge.height / tempContent.height;
7807
+ } else {
7808
+ fitScaleY = tempIntersect.height / tempContent.height;
7809
+ }
7810
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7811
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7812
+ return scale;
7747
7813
  }
7748
7814
  };
7749
7815
  const D = DragBoundsHelper;
@@ -7758,7 +7824,7 @@ var LeaferUI = function(exports) {
7758
7824
  }
7759
7825
  if (data.__useEffect) {
7760
7826
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7761
- stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
7827
+ stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
7762
7828
  data.__useEffect = !!(shadow || otherEffect);
7763
7829
  }
7764
7830
  data.__checkSingle();
@@ -7889,20 +7955,9 @@ var LeaferUI = function(exports) {
7889
7955
  if (!path) this.__drawPathByBox(pen);
7890
7956
  return pen;
7891
7957
  }
7892
- constructor(data) {
7893
- super(data);
7894
- }
7895
7958
  reset(_data) {}
7896
- set(data, transition) {
7897
- if (data) {
7898
- if (transition) {
7899
- if (transition === "temp") {
7900
- this.lockNormalStyle = true;
7901
- Object.assign(this, data);
7902
- this.lockNormalStyle = false;
7903
- } else this.animate(data, transition);
7904
- } else Object.assign(this, data);
7905
- }
7959
+ set(data, _transition) {
7960
+ if (data) Object.assign(this, data);
7906
7961
  }
7907
7962
  get(name) {
7908
7963
  return isString(name) ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -7948,7 +8003,7 @@ var LeaferUI = function(exports) {
7948
8003
  const data = this.__;
7949
8004
  if (data.path) {
7950
8005
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7951
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius);
8006
+ if (data.__useArrow) PathArrow.addArrows(this);
7952
8007
  } else data.__pathForRender && (data.__pathForRender = undefined);
7953
8008
  }
7954
8009
  __drawRenderPath(canvas) {
@@ -7972,7 +8027,8 @@ var LeaferUI = function(exports) {
7972
8027
  drawImagePlaceholder(canvas, _image) {
7973
8028
  Paint.fill(this.__.placeholderColor, this, canvas);
7974
8029
  }
7975
- animate(_keyframe, _options, _type, _isTemp) {
8030
+ animate(keyframe, _options, _type, _isTemp) {
8031
+ this.set(keyframe);
7976
8032
  return Plugin.need("animate");
7977
8033
  }
7978
8034
  killAnimate(_type, _nextStyle) {}
@@ -8086,9 +8142,6 @@ var LeaferUI = function(exports) {
8086
8142
  get isBranch() {
8087
8143
  return true;
8088
8144
  }
8089
- constructor(data) {
8090
- super(data);
8091
- }
8092
8145
  reset(data) {
8093
8146
  this.__setBranch();
8094
8147
  super.reset(data);
@@ -8206,7 +8259,7 @@ var LeaferUI = function(exports) {
8206
8259
  const canvas = this.canvas = Creator.canvas(config);
8207
8260
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
8208
8261
  if (this.isApp) this.__setApp();
8209
- this.__checkAutoLayout(config, parentApp);
8262
+ this.__checkAutoLayout();
8210
8263
  this.view = canvas.view;
8211
8264
  if (!parentApp) {
8212
8265
  this.selector = Creator.selector(this);
@@ -8305,7 +8358,8 @@ var LeaferUI = function(exports) {
8305
8358
  this.leafer = leafer;
8306
8359
  this.__level = 1;
8307
8360
  }
8308
- __checkAutoLayout(config, parentApp) {
8361
+ __checkAutoLayout() {
8362
+ const {config: config, parentApp: parentApp} = this;
8309
8363
  if (!parentApp) {
8310
8364
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config);
8311
8365
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
@@ -8322,7 +8376,9 @@ var LeaferUI = function(exports) {
8322
8376
  } else if (attrName === "zIndex") {
8323
8377
  this.canvas.zIndex = newValue;
8324
8378
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8325
- }
8379
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8380
+ mode: newValue
8381
+ });
8326
8382
  }
8327
8383
  return super.__setAttr(attrName, newValue);
8328
8384
  }
@@ -8331,9 +8387,10 @@ var LeaferUI = function(exports) {
8331
8387
  return super.__getAttr(attrName);
8332
8388
  }
8333
8389
  __changeCanvasSize(attrName, newValue) {
8334
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
8335
- data[attrName] = this.config[attrName] = newValue;
8336
- if (newValue) this.canvas.stopAutoLayout();
8390
+ const {config: config, canvas: canvas} = this;
8391
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs);
8392
+ data[attrName] = config[attrName] = newValue;
8393
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout();
8337
8394
  this.__doResize(data);
8338
8395
  }
8339
8396
  __changeFill(newValue) {
@@ -8480,9 +8537,9 @@ var LeaferUI = function(exports) {
8480
8537
  if (!this.parent) {
8481
8538
  if (this.selector) this.selector.destroy();
8482
8539
  if (this.hitCanvasManager) this.hitCanvasManager.destroy();
8483
- this.canvasManager.destroy();
8540
+ if (this.canvasManager) this.canvasManager.destroy();
8484
8541
  }
8485
- this.canvas.destroy();
8542
+ if (this.canvas) this.canvas.destroy();
8486
8543
  this.config.view = this.view = this.parentApp = null;
8487
8544
  if (this.userConfig) this.userConfig.view = null;
8488
8545
  super.destroy();
@@ -8500,14 +8557,12 @@ var LeaferUI = function(exports) {
8500
8557
  exports.Leafer.list = new LeafList;
8501
8558
  __decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
8502
8559
  __decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
8560
+ __decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
8503
8561
  exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
8504
8562
  exports.Rect = class Rect extends exports.UI {
8505
8563
  get __tag() {
8506
8564
  return "Rect";
8507
8565
  }
8508
- constructor(data) {
8509
- super(data);
8510
- }
8511
8566
  };
8512
8567
  __decorate([ dataProcessor(RectData) ], exports.Rect.prototype, "__", void 0);
8513
8568
  exports.Rect = __decorate([ useModule(RectRender), rewriteAble(), registerUI() ], exports.Rect);
@@ -8619,9 +8674,6 @@ var LeaferUI = function(exports) {
8619
8674
  get isFrame() {
8620
8675
  return true;
8621
8676
  }
8622
- constructor(data) {
8623
- super(data);
8624
- }
8625
8677
  };
8626
8678
  __decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
8627
8679
  __decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
@@ -8632,9 +8684,6 @@ var LeaferUI = function(exports) {
8632
8684
  get __tag() {
8633
8685
  return "Ellipse";
8634
8686
  }
8635
- constructor(data) {
8636
- super(data);
8637
- }
8638
8687
  __updatePath() {
8639
8688
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8640
8689
  const rx = width / 2, ry = height / 2;
@@ -8668,108 +8717,46 @@ var LeaferUI = function(exports) {
8668
8717
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
8669
8718
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
8670
8719
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8671
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8672
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8673
- const {toBounds: toBounds} = PathBounds;
8674
- exports.Line = class Line extends exports.UI {
8675
- get __tag() {
8676
- return "Line";
8677
- }
8678
- get toPoint() {
8679
- const {width: width, rotation: rotation} = this.__;
8680
- const to = getPointData();
8681
- if (width) to.x = width;
8682
- if (rotation) rotate$1(to, rotation);
8683
- return to;
8684
- }
8685
- set toPoint(value) {
8686
- this.width = getDistance$2(defaultPoint, value);
8687
- this.rotation = getAngle$1(defaultPoint, value);
8688
- if (this.height) this.height = 0;
8689
- }
8690
- constructor(data) {
8691
- super(data);
8692
- }
8693
- __updatePath() {
8694
- const data = this.__;
8695
- const path = data.path = [];
8696
- if (data.points) {
8697
- drawPoints$1(path, data.points, false, data.closed);
8698
- } else {
8699
- moveTo$2(path, 0, 0);
8700
- lineTo$2(path, this.width, 0);
8701
- }
8702
- }
8703
- __updateRenderPath() {
8704
- const data = this.__;
8705
- if (!this.pathInputed && data.points && data.curve) {
8706
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
8707
- if (data.__useArrow) PathArrow.addArrows(this, false);
8708
- } else super.__updateRenderPath();
8709
- }
8710
- __updateBoxBounds() {
8711
- if (this.points) {
8712
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8713
- } else super.__updateBoxBounds();
8714
- }
8715
- };
8716
- __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8717
- __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8718
- __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8719
- __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8720
- __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8721
- __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8722
- exports.Line = __decorate([ registerUI() ], exports.Line);
8723
8720
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
8724
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
8725
- const line = exports.Line.prototype;
8721
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
8726
8722
  exports.Polygon = class Polygon extends exports.UI {
8727
8723
  get __tag() {
8728
8724
  return "Polygon";
8729
8725
  }
8730
- constructor(data) {
8731
- super(data);
8732
- }
8733
8726
  __updatePath() {
8734
- const path = this.__.path = [];
8735
- if (this.__.points) {
8736
- drawPoints(path, this.__.points, false, true);
8727
+ const data = this.__;
8728
+ const path = data.path = [];
8729
+ if (data.points) {
8730
+ drawPoints$1(path, data.points, data.curve, true);
8737
8731
  } else {
8738
- const {width: width, height: height, sides: sides} = this.__;
8732
+ const {width: width, height: height, sides: sides} = data;
8739
8733
  const rx = width / 2, ry = height / 2;
8740
- moveTo$1(path, rx, 0);
8734
+ moveTo$2(path, rx, 0);
8741
8735
  for (let i = 1; i < sides; i++) {
8742
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8736
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8743
8737
  }
8744
8738
  closePath$1(path);
8745
8739
  }
8746
8740
  }
8747
- __updateRenderPath() {}
8748
- __updateBoxBounds() {}
8749
8741
  };
8750
8742
  __decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
8751
8743
  __decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
8752
8744
  __decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
8753
8745
  __decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
8754
- __decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
8755
- __decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
8756
8746
  exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
8757
8747
  const {sin: sin, cos: cos, PI: PI} = Math;
8758
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
8748
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
8759
8749
  exports.Star = class Star extends exports.UI {
8760
8750
  get __tag() {
8761
8751
  return "Star";
8762
8752
  }
8763
- constructor(data) {
8764
- super(data);
8765
- }
8766
8753
  __updatePath() {
8767
8754
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8768
8755
  const rx = width / 2, ry = height / 2;
8769
8756
  const path = this.__.path = [];
8770
- moveTo(path, rx, 0);
8757
+ moveTo$1(path, rx, 0);
8771
8758
  for (let i = 1; i < corners * 2; i++) {
8772
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8759
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8773
8760
  }
8774
8761
  closePath(path);
8775
8762
  }
@@ -8778,6 +8765,42 @@ var LeaferUI = function(exports) {
8778
8765
  __decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
8779
8766
  __decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
8780
8767
  exports.Star = __decorate([ registerUI() ], exports.Star);
8768
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
8769
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8770
+ exports.Line = class Line extends exports.UI {
8771
+ get __tag() {
8772
+ return "Line";
8773
+ }
8774
+ get toPoint() {
8775
+ const {width: width, rotation: rotation} = this.__;
8776
+ const to = getPointData();
8777
+ if (width) to.x = width;
8778
+ if (rotation) rotate$1(to, rotation);
8779
+ return to;
8780
+ }
8781
+ set toPoint(value) {
8782
+ this.width = getDistance$2(defaultPoint, value);
8783
+ this.rotation = getAngle$1(defaultPoint, value);
8784
+ if (this.height) this.height = 0;
8785
+ }
8786
+ __updatePath() {
8787
+ const data = this.__;
8788
+ const path = data.path = [];
8789
+ if (data.points) {
8790
+ drawPoints(path, data.points, data.curve, data.closed);
8791
+ } else {
8792
+ moveTo(path, 0, 0);
8793
+ lineTo(path, this.width, 0);
8794
+ }
8795
+ }
8796
+ };
8797
+ __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8798
+ __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8799
+ __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8800
+ __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8801
+ __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8802
+ __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8803
+ exports.Line = __decorate([ registerUI() ], exports.Line);
8781
8804
  exports.Image = class Image extends exports.Rect {
8782
8805
  get __tag() {
8783
8806
  return "Image";
@@ -8790,9 +8813,6 @@ var LeaferUI = function(exports) {
8790
8813
  const {fill: fill} = this.__;
8791
8814
  return isArray(fill) && fill[0].image;
8792
8815
  }
8793
- constructor(data) {
8794
- super(data);
8795
- }
8796
8816
  };
8797
8817
  __decorate([ dataProcessor(ImageData) ], exports.Image.prototype, "__", void 0);
8798
8818
  __decorate([ boundsType("") ], exports.Image.prototype, "url", void 0);
@@ -8877,9 +8897,6 @@ var LeaferUI = function(exports) {
8877
8897
  this.updateLayout();
8878
8898
  return this.__.__textDrawData;
8879
8899
  }
8880
- constructor(data) {
8881
- super(data);
8882
- }
8883
8900
  __updateTextDrawData() {
8884
8901
  const data = this.__;
8885
8902
  const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding} = data;
@@ -8916,10 +8933,6 @@ var LeaferUI = function(exports) {
8916
8933
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
8917
8934
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8918
8935
  }
8919
- __onUpdateSize() {
8920
- if (this.__box) this.__box.__onUpdateSize();
8921
- super.__onUpdateSize();
8922
- }
8923
8936
  __updateRenderSpread() {
8924
8937
  let width = super.__updateRenderSpread();
8925
8938
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -8930,6 +8943,11 @@ var LeaferUI = function(exports) {
8930
8943
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8931
8944
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8932
8945
  }
8946
+ __updateChange() {
8947
+ super.__updateChange();
8948
+ const box = this.__box;
8949
+ if (box) box.__onUpdateSize(), box.__updateChange();
8950
+ }
8933
8951
  __drawRenderPath(canvas) {
8934
8952
  canvas.font = this.__.__font;
8935
8953
  }
@@ -8983,9 +9001,6 @@ var LeaferUI = function(exports) {
8983
9001
  get __tag() {
8984
9002
  return "Path";
8985
9003
  }
8986
- constructor(data) {
8987
- super(data);
8988
- }
8989
9004
  };
8990
9005
  __decorate([ dataProcessor(PathData) ], exports.Path.prototype, "__", void 0);
8991
9006
  __decorate([ affectStrokeBoundsType("center") ], exports.Path.prototype, "strokeAlign", void 0);
@@ -8994,9 +9009,6 @@ var LeaferUI = function(exports) {
8994
9009
  get __tag() {
8995
9010
  return "Pen";
8996
9011
  }
8997
- constructor(data) {
8998
- super(data);
8999
- }
9000
9012
  setStyle(data) {
9001
9013
  const path = this.pathElement = new exports.Path(data);
9002
9014
  this.pathStyle = data;
@@ -10340,10 +10352,10 @@ var LeaferUI = function(exports) {
10340
10352
  };
10341
10353
  const PointerEventHelper = {
10342
10354
  convert(e, local) {
10343
- const base = InteractionHelper.getBase(e);
10355
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
10344
10356
  const data = Object.assign(Object.assign({}, base), {
10345
- x: local.x,
10346
- y: local.y,
10357
+ x: x,
10358
+ y: y,
10347
10359
  width: e.width,
10348
10360
  height: e.height,
10349
10361
  pointerType: e.pointerType,
@@ -10358,10 +10370,10 @@ var LeaferUI = function(exports) {
10358
10370
  return data;
10359
10371
  },
10360
10372
  convertMouse(e, local) {
10361
- const base = InteractionHelper.getBase(e);
10373
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
10362
10374
  return Object.assign(Object.assign({}, base), {
10363
- x: local.x,
10364
- y: local.y,
10375
+ x: x,
10376
+ y: y,
10365
10377
  width: 1,
10366
10378
  height: 1,
10367
10379
  pointerType: "mouse",
@@ -10370,10 +10382,10 @@ var LeaferUI = function(exports) {
10370
10382
  },
10371
10383
  convertTouch(e, local) {
10372
10384
  const touch = PointerEventHelper.getTouch(e);
10373
- const base = InteractionHelper.getBase(e);
10385
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
10374
10386
  return Object.assign(Object.assign({}, base), {
10375
- x: local.x,
10376
- y: local.y,
10387
+ x: x,
10388
+ y: y,
10377
10389
  width: 1,
10378
10390
  height: 1,
10379
10391
  pointerType: "touch",
@@ -11239,7 +11251,7 @@ var LeaferUI = function(exports) {
11239
11251
  if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
11240
11252
  }
11241
11253
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
11242
- const {floor: floor, max: max, abs: abs} = Math;
11254
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
11243
11255
  function createPattern(ui, paint, pixelRatio) {
11244
11256
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
11245
11257
  const id = scaleX + "-" + scaleY + "-" + pixelRatio;
@@ -11248,8 +11260,6 @@ var LeaferUI = function(exports) {
11248
11260
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
11249
11261
  scaleX *= pixelRatio;
11250
11262
  scaleY *= pixelRatio;
11251
- const xGap = gap && gap.x * scaleX;
11252
- const yGap = gap && gap.y * scaleY;
11253
11263
  if (sx) {
11254
11264
  sx = abs(sx);
11255
11265
  sy = abs(sy);
@@ -11266,7 +11276,10 @@ var LeaferUI = function(exports) {
11266
11276
  if (size > Platform.image.maxCacheSize) return false;
11267
11277
  }
11268
11278
  let maxSize = Platform.image.maxPatternSize;
11269
- if (!image.isSVG) {
11279
+ if (image.isSVG) {
11280
+ const ws = width / image.width;
11281
+ if (ws > 1) imageScale = ws / ceil(ws);
11282
+ } else {
11270
11283
  const imageSize = image.width * image.height;
11271
11284
  if (maxSize > imageSize) maxSize = imageSize;
11272
11285
  }
@@ -11281,18 +11294,20 @@ var LeaferUI = function(exports) {
11281
11294
  scaleX /= sx;
11282
11295
  scaleY /= sy;
11283
11296
  }
11297
+ const xGap = gap && gap.x * scaleX;
11298
+ const yGap = gap && gap.y * scaleY;
11284
11299
  if (transform || scaleX !== 1 || scaleY !== 1) {
11300
+ const canvasWidth = width + (xGap || 0);
11301
+ const canvasHeight = height + (yGap || 0);
11302
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
11303
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
11285
11304
  if (!imageMatrix) {
11286
11305
  imageMatrix = get$1();
11287
11306
  if (transform) copy$1(imageMatrix, transform);
11288
11307
  }
11289
11308
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11290
11309
  }
11291
- if (imageMatrix) {
11292
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11293
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
11294
- }
11295
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11310
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11296
11311
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11297
11312
  paint.style = pattern;
11298
11313
  paint.patternId = id;
@@ -11508,11 +11523,16 @@ var LeaferUI = function(exports) {
11508
11523
  }
11509
11524
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
11510
11525
  }
11511
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11526
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11512
11527
  if (end && index < end) other.clearWorld(copyBounds);
11513
11528
  });
11514
11529
  other.recycle(copyBounds);
11515
11530
  }
11531
+ function getShadowSpread(_ui, shadow) {
11532
+ let width = 0;
11533
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
11534
+ return width;
11535
+ }
11516
11536
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
11517
11537
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
11518
11538
  if (Platform.fullImageShadow) {
@@ -11584,7 +11604,11 @@ var LeaferUI = function(exports) {
11584
11604
  shadow: shadow,
11585
11605
  innerShadow: innerShadow,
11586
11606
  blur: blur,
11587
- backgroundBlur: backgroundBlur
11607
+ backgroundBlur: backgroundBlur,
11608
+ getShadowSpread: getShadowSpread,
11609
+ isTransformShadow(_shadow) {
11610
+ return undefined;
11611
+ }
11588
11612
  };
11589
11613
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
11590
11614
  let usedGrayscaleAlpha;
@@ -12040,16 +12064,17 @@ var LeaferUI = function(exports) {
12040
12064
  row.data = null;
12041
12065
  }
12042
12066
  function decorationText(drawData, style) {
12043
- let type;
12067
+ let type, offset = 0;
12044
12068
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
12045
12069
  drawData.decorationHeight = fontSize / 11;
12046
12070
  if (isObject(textDecoration)) {
12047
12071
  type = textDecoration.type;
12048
12072
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
12073
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
12049
12074
  } else type = textDecoration;
12050
12075
  switch (type) {
12051
12076
  case "under":
12052
- drawData.decorationY = [ fontSize * .15 ];
12077
+ drawData.decorationY = [ fontSize * .15 + offset ];
12053
12078
  break;
12054
12079
 
12055
12080
  case "delete":
@@ -12057,7 +12082,7 @@ var LeaferUI = function(exports) {
12057
12082
  break;
12058
12083
 
12059
12084
  case "under-delete":
12060
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
12085
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
12061
12086
  }
12062
12087
  }
12063
12088
  const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
@@ -12306,6 +12331,7 @@ var LeaferUI = function(exports) {
12306
12331
  exports.maskType = maskType;
12307
12332
  exports.naturalBoundsType = naturalBoundsType;
12308
12333
  exports.opacityType = opacityType;
12334
+ exports.path = path;
12309
12335
  exports.pathInputType = pathInputType;
12310
12336
  exports.pathType = pathType;
12311
12337
  exports.pen = pen;