@leafer-draw/miniapp 1.6.2 → 1.6.3

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.
@@ -23,8 +23,6 @@ const Platform = {
23
23
  }
24
24
  };
25
25
 
26
- const Creator = {};
27
-
28
26
  const IncrementId = {
29
27
  RUNTIME: 'runtime',
30
28
  LEAF: 'leaf',
@@ -150,7 +148,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
150
148
 
151
149
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
152
150
  const { float: float$1 } = MathHelper;
153
- const tempPoint$4 = {};
151
+ const tempPoint$3 = {};
154
152
  function getWorld() {
155
153
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
156
154
  }
@@ -193,8 +191,8 @@ const MatrixHelper = {
193
191
  t.d *= scaleY;
194
192
  },
195
193
  scaleOfOuter(t, origin, scaleX, scaleY) {
196
- M$6.toInnerPoint(t, origin, tempPoint$4);
197
- M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
194
+ M$6.toInnerPoint(t, origin, tempPoint$3);
195
+ M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
198
196
  },
199
197
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
200
198
  M$6.translateInner(t, origin.x, origin.y);
@@ -212,8 +210,8 @@ const MatrixHelper = {
212
210
  t.d = c * sinR + d * cosR;
213
211
  },
214
212
  rotateOfOuter(t, origin, rotation) {
215
- M$6.toInnerPoint(t, origin, tempPoint$4);
216
- M$6.rotateOfInner(t, tempPoint$4, rotation);
213
+ M$6.toInnerPoint(t, origin, tempPoint$3);
214
+ M$6.rotateOfInner(t, tempPoint$3, rotation);
217
215
  },
218
216
  rotateOfInner(t, origin, rotation) {
219
217
  M$6.translateInner(t, origin.x, origin.y);
@@ -234,8 +232,8 @@ const MatrixHelper = {
234
232
  }
235
233
  },
236
234
  skewOfOuter(t, origin, skewX, skewY) {
237
- M$6.toInnerPoint(t, origin, tempPoint$4);
238
- M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
235
+ M$6.toInnerPoint(t, origin, tempPoint$3);
236
+ M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
239
237
  },
240
238
  skewOfInner(t, origin, skewX, skewY = 0) {
241
239
  M$6.translateInner(t, origin.x, origin.y);
@@ -464,8 +462,10 @@ const PointHelper = {
464
462
  t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
465
463
  },
466
464
  move(t, x, y) {
467
- t.x += x;
468
- t.y += y;
465
+ if (typeof x === 'object')
466
+ t.x += x.x, t.y += x.y;
467
+ else
468
+ t.x += x, t.y += y;
469
469
  },
470
470
  scale(t, scaleX, scaleY = scaleX) {
471
471
  if (t.x)
@@ -490,19 +490,19 @@ const PointHelper = {
490
490
  },
491
491
  tempToInnerOf(t, matrix) {
492
492
  const { tempPoint: temp } = P$5;
493
- copy$a(temp, t);
493
+ copy$b(temp, t);
494
494
  toInnerPoint$2(matrix, temp, temp);
495
495
  return temp;
496
496
  },
497
497
  tempToOuterOf(t, matrix) {
498
498
  const { tempPoint: temp } = P$5;
499
- copy$a(temp, t);
499
+ copy$b(temp, t);
500
500
  toOuterPoint$3(matrix, temp, temp);
501
501
  return temp;
502
502
  },
503
503
  tempToInnerRadiusPointOf(t, matrix) {
504
504
  const { tempRadiusPoint: temp } = P$5;
505
- copy$a(temp, t);
505
+ copy$b(temp, t);
506
506
  P$5.toInnerRadiusPointOf(t, matrix, temp);
507
507
  return temp;
508
508
  },
@@ -575,7 +575,7 @@ const PointHelper = {
575
575
  }
576
576
  };
577
577
  const P$5 = PointHelper;
578
- const { getDistanceFrom, copy: copy$a, getAtan2 } = P$5;
578
+ const { getDistanceFrom, copy: copy$b, getAtan2 } = P$5;
579
579
 
580
580
  class Point {
581
581
  constructor(x, y) {
@@ -643,7 +643,7 @@ class Point {
643
643
  return this;
644
644
  }
645
645
  }
646
- const tempPoint$3 = new Point();
646
+ const tempPoint$2 = new Point();
647
647
 
648
648
  class Matrix {
649
649
  constructor(a, b, c, d, e, f) {
@@ -801,15 +801,87 @@ const TwoPointBoundsHelper = {
801
801
  };
802
802
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
803
803
 
804
+ var Direction4;
805
+ (function (Direction4) {
806
+ Direction4[Direction4["top"] = 0] = "top";
807
+ Direction4[Direction4["right"] = 1] = "right";
808
+ Direction4[Direction4["bottom"] = 2] = "bottom";
809
+ Direction4[Direction4["left"] = 3] = "left";
810
+ })(Direction4 || (Direction4 = {}));
811
+ var Direction9;
812
+ (function (Direction9) {
813
+ Direction9[Direction9["topLeft"] = 0] = "topLeft";
814
+ Direction9[Direction9["top"] = 1] = "top";
815
+ Direction9[Direction9["topRight"] = 2] = "topRight";
816
+ Direction9[Direction9["right"] = 3] = "right";
817
+ Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
818
+ Direction9[Direction9["bottom"] = 5] = "bottom";
819
+ Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
820
+ Direction9[Direction9["left"] = 7] = "left";
821
+ Direction9[Direction9["center"] = 8] = "center";
822
+ Direction9[Direction9["top-left"] = 0] = "top-left";
823
+ Direction9[Direction9["top-right"] = 2] = "top-right";
824
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
825
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
826
+ })(Direction9 || (Direction9 = {}));
827
+
828
+ const directionData = [
829
+ { x: 0, y: 0 },
830
+ { x: 0.5, y: 0 },
831
+ { x: 1, y: 0 },
832
+ { x: 1, y: 0.5 },
833
+ { x: 1, y: 1 },
834
+ { x: 0.5, y: 1 },
835
+ { x: 0, y: 1 },
836
+ { x: 0, y: 0.5 },
837
+ { x: 0.5, y: 0.5 }
838
+ ];
839
+ directionData.forEach(item => item.type = 'percent');
840
+ const AroundHelper = {
841
+ directionData,
842
+ tempPoint: {},
843
+ get: get$4,
844
+ toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
845
+ const point = get$4(around);
846
+ to.x = point.x;
847
+ to.y = point.y;
848
+ if (point.type === 'percent') {
849
+ to.x *= box.width;
850
+ to.y *= box.height;
851
+ if (content) {
852
+ if (!onlyContentSize)
853
+ to.x -= content.x, to.y -= content.y;
854
+ if (point.x)
855
+ to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
856
+ if (point.y)
857
+ to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
858
+ }
859
+ }
860
+ if (!onlyBoxSize)
861
+ to.x += box.x, to.y += box.y;
862
+ }
863
+ };
864
+ function get$4(around) {
865
+ return typeof around === 'string' ? directionData[Direction9[around]] : around;
866
+ }
867
+
868
+ const { toPoint: toPoint$5 } = AroundHelper;
869
+ const AlignHelper = {
870
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
871
+ toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
872
+ }
873
+ };
874
+
804
875
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
805
876
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
806
877
  const { float, fourNumber } = MathHelper;
807
878
  const { floor, ceil: ceil$2 } = Math;
808
879
  let right$1, bottom$1, boundsRight, boundsBottom;
809
880
  const point = {};
810
- const toPoint$5 = {};
881
+ const toPoint$4 = {};
882
+ const tempBounds$2 = {};
811
883
  const BoundsHelper = {
812
- tempBounds: {},
884
+ tempBounds: tempBounds$2,
813
885
  set(t, x = 0, y = 0, width = 0, height = 0) {
814
886
  t.x = x;
815
887
  t.y = y;
@@ -860,7 +932,7 @@ const BoundsHelper = {
860
932
  to = t;
861
933
  }
862
934
  else {
863
- copy$9(to, t);
935
+ copy$a(to, t);
864
936
  }
865
937
  if (parent) {
866
938
  to.offsetX = -(B.maxX(parent) - t.x);
@@ -872,8 +944,8 @@ const BoundsHelper = {
872
944
  }
873
945
  B.move(to, -to.offsetX, -to.offsetY);
874
946
  },
875
- scale(t, scaleX, scaleY = scaleX) {
876
- PointHelper.scale(t, scaleX, scaleY);
947
+ scale(t, scaleX, scaleY = scaleX, onlySize) {
948
+ onlySize || PointHelper.scale(t, scaleX, scaleY);
877
949
  t.width *= scaleX;
878
950
  t.height *= scaleY;
879
951
  },
@@ -883,9 +955,9 @@ const BoundsHelper = {
883
955
  t.height *= scaleY;
884
956
  },
885
957
  tempToOuterOf(t, matrix) {
886
- B.copy(B.tempBounds, t);
887
- B.toOuterOf(B.tempBounds, matrix);
888
- return B.tempBounds;
958
+ B.copy(tempBounds$2, t);
959
+ B.toOuterOf(tempBounds$2, matrix);
960
+ return tempBounds$2;
889
961
  },
890
962
  getOuterOf(t, matrix) {
891
963
  t = Object.assign({}, t);
@@ -916,17 +988,17 @@ const BoundsHelper = {
916
988
  else {
917
989
  point.x = t.x;
918
990
  point.y = t.y;
919
- toOuterPoint$2(matrix, point, toPoint$5);
920
- setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
991
+ toOuterPoint$2(matrix, point, toPoint$4);
992
+ setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
921
993
  point.x = t.x + t.width;
922
- toOuterPoint$2(matrix, point, toPoint$5);
923
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
994
+ toOuterPoint$2(matrix, point, toPoint$4);
995
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
924
996
  point.y = t.y + t.height;
925
- toOuterPoint$2(matrix, point, toPoint$5);
926
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
997
+ toOuterPoint$2(matrix, point, toPoint$4);
998
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
927
999
  point.x = t.x;
928
- toOuterPoint$2(matrix, point, toPoint$5);
929
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
1000
+ toOuterPoint$2(matrix, point, toPoint$4);
1001
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
930
1002
  toBounds$3(tempPointBounds$1, to);
931
1003
  }
932
1004
  },
@@ -936,9 +1008,21 @@ const BoundsHelper = {
936
1008
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
937
1009
  },
938
1010
  getFitMatrix(t, put, baseScale = 1) {
939
- const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
1011
+ const scale = Math.min(baseScale, B.getFitScale(t, put));
940
1012
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
941
1013
  },
1014
+ getFitScale(t, put, isCoverMode) {
1015
+ const sw = t.width / put.width, sh = t.height / put.height;
1016
+ return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
1017
+ },
1018
+ put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
1019
+ to || (to = put);
1020
+ if (typeof putScale === 'string')
1021
+ putScale = B.getFitScale(t, put, putScale === 'cover');
1022
+ tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1023
+ tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1024
+ AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1025
+ },
942
1026
  getSpread(t, spread, side) {
943
1027
  const n = {};
944
1028
  B.copyAndSpread(n, t, spread, false, side);
@@ -1006,7 +1090,7 @@ const BoundsHelper = {
1006
1090
  if (first) {
1007
1091
  first = false;
1008
1092
  if (!addMode)
1009
- copy$9(t, bounds);
1093
+ copy$a(t, bounds);
1010
1094
  }
1011
1095
  else {
1012
1096
  add$1(t, bounds);
@@ -1087,7 +1171,7 @@ const BoundsHelper = {
1087
1171
  }
1088
1172
  };
1089
1173
  const B = BoundsHelper;
1090
- const { add: add$1, copy: copy$9 } = B;
1174
+ const { add: add$1, copy: copy$a } = B;
1091
1175
 
1092
1176
  class Bounds {
1093
1177
  get minX() { return BoundsHelper.minX(this); }
@@ -1112,8 +1196,8 @@ class Bounds {
1112
1196
  BoundsHelper.move(this, x, y);
1113
1197
  return this;
1114
1198
  }
1115
- scale(scaleX, scaleY) {
1116
- BoundsHelper.scale(this, scaleX, scaleY);
1199
+ scale(scaleX, scaleY, onlySize) {
1200
+ BoundsHelper.scale(this, scaleX, scaleY, onlySize);
1117
1201
  return this;
1118
1202
  }
1119
1203
  scaleOf(origin, scaleX, scaleY) {
@@ -1131,6 +1215,9 @@ class Bounds {
1131
1215
  getFitMatrix(put, baseScale) {
1132
1216
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1133
1217
  }
1218
+ put(put, align, putScale) {
1219
+ BoundsHelper.put(this, put, align, putScale);
1220
+ }
1134
1221
  spread(fourNumber, side) {
1135
1222
  BoundsHelper.spread(this, fourNumber, side);
1136
1223
  return this;
@@ -1239,79 +1326,6 @@ class AutoBounds {
1239
1326
  }
1240
1327
  }
1241
1328
 
1242
- var Direction4;
1243
- (function (Direction4) {
1244
- Direction4[Direction4["top"] = 0] = "top";
1245
- Direction4[Direction4["right"] = 1] = "right";
1246
- Direction4[Direction4["bottom"] = 2] = "bottom";
1247
- Direction4[Direction4["left"] = 3] = "left";
1248
- })(Direction4 || (Direction4 = {}));
1249
- var Direction9;
1250
- (function (Direction9) {
1251
- Direction9[Direction9["topLeft"] = 0] = "topLeft";
1252
- Direction9[Direction9["top"] = 1] = "top";
1253
- Direction9[Direction9["topRight"] = 2] = "topRight";
1254
- Direction9[Direction9["right"] = 3] = "right";
1255
- Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
1256
- Direction9[Direction9["bottom"] = 5] = "bottom";
1257
- Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1258
- Direction9[Direction9["left"] = 7] = "left";
1259
- Direction9[Direction9["center"] = 8] = "center";
1260
- Direction9[Direction9["top-left"] = 0] = "top-left";
1261
- Direction9[Direction9["top-right"] = 2] = "top-right";
1262
- Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1263
- Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1264
- })(Direction9 || (Direction9 = {}));
1265
-
1266
- const directionData = [
1267
- { x: 0, y: 0 },
1268
- { x: 0.5, y: 0 },
1269
- { x: 1, y: 0 },
1270
- { x: 1, y: 0.5 },
1271
- { x: 1, y: 1 },
1272
- { x: 0.5, y: 1 },
1273
- { x: 0, y: 1 },
1274
- { x: 0, y: 0.5 },
1275
- { x: 0.5, y: 0.5 }
1276
- ];
1277
- directionData.forEach(item => item.type = 'percent');
1278
- const AroundHelper = {
1279
- directionData,
1280
- tempPoint: {},
1281
- get: get$4,
1282
- toPoint(around, bounds, to, onlySize, pointBounds) {
1283
- const point = get$4(around);
1284
- to.x = point.x;
1285
- to.y = point.y;
1286
- if (point.type === 'percent') {
1287
- to.x *= bounds.width;
1288
- to.y *= bounds.height;
1289
- if (pointBounds) {
1290
- to.x -= pointBounds.x;
1291
- to.y -= pointBounds.y;
1292
- if (point.x)
1293
- to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1294
- if (point.y)
1295
- to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1296
- }
1297
- }
1298
- if (!onlySize) {
1299
- to.x += bounds.x;
1300
- to.y += bounds.y;
1301
- }
1302
- }
1303
- };
1304
- function get$4(around) {
1305
- return typeof around === 'string' ? directionData[Direction9[around]] : around;
1306
- }
1307
-
1308
- const { toPoint: toPoint$4 } = AroundHelper;
1309
- const AlignHelper = {
1310
- toPoint(align, contentBounds, bounds, to, onlySize) {
1311
- toPoint$4(align, bounds, to, onlySize, contentBounds);
1312
- }
1313
- };
1314
-
1315
1329
  const StringNumberMap = {
1316
1330
  '0': 1,
1317
1331
  '1': 1,
@@ -1442,11 +1456,17 @@ const Plugin = {
1442
1456
  return rs;
1443
1457
  },
1444
1458
  need(name) {
1445
- console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1459
+ console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1446
1460
  }
1447
1461
  };
1448
1462
  setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1449
1463
 
1464
+ const Creator = {
1465
+ editor(_options) {
1466
+ return Plugin.need('editor');
1467
+ }
1468
+ };
1469
+
1450
1470
  const debug$d = Debug.get('UICreator');
1451
1471
  const UICreator = {
1452
1472
  list: {},
@@ -1584,6 +1604,10 @@ const DataHelper = {
1584
1604
  for (let i = 0, len = list.length; i < len; i++)
1585
1605
  map[list[i]] = true;
1586
1606
  return map;
1607
+ },
1608
+ stintSet(data, attrName, value) {
1609
+ value || (value = undefined);
1610
+ data[attrName] !== value && (data[attrName] = value);
1587
1611
  }
1588
1612
  };
1589
1613
  const { assign } = DataHelper;
@@ -2042,7 +2066,7 @@ __decorate([
2042
2066
  contextMethod()
2043
2067
  ], Canvas$1.prototype, "strokeText", null);
2044
2068
 
2045
- const { copy: copy$8, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
2069
+ const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
2046
2070
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2047
2071
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2048
2072
  class LeaferCanvasBase extends Canvas$1 {
@@ -2274,7 +2298,7 @@ class LeaferCanvasBase extends Canvas$1 {
2274
2298
  const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
2275
2299
  canvas.save();
2276
2300
  if (useSameWorldTransform)
2277
- copy$8(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2301
+ copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2278
2302
  if (useSameSmooth)
2279
2303
  canvas.smooth = this.smooth;
2280
2304
  canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
@@ -2385,7 +2409,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2385
2409
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2386
2410
  const { set, toNumberPoints } = PointHelper;
2387
2411
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
2388
- const tempPoint$2 = {};
2412
+ const tempPoint$1 = {};
2389
2413
  const BezierHelper = {
2390
2414
  points(data, originPoints, curve, close) {
2391
2415
  let points = toNumberPoints(originPoints);
@@ -2407,6 +2431,8 @@ const BezierHelper = {
2407
2431
  cY = points[i + 3];
2408
2432
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2409
2433
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2434
+ if (!ba && !cb)
2435
+ continue;
2410
2436
  d = ba + cb;
2411
2437
  ba = (t * ba) / d;
2412
2438
  cb = (t * cb) / d;
@@ -2576,8 +2602,8 @@ const BezierHelper = {
2576
2602
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2577
2603
  addPoint$1(pointBounds, toX, toY);
2578
2604
  for (let i = 0, len = tList.length; i < len; i++) {
2579
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2580
- addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
2605
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2606
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2581
2607
  }
2582
2608
  },
2583
2609
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2651,7 +2677,7 @@ const EllipseHelper = {
2651
2677
  };
2652
2678
 
2653
2679
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$3, 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;
2654
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2680
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2655
2681
  const { ellipticalArc } = EllipseHelper;
2656
2682
  const debug$b = Debug.get('PathConvert');
2657
2683
  const setEndPoint$1 = {};
@@ -2848,7 +2874,7 @@ const PathConvert = {
2848
2874
  case N$3:
2849
2875
  x = old[i + 1];
2850
2876
  y = old[i + 2];
2851
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2877
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2852
2878
  i += 5;
2853
2879
  break;
2854
2880
  case D$3:
@@ -3024,7 +3050,7 @@ const PathCommandDataHelper = {
3024
3050
  };
3025
3051
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
3026
3052
 
3027
- const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
3053
+ const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
3028
3054
  class PathCreator {
3029
3055
  set path(value) { this.__path = value; }
3030
3056
  get path() { return this.__path; }
@@ -3071,7 +3097,7 @@ class PathCreator {
3071
3097
  return this;
3072
3098
  }
3073
3099
  rect(x, y, width, height) {
3074
- rect$1(this.__path, x, y, width, height);
3100
+ rect$2(this.__path, x, y, width, height);
3075
3101
  this.paint();
3076
3102
  return this;
3077
3103
  }
@@ -3189,7 +3215,7 @@ const PathDrawer = {
3189
3215
 
3190
3216
  const { M: M$1, L: L$2, C, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
3191
3217
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3192
- const { addPointBounds, copy: copy$7, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3218
+ const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3193
3219
  const debug$9 = Debug.get('PathBounds');
3194
3220
  let radius, radiusX, radiusY;
3195
3221
  const tempPointBounds = {};
@@ -3261,7 +3287,7 @@ const PathBounds = {
3261
3287
  break;
3262
3288
  case G:
3263
3289
  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);
3264
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3290
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3265
3291
  x = setEndPoint.x;
3266
3292
  y = setEndPoint.y;
3267
3293
  i += 9;
@@ -3277,7 +3303,7 @@ const PathBounds = {
3277
3303
  break;
3278
3304
  case O:
3279
3305
  arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
3280
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3306
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3281
3307
  x = setEndPoint.x;
3282
3308
  y = setEndPoint.y;
3283
3309
  i += 7;
@@ -3292,7 +3318,7 @@ const PathBounds = {
3292
3318
  break;
3293
3319
  case U:
3294
3320
  arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
3295
- i === 0 ? copy$7(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3321
+ i === 0 ? copy$8(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
3296
3322
  x = setEndPoint.x;
3297
3323
  y = setEndPoint.y;
3298
3324
  i += 6;
@@ -3386,7 +3412,7 @@ function canvasPatch(drawer) {
3386
3412
  }
3387
3413
 
3388
3414
  const FileHelper = {
3389
- opacityTypes: ['png', 'webp', 'svg'],
3415
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3390
3416
  upperCaseTypeMap: {},
3391
3417
  mineType(type) {
3392
3418
  if (!type || type.startsWith('image'))
@@ -3413,7 +3439,7 @@ const FileHelper = {
3413
3439
  }
3414
3440
  };
3415
3441
  const F = FileHelper;
3416
- F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3442
+ F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3417
3443
 
3418
3444
  const debug$8 = Debug.get('TaskProcessor');
3419
3445
  class TaskItem {
@@ -3730,8 +3756,8 @@ const ImageManager = {
3730
3756
  list.length = 0;
3731
3757
  }
3732
3758
  },
3733
- hasOpacityPixel(config) {
3734
- return FileHelper.opacityTypes.some(item => I.isFormat(item, config));
3759
+ hasAlphaPixel(config) {
3760
+ return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3735
3761
  },
3736
3762
  isFormat(format, config) {
3737
3763
  if (config.format === format)
@@ -3769,7 +3795,7 @@ class LeaferImage {
3769
3795
  this.setView(view.config ? view.view : view);
3770
3796
  }
3771
3797
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3772
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3798
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3773
3799
  }
3774
3800
  load(onSuccess, onError) {
3775
3801
  if (!this.loading) {
@@ -4228,8 +4254,8 @@ function registerUIEvent() {
4228
4254
  };
4229
4255
  }
4230
4256
 
4231
- const { copy: copy$6, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4232
- const matrix = {}, { round } = Math;
4257
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4258
+ const matrix$1 = {}, { round } = Math;
4233
4259
  const LeafHelper = {
4234
4260
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4235
4261
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
@@ -4324,13 +4350,13 @@ const LeafHelper = {
4324
4350
  transition = scaleY;
4325
4351
  scaleY = scaleX;
4326
4352
  }
4327
- copy$6(matrix, o);
4328
- scaleOfOuter$2(matrix, origin, scaleX, scaleY);
4353
+ copy$7(matrix$1, o);
4354
+ scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4329
4355
  if (t.origin || t.around) {
4330
- L.setTransform(t, matrix, resize, transition);
4356
+ L.setTransform(t, matrix$1, resize, transition);
4331
4357
  }
4332
4358
  else {
4333
- const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
4359
+ const x = t.x + matrix$1.e - o.e, y = t.y + matrix$1.f - o.f;
4334
4360
  if (transition && !resize)
4335
4361
  t.animate({ x, y, scaleX: t.scaleX * scaleX, scaleY: t.scaleY * scaleY }, transition);
4336
4362
  else
@@ -4342,32 +4368,32 @@ const LeafHelper = {
4342
4368
  },
4343
4369
  rotateOfLocal(t, origin, angle, transition) {
4344
4370
  const o = t.__localMatrix;
4345
- copy$6(matrix, o);
4346
- rotateOfOuter$2(matrix, origin, angle);
4371
+ copy$7(matrix$1, o);
4372
+ rotateOfOuter$2(matrix$1, origin, angle);
4347
4373
  if (t.origin || t.around)
4348
- L.setTransform(t, matrix, false, transition);
4374
+ L.setTransform(t, matrix$1, false, transition);
4349
4375
  else
4350
- t.set({ x: t.x + matrix.e - o.e, y: t.y + matrix.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
4376
+ t.set({ x: t.x + matrix$1.e - o.e, y: t.y + matrix$1.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition);
4351
4377
  },
4352
4378
  skewOfWorld(t, origin, skewX, skewY, resize, transition) {
4353
4379
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize, transition);
4354
4380
  },
4355
4381
  skewOfLocal(t, origin, skewX, skewY = 0, resize, transition) {
4356
- copy$6(matrix, t.__localMatrix);
4357
- skewOfOuter(matrix, origin, skewX, skewY);
4358
- L.setTransform(t, matrix, resize, transition);
4382
+ copy$7(matrix$1, t.__localMatrix);
4383
+ skewOfOuter(matrix$1, origin, skewX, skewY);
4384
+ L.setTransform(t, matrix$1, resize, transition);
4359
4385
  },
4360
4386
  transformWorld(t, transform, resize, transition) {
4361
- copy$6(matrix, t.worldTransform);
4362
- multiplyParent$2(matrix, transform);
4387
+ copy$7(matrix$1, t.worldTransform);
4388
+ multiplyParent$2(matrix$1, transform);
4363
4389
  if (t.parent)
4364
- divideParent(matrix, t.parent.worldTransform);
4365
- L.setTransform(t, matrix, resize, transition);
4390
+ divideParent(matrix$1, t.parent.worldTransform);
4391
+ L.setTransform(t, matrix$1, resize, transition);
4366
4392
  },
4367
4393
  transform(t, transform, resize, transition) {
4368
- copy$6(matrix, t.localTransform);
4369
- multiplyParent$2(matrix, transform);
4370
- L.setTransform(t, matrix, resize, transition);
4394
+ copy$7(matrix$1, t.localTransform);
4395
+ multiplyParent$2(matrix$1, transform);
4396
+ L.setTransform(t, matrix$1, resize, transition);
4371
4397
  },
4372
4398
  setTransform(t, transform, resize, transition) {
4373
4399
  const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
@@ -4401,9 +4427,9 @@ const LeafHelper = {
4401
4427
  return innerOrigin;
4402
4428
  },
4403
4429
  getRelativeWorld(t, relative, temp) {
4404
- copy$6(matrix, t.worldTransform);
4405
- divideParent(matrix, relative.worldTransform);
4406
- return temp ? matrix : Object.assign({}, matrix);
4430
+ copy$7(matrix$1, t.worldTransform);
4431
+ divideParent(matrix$1, relative.worldTransform);
4432
+ return temp ? matrix$1 : Object.assign({}, matrix$1);
4407
4433
  },
4408
4434
  drop(t, parent, index, resize) {
4409
4435
  t.setTransform(L.getRelativeWorld(t, parent, true), resize);
@@ -4457,7 +4483,7 @@ const LeafBoundsHelper = {
4457
4483
  }
4458
4484
  };
4459
4485
 
4460
- const { updateBounds: updateBounds$2 } = LeafHelper;
4486
+ const { updateBounds: updateBounds$3 } = LeafHelper;
4461
4487
  const BranchHelper = {
4462
4488
  sort(a, b) {
4463
4489
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4519,11 +4545,11 @@ const BranchHelper = {
4519
4545
  branch = branchStack[i];
4520
4546
  children = branch.children;
4521
4547
  for (let j = 0, len = children.length; j < len; j++) {
4522
- updateBounds$2(children[j]);
4548
+ updateBounds$3(children[j]);
4523
4549
  }
4524
4550
  if (exclude && exclude === branch)
4525
4551
  continue;
4526
- updateBounds$2(branch);
4552
+ updateBounds$3(branch);
4527
4553
  }
4528
4554
  }
4529
4555
  };
@@ -4541,8 +4567,8 @@ const WaitHelper = {
4541
4567
  }
4542
4568
  };
4543
4569
 
4544
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4545
- const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4570
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
4571
+ const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
4546
4572
  const localContent = '_localContentBounds';
4547
4573
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
4548
4574
  class LeafLayout {
@@ -4585,7 +4611,9 @@ class LeafLayout {
4585
4611
  this._localRenderBounds = local;
4586
4612
  }
4587
4613
  update() {
4588
- const { leafer } = this.leaf;
4614
+ const { leaf } = this, { leafer } = leaf;
4615
+ if (leaf.isApp)
4616
+ return updateBounds$2(leaf);
4589
4617
  if (leafer) {
4590
4618
  if (leafer.ready)
4591
4619
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4593,7 +4621,7 @@ class LeafLayout {
4593
4621
  leafer.start();
4594
4622
  }
4595
4623
  else {
4596
- let root = this.leaf;
4624
+ let root = leaf;
4597
4625
  while (root.parent && !root.parent.leafer) {
4598
4626
  root = root.parent;
4599
4627
  }
@@ -4700,7 +4728,7 @@ class LeafLayout {
4700
4728
  }
4701
4729
  if (!layoutBounds)
4702
4730
  layoutBounds = MatrixHelper.getLayout(matrix);
4703
- copy$5(layoutBounds, bounds);
4731
+ copy$6(layoutBounds, bounds);
4704
4732
  PointHelper.copy(layoutBounds, point);
4705
4733
  if (unscale) {
4706
4734
  const { scaleX, scaleY } = layoutBounds;
@@ -4815,7 +4843,7 @@ class LeafLayout {
4815
4843
  }
4816
4844
  childrenSortChange() {
4817
4845
  if (!this.childrenSortChanged) {
4818
- this.childrenSortChanged = true;
4846
+ this.childrenSortChanged = this.affectChildrenSort = true;
4819
4847
  this.leaf.forceUpdate('surface');
4820
4848
  }
4821
4849
  }
@@ -4882,6 +4910,40 @@ ImageEvent.LOAD = 'image.load';
4882
4910
  ImageEvent.LOADED = 'image.loaded';
4883
4911
  ImageEvent.ERROR = 'image.error';
4884
4912
 
4913
+ class BoundsEvent extends Event {
4914
+ static checkHas(leaf, type, mode) {
4915
+ if (mode === 'on') {
4916
+ type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
4917
+ }
4918
+ else {
4919
+ leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
4920
+ leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
4921
+ }
4922
+ }
4923
+ static emitLocal(leaf) {
4924
+ if (leaf.leaferIsReady) {
4925
+ const { resized } = leaf.__layout;
4926
+ if (resized !== 'local') {
4927
+ leaf.emit(RESIZE, leaf);
4928
+ if (resized === 'inner')
4929
+ leaf.emit(INNER, leaf);
4930
+ }
4931
+ leaf.emit(LOCAL, leaf);
4932
+ }
4933
+ }
4934
+ static emitWorld(leaf) {
4935
+ if (leaf.leaferIsReady)
4936
+ leaf.emit(WORLD, this);
4937
+ }
4938
+ }
4939
+ BoundsEvent.RESIZE = 'bounds.resize';
4940
+ BoundsEvent.INNER = 'bounds.inner';
4941
+ BoundsEvent.LOCAL = 'bounds.local';
4942
+ BoundsEvent.WORLD = 'bounds.world';
4943
+ const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
4944
+ const boundsEventMap = {};
4945
+ [RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
4946
+
4885
4947
  class ResizeEvent extends Event {
4886
4948
  get bigger() {
4887
4949
  if (!this.old)
@@ -4978,9 +5040,12 @@ class Eventer {
4978
5040
  set event(map) { this.on(map); }
4979
5041
  on(type, listener, options) {
4980
5042
  if (!listener) {
4981
- let event, map = type;
4982
- for (let key in map)
4983
- event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
5043
+ let event;
5044
+ if (type instanceof Array)
5045
+ type.forEach(item => this.on(item[0], item[1], item[2]));
5046
+ else
5047
+ for (let key in type)
5048
+ (event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
4984
5049
  return;
4985
5050
  }
4986
5051
  let capture, once;
@@ -5010,6 +5075,8 @@ class Eventer {
5010
5075
  else {
5011
5076
  map[type] = [item];
5012
5077
  }
5078
+ if (boundsEventMap[type])
5079
+ BoundsEvent.checkHas(this, type, 'on');
5013
5080
  }
5014
5081
  });
5015
5082
  }
@@ -5031,6 +5098,8 @@ class Eventer {
5031
5098
  events.splice(index, 1);
5032
5099
  if (!events.length)
5033
5100
  delete map[type];
5101
+ if (boundsEventMap[type])
5102
+ BoundsEvent.checkHas(this, type, 'off');
5034
5103
  }
5035
5104
  }
5036
5105
  });
@@ -5050,19 +5119,31 @@ class Eventer {
5050
5119
  }
5051
5120
  }
5052
5121
  on_(type, listener, bind, options) {
5053
- if (bind)
5054
- listener = listener.bind(bind);
5055
- this.on(type, listener, options);
5122
+ if (!listener)
5123
+ (type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
5124
+ else
5125
+ this.on(type, bind ? listener = listener.bind(bind) : listener, options);
5056
5126
  return { type, current: this, listener, options };
5057
5127
  }
5058
5128
  off_(id) {
5059
5129
  if (!id)
5060
5130
  return;
5061
5131
  const list = id instanceof Array ? id : [id];
5062
- list.forEach(item => item.current.off(item.type, item.listener, item.options));
5132
+ list.forEach(item => {
5133
+ if (!item.listener)
5134
+ (item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
5135
+ else
5136
+ item.current.off(item.type, item.listener, item.options);
5137
+ });
5063
5138
  list.length = 0;
5064
5139
  }
5065
- once(type, listener, capture) {
5140
+ once(type, listener, captureOrBind, capture) {
5141
+ if (!listener)
5142
+ return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
5143
+ if (typeof captureOrBind === 'object')
5144
+ listener = listener.bind(captureOrBind);
5145
+ else
5146
+ capture = captureOrBind;
5066
5147
  this.on(type, listener, { once: true, capture });
5067
5148
  }
5068
5149
  emit(type, event, capture) {
@@ -5174,7 +5255,7 @@ const LeafDataProxy = {
5174
5255
  };
5175
5256
 
5176
5257
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5177
- const { toPoint: toPoint$3, tempPoint: tempPoint$1 } = AroundHelper;
5258
+ const { toPoint: toPoint$3, tempPoint } = AroundHelper;
5178
5259
  const LeafMatrix = {
5179
5260
  __updateWorldMatrix() {
5180
5261
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
@@ -5183,33 +5264,39 @@ const LeafMatrix = {
5183
5264
  if (this.__local) {
5184
5265
  const layout = this.__layout, local = this.__local, data = this.__;
5185
5266
  if (layout.affectScaleOrRotation) {
5186
- if (layout.scaleChanged || layout.rotationChanged) {
5267
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5187
5268
  setLayout(local, data, null, null, layout.affectRotation);
5188
- layout.scaleChanged = layout.rotationChanged = false;
5269
+ layout.scaleChanged = layout.rotationChanged = undefined;
5189
5270
  }
5190
5271
  }
5191
5272
  local.e = data.x + data.offsetX;
5192
5273
  local.f = data.y + data.offsetY;
5193
5274
  if (data.around || data.origin) {
5194
- toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
5195
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
5275
+ toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
5276
+ translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
5196
5277
  }
5197
5278
  }
5198
- this.__layout.matrixChanged = false;
5279
+ this.__layout.matrixChanged = undefined;
5199
5280
  }
5200
5281
  };
5201
5282
 
5202
5283
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5203
5284
  const { updateBounds: updateBounds$1 } = BranchHelper;
5204
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
5285
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5205
5286
  const { toBounds: toBounds$1 } = PathBounds;
5206
5287
  const LeafBounds = {
5207
5288
  __updateWorldBounds() {
5208
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5209
- if (this.__layout.resized) {
5210
- this.__onUpdateSize();
5211
- this.__layout.resized = false;
5289
+ const layout = this.__layout;
5290
+ toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5291
+ if (layout.resized) {
5292
+ if (layout.resized === 'inner')
5293
+ this.__onUpdateSize();
5294
+ if (this.__hasLocalEvent)
5295
+ BoundsEvent.emitLocal(this);
5296
+ layout.resized = undefined;
5212
5297
  }
5298
+ if (this.__hasWorldEvent)
5299
+ BoundsEvent.emitWorld(this);
5213
5300
  },
5214
5301
  __updateLocalBounds() {
5215
5302
  const layout = this.__layout;
@@ -5218,12 +5305,12 @@ const LeafBounds = {
5218
5305
  this.__updatePath();
5219
5306
  this.__updateRenderPath();
5220
5307
  this.__updateBoxBounds();
5221
- layout.resized = true;
5308
+ layout.resized = 'inner';
5222
5309
  }
5223
5310
  if (layout.localBoxChanged) {
5224
5311
  if (this.__local)
5225
5312
  this.__updateLocalBoxBounds();
5226
- layout.localBoxChanged = false;
5313
+ layout.localBoxChanged = undefined;
5227
5314
  if (layout.strokeSpread)
5228
5315
  layout.strokeChanged = true;
5229
5316
  if (layout.renderSpread)
@@ -5231,7 +5318,7 @@ const LeafBounds = {
5231
5318
  if (this.parent)
5232
5319
  this.parent.__layout.boxChange();
5233
5320
  }
5234
- layout.boxChanged = false;
5321
+ layout.boxChanged = undefined;
5235
5322
  if (layout.strokeChanged) {
5236
5323
  layout.strokeSpread = this.__updateStrokeSpread();
5237
5324
  if (layout.strokeSpread) {
@@ -5243,12 +5330,12 @@ const LeafBounds = {
5243
5330
  else {
5244
5331
  layout.spreadStrokeCancel();
5245
5332
  }
5246
- layout.strokeChanged = false;
5333
+ layout.strokeChanged = undefined;
5247
5334
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5248
5335
  layout.renderChanged = true;
5249
5336
  if (this.parent)
5250
5337
  this.parent.__layout.strokeChange();
5251
- layout.resized = true;
5338
+ layout.resized = 'inner';
5252
5339
  }
5253
5340
  if (layout.renderChanged) {
5254
5341
  layout.renderSpread = this.__updateRenderSpread();
@@ -5261,11 +5348,12 @@ const LeafBounds = {
5261
5348
  else {
5262
5349
  layout.spreadRenderCancel();
5263
5350
  }
5264
- layout.renderChanged = false;
5351
+ layout.renderChanged = undefined;
5265
5352
  if (this.parent)
5266
5353
  this.parent.__layout.renderChange();
5267
5354
  }
5268
- layout.boundsChanged = false;
5355
+ layout.resized || (layout.resized = 'local');
5356
+ layout.boundsChanged = undefined;
5269
5357
  },
5270
5358
  __updateLocalBoxBounds() {
5271
5359
  if (this.__hasMotionPath)
@@ -5325,7 +5413,7 @@ const LeafBounds = {
5325
5413
  },
5326
5414
  __updateRenderBounds() {
5327
5415
  const layout = this.__layout;
5328
- layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
5416
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
5329
5417
  }
5330
5418
  };
5331
5419
 
@@ -5430,7 +5518,7 @@ const BranchRender = {
5430
5518
  const { LEAF, create } = IncrementId;
5431
5519
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5432
5520
  const { toOuterOf } = BoundsHelper;
5433
- const { copy: copy$3, move } = PointHelper;
5521
+ const { copy: copy$4, move } = PointHelper;
5434
5522
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5435
5523
  let Leaf = class Leaf {
5436
5524
  get tag() { return this.__tag; }
@@ -5643,7 +5731,7 @@ let Leaf = class Leaf {
5643
5731
  }
5644
5732
  else {
5645
5733
  if (to)
5646
- copy$3(to, world);
5734
+ copy$4(to, world);
5647
5735
  }
5648
5736
  }
5649
5737
  localToWorld(local, to, distance, relative) {
@@ -5652,7 +5740,7 @@ let Leaf = class Leaf {
5652
5740
  }
5653
5741
  else {
5654
5742
  if (to)
5655
- copy$3(to, local);
5743
+ copy$4(to, local);
5656
5744
  }
5657
5745
  }
5658
5746
  worldToInner(world, to, distance, relative) {
@@ -5805,7 +5893,7 @@ let Leaf = class Leaf {
5805
5893
  off(_type, _listener, _options) { }
5806
5894
  on_(_type, _listener, _bind, _options) { return undefined; }
5807
5895
  off_(_id) { }
5808
- once(_type, _listener, _capture) { }
5896
+ once(_type, _listener, _captureOrBind, _capture) { }
5809
5897
  emit(_type, _event, _capture) { }
5810
5898
  emitEvent(_event, _capture) { }
5811
5899
  hasEvent(_type, _capture) { return false; }
@@ -6142,7 +6230,7 @@ class LeafLevelList {
6142
6230
  }
6143
6231
  }
6144
6232
 
6145
- const version = "1.6.2";
6233
+ const version = "1.6.3";
6146
6234
 
6147
6235
  class LeaferCanvas extends LeaferCanvasBase {
6148
6236
  get allowBackgroundColor() { return false; }
@@ -6440,17 +6528,15 @@ class Watcher {
6440
6528
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6441
6529
  this.__updatedList = new LeafList();
6442
6530
  this.totalTimes++;
6443
- this.changed = false;
6444
- this.hasVisible = false;
6445
- this.hasRemove = false;
6446
- this.hasAdd = false;
6531
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6447
6532
  }
6448
6533
  __listenEvents() {
6449
- const { target } = this;
6450
6534
  this.__eventIds = [
6451
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6452
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6453
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6535
+ this.target.on_([
6536
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6537
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6538
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6539
+ ])
6454
6540
  ];
6455
6541
  }
6456
6542
  __removeListenEvents() {
@@ -6460,8 +6546,7 @@ class Watcher {
6460
6546
  if (this.target) {
6461
6547
  this.stop();
6462
6548
  this.__removeListenEvents();
6463
- this.target = null;
6464
- this.__updatedList = null;
6549
+ this.target = this.__updatedList = null;
6465
6550
  }
6466
6551
  }
6467
6552
  }
@@ -6566,7 +6651,7 @@ class Layouter {
6566
6651
  this.disabled = true;
6567
6652
  }
6568
6653
  layout() {
6569
- if (!this.running)
6654
+ if (this.layouting || !this.running)
6570
6655
  return;
6571
6656
  const { target } = this;
6572
6657
  this.times = 0;
@@ -6649,12 +6734,10 @@ class Layouter {
6649
6734
  }
6650
6735
  static fullLayout(target) {
6651
6736
  updateAllMatrix(target, true);
6652
- if (target.isBranch) {
6737
+ if (target.isBranch)
6653
6738
  BranchHelper.updateBounds(target);
6654
- }
6655
- else {
6739
+ else
6656
6740
  LeafHelper.updateBounds(target);
6657
- }
6658
6741
  updateAllChange(target);
6659
6742
  }
6660
6743
  addExtra(leaf) {
@@ -6677,11 +6760,12 @@ class Layouter {
6677
6760
  this.__updatedList = event.data.updatedList;
6678
6761
  }
6679
6762
  __listenEvents() {
6680
- const { target } = this;
6681
6763
  this.__eventIds = [
6682
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6683
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6684
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6764
+ this.target.on_([
6765
+ [LayoutEvent.REQUEST, this.layout, this],
6766
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6767
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6768
+ ])
6685
6769
  ];
6686
6770
  }
6687
6771
  __removeListenEvents() {
@@ -6912,12 +6996,13 @@ class Renderer {
6912
6996
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6913
6997
  }
6914
6998
  __listenEvents() {
6915
- const { target } = this;
6916
6999
  this.__eventIds = [
6917
- target.on_(RenderEvent.REQUEST, this.update, this),
6918
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6919
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6920
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7000
+ this.target.on_([
7001
+ [RenderEvent.REQUEST, this.update, this],
7002
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7003
+ [RenderEvent.AGAIN, this.renderAgain, this],
7004
+ [ResizeEvent.RESIZE, this.__onResize, this]
7005
+ ])
6921
7006
  ];
6922
7007
  }
6923
7008
  __removeListenEvents() {
@@ -6976,8 +7061,32 @@ function zoomLayerType() {
6976
7061
  };
6977
7062
  }
6978
7063
 
7064
+ function hasTransparent$3(color) {
7065
+ if (!color || color.length === 7 || color.length === 4)
7066
+ return false;
7067
+ if (color === 'transparent')
7068
+ return true;
7069
+ const first = color[0];
7070
+ if (first === '#') {
7071
+ switch (color.length) {
7072
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7073
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7074
+ }
7075
+ }
7076
+ else if (first === 'r' || first === 'h') {
7077
+ if (color[3] === 'a') {
7078
+ const i = color.lastIndexOf(',');
7079
+ if (i > -1)
7080
+ return parseFloat(color.slice(i + 1)) < 1;
7081
+ }
7082
+ }
7083
+ return false;
7084
+ }
7085
+
6979
7086
  const TextConvert = {};
6980
- const ColorConvert = {};
7087
+ const ColorConvert = {
7088
+ hasTransparent: hasTransparent$3
7089
+ };
6981
7090
  const UnitConvert = {
6982
7091
  number(value, percentRefer) {
6983
7092
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7003,6 +7112,7 @@ const Transition = {
7003
7112
  };
7004
7113
 
7005
7114
  const { parse, objectToCanvasData } = PathConvert;
7115
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7006
7116
  const emptyPaint = {};
7007
7117
  const debug$1 = Debug.get('UIData');
7008
7118
  class UIData extends LeafData {
@@ -7061,38 +7171,22 @@ class UIData extends LeafData {
7061
7171
  if (this.__naturalWidth)
7062
7172
  this.__removeNaturalSize();
7063
7173
  if (typeof value === 'string' || !value) {
7064
- if (this.__isFills) {
7065
- this.__removeInput('fill');
7066
- PaintImage.recycleImage('fill', this);
7067
- this.__isFills = false;
7068
- this.__pixelFill && (this.__pixelFill = false);
7069
- }
7174
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7175
+ this.__isFills && this.__removePaint('fill', true);
7070
7176
  this._fill = value;
7071
7177
  }
7072
7178
  else if (typeof value === 'object') {
7073
- this.__setInput('fill', value);
7074
- const layout = this.__leaf.__layout;
7075
- layout.boxChanged || layout.boxChange();
7076
- this.__isFills = true;
7077
- this._fill || (this._fill = emptyPaint);
7179
+ this.__setPaint('fill', value);
7078
7180
  }
7079
7181
  }
7080
7182
  setStroke(value) {
7081
7183
  if (typeof value === 'string' || !value) {
7082
- if (this.__isStrokes) {
7083
- this.__removeInput('stroke');
7084
- PaintImage.recycleImage('stroke', this);
7085
- this.__isStrokes = false;
7086
- this.__pixelStroke && (this.__pixelStroke = false);
7087
- }
7184
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7185
+ this.__isStrokes && this.__removePaint('stroke', true);
7088
7186
  this._stroke = value;
7089
7187
  }
7090
7188
  else if (typeof value === 'object') {
7091
- this.__setInput('stroke', value);
7092
- const layout = this.__leaf.__layout;
7093
- layout.boxChanged || layout.boxChange();
7094
- this.__isStrokes = true;
7095
- this._stroke || (this._stroke = emptyPaint);
7189
+ this.__setPaint('stroke', value);
7096
7190
  }
7097
7191
  }
7098
7192
  setPath(value) {
@@ -7122,7 +7216,34 @@ class UIData extends LeafData {
7122
7216
  Paint.compute('fill', this.__leaf);
7123
7217
  if (stroke)
7124
7218
  Paint.compute('stroke', this.__leaf);
7125
- this.__needComputePaint = false;
7219
+ this.__needComputePaint = undefined;
7220
+ }
7221
+ __setPaint(attrName, value) {
7222
+ this.__setInput(attrName, value);
7223
+ const layout = this.__leaf.__layout;
7224
+ layout.boxChanged || layout.boxChange();
7225
+ if (value instanceof Array && !value.length) {
7226
+ this.__removePaint(attrName);
7227
+ }
7228
+ else {
7229
+ if (attrName === 'fill')
7230
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7231
+ else
7232
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7233
+ }
7234
+ }
7235
+ __removePaint(attrName, removeInput) {
7236
+ if (removeInput)
7237
+ this.__removeInput(attrName);
7238
+ PaintImage.recycleImage(attrName, this);
7239
+ if (attrName === 'fill') {
7240
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7241
+ this._fill = this.__isFills = undefined;
7242
+ }
7243
+ else {
7244
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7245
+ this._stroke = this.__isStrokes = undefined;
7246
+ }
7126
7247
  }
7127
7248
  }
7128
7249
  function setArray(data, key, value) {
@@ -7130,10 +7251,10 @@ function setArray(data, key, value) {
7130
7251
  if (value instanceof Array) {
7131
7252
  if (value.some((item) => item.visible === false))
7132
7253
  value = value.filter((item) => item.visible !== false);
7133
- value.length || (value = null);
7254
+ value.length || (value = undefined);
7134
7255
  }
7135
7256
  else
7136
- value = value && value.visible !== false ? [value] : null;
7257
+ value = value && value.visible !== false ? [value] : undefined;
7137
7258
  data['_' + key] = value;
7138
7259
  }
7139
7260
 
@@ -7236,8 +7357,6 @@ class ImageData extends RectData {
7236
7357
  this._url = value;
7237
7358
  }
7238
7359
  __setImageFill(value) {
7239
- if (this.__leaf.image)
7240
- this.__leaf.image = null;
7241
7360
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7242
7361
  }
7243
7362
  __getData() {
@@ -7303,21 +7422,19 @@ const UIBounds = {
7303
7422
  }
7304
7423
  };
7305
7424
 
7425
+ const { stintSet: stintSet$1 } = DataHelper;
7306
7426
  const UIRender = {
7307
7427
  __updateChange() {
7308
- const data = this.__, w = this.__world;
7428
+ const data = this.__;
7309
7429
  if (data.__useEffect) {
7310
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7311
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7430
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7431
+ stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7432
+ data.__useEffect = !!(shadow || otherEffect);
7312
7433
  }
7313
- const half = data.__hasHalf;
7314
- w.half !== half && (w.half = half);
7434
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7435
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7315
7436
  data.__checkSingle();
7316
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7317
- if (complex)
7318
- data.__complex = true;
7319
- else
7320
- data.__complex && (data.__complex = false);
7437
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7321
7438
  },
7322
7439
  __drawFast(canvas, options) {
7323
7440
  drawFast(this, canvas, options);
@@ -7327,21 +7444,23 @@ const UIRender = {
7327
7444
  if (data.__complex) {
7328
7445
  if (data.__needComputePaint)
7329
7446
  data.__computePaint();
7330
- const { fill, stroke, __drawAfterFill } = data;
7447
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7331
7448
  this.__drawRenderPath(canvas);
7332
- if (data.__useEffect) {
7449
+ if (data.__useEffect && !__isFastShadow) {
7333
7450
  const shape = Paint.shape(this, canvas, options);
7334
7451
  this.__nowWorld = this.__getNowWorld(options);
7335
7452
  const { shadow, innerShadow, filter } = data;
7336
7453
  if (shadow)
7337
7454
  Effect.shadow(this, canvas, shape);
7455
+ if (__fillAfterStroke)
7456
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7338
7457
  if (fill)
7339
7458
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7340
7459
  if (__drawAfterFill)
7341
7460
  this.__drawAfterFill(canvas, options);
7342
7461
  if (innerShadow)
7343
7462
  Effect.innerShadow(this, canvas, shape);
7344
- if (stroke)
7463
+ if (stroke && !__fillAfterStroke)
7345
7464
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7346
7465
  if (filter)
7347
7466
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7350,21 +7469,27 @@ const UIRender = {
7350
7469
  shape.canvas.recycle();
7351
7470
  }
7352
7471
  else {
7472
+ if (__fillAfterStroke)
7473
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7474
+ if (__isFastShadow) {
7475
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7476
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7477
+ }
7353
7478
  if (fill)
7354
7479
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7480
+ if (__isFastShadow)
7481
+ canvas.restore();
7355
7482
  if (__drawAfterFill)
7356
7483
  this.__drawAfterFill(canvas, options);
7357
- if (stroke)
7484
+ if (stroke && !__fillAfterStroke)
7358
7485
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7359
7486
  }
7360
7487
  }
7361
7488
  else {
7362
- if (data.__pathInputed) {
7489
+ if (data.__pathInputed)
7363
7490
  drawFast(this, canvas, options);
7364
- }
7365
- else {
7491
+ else
7366
7492
  this.__drawFast(canvas, options);
7367
- }
7368
7493
  }
7369
7494
  },
7370
7495
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7373,11 +7498,11 @@ const UIRender = {
7373
7498
  const { fill, stroke } = this.__;
7374
7499
  this.__drawRenderPath(canvas);
7375
7500
  if (fill && !ignoreFill)
7376
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7501
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7377
7502
  if (this.__.__isCanvas)
7378
7503
  this.__drawAfterFill(canvas, options);
7379
7504
  if (stroke && !ignoreStroke)
7380
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7505
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7381
7506
  }
7382
7507
  },
7383
7508
  __drawAfterFill(canvas, options) {
@@ -7392,13 +7517,15 @@ const UIRender = {
7392
7517
  }
7393
7518
  };
7394
7519
  function drawFast(ui, canvas, options) {
7395
- const { fill, stroke, __drawAfterFill } = ui.__;
7520
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7396
7521
  ui.__drawRenderPath(canvas);
7522
+ if (__fillAfterStroke)
7523
+ Paint.stroke(stroke, ui, canvas);
7397
7524
  if (fill)
7398
7525
  Paint.fill(fill, ui, canvas);
7399
7526
  if (__drawAfterFill)
7400
7527
  ui.__drawAfterFill(canvas, options);
7401
- if (stroke)
7528
+ if (stroke && !__fillAfterStroke)
7402
7529
  Paint.stroke(stroke, ui, canvas);
7403
7530
  }
7404
7531
 
@@ -7770,6 +7897,9 @@ __decorate([
7770
7897
  __decorate([
7771
7898
  surfaceType()
7772
7899
  ], UI.prototype, "placeholderColor", void 0);
7900
+ __decorate([
7901
+ dataType(100)
7902
+ ], UI.prototype, "placeholderDelay", void 0);
7773
7903
  __decorate([
7774
7904
  dataType({})
7775
7905
  ], UI.prototype, "data", void 0);
@@ -8171,15 +8301,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8171
8301
  }
8172
8302
  __listenEvents() {
8173
8303
  const runId = Run.start('FirstCreate ' + this.innerName);
8174
- this.once(LeaferEvent.START, () => Run.end(runId));
8175
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8176
- this.once(RenderEvent.START, () => this.__onCreated());
8177
- this.once(RenderEvent.END, () => this.__onViewReady());
8178
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8304
+ this.once([
8305
+ [LeaferEvent.START, () => Run.end(runId)],
8306
+ [LayoutEvent.START, this.updateLazyBounds, this],
8307
+ [RenderEvent.START, this.__onCreated, this],
8308
+ [RenderEvent.END, this.__onViewReady, this]
8309
+ ]);
8310
+ this.__eventIds.push(this.on_([
8311
+ [WatchEvent.DATA, this.__onWatchData, this],
8312
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8313
+ [RenderEvent.NEXT, this.__onNextRender, this]
8314
+ ]));
8179
8315
  }
8180
8316
  __removeListenEvents() {
8181
8317
  this.off_(this.__eventIds);
8182
- this.__eventIds.length = 0;
8183
8318
  }
8184
8319
  destroy(sync) {
8185
8320
  const doDestory = () => {
@@ -8239,8 +8374,8 @@ Rect = __decorate([
8239
8374
  registerUI()
8240
8375
  ], Rect);
8241
8376
 
8242
- const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
8243
- const rect = Rect.prototype, group = Group.prototype;
8377
+ const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8378
+ const rect$1 = Rect.prototype, group = Group.prototype;
8244
8379
  const childrenRenderBounds = {};
8245
8380
  let Box = class Box extends Group {
8246
8381
  get __tag() { return 'Box'; }
@@ -8285,15 +8420,15 @@ let Box = class Box extends Group {
8285
8420
  const { renderBounds } = this.__layout;
8286
8421
  if (this.children.length) {
8287
8422
  super.__updateRenderBounds();
8288
- copy$2(childrenRenderBounds, renderBounds);
8423
+ copy$3(childrenRenderBounds, renderBounds);
8289
8424
  this.__updateRectRenderBounds();
8290
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8425
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8291
8426
  if (isOverflow && this.__.overflow !== 'hide')
8292
8427
  add(renderBounds, childrenRenderBounds);
8293
8428
  }
8294
8429
  else
8295
8430
  this.__updateRectRenderBounds();
8296
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8431
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8297
8432
  }
8298
8433
  __updateRectRenderBounds() { }
8299
8434
  __updateRectChange() { }
@@ -8337,25 +8472,25 @@ __decorate([
8337
8472
  affectRenderBoundsType('show')
8338
8473
  ], Box.prototype, "overflow", void 0);
8339
8474
  __decorate([
8340
- rewrite(rect.__updateStrokeSpread)
8475
+ rewrite(rect$1.__updateStrokeSpread)
8341
8476
  ], Box.prototype, "__updateStrokeSpread", null);
8342
8477
  __decorate([
8343
- rewrite(rect.__updateRenderSpread)
8478
+ rewrite(rect$1.__updateRenderSpread)
8344
8479
  ], Box.prototype, "__updateRectRenderSpread", null);
8345
8480
  __decorate([
8346
- rewrite(rect.__updateBoxBounds)
8481
+ rewrite(rect$1.__updateBoxBounds)
8347
8482
  ], Box.prototype, "__updateRectBoxBounds", null);
8348
8483
  __decorate([
8349
- rewrite(rect.__updateStrokeBounds)
8484
+ rewrite(rect$1.__updateStrokeBounds)
8350
8485
  ], Box.prototype, "__updateStrokeBounds", null);
8351
8486
  __decorate([
8352
- rewrite(rect.__updateRenderBounds)
8487
+ rewrite(rect$1.__updateRenderBounds)
8353
8488
  ], Box.prototype, "__updateRectRenderBounds", null);
8354
8489
  __decorate([
8355
- rewrite(rect.__updateChange)
8490
+ rewrite(rect$1.__updateChange)
8356
8491
  ], Box.prototype, "__updateRectChange", null);
8357
8492
  __decorate([
8358
- rewrite(rect.__render)
8493
+ rewrite(rect$1.__render)
8359
8494
  ], Box.prototype, "__renderRect", null);
8360
8495
  __decorate([
8361
8496
  rewrite(group.__render)
@@ -8597,18 +8732,10 @@ Star = __decorate([
8597
8732
 
8598
8733
  let Image = class Image extends Rect {
8599
8734
  get __tag() { return 'Image'; }
8600
- get ready() { return this.image ? this.image.ready : false; }
8735
+ get ready() { const { image } = this; return image && image.ready; }
8736
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8601
8737
  constructor(data) {
8602
8738
  super(data);
8603
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8604
- }
8605
- __onLoaded(e) {
8606
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8607
- this.image = e.image;
8608
- }
8609
- destroy() {
8610
- this.image = null;
8611
- super.destroy();
8612
8739
  }
8613
8740
  };
8614
8741
  __decorate([
@@ -8624,11 +8751,11 @@ const MyImage = Image;
8624
8751
 
8625
8752
  let Canvas = class Canvas extends Rect {
8626
8753
  get __tag() { return 'Canvas'; }
8754
+ get context() { return this.canvas.context; }
8627
8755
  get ready() { return !this.url; }
8628
8756
  constructor(data) {
8629
8757
  super(data);
8630
8758
  this.canvas = Creator.canvas(this.__);
8631
- this.context = this.canvas.context;
8632
8759
  if (data && data.url)
8633
8760
  this.drawImage(data.url);
8634
8761
  }
@@ -8672,7 +8799,7 @@ let Canvas = class Canvas extends Rect {
8672
8799
  destroy() {
8673
8800
  if (this.canvas) {
8674
8801
  this.canvas.destroy();
8675
- this.canvas = this.context = null;
8802
+ this.canvas = null;
8676
8803
  }
8677
8804
  super.destroy();
8678
8805
  }
@@ -8748,12 +8875,11 @@ let Text = class Text extends UI {
8748
8875
  super.__updateBoxBounds();
8749
8876
  if (italic)
8750
8877
  b.width += fontSize * 0.16;
8751
- const isOverflow = !includes(b, contentBounds) || undefined;
8752
- if (isOverflow)
8878
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8879
+ if (this.isOverflow)
8753
8880
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8754
8881
  else
8755
8882
  data.__textBoxBounds = b;
8756
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8757
8883
  }
8758
8884
  __onUpdateSize() {
8759
8885
  if (this.__box)
@@ -8998,32 +9124,557 @@ function fillPathOrText(ui, canvas) {
8998
9124
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
8999
9125
  }
9000
9126
 
9127
+ let App = class App extends Leafer {
9128
+ get __tag() { return 'App'; }
9129
+ get isApp() { return true; }
9130
+ constructor(userConfig, data) {
9131
+ super(userConfig, data);
9132
+ }
9133
+ init(userConfig, parentApp) {
9134
+ super.init(userConfig, parentApp);
9135
+ if (userConfig) {
9136
+ const { ground, tree, sky, editor } = userConfig;
9137
+ if (ground)
9138
+ this.ground = this.addLeafer(ground);
9139
+ if (tree || editor)
9140
+ this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
9141
+ if (sky || editor)
9142
+ this.sky = this.addLeafer(sky);
9143
+ if (editor)
9144
+ Creator.editor(editor, this);
9145
+ }
9146
+ }
9147
+ __setApp() {
9148
+ const { canvas } = this;
9149
+ const { realCanvas, view } = this.config;
9150
+ if (realCanvas || view === this.canvas.view || !canvas.parentView)
9151
+ this.realCanvas = true;
9152
+ else
9153
+ canvas.unrealCanvas();
9154
+ this.leafer = this;
9155
+ this.watcher.disable();
9156
+ this.layouter.disable();
9157
+ }
9158
+ __updateLocalBounds() {
9159
+ this.forEach(leafer => leafer.updateLayout());
9160
+ super.__updateLocalBounds();
9161
+ }
9162
+ start() {
9163
+ super.start();
9164
+ this.forEach(leafer => leafer.start());
9165
+ }
9166
+ stop() {
9167
+ this.forEach(leafer => leafer.stop());
9168
+ super.stop();
9169
+ }
9170
+ unlockLayout() {
9171
+ super.unlockLayout();
9172
+ this.forEach(leafer => leafer.unlockLayout());
9173
+ }
9174
+ lockLayout() {
9175
+ super.lockLayout();
9176
+ this.forEach(leafer => leafer.lockLayout());
9177
+ }
9178
+ forceRender(bounds, sync) {
9179
+ this.forEach(leafer => leafer.forceRender(bounds, sync));
9180
+ }
9181
+ addLeafer(merge) {
9182
+ const leafer = new Leafer(merge);
9183
+ this.add(leafer);
9184
+ return leafer;
9185
+ }
9186
+ add(leafer, index) {
9187
+ if (!leafer.view) {
9188
+ if (this.realCanvas && !this.canvas.bounds) {
9189
+ setTimeout(() => this.add(leafer, index), 10);
9190
+ return;
9191
+ }
9192
+ leafer.init(this.__getChildConfig(leafer.userConfig), this);
9193
+ }
9194
+ super.add(leafer, index);
9195
+ if (index !== undefined)
9196
+ leafer.canvas.childIndex = index;
9197
+ this.__listenChildEvents(leafer);
9198
+ }
9199
+ forEach(fn) {
9200
+ this.children.forEach(fn);
9201
+ }
9202
+ __onCreated() {
9203
+ this.created = this.children.every(child => child.created);
9204
+ }
9205
+ __onReady() {
9206
+ if (this.children.every(child => child.ready))
9207
+ super.__onReady();
9208
+ }
9209
+ __onViewReady() {
9210
+ if (this.children.every(child => child.viewReady))
9211
+ super.__onViewReady();
9212
+ }
9213
+ __onChildRenderEnd(e) {
9214
+ this.renderer.addBlock(e.renderBounds);
9215
+ if (this.viewReady)
9216
+ this.renderer.update();
9217
+ }
9218
+ __render(canvas, options) {
9219
+ if (canvas.context)
9220
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9221
+ }
9222
+ __onResize(event) {
9223
+ this.forEach(leafer => leafer.resize(event));
9224
+ super.__onResize(event);
9225
+ }
9226
+ updateLayout() {
9227
+ this.forEach(leafer => leafer.updateLayout());
9228
+ }
9229
+ __getChildConfig(userConfig) {
9230
+ const config = Object.assign({}, this.config);
9231
+ config.hittable = config.realCanvas = undefined;
9232
+ if (userConfig)
9233
+ DataHelper.assign(config, userConfig);
9234
+ if (this.autoLayout)
9235
+ DataHelper.copyAttrs(config, this, canvasSizeAttrs);
9236
+ config.view = this.realCanvas ? undefined : this.view;
9237
+ config.fill = undefined;
9238
+ return config;
9239
+ }
9240
+ __listenChildEvents(leafer) {
9241
+ leafer.once([
9242
+ [LayoutEvent.END, this.__onReady, this],
9243
+ [RenderEvent.START, this.__onCreated, this],
9244
+ [RenderEvent.END, this.__onViewReady, this]
9245
+ ]);
9246
+ if (this.realCanvas)
9247
+ this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9248
+ }
9249
+ };
9250
+ App = __decorate([
9251
+ registerUI()
9252
+ ], App);
9253
+
9254
+ const downKeyMap = {};
9255
+ const Keyboard = {
9256
+ isHoldSpaceKey() {
9257
+ return Keyboard.isHold('Space');
9258
+ },
9259
+ isHold(code) {
9260
+ return downKeyMap[code];
9261
+ },
9262
+ setDownCode(code) {
9263
+ if (!downKeyMap[code])
9264
+ downKeyMap[code] = true;
9265
+ },
9266
+ setUpCode(code) {
9267
+ downKeyMap[code] = false;
9268
+ }
9269
+ };
9270
+
9271
+ const PointerButton = {
9272
+ LEFT: 1,
9273
+ RIGHT: 2,
9274
+ MIDDLE: 4,
9275
+ defaultLeft(event) { if (!event.buttons)
9276
+ event.buttons = 1; },
9277
+ left(event) { return event.buttons === 1; },
9278
+ right(event) { return event.buttons === 2; },
9279
+ middle(event) { return event.buttons === 4; }
9280
+ };
9281
+
9282
+ class UIEvent extends Event {
9283
+ get spaceKey() { return Keyboard.isHoldSpaceKey(); }
9284
+ get left() { return PointerButton.left(this); }
9285
+ get right() { return PointerButton.right(this); }
9286
+ get middle() { return PointerButton.middle(this); }
9287
+ constructor(params) {
9288
+ super(params.type);
9289
+ this.bubbles = true;
9290
+ Object.assign(this, params);
9291
+ }
9292
+ getBoxPoint(relative) {
9293
+ return (relative || this.current).getBoxPoint(this);
9294
+ }
9295
+ getInnerPoint(relative) {
9296
+ return (relative || this.current).getInnerPoint(this);
9297
+ }
9298
+ getLocalPoint(relative) {
9299
+ return (relative || this.current).getLocalPoint(this);
9300
+ }
9301
+ getPagePoint() {
9302
+ return this.current.getPagePoint(this);
9303
+ }
9304
+ getInner(relative) { return this.getInnerPoint(relative); }
9305
+ getLocal(relative) { return this.getLocalPoint(relative); }
9306
+ getPage() { return this.getPagePoint(); }
9307
+ static changeName(oldName, newName) {
9308
+ EventCreator.changeName(oldName, newName);
9309
+ }
9310
+ }
9311
+
9312
+ let PointerEvent = class PointerEvent extends UIEvent {
9313
+ };
9314
+ PointerEvent.POINTER = 'pointer';
9315
+ PointerEvent.BEFORE_DOWN = 'pointer.before_down';
9316
+ PointerEvent.BEFORE_MOVE = 'pointer.before_move';
9317
+ PointerEvent.BEFORE_UP = 'pointer.before_up';
9318
+ PointerEvent.DOWN = 'pointer.down';
9319
+ PointerEvent.MOVE = 'pointer.move';
9320
+ PointerEvent.UP = 'pointer.up';
9321
+ PointerEvent.OVER = 'pointer.over';
9322
+ PointerEvent.OUT = 'pointer.out';
9323
+ PointerEvent.ENTER = 'pointer.enter';
9324
+ PointerEvent.LEAVE = 'pointer.leave';
9325
+ PointerEvent.TAP = 'tap';
9326
+ PointerEvent.DOUBLE_TAP = 'double_tap';
9327
+ PointerEvent.CLICK = 'click';
9328
+ PointerEvent.DOUBLE_CLICK = 'double_click';
9329
+ PointerEvent.LONG_PRESS = 'long_press';
9330
+ PointerEvent.LONG_TAP = 'long_tap';
9331
+ PointerEvent.MENU = 'pointer.menu';
9332
+ PointerEvent.MENU_TAP = 'pointer.menu_tap';
9333
+ PointerEvent = __decorate([
9334
+ registerUIEvent()
9335
+ ], PointerEvent);
9336
+
9337
+ const tempMove = {};
9338
+ let DragEvent = class DragEvent extends PointerEvent {
9339
+ static setList(data) {
9340
+ this.list = data instanceof LeafList ? data : new LeafList(data);
9341
+ }
9342
+ static setData(data) {
9343
+ this.data = data;
9344
+ }
9345
+ static getValidMove(leaf, start, total) {
9346
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9347
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9348
+ if (dragBounds)
9349
+ this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9350
+ if (draggable === 'x')
9351
+ move.y = 0;
9352
+ if (draggable === 'y')
9353
+ move.x = 0;
9354
+ return move;
9355
+ }
9356
+ static getMoveInDragBounds(childBox, dragBounds, move, change) {
9357
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9358
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9359
+ if (!change)
9360
+ move = Object.assign({}, move);
9361
+ if (BoundsHelper.includes(childBox, dragBounds)) {
9362
+ if (x > dragBounds.x)
9363
+ move.x += dragBounds.x - x;
9364
+ else if (right < boundsRight)
9365
+ move.x += boundsRight - right;
9366
+ if (y > dragBounds.y)
9367
+ move.y += dragBounds.y - y;
9368
+ else if (bottom < boundsBottom)
9369
+ move.y += boundsBottom - bottom;
9370
+ }
9371
+ else {
9372
+ if (x < dragBounds.x)
9373
+ move.x += dragBounds.x - x;
9374
+ else if (right > boundsRight)
9375
+ move.x += boundsRight - right;
9376
+ if (y < dragBounds.y)
9377
+ move.y += dragBounds.y - y;
9378
+ else if (bottom > boundsBottom)
9379
+ move.y += boundsBottom - bottom;
9380
+ }
9381
+ return move;
9382
+ }
9383
+ getPageMove(total) {
9384
+ this.assignMove(total);
9385
+ return this.current.getPagePoint(tempMove, null, true);
9386
+ }
9387
+ getInnerMove(relative, total) {
9388
+ if (!relative)
9389
+ relative = this.current;
9390
+ this.assignMove(total);
9391
+ return relative.getInnerPoint(tempMove, null, true);
9392
+ }
9393
+ getLocalMove(relative, total) {
9394
+ if (!relative)
9395
+ relative = this.current;
9396
+ this.assignMove(total);
9397
+ return relative.getLocalPoint(tempMove, null, true);
9398
+ }
9399
+ getPageTotal() {
9400
+ return this.getPageMove(true);
9401
+ }
9402
+ getInnerTotal(relative) {
9403
+ return this.getInnerMove(relative, true);
9404
+ }
9405
+ getLocalTotal(relative) {
9406
+ return this.getLocalMove(relative, true);
9407
+ }
9408
+ getPageBounds() {
9409
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9410
+ BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9411
+ BoundsHelper.unsign(bounds);
9412
+ return bounds;
9413
+ }
9414
+ assignMove(total) {
9415
+ tempMove.x = total ? this.totalX : this.moveX;
9416
+ tempMove.y = total ? this.totalY : this.moveY;
9417
+ }
9418
+ };
9419
+ DragEvent.BEFORE_DRAG = 'drag.before_drag';
9420
+ DragEvent.START = 'drag.start';
9421
+ DragEvent.DRAG = 'drag';
9422
+ DragEvent.END = 'drag.end';
9423
+ DragEvent.OVER = 'drag.over';
9424
+ DragEvent.OUT = 'drag.out';
9425
+ DragEvent.ENTER = 'drag.enter';
9426
+ DragEvent.LEAVE = 'drag.leave';
9427
+ DragEvent = __decorate([
9428
+ registerUIEvent()
9429
+ ], DragEvent);
9430
+
9431
+ let DropEvent = class DropEvent extends PointerEvent {
9432
+ static setList(data) {
9433
+ DragEvent.setList(data);
9434
+ }
9435
+ static setData(data) {
9436
+ DragEvent.setData(data);
9437
+ }
9438
+ };
9439
+ DropEvent.DROP = 'drop';
9440
+ DropEvent = __decorate([
9441
+ registerUIEvent()
9442
+ ], DropEvent);
9443
+
9444
+ let MoveEvent = class MoveEvent extends DragEvent {
9445
+ };
9446
+ MoveEvent.BEFORE_MOVE = 'move.before_move';
9447
+ MoveEvent.START = 'move.start';
9448
+ MoveEvent.MOVE = 'move';
9449
+ MoveEvent.END = 'move.end';
9450
+ MoveEvent = __decorate([
9451
+ registerUIEvent()
9452
+ ], MoveEvent);
9453
+
9454
+ let RotateEvent = class RotateEvent extends PointerEvent {
9455
+ };
9456
+ RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9457
+ RotateEvent.START = 'rotate.start';
9458
+ RotateEvent.ROTATE = 'rotate';
9459
+ RotateEvent.END = 'rotate.end';
9460
+ RotateEvent = __decorate([
9461
+ registerUIEvent()
9462
+ ], RotateEvent);
9463
+
9464
+ let SwipeEvent = class SwipeEvent extends DragEvent {
9465
+ };
9466
+ SwipeEvent.SWIPE = 'swipe';
9467
+ SwipeEvent.LEFT = 'swipe.left';
9468
+ SwipeEvent.RIGHT = 'swipe.right';
9469
+ SwipeEvent.UP = 'swipe.up';
9470
+ SwipeEvent.DOWN = 'swipe.down';
9471
+ SwipeEvent = __decorate([
9472
+ registerUIEvent()
9473
+ ], SwipeEvent);
9474
+
9475
+ let ZoomEvent = class ZoomEvent extends PointerEvent {
9476
+ };
9477
+ ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9478
+ ZoomEvent.START = 'zoom.start';
9479
+ ZoomEvent.ZOOM = 'zoom';
9480
+ ZoomEvent.END = 'zoom.end';
9481
+ ZoomEvent = __decorate([
9482
+ registerUIEvent()
9483
+ ], ZoomEvent);
9484
+
9485
+ let KeyEvent = class KeyEvent extends UIEvent {
9486
+ };
9487
+ KeyEvent.DOWN = 'key.down';
9488
+ KeyEvent.HOLD = 'key.hold';
9489
+ KeyEvent.UP = 'key.up';
9490
+ KeyEvent = __decorate([
9491
+ registerUIEvent()
9492
+ ], KeyEvent);
9493
+
9494
+ new LeafList();
9495
+
9496
+ Debug.get('emit');
9497
+
9498
+ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9499
+ const inner = {};
9500
+ const leaf = Leaf.prototype;
9501
+ leaf.__hitWorld = function (point) {
9502
+ const data = this.__;
9503
+ if (!data.hitSelf)
9504
+ return false;
9505
+ const world = this.__world, layout = this.__layout;
9506
+ const isSmall = world.width < 10 && world.height < 10;
9507
+ if (data.hitRadius) {
9508
+ copy$2(inner, point), point = inner;
9509
+ setRadius(point, data.hitRadius);
9510
+ }
9511
+ toInnerRadiusPointOf(point, world, inner);
9512
+ if (data.hitBox || isSmall) {
9513
+ if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
9514
+ return true;
9515
+ if (isSmall)
9516
+ return false;
9517
+ }
9518
+ if (layout.hitCanvasChanged || !this.__hitCanvas) {
9519
+ this.__updateHitCanvas();
9520
+ if (!layout.boundsChanged)
9521
+ layout.hitCanvasChanged = false;
9522
+ }
9523
+ return this.__hit(inner);
9524
+ };
9525
+ leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
9526
+ leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
9527
+ leaf.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
9528
+ leaf.__drawHitPath = function (canvas) { if (canvas)
9529
+ this.__drawRenderPath(canvas); };
9530
+
9531
+ const matrix = new Matrix();
9532
+ const ui$1 = UI.prototype;
9533
+ ui$1.__updateHitCanvas = function () {
9534
+ if (this.__box)
9535
+ this.__box.__updateHitCanvas();
9536
+ const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
9537
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
9538
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
9539
+ const isHitPixel = isHitPixelFill || isHitPixelStroke;
9540
+ if (!this.__hitCanvas)
9541
+ this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
9542
+ const h = this.__hitCanvas;
9543
+ if (isHitPixel) {
9544
+ const { renderBounds } = this.__layout;
9545
+ const size = Platform.image.hitCanvasSize;
9546
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
9547
+ const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
9548
+ h.resize({ width, height, pixelRatio: 1 });
9549
+ h.clear();
9550
+ ImageManager.patternLocked = true;
9551
+ this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
9552
+ ImageManager.patternLocked = false;
9553
+ h.resetTransform();
9554
+ data.__isHitPixel = true;
9555
+ }
9556
+ else {
9557
+ data.__isHitPixel && (data.__isHitPixel = false);
9558
+ }
9559
+ this.__drawHitPath(h);
9560
+ h.setStrokeOptions(data);
9561
+ };
9562
+ ui$1.__hit = function (inner) {
9563
+ if (this.__box && this.__box.__hit(inner))
9564
+ return true;
9565
+ const data = this.__;
9566
+ if (data.__isHitPixel && this.__hitPixel(inner))
9567
+ return true;
9568
+ const { hitFill } = data;
9569
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
9570
+ if (needHitFillPath && this.__hitFill(inner))
9571
+ return true;
9572
+ const { hitStroke, __strokeWidth } = data;
9573
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
9574
+ if (!needHitFillPath && !needHitStrokePath)
9575
+ return false;
9576
+ const radiusWidth = inner.radiusX * 2;
9577
+ let hitWidth = radiusWidth;
9578
+ if (needHitStrokePath) {
9579
+ switch (data.strokeAlign) {
9580
+ case 'inside':
9581
+ hitWidth += __strokeWidth * 2;
9582
+ if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
9583
+ return true;
9584
+ hitWidth = radiusWidth;
9585
+ break;
9586
+ case 'center':
9587
+ hitWidth += __strokeWidth;
9588
+ break;
9589
+ case 'outside':
9590
+ hitWidth += __strokeWidth * 2;
9591
+ if (!needHitFillPath) {
9592
+ if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
9593
+ return true;
9594
+ hitWidth = radiusWidth;
9595
+ }
9596
+ break;
9597
+ }
9598
+ }
9599
+ return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9600
+ };
9601
+
9602
+ const ui = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
9603
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
9604
+ if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
9605
+ ui.__updateHitCanvas.call(this);
9606
+ else if (this.__hitCanvas)
9607
+ this.__hitCanvas = null;
9608
+ };
9609
+ rect.__hitFill = box$1.__hitFill = function (inner) {
9610
+ return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9611
+ };
9612
+
9613
+ Text.prototype.__drawHitPath = function (canvas) {
9614
+ const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
9615
+ canvas.beginPath();
9616
+ if (__letterSpacing < 0)
9617
+ this.__drawPathByBox(canvas);
9618
+ else
9619
+ data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
9620
+ };
9621
+
9622
+ function getSelector(ui) {
9623
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
9624
+ }
9625
+ Group.prototype.pick = function (hitPoint, options) {
9626
+ options || (options = emptyData);
9627
+ this.updateLayout();
9628
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
9629
+ };
9630
+
9631
+ const canvas = LeaferCanvasBase.prototype;
9632
+ canvas.hitFill = function (point, fillRule) {
9633
+ return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
9634
+ };
9635
+ canvas.hitStroke = function (point, strokeWidth) {
9636
+ this.strokeWidth = strokeWidth;
9637
+ return this.context.isPointInStroke(point.x, point.y);
9638
+ };
9639
+ canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
9640
+ let { x, y, radiusX, radiusY } = radiusPoint;
9641
+ if (offset)
9642
+ x -= offset.x, y -= offset.y;
9643
+ tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
9644
+ const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
9645
+ for (let i = 0, len = data.length; i < len; i += 4) {
9646
+ if (data[i + 3] > 0)
9647
+ return true;
9648
+ }
9649
+ return data[3] > 0;
9650
+ };
9651
+
9001
9652
  function strokeText(stroke, ui, canvas) {
9002
- const { strokeAlign } = ui.__;
9003
- const isStrokes = typeof stroke !== 'string';
9004
- switch (strokeAlign) {
9653
+ switch (ui.__.strokeAlign) {
9005
9654
  case 'center':
9006
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
9007
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9655
+ drawCenter$1(stroke, 1, ui, canvas);
9008
9656
  break;
9009
9657
  case 'inside':
9010
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
9658
+ drawAlign(stroke, 'inside', ui, canvas);
9011
9659
  break;
9012
9660
  case 'outside':
9013
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
9661
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
9014
9662
  break;
9015
9663
  }
9016
9664
  }
9017
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
9018
- const { __strokeWidth, __font } = ui.__;
9665
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
9666
+ const data = ui.__;
9667
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
9668
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9669
+ }
9670
+ function drawAlign(stroke, align, ui, canvas) {
9019
9671
  const out = canvas.getSameCanvas(true, true);
9020
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
9021
- out.font = __font;
9022
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
9672
+ out.font = ui.__.__font;
9673
+ drawCenter$1(stroke, 2, ui, out);
9023
9674
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9024
9675
  fillText(ui, out);
9025
9676
  out.blendMode = 'normal';
9026
- if (ui.__worldFlipped)
9677
+ if (ui.__worldFlipped || Platform.fullImageShadow)
9027
9678
  canvas.copyWorldByReset(out, ui.__nowWorld);
9028
9679
  else
9029
9680
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -9065,90 +9716,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
9065
9716
  }
9066
9717
 
9067
9718
  function stroke(stroke, ui, canvas) {
9068
- const options = ui.__;
9069
- const { __strokeWidth, strokeAlign, __font } = options;
9070
- if (!__strokeWidth)
9719
+ const data = ui.__;
9720
+ if (!data.__strokeWidth)
9071
9721
  return;
9072
- if (__font) {
9722
+ if (data.__font) {
9073
9723
  strokeText(stroke, ui, canvas);
9074
9724
  }
9075
9725
  else {
9076
- switch (strokeAlign) {
9726
+ switch (data.strokeAlign) {
9077
9727
  case 'center':
9078
- canvas.setStroke(stroke, __strokeWidth, options);
9079
- canvas.stroke();
9080
- if (options.__useArrow)
9081
- strokeArrow(ui, canvas);
9728
+ drawCenter(stroke, 1, ui, canvas);
9082
9729
  break;
9083
9730
  case 'inside':
9084
- canvas.save();
9085
- canvas.setStroke(stroke, __strokeWidth * 2, options);
9086
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9087
- canvas.stroke();
9088
- canvas.restore();
9731
+ drawInside(stroke, ui, canvas);
9089
9732
  break;
9090
9733
  case 'outside':
9091
- const out = canvas.getSameCanvas(true, true);
9092
- out.setStroke(stroke, __strokeWidth * 2, options);
9093
- ui.__drawRenderPath(out);
9094
- out.stroke();
9095
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9096
- out.clearWorld(ui.__layout.renderBounds);
9097
- if (ui.__worldFlipped)
9098
- canvas.copyWorldByReset(out, ui.__nowWorld);
9099
- else
9100
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9101
- out.recycle(ui.__nowWorld);
9734
+ drawOutside(stroke, ui, canvas);
9102
9735
  break;
9103
9736
  }
9104
9737
  }
9105
9738
  }
9106
9739
  function strokes(strokes, ui, canvas) {
9107
- const options = ui.__;
9108
- const { __strokeWidth, strokeAlign, __font } = options;
9109
- if (!__strokeWidth)
9110
- return;
9111
- if (__font) {
9112
- strokeText(strokes, ui, canvas);
9740
+ stroke(strokes, ui, canvas);
9741
+ }
9742
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
9743
+ const data = ui.__;
9744
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
9745
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
9746
+ if (data.__useArrow)
9747
+ Paint.strokeArrow(stroke, ui, canvas);
9748
+ }
9749
+ function drawInside(stroke, ui, canvas) {
9750
+ const data = ui.__;
9751
+ canvas.save();
9752
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
9753
+ drawCenter(stroke, 2, ui, canvas);
9754
+ canvas.restore();
9755
+ }
9756
+ function drawOutside(stroke, ui, canvas) {
9757
+ const data = ui.__;
9758
+ if (data.__fillAfterStroke) {
9759
+ drawCenter(stroke, 2, ui, canvas);
9113
9760
  }
9114
9761
  else {
9115
- switch (strokeAlign) {
9116
- case 'center':
9117
- canvas.setStroke(undefined, __strokeWidth, options);
9118
- drawStrokesStyle(strokes, false, ui, canvas);
9119
- if (options.__useArrow)
9120
- strokeArrow(ui, canvas);
9121
- break;
9122
- case 'inside':
9123
- canvas.save();
9124
- canvas.setStroke(undefined, __strokeWidth * 2, options);
9125
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9126
- drawStrokesStyle(strokes, false, ui, canvas);
9127
- canvas.restore();
9128
- break;
9129
- case 'outside':
9130
- const { renderBounds } = ui.__layout;
9131
- const out = canvas.getSameCanvas(true, true);
9132
- ui.__drawRenderPath(out);
9133
- out.setStroke(undefined, __strokeWidth * 2, options);
9134
- drawStrokesStyle(strokes, false, ui, out);
9135
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9136
- out.clearWorld(renderBounds);
9137
- if (ui.__worldFlipped)
9138
- canvas.copyWorldByReset(out, ui.__nowWorld);
9139
- else
9140
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
9141
- out.recycle(ui.__nowWorld);
9142
- break;
9143
- }
9144
- }
9145
- }
9146
- function strokeArrow(ui, canvas) {
9147
- if (ui.__.dashPattern) {
9148
- canvas.beginPath();
9149
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
9150
- canvas.dashPattern = null;
9151
- canvas.stroke();
9762
+ const { renderBounds } = ui.__layout;
9763
+ const out = canvas.getSameCanvas(true, true);
9764
+ ui.__drawRenderPath(out);
9765
+ drawCenter(stroke, 2, ui, out);
9766
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
9767
+ out.clearWorld(renderBounds);
9768
+ if (ui.__worldFlipped || Platform.fullImageShadow)
9769
+ canvas.copyWorldByReset(out, ui.__nowWorld);
9770
+ else
9771
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
9772
+ out.recycle(ui.__nowWorld);
9152
9773
  }
9153
9774
  }
9154
9775
 
@@ -9195,9 +9816,10 @@ function shape(ui, current, options) {
9195
9816
  }
9196
9817
 
9197
9818
  let recycleMap;
9819
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
9198
9820
  function compute(attrName, ui) {
9199
9821
  const data = ui.__, leafPaints = [];
9200
- let paints = data.__input[attrName], hasOpacityPixel;
9822
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
9201
9823
  if (!(paints instanceof Array))
9202
9824
  paints = [paints];
9203
9825
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -9207,29 +9829,55 @@ function compute(attrName, ui) {
9207
9829
  leafPaints.push(item);
9208
9830
  }
9209
9831
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
9210
- if (leafPaints.length && leafPaints[0].image)
9211
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
9212
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
9832
+ if (leafPaints.length) {
9833
+ if (leafPaints.every(item => item.isTransparent)) {
9834
+ if (leafPaints.some(item => item.image))
9835
+ isAlphaPixel = true;
9836
+ isTransparent = true;
9837
+ }
9838
+ }
9839
+ if (attrName === 'fill') {
9840
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
9841
+ stintSet(data, '__isTransparentFill', isTransparent);
9842
+ }
9843
+ else {
9844
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
9845
+ stintSet(data, '__isTransparentStroke', isTransparent);
9846
+ }
9213
9847
  }
9214
9848
  function getLeafPaint(attrName, paint, ui) {
9215
9849
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
9216
9850
  return undefined;
9851
+ let data;
9217
9852
  const { boxBounds } = ui.__layout;
9218
9853
  switch (paint.type) {
9219
- case 'solid':
9220
- let { type, blendMode, color, opacity } = paint;
9221
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
9222
9854
  case 'image':
9223
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9855
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9856
+ break;
9224
9857
  case 'linear':
9225
- return PaintGradient.linearGradient(paint, boxBounds);
9858
+ data = PaintGradient.linearGradient(paint, boxBounds);
9859
+ break;
9226
9860
  case 'radial':
9227
- return PaintGradient.radialGradient(paint, boxBounds);
9861
+ data = PaintGradient.radialGradient(paint, boxBounds);
9862
+ break;
9228
9863
  case 'angular':
9229
- return PaintGradient.conicGradient(paint, boxBounds);
9864
+ data = PaintGradient.conicGradient(paint, boxBounds);
9865
+ break;
9866
+ case 'solid':
9867
+ const { type, blendMode, color, opacity } = paint;
9868
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
9869
+ break;
9230
9870
  default:
9231
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
9871
+ if (paint.r !== undefined)
9872
+ data = { type: 'solid', style: ColorConvert.string(paint) };
9873
+ }
9874
+ if (data) {
9875
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
9876
+ data.isTransparent = true;
9877
+ if (paint.blendMode)
9878
+ data.blendMode = paint.blendMode;
9232
9879
  }
9880
+ return data;
9233
9881
  }
9234
9882
 
9235
9883
  const PaintModule = {
@@ -9295,12 +9943,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
9295
9943
 
9296
9944
  const { get: get$2, translate } = MatrixHelper;
9297
9945
  const tempBox = new Bounds();
9298
- const tempPoint = {};
9299
9946
  const tempScaleData = {};
9947
+ const tempImage = {};
9300
9948
  function createData(leafPaint, image, paint, box) {
9301
- const { blendMode, changeful, sync } = paint;
9302
- if (blendMode)
9303
- leafPaint.blendMode = blendMode;
9949
+ const { changeful, sync } = paint;
9304
9950
  if (changeful)
9305
9951
  leafPaint.changeful = changeful;
9306
9952
  if (sync)
@@ -9308,38 +9954,38 @@ function createData(leafPaint, image, paint, box) {
9308
9954
  leafPaint.data = getPatternData(paint, box, image);
9309
9955
  }
9310
9956
  function getPatternData(paint, box, image) {
9311
- let { width, height } = image;
9312
9957
  if (paint.padding)
9313
9958
  box = tempBox.set(box).shrink(paint.padding);
9314
9959
  if (paint.mode === 'strench')
9315
9960
  paint.mode = 'stretch';
9961
+ let { width, height } = image;
9316
9962
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
9317
9963
  const sameBox = box.width === width && box.height === height;
9318
9964
  const data = { mode };
9319
9965
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
9320
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
9321
- let x = 0, y = 0, scaleX, scaleY;
9966
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
9967
+ let scaleX, scaleY;
9322
9968
  if (!mode || mode === 'cover' || mode === 'fit') {
9323
9969
  if (!sameBox || rotation) {
9324
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
9325
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
9326
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
9970
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
9971
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
9972
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9327
9973
  }
9328
9974
  }
9329
- else if (scale || size) {
9330
- MathHelper.getScaleData(scale, size, image, tempScaleData);
9331
- scaleX = tempScaleData.scaleX;
9332
- scaleY = tempScaleData.scaleY;
9333
- }
9334
- if (align) {
9335
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
9336
- if (scaleX)
9337
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
9338
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
9339
- x += tempPoint.x, y += tempPoint.y;
9975
+ else {
9976
+ if (scale || size) {
9977
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
9978
+ scaleX = tempScaleData.scaleX;
9979
+ scaleY = tempScaleData.scaleY;
9980
+ }
9981
+ if (align) {
9982
+ if (scaleX)
9983
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9984
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
9985
+ }
9340
9986
  }
9341
9987
  if (offset)
9342
- x += offset.x, y += offset.y;
9988
+ PointHelper.move(tempImage, offset);
9343
9989
  switch (mode) {
9344
9990
  case 'stretch':
9345
9991
  if (!sameBox)
@@ -9347,12 +9993,12 @@ function getPatternData(paint, box, image) {
9347
9993
  break;
9348
9994
  case 'normal':
9349
9995
  case 'clip':
9350
- if (x || y || scaleX || rotation)
9351
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
9996
+ if (tempImage.x || tempImage.y || scaleX || rotation)
9997
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9352
9998
  break;
9353
9999
  case 'repeat':
9354
10000
  if (!sameBox || scaleX || rotation)
9355
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10001
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
9356
10002
  if (!repeat)
9357
10003
  data.repeat = 'repeat';
9358
10004
  break;
@@ -9360,7 +10006,7 @@ function getPatternData(paint, box, image) {
9360
10006
  case 'cover':
9361
10007
  default:
9362
10008
  if (scaleX)
9363
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10009
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9364
10010
  }
9365
10011
  if (!data.transform) {
9366
10012
  if (box.x || box.y) {
@@ -9393,6 +10039,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9393
10039
  }
9394
10040
  else {
9395
10041
  leafPaint = { type: paint.type, image };
10042
+ if (image.hasAlphaPixel)
10043
+ leafPaint.isTransparent = true;
9396
10044
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
9397
10045
  }
9398
10046
  if (firstUse || image.loading)
@@ -9417,7 +10065,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9417
10065
  ignoreRender(ui, false);
9418
10066
  if (!ui.destroyed) {
9419
10067
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
9420
- if (image.hasOpacityPixel)
10068
+ if (image.hasAlphaPixel)
9421
10069
  ui.__layout.hitCanvasChanged = true;
9422
10070
  ui.forceUpdate('surface');
9423
10071
  }
@@ -9429,13 +10077,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9429
10077
  onLoadError(ui, event, error);
9430
10078
  leafPaint.loadId = null;
9431
10079
  });
9432
- if (ui.placeholderColor)
9433
- setTimeout(() => {
9434
- if (!(image.ready || image.isPlacehold)) {
9435
- image.isPlacehold = true;
9436
- ui.forceUpdate('surface');
9437
- }
9438
- }, 100);
10080
+ if (ui.placeholderColor) {
10081
+ if (!ui.placeholderDelay)
10082
+ image.isPlacehold = true;
10083
+ else
10084
+ setTimeout(() => {
10085
+ if (!image.ready) {
10086
+ image.isPlacehold = true;
10087
+ ui.forceUpdate('surface');
10088
+ }
10089
+ }, ui.placeholderDelay);
10090
+ }
9439
10091
  }
9440
10092
  return leafPaint;
9441
10093
  }
@@ -9641,32 +10293,33 @@ const PaintImageModule = {
9641
10293
  repeatMode
9642
10294
  };
9643
10295
 
9644
- const { toPoint: toPoint$2 } = AroundHelper;
10296
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
9645
10297
  const realFrom$2 = {};
9646
10298
  const realTo$2 = {};
9647
10299
  function linearGradient(paint, box) {
9648
- let { from, to, type, blendMode, opacity } = paint;
10300
+ let { from, to, type, opacity } = paint;
9649
10301
  toPoint$2(from || 'top', box, realFrom$2);
9650
10302
  toPoint$2(to || 'bottom', box, realTo$2);
9651
10303
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
9652
- applyStops(style, paint.stops, opacity);
9653
10304
  const data = { type, style };
9654
- if (blendMode)
9655
- data.blendMode = blendMode;
10305
+ applyStops(data, style, paint.stops, opacity);
9656
10306
  return data;
9657
10307
  }
9658
- function applyStops(gradient, stops, opacity) {
10308
+ function applyStops(data, gradient, stops, opacity) {
9659
10309
  if (stops) {
9660
- let stop;
10310
+ let stop, color, offset, isTransparent;
9661
10311
  for (let i = 0, len = stops.length; i < len; i++) {
9662
10312
  stop = stops[i];
9663
- if (typeof stop === 'string') {
9664
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
9665
- }
9666
- else {
9667
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
9668
- }
10313
+ if (typeof stop === 'string')
10314
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
10315
+ else
10316
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
10317
+ gradient.addColorStop(offset, color);
10318
+ if (!isTransparent && hasTransparent(color))
10319
+ isTransparent = true;
9669
10320
  }
10321
+ if (isTransparent)
10322
+ data.isTransparent = true;
9670
10323
  }
9671
10324
  }
9672
10325
 
@@ -9676,17 +10329,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
9676
10329
  const realFrom$1 = {};
9677
10330
  const realTo$1 = {};
9678
10331
  function radialGradient(paint, box) {
9679
- let { from, to, type, opacity, blendMode, stretch } = paint;
10332
+ let { from, to, type, opacity, stretch } = paint;
9680
10333
  toPoint$1(from || 'center', box, realFrom$1);
9681
10334
  toPoint$1(to || 'bottom', box, realTo$1);
9682
10335
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
9683
- applyStops(style, paint.stops, opacity);
9684
10336
  const data = { type, style };
10337
+ applyStops(data, style, paint.stops, opacity);
9685
10338
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
9686
10339
  if (transform)
9687
10340
  data.transform = transform;
9688
- if (blendMode)
9689
- data.blendMode = blendMode;
9690
10341
  return data;
9691
10342
  }
9692
10343
  function getTransform(box, from, to, stretch, rotate90) {
@@ -9712,17 +10363,15 @@ const { toPoint } = AroundHelper;
9712
10363
  const realFrom = {};
9713
10364
  const realTo = {};
9714
10365
  function conicGradient(paint, box) {
9715
- let { from, to, type, opacity, blendMode, stretch } = paint;
10366
+ let { from, to, type, opacity, stretch } = paint;
9716
10367
  toPoint(from || 'center', box, realFrom);
9717
10368
  toPoint(to || 'bottom', box, realTo);
9718
10369
  const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
9719
- applyStops(style, paint.stops, opacity);
9720
10370
  const data = { type, style };
10371
+ applyStops(data, style, paint.stops, opacity);
9721
10372
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
9722
10373
  if (transform)
9723
10374
  data.transform = transform;
9724
- if (blendMode)
9725
- data.blendMode = blendMode;
9726
10375
  return data;
9727
10376
  }
9728
10377
 
@@ -10055,6 +10704,8 @@ function createRows(drawData, content, style) {
10055
10704
  lastCharType = null;
10056
10705
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
10057
10706
  word = { data: [] }, row = { words: [] };
10707
+ if (__letterSpacing)
10708
+ content = [...content];
10058
10709
  for (let i = 0, len = content.length; i < len; i++) {
10059
10710
  char = content[i];
10060
10711
  if (char === '\n') {
@@ -10472,4 +11123,4 @@ try {
10472
11123
  }
10473
11124
  catch (_a) { }
10474
11125
 
10475
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
11126
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };