leafer-ui 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)
@@ -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;
@@ -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);
@@ -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$f = 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;
@@ -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) {
@@ -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$a = 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$1.isFormat(item, config));
3759
+ hasAlphaPixel(config) {
3760
+ return FileHelper.alphaPixelTypes.some(item => I$1.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) {
@@ -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,7 +4567,7 @@ const WaitHelper = {
4541
4567
  }
4542
4568
  };
4543
4569
 
4544
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4570
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
4545
4571
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = BoundsHelper;
4546
4572
  const localContent = '_localContentBounds';
4547
4573
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -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
  }
@@ -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,19 +5264,19 @@ 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
 
@@ -5205,11 +5286,17 @@ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } =
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)
@@ -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
  const debug$5 = Debug.get('LeaferCanvas');
6148
6236
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6482,17 +6570,15 @@ class Watcher {
6482
6570
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6483
6571
  this.__updatedList = new LeafList();
6484
6572
  this.totalTimes++;
6485
- this.changed = false;
6486
- this.hasVisible = false;
6487
- this.hasRemove = false;
6488
- this.hasAdd = false;
6573
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6489
6574
  }
6490
6575
  __listenEvents() {
6491
- const { target } = this;
6492
6576
  this.__eventIds = [
6493
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6494
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6495
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6577
+ this.target.on_([
6578
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6579
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6580
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6581
+ ])
6496
6582
  ];
6497
6583
  }
6498
6584
  __removeListenEvents() {
@@ -6502,8 +6588,7 @@ class Watcher {
6502
6588
  if (this.target) {
6503
6589
  this.stop();
6504
6590
  this.__removeListenEvents();
6505
- this.target = null;
6506
- this.__updatedList = null;
6591
+ this.target = this.__updatedList = null;
6507
6592
  }
6508
6593
  }
6509
6594
  }
@@ -6608,7 +6693,7 @@ class Layouter {
6608
6693
  this.disabled = true;
6609
6694
  }
