@leafer-draw/worker 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/worker.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$9(temp, t);
453
+ copy$a(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$9(temp, t);
459
+ copy$a(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$9(temp, t);
465
+ copy$a(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$9, getAtan2 } = P$5;
532
+ const { getDistanceFrom, copy: copy$a, 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$8(to, t);
808
+ copy$9(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$8(t, bounds);
951
+ copy$9(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$8 } = B;
1029
+ const { add: add$1, copy: copy$9 } = 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$c = Debug.get('RunTime');
1299
+ const debug$d = 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$c.log(name, duration, 'ms');
1317
+ debug$d.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$b = Debug.get('UICreator');
1327
+ const debug$c = 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$1[tag]) {
1300
- debug$b.repeat(tag);
1333
+ debug$c.repeat(tag);
1301
1334
  }
1302
1335
  else {
1303
1336
  list$1[tag] = UI;
@@ -1319,7 +1352,7 @@ var LeaferUI = (function (exports) {
1319
1352
  };
1320
1353
  const { list: list$1 } = UICreator;
1321
1354
 
1322
- const debug$a = Debug.get('EventCreator');
1355
+ const debug$b = 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$a.repeat(name) : nameList[name] = Event;
1363
+ nameList[name] ? debug$b.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$7 } = MatrixHelper;
1895
- const temp = new Bounds();
1898
+ const { copy: copy$8 } = MatrixHelper;
1896
1899
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
1897
- const debug$9 = 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$9.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$9.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$7(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2102
+ copy$8(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$8 = Debug.get('PathConvert');
2475
+ const debug$a = 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$8.error(`command: ${command} [index:${i}]`, old);
2712
+ debug$a.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$7 = 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$9 = 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$7.error(`command: ${command} [index:${i}]`, data);
2962
+ debug$9.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$6, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3002
- const debug$6 = Debug.get('PathBounds');
2971
+ const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
2972
+ const debug$8 = 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$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3044
+ i === 0 ? copy$7(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$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3060
+ i === 0 ? copy$7(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$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3075
+ i === 0 ? copy$7(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$6.error(`command: ${command} [index:${i}]`, data);
3081
+ debug$8.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$5 = 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$7 = 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$5.error(error);
3212
+ debug$7.error(error);
3213
3213
  }
3214
3214
  });
3215
3215
  }
@@ -3493,6 +3493,7 @@ var LeaferUI = (function (exports) {
3493
3493
  },
3494
3494
  destroy() {
3495
3495
  I.map = {};
3496
+ I.recycledList = [];
3496
3497
  }
3497
3498
  };
3498
3499
  const I = 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$4 = new Debug('rewrite');
3842
+ const debug$6 = new Debug('rewrite');
3872
3843
  const list = [];
3873
3844
  const excludeNames = ['destroy', 'constructor'];
3874
3845
  function rewrite(method) {
@@ -3885,7 +3856,7 @@ var LeaferUI = (function (exports) {
3885
3856
  if (list.length) {
3886
3857
  list.forEach(item => {
3887
3858
  if (error)
3888
- debug$4.error(item.name, '需在Class上装饰@rewriteAble()');
3859
+ debug$6.error(item.name, '需在Class上装饰@rewriteAble()');
3889
3860
  item.run();
3890
3861
  });
3891
3862
  list.length = 0;
@@ -3921,7 +3892,7 @@ var LeaferUI = (function (exports) {
3921
3892
  };
3922
3893
  }
3923
3894
 
3924
- const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3895
+ const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3925
3896
  const matrix = {};
3926
3897
  const LeafHelper = {
3927
3898
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4000,7 +3971,7 @@ 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$5(matrix, t.__localMatrix);
3974
+ copy$6(matrix, t.__localMatrix);
4004
3975
  scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4005
3976
  moveByMatrix(t, matrix);
4006
3977
  t.scaleResize(scaleX, scaleY, resize !== true);
@@ -4009,7 +3980,7 @@ var LeaferUI = (function (exports) {
4009
3980
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4010
3981
  },
4011
3982
  rotateOfLocal(t, origin, angle) {
4012
- copy$5(matrix, t.__localMatrix);
3983
+ copy$6(matrix, t.__localMatrix);
4013
3984
  rotateOfOuter$3(matrix, origin, angle);
4014
3985
  moveByMatrix(t, matrix);
4015
3986
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
@@ -4018,19 +3989,19 @@ var LeaferUI = (function (exports) {
4018
3989
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4019
3990
  },
4020
3991
  skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4021
- copy$5(matrix, t.__localMatrix);
3992
+ copy$6(matrix, t.__localMatrix);
4022
3993
  skewOfOuter(matrix, origin, skewX, skewY);
4023
3994
  L.setTransform(t, matrix, resize);
4024
3995
  },
4025
3996
  transformWorld(t, transform, resize) {
4026
- copy$5(matrix, t.worldTransform);
3997
+ copy$6(matrix, t.worldTransform);
4027
3998
  multiplyParent$2(matrix, transform);
4028
3999
  if (t.parent)
4029
4000
  divideParent(matrix, t.parent.worldTransform);
4030
4001
  L.setTransform(t, matrix, resize);
4031
4002
  },
4032
4003
  transform(t, transform, resize) {
4033
- copy$5(matrix, t.localTransform);
4004
+ copy$6(matrix, t.localTransform);
4034
4005
  multiplyParent$2(matrix, transform);
4035
4006
  L.setTransform(t, matrix, resize);
4036
4007
  },
@@ -4044,7 +4015,7 @@ var LeaferUI = (function (exports) {
4044
4015
  t.set(layout);
4045
4016
  },
4046
4017
  getRelativeWorld(t, relative, temp) {
4047
- copy$5(matrix, t.worldTransform);
4018
+ copy$6(matrix, t.worldTransform);
4048
4019
  divideParent(matrix, relative.worldTransform);
4049
4020
  return temp ? matrix : Object.assign({}, matrix);
4050
4021
  },
@@ -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$4 } = BoundsHelper;
4171
+ const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = 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$4(layoutBounds, bounds);
4316
+ copy$5(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$5 = 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$5.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$4 } = 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$4(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) { }
@@ -5684,6 +5659,7 @@ var LeaferUI = (function (exports) {
5684
5659
  },
5685
5660
  canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({ type: mineType(type), quality }),
5686
5661
  canvasSaveAs: (_canvas, _filename, _quality) => new Promise((resolve) => resolve()),
5662
+ download(_url, _filename) { return undefined; },
5687
5663
  loadImage(src) {
5688
5664
  return new Promise((resolve, reject) => {
5689
5665
  if (!src.startsWith('data:') && Platform.image.suffix)
@@ -5910,7 +5886,7 @@ var LeaferUI = (function (exports) {
5910
5886
  }
5911
5887
 
5912
5888
  const { updateAllMatrix, updateAllChange } = LeafHelper;
5913
- const debug$3 = Debug.get('Layouter');
5889
+ const debug$4 = Debug.get('Layouter');
5914
5890
  class Layouter {
5915
5891
  constructor(target, userConfig) {
5916
5892
  this.totalTimes = 0;
@@ -5945,7 +5921,7 @@ var LeaferUI = (function (exports) {
5945
5921
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
5946
5922
  }
5947
5923
  catch (e) {
5948
- debug$3.error(e);
5924
+ debug$4.error(e);
5949
5925
  }
5950
5926
  this.layoutedBlocks = null;
5951
5927
  }
@@ -5959,9 +5935,9 @@ var LeaferUI = (function (exports) {
5959
5935
  }
5960
5936
  layoutOnce() {
5961
5937
  if (this.layouting)
5962
- return debug$3.warn('layouting');
5938
+ return debug$4.warn('layouting');
5963
5939
  if (this.times > 3)
5964
- return debug$3.warn('layout max times');
5940
+ return debug$4.warn('layout max times');
5965
5941
  this.times++;
5966
5942
  this.totalTimes++;
5967
5943
  this.layouting = true;
@@ -6065,7 +6041,7 @@ var LeaferUI = (function (exports) {
6065
6041
  }
6066
6042
  }
6067
6043
 
6068
- const debug$2 = Debug.get('Renderer');
6044
+ const debug$3 = Debug.get('Renderer');
6069
6045
  class Renderer {
6070
6046
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6071
6047
  constructor(target, canvas, userConfig) {
@@ -6103,7 +6079,7 @@ var LeaferUI = (function (exports) {
6103
6079
  const { target } = this;
6104
6080
  this.times = 0;
6105
6081
  this.totalBounds = new Bounds();
6106
- debug$2.log(target.innerName, '--->');
6082
+ debug$3.log(target.innerName, '--->');
6107
6083
  try {
6108
6084
  this.emitRender(RenderEvent.START);
6109
6085
  this.renderOnce(callback);
@@ -6112,9 +6088,9 @@ var LeaferUI = (function (exports) {
6112
6088
  }
6113
6089
  catch (e) {
6114
6090
  this.rendering = false;
6115
- debug$2.error(e);
6091
+ debug$3.error(e);
6116
6092
  }
6117
- debug$2.log('-------------|');
6093
+ debug$3.log('-------------|');
6118
6094
  }
6119
6095
  renderAgain() {
6120
6096
  if (this.rendering) {
@@ -6126,9 +6102,9 @@ var LeaferUI = (function (exports) {
6126
6102
  }
6127
6103
  renderOnce(callback) {
6128
6104
  if (this.rendering)
6129
- return debug$2.warn('rendering');
6105
+ return debug$3.warn('rendering');
6130
6106
  if (this.times > 3)
6131
- return debug$2.warn('render max times');
6107
+ return debug$3.warn('render max times');
6132
6108
  this.times++;
6133
6109
  this.totalTimes++;
6134
6110
  this.rendering = true;
@@ -6165,7 +6141,7 @@ var LeaferUI = (function (exports) {
6165
6141
  partRender() {
6166
6142
  const { canvas, updateBlocks: list } = this;
6167
6143
  if (!list)
6168
- return debug$2.warn('PartRender: need update attr');
6144
+ return debug$3.warn('PartRender: need update attr');
6169
6145
  this.mergeBlocks();
6170
6146
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6171
6147
  this.clipRender(block); });
@@ -6265,7 +6241,7 @@ var LeaferUI = (function (exports) {
6265
6241
  empty = (!leaf.__world.width || !leaf.__world.height);
6266
6242
  if (empty) {
6267
6243
  if (!leaf.isLeafer)
6268
- debug$2.tip(leaf.innerName, ': empty');
6244
+ debug$3.tip(leaf.innerName, ': empty');
6269
6245
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6270
6246
  }
6271
6247
  return empty;
@@ -6317,51 +6293,42 @@ var LeaferUI = (function (exports) {
6317
6293
  const State = {};
6318
6294
 
6319
6295
  function stateType(defaultValue) {
6320
- return (target, key) => {
6321
- const stateType = key + 'Style';
6322
- defineLeafAttr(target, key, defaultValue, {
6323
- set(value) {
6324
- this.__setAttr(key, value);
6325
- this.waitLeafer(() => { if (State.setStyle)
6326
- State.setStyle(this, stateType, value); });
6327
- }
6328
- });
6329
- };
6296
+ return decorateLeafAttr(defaultValue, (key) => attr({
6297
+ set(value) {
6298
+ this.__setAttr(key, value);
6299
+ this.waitLeafer(() => { if (State.setStyle)
6300
+ State.setStyle(this, key + 'Style', value); });
6301
+ }
6302
+ }));
6330
6303
  }
6331
6304
  function arrowType(defaultValue) {
6332
- return (target, key) => {
6333
- defineLeafAttr(target, key, defaultValue, {
6334
- set(value) {
6335
- this.__setAttr(key, value);
6336
- const data = this.__;
6337
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6338
- doStrokeType(this);
6339
- }
6340
- });
6341
- };
6305
+ return decorateLeafAttr(defaultValue, (key) => attr({
6306
+ set(value) {
6307
+ this.__setAttr(key, value);
6308
+ const data = this.__;
6309
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6310
+ doStrokeType(this);
6311
+ }
6312
+ }));
6342
6313
  }
6343
6314
  function effectType(defaultValue) {
6344
- return (target, key) => {
6345
- defineLeafAttr(target, key, defaultValue, {
6346
- set(value) {
6347
- this.__setAttr(key, value);
6348
- if (value)
6349
- this.__.__useEffect = true;
6350
- this.__layout.renderChanged || this.__layout.renderChange();
6351
- }
6352
- });
6353
- };
6315
+ return decorateLeafAttr(defaultValue, (key) => attr({
6316
+ set(value) {
6317
+ this.__setAttr(key, value);
6318
+ if (value)
6319
+ this.__.__useEffect = true;
6320
+ this.__layout.renderChanged || this.__layout.renderChange();
6321
+ }
6322
+ }));
6354
6323
  }
6355
6324
  function resizeType(defaultValue) {
6356
- return (target, key) => {
6357
- defineLeafAttr(target, key, defaultValue, {
6358
- set(value) {
6359
- this.__setAttr(key, value);
6360
- this.__layout.boxChanged || this.__layout.boxChange();
6361
- this.__updateSize();
6362
- }
6363
- });
6364
- };
6325
+ return decorateLeafAttr(defaultValue, (key) => attr({
6326
+ set(value) {
6327
+ this.__setAttr(key, value);
6328
+ this.__layout.boxChanged || this.__layout.boxChange();
6329
+ this.__updateSize();
6330
+ }
6331
+ }));
6365
6332
  }
6366
6333
  function zoomLayerType() {
6367
6334
  return (target, key) => {
@@ -6376,12 +6343,13 @@ var LeaferUI = (function (exports) {
6376
6343
 
6377
6344
  const { parse } = PathConvert;
6378
6345
  const emptyPaint = {};
6379
- const debug$1 = Debug.get('UIData');
6346
+ const debug$2 = Debug.get('UIData');
6380
6347
  class UIData extends LeafData {
6381
6348
  get __strokeWidth() {
6382
6349
  const { strokeWidth, strokeWidthFixed } = this;
6383
6350
  if (strokeWidthFixed) {
6384
- let { scaleX } = this.__leaf.__nowWorld;
6351
+ const ui = this.__leaf;
6352
+ let { scaleX } = ui.__nowWorld || ui.__world;
6385
6353
  if (scaleX < 0)
6386
6354
  scaleX = -scaleX;
6387
6355
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
@@ -6403,7 +6371,7 @@ var LeaferUI = (function (exports) {
6403
6371
  if (value < 0) {
6404
6372
  this._width = -value;
6405
6373
  this.__leaf.scaleX *= -1;
6406
- debug$1.warn('width < 0, instead -scaleX ', this);
6374
+ debug$2.warn('width < 0, instead -scaleX ', this);
6407
6375
  }
6408
6376
  else {
6409
6377
  this._width = value;
@@ -6413,7 +6381,7 @@ var LeaferUI = (function (exports) {
6413
6381
  if (value < 0) {
6414
6382
  this._height = -value;
6415
6383
  this.__leaf.scaleY *= -1;
6416
- debug$1.warn('height < 0, instead -scaleY', this);
6384
+ debug$2.warn('height < 0, instead -scaleY', this);
6417
6385
  }
6418
6386
  else {
6419
6387
  this._height = value;
@@ -6700,14 +6668,14 @@ var LeaferUI = (function (exports) {
6700
6668
  }
6701
6669
  }
6702
6670
  },
6703
- __renderShape(canvas, options) {
6671
+ __renderShape(canvas, options, ignoreFill, ignoreStroke) {
6704
6672
  if (this.__worldOpacity) {
6705
6673
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
6706
6674
  const { fill, stroke } = this.__;
6707
6675
  this.__drawRenderPath(canvas);
6708
- if (fill)
6676
+ if (fill && !ignoreFill)
6709
6677
  this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
6710
- if (stroke)
6678
+ if (stroke && !ignoreStroke)
6711
6679
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
6712
6680
  }
6713
6681
  }
@@ -6805,10 +6773,7 @@ var LeaferUI = (function (exports) {
6805
6773
  __onUpdateSize() {
6806
6774
  if (this.__.__input) {
6807
6775
  const data = this.__;
6808
- data.__needComputePaint = true;
6809
- if (data.lazy && this.leafer && !this.leafer.canvas.bounds.hit(this.__world))
6810
- return;
6811
- data.__computePaint();
6776
+ (data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
6812
6777
  }
6813
6778
  }
6814
6779
  __updateRenderPath() {
@@ -6910,31 +6875,31 @@ var LeaferUI = (function (exports) {
6910
6875
  eraserType(false)
6911
6876
  ], exports.UI.prototype, "eraser", void 0);
6912
6877
  __decorate([
6913
- positionType(0)
6878
+ positionType(0, true)
6914
6879
  ], exports.UI.prototype, "x", void 0);
6915
6880
  __decorate([
6916
- positionType(0)
6881
+ positionType(0, true)
6917
6882
  ], exports.UI.prototype, "y", void 0);
6918
6883
  __decorate([
6919
- boundsType(100)
6884
+ boundsType(100, true)
6920
6885
  ], exports.UI.prototype, "width", void 0);
6921
6886
  __decorate([
6922
- boundsType(100)
6887
+ boundsType(100, true)
6923
6888
  ], exports.UI.prototype, "height", void 0);
6924
6889
  __decorate([
6925
- scaleType(1)
6890
+ scaleType(1, true)
6926
6891
  ], exports.UI.prototype, "scaleX", void 0);
6927
6892
  __decorate([
6928
- scaleType(1)
6893
+ scaleType(1, true)
6929
6894
  ], exports.UI.prototype, "scaleY", void 0);
6930
6895
  __decorate([
6931
- rotationType(0)
6896
+ rotationType(0, true)
6932
6897
  ], exports.UI.prototype, "rotation", void 0);
6933
6898
  __decorate([
6934
- rotationType(0)
6899
+ rotationType(0, true)
6935
6900
  ], exports.UI.prototype, "skewX", void 0);
6936
6901
  __decorate([
6937
- rotationType(0)
6902
+ rotationType(0, true)
6938
6903
  ], exports.UI.prototype, "skewY", void 0);
6939
6904
  __decorate([
6940
6905
  autoLayoutType()
@@ -6948,6 +6913,9 @@ var LeaferUI = (function (exports) {
6948
6913
  __decorate([
6949
6914
  dataType('size')
6950
6915
  ], exports.UI.prototype, "editSize", void 0);
6916
+ __decorate([
6917
+ dataType()
6918
+ ], exports.UI.prototype, "editorStyle", void 0);
6951
6919
  __decorate([
6952
6920
  hitType(true)
6953
6921
  ], exports.UI.prototype, "hittable", void 0);
@@ -7014,6 +6982,9 @@ var LeaferUI = (function (exports) {
7014
6982
  __decorate([
7015
6983
  pathType()
7016
6984
  ], exports.UI.prototype, "windingRule", void 0);
6985
+ __decorate([
6986
+ pathType(true)
6987
+ ], exports.UI.prototype, "closed", void 0);
7017
6988
  __decorate([
7018
6989
  arrowType('none')
7019
6990
  ], exports.UI.prototype, "startArrow", void 0);
@@ -7133,14 +7104,17 @@ var LeaferUI = (function (exports) {
7133
7104
  registerUI()
7134
7105
  ], exports.Group);
7135
7106
 
7136
- const debug = Debug.get('Leafer');
7137
- exports.Leafer = class Leafer extends exports.Group {
7107
+ var Leafer_1;
7108
+ const debug$1 = Debug.get('Leafer');
7109
+ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7110
+ static get version() { return '1.0.0-rc.20'; }
7138
7111
  get __tag() { return 'Leafer'; }
7139
7112
  get isApp() { return false; }
7140
7113
  get app() { return this.parent || this; }
7141
7114
  get isLeafer() { return true; }
7142
7115
  get imageReady() { return this.viewReady && ImageManager.isComplete; }
7143
7116
  get layoutLocked() { return !this.layouter.running; }
7117
+ get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7144
7118
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7145
7119
  constructor(userConfig, data) {
7146
7120
  super(data);
@@ -7149,6 +7123,7 @@ var LeaferUI = (function (exports) {
7149
7123
  start: true,
7150
7124
  hittable: true,
7151
7125
  smooth: true,
7126
+ lazySpeard: 100,
7152
7127
  zoom: {
7153
7128
  min: 0.01,
7154
7129
  max: 256
@@ -7169,6 +7144,7 @@ var LeaferUI = (function (exports) {
7169
7144
  this.userConfig = userConfig;
7170
7145
  if (userConfig && (userConfig.view || userConfig.width))
7171
7146
  this.init(userConfig);
7147
+ Leafer_1.list.add(this);
7172
7148
  }
7173
7149
  init(userConfig, parentApp) {
7174
7150
  if (this.canvas)
@@ -7179,19 +7155,20 @@ var LeaferUI = (function (exports) {
7179
7155
  let start;
7180
7156
  const { config } = this;
7181
7157
  this.initType(config.type);
7182
- this.canvas = Creator.canvas(config);
7183
- this.__controllers.push(this.renderer = Creator.renderer(this, this.canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7158
+ const canvas = this.canvas = Creator.canvas(config);
7159
+ this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7184
7160
  if (this.isApp)
7185
7161
  this.__setApp();
7186
7162
  this.__checkAutoLayout(config);
7187
- this.view = this.canvas.view;
7163
+ this.updateLazyBounds();
7164
+ this.view = canvas.view;
7188
7165
  if (parentApp) {
7189
7166
  this.__bindApp(parentApp);
7190
7167
  start = parentApp.running;
7191
7168
  }
7192
7169
  else {
7193
7170
  this.selector = Creator.selector(this);
7194
- this.interaction = Creator.interaction(this, this.canvas, this.selector, config);
7171
+ this.interaction = Creator.interaction(this, canvas, this.selector, config);
7195
7172
  if (this.interaction) {
7196
7173
  this.__controllers.unshift(this.interaction);
7197
7174
  this.hitCanvasManager = Creator.hitCanvasManager();
@@ -7201,23 +7178,17 @@ var LeaferUI = (function (exports) {
7201
7178
  }
7202
7179
  this.hittable = config.hittable;
7203
7180
  this.fill = config.fill;
7204
- this.canvasManager.add(this.canvas);
7181
+ this.canvasManager.add(canvas);
7205
7182
  this.__listenEvents();
7206
7183
  if (start)
7207
7184
  this.__startTimer = setTimeout(this.start.bind(this));
7185
+ WaitHelper.run(this.__initWait);
7208
7186
  this.onInit();
7209
7187
  }
7210
7188
  onInit() { }
7211
7189
  initType(_type) { }
7212
7190
  set(data) {
7213
- if (!this.children) {
7214
- setTimeout(() => {
7215
- super.set(data);
7216
- });
7217
- }
7218
- else {
7219
- super.set(data);
7220
- }
7191
+ this.waitInit(() => { super.set(data); });
7221
7192
  }
7222
7193
  start() {
7223
7194
  clearTimeout(this.__startTimer);
@@ -7262,11 +7233,16 @@ var LeaferUI = (function (exports) {
7262
7233
  if (i)
7263
7234
  cursor ? i.setCursor(cursor) : i.updateCursor();
7264
7235
  }
7236
+ updateLazyBounds() {
7237
+ this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
7238
+ }
7265
7239
  __doResize(size) {
7266
- if (!this.canvas || this.canvas.isSameSize(size))
7240
+ const { canvas } = this;
7241
+ if (!canvas || canvas.isSameSize(size))
7267
7242
  return;
7268
7243
  const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
7269
- this.canvas.resize(size);
7244
+ canvas.resize(size);
7245
+ this.updateLazyBounds();
7270
7246
  this.__onResize(new ResizeEvent(size, old));
7271
7247
  }
7272
7248
  __onResize(event) {
@@ -7304,7 +7280,7 @@ var LeaferUI = (function (exports) {
7304
7280
  this.canvas.hittable = newValue;
7305
7281
  }
7306
7282
  }
7307
- super.__setAttr(attrName, newValue);
7283
+ return super.__setAttr(attrName, newValue);
7308
7284
  }
7309
7285
  __getAttr(attrName) {
7310
7286
  if (this.canvas && canvasSizeAttrs.includes(attrName))
@@ -7371,6 +7347,13 @@ var LeaferUI = (function (exports) {
7371
7347
  this.nextRender(() => this.interaction.updateCursor());
7372
7348
  }
7373
7349
  }
7350
+ waitInit(item, bind) {
7351
+ if (bind)
7352
+ item = item.bind(bind);
7353
+ if (!this.__initWait)
7354
+ this.__initWait = [];
7355
+ this.canvas ? item() : this.__initWait.push(item);
7356
+ }
7374
7357
  waitReady(item, bind) {
7375
7358
  if (bind)
7376
7359
  item = item.bind(bind);
@@ -7410,14 +7393,8 @@ var LeaferUI = (function (exports) {
7410
7393
  }
7411
7394
  }
7412
7395
  zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7413
- validScale(changeScale) {
7414
- const { scaleX } = this.zoomLayer.__, { min, max } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
7415
- if (absScale < min)
7416
- changeScale = min / scaleX;
7417
- else if (absScale > max)
7418
- changeScale = max / scaleX;
7419
- return changeScale;
7420
- }
7396
+ getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
7397
+ getValidScale(changeScale) { return changeScale; }
7421
7398
  __checkUpdateLayout() {
7422
7399
  this.__layout.update();
7423
7400
  }
@@ -7436,9 +7413,10 @@ var LeaferUI = (function (exports) {
7436
7413
  this.off_(this.__eventIds);
7437
7414
  this.__eventIds.length = 0;
7438
7415
  }
7439
- destroy() {
7440
- setTimeout(() => {
7416
+ destroy(sync) {
7417
+ const doDestory = () => {
7441
7418
  if (!this.destroyed) {
7419
+ Leafer_1.list.remove(this);
7442
7420
  try {
7443
7421
  this.stop();
7444
7422
  this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
@@ -7463,19 +7441,21 @@ var LeaferUI = (function (exports) {
7463
7441
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
7464
7442
  }
7465
7443
  catch (e) {
7466
- debug.error(e);
7444
+ debug$1.error(e);
7467
7445
  }
7468
7446
  }
7469
- });
7447
+ };
7448
+ sync ? doDestory() : setTimeout(doDestory);
7470
7449
  }
7471
7450
  };
7451
+ exports.Leafer.list = new LeafList();
7472
7452
  __decorate([
7473
7453
  dataProcessor(LeaferData)
7474
7454
  ], exports.Leafer.prototype, "__", void 0);
7475
7455
  __decorate([
7476
7456
  boundsType()
7477
7457
  ], exports.Leafer.prototype, "pixelRatio", void 0);
7478
- exports.Leafer = __decorate([
7458
+ exports.Leafer = Leafer_1 = __decorate([
7479
7459
  registerUI()
7480
7460
  ], exports.Leafer);
7481
7461
 
@@ -7508,11 +7488,9 @@ var LeaferUI = (function (exports) {
7508
7488
  __updateStrokeSpread() { return 0; }
7509
7489
  __updateRectRenderSpread() { return 0; }
7510
7490
  __updateRenderSpread() {
7511
- let width = this.__updateRectRenderSpread() || super.__updateRenderSpread();
7512
- this.__.__drawAfterFill = this.__.overflow === 'hide';
7513
- if (!width)
7514
- width = this.__.__drawAfterFill ? 0 : 1;
7515
- return width;
7491
+ const width = this.__updateRectRenderSpread();
7492
+ const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
7493
+ return (width || hide) ? width : -1;
7516
7494
  }
7517
7495
  __updateRectBoxBounds() { }
7518
7496
  __updateBoxBounds() {
@@ -7706,7 +7684,7 @@ var LeaferUI = (function (exports) {
7706
7684
  __updatePath() {
7707
7685
  const path = this.__.path = [];
7708
7686
  if (this.__.points) {
7709
- drawPoints$1(path, this.__.points, false);
7687
+ drawPoints$1(path, this.__.points, this.__.closed);
7710
7688
  }
7711
7689
  else {
7712
7690
  moveTo$2(path, 0, 0);
@@ -7716,7 +7694,7 @@ var LeaferUI = (function (exports) {
7716
7694
  __updateRenderPath() {
7717
7695
  const data = this.__;
7718
7696
  if (!this.pathInputed && data.points && data.curve) {
7719
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, this.pathClosed);
7697
+ drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
7720
7698
  if (data.__useArrow)
7721
7699
  PathArrow.addArrows(this, false);
7722
7700
  }
@@ -7748,6 +7726,9 @@ var LeaferUI = (function (exports) {
7748
7726
  __decorate([
7749
7727
  pathType(0)
7750
7728
  ], exports.Line.prototype, "curve", void 0);
7729
+ __decorate([
7730
+ pathType(false)
7731
+ ], exports.Line.prototype, "closed", void 0);
7751
7732
  exports.Line = __decorate([
7752
7733
  registerUI()
7753
7734
  ], exports.Line);
@@ -7759,7 +7740,6 @@ var LeaferUI = (function (exports) {
7759
7740
  get __tag() { return 'Polygon'; }
7760
7741
  constructor(data) {
7761
7742
  super(data);
7762
- this.pathClosed = true;
7763
7743
  }
7764
7744
  __updatePath() {
7765
7745
  const path = this.__.path = [];
@@ -7929,6 +7909,9 @@ var LeaferUI = (function (exports) {
7929
7909
  __decorate([
7930
7910
  resizeType(true)
7931
7911
  ], exports.Canvas.prototype, "smooth", void 0);
7912
+ __decorate([
7913
+ resizeType()
7914
+ ], exports.Canvas.prototype, "contextSettings", void 0);
7932
7915
  __decorate([
7933
7916
  hitType('all')
7934
7917
  ], exports.Canvas.prototype, "hitFill", void 0);
@@ -8005,6 +7988,8 @@ var LeaferUI = (function (exports) {
8005
7988
  else {
8006
7989
  super.__updateBoxBounds();
8007
7990
  }
7991
+ if (italic)
7992
+ b.width += fontSize * 0.16;
8008
7993
  const contentBounds = includes(b, bounds) ? b : bounds;
8009
7994
  if (contentBounds !== layout.contentBounds) {
8010
7995
  layout.contentBounds = contentBounds;
@@ -8142,6 +8127,7 @@ var LeaferUI = (function (exports) {
8142
8127
  drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
8143
8128
  drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
8144
8129
  drawPoints(_points, _curve, _close) { return this; }
8130
+ clearPath() { return this; }
8145
8131
  paint() {
8146
8132
  this.pathElement.forceUpdate('path');
8147
8133
  }
@@ -8153,7 +8139,7 @@ var LeaferUI = (function (exports) {
8153
8139
  penPathType()
8154
8140
  ], exports.Pen.prototype, "path", void 0);
8155
8141
  exports.Pen = __decorate([
8156
- useModule(PathCreator, ['beginPath', 'path']),
8142
+ useModule(PathCreator, ['set', 'beginPath', 'path']),
8157
8143
  registerUI()
8158
8144
  ], exports.Pen);
8159
8145
  function penPathType() {
@@ -8164,6 +8150,8 @@ var LeaferUI = (function (exports) {
8164
8150
  };
8165
8151
  }
8166
8152
 
8153
+ const version = "1.0.0-rc.20";
8154
+
8167
8155
  function fillText(ui, canvas) {
8168
8156
  let row;
8169
8157
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
@@ -8525,8 +8513,11 @@ var LeaferUI = (function (exports) {
8525
8513
  }
8526
8514
 
8527
8515
  const { get: get$3, translate } = MatrixHelper;
8516
+ const tempBox = new Bounds();
8528
8517
  function createData(leafPaint, image, paint, box) {
8529
8518
  let { width, height } = image;
8519
+ if (paint.padding)
8520
+ box = tempBox.set(box).shrink(paint.padding);
8530
8521
  const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
8531
8522
  const sameBox = box.width === width && box.height === height;
8532
8523
  if (blendMode)
@@ -8610,8 +8601,11 @@ var LeaferUI = (function (exports) {
8610
8601
  leafPaint.loadId = image.load(() => {
8611
8602
  ignoreRender(ui, false);
8612
8603
  if (!ui.destroyed) {
8613
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
8604
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
8605
+ if (image.hasOpacityPixel)
8606
+ ui.__layout.hitCanvasChanged = true;
8614
8607
  ui.forceUpdate('surface');
8608
+ }
8615
8609
  onLoadSuccess(ui, event);
8616
8610
  }
8617
8611
  leafPaint.loadId = null;
@@ -8665,7 +8659,7 @@ var LeaferUI = (function (exports) {
8665
8659
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
8666
8660
  const { ceil, abs: abs$1 } = Math;
8667
8661
  function createPattern(ui, paint, pixelRatio) {
8668
- let { scaleX, scaleY } = ui.__nowWorld;
8662
+ let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
8669
8663
  const id = scaleX + '-' + scaleY;
8670
8664
  if (paint.patternId !== id && !ui.destroyed) {
8671
8665
  scaleX = abs$1(scaleX);
@@ -8727,7 +8721,7 @@ var LeaferUI = (function (exports) {
8727
8721
 
8728
8722
  const { abs } = Math;
8729
8723
  function checkImage(ui, canvas, paint, allowPaint) {
8730
- const { scaleX, scaleY } = ui.__nowWorld;
8724
+ const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
8731
8725
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
8732
8726
  return false;
8733
8727
  }
@@ -9632,7 +9626,7 @@ var LeaferUI = (function (exports) {
9632
9626
  const scale = options.scale || 1;
9633
9627
  const pixelRatio = options.pixelRatio || 1;
9634
9628
  const screenshot = options.screenshot || leaf.isApp;
9635
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
9629
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
9636
9630
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
9637
9631
  if (screenshot) {
9638
9632
  renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
@@ -9643,10 +9637,10 @@ var LeaferUI = (function (exports) {
9643
9637
  scaleY = worldTransform.scaleY;
9644
9638
  switch (relative) {
9645
9639
  case 'inner':
9646
- matrix.set(worldTransform).invert();
9640
+ matrix.set(worldTransform);
9647
9641
  break;
9648
9642
  case 'local':
9649
- matrix.set(worldTransform).divide(leaf.localTransform).invert();
9643
+ matrix.set(worldTransform).divide(leaf.localTransform);
9650
9644
  scaleX /= leaf.scaleX;
9651
9645
  scaleY /= leaf.scaleY;
9652
9646
  break;
@@ -9657,7 +9651,7 @@ var LeaferUI = (function (exports) {
9657
9651
  case 'page':
9658
9652
  relative = leaf.leafer;
9659
9653
  default:
9660
- matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
9654
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
9661
9655
  const l = relative.worldTransform;
9662
9656
  scaleX /= scaleX / l.scaleX;
9663
9657
  scaleY /= scaleY / l.scaleY;
@@ -9666,7 +9660,7 @@ var LeaferUI = (function (exports) {
9666
9660
  }
9667
9661
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
9668
9662
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
9669
- const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
9663
+ const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
9670
9664
  if (slice) {
9671
9665
  leaf = leafer;
9672
9666
  renderOptions.bounds = canvas.bounds;
@@ -9712,6 +9706,44 @@ var LeaferUI = (function (exports) {
9712
9706
  });
9713
9707
  }
9714
9708
 
9709
+ const canvas = LeaferCanvasBase.prototype;
9710
+ const debug = Debug.get('@leafer-ui/export');
9711
+ canvas.export = function (filename, options) {
9712
+ const { quality, blob } = FileHelper.getExportOptions(options);
9713
+ if (filename.includes('.')) {
9714
+ return this.saveAs(filename, quality);
9715
+ }
9716
+ else if (blob) {
9717
+ return this.toBlob(filename, quality);
9718
+ }
9719
+ else {
9720
+ return this.toDataURL(filename, quality);
9721
+ }
9722
+ };
9723
+ canvas.toBlob = function (type, quality) {
9724
+ return new Promise((resolve) => {
9725
+ Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
9726
+ resolve(blob);
9727
+ }).catch((e) => {
9728
+ debug.error(e);
9729
+ resolve(null);
9730
+ });
9731
+ });
9732
+ };
9733
+ canvas.toDataURL = function (type, quality) {
9734
+ return Platform.origin.canvasToDataURL(this.view, type, quality);
9735
+ };
9736
+ canvas.saveAs = function (filename, quality) {
9737
+ return new Promise((resolve) => {
9738
+ Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
9739
+ resolve(true);
9740
+ }).catch((e) => {
9741
+ debug.error(e);
9742
+ resolve(false);
9743
+ });
9744
+ });
9745
+ };
9746
+
9715
9747
  Object.assign(TextConvert, TextConvertModule);
9716
9748
  Object.assign(ColorConvert, ColorConvertModule);
9717
9749
  Object.assign(Paint, PaintModule);
@@ -9824,6 +9856,7 @@ var LeaferUI = (function (exports) {
9824
9856
  exports.affectRenderBoundsType = affectRenderBoundsType;
9825
9857
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
9826
9858
  exports.arrowType = arrowType;
9859
+ exports.attr = attr;
9827
9860
  exports.autoLayoutType = autoLayoutType;
9828
9861
  exports.boundsType = boundsType;
9829
9862
  exports.canvasPatch = canvasPatch;
@@ -9831,12 +9864,14 @@ var LeaferUI = (function (exports) {
9831
9864
  exports.cursorType = cursorType;
9832
9865
  exports.dataProcessor = dataProcessor;
9833
9866
  exports.dataType = dataType;
9867
+ exports.decorateLeafAttr = decorateLeafAttr;
9834
9868
  exports.defineDataProcessor = defineDataProcessor;
9835
9869
  exports.defineKey = defineKey;
9836
9870
  exports.defineLeafAttr = defineLeafAttr;
9837
9871
  exports.doBoundsType = doBoundsType;
9838
9872
  exports.doStrokeType = doStrokeType;
9839
9873
  exports.effectType = effectType;
9874
+ exports.emptyData = emptyData;
9840
9875
  exports.eraserType = eraserType;
9841
9876
  exports.getBoundsData = getBoundsData;
9842
9877
  exports.getDescriptor = getDescriptor;
@@ -9862,8 +9897,12 @@ var LeaferUI = (function (exports) {
9862
9897
  exports.stateType = stateType;
9863
9898
  exports.strokeType = strokeType;
9864
9899
  exports.surfaceType = surfaceType;
9900
+ exports.tempBounds = tempBounds$1;
9901
+ exports.tempMatrix = tempMatrix;
9902
+ exports.tempPoint = tempPoint$2;
9865
9903
  exports.useCanvas = useCanvas;
9866
9904
  exports.useModule = useModule;
9905
+ exports.version = version;
9867
9906
  exports.zoomLayerType = zoomLayerType;
9868
9907
 
9869
9908
  return exports;