leafer-ui 1.0.0-rc.19 → 1.0.0-rc.20

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
@@ -3,6 +3,7 @@ var LeaferUI = (function (exports) {
3
3
 
4
4
  const Platform = {
5
5
  image: {
6
+ hitCanvasSize: 100,
6
7
  maxCacheSize: 2560 * 1600,
7
8
  maxPatternSize: 4096 * 2160,
8
9
  suffix: 'leaf',
@@ -44,7 +45,7 @@ var LeaferUI = (function (exports) {
44
45
  minus(value, isFourNumber) {
45
46
  if (value instanceof Array) {
46
47
  if (isFourNumber)
47
- value = MathHelper.fourNumber(value);
48
+ value = MathHelper.fourNumber(value, 0);
48
49
  for (let i = 0; i < value.length; i++)
49
50
  value[i] = -value[i];
50
51
  }
@@ -58,7 +59,7 @@ var LeaferUI = (function (exports) {
58
59
  if (num instanceof Array) {
59
60
  switch (num.length) {
60
61
  case 4:
61
- data = num;
62
+ data = maxValue === undefined ? num : [...num];
62
63
  break;
63
64
  case 2:
64
65
  data = [num[0], num[1], num[0], num[1]];
@@ -119,7 +120,7 @@ var LeaferUI = (function (exports) {
119
120
 
120
121
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
121
122
  const { float: float$1 } = MathHelper;
122
- const tempPoint$2 = {};
123
+ const tempPoint$3 = {};
123
124
  function getWorld() {
124
125
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
125
126
  }
@@ -160,8 +161,8 @@ var LeaferUI = (function (exports) {
160
161
  t.d *= scaleY;
161
162
  },
162
163
  scaleOfOuter(t, origin, scaleX, scaleY) {
163
- M$6.toInnerPoint(t, origin, tempPoint$2);
164
- M$6.scaleOfInner(t, tempPoint$2, scaleX, scaleY);
164
+ M$6.toInnerPoint(t, origin, tempPoint$3);
165
+ M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
165
166
  },
166
167
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
167
168
  M$6.translateInner(t, origin.x, origin.y);
@@ -179,8 +180,8 @@ var LeaferUI = (function (exports) {
179
180
  t.d = c * sinR + d * cosR;
180
181
  },
181
182
  rotateOfOuter(t, origin, rotation) {
182
- M$6.toInnerPoint(t, origin, tempPoint$2);
183
- M$6.rotateOfInner(t, tempPoint$2, rotation);
183
+ M$6.toInnerPoint(t, origin, tempPoint$3);
184
+ M$6.rotateOfInner(t, tempPoint$3, rotation);
184
185
  },
185
186
  rotateOfInner(t, origin, rotation) {
186
187
  M$6.translateInner(t, origin.x, origin.y);
@@ -201,8 +202,8 @@ var LeaferUI = (function (exports) {
201
202
  }
202
203
  },
203
204
  skewOfOuter(t, origin, skewX, skewY) {
204
- M$6.toInnerPoint(t, origin, tempPoint$2);
205
- M$6.skewOfInner(t, tempPoint$2, skewX, skewY);
205
+ M$6.toInnerPoint(t, origin, tempPoint$3);
206
+ M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
206
207
  },
207
208
  skewOfInner(t, origin, skewX, skewY = 0) {
208
209
  M$6.translateInner(t, origin.x, origin.y);
@@ -449,19 +450,19 @@ var LeaferUI = (function (exports) {
449
450
  },
450
451
  tempToInnerOf(t, matrix) {
451
452
  const { tempPoint: temp } = P$5;
452
- copy$a(temp, t);
453
+ copy$b(temp, t);
453
454
  toInnerPoint$2(matrix, temp, temp);
454
455
  return temp;
455
456
  },
456
457
  tempToOuterOf(t, matrix) {
457
458
  const { tempPoint: temp } = P$5;
458
- copy$a(temp, t);
459
+ copy$b(temp, t);
459
460
  toOuterPoint$2(matrix, temp, temp);
460
461
  return temp;
461
462
  },
462
463
  tempToInnerRadiusPointOf(t, matrix) {
463
464
  const { tempRadiusPoint: temp } = P$5;
464
- copy$a(temp, t);
465
+ copy$b(temp, t);
465
466
  P$5.toInnerRadiusPointOf(t, matrix, temp);
466
467
  return temp;
467
468
  },
@@ -528,7 +529,7 @@ var LeaferUI = (function (exports) {
528
529
  }
529
530
  };
530
531
  const P$5 = PointHelper;
531
- const { getDistanceFrom, copy: copy$a, getAtan2 } = P$5;
532
+ const { getDistanceFrom, copy: copy$b, getAtan2 } = P$5;
532
533
 
533
534
  class Point {
534
535
  constructor(x, y) {
@@ -596,6 +597,7 @@ var LeaferUI = (function (exports) {
596
597
  return this;
597
598
  }
598
599
  }
600
+ const tempPoint$2 = new Point();
599
601
 
600
602
  class Matrix {
601
603
  constructor(a, b, c, d, e, f) {
@@ -605,6 +607,12 @@ var LeaferUI = (function (exports) {
605
607
  typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
606
608
  return this;
607
609
  }
610
+ setWith(dataWithScale) {
611
+ MatrixHelper.copy(this, dataWithScale);
612
+ this.scaleX = dataWithScale.scaleX;
613
+ this.scaleY = dataWithScale.scaleY;
614
+ return this;
615
+ }
608
616
  get() {
609
617
  const { a, b, c, d, e, f } = this;
610
618
  return { a, b, c, d, e, f };
@@ -624,6 +632,12 @@ var LeaferUI = (function (exports) {
624
632
  MatrixHelper.scale(this, x, y);
625
633
  return this;
626
634
  }
635
+ scaleWith(x, y) {
636
+ MatrixHelper.scale(this, x, y);
637
+ this.scaleX *= x;
638
+ this.scaleY *= y || x;
639
+ return this;
640
+ }
627
641
  scaleOfOuter(origin, x, y) {
628
642
  MatrixHelper.scaleOfOuter(this, origin, x, y);
629
643
  return this;
@@ -676,6 +690,12 @@ var LeaferUI = (function (exports) {
676
690
  MatrixHelper.invert(this);
677
691
  return this;
678
692
  }
693
+ invertWith() {
694
+ MatrixHelper.invert(this);
695
+ this.scaleX = 1 / this.scaleX;
696
+ this.scaleY = 1 / this.scaleY;
697
+ return this;
698
+ }
679
699
  toOuterPoint(inner, to, distance) {
680
700
  MatrixHelper.toOuterPoint(this, inner, to, distance);
681
701
  }
@@ -696,6 +716,7 @@ var LeaferUI = (function (exports) {
696
716
  MatrixHelper.reset(this);
697
717
  }
698
718
  }
719
+ const tempMatrix = new Matrix();
699
720
 
700
721
  const TwoPointBoundsHelper = {
701
722
  tempPointBounds: {},
@@ -784,7 +805,7 @@ var LeaferUI = (function (exports) {
784
805
  to = t;
785
806
  }
786
807
  else {
787
- copy$9(to, t);
808
+ copy$a(to, t);
788
809
  }
789
810
  if (parent) {
790
811
  to.offsetX = -(B.maxX(parent) - t.x);
@@ -859,8 +880,8 @@ var LeaferUI = (function (exports) {
859
880
  B.move(to, -matrix.e, -matrix.f);
860
881
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
861
882
  },
862
- getFitMatrix(t, put) {
863
- const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
883
+ getFitMatrix(t, put, baseScale = 1) {
884
+ const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
864
885
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
865
886
  },
866
887
  getSpread(t, spreadX, spreadY) {
@@ -894,11 +915,15 @@ var LeaferUI = (function (exports) {
894
915
  t.width = float(t.width, maxLength);
895
916
  t.height = float(t.height, maxLength);
896
917
  },
897
- add(t, bounds) {
918
+ add(t, bounds, isPoint) {
898
919
  right$1 = t.x + t.width;
899
920
  bottom$1 = t.y + t.height;
900
- boundsRight = bounds.x + bounds.width;
901
- boundsBottom = bounds.y + bounds.height;
921
+ boundsRight = bounds.x;
922
+ boundsBottom = bounds.y;
923
+ if (!isPoint) {
924
+ boundsRight += bounds.width;
925
+ boundsBottom += bounds.height;
926
+ }
902
927
  right$1 = right$1 > boundsRight ? right$1 : boundsRight;
903
928
  bottom$1 = bottom$1 > boundsBottom ? bottom$1 : boundsBottom;
904
929
  t.x = t.x < bounds.x ? t.x : bounds.x;
@@ -923,7 +948,7 @@ var LeaferUI = (function (exports) {
923
948
  if (first) {
924
949
  first = false;
925
950
  if (!addMode)
926
- copy$9(t, bounds);
951
+ copy$a(t, bounds);
927
952
  }
928
953
  else {
929
954
  add$1(t, bounds);
@@ -937,6 +962,9 @@ var LeaferUI = (function (exports) {
937
962
  points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
938
963
  toBounds$4(tempPointBounds$1, t);
939
964
  },
965
+ addPoint(t, point) {
966
+ add$1(t, point, true);
967
+ },
940
968
  getPoints(t) {
941
969
  const { x, y, width, height } = t;
942
970
  return [
@@ -998,7 +1026,7 @@ var LeaferUI = (function (exports) {
998
1026
  }
999
1027
  };
1000
1028
  const B = BoundsHelper;
1001
- const { add: add$1, copy: copy$9 } = B;
1029
+ const { add: add$1, copy: copy$a } = B;
1002
1030
 
1003
1031
  class Bounds {
1004
1032
  get minX() { return BoundsHelper.minX(this); }
@@ -1039,8 +1067,8 @@ var LeaferUI = (function (exports) {
1039
1067
  BoundsHelper.toInnerOf(this, matrix, to);
1040
1068
  return this;
1041
1069
  }
1042
- getFitMatrix(put) {
1043
- return BoundsHelper.getFitMatrix(this, put);
1070
+ getFitMatrix(put, baseScale) {
1071
+ return BoundsHelper.getFitMatrix(this, put, baseScale);
1044
1072
  }
1045
1073
  spread(fourNumber, spreadY) {
1046
1074
  BoundsHelper.spread(this, fourNumber, spreadY);
@@ -1086,6 +1114,10 @@ var LeaferUI = (function (exports) {
1086
1114
  BoundsHelper.setPoints(this, points);
1087
1115
  return this;
1088
1116
  }
1117
+ addPoint(point) {
1118
+ BoundsHelper.addPoint(this, point);
1119
+ return this;
1120
+ }
1089
1121
  getPoints() {
1090
1122
  return BoundsHelper.getPoints(this);
1091
1123
  }
@@ -1118,6 +1150,7 @@ var LeaferUI = (function (exports) {
1118
1150
  BoundsHelper.reset(this);
1119
1151
  }
1120
1152
  }
1153
+ const tempBounds$1 = new Bounds();
1121
1154
 
1122
1155
  class AutoBounds {
1123
1156
  constructor(top, right, bottom, left, width, height) {
@@ -1263,7 +1296,7 @@ var LeaferUI = (function (exports) {
1263
1296
  }
1264
1297
  const D$4 = Debug;
1265
1298
 
1266
- const debug$f = Debug.get('RunTime');
1299
+ const debug$g = Debug.get('RunTime');
1267
1300
  const Run = {
1268
1301
  currentId: 0,
1269
1302
  currentName: '',
@@ -1281,7 +1314,7 @@ var LeaferUI = (function (exports) {
1281
1314
  const time = R.idMap[id], name = R.nameMap[id];
1282
1315
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1283
1316
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1284
- debug$f.log(name, duration, 'ms');
1317
+ debug$g.log(name, duration, 'ms');
1285
1318
  },
1286
1319
  endOfName(name, microsecond) {
1287
1320
  const id = R.nameToIdMap[name];
@@ -1291,13 +1324,13 @@ var LeaferUI = (function (exports) {
1291
1324
  };
1292
1325
  const R = Run;
1293
1326
 
1294
- const debug$e = Debug.get('UICreator');
1327
+ const debug$f = Debug.get('UICreator');
1295
1328
  const UICreator = {
1296
1329
  list: {},
1297
1330
  register(UI) {
1298
1331
  const { __tag: tag } = UI.prototype;
1299
1332
  if (list$2[tag]) {
1300
- debug$e.repeat(tag);
1333
+ debug$f.repeat(tag);
1301
1334
  }
1302
1335
  else {
1303
1336
  list$2[tag] = UI;
@@ -1319,7 +1352,7 @@ var LeaferUI = (function (exports) {
1319
1352
  };
1320
1353
  const { list: list$2 } = UICreator;
1321
1354
 
1322
- const debug$d = Debug.get('EventCreator');
1355
+ const debug$e = Debug.get('EventCreator');
1323
1356
  const EventCreator = {
1324
1357
  nameList: {},
1325
1358
  register(Event) {
@@ -1327,7 +1360,7 @@ var LeaferUI = (function (exports) {
1327
1360
  Object.keys(Event).forEach(key => {
1328
1361
  name = Event[key];
1329
1362
  if (typeof name === 'string')
1330
- nameList[name] ? debug$d.repeat(name) : nameList[name] = Event;
1363
+ nameList[name] ? debug$e.repeat(name) : nameList[name] = Event;
1331
1364
  });
1332
1365
  },
1333
1366
  changeName(oldName, newName) {
@@ -1538,36 +1571,7 @@ var LeaferUI = (function (exports) {
1538
1571
  Answer[Answer["NoAndSkip"] = 2] = "NoAndSkip";
1539
1572
  Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
1540
1573
  })(exports.Answer || (exports.Answer = {}));
1541
-
1542
- const FileHelper = {
1543
- opacityTypes: ['png', 'webp', 'svg'],
1544
- upperCaseTypeMap: {},
1545
- mineType(type) {
1546
- if (!type || type.startsWith('image'))
1547
- return type;
1548
- if (type === 'jpg')
1549
- type = 'jpeg';
1550
- return 'image/' + type;
1551
- },
1552
- fileType(filename) {
1553
- const l = filename.split('.');
1554
- return l[l.length - 1];
1555
- },
1556
- isOpaqueImage(filename) {
1557
- const type = F$4.fileType(filename);
1558
- return ['jpg', 'jpeg'].some(item => item === type);
1559
- },
1560
- getExportOptions(options) {
1561
- switch (typeof options) {
1562
- case 'object': return options;
1563
- case 'number': return { quality: options };
1564
- case 'boolean': return { blob: options };
1565
- default: return {};
1566
- }
1567
- }
1568
- };
1569
- const F$4 = FileHelper;
1570
- F$4.opacityTypes.forEach(type => F$4.upperCaseTypeMap[type] = type.toUpperCase());
1574
+ const emptyData = {};
1571
1575
 
1572
1576
  /******************************************************************************
1573
1577
  Copyright (c) Microsoft Corporation.
@@ -1891,10 +1895,8 @@ var LeaferUI = (function (exports) {
1891
1895
  contextMethod()
1892
1896
  ], Canvas.prototype, "strokeText", null);
1893
1897
 
1894
- const { copy: copy$8 } = MatrixHelper;
1895
- const temp = new Bounds();
1898
+ const { copy: copy$9 } = MatrixHelper;
1896
1899
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
1897
- const debug$c = Debug.get('LeaferCanvasBase');
1898
1900
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
1899
1901
  class LeaferCanvasBase extends Canvas {
1900
1902
  get width() { return this.size.width; }
@@ -1921,44 +1923,15 @@ var LeaferUI = (function (exports) {
1921
1923
  }
1922
1924
  init() { }
1923
1925
  __createContext() {
1924
- this.context = this.view.getContext('2d');
1926
+ const { view } = this;
1927
+ const { contextSettings } = this.config;
1928
+ this.context = contextSettings ? view.getContext('2d', contextSettings) : view.getContext('2d');
1925
1929
  this.__bindContext();
1926
1930
  }
1927
- export(filename, options) {
1928
- const { quality, blob } = FileHelper.getExportOptions(options);
1929
- if (filename.includes('.')) {
1930
- return this.saveAs(filename, quality);
1931
- }
1932
- else if (blob) {
1933
- return this.toBlob(filename, quality);
1934
- }
1935
- else {
1936
- return this.toDataURL(filename, quality);
1937
- }
1938
- }
1939
- toBlob(type, quality) {
1940
- return new Promise((resolve) => {
1941
- Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
1942
- resolve(blob);
1943
- }).catch((e) => {
1944
- debug$c.error(e);
1945
- resolve(null);
1946
- });
1947
- });
1948
- }
1949
- toDataURL(type, quality) {
1950
- return Platform.origin.canvasToDataURL(this.view, type, quality);
1951
- }
1952
- saveAs(filename, quality) {
1953
- return new Promise((resolve) => {
1954
- Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
1955
- resolve(true);
1956
- }).catch((e) => {
1957
- debug$c.error(e);
1958
- resolve(false);
1959
- });
1960
- });
1961
- }
1931
+ export(_filename, _options) { return undefined; }
1932
+ toBlob(_type, _quality) { return undefined; }
1933
+ toDataURL(_type, _quality) { return undefined; }
1934
+ saveAs(_filename, _quality) { return undefined; }
1962
1935
  resize(size) {
1963
1936
  if (this.isSameSize(size))
1964
1937
  return;
@@ -2026,13 +1999,9 @@ var LeaferUI = (function (exports) {
2026
1999
  restoreBlendMode() {
2027
2000
  this.blendMode = this.savedBlendMode;
2028
2001
  }
2029
- hitFill(point, fillRule) {
2030
- return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
2031
- }
2032
- hitStroke(point, strokeWidth) {
2033
- this.strokeWidth = strokeWidth;
2034
- return this.context.isPointInStroke(point.x, point.y);
2035
- }
2002
+ hitFill(_point, _fillRule) { return true; }
2003
+ hitStroke(_point, _strokeWidth) { return true; }
2004
+ hitPixel(_radiusPoint, _offset, _scale = 1) { return true; }
2036
2005
  setWorldShadow(x, y, blur, color) {
2037
2006
  const { pixelRatio } = this;
2038
2007
  this.shadowOffsetX = x * pixelRatio;
@@ -2091,8 +2060,8 @@ var LeaferUI = (function (exports) {
2091
2060
  if (blendMode)
2092
2061
  this.blendMode = blendMode;
2093
2062
  this.fillStyle = color;
2094
- temp.set(bounds).scale(this.pixelRatio);
2095
- this.fillRect(temp.x, temp.y, temp.width, temp.height);
2063
+ tempBounds$1.set(bounds).scale(this.pixelRatio);
2064
+ this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2096
2065
  if (blendMode)
2097
2066
  this.blendMode = 'source-over';
2098
2067
  }
@@ -2100,23 +2069,23 @@ var LeaferUI = (function (exports) {
2100
2069
  if (blendMode)
2101
2070
  this.blendMode = blendMode;
2102
2071
  this.strokeStyle = color;
2103
- temp.set(bounds).scale(this.pixelRatio);
2104
- this.strokeRect(temp.x, temp.y, temp.width, temp.height);
2072
+ tempBounds$1.set(bounds).scale(this.pixelRatio);
2073
+ this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2105
2074
  if (blendMode)
2106
2075
  this.blendMode = 'source-over';
2107
2076
  }
2108
2077
  clearWorld(bounds, ceilPixel) {
2109
- temp.set(bounds).scale(this.pixelRatio);
2078
+ tempBounds$1.set(bounds).scale(this.pixelRatio);
2110
2079
  if (ceilPixel)
2111
- temp.ceil();
2112
- this.clearRect(temp.x, temp.y, temp.width, temp.height);
2080
+ tempBounds$1.ceil();
2081
+ this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2113
2082
  }
2114
2083
  clipWorld(bounds, ceilPixel) {
2115
2084
  this.beginPath();
2116
- temp.set(bounds).scale(this.pixelRatio);
2085
+ tempBounds$1.set(bounds).scale(this.pixelRatio);
2117
2086
  if (ceilPixel)
2118
- temp.ceil();
2119
- this.rect(temp.x, temp.y, temp.width, temp.height);
2087
+ tempBounds$1.ceil();
2088
+ this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2120
2089
  this.clip();
2121
2090
  }
2122
2091
  clear() {
@@ -2130,7 +2099,7 @@ var LeaferUI = (function (exports) {
2130
2099
  const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
2131
2100
  canvas.save();
2132
2101
  if (useSameWorldTransform)
2133
- copy$8(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2102
+ copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2134
2103
  if (useSameSmooth)
2135
2104
  canvas.smooth = this.smooth;
2136
2105
  return canvas;
@@ -2500,10 +2469,10 @@ var LeaferUI = (function (exports) {
2500
2469
  }
2501
2470
  };
2502
2471
 
2503
- const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2472
+ const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2504
2473
  const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2505
2474
  const { ellipticalArc } = EllipseHelper;
2506
- const debug$b = Debug.get('PathConvert');
2475
+ const debug$d = Debug.get('PathConvert');
2507
2476
  const setEndPoint$1 = {};
2508
2477
  const PathConvert = {
2509
2478
  current: { dot: 0 },
@@ -2715,7 +2684,7 @@ var LeaferUI = (function (exports) {
2715
2684
  y = setEndPoint$1.y;
2716
2685
  i += 9;
2717
2686
  break;
2718
- case F$3:
2687
+ case F$4:
2719
2688
  curveMode ? ellipse$4(data, old[i + 1], old[i + 2], old[i + 3], old[i + 4], 0, 0, 360, false) : copyData(data, old, i, 5);
2720
2689
  x = old[i + 1] + old[i + 3];
2721
2690
  y = old[i + 2];
@@ -2740,7 +2709,7 @@ var LeaferUI = (function (exports) {
2740
2709
  i += 6;
2741
2710
  break;
2742
2711
  default:
2743
- debug$b.error(`command: ${command} [index:${i}]`, old);
2712
+ debug$d.error(`command: ${command} [index:${i}]`, old);
2744
2713
  return data;
2745
2714
  }
2746
2715
  lastCommand = command;
@@ -2764,7 +2733,7 @@ var LeaferUI = (function (exports) {
2764
2733
  };
2765
2734
  const { current, pushData, copyData } = PathConvert;
2766
2735
 
2767
- const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2736
+ const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2768
2737
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2769
2738
  const { tan, min, abs: abs$2 } = Math;
2770
2739
  const startPoint = {};
@@ -2806,7 +2775,7 @@ var LeaferUI = (function (exports) {
2806
2775
  },
2807
2776
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2808
2777
  if (rotation === undefined) {
2809
- data.push(F$2, x, y, radiusX, radiusY);
2778
+ data.push(F$3, x, y, radiusX, radiusY);
2810
2779
  }
2811
2780
  else {
2812
2781
  if (startAngle === undefined)
@@ -2856,6 +2825,7 @@ var LeaferUI = (function (exports) {
2856
2825
  set path(value) { this.__path = value; }
2857
2826
  get path() { return this.__path; }
2858
2827
  constructor(path) {
2828
+ this.clearPath = this.beginPath;
2859
2829
  this.set(path);
2860
2830
  }
2861
2831
  set(path) {
@@ -2925,8 +2895,8 @@ var LeaferUI = (function (exports) {
2925
2895
  }
2926
2896
  }
2927
2897
 
2928
- const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
2929
- const debug$a = Debug.get('PathDrawer');
2898
+ const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
2899
+ const debug$c = Debug.get('PathDrawer');
2930
2900
  const PathDrawer = {
2931
2901
  drawPathByData(drawer, data) {
2932
2902
  if (!data)
@@ -2972,7 +2942,7 @@ var LeaferUI = (function (exports) {
2972
2942
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5] * OneRadian, data[i + 6] * OneRadian, data[i + 7] * OneRadian, data[i + 8]);
2973
2943
  i += 9;
2974
2944
  break;
2975
- case F$1:
2945
+ case F$2:
2976
2946
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
2977
2947
  i += 5;
2978
2948
  break;
@@ -2989,17 +2959,17 @@ var LeaferUI = (function (exports) {
2989
2959
  i += 6;
2990
2960
  break;
2991
2961
  default:
2992
- debug$a.error(`command: ${command} [index:${i}]`, data);
2962
+ debug$c.error(`command: ${command} [index:${i}]`, data);
2993
2963
  return;
2994
2964
  }
2995
2965
  }
2996
2966
  }
2997
2967
  };
2998
2968
 
2999
- const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
2969
+ const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
3000
2970
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3001
- const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3002
- const debug$9 = Debug.get('PathBounds');
2971
+ const { addPointBounds, copy: copy$8, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
2972
+ const debug$b = Debug.get('PathBounds');
3003
2973
  let radius, radiusX, radiusY;
3004
2974
  const tempPointBounds = {};
3005
2975
  const setPointBounds = {};
@@ -3071,12 +3041,12 @@ var LeaferUI = (function (exports) {
3071
3041
  break;
3072
3042
  case G:
3073
3043
  ellipse$1(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8], tempPointBounds, setEndPoint);
3074
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3044
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3075
3045
  x = setEndPoint.x;
3076
3046
  y = setEndPoint.y;
3077
3047
  i += 9;
3078
3048
  break;
3079
- case F:
3049
+ case F$1:
3080
3050
  x = data[i + 1];
3081
3051
  y = data[i + 2];
3082
3052
  radiusX = data[i + 3];
@@ -3087,7 +3057,7 @@ var LeaferUI = (function (exports) {
3087
3057
  break;
3088
3058
  case O:
3089
3059
  arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
3090
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3060
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3091
3061
  x = setEndPoint.x;
3092
3062
  y = setEndPoint.y;
3093
3063
  i += 7;
@@ -3102,13 +3072,13 @@ var LeaferUI = (function (exports) {
3102
3072
  break;
3103
3073
  case U:
3104
3074
  arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
3105
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3075
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3106
3076
  x = setEndPoint.x;
3107
3077
  y = setEndPoint.y;
3108
3078
  i += 6;
3109
3079
  break;
3110
3080
  default:
3111
- debug$9.error(`command: ${command} [index:${i}]`, data);
3081
+ debug$b.error(`command: ${command} [index:${i}]`, data);
3112
3082
  return;
3113
3083
  }
3114
3084
  }
@@ -3194,7 +3164,37 @@ var LeaferUI = (function (exports) {
3194
3164
  roundRect(drawer);
3195
3165
  }
3196
3166
 
3197
- const debug$8 = Debug.get('TaskProcessor');
3167
+ const FileHelper = {
3168
+ opacityTypes: ['png', 'webp', 'svg'],
3169
+ upperCaseTypeMap: {},
3170
+ mineType(type) {
3171
+ if (!type || type.startsWith('image'))
3172
+ return type;
3173
+ if (type === 'jpg')
3174
+ type = 'jpeg';
3175
+ return 'image/' + type;
3176
+ },
3177
+ fileType(filename) {
3178
+ const l = filename.split('.');
3179
+ return l[l.length - 1];
3180
+ },
3181
+ isOpaqueImage(filename) {
3182
+ const type = F.fileType(filename);
3183
+ return ['jpg', 'jpeg'].some(item => item === type);
3184
+ },
3185
+ getExportOptions(options) {
3186
+ switch (typeof options) {
3187
+ case 'object': return options;
3188
+ case 'number': return { quality: options };
3189
+ case 'boolean': return { blob: options };
3190
+ default: return {};
3191
+ }
3192
+ }
3193
+ };
3194
+ const F = FileHelper;
3195
+ F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3196
+
3197
+ const debug$a = Debug.get('TaskProcessor');
3198
3198
  class TaskItem {
3199
3199
  constructor(task) {
3200
3200
  this.parallel = true;
@@ -3209,7 +3209,7 @@ var LeaferUI = (function (exports) {
3209
3209
  yield this.task();
3210
3210
  }
3211
3211
  catch (error) {
3212
- debug$8.error(error);
3212
+ debug$a.error(error);
3213
3213
  }
3214
3214
  });
3215
3215
  }
@@ -3493,6 +3493,7 @@ var LeaferUI = (function (exports) {
3493
3493
  },
3494
3494
  destroy() {
3495
3495
  I$1.map = {};
3496
+ I$1.recycledList = [];
3496
3497
  }
3497
3498
  };
3498
3499
  const I$1 = ImageManager;
@@ -3607,84 +3608,75 @@ var LeaferUI = (function (exports) {
3607
3608
  return Object.getOwnPropertyNames(object);
3608
3609
  }
3609
3610
 
3610
- function defineLeafAttr(target, key, defaultValue, mergeDescriptor) {
3611
+ function decorateLeafAttr(defaultValue, descriptorFn) {
3612
+ return (target, key) => defineLeafAttr(target, key, defaultValue, descriptorFn && descriptorFn(key));
3613
+ }
3614
+ function attr(partDescriptor) {
3615
+ return partDescriptor;
3616
+ }
3617
+ function defineLeafAttr(target, key, defaultValue, partDescriptor) {
3611
3618
  const defaultDescriptor = {
3612
3619
  get() { return this.__getAttr(key); },
3613
3620
  set(value) { this.__setAttr(key, value); },
3614
3621
  configurable: true,
3615
3622
  enumerable: true
3616
3623
  };
3617
- defineKey(target, key, Object.assign(defaultDescriptor, mergeDescriptor || {}));
3624
+ defineKey(target, key, Object.assign(defaultDescriptor, partDescriptor || {}));
3618
3625
  defineDataProcessor(target, key, defaultValue);
3619
3626
  }
3620
3627
  function dataType(defaultValue) {
3621
- return (target, key) => {
3622
- defineLeafAttr(target, key, defaultValue);
3623
- };
3628
+ return decorateLeafAttr(defaultValue);
3624
3629
  }
3625
- function positionType(defaultValue) {
3626
- return (target, key) => {
3627
- defineLeafAttr(target, key, defaultValue, {
3628
- set(value) {
3629
- this.__setAttr(key, value);
3630
- this.__layout.matrixChanged || this.__layout.matrixChange();
3631
- }
3632
- });
3633
- };
3630
+ function positionType(defaultValue, checkFiniteNumber) {
3631
+ return decorateLeafAttr(defaultValue, (key) => attr({
3632
+ set(value) {
3633
+ this.__setAttr(key, value, checkFiniteNumber);
3634
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3635
+ }
3636
+ }));
3634
3637
  }
3635
3638
  function autoLayoutType(defaultValue) {
3636
- return (target, key) => {
3637
- defineLeafAttr(target, key, defaultValue, {
3638
- set(value) {
3639
- this.__setAttr(key, value);
3640
- this.__layout.matrixChanged || this.__layout.matrixChange();
3641
- this.__hasAutoLayout = !!value;
3642
- if (!this.__local)
3643
- this.__layout.createLocal();
3644
- }
3645
- });
3646
- };
3639
+ return decorateLeafAttr(defaultValue, (key) => attr({
3640
+ set(value) {
3641
+ this.__setAttr(key, value);
3642
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3643
+ this.__hasAutoLayout = !!value;
3644
+ if (!this.__local)
3645
+ this.__layout.createLocal();
3646
+ }
3647
+ }));
3647
3648
  }
3648
- function scaleType(defaultValue) {
3649
- return (target, key) => {
3650
- defineLeafAttr(target, key, defaultValue, {
3651
- set(value) {
3652
- this.__setAttr(key, value);
3653
- this.__layout.scaleChanged || this.__layout.scaleChange();
3654
- }
3655
- });
3656
- };
3649
+ function scaleType(defaultValue, checkFiniteNumber) {
3650
+ return decorateLeafAttr(defaultValue, (key) => attr({
3651
+ set(value) {
3652
+ this.__setAttr(key, value, checkFiniteNumber);
3653
+ this.__layout.scaleChanged || this.__layout.scaleChange();
3654
+ }
3655
+ }));
3657
3656
  }
3658
- function rotationType(defaultValue) {
3659
- return (target, key) => {
3660
- defineLeafAttr(target, key, defaultValue, {
3661
- set(value) {
3662
- this.__setAttr(key, value);
3663
- this.__layout.rotationChanged || this.__layout.rotationChange();
3664
- }
3665
- });
3666
- };
3657
+ function rotationType(defaultValue, checkFiniteNumber) {
3658
+ return decorateLeafAttr(defaultValue, (key) => attr({
3659
+ set(value) {
3660
+ this.__setAttr(key, value, checkFiniteNumber);
3661
+ this.__layout.rotationChanged || this.__layout.rotationChange();
3662
+ }
3663
+ }));
3667
3664
  }
3668
- function boundsType(defaultValue) {
3669
- return (target, key) => {
3670
- defineLeafAttr(target, key, defaultValue, {
3671
- set(value) {
3672
- this.__setAttr(key, value);
3673
- doBoundsType(this);
3674
- }
3675
- });
3676
- };
3665
+ function boundsType(defaultValue, checkFiniteNumber) {
3666
+ return decorateLeafAttr(defaultValue, (key) => attr({
3667
+ set(value) {
3668
+ this.__setAttr(key, value, checkFiniteNumber) && doBoundsType(this);
3669
+ }
3670
+ }));
3677
3671
  }
3678
3672
  function naturalBoundsType(defaultValue) {
3679
- return (target, key) => {
3680
- defineLeafAttr(target, key, defaultValue, {
3681
- set(value) {
3682
- this.__setAttr(key, value);
3683
- doBoundsType(this);
3684
- this.__.__removeNaturalSize();
3685
- }
3686
- });
3687
- };
3673
+ return decorateLeafAttr(defaultValue, (key) => attr({
3674
+ set(value) {
3675
+ this.__setAttr(key, value);
3676
+ doBoundsType(this);
3677
+ this.__.__removeNaturalSize();
3678
+ }
3679
+ }));
3688
3680
  }
3689
3681
  function doBoundsType(leaf) {
3690
3682
  leaf.__layout.boxChanged || leaf.__layout.boxChange();
@@ -3692,27 +3684,22 @@ var LeaferUI = (function (exports) {
3692
3684
  leaf.__layout.matrixChanged || leaf.__layout.matrixChange();
3693
3685
  }
3694
3686
  function pathInputType(defaultValue) {
3695
- return (target, key) => {
3696
- defineLeafAttr(target, key, defaultValue, {
3697
- set(value) {
3698
- if (this.__.__pathInputed !== 2)
3699
- this.__.__pathInputed = value ? 1 : 0;
3700
- this.__setAttr(key, value);
3701
- doBoundsType(this);
3702
- }
3703
- });
3704
- };
3687
+ return decorateLeafAttr(defaultValue, (key) => attr({
3688
+ set(value) {
3689
+ if (this.__.__pathInputed !== 2)
3690
+ this.__.__pathInputed = value ? 1 : 0;
3691
+ this.__setAttr(key, value);
3692
+ doBoundsType(this);
3693
+ }
3694
+ }));
3705
3695
  }
3706
3696
  const pathType = boundsType;
3707
3697
  function affectStrokeBoundsType(defaultValue) {
3708
- return (target, key) => {
3709
- defineLeafAttr(target, key, defaultValue, {
3710
- set(value) {
3711
- this.__setAttr(key, value);
3712
- doStrokeType(this);
3713
- }
3714
- });
3715
- };
3698
+ return decorateLeafAttr(defaultValue, (key) => attr({
3699
+ set(value) {
3700
+ this.__setAttr(key, value) && doStrokeType(this);
3701
+ }
3702
+ }));
3716
3703
  }
3717
3704
  function doStrokeType(leaf) {
3718
3705
  leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
@@ -3721,91 +3708,75 @@ var LeaferUI = (function (exports) {
3721
3708
  }
3722
3709
  const strokeType = affectStrokeBoundsType;
3723
3710
  function affectRenderBoundsType(defaultValue) {
3724
- return (target, key) => {
3725
- defineLeafAttr(target, key, defaultValue, {
3726
- set(value) {
3727
- this.__setAttr(key, value);
3728
- this.__layout.renderChanged || this.__layout.renderChange();
3729
- }
3730
- });
3731
- };
3711
+ return decorateLeafAttr(defaultValue, (key) => attr({
3712
+ set(value) {
3713
+ this.__setAttr(key, value);
3714
+ this.__layout.renderChanged || this.__layout.renderChange();
3715
+ }
3716
+ }));
3732
3717
  }
3733
3718
  function surfaceType(defaultValue) {
3734
- return (target, key) => {
3735
- defineLeafAttr(target, key, defaultValue, {
3736
- set(value) {
3737
- this.__setAttr(key, value);
3738
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3739
- }
3740
- });
3741
- };
3719
+ return decorateLeafAttr(defaultValue, (key) => attr({
3720
+ set(value) {
3721
+ this.__setAttr(key, value);
3722
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3723
+ }
3724
+ }));
3742
3725
  }
3743
3726
  function opacityType(defaultValue) {
3744
- return (target, key) => {
3745
- defineLeafAttr(target, key, defaultValue, {
3746
- set(value) {
3747
- this.__setAttr(key, value);
3748
- this.__layout.opacityChanged || this.__layout.opacityChange();
3749
- }
3750
- });
3751
- };
3727
+ return decorateLeafAttr(defaultValue, (key) => attr({
3728
+ set(value) {
3729
+ this.__setAttr(key, value);
3730
+ this.__layout.opacityChanged || this.__layout.opacityChange();
3731
+ }
3732
+ }));
3752
3733
  }
3753
3734
  function sortType(defaultValue) {
3754
- return (target, key) => {
3755
- defineLeafAttr(target, key, defaultValue, {
3756
- set(value) {
3757
- this.__setAttr(key, value);
3758
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3759
- this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3760
- }
3761
- });
3762
- };
3735
+ return decorateLeafAttr(defaultValue, (key) => attr({
3736
+ set(value) {
3737
+ this.__setAttr(key, value);
3738
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3739
+ this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3740
+ }
3741
+ }));
3763
3742
  }
3764
3743
  function maskType(defaultValue) {
3765
- return (target, key) => {
3766
- defineLeafAttr(target, key, defaultValue, {
3767
- set(value) {
3768
- this.__setAttr(key, value);
3769
- this.__layout.boxChanged || this.__layout.boxChange();
3770
- this.waitParent(() => { this.parent.__updateMask(value); });
3771
- }
3772
- });
3773
- };
3744
+ return decorateLeafAttr(defaultValue, (key) => attr({
3745
+ set(value) {
3746
+ this.__setAttr(key, value);
3747
+ this.__layout.boxChanged || this.__layout.boxChange();
3748
+ this.waitParent(() => { this.parent.__updateMask(value); });
3749
+ }
3750
+ }));
3774
3751
  }
3775
3752
  function eraserType(defaultValue) {
3776
- return (target, key) => {
3777
- defineLeafAttr(target, key, defaultValue, {
3778
- set(value) {
3779
- this.__setAttr(key, value);
3780
- this.waitParent(() => { this.parent.__updateEraser(value); });
3781
- }
3782
- });
3783
- };
3753
+ return decorateLeafAttr(defaultValue, (key) => attr({
3754
+ set(value) {
3755
+ this.__setAttr(key, value);
3756
+ this.waitParent(() => { this.parent.__updateEraser(value); });
3757
+ }
3758
+ }));
3784
3759
  }
3785
3760
  function hitType(defaultValue) {
3786
- return (target, key) => {
3787
- defineLeafAttr(target, key, defaultValue, {
3788
- set(value) {
3789
- this.__setAttr(key, value);
3790
- if (Debug.showHitView) {
3791
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3792
- }
3793
- if (this.leafer)
3794
- this.leafer.updateCursor();
3761
+ return decorateLeafAttr(defaultValue, (key) => attr({
3762
+ set(value) {
3763
+ this.__setAttr(key, value);
3764
+ if (Debug.showHitView) {
3765
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3795
3766
  }
3796
- });
3797
- };
3767
+ if (this.leafer)
3768
+ this.leafer.updateCursor();
3769
+ }
3770
+ }));
3798
3771
  }
3799
3772
  function cursorType(defaultValue) {
3800
- return (target, key) => {
3801
- defineLeafAttr(target, key, defaultValue, {
3802
- set(value) {
3803
- this.__setAttr(key, value);
3804
- if (this.leafer)
3805
- this.leafer.updateCursor();
3806
- }
3807
- });
3808
- };
3773
+ return decorateLeafAttr(defaultValue, (key) => attr({
3774
+ set(value) {
3775
+ this.__setAttr(key, value);
3776
+ if (this.leafer)
3777
+ this.leafer.updateCursor();
3778
+ }
3779
+ }));
3809
3780
  }
3810
3781
  function dataProcessor(processor) {
3811
3782
  return (target, _key) => {
@@ -3868,7 +3839,7 @@ var LeaferUI = (function (exports) {
3868
3839
  Object.defineProperty(data, key, property);
3869
3840
  }
3870
3841
 
3871
- const debug$7 = new Debug('rewrite');
3842
+ const debug$9 = new Debug('rewrite');
3872
3843
  const list$1 = [];
3873
3844
  const excludeNames = ['destroy', 'constructor'];
3874
3845
  function rewrite(method) {
@@ -3885,7 +3856,7 @@ var LeaferUI = (function (exports) {
3885
3856
  if (list$1.length) {
3886
3857
  list$1.forEach(item => {
3887
3858
  if (error)
3888
- debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
3859
+ debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
3889
3860
  item.run();
3890
3861
  });
3891
3862
  list$1.length = 0;
@@ -3921,8 +3892,8 @@ var LeaferUI = (function (exports) {
3921
3892
  };
3922
3893
  }
3923
3894
 
3924
- const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3925
- const matrix = {};
3895
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3896
+ const matrix$1 = {};
3926
3897
  const LeafHelper = {
3927
3898
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
3928
3899
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
@@ -4000,39 +3971,39 @@ var LeaferUI = (function (exports) {
4000
3971
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4001
3972
  },
4002
3973
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4003
- copy$6(matrix, t.__localMatrix);
4004
- scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4005
- moveByMatrix(t, matrix);
3974
+ copy$7(matrix$1, t.__localMatrix);
3975
+ scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
3976
+ moveByMatrix(t, matrix$1);
4006
3977
  t.scaleResize(scaleX, scaleY, resize !== true);
4007
3978
  },
4008
3979
  rotateOfWorld(t, origin, angle) {
4009
3980
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4010
3981
  },
4011
3982
  rotateOfLocal(t, origin, angle) {
4012
- copy$6(matrix, t.__localMatrix);
4013
- rotateOfOuter$3(matrix, origin, angle);
4014
- moveByMatrix(t, matrix);
3983
+ copy$7(matrix$1, t.__localMatrix);
3984
+ rotateOfOuter$3(matrix$1, origin, angle);
3985
+ moveByMatrix(t, matrix$1);
4015
3986
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4016
3987
  },
4017
3988
  skewOfWorld(t, origin, skewX, skewY, resize) {
4018
3989
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4019
3990
  },
4020
3991
  skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4021
- copy$6(matrix, t.__localMatrix);
4022
- skewOfOuter(matrix, origin, skewX, skewY);
4023
- L.setTransform(t, matrix, resize);
3992
+ copy$7(matrix$1, t.__localMatrix);
3993
+ skewOfOuter(matrix$1, origin, skewX, skewY);
3994
+ L.setTransform(t, matrix$1, resize);
4024
3995
  },
4025
3996
  transformWorld(t, transform, resize) {
4026
- copy$6(matrix, t.worldTransform);
4027
- multiplyParent$2(matrix, transform);
3997
+ copy$7(matrix$1, t.worldTransform);
3998
+ multiplyParent$2(matrix$1, transform);
4028
3999
  if (t.parent)
4029
- divideParent(matrix, t.parent.worldTransform);
4030
- L.setTransform(t, matrix, resize);
4000
+ divideParent(matrix$1, t.parent.worldTransform);
4001
+ L.setTransform(t, matrix$1, resize);
4031
4002
  },
4032
4003
  transform(t, transform, resize) {
4033
- copy$6(matrix, t.localTransform);
4034
- multiplyParent$2(matrix, transform);
4035
- L.setTransform(t, matrix, resize);
4004
+ copy$7(matrix$1, t.localTransform);
4005
+ multiplyParent$2(matrix$1, transform);
4006
+ L.setTransform(t, matrix$1, resize);
4036
4007
  },
4037
4008
  setTransform(t, transform, resize) {
4038
4009
  const layout = getLayout(transform);
@@ -4044,9 +4015,9 @@ var LeaferUI = (function (exports) {
4044
4015
  t.set(layout);
4045
4016
  },
4046
4017
  getRelativeWorld(t, relative, temp) {
4047
- copy$6(matrix, t.worldTransform);
4048
- divideParent(matrix, relative.worldTransform);
4049
- return temp ? matrix : Object.assign({}, matrix);
4018
+ copy$7(matrix$1, t.worldTransform);
4019
+ divideParent(matrix$1, relative.worldTransform);
4020
+ return temp ? matrix$1 : Object.assign({}, matrix$1);
4050
4021
  },
4051
4022
  drop(t, parent, index, resize) {
4052
4023
  t.setTransform(L.getRelativeWorld(t, parent, true), resize);
@@ -4186,7 +4157,7 @@ var LeaferUI = (function (exports) {
4186
4157
 
4187
4158
  const WaitHelper = {
4188
4159
  run(wait) {
4189
- if (wait.length) {
4160
+ if (wait && wait.length) {
4190
4161
  const len = wait.length;
4191
4162
  for (let i = 0; i < len; i++) {
4192
4163
  wait[i]();
@@ -4197,7 +4168,7 @@ var LeaferUI = (function (exports) {
4197
4168
  };
4198
4169
 
4199
4170
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4200
- const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4171
+ const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
4201
4172
  class LeafLayout {
4202
4173
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4203
4174
  get renderBounds() { return this._renderBounds || this.boxBounds; }
@@ -4342,7 +4313,7 @@ var LeaferUI = (function (exports) {
4342
4313
  matrix = getRelativeWorld$1(leaf, relative, true);
4343
4314
  }
4344
4315
  const layoutBounds = MatrixHelper.getLayout(matrix);
4345
- copy$5(layoutBounds, bounds);
4316
+ copy$6(layoutBounds, bounds);
4346
4317
  PointHelper.copy(layoutBounds, point);
4347
4318
  if (unscale) {
4348
4319
  const { scaleX, scaleY } = layoutBounds;
@@ -4736,10 +4707,16 @@ var LeaferUI = (function (exports) {
4736
4707
  LeaferEvent.RESTART = 'leafer.restart';
4737
4708
  LeaferEvent.END = 'leafer.end';
4738
4709
 
4710
+ const { isFinite } = Number;
4711
+ const debug$8 = Debug.get('setAttr');
4739
4712
  const LeafDataProxy = {
4740
- __setAttr(name, newValue) {
4713
+ __setAttr(name, newValue, checkFiniteNumber) {
4741
4714
  if (this.leafer && this.leafer.created) {
4742
4715
  const oldValue = this.__.__getInput(name);
4716
+ if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4717
+ debug$8.warn(this.innerName, name, newValue);
4718
+ newValue = undefined;
4719
+ }
4743
4720
  if (typeof newValue === 'object' || oldValue !== newValue) {
4744
4721
  this.__[name] = newValue;
4745
4722
  if (this.__proxyData)
@@ -4754,12 +4731,17 @@ var LeaferUI = (function (exports) {
4754
4731
  this.emitEvent(event);
4755
4732
  }
4756
4733
  this.leafer.emitEvent(event);
4734
+ return true;
4735
+ }
4736
+ else {
4737
+ return false;
4757
4738
  }
4758
4739
  }
4759
4740
  else {
4760
4741
  this.__[name] = newValue;
4761
4742
  if (this.__proxyData)
4762
4743
  this.setProxyAttr(name, newValue);
4744
+ return true;
4763
4745
  }
4764
4746
  },
4765
4747
  __getAttr(name) {
@@ -4797,7 +4779,7 @@ var LeaferUI = (function (exports) {
4797
4779
 
4798
4780
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
4799
4781
  const { updateBounds: updateBounds$1 } = BranchHelper;
4800
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
4782
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
4801
4783
  const { toBounds: toBounds$2 } = PathBounds;
4802
4784
  const LeafBounds = {
4803
4785
  __updateWorldBounds() {
@@ -4915,7 +4897,8 @@ var LeaferUI = (function (exports) {
4915
4897
  copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
4916
4898
  },
4917
4899
  __updateRenderBounds() {
4918
- copyAndSpread$1(this.__layout.renderBounds, this.__layout.strokeBounds, this.__layout.renderSpread);
4900
+ const { renderSpread, strokeBounds, renderBounds } = this.__layout;
4901
+ renderSpread > 0 ? copyAndSpread$1(renderBounds, strokeBounds, renderSpread) : copy$5(renderBounds, strokeBounds);
4919
4902
  },
4920
4903
  };
4921
4904
 
@@ -5101,7 +5084,7 @@ var LeaferUI = (function (exports) {
5101
5084
  toString() {
5102
5085
  return JSON.stringify(this.toJSON());
5103
5086
  }
5104
- __setAttr(_attrName, _newValue) { }
5087
+ __setAttr(_attrName, _newValue) { return true; }
5105
5088
  __getAttr(_attrName) { return undefined; }
5106
5089
  setProxyAttr(_attrName, _newValue) { }
5107
5090
  getProxyAttr(_attrName) { return undefined; }
@@ -5285,24 +5268,16 @@ var LeaferUI = (function (exports) {
5285
5268
  __scaleResize(_scaleX, _scaleY) { }
5286
5269
  __hitWorld(_point) { return true; }
5287
5270
  __hit(_local) { return true; }
5288
- __hitFill(inner, windingRule) {
5289
- var _a;
5290
- return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, windingRule);
5291
- }
5292
- __hitStroke(inner, strokeWidth) {
5293
- var _a;
5294
- return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth);
5295
- }
5296
- __drawHitPath(canvas) {
5297
- if (canvas)
5298
- this.__drawRenderPath(canvas);
5299
- }
5271
+ __hitFill(_inner) { return true; }
5272
+ __hitStroke(_inner, _strokeWidth) { return true; }
5273
+ __hitPixel(_inner) { return true; }
5274
+ __drawHitPath(_canvas) { }
5300
5275
  __updateHitCanvas() { }
5301
5276
  __render(_canvas, _options) { }
5302
5277
  __drawFast(_canvas, _options) { }
5303
5278
  __draw(_canvas, _options) { }
5304
5279
  __clip(_canvas, _options) { }
5305
- __renderShape(_canvas, _options) { }
5280
+ __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5306
5281
  __updateWorldOpacity() { }
5307
5282
  __updateChange() { }
5308
5283
  __drawPath(_canvas) { }
@@ -5641,7 +5616,7 @@ var LeaferUI = (function (exports) {
5641
5616
  }
5642
5617
  }
5643
5618
 
5644
- const debug$6 = Debug.get('LeaferCanvas');
5619
+ const debug$7 = Debug.get('LeaferCanvas');
5645
5620
  class LeaferCanvas extends LeaferCanvasBase {
5646
5621
  init() {
5647
5622
  const { view } = this.config;
@@ -5694,7 +5669,7 @@ var LeaferUI = (function (exports) {
5694
5669
  }
5695
5670
  }
5696
5671
  else {
5697
- debug$6.error(`no id: ${inputView}`);
5672
+ debug$7.error(`no id: ${inputView}`);
5698
5673
  this.__createView();
5699
5674
  }
5700
5675
  }
@@ -5800,9 +5775,13 @@ var LeaferUI = (function (exports) {
5800
5775
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
5801
5776
  canvasToBolb: (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
5802
5777
  canvasSaveAs: (canvas, filename, quality) => {
5778
+ const url = canvas.toDataURL(mineType(fileType(filename)), quality);
5779
+ return Platform.origin.download(url, filename);
5780
+ },
5781
+ download(url, filename) {
5803
5782
  return new Promise((resolve) => {
5804
5783
  let el = document.createElement('a');
5805
- el.href = canvas.toDataURL(mineType(fileType(filename)), quality);
5784
+ el.href = url;
5806
5785
  el.download = filename;
5807
5786
  document.body.appendChild(el);
5808
5787
  el.click();
@@ -6039,7 +6018,7 @@ var LeaferUI = (function (exports) {
6039
6018
  }
6040
6019
 
6041
6020
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6042
- const debug$5 = Debug.get('Layouter');
6021
+ const debug$6 = Debug.get('Layouter');
6043
6022
  class Layouter {
6044
6023
  constructor(target, userConfig) {
6045
6024
  this.totalTimes = 0;
@@ -6074,7 +6053,7 @@ var LeaferUI = (function (exports) {
6074
6053
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6075
6054
  }
6076
6055
  catch (e) {
6077
- debug$5.error(e);
6056
+ debug$6.error(e);
6078
6057
  }
6079
6058
  this.layoutedBlocks = null;
6080
6059
  }
@@ -6088,9 +6067,9 @@ var LeaferUI = (function (exports) {
6088
6067
  }
6089
6068
  layoutOnce() {
6090
6069
  if (this.layouting)
6091
- return debug$5.warn('layouting');
6070
+ return debug$6.warn('layouting');
6092
6071
  if (this.times > 3)
6093
- return debug$5.warn('layout max times');
6072
+ return debug$6.warn('layout max times');
6094
6073
  this.times++;
6095
6074
  this.totalTimes++;
6096
6075
  this.layouting = true;
@@ -6194,7 +6173,7 @@ var LeaferUI = (function (exports) {
6194
6173
  }
6195
6174
  }
6196
6175
 
6197
- const debug$4 = Debug.get('Renderer');
6176
+ const debug$5 = Debug.get('Renderer');
6198
6177
  class Renderer {
6199
6178
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6200
6179
  constructor(target, canvas, userConfig) {
@@ -6232,7 +6211,7 @@ var LeaferUI = (function (exports) {
6232
6211
  const { target } = this;
6233
6212
  this.times = 0;
6234
6213
  this.totalBounds = new Bounds();
6235
- debug$4.log(target.innerName, '--->');
6214
+ debug$5.log(target.innerName, '--->');
6236
6215
  try {
6237
6216
  this.emitRender(RenderEvent.START);
6238
6217
  this.renderOnce(callback);
@@ -6241,9 +6220,9 @@ var LeaferUI = (function (exports) {
6241
6220
  }
6242
6221
  catch (e) {
6243
6222
  this.rendering = false;
6244
- debug$4.error(e);
6223
+ debug$5.error(e);
6245
6224
  }
6246
- debug$4.log('-------------|');
6225
+ debug$5.log('-------------|');
6247
6226
  }
6248
6227
  renderAgain() {
6249
6228
  if (this.rendering) {
@@ -6255,9 +6234,9 @@ var LeaferUI = (function (exports) {
6255
6234
  }
6256
6235
  renderOnce(callback) {
6257
6236
  if (this.rendering)
6258
- return debug$4.warn('rendering');
6237
+ return debug$5.warn('rendering');
6259
6238
  if (this.times > 3)
6260
- return debug$4.warn('render max times');
6239
+ return debug$5.warn('render max times');
6261
6240
  this.times++;
6262
6241
  this.totalTimes++;
6263
6242
  this.rendering = true;
@@ -6294,7 +6273,7 @@ var LeaferUI = (function (exports) {
6294
6273
  partRender() {
6295
6274
  const { canvas, updateBlocks: list } = this;
6296
6275
  if (!list)
6297
- return debug$4.warn('PartRender: need update attr');
6276
+ return debug$5.warn('PartRender: need update attr');
6298
6277
  this.mergeBlocks();
6299
6278
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6300
6279
  this.clipRender(block); });
@@ -6394,7 +6373,7 @@ var LeaferUI = (function (exports) {
6394
6373
  empty = (!leaf.__world.width || !leaf.__world.height);
6395
6374
  if (empty) {
6396
6375
  if (!leaf.isLeafer)
6397
- debug$4.tip(leaf.innerName, ': empty');
6376
+ debug$5.tip(leaf.innerName, ': empty');
6398
6377
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6399
6378
  }
6400
6379
  return empty;
@@ -6689,51 +6668,42 @@ var LeaferUI = (function (exports) {
6689
6668
  const State = {};
6690
6669
 
6691
6670
  function stateType(defaultValue) {
6692
- return (target, key) => {
6693
- const stateType = key + 'Style';
6694
- defineLeafAttr(target, key, defaultValue, {
6695
- set(value) {
6696
- this.__setAttr(key, value);
6697
- this.waitLeafer(() => { if (State.setStyle)
6698
- State.setStyle(this, stateType, value); });
6699
- }
6700
- });
6701
- };
6671
+ return decorateLeafAttr(defaultValue, (key) => attr({
6672
+ set(value) {
6673
+ this.__setAttr(key, value);
6674
+ this.waitLeafer(() => { if (State.setStyle)
6675
+ State.setStyle(this, key + 'Style', value); });
6676
+ }
6677
+ }));
6702
6678
  }
6703
6679
  function arrowType(defaultValue) {
6704
- return (target, key) => {
6705
- defineLeafAttr(target, key, defaultValue, {
6706
- set(value) {
6707
- this.__setAttr(key, value);
6708
- const data = this.__;
6709
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6710
- doStrokeType(this);
6711
- }
6712
- });
6713
- };
6680
+ return decorateLeafAttr(defaultValue, (key) => attr({
6681
+ set(value) {
6682
+ this.__setAttr(key, value);
6683
+ const data = this.__;
6684
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6685
+ doStrokeType(this);
6686
+ }
6687
+ }));
6714
6688
  }
6715
6689
  function effectType(defaultValue) {
6716
- return (target, key) => {
6717
- defineLeafAttr(target, key, defaultValue, {
6718
- set(value) {
6719
- this.__setAttr(key, value);
6720
- if (value)
6721
- this.__.__useEffect = true;
6722
- this.__layout.renderChanged || this.__layout.renderChange();
6723
- }
6724
- });
6725
- };
6690
+ return decorateLeafAttr(defaultValue, (key) => attr({
6691
+ set(value) {
6692
+ this.__setAttr(key, value);
6693
+ if (value)
6694
+ this.__.__useEffect = true;
6695
+ this.__layout.renderChanged || this.__layout.renderChange();
6696
+ }
6697
+ }));
6726
6698
  }
6727
6699
  function resizeType(defaultValue) {
6728
- return (target, key) => {
6729
- defineLeafAttr(target, key, defaultValue, {
6730
- set(value) {
6731
- this.__setAttr(key, value);
6732
- this.__layout.boxChanged || this.__layout.boxChange();
6733
- this.__updateSize();
6734
- }
6735
- });
6736
- };
6700
+ return decorateLeafAttr(defaultValue, (key) => attr({
6701
+ set(value) {
6702
+ this.__setAttr(key, value);
6703
+ this.__layout.boxChanged || this.__layout.boxChange();
6704
+ this.__updateSize();
6705
+ }
6706
+ }));
6737
6707
  }
6738
6708
  function zoomLayerType() {
6739
6709
  return (target, key) => {
@@ -6748,12 +6718,13 @@ var LeaferUI = (function (exports) {
6748
6718
 
6749
6719
  const { parse } = PathConvert;
6750
6720
  const emptyPaint = {};
6751
- const debug$3 = Debug.get('UIData');
6721
+ const debug$4 = Debug.get('UIData');
6752
6722
  class UIData extends LeafData {
6753
6723
  get __strokeWidth() {
6754
6724
  const { strokeWidth, strokeWidthFixed } = this;
6755
6725
  if (strokeWidthFixed) {
6756
- let { scaleX } = this.__leaf.__nowWorld;
6726
+ const ui = this.__leaf;
6727
+ let { scaleX } = ui.__nowWorld || ui.__world;
6757
6728
  if (scaleX < 0)
6758
6729
  scaleX = -scaleX;
6759
6730
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
@@ -6775,7 +6746,7 @@ var LeaferUI = (function (exports) {
6775
6746
  if (value < 0) {
6776
6747
  this._width = -value;
6777
6748
  this.__leaf.scaleX *= -1;
6778
- debug$3.warn('width < 0, instead -scaleX ', this);
6749
+ debug$4.warn('width < 0, instead -scaleX ', this);
6779
6750
  }
6780
6751
  else {
6781
6752
  this._width = value;
@@ -6785,7 +6756,7 @@ var LeaferUI = (function (exports) {
6785
6756
  if (value < 0) {
6786
6757
  this._height = -value;
6787
6758
  this.__leaf.scaleY *= -1;
6788
- debug$3.warn('height < 0, instead -scaleY', this);
6759
+ debug$4.warn('height < 0, instead -scaleY', this);
6789
6760
  }
6790
6761
  else {
6791
6762
  this._height = value;
@@ -7072,14 +7043,14 @@ var LeaferUI = (function (exports) {
7072
7043
  }
7073
7044
  }
7074
7045
  },
7075
- __renderShape(canvas, options) {
7046
+ __renderShape(canvas, options, ignoreFill, ignoreStroke) {
7076
7047
  if (this.__worldOpacity) {
7077
7048
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
7078
7049
  const { fill, stroke } = this.__;
7079
7050
  this.__drawRenderPath(canvas);
7080
- if (fill)
7051
+ if (fill && !ignoreFill)
7081
7052
  this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7082
- if (stroke)
7053
+ if (stroke && !ignoreStroke)
7083
7054
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7084
7055
  }
7085
7056
  }
@@ -7177,10 +7148,7 @@ var LeaferUI = (function (exports) {
7177
7148
  __onUpdateSize() {
7178
7149
  if (this.__.__input) {
7179
7150
  const data = this.__;
7180
- data.__needComputePaint = true;
7181
- if (data.lazy && this.leafer && !this.leafer.canvas.bounds.hit(this.__world))
7182
- return;
7183
- data.__computePaint();
7151
+ (data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
7184
7152
  }
7185
7153
  }
7186
7154
  __updateRenderPath() {
@@ -7282,31 +7250,31 @@ var LeaferUI = (function (exports) {
7282
7250
  eraserType(false)
7283
7251
  ], exports.UI.prototype, "eraser", void 0);
7284
7252
  __decorate([
7285
- positionType(0)
7253
+ positionType(0, true)
7286
7254
  ], exports.UI.prototype, "x", void 0);
7287
7255
  __decorate([
7288
- positionType(0)
7256
+ positionType(0, true)
7289
7257
  ], exports.UI.prototype, "y", void 0);
7290
7258
  __decorate([
7291
- boundsType(100)
7259
+ boundsType(100, true)
7292
7260
  ], exports.UI.prototype, "width", void 0);
7293
7261
  __decorate([
7294
- boundsType(100)
7262
+ boundsType(100, true)
7295
7263
  ], exports.UI.prototype, "height", void 0);
7296
7264
  __decorate([
7297
- scaleType(1)
7265
+ scaleType(1, true)
7298
7266
  ], exports.UI.prototype, "scaleX", void 0);
7299
7267
  __decorate([
7300
- scaleType(1)
7268
+ scaleType(1, true)
7301
7269
  ], exports.UI.prototype, "scaleY", void 0);
7302
7270
  __decorate([
7303
- rotationType(0)
7271
+ rotationType(0, true)
7304
7272
  ], exports.UI.prototype, "rotation", void 0);
7305
7273
  __decorate([
7306
- rotationType(0)
7274
+ rotationType(0, true)
7307
7275
  ], exports.UI.prototype, "skewX", void 0);
7308
7276
  __decorate([
7309
- rotationType(0)
7277
+ rotationType(0, true)
7310
7278
  ], exports.UI.prototype, "skewY", void 0);
7311
7279
  __decorate([
7312
7280
  autoLayoutType()
@@ -7320,6 +7288,9 @@ var LeaferUI = (function (exports) {
7320
7288
  __decorate([
7321
7289
  dataType('size')
7322
7290
  ], exports.UI.prototype, "editSize", void 0);
7291
+ __decorate([
7292
+ dataType()
7293
+ ], exports.UI.prototype, "editorStyle", void 0);
7323
7294
  __decorate([
7324
7295
  hitType(true)
7325
7296
  ], exports.UI.prototype, "hittable", void 0);
@@ -7386,6 +7357,9 @@ var LeaferUI = (function (exports) {
7386
7357
  __decorate([
7387
7358
  pathType()
7388
7359
  ], exports.UI.prototype, "windingRule", void 0);
7360
+ __decorate([
7361
+ pathType(true)
7362
+ ], exports.UI.prototype, "closed", void 0);
7389
7363
  __decorate([
7390
7364
  arrowType('none')
7391
7365
  ], exports.UI.prototype, "startArrow", void 0);
@@ -7505,14 +7479,17 @@ var LeaferUI = (function (exports) {
7505
7479
  registerUI()
7506
7480
  ], exports.Group);
7507
7481
 
7508
- const debug$2 = Debug.get('Leafer');
7509
- exports.Leafer = class Leafer extends exports.Group {
7482
+ var Leafer_1;
7483
+ const debug$3 = Debug.get('Leafer');
7484
+ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7485
+ static get version() { return '1.0.0-rc.20'; }
7510
7486
  get __tag() { return 'Leafer'; }
7511
7487
  get isApp() { return false; }
7512
7488
  get app() { return this.parent || this; }
7513
7489
  get isLeafer() { return true; }
7514
7490
  get imageReady() { return this.viewReady && ImageManager.isComplete; }
7515
7491
  get layoutLocked() { return !this.layouter.running; }
7492
+ get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7516
7493
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7517
7494
  constructor(userConfig, data) {
7518
7495
  super(data);
@@ -7521,6 +7498,7 @@ var LeaferUI = (function (exports) {
7521
7498
  start: true,
7522
7499
  hittable: true,
7523
7500
  smooth: true,
7501
+ lazySpeard: 100,
7524
7502
  zoom: {
7525
7503
  min: 0.01,
7526
7504
  max: 256
@@ -7541,6 +7519,7 @@ var LeaferUI = (function (exports) {
7541
7519
  this.userConfig = userConfig;
7542
7520
  if (userConfig && (userConfig.view || userConfig.width))
7543
7521
  this.init(userConfig);
7522
+ Leafer_1.list.add(this);
7544
7523
  }
7545
7524
  init(userConfig, parentApp) {
7546
7525
  if (this.canvas)
@@ -7551,19 +7530,20 @@ var LeaferUI = (function (exports) {
7551
7530
  let start;
7552
7531
  const { config } = this;
7553
7532
  this.initType(config.type);
7554
- this.canvas = Creator.canvas(config);
7555
- this.__controllers.push(this.renderer = Creator.renderer(this, this.canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7533
+ const canvas = this.canvas = Creator.canvas(config);
7534
+ this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7556
7535
  if (this.isApp)
7557
7536
  this.__setApp();
7558
7537
  this.__checkAutoLayout(config);
7559
- this.view = this.canvas.view;
7538
+ this.updateLazyBounds();
7539
+ this.view = canvas.view;
7560
7540
  if (parentApp) {
7561
7541
  this.__bindApp(parentApp);
7562
7542
  start = parentApp.running;
7563
7543
  }
7564
7544
  else {
7565
7545
  this.selector = Creator.selector(this);
7566
- this.interaction = Creator.interaction(this, this.canvas, this.selector, config);
7546
+ this.interaction = Creator.interaction(this, canvas, this.selector, config);
7567
7547
  if (this.interaction) {
7568
7548
  this.__controllers.unshift(this.interaction);
7569
7549
  this.hitCanvasManager = Creator.hitCanvasManager();
@@ -7573,23 +7553,17 @@ var LeaferUI = (function (exports) {
7573
7553
  }
7574
7554
  this.hittable = config.hittable;
7575
7555
  this.fill = config.fill;
7576
- this.canvasManager.add(this.canvas);
7556
+ this.canvasManager.add(canvas);
7577
7557
  this.__listenEvents();
7578
7558
  if (start)
7579
7559
  this.__startTimer = setTimeout(this.start.bind(this));
7560
+ WaitHelper.run(this.__initWait);
7580
7561
  this.onInit();
7581
7562
  }
7582
7563
  onInit() { }
7583
7564
  initType(_type) { }
7584
7565
  set(data) {
7585
- if (!this.children) {
7586
- setTimeout(() => {
7587
- super.set(data);
7588
- });
7589
- }
7590
- else {
7591
- super.set(data);
7592
- }
7566
+ this.waitInit(() => { super.set(data); });
7593
7567
  }
7594
7568
  start() {
7595
7569
  clearTimeout(this.__startTimer);
@@ -7634,11 +7608,16 @@ var LeaferUI = (function (exports) {
7634
7608
  if (i)
7635
7609
  cursor ? i.setCursor(cursor) : i.updateCursor();
7636
7610
  }
7611
+ updateLazyBounds() {
7612
+ this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
7613
+ }
7637
7614
  __doResize(size) {
7638
- if (!this.canvas || this.canvas.isSameSize(size))
7615
+ const { canvas } = this;
7616
+ if (!canvas || canvas.isSameSize(size))
7639
7617
  return;
7640
7618
  const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
7641
- this.canvas.resize(size);
7619
+ canvas.resize(size);
7620
+ this.updateLazyBounds();
7642
7621
  this.__onResize(new ResizeEvent(size, old));
7643
7622
  }
7644
7623
  __onResize(event) {
@@ -7676,7 +7655,7 @@ var LeaferUI = (function (exports) {
7676
7655
  this.canvas.hittable = newValue;
7677
7656
  }
7678
7657
  }
7679
- super.__setAttr(attrName, newValue);
7658
+ return super.__setAttr(attrName, newValue);
7680
7659
  }
7681
7660
  __getAttr(attrName) {
7682
7661
  if (this.canvas && canvasSizeAttrs.includes(attrName))
@@ -7743,6 +7722,13 @@ var LeaferUI = (function (exports) {
7743
7722
  this.nextRender(() => this.interaction.updateCursor());
7744
7723
  }
7745
7724
  }
7725
+ waitInit(item, bind) {
7726
+ if (bind)
7727
+ item = item.bind(bind);
7728
+ if (!this.__initWait)
7729
+ this.__initWait = [];
7730
+ this.canvas ? item() : this.__initWait.push(item);
7731
+ }
7746
7732
  waitReady(item, bind) {
7747
7733
  if (bind)
7748
7734
  item = item.bind(bind);
@@ -7782,14 +7768,8 @@ var LeaferUI = (function (exports) {
7782
7768
  }
7783
7769
  }
7784
7770
  zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7785
- validScale(changeScale) {
7786
- const { scaleX } = this.zoomLayer.__, { min, max } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
7787
- if (absScale < min)
7788
- changeScale = min / scaleX;
7789
- else if (absScale > max)
7790
- changeScale = max / scaleX;
7791
- return changeScale;
7792
- }
7771
+ getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
7772
+ getValidScale(changeScale) { return changeScale; }
7793
7773
  __checkUpdateLayout() {
7794
7774
  this.__layout.update();
7795
7775
  }
@@ -7808,9 +7788,10 @@ var LeaferUI = (function (exports) {
7808
7788
  this.off_(this.__eventIds);
7809
7789
  this.__eventIds.length = 0;
7810
7790
  }
7811
- destroy() {
7812
- setTimeout(() => {
7791
+ destroy(sync) {
7792
+ const doDestory = () => {
7813
7793
  if (!this.destroyed) {
7794
+ Leafer_1.list.remove(this);
7814
7795
  try {
7815
7796
  this.stop();
7816
7797
  this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
@@ -7835,19 +7816,21 @@ var LeaferUI = (function (exports) {
7835
7816
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
7836
7817
  }
7837
7818
  catch (e) {
7838
- debug$2.error(e);
7819
+ debug$3.error(e);
7839
7820
  }
7840
7821
  }
7841
- });
7822
+ };
7823
+ sync ? doDestory() : setTimeout(doDestory);
7842
7824
  }
7843
7825
  };
7826
+ exports.Leafer.list = new LeafList();
7844
7827
  __decorate([
7845
7828
  dataProcessor(LeaferData)
7846
7829
  ], exports.Leafer.prototype, "__", void 0);
7847
7830
  __decorate([
7848
7831
  boundsType()
7849
7832
  ], exports.Leafer.prototype, "pixelRatio", void 0);
7850
- exports.Leafer = __decorate([
7833
+ exports.Leafer = Leafer_1 = __decorate([
7851
7834
  registerUI()
7852
7835
  ], exports.Leafer);
7853
7836
 
@@ -7880,11 +7863,9 @@ var LeaferUI = (function (exports) {
7880
7863
  __updateStrokeSpread() { return 0; }
7881
7864
  __updateRectRenderSpread() { return 0; }
7882
7865
  __updateRenderSpread() {
7883
- let width = this.__updateRectRenderSpread() || super.__updateRenderSpread();
7884
- this.__.__drawAfterFill = this.__.overflow === 'hide';
7885
- if (!width)
7886
- width = this.__.__drawAfterFill ? 0 : 1;
7887
- return width;
7866
+ const width = this.__updateRectRenderSpread();
7867
+ const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
7868
+ return (width || hide) ? width : -1;
7888
7869
  }
7889
7870
  __updateRectBoxBounds() { }
7890
7871
  __updateBoxBounds() {
@@ -8078,7 +8059,7 @@ var LeaferUI = (function (exports) {
8078
8059
  __updatePath() {
8079
8060
  const path = this.__.path = [];
8080
8061
  if (this.__.points) {
8081
- drawPoints$1(path, this.__.points, false);
8062
+ drawPoints$1(path, this.__.points, this.__.closed);
8082
8063
  }
8083
8064
  else {
8084
8065
  moveTo$2(path, 0, 0);
@@ -8088,7 +8069,7 @@ var LeaferUI = (function (exports) {
8088
8069
  __updateRenderPath() {
8089
8070
  const data = this.__;
8090
8071
  if (!this.pathInputed && data.points && data.curve) {
8091
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, this.pathClosed);
8072
+ drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
8092
8073
  if (data.__useArrow)
8093
8074
  PathArrow.addArrows(this, false);
8094
8075
  }
@@ -8120,6 +8101,9 @@ var LeaferUI = (function (exports) {
8120
8101
  __decorate([
8121
8102
  pathType(0)
8122
8103
  ], exports.Line.prototype, "curve", void 0);
8104
+ __decorate([
8105
+ pathType(false)
8106
+ ], exports.Line.prototype, "closed", void 0);
8123
8107
  exports.Line = __decorate([
8124
8108
  registerUI()
8125
8109
  ], exports.Line);
@@ -8131,7 +8115,6 @@ var LeaferUI = (function (exports) {
8131
8115
  get __tag() { return 'Polygon'; }
8132
8116
  constructor(data) {
8133
8117
  super(data);
8134
- this.pathClosed = true;
8135
8118
  }
8136
8119
  __updatePath() {
8137
8120
  const path = this.__.path = [];
@@ -8301,6 +8284,9 @@ var LeaferUI = (function (exports) {
8301
8284
  __decorate([
8302
8285
  resizeType(true)
8303
8286
  ], exports.Canvas.prototype, "smooth", void 0);
8287
+ __decorate([
8288
+ resizeType()
8289
+ ], exports.Canvas.prototype, "contextSettings", void 0);
8304
8290
  __decorate([
8305
8291
  hitType('all')
8306
8292
  ], exports.Canvas.prototype, "hitFill", void 0);
@@ -8377,6 +8363,8 @@ var LeaferUI = (function (exports) {
8377
8363
  else {
8378
8364
  super.__updateBoxBounds();
8379
8365
  }
8366
+ if (italic)
8367
+ b.width += fontSize * 0.16;
8380
8368
  const contentBounds = includes(b, bounds) ? b : bounds;
8381
8369
  if (contentBounds !== layout.contentBounds) {
8382
8370
  layout.contentBounds = contentBounds;
@@ -8514,6 +8502,7 @@ var LeaferUI = (function (exports) {
8514
8502
  drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
8515
8503
  drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
8516
8504
  drawPoints(_points, _curve, _close) { return this; }
8505
+ clearPath() { return this; }
8517
8506
  paint() {
8518
8507
  this.pathElement.forceUpdate('path');
8519
8508
  }
@@ -8525,7 +8514,7 @@ var LeaferUI = (function (exports) {
8525
8514
  penPathType()
8526
8515
  ], exports.Pen.prototype, "path", void 0);
8527
8516
  exports.Pen = __decorate([
8528
- useModule(PathCreator, ['beginPath', 'path']),
8517
+ useModule(PathCreator, ['set', 'beginPath', 'path']),
8529
8518
  registerUI()
8530
8519
  ], exports.Pen);
8531
8520
  function penPathType() {
@@ -8536,6 +8525,8 @@ var LeaferUI = (function (exports) {
8536
8525
  };
8537
8526
  }
8538
8527
 
8528
+ const version = "1.0.0-rc.20";
8529
+
8539
8530
  exports.App = class App extends exports.Leafer {
8540
8531
  get __tag() { return 'App'; }
8541
8532
  get isApp() { return true; }
@@ -8627,7 +8618,8 @@ var LeaferUI = (function (exports) {
8627
8618
  if (this.viewReady)
8628
8619
  this.renderer.update();
8629
8620
  }
8630
- __render(canvas, _options) {
8621
+ __render(canvas, options) {
8622
+ canvas.setWorld(options.matrix || this.__world);
8631
8623
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8632
8624
  }
8633
8625
  __onResize(event) {
@@ -8660,11 +8652,6 @@ var LeaferUI = (function (exports) {
8660
8652
  registerUI()
8661
8653
  ], exports.App);
8662
8654
 
8663
- function draw(leafer) {
8664
- const { config } = leafer;
8665
- config.move.dragOut = false;
8666
- }
8667
-
8668
8655
  const downKeyMap = {};
8669
8656
  const Keyboard = {
8670
8657
  isHoldSpaceKey() {
@@ -8859,21 +8846,16 @@ var LeaferUI = (function (exports) {
8859
8846
  registerUIEvent()
8860
8847
  ], exports.KeyEvent);
8861
8848
 
8862
- function design(leafer) {
8849
+ function addInteractionWindow(leafer) {
8863
8850
  if (leafer.isApp)
8864
8851
  return;
8865
8852
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
8866
- let { moveX, moveY } = e;
8867
- if (leafer.config.move.scroll) {
8868
- if (Math.abs(moveX) > Math.abs(moveY))
8869
- moveY = 0;
8870
- else
8871
- moveX = 0;
8872
- }
8873
- leafer.zoomLayer.move(moveX, moveY);
8853
+ const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8854
+ if (x || y)
8855
+ leafer.zoomLayer.move(x, y);
8874
8856
  }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
8875
8857
  const { zoomLayer } = leafer;
8876
- const changeScale = leafer.validScale(e.scale);
8858
+ const changeScale = leafer.getValidScale(e.scale);
8877
8859
  if (changeScale !== 1) {
8878
8860
  PointHelper.scaleOf(zoomLayer, e, changeScale);
8879
8861
  zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
@@ -8881,12 +8863,18 @@ var LeaferUI = (function (exports) {
8881
8863
  }));
8882
8864
  }
8883
8865
 
8884
- const debug$1 = Debug.get('LeaferTypeCreator');
8866
+ function document$1(leafer) {
8867
+ addInteractionWindow(leafer);
8868
+ leafer.config.move.scroll = 'limit';
8869
+ leafer.config.zoom.min = 1;
8870
+ }
8871
+
8872
+ const debug$2 = Debug.get('LeaferTypeCreator');
8885
8873
  const LeaferTypeCreator = {
8886
8874
  list: {},
8887
8875
  register(name, fn) {
8888
8876
  if (list[name]) {
8889
- debug$1.repeat(name);
8877
+ debug$2.repeat(name);
8890
8878
  }
8891
8879
  else {
8892
8880
  list[name] = fn;
@@ -8898,17 +8886,56 @@ var LeaferUI = (function (exports) {
8898
8886
  fn(leafer);
8899
8887
  }
8900
8888
  else {
8901
- debug$1.error('no', name);
8889
+ debug$2.error('no', name);
8902
8890
  }
8903
8891
  }
8904
8892
  };
8905
8893
  const { list, register } = LeaferTypeCreator;
8906
- register('draw', draw);
8907
- register('design', design);
8894
+ register('draw', () => { });
8895
+ register('design', addInteractionWindow);
8896
+ register('document', document$1);
8908
8897
 
8909
8898
  exports.Leafer.prototype.initType = function (type) {
8910
8899
  LeaferTypeCreator.run(type, this);
8911
8900
  };
8901
+ exports.Leafer.prototype.getValidMove = function (moveX, moveY) {
8902
+ const { scroll, disabled } = this.app.config.move;
8903
+ if (scroll) {
8904
+ if (Math.abs(moveX) > Math.abs(moveY))
8905
+ moveY = 0;
8906
+ else
8907
+ moveX = 0;
8908
+ if (scroll === 'limit') {
8909
+ const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
8910
+ const right = x + width - this.width, bottom = y + height - this.height;
8911
+ if (x >= 0 && right <= 0)
8912
+ moveX = 0;
8913
+ else if (moveX > 0) {
8914
+ if (x + moveX > 0)
8915
+ moveX = -x;
8916
+ }
8917
+ else if (moveX < 0 && right + moveX < 0)
8918
+ moveX = -right;
8919
+ if (y >= 0 && bottom <= 0)
8920
+ moveY = 0;
8921
+ else if (moveY > 0) {
8922
+ if (y + moveY > 0)
8923
+ moveY = -y;
8924
+ }
8925
+ else if (moveY < 0 && bottom + moveY < 0)
8926
+ moveY = -bottom;
8927
+ }
8928
+ }
8929
+ return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
8930
+ };
8931
+ exports.Leafer.prototype.getValidScale = function (changeScale) {
8932
+ const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
8933
+ if (absScale < min)
8934
+ changeScale = min / scaleX;
8935
+ else if (absScale > max)
8936
+ changeScale = max / scaleX;
8937
+ return disabled ? 1 : changeScale;
8938
+ };
8912
8939
 
8913
8940
  class Transformer {
8914
8941
  constructor(interaction) {
@@ -9080,7 +9107,7 @@ var LeaferUI = (function (exports) {
9080
9107
  return;
9081
9108
  }
9082
9109
  if (!this.moving && canDrag) {
9083
- if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey)
9110
+ if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
9084
9111
  interaction.emit(exports.MoveEvent.START, this.dragData);
9085
9112
  }
9086
9113
  if (!this.moving) {
@@ -9129,7 +9156,7 @@ var LeaferUI = (function (exports) {
9129
9156
  const list = this.getList();
9130
9157
  if (list.length && running) {
9131
9158
  const { moveX, moveY } = this.dragData;
9132
- list.forEach(leaf => leaf.moveWorld(moveX, moveY));
9159
+ list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9133
9160
  }
9134
9161
  }
9135
9162
  dragOverOrOut(data) {
@@ -9156,7 +9183,7 @@ var LeaferUI = (function (exports) {
9156
9183
  this.dragEnterPath = path;
9157
9184
  }
9158
9185
  dragEnd(data, speed) {
9159
- if (!this.dragData)
9186
+ if (!this.dragging && !this.moving)
9160
9187
  return;
9161
9188
  const { moveX, moveY } = this.dragData;
9162
9189
  if (this.interaction.config.move.dragAnimate && this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
@@ -9179,12 +9206,16 @@ var LeaferUI = (function (exports) {
9179
9206
  if (throughPath)
9180
9207
  endDragData.throughPath = throughPath;
9181
9208
  endDragData.path = path;
9182
- if (this.moving)
9209
+ if (this.moving) {
9210
+ this.moving = false;
9183
9211
  interaction.emit(exports.MoveEvent.END, endDragData);
9212
+ }
9184
9213
  if (this.dragging) {
9214
+ const dropList = this.getList();
9215
+ this.dragging = false;
9185
9216
  interaction.emit(exports.DragEvent.END, endDragData);
9186
- this.swipe(data, endDragData);
9187
- this.drop(data);
9217
+ this.swipe(data, downData, dragData, endDragData);
9218
+ this.drop(data, dropList, this.dragEnterPath);
9188
9219
  }
9189
9220
  this.autoMoveCancel();
9190
9221
  this.dragReset();
@@ -9196,22 +9227,21 @@ var LeaferUI = (function (exports) {
9196
9227
  this.interaction.target.nextRender(animateWait, null, off);
9197
9228
  this.animateWait = func;
9198
9229
  }
9199
- swipe(data, endDragData) {
9200
- const { interaction, downData } = this;
9230
+ swipe(data, downData, dragData, endDragData) {
9231
+ const { interaction } = this;
9201
9232
  if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
9202
- const swipeData = getSwipeEventData(downData, this.dragData, endDragData);
9233
+ const swipeData = getSwipeEventData(downData, dragData, endDragData);
9203
9234
  this.interaction.emit(swipeData.type, swipeData);
9204
9235
  }
9205
9236
  }
9206
- drop(data) {
9207
- const dropData = getDropEventData(data, this.getList(), exports.DragEvent.data);
9208
- dropData.path = this.dragEnterPath;
9237
+ drop(data, dropList, dragEnterPath) {
9238
+ const dropData = getDropEventData(data, dropList, exports.DragEvent.data);
9239
+ dropData.path = dragEnterPath;
9209
9240
  this.interaction.emit(exports.DropEvent.DROP, dropData);
9210
- this.interaction.emit(exports.DragEvent.LEAVE, data, this.dragEnterPath);
9241
+ this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9211
9242
  }
9212
9243
  dragReset() {
9213
9244
  exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9214
- this.dragging = this.moving = false;
9215
9245
  }
9216
9246
  checkDragOut(data) {
9217
9247
  const { interaction } = this;
@@ -9251,7 +9281,7 @@ var LeaferUI = (function (exports) {
9251
9281
  }
9252
9282
  }
9253
9283
 
9254
- const debug = Debug.get('emit');
9284
+ const debug$1 = Debug.get('emit');
9255
9285
  function emit$1(type, data, path, excludePath) {
9256
9286
  if (!path && !data.path)
9257
9287
  return;
@@ -9281,7 +9311,7 @@ var LeaferUI = (function (exports) {
9281
9311
  }
9282
9312
  }
9283
9313
  catch (e) {
9284
- debug.error(e);
9314
+ debug$1.error(e);
9285
9315
  }
9286
9316
  }
9287
9317
  const allowTypes = ['move', 'zoom', 'rotate', 'key'];
@@ -9343,6 +9373,7 @@ var LeaferUI = (function (exports) {
9343
9373
  tapTime: 120,
9344
9374
  longPressTime: 800,
9345
9375
  transformTime: 500,
9376
+ hover: true,
9346
9377
  dragHover: true,
9347
9378
  dragDistance: 2,
9348
9379
  swipeDistance: 20,
@@ -9354,9 +9385,12 @@ var LeaferUI = (function (exports) {
9354
9385
  const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
9355
9386
  class InteractionBase {
9356
9387
  get dragging() { return this.dragger.dragging; }
9388
+ get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9357
9389
  get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9390
+ get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.config.pointer.hover && this.downData && this.isTreePath(this.downData); }
9391
+ get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
9358
9392
  get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
9359
- get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && ((this.config.move.holdMiddleKey && PointerButton.middle(this.downData)) || (this.isHoldRightKey && this.dragger.moving))) || this.isDragEmpty; }
9393
+ get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
9360
9394
  get hitRadius() { return this.config.pointer.hitRadius; }
9361
9395
  constructor(target, canvas, selector, userConfig) {
9362
9396
  this.config = config;
@@ -9398,7 +9432,8 @@ var LeaferUI = (function (exports) {
9398
9432
  this.waitMenuTap = true;
9399
9433
  }
9400
9434
  this.dragger.setDragData(data);
9401
- this.updateCursor(data);
9435
+ if (!this.isHoldRightKey)
9436
+ this.updateCursor(data);
9402
9437
  }
9403
9438
  pointerMove(data) {
9404
9439
  if (!data)
@@ -9416,9 +9451,10 @@ var LeaferUI = (function (exports) {
9416
9451
  }
9417
9452
  }
9418
9453
  pointerMoveReal(data) {
9454
+ const { dragHover, dragDistance } = this.config.pointer;
9419
9455
  this.emit(exports.PointerEvent.BEFORE_MOVE, data, this.defaultPath);
9420
9456
  if (this.downData) {
9421
- const canDrag = PointHelper.getDistance(this.downData, data) > this.config.pointer.dragDistance;
9457
+ const canDrag = PointHelper.getDistance(this.downData, data) > dragDistance;
9422
9458
  if (canDrag) {
9423
9459
  if (this.waitTap)
9424
9460
  this.pointerWaitCancel();
@@ -9430,7 +9466,7 @@ var LeaferUI = (function (exports) {
9430
9466
  this.updateHoverData(data);
9431
9467
  this.checkPath(data);
9432
9468
  this.emit(exports.PointerEvent.MOVE, data);
9433
- if (!(this.dragging && !this.config.pointer.dragHover))
9469
+ if (!(this.dragging && !dragHover))
9434
9470
  this.pointerHover(data);
9435
9471
  if (this.dragger.dragging) {
9436
9472
  this.dragger.dragOverOrOut(data);
@@ -9446,20 +9482,25 @@ var LeaferUI = (function (exports) {
9446
9482
  if (!downData)
9447
9483
  return;
9448
9484
  PointerButton.defaultLeft(data);
9449
- this.downData = null;
9450
9485
  this.findPath(data);
9486
+ const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
9451
9487
  data.path.addList(downData.path.list);
9452
9488
  this.checkPath(data);
9489
+ this.downData = null;
9453
9490
  this.emit(exports.PointerEvent.BEFORE_UP, data);
9454
9491
  this.emit(exports.PointerEvent.UP, data);
9455
9492
  this.touchLeave(data);
9456
- this.tap(data);
9457
- this.menuTap(data);
9493
+ if (!data.isCancel) {
9494
+ this.tap(data);
9495
+ this.menuTap(data);
9496
+ }
9458
9497
  this.dragger.dragEnd(data);
9459
- this.updateCursor(data);
9498
+ this.updateCursor(upData);
9460
9499
  }
9461
9500
  pointerCancel() {
9462
- this.pointerUp(this.dragger.dragData);
9501
+ const data = Object.assign({}, this.dragger.dragData);
9502
+ data.isCancel = true;
9503
+ this.pointerUp(data);
9463
9504
  }
9464
9505
  multiTouch(data, list) {
9465
9506
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
@@ -9509,8 +9550,10 @@ var LeaferUI = (function (exports) {
9509
9550
  this.updateCursor();
9510
9551
  }
9511
9552
  pointerHover(data) {
9512
- this.pointerOverOrOut(data);
9513
- this.pointerEnterOrLeave(data);
9553
+ if (this.config.pointer.hover) {
9554
+ this.pointerOverOrOut(data);
9555
+ this.pointerEnterOrLeave(data);
9556
+ }
9514
9557
  }
9515
9558
  pointerOverOrOut(data) {
9516
9559
  const { path } = data;
@@ -9591,6 +9634,12 @@ var LeaferUI = (function (exports) {
9591
9634
  isRootPath(data) {
9592
9635
  return data && data.path.list[0].isLeafer;
9593
9636
  }
9637
+ isTreePath(data) {
9638
+ const app = this.target.app;
9639
+ if (!app || !app.isApp)
9640
+ return false;
9641
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9642
+ }
9594
9643
  checkPath(data, useDefaultPath) {
9595
9644
  if (useDefaultPath || this.canMove(data))
9596
9645
  data.path = this.defaultPath;
@@ -9637,7 +9686,7 @@ var LeaferUI = (function (exports) {
9637
9686
  this.hoverData = data;
9638
9687
  }
9639
9688
  updateCursor(data) {
9640
- if (this.config.cursor.stop)
9689
+ if (this.config.cursor.stop || !this.config.pointer.hover)
9641
9690
  return;
9642
9691
  if (!data) {
9643
9692
  this.updateHoverData();
@@ -9747,22 +9796,25 @@ var LeaferUI = (function (exports) {
9747
9796
  class HitCanvasManager extends CanvasManager {
9748
9797
  constructor() {
9749
9798
  super(...arguments);
9750
- this.pathTypeList = new LeafList();
9751
- this.imageTypeList = new LeafList();
9799
+ this.maxTotal = 1000;
9800
+ this.pathList = new LeafList();
9801
+ this.pixelList = new LeafList();
9752
9802
  }
9753
- getImageType(leaf, size) {
9754
- this.imageTypeList.add(leaf);
9755
- return Creator.hitCanvas(size);
9803
+ getPixelType(leaf, config) {
9804
+ this.__autoClear();
9805
+ this.pixelList.add(leaf);
9806
+ return Creator.hitCanvas(config);
9756
9807
  }
9757
9808
  getPathType(leaf) {
9758
- this.pathTypeList.add(leaf);
9809
+ this.__autoClear();
9810
+ this.pathList.add(leaf);
9759
9811
  return Creator.hitCanvas();
9760
9812
  }
9761
9813
  clearImageType() {
9762
- this.__clearLeafList(this.imageTypeList);
9814
+ this.__clearLeafList(this.pixelList);
9763
9815
  }
9764
9816
  clearPathType() {
9765
- this.__clearLeafList(this.pathTypeList);
9817
+ this.__clearLeafList(this.pathList);
9766
9818
  }
9767
9819
  __clearLeafList(leafList) {
9768
9820
  if (leafList.length) {
@@ -9775,56 +9827,117 @@ var LeaferUI = (function (exports) {
9775
9827
  leafList.reset();
9776
9828
  }
9777
9829
  }
9830
+ __autoClear() {
9831
+ if (this.pathList.length + this.pixelList.length > this.maxTotal)
9832
+ this.clear();
9833
+ }
9778
9834
  clear() {
9779
9835
  this.clearPathType();
9780
9836
  this.clearImageType();
9781
9837
  }
9782
9838
  }
9783
9839
 
9840
+ const canvas$1 = LeaferCanvasBase.prototype;
9841
+ canvas$1.hitFill = function (point, fillRule) {
9842
+ return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
9843
+ };
9844
+ canvas$1.hitStroke = function (point, strokeWidth) {
9845
+ this.strokeWidth = strokeWidth;
9846
+ return this.context.isPointInStroke(point.x, point.y);
9847
+ };
9848
+ canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
9849
+ let { x, y, radiusX, radiusY } = radiusPoint;
9850
+ if (offset)
9851
+ x -= offset.x, y -= offset.y;
9852
+ tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
9853
+ const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
9854
+ for (let i = 0, len = data.length; i < len; i += 4) {
9855
+ if (data[i + 3] > 0)
9856
+ return true;
9857
+ }
9858
+ return data[3] > 0;
9859
+ };
9860
+
9784
9861
  const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9785
9862
  const inner = {};
9786
- exports.Leaf.prototype.__hitWorld = function (point) {
9787
- if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
9788
- this.__updateHitCanvas();
9789
- if (!this.__layout.boundsChanged)
9790
- this.__layout.hitCanvasChanged = false;
9791
- }
9863
+ const leaf = exports.Leaf.prototype;
9864
+ leaf.__hitWorld = function (point) {
9792
9865
  if (this.__.hitRadius) {
9793
9866
  copy$2(inner, point), point = inner;
9794
9867
  setRadius(point, this.__.hitRadius);
9795
9868
  }
9796
9869
  toInnerRadiusPointOf(point, this.__world, inner);
9797
- if (this.__.hitBox) {
9870
+ const { width, height } = this.__world;
9871
+ const isSmall = width < 10 && height < 10;
9872
+ if (this.__.hitBox || isSmall) {
9798
9873
  if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
9799
9874
  return true;
9875
+ if (isSmall)
9876
+ return false;
9877
+ }
9878
+ if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
9879
+ this.__updateHitCanvas();
9880
+ if (!this.__layout.boundsChanged)
9881
+ this.__layout.hitCanvasChanged = false;
9800
9882
  }
9801
9883
  return this.__hit(inner);
9802
9884
  };
9803
-
9804
- exports.UI.prototype.__updateHitCanvas = function () {
9885
+ leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
9886
+ leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
9887
+ leaf.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
9888
+ leaf.__drawHitPath = function (canvas) { if (canvas)
9889
+ this.__drawRenderPath(canvas); };
9890
+
9891
+ const matrix = new Matrix();
9892
+ const ui$1 = exports.UI.prototype;
9893
+ ui$1.__updateHitCanvas = function () {
9894
+ const data = this.__, { hitCanvasManager } = this.leafer;
9895
+ const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9896
+ const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
9897
+ const isHitPixel = isHitPixelFill || isHitPixelStroke;
9805
9898
  if (!this.__hitCanvas)
9806
- this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this);
9899
+ this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
9807
9900
  const h = this.__hitCanvas;
9901
+ if (isHitPixel) {
9902
+ const { renderBounds } = this.__layout;
9903
+ const size = Platform.image.hitCanvasSize;
9904
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
9905
+ const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
9906
+ h.resize({ width, height, pixelRatio: 1 });
9907
+ h.clear();
9908
+ ImageManager.patternLocked = true;
9909
+ this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
9910
+ ImageManager.patternLocked = false;
9911
+ h.resetTransform();
9912
+ data.__isHitPixel = true;
9913
+ }
9914
+ else {
9915
+ data.__isHitPixel && (data.__isHitPixel = false);
9916
+ }
9808
9917
  this.__drawHitPath(h);
9809
- h.setStrokeOptions(this.__);
9918
+ h.setStrokeOptions(data);
9810
9919
  };
9811
- exports.UI.prototype.__hit = function (inner) {
9920
+ ui$1.__hit = function (inner) {
9812
9921
  if (Platform.name === 'miniapp')
9813
9922
  this.__drawHitPath(this.__hitCanvas);
9814
- const { fill, hitFill, windingRule } = this.__;
9815
- const needHitFill = (fill && hitFill === 'path') || hitFill === 'all';
9816
- const isHitFill = this.__hitFill(inner, windingRule);
9817
- if (needHitFill && isHitFill)
9923
+ const data = this.__;
9924
+ if (data.__isHitPixel && this.__hitPixel(inner))
9925
+ return true;
9926
+ const { hitFill } = data;
9927
+ const needHitFillPath = ((data.fill && hitFill == 'path') || hitFill === 'all');
9928
+ if (needHitFillPath && this.__hitFill(inner))
9818
9929
  return true;
9819
- const { stroke, hitStroke, __strokeWidth, strokeAlign } = this.__;
9820
- const needHitStroke = (stroke && hitStroke === 'path') || hitStroke === 'all';
9930
+ const { hitStroke, __strokeWidth } = data;
9931
+ const needHitStrokePath = ((data.stroke && hitStroke == 'path') || hitStroke === 'all');
9932
+ if (!needHitFillPath && !needHitStrokePath)
9933
+ return false;
9821
9934
  const radiusWidth = inner.radiusX * 2;
9822
9935
  let hitWidth = radiusWidth;
9823
- if (needHitStroke) {
9824
- switch (strokeAlign) {
9936
+ if (needHitStrokePath) {
9937
+ switch (data.strokeAlign) {
9825
9938
  case 'inside':
9826
9939
  hitWidth += __strokeWidth * 2;
9827
- if (!needHitFill && (isHitFill && this.__hitStroke(inner, hitWidth)))
9940
+ if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
9828
9941
  return true;
9829
9942
  hitWidth = radiusWidth;
9830
9943
  break;
@@ -9833,8 +9946,8 @@ var LeaferUI = (function (exports) {
9833
9946
  break;
9834
9947
  case 'outside':
9835
9948
  hitWidth += __strokeWidth * 2;
9836
- if (!needHitFill) {
9837
- if (!isHitFill && this.__hitStroke(inner, hitWidth))
9949
+ if (!needHitFillPath) {
9950
+ if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
9838
9951
  return true;
9839
9952
  hitWidth = radiusWidth;
9840
9953
  }
@@ -9849,8 +9962,8 @@ var LeaferUI = (function (exports) {
9849
9962
  if (this.stroke || this.cornerRadius)
9850
9963
  ui.__updateHitCanvas.call(this);
9851
9964
  };
9852
- exports.Rect.prototype.__hitFill = function (inner, windingRule) {
9853
- return this.__hitCanvas ? ui.__hitFill.call(this, inner, windingRule) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9965
+ exports.Rect.prototype.__hitFill = function (inner) {
9966
+ return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9854
9967
  };
9855
9968
 
9856
9969
  exports.UI.prototype.find = function (condition, options) {
@@ -10574,8 +10687,11 @@ var LeaferUI = (function (exports) {
10574
10687
  }
10575
10688
 
10576
10689
  const { get: get$3, translate } = MatrixHelper;
10690
+ const tempBox = new Bounds();
10577
10691
  function createData(leafPaint, image, paint, box) {
10578
10692
  let { width, height } = image;
10693
+ if (paint.padding)
10694
+ box = tempBox.set(box).shrink(paint.padding);
10579
10695
  const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10580
10696
  const sameBox = box.width === width && box.height === height;
10581
10697
  if (blendMode)
@@ -10659,8 +10775,11 @@ var LeaferUI = (function (exports) {
10659
10775
  leafPaint.loadId = image.load(() => {
10660
10776
  ignoreRender(ui, false);
10661
10777
  if (!ui.destroyed) {
10662
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
10778
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10779
+ if (image.hasOpacityPixel)
10780
+ ui.__layout.hitCanvasChanged = true;
10663
10781
  ui.forceUpdate('surface');
10782
+ }
10664
10783
  onLoadSuccess(ui, event);
10665
10784
  }
10666
10785
  leafPaint.loadId = null;
@@ -10714,7 +10833,7 @@ var LeaferUI = (function (exports) {
10714
10833
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
10715
10834
  const { ceil, abs: abs$1 } = Math;
10716
10835
  function createPattern(ui, paint, pixelRatio) {
10717
- let { scaleX, scaleY } = ui.__nowWorld;
10836
+ let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10718
10837
  const id = scaleX + '-' + scaleY;
10719
10838
  if (paint.patternId !== id && !ui.destroyed) {
10720
10839
  scaleX = abs$1(scaleX);
@@ -10776,7 +10895,7 @@ var LeaferUI = (function (exports) {
10776
10895
 
10777
10896
  const { abs } = Math;
10778
10897
  function checkImage(ui, canvas, paint, allowPaint) {
10779
- const { scaleX, scaleY } = ui.__nowWorld;
10898
+ const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10780
10899
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
10781
10900
  return false;
10782
10901
  }
@@ -11681,7 +11800,7 @@ var LeaferUI = (function (exports) {
11681
11800
  const scale = options.scale || 1;
11682
11801
  const pixelRatio = options.pixelRatio || 1;
11683
11802
  const screenshot = options.screenshot || leaf.isApp;
11684
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
11803
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11685
11804
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
11686
11805
  if (screenshot) {
11687
11806
  renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
@@ -11692,10 +11811,10 @@ var LeaferUI = (function (exports) {
11692
11811
  scaleY = worldTransform.scaleY;
11693
11812
  switch (relative) {
11694
11813
  case 'inner':
11695
- matrix.set(worldTransform).invert();
11814
+ matrix.set(worldTransform);
11696
11815
  break;
11697
11816
  case 'local':
11698
- matrix.set(worldTransform).divide(leaf.localTransform).invert();
11817
+ matrix.set(worldTransform).divide(leaf.localTransform);
11699
11818
  scaleX /= leaf.scaleX;
11700
11819
  scaleY /= leaf.scaleY;
11701
11820
  break;
@@ -11706,7 +11825,7 @@ var LeaferUI = (function (exports) {
11706
11825
  case 'page':
11707
11826
  relative = leaf.leafer;
11708
11827
  default:
11709
- matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
11828
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
11710
11829
  const l = relative.worldTransform;
11711
11830
  scaleX /= scaleX / l.scaleX;
11712
11831
  scaleY /= scaleY / l.scaleY;
@@ -11715,7 +11834,7 @@ var LeaferUI = (function (exports) {
11715
11834
  }
11716
11835
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
11717
11836
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
11718
- const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
11837
+ const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
11719
11838
  if (slice) {
11720
11839
  leaf = leafer;
11721
11840
  renderOptions.bounds = canvas.bounds;
@@ -11761,6 +11880,44 @@ var LeaferUI = (function (exports) {
11761
11880
  });
11762
11881
  }
11763
11882
 
11883
+ const canvas = LeaferCanvasBase.prototype;
11884
+ const debug = Debug.get('@leafer-ui/export');
11885
+ canvas.export = function (filename, options) {
11886
+ const { quality, blob } = FileHelper.getExportOptions(options);
11887
+ if (filename.includes('.')) {
11888
+ return this.saveAs(filename, quality);
11889
+ }
11890
+ else if (blob) {
11891
+ return this.toBlob(filename, quality);
11892
+ }
11893
+ else {
11894
+ return this.toDataURL(filename, quality);
11895
+ }
11896
+ };
11897
+ canvas.toBlob = function (type, quality) {
11898
+ return new Promise((resolve) => {
11899
+ Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
11900
+ resolve(blob);
11901
+ }).catch((e) => {
11902
+ debug.error(e);
11903
+ resolve(null);
11904
+ });
11905
+ });
11906
+ };
11907
+ canvas.toDataURL = function (type, quality) {
11908
+ return Platform.origin.canvasToDataURL(this.view, type, quality);
11909
+ };
11910
+ canvas.saveAs = function (filename, quality) {
11911
+ return new Promise((resolve) => {
11912
+ Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
11913
+ resolve(true);
11914
+ }).catch((e) => {
11915
+ debug.error(e);
11916
+ resolve(false);
11917
+ });
11918
+ });
11919
+ };
11920
+
11764
11921
  Object.assign(TextConvert, TextConvertModule);
11765
11922
  Object.assign(ColorConvert, ColorConvertModule);
11766
11923
  Object.assign(Paint, PaintModule);
@@ -11775,6 +11932,12 @@ var LeaferUI = (function (exports) {
11775
11932
  hitCanvasManager: () => new HitCanvasManager()
11776
11933
  });
11777
11934
  useCanvas();
11935
+ window.addEventListener('unload', () => {
11936
+ const { list } = exports.Leafer;
11937
+ list.forEach(leafer => leafer.destroy(true));
11938
+ list.destroy();
11939
+ ImageManager.destroy();
11940
+ });
11778
11941
 
11779
11942
  exports.AnimateEvent = AnimateEvent;
11780
11943
  exports.AroundHelper = AroundHelper;
@@ -11889,6 +12052,7 @@ var LeaferUI = (function (exports) {
11889
12052
  exports.affectRenderBoundsType = affectRenderBoundsType;
11890
12053
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
11891
12054
  exports.arrowType = arrowType;
12055
+ exports.attr = attr;
11892
12056
  exports.autoLayoutType = autoLayoutType;
11893
12057
  exports.boundsType = boundsType;
11894
12058
  exports.canvasPatch = canvasPatch;
@@ -11896,12 +12060,14 @@ var LeaferUI = (function (exports) {
11896
12060
  exports.cursorType = cursorType;
11897
12061
  exports.dataProcessor = dataProcessor;
11898
12062
  exports.dataType = dataType;
12063
+ exports.decorateLeafAttr = decorateLeafAttr;
11899
12064
  exports.defineDataProcessor = defineDataProcessor;
11900
12065
  exports.defineKey = defineKey;
11901
12066
  exports.defineLeafAttr = defineLeafAttr;
11902
12067
  exports.doBoundsType = doBoundsType;
11903
12068
  exports.doStrokeType = doStrokeType;
11904
12069
  exports.effectType = effectType;
12070
+ exports.emptyData = emptyData;
11905
12071
  exports.eraserType = eraserType;
11906
12072
  exports.getBoundsData = getBoundsData;
11907
12073
  exports.getDescriptor = getDescriptor;
@@ -11927,8 +12093,12 @@ var LeaferUI = (function (exports) {
11927
12093
  exports.stateType = stateType;
11928
12094
  exports.strokeType = strokeType;
11929
12095
  exports.surfaceType = surfaceType;
12096
+ exports.tempBounds = tempBounds$1;
12097
+ exports.tempMatrix = tempMatrix;
12098
+ exports.tempPoint = tempPoint$2;
11930
12099
  exports.useCanvas = useCanvas;
11931
12100
  exports.useModule = useModule;
12101
+ exports.version = version;
11932
12102
  exports.zoomLayerType = zoomLayerType;
11933
12103
 
11934
12104
  return exports;