6610
6695
  layout() {
6611
- if (!this.running)
6696
+ if (this.layouting || !this.running)
6612
6697
  return;
6613
6698
  const { target } = this;
6614
6699
  this.times = 0;
@@ -6691,12 +6776,10 @@ class Layouter {
6691
6776
  }
6692
6777
  static fullLayout(target) {
6693
6778
  updateAllMatrix(target, true);
6694
- if (target.isBranch) {
6779
+ if (target.isBranch)
6695
6780
  BranchHelper.updateBounds(target);
6696
- }
6697
- else {
6781
+ else
6698
6782
  LeafHelper.updateBounds(target);
6699
- }
6700
6783
  updateAllChange(target);
6701
6784
  }
6702
6785
  addExtra(leaf) {
@@ -6719,11 +6802,12 @@ class Layouter {
6719
6802
  this.__updatedList = event.data.updatedList;
6720
6803
  }
6721
6804
  __listenEvents() {
6722
- const { target } = this;
6723
6805
  this.__eventIds = [
6724
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6725
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6726
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6806
+ this.target.on_([
6807
+ [LayoutEvent.REQUEST, this.layout, this],
6808
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6809
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6810
+ ])
6727
6811
  ];
6728
6812
  }
6729
6813
  __removeListenEvents() {
@@ -6954,12 +7038,13 @@ class Renderer {
6954
7038
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6955
7039
  }
6956
7040
  __listenEvents() {
6957
- const { target } = this;
6958
7041
  this.__eventIds = [
6959
- target.on_(RenderEvent.REQUEST, this.update, this),
6960
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6961
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6962
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7042
+ this.target.on_([
7043
+ [RenderEvent.REQUEST, this.update, this],
7044
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7045
+ [RenderEvent.AGAIN, this.renderAgain, this],
7046
+ [ResizeEvent.RESIZE, this.__onResize, this]
7047
+ ])
6963
7048
  ];
6964
7049
  }
6965
7050
  __removeListenEvents() {
@@ -7175,8 +7260,32 @@ function zoomLayerType() {
7175
7260
  };
7176
7261
  }
7177
7262
 
7263
+ function hasTransparent$3(color) {
7264
+ if (!color || color.length === 7 || color.length === 4)
7265
+ return false;
7266
+ if (color === 'transparent')
7267
+ return true;
7268
+ const first = color[0];
7269
+ if (first === '#') {
7270
+ switch (color.length) {
7271
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7272
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7273
+ }
7274
+ }
7275
+ else if (first === 'r' || first === 'h') {
7276
+ if (color[3] === 'a') {
7277
+ const i = color.lastIndexOf(',');
7278
+ if (i > -1)
7279
+ return parseFloat(color.slice(i + 1)) < 1;
7280
+ }
7281
+ }
7282
+ return false;
7283
+ }
7284
+
7178
7285
  const TextConvert = {};
7179
- const ColorConvert = {};
7286
+ const ColorConvert = {
7287
+ hasTransparent: hasTransparent$3
7288
+ };
7180
7289
  const UnitConvert = {
7181
7290
  number(value, percentRefer) {
7182
7291
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7202,6 +7311,7 @@ const Transition = {
7202
7311
  };
7203
7312
 
7204
7313
  const { parse, objectToCanvasData } = PathConvert;
7314
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7205
7315
  const emptyPaint = {};
7206
7316
  const debug$2 = Debug.get('UIData');
7207
7317
  class UIData extends LeafData {
@@ -7260,38 +7370,22 @@ class UIData extends LeafData {
7260
7370
  if (this.__naturalWidth)
7261
7371
  this.__removeNaturalSize();
7262
7372
  if (typeof value === 'string' || !value) {
7263
- if (this.__isFills) {
7264
- this.__removeInput('fill');
7265
- PaintImage.recycleImage('fill', this);
7266
- this.__isFills = false;
7267
- this.__pixelFill && (this.__pixelFill = false);
7268
- }
7373
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7374
+ this.__isFills && this.__removePaint('fill', true);
7269
7375
  this._fill = value;
7270
7376
  }
7271
7377
  else if (typeof value === 'object') {
7272
- this.__setInput('fill', value);
7273
- const layout = this.__leaf.__layout;
7274
- layout.boxChanged || layout.boxChange();
7275
- this.__isFills = true;
7276
- this._fill || (this._fill = emptyPaint);
7378
+ this.__setPaint('fill', value);
7277
7379
  }
7278
7380
  }
7279
7381
  setStroke(value) {
7280
7382
  if (typeof value === 'string' || !value) {
7281
- if (this.__isStrokes) {
7282
- this.__removeInput('stroke');
7283
- PaintImage.recycleImage('stroke', this);
7284
- this.__isStrokes = false;
7285
- this.__pixelStroke && (this.__pixelStroke = false);
7286
- }
7383
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7384
+ this.__isStrokes && this.__removePaint('stroke', true);
7287
7385
  this._stroke = value;
7288
7386
  }
7289
7387
  else if (typeof value === 'object') {
7290
- this.__setInput('stroke', value);
7291
- const layout = this.__leaf.__layout;
7292
- layout.boxChanged || layout.boxChange();
7293
- this.__isStrokes = true;
7294
- this._stroke || (this._stroke = emptyPaint);
7388
+ this.__setPaint('stroke', value);
7295
7389
  }
7296
7390
  }
7297
7391
  setPath(value) {
@@ -7321,7 +7415,34 @@ class UIData extends LeafData {
7321
7415
  Paint.compute('fill', this.__leaf);
7322
7416
  if (stroke)
7323
7417
  Paint.compute('stroke', this.__leaf);
7324
- this.__needComputePaint = false;
7418
+ this.__needComputePaint = undefined;
7419
+ }
7420
+ __setPaint(attrName, value) {
7421
+ this.__setInput(attrName, value);
7422
+ const layout = this.__leaf.__layout;
7423
+ layout.boxChanged || layout.boxChange();
7424
+ if (value instanceof Array && !value.length) {
7425
+ this.__removePaint(attrName);
7426
+ }
7427
+ else {
7428
+ if (attrName === 'fill')
7429
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7430
+ else
7431
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7432
+ }
7433
+ }
7434
+ __removePaint(attrName, removeInput) {
7435
+ if (removeInput)
7436
+ this.__removeInput(attrName);
7437
+ PaintImage.recycleImage(attrName, this);
7438
+ if (attrName === 'fill') {
7439
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7440
+ this._fill = this.__isFills = undefined;
7441
+ }
7442
+ else {
7443
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7444
+ this._stroke = this.__isStrokes = undefined;
7445
+ }
7325
7446
  }
7326
7447
  }
7327
7448
  function setArray(data, key, value) {
@@ -7329,10 +7450,10 @@ function setArray(data, key, value) {
7329
7450
  if (value instanceof Array) {
7330
7451
  if (value.some((item) => item.visible === false))
7331
7452
  value = value.filter((item) => item.visible !== false);
7332
- value.length || (value = null);
7453
+ value.length || (value = undefined);
7333
7454
  }
7334
7455
  else
7335
- value = value && value.visible !== false ? [value] : null;
7456
+ value = value && value.visible !== false ? [value] : undefined;
7336
7457
  data['_' + key] = value;
7337
7458
  }
7338
7459
 
@@ -7435,8 +7556,6 @@ class ImageData extends RectData {
7435
7556
  this._url = value;
7436
7557
  }
7437
7558
  __setImageFill(value) {
7438
- if (this.__leaf.image)
7439
- this.__leaf.image = null;
7440
7559
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7441
7560
  }
7442
7561
  __getData() {
@@ -7502,21 +7621,19 @@ const UIBounds = {
7502
7621
  }
7503
7622
  };
7504
7623
 
7624
+ const { stintSet: stintSet$1 } = DataHelper;
7505
7625
  const UIRender = {
7506
7626
  __updateChange() {
7507
- const data = this.__, w = this.__world;
7627
+ const data = this.__;
7508
7628
  if (data.__useEffect) {
7509
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7510
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7629
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7630
+ 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')));
7631
+ data.__useEffect = !!(shadow || otherEffect);
7511
7632
  }
7512
- const half = data.__hasHalf;
7513
- w.half !== half && (w.half = half);
7633
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7634
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7514
7635
  data.__checkSingle();
7515
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7516
- if (complex)
7517
- data.__complex = true;
7518
- else
7519
- data.__complex && (data.__complex = false);
7636
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7520
7637
  },
7521
7638
  __drawFast(canvas, options) {
7522
7639
  drawFast(this, canvas, options);
@@ -7526,21 +7643,23 @@ const UIRender = {
7526
7643
  if (data.__complex) {
7527
7644
  if (data.__needComputePaint)
7528
7645
  data.__computePaint();
7529
- const { fill, stroke, __drawAfterFill } = data;
7646
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7530
7647
  this.__drawRenderPath(canvas);
7531
- if (data.__useEffect) {
7648
+ if (data.__useEffect && !__isFastShadow) {
7532
7649
  const shape = Paint.shape(this, canvas, options);
7533
7650
  this.__nowWorld = this.__getNowWorld(options);
7534
7651
  const { shadow, innerShadow, filter } = data;
7535
7652
  if (shadow)
7536
7653
  Effect.shadow(this, canvas, shape);
7654
+ if (__fillAfterStroke)
7655
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7537
7656
  if (fill)
7538
7657
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7539
7658
  if (__drawAfterFill)
7540
7659
  this.__drawAfterFill(canvas, options);
7541
7660
  if (innerShadow)
7542
7661
  Effect.innerShadow(this, canvas, shape);
7543
- if (stroke)
7662
+ if (stroke && !__fillAfterStroke)
7544
7663
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7545
7664
  if (filter)
7546
7665
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7549,21 +7668,27 @@ const UIRender = {
7549
7668
  shape.canvas.recycle();
7550
7669
  }
7551
7670
  else {
7671
+ if (__fillAfterStroke)
7672
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7673
+ if (__isFastShadow) {
7674
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7675
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7676
+ }
7552
7677
  if (fill)
7553
7678
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7679
+ if (__isFastShadow)
7680
+ canvas.restore();
7554
7681
  if (__drawAfterFill)
7555
7682
  this.__drawAfterFill(canvas, options);
7556
- if (stroke)
7683
+ if (stroke && !__fillAfterStroke)
7557
7684
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7558
7685
  }
7559
7686
  }
7560
7687
  else {
7561
- if (data.__pathInputed) {
7688
+ if (data.__pathInputed)
7562
7689
  drawFast(this, canvas, options);
7563
- }
7564
- else {
7690
+ else
7565
7691
  this.__drawFast(canvas, options);
7566
- }
7567
7692
  }
7568
7693
  },
7569
7694
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7572,11 +7697,11 @@ const UIRender = {
7572
7697
  const { fill, stroke } = this.__;
7573
7698
  this.__drawRenderPath(canvas);
7574
7699
  if (fill && !ignoreFill)
7575
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7700
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7576
7701
  if (this.__.__isCanvas)
7577
7702
  this.__drawAfterFill(canvas, options);
7578
7703
  if (stroke && !ignoreStroke)
7579
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7704
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7580
7705
  }
7581
7706
  },
7582
7707
  __drawAfterFill(canvas, options) {
@@ -7591,13 +7716,15 @@ const UIRender = {
7591
7716
  }
7592
7717
  };
7593
7718
  function drawFast(ui, canvas, options) {
7594
- const { fill, stroke, __drawAfterFill } = ui.__;
7719
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7595
7720
  ui.__drawRenderPath(canvas);
7721
+ if (__fillAfterStroke)
7722
+ Paint.stroke(stroke, ui, canvas);
7596
7723
  if (fill)
7597
7724
  Paint.fill(fill, ui, canvas);
7598
7725
  if (__drawAfterFill)
7599
7726
  ui.__drawAfterFill(canvas, options);
7600
- if (stroke)
7727
+ if (stroke && !__fillAfterStroke)
7601
7728
  Paint.stroke(stroke, ui, canvas);
7602
7729
  }
7603
7730
 
@@ -7969,6 +8096,9 @@ __decorate([
7969
8096
  __decorate([
7970
8097
  surfaceType()
7971
8098
  ], UI.prototype, "placeholderColor", void 0);
8099
+ __decorate([
8100
+ dataType(100)
8101
+ ], UI.prototype, "placeholderDelay", void 0);
7972
8102
  __decorate([
7973
8103
  dataType({})
7974
8104
  ], UI.prototype, "data", void 0);
@@ -8370,15 +8500,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8370
8500
  }
8371
8501
  __listenEvents() {
8372
8502
  const runId = Run.start('FirstCreate ' + this.innerName);
8373
- this.once(LeaferEvent.START, () => Run.end(runId));
8374
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8375
- this.once(RenderEvent.START, () => this.__onCreated());
8376
- this.once(RenderEvent.END, () => this.__onViewReady());
8377
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8503
+ this.once([
8504
+ [LeaferEvent.START, () => Run.end(runId)],
8505
+ [LayoutEvent.START, this.updateLazyBounds, this],
8506
+ [RenderEvent.START, this.__onCreated, this],
8507
+ [RenderEvent.END, this.__onViewReady, this]
8508
+ ]);
8509
+ this.__eventIds.push(this.on_([
8510
+ [WatchEvent.DATA, this.__onWatchData, this],
8511
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8512
+ [RenderEvent.NEXT, this.__onNextRender, this]
8513
+ ]));
8378
8514
  }
8379
8515
  __removeListenEvents() {
8380
8516
  this.off_(this.__eventIds);
8381
- this.__eventIds.length = 0;
8382
8517
  }
8383
8518
  destroy(sync) {
8384
8519
  const doDestory = () => {
@@ -8486,13 +8621,13 @@ let Box = class Box extends Group {
8486
8621
  super.__updateRenderBounds();
8487
8622
  copy$3(childrenRenderBounds, renderBounds);
8488
8623
  this.__updateRectRenderBounds();
8489
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8624
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8490
8625
  if (isOverflow && this.__.overflow !== 'hide')
8491
8626
  add(renderBounds, childrenRenderBounds);
8492
8627
  }
8493
8628
  else
8494
8629
  this.__updateRectRenderBounds();
8495
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8630
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8496
8631
  }
8497
8632
  __updateRectRenderBounds() { }
8498
8633
  __updateRectChange() { }
@@ -8796,18 +8931,10 @@ Star = __decorate([
8796
8931
 
8797
8932
  let Image$1 = class Image extends Rect {
8798
8933
  get __tag() { return 'Image'; }
8799
- get ready() { return this.image ? this.image.ready : false; }
8934
+ get ready() { const { image } = this; return image && image.ready; }
8935
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8800
8936
  constructor(data) {
8801
8937
  super(data);
8802
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8803
- }
8804
- __onLoaded(e) {
8805
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8806
- this.image = e.image;
8807
- }
8808
- destroy() {
8809
- this.image = null;
8810
- super.destroy();
8811
8938
  }
8812
8939
  };
8813
8940
  __decorate([
@@ -8823,11 +8950,11 @@ const MyImage = Image$1;
8823
8950
 
8824
8951
  let Canvas = class Canvas extends Rect {
8825
8952
  get __tag() { return 'Canvas'; }
8953
+ get context() { return this.canvas.context; }
8826
8954
  get ready() { return !this.url; }
8827
8955
  constructor(data) {
8828
8956
  super(data);
8829
8957
  this.canvas = Creator.canvas(this.__);
8830
- this.context = this.canvas.context;
8831
8958
  if (data && data.url)
8832
8959
  this.drawImage(data.url);
8833
8960
  }
@@ -8871,7 +8998,7 @@ let Canvas = class Canvas extends Rect {
8871
8998
  destroy() {
8872
8999
  if (this.canvas) {
8873
9000
  this.canvas.destroy();
8874
- this.canvas = this.context = null;
9001
+ this.canvas = null;
8875
9002
  }
8876
9003
  super.destroy();
8877
9004
  }
@@ -8947,12 +9074,11 @@ let Text = class Text extends UI {
8947
9074
  super.__updateBoxBounds();
8948
9075
  if (italic)
8949
9076
  b.width += fontSize * 0.16;
8950
- const isOverflow = !includes(b, contentBounds) || undefined;
8951
- if (isOverflow)
9077
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
9078
+ if (this.isOverflow)
8952
9079
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8953
9080
  else
8954
9081
  data.__textBoxBounds = b;
8955
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8956
9082
  }
8957
9083
  __onUpdateSize() {
8958
9084
  if (this.__box)
@@ -9153,7 +9279,7 @@ let App = class App extends Leafer {
9153
9279
  if (sky || editor)
9154
9280
  this.sky = this.addLeafer(sky);
9155
9281
  if (editor)
9156
- this.sky.add(this.editor = Creator.editor(editor));
9282
+ Creator.editor(editor, this);
9157
9283
  }
9158
9284
  }
9159
9285
  __setApp() {
@@ -9167,6 +9293,10 @@ let App = class App extends Leafer {
9167
9293
  this.watcher.disable();
9168
9294
  this.layouter.disable();
9169
9295
  }
9296
+ __updateLocalBounds() {
9297
+ this.forEach(leafer => leafer.updateLayout());
9298
+ super.__updateLocalBounds();
9299
+ }
9170
9300
  start() {
9171
9301
  super.start();
9172
9302
  this.forEach(leafer => leafer.start());
@@ -9224,12 +9354,8 @@ let App = class App extends Leafer {
9224
9354
  this.renderer.update();
9225
9355
  }
9226
9356
  __render(canvas, options) {
9227
- if (canvas.context) {
9228
- const m = options.matrix;
9229
- if (m)
9230
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9231
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9232
- }
9357
+ if (canvas.context)
9358
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9233
9359
  }
9234
9360
  __onResize(event) {
9235
9361
  this.forEach(leafer => leafer.resize(event));
@@ -9250,9 +9376,11 @@ let App = class App extends Leafer {
9250
9376
  return config;
9251
9377
  }
9252
9378
  __listenChildEvents(leafer) {
9253
- leafer.once(LayoutEvent.END, () => this.__onReady());
9254
- leafer.once(RenderEvent.START, () => this.__onCreated());
9255
- leafer.once(RenderEvent.END, () => this.__onViewReady());
9379
+ leafer.once([
9380
+ [LayoutEvent.END, this.__onReady, this],
9381
+ [RenderEvent.START, this.__onCreated, this],
9382
+ [RenderEvent.END, this.__onViewReady, this]
9383
+ ]);
9256
9384
  if (this.realCanvas)
9257
9385
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9258
9386
  }
@@ -9463,7 +9591,7 @@ MoveEvent = __decorate([
9463
9591
  registerUIEvent()
9464
9592
  ], MoveEvent);
9465
9593
 
9466
- let RotateEvent = class RotateEvent extends UIEvent {
9594
+ let RotateEvent = class RotateEvent extends PointerEvent$1 {
9467
9595
  };
9468
9596
  RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9469
9597
  RotateEvent.START = 'rotate.start';
@@ -9484,7 +9612,7 @@ SwipeEvent = __decorate([
9484
9612
  registerUIEvent()
9485
9613
  ], SwipeEvent);
9486
9614
 
9487
- let ZoomEvent = class ZoomEvent extends UIEvent {
9615
+ let ZoomEvent = class ZoomEvent extends PointerEvent$1 {
9488
9616
  };
9489
9617
  ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9490
9618
  ZoomEvent.START = 'zoom.start';
@@ -10327,8 +10455,8 @@ ui$1.__updateHitCanvas = function () {
10327
10455
  if (this.__box)
10328
10456
  this.__box.__updateHitCanvas();
10329
10457
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10330
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10331
- const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10458
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10459
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10332
10460
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10333
10461
  if (!this.__hitCanvas)
10334
10462
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10359,11 +10487,11 @@ ui$1.__hit = function (inner) {
10359
10487
  if (data.__isHitPixel && this.__hitPixel(inner))
10360
10488
  return true;
10361
10489
  const { hitFill } = data;
10362
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10490
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10363
10491
  if (needHitFillPath && this.__hitFill(inner))
10364
10492
  return true;
10365
10493
  const { hitStroke, __strokeWidth } = data;
10366
- const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10494
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10367
10495
  if (!needHitFillPath && !needHitStrokePath)
10368
10496
  return false;
10369
10497
  const radiusWidth = inner.radiusX * 2;
@@ -10813,31 +10941,31 @@ function fillPathOrText(ui, canvas) {
10813
10941
  }
10814
10942
 
10815
10943
  function strokeText(stroke, ui, canvas) {
10816
- const { strokeAlign } = ui.__;
10817
- const isStrokes = typeof stroke !== 'string';
10818
- switch (strokeAlign) {
10944
+ switch (ui.__.strokeAlign) {
10819
10945
  case 'center':
10820
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10821
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10946
+ drawCenter$1(stroke, 1, ui, canvas);
10822
10947
  break;
10823
10948
  case 'inside':
10824
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10949
+ drawAlign(stroke, 'inside', ui, canvas);
10825
10950
  break;
10826
10951
  case 'outside':
10827
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10952
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10828
10953
  break;
10829
10954
  }
10830
10955
  }
10831
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10832
- const { __strokeWidth, __font } = ui.__;
10956
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10957
+ const data = ui.__;
10958
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10959
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10960
+ }
10961
+ function drawAlign(stroke, align, ui, canvas) {
10833
10962
  const out = canvas.getSameCanvas(true, true);
10834
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10835
- out.font = __font;
10836
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10963
+ out.font = ui.__.__font;
10964
+ drawCenter$1(stroke, 2, ui, out);
10837
10965
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10838
10966
  fillText(ui, out);
10839
10967
  out.blendMode = 'normal';
10840
- if (ui.__worldFlipped)
10968
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10841
10969
  canvas.copyWorldByReset(out, ui.__nowWorld);
10842
10970
  else
10843
10971
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10879,90 +11007,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
10879
11007
  }
10880
11008
 
10881
11009
  function stroke(stroke, ui, canvas) {
10882
- const options = ui.__;
10883
- const { __strokeWidth, strokeAlign, __font } = options;
10884
- if (!__strokeWidth)
11010
+ const data = ui.__;
11011
+ if (!data.__strokeWidth)
10885
11012
  return;
10886
- if (__font) {
11013
+ if (data.__font) {
10887
11014
  strokeText(stroke, ui, canvas);
10888
11015
  }
10889
11016
  else {
10890
- switch (strokeAlign) {
11017
+ switch (data.strokeAlign) {
10891
11018
  case 'center':
10892
- canvas.setStroke(stroke, __strokeWidth, options);
10893
- canvas.stroke();
10894
- if (options.__useArrow)
10895
- strokeArrow(ui, canvas);
11019
+ drawCenter(stroke, 1, ui, canvas);
10896
11020
  break;
10897
11021
  case 'inside':
10898
- canvas.save();
10899
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10900
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10901
- canvas.stroke();
10902
- canvas.restore();
11022
+ drawInside(stroke, ui, canvas);
10903
11023
  break;
10904
11024
  case 'outside':
10905
- const out = canvas.getSameCanvas(true, true);
10906
- out.setStroke(stroke, __strokeWidth * 2, options);
10907
- ui.__drawRenderPath(out);
10908
- out.stroke();
10909
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10910
- out.clearWorld(ui.__layout.renderBounds);
10911
- if (ui.__worldFlipped)
10912
- canvas.copyWorldByReset(out, ui.__nowWorld);
10913
- else
10914
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10915
- out.recycle(ui.__nowWorld);
11025
+ drawOutside(stroke, ui, canvas);
10916
11026
  break;
10917
11027
  }
10918
11028
  }
10919
11029
  }
10920
11030
  function strokes(strokes, ui, canvas) {
10921
- const options = ui.__;
10922
- const { __strokeWidth, strokeAlign, __font } = options;
10923
- if (!__strokeWidth)
10924
- return;
10925
- if (__font) {
10926
- strokeText(strokes, ui, canvas);
11031
+ stroke(strokes, ui, canvas);
11032
+ }
11033
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
11034
+ const data = ui.__;
11035
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
11036
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
11037
+ if (data.__useArrow)
11038
+ Paint.strokeArrow(stroke, ui, canvas);
11039
+ }
11040
+ function drawInside(stroke, ui, canvas) {
11041
+ const data = ui.__;
11042
+ canvas.save();
11043
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
11044
+ drawCenter(stroke, 2, ui, canvas);
11045
+ canvas.restore();
11046
+ }
11047
+ function drawOutside(stroke, ui, canvas) {
11048
+ const data = ui.__;
11049
+ if (data.__fillAfterStroke) {
11050
+ drawCenter(stroke, 2, ui, canvas);
10927
11051
  }
10928
11052
  else {
10929
- switch (strokeAlign) {
10930
- case 'center':
10931
- canvas.setStroke(undefined, __strokeWidth, options);
10932
- drawStrokesStyle(strokes, false, ui, canvas);
10933
- if (options.__useArrow)
10934
- strokeArrow(ui, canvas);
10935
- break;
10936
- case 'inside':
10937
- canvas.save();
10938
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10939
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10940
- drawStrokesStyle(strokes, false, ui, canvas);
10941
- canvas.restore();
10942
- break;
10943
- case 'outside':
10944
- const { renderBounds } = ui.__layout;
10945
- const out = canvas.getSameCanvas(true, true);
10946
- ui.__drawRenderPath(out);
10947
- out.setStroke(undefined, __strokeWidth * 2, options);
10948
- drawStrokesStyle(strokes, false, ui, out);
10949
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10950
- out.clearWorld(renderBounds);
10951
- if (ui.__worldFlipped)
10952
- canvas.copyWorldByReset(out, ui.__nowWorld);
10953
- else
10954
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10955
- out.recycle(ui.__nowWorld);
10956
- break;
10957
- }
10958
- }
10959
- }
10960
- function strokeArrow(ui, canvas) {
10961
- if (ui.__.dashPattern) {
10962
- canvas.beginPath();
10963
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10964
- canvas.dashPattern = null;
10965
- canvas.stroke();
11053
+ const { renderBounds } = ui.__layout;
11054
+ const out = canvas.getSameCanvas(true, true);
11055
+ ui.__drawRenderPath(out);
11056
+ drawCenter(stroke, 2, ui, out);
11057
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
11058
+ out.clearWorld(renderBounds);
11059
+ if (ui.__worldFlipped || Platform.fullImageShadow)
11060
+ canvas.copyWorldByReset(out, ui.__nowWorld);
11061
+ else
11062
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
11063
+ out.recycle(ui.__nowWorld);
10966
11064
  }
10967
11065
  }
10968
11066
 
@@ -11009,9 +11107,10 @@ function shape(ui, current, options) {
11009
11107
  }
11010
11108
 
11011
11109
  let recycleMap;
11110
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
11012
11111
  function compute(attrName, ui) {
11013
11112
  const data = ui.__, leafPaints = [];
11014
- let paints = data.__input[attrName], hasOpacityPixel;
11113
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
11015
11114
  if (!(paints instanceof Array))
11016
11115
  paints = [paints];
11017
11116
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -11021,29 +11120,55 @@ function compute(attrName, ui) {
11021
11120
  leafPaints.push(item);
11022
11121
  }
11023
11122
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
11024
- if (leafPaints.length && leafPaints[0].image)
11025
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
11026
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
11123
+ if (leafPaints.length) {
11124
+ if (leafPaints.every(item => item.isTransparent)) {
11125
+ if (leafPaints.some(item => item.image))
11126
+ isAlphaPixel = true;
11127
+ isTransparent = true;
11128
+ }
11129
+ }
11130
+ if (attrName === 'fill') {
11131
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
11132
+ stintSet(data, '__isTransparentFill', isTransparent);
11133
+ }
11134
+ else {
11135
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
11136
+ stintSet(data, '__isTransparentStroke', isTransparent);
11137
+ }
11027
11138
  }
11028
11139
  function getLeafPaint(attrName, paint, ui) {
11029
11140
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
11030
11141
  return undefined;
11142
+ let data;
11031
11143
  const { boxBounds } = ui.__layout;
11032
11144
  switch (paint.type) {
11033
- case 'solid':
11034
- let { type, blendMode, color, opacity } = paint;
11035
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
11036
11145
  case 'image':
11037
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11146
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11147
+ break;
11038
11148
  case 'linear':
11039
- return PaintGradient.linearGradient(paint, boxBounds);
11149
+ data = PaintGradient.linearGradient(paint, boxBounds);
11150
+ break;
11040
11151
  case 'radial':
11041
- return PaintGradient.radialGradient(paint, boxBounds);
11152
+ data = PaintGradient.radialGradient(paint, boxBounds);
11153
+ break;
11042
11154
  case 'angular':
11043
- return PaintGradient.conicGradient(paint, boxBounds);
11155
+ data = PaintGradient.conicGradient(paint, boxBounds);
11156
+ break;
11157
+ case 'solid':
11158
+ const { type, blendMode, color, opacity } = paint;
11159
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
11160
+ break;
11044
11161
  default:
11045
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
11162
+ if (paint.r !== undefined)
11163
+ data = { type: 'solid', style: ColorConvert.string(paint) };
11164
+ }
11165
+ if (data) {
11166
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
11167
+ data.isTransparent = true;
11168
+ if (paint.blendMode)
11169
+ data.blendMode = paint.blendMode;
11046
11170
  }
11171
+ return data;
11047
11172
  }
11048
11173
 
11049
11174
  const PaintModule = {
@@ -11109,12 +11234,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
11109
11234
 
11110
11235
  const { get: get$2, translate } = MatrixHelper;
11111
11236
  const tempBox = new Bounds();
11112
- const tempPoint = {};
11113
11237
  const tempScaleData = {};
11238
+ const tempImage = {};
11114
11239
  function createData(leafPaint, image, paint, box) {
11115
- const { blendMode, changeful, sync } = paint;
11116
- if (blendMode)
11117
- leafPaint.blendMode = blendMode;
11240
+ const { changeful, sync } = paint;
11118
11241
  if (changeful)
11119
11242
  leafPaint.changeful = changeful;
11120
11243
  if (sync)
@@ -11122,38 +11245,38 @@ function createData(leafPaint, image, paint, box) {
11122
11245
  leafPaint.data = getPatternData(paint, box, image);
11123
11246
  }
11124
11247
  function getPatternData(paint, box, image) {
11125
- let { width, height } = image;
11126
11248
  if (paint.padding)
11127
11249
  box = tempBox.set(box).shrink(paint.padding);
11128
11250
  if (paint.mode === 'strench')
11129
11251
  paint.mode = 'stretch';
11252
+ let { width, height } = image;
11130
11253
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
11131
11254
  const sameBox = box.width === width && box.height === height;
11132
11255
  const data = { mode };
11133
11256
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
11134
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
11135
- let x = 0, y = 0, scaleX, scaleY;
11257
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
11258
+ let scaleX, scaleY;
11136
11259
  if (!mode || mode === 'cover' || mode === 'fit') {
11137
11260
  if (!sameBox || rotation) {
11138
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
11139
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
11140
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
11261
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
11262
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
11263
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
11141
11264
  }
11142
11265
  }
11143
- else if (scale || size) {
11144
- MathHelper.getScaleData(scale, size, image, tempScaleData);
11145
- scaleX = tempScaleData.scaleX;
11146
- scaleY = tempScaleData.scaleY;
11147
- }
11148
- if (align) {
11149
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
11150
- if (scaleX)
11151
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
11152
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
11153
- x += tempPoint.x, y += tempPoint.y;
11266
+ else {
11267
+ if (scale || size) {
11268
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
11269
+ scaleX = tempScaleData.scaleX;
11270
+ scaleY = tempScaleData.scaleY;
11271
+ }
11272
+ if (align) {
11273
+ if (scaleX)
11274
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
11275
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
11276
+ }
11154
11277
  }
11155
11278
  if (offset)
11156
- x += offset.x, y += offset.y;
11279
+ PointHelper.move(tempImage, offset);
11157
11280
  switch (mode) {
11158
11281
  case 'stretch':
11159
11282
  if (!sameBox)
@@ -11161,12 +11284,12 @@ function getPatternData(paint, box, image) {
11161
11284
  break;
11162
11285
  case 'normal':
11163
11286
  case 'clip':
11164
- if (x || y || scaleX || rotation)
11165
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
11287
+ if (tempImage.x || tempImage.y || scaleX || rotation)
11288
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11166
11289
  break;
11167
11290
  case 'repeat':
11168
11291
  if (!sameBox || scaleX || rotation)
11169
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
11292
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
11170
11293
  if (!repeat)
11171
11294
  data.repeat = 'repeat';
11172
11295
  break;
@@ -11174,7 +11297,7 @@ function getPatternData(paint, box, image) {
11174
11297
  case 'cover':
11175
11298
  default:
11176
11299
  if (scaleX)
11177
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
11300
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11178
11301
  }
11179
11302
  if (!data.transform) {
11180
11303
  if (box.x || box.y) {
@@ -11207,6 +11330,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11207
11330
  }
11208
11331
  else {
11209
11332
  leafPaint = { type: paint.type, image };
11333
+ if (image.hasAlphaPixel)
11334
+ leafPaint.isTransparent = true;
11210
11335
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
11211
11336
  }
11212
11337
  if (firstUse || image.loading)
@@ -11231,7 +11356,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11231
11356
  ignoreRender(ui, false);
11232
11357
  if (!ui.destroyed) {
11233
11358
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11234
- if (image.hasOpacityPixel)
11359
+ if (image.hasAlphaPixel)
11235
11360
  ui.__layout.hitCanvasChanged = true;
11236
11361
  ui.forceUpdate('surface');
11237
11362
  }
@@ -11243,13 +11368,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11243
11368
  onLoadError(ui, event, error);
11244
11369
  leafPaint.loadId = null;
11245
11370
  });
11246
- if (ui.placeholderColor)
11247
- setTimeout(() => {
11248
- if (!(image.ready || image.isPlacehold)) {
11249
- image.isPlacehold = true;
11250
- ui.forceUpdate('surface');
11251
- }
11252
- }, 100);
11371
+ if (ui.placeholderColor) {
11372
+ if (!ui.placeholderDelay)
11373
+ image.isPlacehold = true;
11374
+ else
11375
+ setTimeout(() => {
11376
+ if (!image.ready) {
11377
+ image.isPlacehold = true;
11378
+ ui.forceUpdate('surface');
11379
+ }
11380
+ }, ui.placeholderDelay);
11381
+ }
11253
11382
  }
11254
11383
  return leafPaint;
11255
11384
  }
@@ -11455,32 +11584,33 @@ const PaintImageModule = {
11455
11584
  repeatMode
11456
11585
  };
11457
11586
 
11458
- const { toPoint: toPoint$2 } = AroundHelper;
11587
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
11459
11588
  const realFrom$2 = {};
11460
11589
  const realTo$2 = {};
11461
11590
  function linearGradient(paint, box) {
11462
- let { from, to, type, blendMode, opacity } = paint;
11591
+ let { from, to, type, opacity } = paint;
11463
11592
  toPoint$2(from || 'top', box, realFrom$2);
11464
11593
  toPoint$2(to || 'bottom', box, realTo$2);
11465
11594
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
11466
- applyStops(style, paint.stops, opacity);
11467
11595
  const data = { type, style };
11468
- if (blendMode)
11469
- data.blendMode = blendMode;
11596
+ applyStops(data, style, paint.stops, opacity);
11470
11597
  return data;
11471
11598
  }
11472
- function applyStops(gradient, stops, opacity) {
11599
+ function applyStops(data, gradient, stops, opacity) {
11473
11600
  if (stops) {
11474
- let stop;
11601
+ let stop, color, offset, isTransparent;
11475
11602
  for (let i = 0, len = stops.length; i < len; i++) {
11476
11603
  stop = stops[i];
11477
- if (typeof stop === 'string') {
11478
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
11479
- }
11480
- else {
11481
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
11482
- }
11604
+ if (typeof stop === 'string')
11605
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
11606
+ else
11607
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
11608
+ gradient.addColorStop(offset, color);
11609
+ if (!isTransparent && hasTransparent(color))
11610
+ isTransparent = true;
11483
11611
  }
11612
+ if (isTransparent)
11613
+ data.isTransparent = true;
11484
11614
  }
11485
11615
  }
11486
11616
 
@@ -11490,17 +11620,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
11490
11620
  const realFrom$1 = {};
11491
11621
  const realTo$1 = {};
11492
11622
  function radialGradient(paint, box) {
11493
- let { from, to, type, opacity, blendMode, stretch } = paint;
11623
+ let { from, to, type, opacity, stretch } = paint;
11494
11624
  toPoint$1(from || 'center', box, realFrom$1);
11495
11625
  toPoint$1(to || 'bottom', box, realTo$1);
11496
11626
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11497
- applyStops(style, paint.stops, opacity);
11498
11627
  const data = { type, style };
11628
+ applyStops(data, style, paint.stops, opacity);
11499
11629
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11500
11630
  if (transform)
11501
11631
  data.transform = transform;
11502
- if (blendMode)
11503
- data.blendMode = blendMode;
11504
11632
  return data;
11505
11633
  }
11506
11634
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11526,17 +11654,15 @@ const { toPoint } = AroundHelper;
11526
11654
  const realFrom = {};
11527
11655
  const realTo = {};
11528
11656
  function conicGradient(paint, box) {
11529
- let { from, to, type, opacity, blendMode, stretch } = paint;
11657
+ let { from, to, type, opacity, stretch } = paint;
11530
11658
  toPoint(from || 'center', box, realFrom);
11531
11659
  toPoint(to || 'bottom', box, realTo);
11532
11660
  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));
11533
- applyStops(style, paint.stops, opacity);
11534
11661
  const data = { type, style };
11662
+ applyStops(data, style, paint.stops, opacity);
11535
11663
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11536
11664
  if (transform)
11537
11665
  data.transform = transform;
11538
- if (blendMode)
11539
- data.blendMode = blendMode;
11540
11666
  return data;
11541
11667
  }
11542
11668
 
@@ -11869,6 +11995,8 @@ function createRows(drawData, content, style) {
11869
11995
  lastCharType = null;
11870
11996
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11871
11997
  word = { data: [] }, row = { words: [] };
11998
+ if (__letterSpacing)
11999
+ content = [...content];
11872
12000
  for (let i = 0, len = content.length; i < len; i++) {
11873
12001
  char = content[i];
11874
12002
  if (char === '\n') {
@@ -12287,4 +12415,4 @@ Object.assign(Creator, {
12287
12415
  });
12288
12416
  useCanvas();
12289
12417
 
12290
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, 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, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, 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 };
12418
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, 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, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, 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 };