@leafer/core 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/lib/core.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const Platform = {
4
4
  image: {
5
+ hitCanvasSize: 100,
5
6
  maxCacheSize: 2560 * 1600,
6
7
  maxPatternSize: 4096 * 2160,
7
8
  suffix: 'leaf',
@@ -43,7 +44,7 @@ const MathHelper = {
43
44
  minus(value, isFourNumber) {
44
45
  if (value instanceof Array) {
45
46
  if (isFourNumber)
46
- value = MathHelper.fourNumber(value);
47
+ value = MathHelper.fourNumber(value, 0);
47
48
  for (let i = 0; i < value.length; i++)
48
49
  value[i] = -value[i];
49
50
  }
@@ -57,7 +58,7 @@ const MathHelper = {
57
58
  if (num instanceof Array) {
58
59
  switch (num.length) {
59
60
  case 4:
60
- data = num;
61
+ data = maxValue === undefined ? num : [...num];
61
62
  break;
62
63
  case 2:
63
64
  data = [num[0], num[1], num[0], num[1]];
@@ -118,7 +119,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
118
119
 
119
120
  const { sin: sin$3, cos: cos$3, acos, sqrt: sqrt$3 } = Math;
120
121
  const { float: float$1 } = MathHelper;
121
- const tempPoint$2 = {};
122
+ const tempPoint$3 = {};
122
123
  function getWorld() {
123
124
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
124
125
  }
@@ -159,8 +160,8 @@ const MatrixHelper = {
159
160
  t.d *= scaleY;
160
161
  },
161
162
  scaleOfOuter(t, origin, scaleX, scaleY) {
162
- M$6.toInnerPoint(t, origin, tempPoint$2);
163
- M$6.scaleOfInner(t, tempPoint$2, scaleX, scaleY);
163
+ M$6.toInnerPoint(t, origin, tempPoint$3);
164
+ M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
164
165
  },
165
166
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
166
167
  M$6.translateInner(t, origin.x, origin.y);
@@ -178,8 +179,8 @@ const MatrixHelper = {
178
179
  t.d = c * sinR + d * cosR;
179
180
  },
180
181
  rotateOfOuter(t, origin, rotation) {
181
- M$6.toInnerPoint(t, origin, tempPoint$2);
182
- M$6.rotateOfInner(t, tempPoint$2, rotation);
182
+ M$6.toInnerPoint(t, origin, tempPoint$3);
183
+ M$6.rotateOfInner(t, tempPoint$3, rotation);
183
184
  },
184
185
  rotateOfInner(t, origin, rotation) {
185
186
  M$6.translateInner(t, origin.x, origin.y);
@@ -200,8 +201,8 @@ const MatrixHelper = {
200
201
  }
201
202
  },
202
203
  skewOfOuter(t, origin, skewX, skewY) {
203
- M$6.toInnerPoint(t, origin, tempPoint$2);
204
- M$6.skewOfInner(t, tempPoint$2, skewX, skewY);
204
+ M$6.toInnerPoint(t, origin, tempPoint$3);
205
+ M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
205
206
  },
206
207
  skewOfInner(t, origin, skewX, skewY = 0) {
207
208
  M$6.translateInner(t, origin.x, origin.y);
@@ -448,19 +449,19 @@ const PointHelper = {
448
449
  },
449
450
  tempToInnerOf(t, matrix) {
450
451
  const { tempPoint: temp } = P$5;
451
- copy$6(temp, t);
452
+ copy$7(temp, t);
452
453
  toInnerPoint$2(matrix, temp, temp);
453
454
  return temp;
454
455
  },
455
456
  tempToOuterOf(t, matrix) {
456
457
  const { tempPoint: temp } = P$5;
457
- copy$6(temp, t);
458
+ copy$7(temp, t);
458
459
  toOuterPoint$2(matrix, temp, temp);
459
460
  return temp;
460
461
  },
461
462
  tempToInnerRadiusPointOf(t, matrix) {
462
463
  const { tempRadiusPoint: temp } = P$5;
463
- copy$6(temp, t);
464
+ copy$7(temp, t);
464
465
  P$5.toInnerRadiusPointOf(t, matrix, temp);
465
466
  return temp;
466
467
  },
@@ -527,7 +528,7 @@ const PointHelper = {
527
528
  }
528
529
  };
529
530
  const P$5 = PointHelper;
530
- const { getDistanceFrom, copy: copy$6, getAtan2 } = P$5;
531
+ const { getDistanceFrom, copy: copy$7, getAtan2 } = P$5;
531
532
 
532
533
  class Point {
533
534
  constructor(x, y) {
@@ -595,6 +596,7 @@ class Point {
595
596
  return this;
596
597
  }
597
598
  }
599
+ const tempPoint$2 = new Point();
598
600
 
599
601
  class Matrix {
600
602
  constructor(a, b, c, d, e, f) {
@@ -604,6 +606,12 @@ class Matrix {
604
606
  typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
605
607
  return this;
606
608
  }
609
+ setWith(dataWithScale) {
610
+ MatrixHelper.copy(this, dataWithScale);
611
+ this.scaleX = dataWithScale.scaleX;
612
+ this.scaleY = dataWithScale.scaleY;
613
+ return this;
614
+ }
607
615
  get() {
608
616
  const { a, b, c, d, e, f } = this;
609
617
  return { a, b, c, d, e, f };
@@ -623,6 +631,12 @@ class Matrix {
623
631
  MatrixHelper.scale(this, x, y);
624
632
  return this;
625
633
  }
634
+ scaleWith(x, y) {
635
+ MatrixHelper.scale(this, x, y);
636
+ this.scaleX *= x;
637
+ this.scaleY *= y || x;
638
+ return this;
639
+ }
626
640
  scaleOfOuter(origin, x, y) {
627
641
  MatrixHelper.scaleOfOuter(this, origin, x, y);
628
642
  return this;
@@ -675,6 +689,12 @@ class Matrix {
675
689
  MatrixHelper.invert(this);
676
690
  return this;
677
691
  }
692
+ invertWith() {
693
+ MatrixHelper.invert(this);
694
+ this.scaleX = 1 / this.scaleX;
695
+ this.scaleY = 1 / this.scaleY;
696
+ return this;
697
+ }
678
698
  toOuterPoint(inner, to, distance) {
679
699
  MatrixHelper.toOuterPoint(this, inner, to, distance);
680
700
  }
@@ -695,6 +715,7 @@ class Matrix {
695
715
  MatrixHelper.reset(this);
696
716
  }
697
717
  }
718
+ const tempMatrix = new Matrix();
698
719
 
699
720
  const TwoPointBoundsHelper = {
700
721
  tempPointBounds: {},
@@ -783,7 +804,7 @@ const BoundsHelper = {
783
804
  to = t;
784
805
  }
785
806
  else {
786
- copy$5(to, t);
807
+ copy$6(to, t);
787
808
  }
788
809
  if (parent) {
789
810
  to.offsetX = -(B.maxX(parent) - t.x);
@@ -858,8 +879,8 @@ const BoundsHelper = {
858
879
  B.move(to, -matrix.e, -matrix.f);
859
880
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
860
881
  },
861
- getFitMatrix(t, put) {
862
- const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
882
+ getFitMatrix(t, put, baseScale = 1) {
883
+ const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
863
884
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
864
885
  },
865
886
  getSpread(t, spreadX, spreadY) {
@@ -893,11 +914,15 @@ const BoundsHelper = {
893
914
  t.width = float(t.width, maxLength);
894
915
  t.height = float(t.height, maxLength);
895
916
  },
896
- add(t, bounds) {
917
+ add(t, bounds, isPoint) {
897
918
  right = t.x + t.width;
898
919
  bottom = t.y + t.height;
899
- boundsRight = bounds.x + bounds.width;
900
- boundsBottom = bounds.y + bounds.height;
920
+ boundsRight = bounds.x;
921
+ boundsBottom = bounds.y;
922
+ if (!isPoint) {
923
+ boundsRight += bounds.width;
924
+ boundsBottom += bounds.height;
925
+ }
901
926
  right = right > boundsRight ? right : boundsRight;
902
927
  bottom = bottom > boundsBottom ? bottom : boundsBottom;
903
928
  t.x = t.x < bounds.x ? t.x : bounds.x;
@@ -922,7 +947,7 @@ const BoundsHelper = {
922
947
  if (first) {
923
948
  first = false;
924
949
  if (!addMode)
925
- copy$5(t, bounds);
950
+ copy$6(t, bounds);
926
951
  }
927
952
  else {
928
953
  add(t, bounds);
@@ -936,6 +961,9 @@ const BoundsHelper = {
936
961
  points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
937
962
  toBounds$2(tempPointBounds$1, t);
938
963
  },
964
+ addPoint(t, point) {
965
+ add(t, point, true);
966
+ },
939
967
  getPoints(t) {
940
968
  const { x, y, width, height } = t;
941
969
  return [
@@ -997,7 +1025,7 @@ const BoundsHelper = {
997
1025
  }
998
1026
  };
999
1027
  const B = BoundsHelper;
1000
- const { add, copy: copy$5 } = B;
1028
+ const { add, copy: copy$6 } = B;
1001
1029
 
1002
1030
  class Bounds {
1003
1031
  get minX() { return BoundsHelper.minX(this); }
@@ -1038,8 +1066,8 @@ class Bounds {
1038
1066
  BoundsHelper.toInnerOf(this, matrix, to);
1039
1067
  return this;
1040
1068
  }
1041
- getFitMatrix(put) {
1042
- return BoundsHelper.getFitMatrix(this, put);
1069
+ getFitMatrix(put, baseScale) {
1070
+ return BoundsHelper.getFitMatrix(this, put, baseScale);
1043
1071
  }
1044
1072
  spread(fourNumber, spreadY) {
1045
1073
  BoundsHelper.spread(this, fourNumber, spreadY);
@@ -1085,6 +1113,10 @@ class Bounds {
1085
1113
  BoundsHelper.setPoints(this, points);
1086
1114
  return this;
1087
1115
  }
1116
+ addPoint(point) {
1117
+ BoundsHelper.addPoint(this, point);
1118
+ return this;
1119
+ }
1088
1120
  getPoints() {
1089
1121
  return BoundsHelper.getPoints(this);
1090
1122
  }
@@ -1117,6 +1149,7 @@ class Bounds {
1117
1149
  BoundsHelper.reset(this);
1118
1150
  }
1119
1151
  }
1152
+ const tempBounds = new Bounds();
1120
1153
 
1121
1154
  class AutoBounds {
1122
1155
  constructor(top, right, bottom, left, width, height) {
@@ -1537,36 +1570,7 @@ exports.Answer = void 0;
1537
1570
  Answer[Answer["NoAndSkip"] = 2] = "NoAndSkip";
1538
1571
  Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
1539
1572
  })(exports.Answer || (exports.Answer = {}));
1540
-
1541
- const FileHelper = {
1542
- opacityTypes: ['png', 'webp', 'svg'],
1543
- upperCaseTypeMap: {},
1544
- mineType(type) {
1545
- if (!type || type.startsWith('image'))
1546
- return type;
1547
- if (type === 'jpg')
1548
- type = 'jpeg';
1549
- return 'image/' + type;
1550
- },
1551
- fileType(filename) {
1552
- const l = filename.split('.');
1553
- return l[l.length - 1];
1554
- },
1555
- isOpaqueImage(filename) {
1556
- const type = F$4.fileType(filename);
1557
- return ['jpg', 'jpeg'].some(item => item === type);
1558
- },
1559
- getExportOptions(options) {
1560
- switch (typeof options) {
1561
- case 'object': return options;
1562
- case 'number': return { quality: options };
1563
- case 'boolean': return { blob: options };
1564
- default: return {};
1565
- }
1566
- }
1567
- };
1568
- const F$4 = FileHelper;
1569
- F$4.opacityTypes.forEach(type => F$4.upperCaseTypeMap[type] = type.toUpperCase());
1573
+ const emptyData = {};
1570
1574
 
1571
1575
  /******************************************************************************
1572
1576
  Copyright (c) Microsoft Corporation.
@@ -1890,10 +1894,8 @@ __decorate([
1890
1894
  contextMethod()
1891
1895
  ], Canvas.prototype, "strokeText", null);
1892
1896
 
1893
- const { copy: copy$4 } = MatrixHelper;
1894
- const temp = new Bounds();
1897
+ const { copy: copy$5 } = MatrixHelper;
1895
1898
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
1896
- const debug$5 = Debug.get('LeaferCanvasBase');
1897
1899
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
1898
1900
  class LeaferCanvasBase extends Canvas {
1899
1901
  get width() { return this.size.width; }
@@ -1920,44 +1922,15 @@ class LeaferCanvasBase extends Canvas {
1920
1922
  }
1921
1923
  init() { }
1922
1924
  __createContext() {
1923
- this.context = this.view.getContext('2d');
1925
+ const { view } = this;
1926
+ const { contextSettings } = this.config;
1927
+ this.context = contextSettings ? view.getContext('2d', contextSettings) : view.getContext('2d');
1924
1928
  this.__bindContext();
1925
1929
  }
1926
- export(filename, options) {
1927
- const { quality, blob } = FileHelper.getExportOptions(options);
1928
- if (filename.includes('.')) {
1929
- return this.saveAs(filename, quality);
1930
- }
1931
- else if (blob) {
1932
- return this.toBlob(filename, quality);
1933
- }
1934
- else {
1935
- return this.toDataURL(filename, quality);
1936
- }
1937
- }
1938
- toBlob(type, quality) {
1939
- return new Promise((resolve) => {
1940
- Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
1941
- resolve(blob);
1942
- }).catch((e) => {
1943
- debug$5.error(e);
1944
- resolve(null);
1945
- });
1946
- });
1947
- }
1948
- toDataURL(type, quality) {
1949
- return Platform.origin.canvasToDataURL(this.view, type, quality);
1950
- }
1951
- saveAs(filename, quality) {
1952
- return new Promise((resolve) => {
1953
- Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
1954
- resolve(true);
1955
- }).catch((e) => {
1956
- debug$5.error(e);
1957
- resolve(false);
1958
- });
1959
- });
1960
- }
1930
+ export(_filename, _options) { return undefined; }
1931
+ toBlob(_type, _quality) { return undefined; }
1932
+ toDataURL(_type, _quality) { return undefined; }
1933
+ saveAs(_filename, _quality) { return undefined; }
1961
1934
  resize(size) {
1962
1935
  if (this.isSameSize(size))
1963
1936
  return;
@@ -2025,13 +1998,9 @@ class LeaferCanvasBase extends Canvas {
2025
1998
  restoreBlendMode() {
2026
1999
  this.blendMode = this.savedBlendMode;
2027
2000
  }
2028
- hitFill(point, fillRule) {
2029
- return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
2030
- }
2031
- hitStroke(point, strokeWidth) {
2032
- this.strokeWidth = strokeWidth;
2033
- return this.context.isPointInStroke(point.x, point.y);
2034
- }
2001
+ hitFill(_point, _fillRule) { return true; }
2002
+ hitStroke(_point, _strokeWidth) { return true; }
2003
+ hitPixel(_radiusPoint, _offset, _scale = 1) { return true; }
2035
2004
  setWorldShadow(x, y, blur, color) {
2036
2005
  const { pixelRatio } = this;
2037
2006
  this.shadowOffsetX = x * pixelRatio;
@@ -2090,8 +2059,8 @@ class LeaferCanvasBase extends Canvas {
2090
2059
  if (blendMode)
2091
2060
  this.blendMode = blendMode;
2092
2061
  this.fillStyle = color;
2093
- temp.set(bounds).scale(this.pixelRatio);
2094
- this.fillRect(temp.x, temp.y, temp.width, temp.height);
2062
+ tempBounds.set(bounds).scale(this.pixelRatio);
2063
+ this.fillRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
2095
2064
  if (blendMode)
2096
2065
  this.blendMode = 'source-over';
2097
2066
  }
@@ -2099,23 +2068,23 @@ class LeaferCanvasBase extends Canvas {
2099
2068
  if (blendMode)
2100
2069
  this.blendMode = blendMode;
2101
2070
  this.strokeStyle = color;
2102
- temp.set(bounds).scale(this.pixelRatio);
2103
- this.strokeRect(temp.x, temp.y, temp.width, temp.height);
2071
+ tempBounds.set(bounds).scale(this.pixelRatio);
2072
+ this.strokeRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
2104
2073
  if (blendMode)
2105
2074
  this.blendMode = 'source-over';
2106
2075
  }
2107
2076
  clearWorld(bounds, ceilPixel) {
2108
- temp.set(bounds).scale(this.pixelRatio);
2077
+ tempBounds.set(bounds).scale(this.pixelRatio);
2109
2078
  if (ceilPixel)
2110
- temp.ceil();
2111
- this.clearRect(temp.x, temp.y, temp.width, temp.height);
2079
+ tempBounds.ceil();
2080
+ this.clearRect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
2112
2081
  }
2113
2082
  clipWorld(bounds, ceilPixel) {
2114
2083
  this.beginPath();
2115
- temp.set(bounds).scale(this.pixelRatio);
2084
+ tempBounds.set(bounds).scale(this.pixelRatio);
2116
2085
  if (ceilPixel)
2117
- temp.ceil();
2118
- this.rect(temp.x, temp.y, temp.width, temp.height);
2086
+ tempBounds.ceil();
2087
+ this.rect(tempBounds.x, tempBounds.y, tempBounds.width, tempBounds.height);
2119
2088
  this.clip();
2120
2089
  }
2121
2090
  clear() {
@@ -2129,7 +2098,7 @@ class LeaferCanvasBase extends Canvas {
2129
2098
  const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
2130
2099
  canvas.save();
2131
2100
  if (useSameWorldTransform)
2132
- copy$4(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2101
+ copy$5(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2133
2102
  if (useSameSmooth)
2134
2103
  canvas.smooth = this.smooth;
2135
2104
  return canvas;
@@ -2499,10 +2468,10 @@ const EllipseHelper = {
2499
2468
  }
2500
2469
  };
2501
2470
 
2502
- 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;
2471
+ 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;
2503
2472
  const { rect: rect$1, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$3, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2504
2473
  const { ellipticalArc } = EllipseHelper;
2505
- const debug$4 = Debug.get('PathConvert');
2474
+ const debug$5 = Debug.get('PathConvert');
2506
2475
  const setEndPoint$1 = {};
2507
2476
  const PathConvert = {
2508
2477
  current: { dot: 0 },
@@ -2714,7 +2683,7 @@ const PathConvert = {
2714
2683
  y = setEndPoint$1.y;
2715
2684
  i += 9;
2716
2685
  break;
2717
- case F$3:
2686
+ case F$4:
2718
2687
  curveMode ? ellipse$3(data, old[i + 1], old[i + 2], old[i + 3], old[i + 4], 0, 0, 360, false) : copyData(data, old, i, 5);
2719
2688
  x = old[i + 1] + old[i + 3];
2720
2689
  y = old[i + 2];
@@ -2739,7 +2708,7 @@ const PathConvert = {
2739
2708
  i += 6;
2740
2709
  break;
2741
2710
  default:
2742
- debug$4.error(`command: ${command} [index:${i}]`, old);
2711
+ debug$5.error(`command: ${command} [index:${i}]`, old);
2743
2712
  return data;
2744
2713
  }
2745
2714
  lastCommand = command;
@@ -2763,7 +2732,7 @@ const PathConvert = {
2763
2732
  };
2764
2733
  const { current, pushData, copyData } = PathConvert;
2765
2734
 
2766
- 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;
2735
+ 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;
2767
2736
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2768
2737
  const { tan, min, abs } = Math;
2769
2738
  const startPoint = {};
@@ -2805,7 +2774,7 @@ const PathCommandDataHelper = {
2805
2774
  },
2806
2775
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2807
2776
  if (rotation === undefined) {
2808
- data.push(F$2, x, y, radiusX, radiusY);
2777
+ data.push(F$3, x, y, radiusX, radiusY);
2809
2778
  }
2810
2779
  else {
2811
2780
  if (startAngle === undefined)
@@ -2855,6 +2824,7 @@ class PathCreator {
2855
2824
  set path(value) { this.__path = value; }
2856
2825
  get path() { return this.__path; }
2857
2826
  constructor(path) {
2827
+ this.clearPath = this.beginPath;
2858
2828
  this.set(path);
2859
2829
  }
2860
2830
  set(path) {
@@ -2924,8 +2894,8 @@ class PathCreator {
2924
2894
  }
2925
2895
  }
2926
2896
 
2927
- 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;
2928
- const debug$3 = Debug.get('PathDrawer');
2897
+ 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;
2898
+ const debug$4 = Debug.get('PathDrawer');
2929
2899
  const PathDrawer = {
2930
2900
  drawPathByData(drawer, data) {
2931
2901
  if (!data)
@@ -2971,7 +2941,7 @@ const PathDrawer = {
2971
2941
  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]);
2972
2942
  i += 9;
2973
2943
  break;
2974
- case F$1:
2944
+ case F$2:
2975
2945
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
2976
2946
  i += 5;
2977
2947
  break;
@@ -2988,17 +2958,17 @@ const PathDrawer = {
2988
2958
  i += 6;
2989
2959
  break;
2990
2960
  default:
2991
- debug$3.error(`command: ${command} [index:${i}]`, data);
2961
+ debug$4.error(`command: ${command} [index:${i}]`, data);
2992
2962
  return;
2993
2963
  }
2994
2964
  }
2995
2965
  }
2996
2966
  };
2997
2967
 
2998
- const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
2968
+ 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;
2999
2969
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse } = BezierHelper;
3000
- const { addPointBounds, copy: copy$3, addPoint, setPoint, addBounds, toBounds: toBounds$1 } = TwoPointBoundsHelper;
3001
- const debug$2 = Debug.get('PathBounds');
2970
+ const { addPointBounds, copy: copy$4, addPoint, setPoint, addBounds, toBounds: toBounds$1 } = TwoPointBoundsHelper;
2971
+ const debug$3 = Debug.get('PathBounds');
3002
2972
  let radius, radiusX, radiusY;
3003
2973
  const tempPointBounds = {};
3004
2974
  const setPointBounds = {};
@@ -3070,12 +3040,12 @@ const PathBounds = {
3070
3040
  break;
3071
3041
  case G:
3072
3042
  ellipse(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);
3073
- i === 0 ? copy$3(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3043
+ i === 0 ? copy$4(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3074
3044
  x = setEndPoint.x;
3075
3045
  y = setEndPoint.y;
3076
3046
  i += 9;
3077
3047
  break;
3078
- case F:
3048
+ case F$1:
3079
3049
  x = data[i + 1];
3080
3050
  y = data[i + 2];
3081
3051
  radiusX = data[i + 3];
@@ -3086,7 +3056,7 @@ const PathBounds = {
3086
3056
  break;
3087
3057
  case O:
3088
3058
  arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
3089
- i === 0 ? copy$3(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3059
+ i === 0 ? copy$4(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3090
3060
  x = setEndPoint.x;
3091
3061
  y = setEndPoint.y;
3092
3062
  i += 7;
@@ -3101,13 +3071,13 @@ const PathBounds = {
3101
3071
  break;
3102
3072
  case U:
3103
3073
  arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
3104
- i === 0 ? copy$3(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3074
+ i === 0 ? copy$4(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3105
3075
  x = setEndPoint.x;
3106
3076
  y = setEndPoint.y;
3107
3077
  i += 6;
3108
3078
  break;
3109
3079
  default:
3110
- debug$2.error(`command: ${command} [index:${i}]`, data);
3080
+ debug$3.error(`command: ${command} [index:${i}]`, data);
3111
3081
  return;
3112
3082
  }
3113
3083
  }
@@ -3193,7 +3163,37 @@ function canvasPatch(drawer) {
3193
3163
  roundRect(drawer);
3194
3164
  }
3195
3165
 
3196
- const debug$1 = Debug.get('TaskProcessor');
3166
+ const FileHelper = {
3167
+ opacityTypes: ['png', 'webp', 'svg'],
3168
+ upperCaseTypeMap: {},
3169
+ mineType(type) {
3170
+ if (!type || type.startsWith('image'))
3171
+ return type;
3172
+ if (type === 'jpg')
3173
+ type = 'jpeg';
3174
+ return 'image/' + type;
3175
+ },
3176
+ fileType(filename) {
3177
+ const l = filename.split('.');
3178
+ return l[l.length - 1];
3179
+ },
3180
+ isOpaqueImage(filename) {
3181
+ const type = F.fileType(filename);
3182
+ return ['jpg', 'jpeg'].some(item => item === type);
3183
+ },
3184
+ getExportOptions(options) {
3185
+ switch (typeof options) {
3186
+ case 'object': return options;
3187
+ case 'number': return { quality: options };
3188
+ case 'boolean': return { blob: options };
3189
+ default: return {};
3190
+ }
3191
+ }
3192
+ };
3193
+ const F = FileHelper;
3194
+ F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3195
+
3196
+ const debug$2 = Debug.get('TaskProcessor');
3197
3197
  class TaskItem {
3198
3198
  constructor(task) {
3199
3199
  this.parallel = true;
@@ -3208,7 +3208,7 @@ class TaskItem {
3208
3208
  yield this.task();
3209
3209
  }
3210
3210
  catch (error) {
3211
- debug$1.error(error);
3211
+ debug$2.error(error);
3212
3212
  }
3213
3213
  });
3214
3214
  }
@@ -3492,6 +3492,7 @@ const ImageManager = {
3492
3492
  },
3493
3493
  destroy() {
3494
3494
  I.map = {};
3495
+ I.recycledList = [];
3495
3496
  }
3496
3497
  };
3497
3498
  const I = ImageManager;
@@ -3606,84 +3607,75 @@ function getNames(object) {
3606
3607
  return Object.getOwnPropertyNames(object);
3607
3608
  }
3608
3609
 
3609
- function defineLeafAttr(target, key, defaultValue, mergeDescriptor) {
3610
+ function decorateLeafAttr(defaultValue, descriptorFn) {
3611
+ return (target, key) => defineLeafAttr(target, key, defaultValue, descriptorFn && descriptorFn(key));
3612
+ }
3613
+ function attr(partDescriptor) {
3614
+ return partDescriptor;
3615
+ }
3616
+ function defineLeafAttr(target, key, defaultValue, partDescriptor) {
3610
3617
  const defaultDescriptor = {
3611
3618
  get() { return this.__getAttr(key); },
3612
3619
  set(value) { this.__setAttr(key, value); },
3613
3620
  configurable: true,
3614
3621
  enumerable: true
3615
3622
  };
3616
- defineKey(target, key, Object.assign(defaultDescriptor, mergeDescriptor || {}));
3623
+ defineKey(target, key, Object.assign(defaultDescriptor, partDescriptor || {}));
3617
3624
  defineDataProcessor(target, key, defaultValue);
3618
3625
  }
3619
3626
  function dataType(defaultValue) {
3620
- return (target, key) => {
3621
- defineLeafAttr(target, key, defaultValue);
3622
- };
3627
+ return decorateLeafAttr(defaultValue);
3623
3628
  }
3624
- function positionType(defaultValue) {
3625
- return (target, key) => {
3626
- defineLeafAttr(target, key, defaultValue, {
3627
- set(value) {
3628
- this.__setAttr(key, value);
3629
- this.__layout.matrixChanged || this.__layout.matrixChange();
3630
- }
3631
- });
3632
- };
3629
+ function positionType(defaultValue, checkFiniteNumber) {
3630
+ return decorateLeafAttr(defaultValue, (key) => attr({
3631
+ set(value) {
3632
+ this.__setAttr(key, value, checkFiniteNumber);
3633
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3634
+ }
3635
+ }));
3633
3636
  }
3634
3637
  function autoLayoutType(defaultValue) {
3635
- return (target, key) => {
3636
- defineLeafAttr(target, key, defaultValue, {
3637
- set(value) {
3638
- this.__setAttr(key, value);
3639
- this.__layout.matrixChanged || this.__layout.matrixChange();
3640
- this.__hasAutoLayout = !!value;
3641
- if (!this.__local)
3642
- this.__layout.createLocal();
3643
- }
3644
- });
3645
- };
3638
+ return decorateLeafAttr(defaultValue, (key) => attr({
3639
+ set(value) {
3640
+ this.__setAttr(key, value);
3641
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3642
+ this.__hasAutoLayout = !!value;
3643
+ if (!this.__local)
3644
+ this.__layout.createLocal();
3645
+ }
3646
+ }));
3646
3647
  }
3647
- function scaleType(defaultValue) {
3648
- return (target, key) => {
3649
- defineLeafAttr(target, key, defaultValue, {
3650
- set(value) {
3651
- this.__setAttr(key, value);
3652
- this.__layout.scaleChanged || this.__layout.scaleChange();
3653
- }
3654
- });
3655
- };
3648
+ function scaleType(defaultValue, checkFiniteNumber) {
3649
+ return decorateLeafAttr(defaultValue, (key) => attr({
3650
+ set(value) {
3651
+ this.__setAttr(key, value, checkFiniteNumber);
3652
+ this.__layout.scaleChanged || this.__layout.scaleChange();
3653
+ }
3654
+ }));
3656
3655
  }
3657
- function rotationType(defaultValue) {
3658
- return (target, key) => {
3659
- defineLeafAttr(target, key, defaultValue, {
3660
- set(value) {
3661
- this.__setAttr(key, value);
3662
- this.__layout.rotationChanged || this.__layout.rotationChange();
3663
- }
3664
- });
3665
- };
3656
+ function rotationType(defaultValue, checkFiniteNumber) {
3657
+ return decorateLeafAttr(defaultValue, (key) => attr({
3658
+ set(value) {
3659
+ this.__setAttr(key, value, checkFiniteNumber);
3660
+ this.__layout.rotationChanged || this.__layout.rotationChange();
3661
+ }
3662
+ }));
3666
3663
  }
3667
- function boundsType(defaultValue) {
3668
- return (target, key) => {
3669
- defineLeafAttr(target, key, defaultValue, {
3670
- set(value) {
3671
- this.__setAttr(key, value);
3672
- doBoundsType(this);
3673
- }
3674
- });
3675
- };
3664
+ function boundsType(defaultValue, checkFiniteNumber) {
3665
+ return decorateLeafAttr(defaultValue, (key) => attr({
3666
+ set(value) {
3667
+ this.__setAttr(key, value, checkFiniteNumber) && doBoundsType(this);
3668
+ }
3669
+ }));
3676
3670
  }
3677
3671
  function naturalBoundsType(defaultValue) {
3678
- return (target, key) => {
3679
- defineLeafAttr(target, key, defaultValue, {
3680
- set(value) {
3681
- this.__setAttr(key, value);
3682
- doBoundsType(this);
3683
- this.__.__removeNaturalSize();
3684
- }
3685
- });
3686
- };
3672
+ return decorateLeafAttr(defaultValue, (key) => attr({
3673
+ set(value) {
3674
+ this.__setAttr(key, value);
3675
+ doBoundsType(this);
3676
+ this.__.__removeNaturalSize();
3677
+ }
3678
+ }));
3687
3679
  }
3688
3680
  function doBoundsType(leaf) {
3689
3681
  leaf.__layout.boxChanged || leaf.__layout.boxChange();
@@ -3691,27 +3683,22 @@ function doBoundsType(leaf) {
3691
3683
  leaf.__layout.matrixChanged || leaf.__layout.matrixChange();
3692
3684
  }
3693
3685
  function pathInputType(defaultValue) {
3694
- return (target, key) => {
3695
- defineLeafAttr(target, key, defaultValue, {
3696
- set(value) {
3697
- if (this.__.__pathInputed !== 2)
3698
- this.__.__pathInputed = value ? 1 : 0;
3699
- this.__setAttr(key, value);
3700
- doBoundsType(this);
3701
- }
3702
- });
3703
- };
3686
+ return decorateLeafAttr(defaultValue, (key) => attr({
3687
+ set(value) {
3688
+ if (this.__.__pathInputed !== 2)
3689
+ this.__.__pathInputed = value ? 1 : 0;
3690
+ this.__setAttr(key, value);
3691
+ doBoundsType(this);
3692
+ }
3693
+ }));
3704
3694
  }
3705
3695
  const pathType = boundsType;
3706
3696
  function affectStrokeBoundsType(defaultValue) {
3707
- return (target, key) => {
3708
- defineLeafAttr(target, key, defaultValue, {
3709
- set(value) {
3710
- this.__setAttr(key, value);
3711
- doStrokeType(this);
3712
- }
3713
- });
3714
- };
3697
+ return decorateLeafAttr(defaultValue, (key) => attr({
3698
+ set(value) {
3699
+ this.__setAttr(key, value) && doStrokeType(this);
3700
+ }
3701
+ }));
3715
3702
  }
3716
3703
  function doStrokeType(leaf) {
3717
3704
  leaf.__layout.strokeChanged || leaf.__layout.strokeChange();
@@ -3720,91 +3707,75 @@ function doStrokeType(leaf) {
3720
3707
  }
3721
3708
  const strokeType = affectStrokeBoundsType;
3722
3709
  function affectRenderBoundsType(defaultValue) {
3723
- return (target, key) => {
3724
- defineLeafAttr(target, key, defaultValue, {
3725
- set(value) {
3726
- this.__setAttr(key, value);
3727
- this.__layout.renderChanged || this.__layout.renderChange();
3728
- }
3729
- });
3730
- };
3710
+ return decorateLeafAttr(defaultValue, (key) => attr({
3711
+ set(value) {
3712
+ this.__setAttr(key, value);
3713
+ this.__layout.renderChanged || this.__layout.renderChange();
3714
+ }
3715
+ }));
3731
3716
  }
3732
3717
  function surfaceType(defaultValue) {
3733
- return (target, key) => {
3734
- defineLeafAttr(target, key, defaultValue, {
3735
- set(value) {
3736
- this.__setAttr(key, value);
3737
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3738
- }
3739
- });
3740
- };
3718
+ return decorateLeafAttr(defaultValue, (key) => attr({
3719
+ set(value) {
3720
+ this.__setAttr(key, value);
3721
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3722
+ }
3723
+ }));
3741
3724
  }
3742
3725
  function opacityType(defaultValue) {
3743
- return (target, key) => {
3744
- defineLeafAttr(target, key, defaultValue, {
3745
- set(value) {
3746
- this.__setAttr(key, value);
3747
- this.__layout.opacityChanged || this.__layout.opacityChange();
3748
- }
3749
- });
3750
- };
3726
+ return decorateLeafAttr(defaultValue, (key) => attr({
3727
+ set(value) {
3728
+ this.__setAttr(key, value);
3729
+ this.__layout.opacityChanged || this.__layout.opacityChange();
3730
+ }
3731
+ }));
3751
3732
  }
3752
3733
  function sortType(defaultValue) {
3753
- return (target, key) => {
3754
- defineLeafAttr(target, key, defaultValue, {
3755
- set(value) {
3756
- this.__setAttr(key, value);
3757
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3758
- this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3759
- }
3760
- });
3761
- };
3734
+ return decorateLeafAttr(defaultValue, (key) => attr({
3735
+ set(value) {
3736
+ this.__setAttr(key, value);
3737
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3738
+ this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3739
+ }
3740
+ }));
3762
3741
  }
3763
3742
  function maskType(defaultValue) {
3764
- return (target, key) => {
3765
- defineLeafAttr(target, key, defaultValue, {
3766
- set(value) {
3767
- this.__setAttr(key, value);
3768
- this.__layout.boxChanged || this.__layout.boxChange();
3769
- this.waitParent(() => { this.parent.__updateMask(value); });
3770
- }
3771
- });
3772
- };
3743
+ return decorateLeafAttr(defaultValue, (key) => attr({
3744
+ set(value) {
3745
+ this.__setAttr(key, value);
3746
+ this.__layout.boxChanged || this.__layout.boxChange();
3747
+ this.waitParent(() => { this.parent.__updateMask(value); });
3748
+ }
3749
+ }));
3773
3750
  }
3774
3751
  function eraserType(defaultValue) {
3775
- return (target, key) => {
3776
- defineLeafAttr(target, key, defaultValue, {
3777
- set(value) {
3778
- this.__setAttr(key, value);
3779
- this.waitParent(() => { this.parent.__updateEraser(value); });
3780
- }
3781
- });
3782
- };
3752
+ return decorateLeafAttr(defaultValue, (key) => attr({
3753
+ set(value) {
3754
+ this.__setAttr(key, value);
3755
+ this.waitParent(() => { this.parent.__updateEraser(value); });
3756
+ }
3757
+ }));
3783
3758
  }
3784
3759
  function hitType(defaultValue) {
3785
- return (target, key) => {
3786
- defineLeafAttr(target, key, defaultValue, {
3787
- set(value) {
3788
- this.__setAttr(key, value);
3789
- if (Debug.showHitView) {
3790
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3791
- }
3792
- if (this.leafer)
3793
- this.leafer.updateCursor();
3760
+ return decorateLeafAttr(defaultValue, (key) => attr({
3761
+ set(value) {
3762
+ this.__setAttr(key, value);
3763
+ if (Debug.showHitView) {
3764
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3794
3765
  }
3795
- });
3796
- };
3766
+ if (this.leafer)
3767
+ this.leafer.updateCursor();
3768
+ }
3769
+ }));
3797
3770
  }
3798
3771
  function cursorType(defaultValue) {
3799
- return (target, key) => {
3800
- defineLeafAttr(target, key, defaultValue, {
3801
- set(value) {
3802
- this.__setAttr(key, value);
3803
- if (this.leafer)
3804
- this.leafer.updateCursor();
3805
- }
3806
- });
3807
- };
3772
+ return decorateLeafAttr(defaultValue, (key) => attr({
3773
+ set(value) {
3774
+ this.__setAttr(key, value);
3775
+ if (this.leafer)
3776
+ this.leafer.updateCursor();
3777
+ }
3778
+ }));
3808
3779
  }
3809
3780
  function dataProcessor(processor) {
3810
3781
  return (target, _key) => {
@@ -3867,7 +3838,7 @@ function defineDataProcessor(target, key, defaultValue) {
3867
3838
  Object.defineProperty(data, key, property);
3868
3839
  }
3869
3840
 
3870
- const debug = new Debug('rewrite');
3841
+ const debug$1 = new Debug('rewrite');
3871
3842
  const list = [];
3872
3843
  const excludeNames = ['destroy', 'constructor'];
3873
3844
  function rewrite(method) {
@@ -3884,7 +3855,7 @@ function doRewrite(error) {
3884
3855
  if (list.length) {
3885
3856
  list.forEach(item => {
3886
3857
  if (error)
3887
- debug.error(item.name, '需在Class上装饰@rewriteAble()');
3858
+ debug$1.error(item.name, '需在Class上装饰@rewriteAble()');
3888
3859
  item.run();
3889
3860
  });
3890
3861
  list.length = 0;
@@ -3920,7 +3891,7 @@ function registerUIEvent() {
3920
3891
  };
3921
3892
  }
3922
3893
 
3923
- const { copy: copy$2, toInnerPoint: toInnerPoint$1, scaleOfOuter, rotateOfOuter, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3894
+ const { copy: copy$3, toInnerPoint: toInnerPoint$1, scaleOfOuter, rotateOfOuter, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3924
3895
  const matrix = {};
3925
3896
  const LeafHelper = {
3926
3897
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -3999,7 +3970,7 @@ const LeafHelper = {
3999
3970
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4000
3971
  },
4001
3972
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4002
- copy$2(matrix, t.__localMatrix);
3973
+ copy$3(matrix, t.__localMatrix);
4003
3974
  scaleOfOuter(matrix, origin, scaleX, scaleY);
4004
3975
  moveByMatrix(t, matrix);
4005
3976
  t.scaleResize(scaleX, scaleY, resize !== true);
@@ -4008,7 +3979,7 @@ const LeafHelper = {
4008
3979
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
4009
3980
  },
4010
3981
  rotateOfLocal(t, origin, angle) {
4011
- copy$2(matrix, t.__localMatrix);
3982
+ copy$3(matrix, t.__localMatrix);
4012
3983
  rotateOfOuter(matrix, origin, angle);
4013
3984
  moveByMatrix(t, matrix);
4014
3985
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
@@ -4017,19 +3988,19 @@ const LeafHelper = {
4017
3988
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4018
3989
  },
4019
3990
  skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4020
- copy$2(matrix, t.__localMatrix);
3991
+ copy$3(matrix, t.__localMatrix);
4021
3992
  skewOfOuter(matrix, origin, skewX, skewY);
4022
3993
  L.setTransform(t, matrix, resize);
4023
3994
  },
4024
3995
  transformWorld(t, transform, resize) {
4025
- copy$2(matrix, t.worldTransform);
3996
+ copy$3(matrix, t.worldTransform);
4026
3997
  multiplyParent$2(matrix, transform);
4027
3998
  if (t.parent)
4028
3999
  divideParent(matrix, t.parent.worldTransform);
4029
4000
  L.setTransform(t, matrix, resize);
4030
4001
  },
4031
4002
  transform(t, transform, resize) {
4032
- copy$2(matrix, t.localTransform);
4003
+ copy$3(matrix, t.localTransform);
4033
4004
  multiplyParent$2(matrix, transform);
4034
4005
  L.setTransform(t, matrix, resize);
4035
4006
  },
@@ -4043,7 +4014,7 @@ const LeafHelper = {
4043
4014
  t.set(layout);
4044
4015
  },
4045
4016
  getRelativeWorld(t, relative, temp) {
4046
- copy$2(matrix, t.worldTransform);
4017
+ copy$3(matrix, t.worldTransform);
4047
4018
  divideParent(matrix, relative.worldTransform);
4048
4019
  return temp ? matrix : Object.assign({}, matrix);
4049
4020
  },
@@ -4185,7 +4156,7 @@ const { pushAllChildBranch, pushAllBranchStack, updateBoundsByBranchStack } = Br
4185
4156
 
4186
4157
  const WaitHelper = {
4187
4158
  run(wait) {
4188
- if (wait.length) {
4159
+ if (wait && wait.length) {
4189
4160
  const len = wait.length;
4190
4161
  for (let i = 0; i < len; i++) {
4191
4162
  wait[i]();
@@ -4196,7 +4167,7 @@ const WaitHelper = {
4196
4167
  };
4197
4168
 
4198
4169
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4199
- const { toOuterOf: toOuterOf$2, getPoints, copy: copy$1 } = BoundsHelper;
4170
+ const { toOuterOf: toOuterOf$2, getPoints, copy: copy$2 } = BoundsHelper;
4200
4171
  class LeafLayout {
4201
4172
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4202
4173
  get renderBounds() { return this._renderBounds || this.boxBounds; }
@@ -4341,7 +4312,7 @@ class LeafLayout {
4341
4312
  matrix = getRelativeWorld$1(leaf, relative, true);
4342
4313
  }
4343
4314
  const layoutBounds = MatrixHelper.getLayout(matrix);
4344
- copy$1(layoutBounds, bounds);
4315
+ copy$2(layoutBounds, bounds);
4345
4316
  PointHelper.copy(layoutBounds, point);
4346
4317
  if (unscale) {
4347
4318
  const { scaleX, scaleY } = layoutBounds;
@@ -4735,10 +4706,16 @@ LeaferEvent.STOP = 'leafer.stop';
4735
4706
  LeaferEvent.RESTART = 'leafer.restart';
4736
4707
  LeaferEvent.END = 'leafer.end';
4737
4708
 
4709
+ const { isFinite } = Number;
4710
+ const debug = Debug.get('setAttr');
4738
4711
  const LeafDataProxy = {
4739
- __setAttr(name, newValue) {
4712
+ __setAttr(name, newValue, checkFiniteNumber) {
4740
4713
  if (this.leafer && this.leafer.created) {
4741
4714
  const oldValue = this.__.__getInput(name);
4715
+ if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4716
+ debug.warn(this.innerName, name, newValue);
4717
+ newValue = undefined;
4718
+ }
4742
4719
  if (typeof newValue === 'object' || oldValue !== newValue) {
4743
4720
  this.__[name] = newValue;
4744
4721
  if (this.__proxyData)
@@ -4753,12 +4730,17 @@ const LeafDataProxy = {
4753
4730
  this.emitEvent(event);
4754
4731
  }
4755
4732
  this.leafer.emitEvent(event);
4733
+ return true;
4734
+ }
4735
+ else {
4736
+ return false;
4756
4737
  }
4757
4738
  }
4758
4739
  else {
4759
4740
  this.__[name] = newValue;
4760
4741
  if (this.__proxyData)
4761
4742
  this.setProxyAttr(name, newValue);
4743
+ return true;
4762
4744
  }
4763
4745
  },
4764
4746
  __getAttr(name) {
@@ -4796,7 +4778,7 @@ const LeafMatrix = {
4796
4778
 
4797
4779
  const { updateMatrix, updateAllMatrix, hasParentAutoLayout } = LeafHelper;
4798
4780
  const { updateBounds } = BranchHelper;
4799
- const { toOuterOf: toOuterOf$1, copyAndSpread } = BoundsHelper;
4781
+ const { toOuterOf: toOuterOf$1, copyAndSpread, copy: copy$1 } = BoundsHelper;
4800
4782
  const { toBounds } = PathBounds;
4801
4783
  const LeafBounds = {
4802
4784
  __updateWorldBounds() {
@@ -4914,7 +4896,8 @@ const LeafBounds = {
4914
4896
  copyAndSpread(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
4915
4897
  },
4916
4898
  __updateRenderBounds() {
4917
- copyAndSpread(this.__layout.renderBounds, this.__layout.strokeBounds, this.__layout.renderSpread);
4899
+ const { renderSpread, strokeBounds, renderBounds } = this.__layout;
4900
+ renderSpread > 0 ? copyAndSpread(renderBounds, strokeBounds, renderSpread) : copy$1(renderBounds, strokeBounds);
4918
4901
  },
4919
4902
  };
4920
4903
 
@@ -5100,7 +5083,7 @@ exports.Leaf = class Leaf {
5100
5083
  toString() {
5101
5084
  return JSON.stringify(this.toJSON());
5102
5085
  }
5103
- __setAttr(_attrName, _newValue) { }
5086
+ __setAttr(_attrName, _newValue) { return true; }
5104
5087
  __getAttr(_attrName) { return undefined; }
5105
5088
  setProxyAttr(_attrName, _newValue) { }
5106
5089
  getProxyAttr(_attrName) { return undefined; }
@@ -5284,24 +5267,16 @@ exports.Leaf = class Leaf {
5284
5267
  __scaleResize(_scaleX, _scaleY) { }
5285
5268
  __hitWorld(_point) { return true; }
5286
5269
  __hit(_local) { return true; }
5287
- __hitFill(inner, windingRule) {
5288
- var _a;
5289
- return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, windingRule);
5290
- }
5291
- __hitStroke(inner, strokeWidth) {
5292
- var _a;
5293
- return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth);
5294
- }
5295
- __drawHitPath(canvas) {
5296
- if (canvas)
5297
- this.__drawRenderPath(canvas);
5298
- }
5270
+ __hitFill(_inner) { return true; }
5271
+ __hitStroke(_inner, _strokeWidth) { return true; }
5272
+ __hitPixel(_inner) { return true; }
5273
+ __drawHitPath(_canvas) { }
5299
5274
  __updateHitCanvas() { }
5300
5275
  __render(_canvas, _options) { }
5301
5276
  __drawFast(_canvas, _options) { }
5302
5277
  __draw(_canvas, _options) { }
5303
5278
  __clip(_canvas, _options) { }
5304
- __renderShape(_canvas, _options) { }
5279
+ __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5305
5280
  __updateWorldOpacity() { }
5306
5281
  __updateChange() { }
5307
5282
  __drawPath(_canvas) { }
@@ -5709,6 +5684,7 @@ exports.WaitHelper = WaitHelper;
5709
5684
  exports.WatchEvent = WatchEvent;
5710
5685
  exports.affectRenderBoundsType = affectRenderBoundsType;
5711
5686
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
5687
+ exports.attr = attr;
5712
5688
  exports.autoLayoutType = autoLayoutType;
5713
5689
  exports.boundsType = boundsType;
5714
5690
  exports.canvasPatch = canvasPatch;
@@ -5716,11 +5692,13 @@ exports.canvasSizeAttrs = canvasSizeAttrs;
5716
5692
  exports.cursorType = cursorType;
5717
5693
  exports.dataProcessor = dataProcessor;
5718
5694
  exports.dataType = dataType;
5695
+ exports.decorateLeafAttr = decorateLeafAttr;
5719
5696
  exports.defineDataProcessor = defineDataProcessor;
5720
5697
  exports.defineKey = defineKey;
5721
5698
  exports.defineLeafAttr = defineLeafAttr;
5722
5699
  exports.doBoundsType = doBoundsType;
5723
5700
  exports.doStrokeType = doStrokeType;
5701
+ exports.emptyData = emptyData;
5724
5702
  exports.eraserType = eraserType;
5725
5703
  exports.getBoundsData = getBoundsData;
5726
5704
  exports.getDescriptor = getDescriptor;
@@ -5744,4 +5722,7 @@ exports.scaleType = scaleType;
5744
5722
  exports.sortType = sortType;
5745
5723
  exports.strokeType = strokeType;
5746
5724
  exports.surfaceType = surfaceType;
5725
+ exports.tempBounds = tempBounds;
5726
+ exports.tempMatrix = tempMatrix;
5727
+ exports.tempPoint = tempPoint$2;
5747
5728
  exports.useModule = useModule;