@leafer/worker 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$6, cos: cos$6, acos, sqrt: sqrt$5 } = Math;
152
150
  const { float: float$2 } = MathHelper;
153
- const tempPoint$5 = {};
151
+ const tempPoint$4 = {};
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$a.toInnerPoint(t, origin, tempPoint$5);
197
- M$a.scaleOfInner(t, tempPoint$5, scaleX, scaleY);
194
+ M$a.toInnerPoint(t, origin, tempPoint$4);
195
+ M$a.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
198
196
  },
199
197
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
200
198
  M$a.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$a.toInnerPoint(t, origin, tempPoint$5);
216
- M$a.rotateOfInner(t, tempPoint$5, rotation);
213
+ M$a.toInnerPoint(t, origin, tempPoint$4);
214
+ M$a.rotateOfInner(t, tempPoint$4, rotation);
217
215
  },
218
216
  rotateOfInner(t, origin, rotation) {
219
217
  M$a.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$a.toInnerPoint(t, origin, tempPoint$5);
238
- M$a.skewOfInner(t, tempPoint$5, skewX, skewY);
235
+ M$a.toInnerPoint(t, origin, tempPoint$4);
236
+ M$a.skewOfInner(t, tempPoint$4, skewX, skewY);
239
237
  },
240
238
  skewOfInner(t, origin, skewX, skewY = 0) {
241
239
  M$a.translateInner(t, origin.x, origin.y);
@@ -464,8 +462,10 @@ const PointHelper = {
464
462
  t.y = halfPixel ? round$5(t.y - 0.5) + 0.5 : round$5(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$4 = new Point();
646
+ const tempPoint$3 = 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$4 } = 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$6 } = AroundHelper;
869
+ const AlignHelper = {
870
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
871
+ toPoint$6(align, box, to, onlyBoxSize, content, onlyContentSize);
872
+ }
873
+ };
874
+
804
875
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
805
876
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
806
877
  const { float: float$1, fourNumber: fourNumber$1 } = MathHelper;
807
878
  const { floor: floor$1, ceil: ceil$3 } = Math;
808
879
  let right$4, bottom$3, boundsRight, boundsBottom;
809
880
  const point$2 = {};
810
- const toPoint$6 = {};
881
+ const toPoint$5 = {};
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$2.x = t.x;
918
990
  point$2.y = t.y;
919
- toOuterPoint$2(matrix, point$2, toPoint$6);
920
- setPoint$5(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
991
+ toOuterPoint$2(matrix, point$2, toPoint$5);
992
+ setPoint$5(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
921
993
  point$2.x = t.x + t.width;
922
- toOuterPoint$2(matrix, point$2, toPoint$6);
923
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
994
+ toOuterPoint$2(matrix, point$2, toPoint$5);
995
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
924
996
  point$2.y = t.y + t.height;
925
- toOuterPoint$2(matrix, point$2, toPoint$6);
926
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
997
+ toOuterPoint$2(matrix, point$2, toPoint$5);
998
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
927
999
  point$2.x = t.x;
928
- toOuterPoint$2(matrix, point$2, toPoint$6);
929
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
1000
+ toOuterPoint$2(matrix, point$2, toPoint$5);
1001
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
930
1002
  toBounds$4(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$5 } = AroundHelper;
1309
- const AlignHelper = {
1310
- toPoint(align, contentBounds, bounds, to, onlySize) {
1311
- toPoint$5(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$h = 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: assign$1 } = DataHelper;
@@ -2385,7 +2409,7 @@ const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI
2385
2409
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2386
2410
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2387
2411
  const { M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8 } = PathCommandMap;
2388
- const tempPoint$3 = {};
2412
+ const tempPoint$2 = {};
2389
2413
  const BezierHelper = {
2390
2414
  points(data, originPoints, curve, close) {
2391
2415
  let points = toNumberPoints$1(originPoints);
@@ -2407,6 +2431,8 @@ const BezierHelper = {
2407
2431
  cY = points[i + 3];
2408
2432
  ba = sqrt$3(pow$1(bX - aX, 2) + pow$1(bY - aY, 2));
2409
2433
  cb = sqrt$3(pow$1(cX - bX, 2) + pow$1(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$2(pointBounds, fromX, fromY) : setPoint$4(pointBounds, fromX, fromY);
2577
2603
  addPoint$2(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$3);
2580
- addPoint$2(pointBounds, tempPoint$3.x, tempPoint$3.y);
2605
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2606
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.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$2 = FileHelper;
3416
- F$2.opacityTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3442
+ F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3417
3443
 
3418
3444
  const debug$c = 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$3 } = LeafHelper;
4486
+ const { updateBounds: updateBounds$4 } = 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$3(children[j]);
4548
+ updateBounds$4(children[j]);
4523
4549
  }
4524
4550
  if (exclude && exclude === branch)
4525
4551
  continue;
4526
- updateBounds$3(branch);
4552
+ updateBounds$4(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$3 } = LeafHelper;
4545
4571
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$9 } = 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$3(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$4, tempPoint: tempPoint$2 } = AroundHelper;
5258
+ const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = 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$4(data.around || data.origin, layout.boxBounds, tempPoint$2);
5195
- translateInner(local, -tempPoint$2.x, -tempPoint$2.y, !data.around);
5275
+ toPoint$4(data.around || data.origin, layout.boxBounds, tempPoint$1);
5276
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.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$2, copy: copy$8 } =
5205
5286
  const { toBounds: toBounds$2 } = 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
  class LeaferCanvas extends LeaferCanvasBase {
6148
6236
  get allowBackgroundColor() { return true; }
@@ -6301,17 +6389,15 @@ class Watcher {
6301
6389
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6302
6390
  this.__updatedList = new LeafList();
6303
6391
  this.totalTimes++;
6304
- this.changed = false;
6305
- this.hasVisible = false;
6306
- this.hasRemove = false;
6307
- this.hasAdd = false;
6392
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6308
6393
  }
6309
6394
  __listenEvents() {
6310
- const { target } = this;
6311
6395
  this.__eventIds = [
6312
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6313
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6314
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6396
+ this.target.on_([
6397
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6398
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6399
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6400
+ ])
6315
6401
  ];
6316
6402
  }
6317
6403
  __removeListenEvents() {
@@ -6321,8 +6407,7 @@ class Watcher {
6321
6407
  if (this.target) {
6322
6408
  this.stop();
6323
6409
  this.__removeListenEvents();
6324
- this.target = null;
6325
- this.__updatedList = null;
6410
+ this.target = this.__updatedList = null;
6326
6411
  }
6327
6412
  }
6328
6413
  }
@@ -6427,7 +6512,7 @@ class Layouter {
6427
6512
  this.disabled = true;
6428
6513
  }
6429
6514
  layout() {
6430
- if (!this.running)
6515
+ if (this.layouting || !this.running)
6431
6516
  return;
6432
6517
  const { target } = this;
6433
6518
  this.times = 0;
@@ -6510,12 +6595,10 @@ class Layouter {
6510
6595
  }
6511
6596
  static fullLayout(target) {
6512
6597
  updateAllMatrix$1(target, true);
6513
- if (target.isBranch) {
6598
+ if (target.isBranch)
6514
6599
  BranchHelper.updateBounds(target);
6515
- }
6516
- else {
6600
+ else
6517
6601
  LeafHelper.updateBounds(target);
6518
- }
6519
6602
  updateAllChange(target);
6520
6603
  }
6521
6604
  addExtra(leaf) {
@@ -6538,11 +6621,12 @@ class Layouter {
6538
6621
  this.__updatedList = event.data.updatedList;
6539
6622
  }
6540
6623
  __listenEvents() {
6541
- const { target } = this;
6542
6624
  this.__eventIds = [
6543
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6544
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6545
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6625
+ this.target.on_([
6626
+ [LayoutEvent.REQUEST, this.layout, this],
6627
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6628
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6629
+ ])
6546
6630
  ];
6547
6631
  }
6548
6632
  __removeListenEvents() {
@@ -6773,12 +6857,13 @@ class Renderer {
6773
6857
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6774
6858
  }
6775
6859
  __listenEvents() {
6776
- const { target } = this;
6777
6860
  this.__eventIds = [
6778
- target.on_(RenderEvent.REQUEST, this.update, this),
6779
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6780
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6781
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
6861
+ this.target.on_([
6862
+ [RenderEvent.REQUEST, this.update, this],
6863
+ [LayoutEvent.END, this.__onLayoutEnd, this],
6864
+ [RenderEvent.AGAIN, this.renderAgain, this],
6865
+ [ResizeEvent.RESIZE, this.__onResize, this]
6866
+ ])
6782
6867
  ];
6783
6868
  }
6784
6869
  __removeListenEvents() {
@@ -6994,8 +7079,32 @@ function zoomLayerType() {
6994
7079
  };
6995
7080
  }
6996
7081
 
7082
+ function hasTransparent$3(color) {
7083
+ if (!color || color.length === 7 || color.length === 4)
7084
+ return false;
7085
+ if (color === 'transparent')
7086
+ return true;
7087
+ const first = color[0];
7088
+ if (first === '#') {
7089
+ switch (color.length) {
7090
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7091
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7092
+ }
7093
+ }
7094
+ else if (first === 'r' || first === 'h') {
7095
+ if (color[3] === 'a') {
7096
+ const i = color.lastIndexOf(',');
7097
+ if (i > -1)
7098
+ return parseFloat(color.slice(i + 1)) < 1;
7099
+ }
7100
+ }
7101
+ return false;
7102
+ }
7103
+
6997
7104
  const TextConvert = {};
6998
- const ColorConvert = {};
7105
+ const ColorConvert = {
7106
+ hasTransparent: hasTransparent$3
7107
+ };
6999
7108
  const UnitConvert = {
7000
7109
  number(value, percentRefer) {
7001
7110
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7021,6 +7130,7 @@ const Transition = {
7021
7130
  };
7022
7131
 
7023
7132
  const { parse, objectToCanvasData } = PathConvert;
7133
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7024
7134
  const emptyPaint = {};
7025
7135
  const debug$5 = Debug.get('UIData');
7026
7136
  class UIData extends LeafData {
@@ -7079,38 +7189,22 @@ class UIData extends LeafData {
7079
7189
  if (this.__naturalWidth)
7080
7190
  this.__removeNaturalSize();
7081
7191
  if (typeof value === 'string' || !value) {
7082
- if (this.__isFills) {
7083
- this.__removeInput('fill');
7084
- PaintImage.recycleImage('fill', this);
7085
- this.__isFills = false;
7086
- this.__pixelFill && (this.__pixelFill = false);
7087
- }
7192
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7193
+ this.__isFills && this.__removePaint('fill', true);
7088
7194
  this._fill = value;
7089
7195
  }
7090
7196
  else if (typeof value === 'object') {
7091
- this.__setInput('fill', value);
7092
- const layout = this.__leaf.__layout;
7093
- layout.boxChanged || layout.boxChange();
7094
- this.__isFills = true;
7095
- this._fill || (this._fill = emptyPaint);
7197
+ this.__setPaint('fill', value);
7096
7198
  }
7097
7199
  }
7098
7200
  setStroke(value) {
7099
7201
  if (typeof value === 'string' || !value) {
7100
- if (this.__isStrokes) {
7101
- this.__removeInput('stroke');
7102
- PaintImage.recycleImage('stroke', this);
7103
- this.__isStrokes = false;
7104
- this.__pixelStroke && (this.__pixelStroke = false);
7105
- }
7202
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7203
+ this.__isStrokes && this.__removePaint('stroke', true);
7106
7204
  this._stroke = value;
7107
7205
  }
7108
7206
  else if (typeof value === 'object') {
7109
- this.__setInput('stroke', value);
7110
- const layout = this.__leaf.__layout;
7111
- layout.boxChanged || layout.boxChange();
7112
- this.__isStrokes = true;
7113
- this._stroke || (this._stroke = emptyPaint);
7207
+ this.__setPaint('stroke', value);
7114
7208
  }
7115
7209
  }
7116
7210
  setPath(value) {
@@ -7140,7 +7234,34 @@ class UIData extends LeafData {
7140
7234
  Paint.compute('fill', this.__leaf);
7141
7235
  if (stroke)
7142
7236
  Paint.compute('stroke', this.__leaf);
7143
- this.__needComputePaint = false;
7237
+ this.__needComputePaint = undefined;
7238
+ }
7239
+ __setPaint(attrName, value) {
7240
+ this.__setInput(attrName, value);
7241
+ const layout = this.__leaf.__layout;
7242
+ layout.boxChanged || layout.boxChange();
7243
+ if (value instanceof Array && !value.length) {
7244
+ this.__removePaint(attrName);
7245
+ }
7246
+ else {
7247
+ if (attrName === 'fill')
7248
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7249
+ else
7250
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7251
+ }
7252
+ }
7253
+ __removePaint(attrName, removeInput) {
7254
+ if (removeInput)
7255
+ this.__removeInput(attrName);
7256
+ PaintImage.recycleImage(attrName, this);
7257
+ if (attrName === 'fill') {
7258
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7259
+ this._fill = this.__isFills = undefined;
7260
+ }
7261
+ else {
7262
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7263
+ this._stroke = this.__isStrokes = undefined;
7264
+ }
7144
7265
  }
7145
7266
  }
7146
7267
  function setArray(data, key, value) {
@@ -7148,10 +7269,10 @@ function setArray(data, key, value) {
7148
7269
  if (value instanceof Array) {
7149
7270
  if (value.some((item) => item.visible === false))
7150
7271
  value = value.filter((item) => item.visible !== false);
7151
- value.length || (value = null);
7272
+ value.length || (value = undefined);
7152
7273
  }
7153
7274
  else
7154
- value = value && value.visible !== false ? [value] : null;
7275
+ value = value && value.visible !== false ? [value] : undefined;
7155
7276
  data['_' + key] = value;
7156
7277
  }
7157
7278
 
@@ -7254,8 +7375,6 @@ class ImageData extends RectData {
7254
7375
  this._url = value;
7255
7376
  }
7256
7377
  __setImageFill(value) {
7257
- if (this.__leaf.image)
7258
- this.__leaf.image = null;
7259
7378
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7260
7379
  }
7261
7380
  __getData() {
@@ -7321,21 +7440,19 @@ const UIBounds = {
7321
7440
  }
7322
7441
  };
7323
7442
 
7443
+ const { stintSet: stintSet$1 } = DataHelper;
7324
7444
  const UIRender = {
7325
7445
  __updateChange() {
7326
- const data = this.__, w = this.__world;
7446
+ const data = this.__;
7327
7447
  if (data.__useEffect) {
7328
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7329
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7448
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7449
+ 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')));
7450
+ data.__useEffect = !!(shadow || otherEffect);
7330
7451
  }
7331
- const half = data.__hasHalf;
7332
- w.half !== half && (w.half = half);
7452
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7453
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7333
7454
  data.__checkSingle();
7334
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7335
- if (complex)
7336
- data.__complex = true;
7337
- else
7338
- data.__complex && (data.__complex = false);
7455
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7339
7456
  },
7340
7457
  __drawFast(canvas, options) {
7341
7458
  drawFast(this, canvas, options);
@@ -7345,21 +7462,23 @@ const UIRender = {
7345
7462
  if (data.__complex) {
7346
7463
  if (data.__needComputePaint)
7347
7464
  data.__computePaint();
7348
- const { fill, stroke, __drawAfterFill } = data;
7465
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7349
7466
  this.__drawRenderPath(canvas);
7350
- if (data.__useEffect) {
7467
+ if (data.__useEffect && !__isFastShadow) {
7351
7468
  const shape = Paint.shape(this, canvas, options);
7352
7469
  this.__nowWorld = this.__getNowWorld(options);
7353
7470
  const { shadow, innerShadow, filter } = data;
7354
7471
  if (shadow)
7355
7472
  Effect.shadow(this, canvas, shape);
7473
+ if (__fillAfterStroke)
7474
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7356
7475
  if (fill)
7357
7476
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7358
7477
  if (__drawAfterFill)
7359
7478
  this.__drawAfterFill(canvas, options);
7360
7479
  if (innerShadow)
7361
7480
  Effect.innerShadow(this, canvas, shape);
7362
- if (stroke)
7481
+ if (stroke && !__fillAfterStroke)
7363
7482
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7364
7483
  if (filter)
7365
7484
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7368,21 +7487,27 @@ const UIRender = {
7368
7487
  shape.canvas.recycle();
7369
7488
  }
7370
7489
  else {
7490
+ if (__fillAfterStroke)
7491
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7492
+ if (__isFastShadow) {
7493
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7494
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7495
+ }
7371
7496
  if (fill)
7372
7497
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7498
+ if (__isFastShadow)
7499
+ canvas.restore();
7373
7500
  if (__drawAfterFill)
7374
7501
  this.__drawAfterFill(canvas, options);
7375
- if (stroke)
7502
+ if (stroke && !__fillAfterStroke)
7376
7503
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7377
7504
  }
7378
7505
  }
7379
7506
  else {
7380
- if (data.__pathInputed) {
7507
+ if (data.__pathInputed)
7381
7508
  drawFast(this, canvas, options);
7382
- }
7383
- else {
7509
+ else
7384
7510
  this.__drawFast(canvas, options);
7385
- }
7386
7511
  }
7387
7512
  },
7388
7513
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7391,11 +7516,11 @@ const UIRender = {
7391
7516
  const { fill, stroke } = this.__;
7392
7517
  this.__drawRenderPath(canvas);
7393
7518
  if (fill && !ignoreFill)
7394
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7519
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7395
7520
  if (this.__.__isCanvas)
7396
7521
  this.__drawAfterFill(canvas, options);
7397
7522
  if (stroke && !ignoreStroke)
7398
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7523
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7399
7524
  }
7400
7525
  },
7401
7526
  __drawAfterFill(canvas, options) {
@@ -7410,13 +7535,15 @@ const UIRender = {
7410
7535
  }
7411
7536
  };
7412
7537
  function drawFast(ui, canvas, options) {
7413
- const { fill, stroke, __drawAfterFill } = ui.__;
7538
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7414
7539
  ui.__drawRenderPath(canvas);
7540
+ if (__fillAfterStroke)
7541
+ Paint.stroke(stroke, ui, canvas);
7415
7542
  if (fill)
7416
7543
  Paint.fill(fill, ui, canvas);
7417
7544
  if (__drawAfterFill)
7418
7545
  ui.__drawAfterFill(canvas, options);
7419
- if (stroke)
7546
+ if (stroke && !__fillAfterStroke)
7420
7547
  Paint.stroke(stroke, ui, canvas);
7421
7548
  }
7422
7549
 
@@ -7788,6 +7915,9 @@ __decorate([
7788
7915
  __decorate([
7789
7916
  surfaceType()
7790
7917
  ], UI.prototype, "placeholderColor", void 0);
7918
+ __decorate([
7919
+ dataType(100)
7920
+ ], UI.prototype, "placeholderDelay", void 0);
7791
7921
  __decorate([
7792
7922
  dataType({})
7793
7923
  ], UI.prototype, "data", void 0);
@@ -8189,15 +8319,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8189
8319
  }
8190
8320
  __listenEvents() {
8191
8321
  const runId = Run.start('FirstCreate ' + this.innerName);
8192
- this.once(LeaferEvent.START, () => Run.end(runId));
8193
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8194
- this.once(RenderEvent.START, () => this.__onCreated());
8195
- this.once(RenderEvent.END, () => this.__onViewReady());
8196
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8322
+ this.once([
8323
+ [LeaferEvent.START, () => Run.end(runId)],
8324
+ [LayoutEvent.START, this.updateLazyBounds, this],
8325
+ [RenderEvent.START, this.__onCreated, this],
8326
+ [RenderEvent.END, this.__onViewReady, this]
8327
+ ]);
8328
+ this.__eventIds.push(this.on_([
8329
+ [WatchEvent.DATA, this.__onWatchData, this],
8330
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8331
+ [RenderEvent.NEXT, this.__onNextRender, this]
8332
+ ]));
8197
8333
  }
8198
8334
  __removeListenEvents() {
8199
8335
  this.off_(this.__eventIds);
8200
- this.__eventIds.length = 0;
8201
8336
  }
8202
8337
  destroy(sync) {
8203
8338
  const doDestory = () => {
@@ -8305,13 +8440,13 @@ let Box = class Box extends Group {
8305
8440
  super.__updateRenderBounds();
8306
8441
  copy$6(childrenRenderBounds, renderBounds);
8307
8442
  this.__updateRectRenderBounds();
8308
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8443
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8309
8444
  if (isOverflow && this.__.overflow !== 'hide')
8310
8445
  add(renderBounds, childrenRenderBounds);
8311
8446
  }
8312
8447
  else
8313
8448
  this.__updateRectRenderBounds();
8314
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8449
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8315
8450
  }
8316
8451
  __updateRectRenderBounds() { }
8317
8452
  __updateRectChange() { }
@@ -8615,18 +8750,10 @@ Star = __decorate([
8615
8750
 
8616
8751
  let Image = class Image extends Rect {
8617
8752
  get __tag() { return 'Image'; }
8618
- get ready() { return this.image ? this.image.ready : false; }
8753
+ get ready() { const { image } = this; return image && image.ready; }
8754
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8619
8755
  constructor(data) {
8620
8756
  super(data);
8621
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8622
- }
8623
- __onLoaded(e) {
8624
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8625
- this.image = e.image;
8626
- }
8627
- destroy() {
8628
- this.image = null;
8629
- super.destroy();
8630
8757
  }
8631
8758
  };
8632
8759
  __decorate([
@@ -8642,11 +8769,11 @@ const MyImage = Image;
8642
8769
 
8643
8770
  let Canvas = class Canvas extends Rect {
8644
8771
  get __tag() { return 'Canvas'; }
8772
+ get context() { return this.canvas.context; }
8645
8773
  get ready() { return !this.url; }
8646
8774
  constructor(data) {
8647
8775
  super(data);
8648
8776
  this.canvas = Creator.canvas(this.__);
8649
- this.context = this.canvas.context;
8650
8777
  if (data && data.url)
8651
8778
  this.drawImage(data.url);
8652
8779
  }
@@ -8690,7 +8817,7 @@ let Canvas = class Canvas extends Rect {
8690
8817
  destroy() {
8691
8818
  if (this.canvas) {
8692
8819
  this.canvas.destroy();
8693
- this.canvas = this.context = null;
8820
+ this.canvas = null;
8694
8821
  }
8695
8822
  super.destroy();
8696
8823
  }
@@ -8766,12 +8893,11 @@ let Text = class Text extends UI {
8766
8893
  super.__updateBoxBounds();
8767
8894
  if (italic)
8768
8895
  b.width += fontSize * 0.16;
8769
- const isOverflow = !includes(b, contentBounds) || undefined;
8770
- if (isOverflow)
8896
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8897
+ if (this.isOverflow)
8771
8898
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8772
8899
  else
8773
8900
  data.__textBoxBounds = b;
8774
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8775
8901
  }
8776
8902
  __onUpdateSize() {
8777
8903
  if (this.__box)
@@ -8972,7 +9098,7 @@ let App = class App extends Leafer {
8972
9098
  if (sky || editor)
8973
9099
  this.sky = this.addLeafer(sky);
8974
9100
  if (editor)
8975
- this.sky.add(this.editor = Creator.editor(editor));
9101
+ Creator.editor(editor, this);
8976
9102
  }
8977
9103
  }
8978
9104
  __setApp() {
@@ -8986,6 +9112,10 @@ let App = class App extends Leafer {
8986
9112
  this.watcher.disable();
8987
9113
  this.layouter.disable();
8988
9114
  }
9115
+ __updateLocalBounds() {
9116
+ this.forEach(leafer => leafer.updateLayout());
9117
+ super.__updateLocalBounds();
9118
+ }
8989
9119
  start() {
8990
9120
  super.start();
8991
9121
  this.forEach(leafer => leafer.start());
@@ -9043,12 +9173,8 @@ let App = class App extends Leafer {
9043
9173
  this.renderer.update();
9044
9174
  }
9045
9175
  __render(canvas, options) {
9046
- if (canvas.context) {
9047
- const m = options.matrix;
9048
- if (m)
9049
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9050
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9051
- }
9176
+ if (canvas.context)
9177
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9052
9178
  }
9053
9179
  __onResize(event) {
9054
9180
  this.forEach(leafer => leafer.resize(event));
@@ -9069,9 +9195,11 @@ let App = class App extends Leafer {
9069
9195
  return config;
9070
9196
  }
9071
9197
  __listenChildEvents(leafer) {
9072
- leafer.once(LayoutEvent.END, () => this.__onReady());
9073
- leafer.once(RenderEvent.START, () => this.__onCreated());
9074
- leafer.once(RenderEvent.END, () => this.__onViewReady());
9198
+ leafer.once([
9199
+ [LayoutEvent.END, this.__onReady, this],
9200
+ [RenderEvent.START, this.__onCreated, this],
9201
+ [RenderEvent.END, this.__onViewReady, this]
9202
+ ]);
9075
9203
  if (this.realCanvas)
9076
9204
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9077
9205
  }
@@ -9282,7 +9410,7 @@ MoveEvent = __decorate([
9282
9410
  registerUIEvent()
9283
9411
  ], MoveEvent);
9284
9412
 
9285
- let RotateEvent = class RotateEvent extends UIEvent {
9413
+ let RotateEvent = class RotateEvent extends PointerEvent {
9286
9414
  };
9287
9415
  RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9288
9416
  RotateEvent.START = 'rotate.start';
@@ -9303,7 +9431,7 @@ SwipeEvent = __decorate([
9303
9431
  registerUIEvent()
9304
9432
  ], SwipeEvent);
9305
9433
 
9306
- let ZoomEvent = class ZoomEvent extends UIEvent {
9434
+ let ZoomEvent = class ZoomEvent extends PointerEvent {
9307
9435
  };
9308
9436
  ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9309
9437
  ZoomEvent.START = 'zoom.start';
@@ -10146,8 +10274,8 @@ ui$5.__updateHitCanvas = function () {
10146
10274
  if (this.__box)
10147
10275
  this.__box.__updateHitCanvas();
10148
10276
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10149
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10150
- const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10277
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10278
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10151
10279
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10152
10280
  if (!this.__hitCanvas)
10153
10281
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10178,11 +10306,11 @@ ui$5.__hit = function (inner) {
10178
10306
  if (data.__isHitPixel && this.__hitPixel(inner))
10179
10307
  return true;
10180
10308
  const { hitFill } = data;
10181
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10309
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10182
10310
  if (needHitFillPath && this.__hitFill(inner))
10183
10311
  return true;
10184
10312
  const { hitStroke, __strokeWidth } = data;
10185
- const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10313
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10186
10314
  if (!needHitFillPath && !needHitStrokePath)
10187
10315
  return false;
10188
10316
  const radiusWidth = inner.radiusX * 2;
@@ -10323,31 +10451,31 @@ function fillPathOrText(ui, canvas) {
10323
10451
  }
10324
10452
 
10325
10453
  function strokeText(stroke, ui, canvas) {
10326
- const { strokeAlign } = ui.__;
10327
- const isStrokes = typeof stroke !== 'string';
10328
- switch (strokeAlign) {
10454
+ switch (ui.__.strokeAlign) {
10329
10455
  case 'center':
10330
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10331
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10456
+ drawCenter$1(stroke, 1, ui, canvas);
10332
10457
  break;
10333
10458
  case 'inside':
10334
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10459
+ drawAlign(stroke, 'inside', ui, canvas);
10335
10460
  break;
10336
10461
  case 'outside':
10337
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10462
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10338
10463
  break;
10339
10464
  }
10340
10465
  }
10341
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10342
- const { __strokeWidth, __font } = ui.__;
10466
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10467
+ const data = ui.__;
10468
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10469
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10470
+ }
10471
+ function drawAlign(stroke, align, ui, canvas) {
10343
10472
  const out = canvas.getSameCanvas(true, true);
10344
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10345
- out.font = __font;
10346
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10473
+ out.font = ui.__.__font;
10474
+ drawCenter$1(stroke, 2, ui, out);
10347
10475
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10348
10476
  fillText(ui, out);
10349
10477
  out.blendMode = 'normal';
10350
- if (ui.__worldFlipped)
10478
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10351
10479
  canvas.copyWorldByReset(out, ui.__nowWorld);
10352
10480
  else
10353
10481
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10389,90 +10517,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
10389
10517
  }
10390
10518
 
10391
10519
  function stroke(stroke, ui, canvas) {
10392
- const options = ui.__;
10393
- const { __strokeWidth, strokeAlign, __font } = options;
10394
- if (!__strokeWidth)
10520
+ const data = ui.__;
10521
+ if (!data.__strokeWidth)
10395
10522
  return;
10396
- if (__font) {
10523
+ if (data.__font) {
10397
10524
  strokeText(stroke, ui, canvas);
10398
10525
  }
10399
10526
  else {
10400
- switch (strokeAlign) {
10527
+ switch (data.strokeAlign) {
10401
10528
  case 'center':
10402
- canvas.setStroke(stroke, __strokeWidth, options);
10403
- canvas.stroke();
10404
- if (options.__useArrow)
10405
- strokeArrow(ui, canvas);
10529
+ drawCenter(stroke, 1, ui, canvas);
10406
10530
  break;
10407
10531
  case 'inside':
10408
- canvas.save();
10409
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10410
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10411
- canvas.stroke();
10412
- canvas.restore();
10532
+ drawInside(stroke, ui, canvas);
10413
10533
  break;
10414
10534
  case 'outside':
10415
- const out = canvas.getSameCanvas(true, true);
10416
- out.setStroke(stroke, __strokeWidth * 2, options);
10417
- ui.__drawRenderPath(out);
10418
- out.stroke();
10419
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10420
- out.clearWorld(ui.__layout.renderBounds);
10421
- if (ui.__worldFlipped)
10422
- canvas.copyWorldByReset(out, ui.__nowWorld);
10423
- else
10424
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10425
- out.recycle(ui.__nowWorld);
10535
+ drawOutside(stroke, ui, canvas);
10426
10536
  break;
10427
10537
  }
10428
10538
  }
10429
10539
  }
10430
10540
  function strokes(strokes, ui, canvas) {
10431
- const options = ui.__;
10432
- const { __strokeWidth, strokeAlign, __font } = options;
10433
- if (!__strokeWidth)
10434
- return;
10435
- if (__font) {
10436
- strokeText(strokes, ui, canvas);
10541
+ stroke(strokes, ui, canvas);
10542
+ }
10543
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10544
+ const data = ui.__;
10545
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10546
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10547
+ if (data.__useArrow)
10548
+ Paint.strokeArrow(stroke, ui, canvas);
10549
+ }
10550
+ function drawInside(stroke, ui, canvas) {
10551
+ const data = ui.__;
10552
+ canvas.save();
10553
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
10554
+ drawCenter(stroke, 2, ui, canvas);
10555
+ canvas.restore();
10556
+ }
10557
+ function drawOutside(stroke, ui, canvas) {
10558
+ const data = ui.__;
10559
+ if (data.__fillAfterStroke) {
10560
+ drawCenter(stroke, 2, ui, canvas);
10437
10561
  }
10438
10562
  else {
10439
- switch (strokeAlign) {
10440
- case 'center':
10441
- canvas.setStroke(undefined, __strokeWidth, options);
10442
- drawStrokesStyle(strokes, false, ui, canvas);
10443
- if (options.__useArrow)
10444
- strokeArrow(ui, canvas);
10445
- break;
10446
- case 'inside':
10447
- canvas.save();
10448
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10449
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10450
- drawStrokesStyle(strokes, false, ui, canvas);
10451
- canvas.restore();
10452
- break;
10453
- case 'outside':
10454
- const { renderBounds } = ui.__layout;
10455
- const out = canvas.getSameCanvas(true, true);
10456
- ui.__drawRenderPath(out);
10457
- out.setStroke(undefined, __strokeWidth * 2, options);
10458
- drawStrokesStyle(strokes, false, ui, out);
10459
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10460
- out.clearWorld(renderBounds);
10461
- if (ui.__worldFlipped)
10462
- canvas.copyWorldByReset(out, ui.__nowWorld);
10463
- else
10464
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10465
- out.recycle(ui.__nowWorld);
10466
- break;
10467
- }
10468
- }
10469
- }
10470
- function strokeArrow(ui, canvas) {
10471
- if (ui.__.dashPattern) {
10472
- canvas.beginPath();
10473
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10474
- canvas.dashPattern = null;
10475
- canvas.stroke();
10563
+ const { renderBounds } = ui.__layout;
10564
+ const out = canvas.getSameCanvas(true, true);
10565
+ ui.__drawRenderPath(out);
10566
+ drawCenter(stroke, 2, ui, out);
10567
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
10568
+ out.clearWorld(renderBounds);
10569
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10570
+ canvas.copyWorldByReset(out, ui.__nowWorld);
10571
+ else
10572
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10573
+ out.recycle(ui.__nowWorld);
10476
10574
  }
10477
10575
  }
10478
10576
 
@@ -10519,9 +10617,10 @@ function shape(ui, current, options) {
10519
10617
  }
10520
10618
 
10521
10619
  let recycleMap;
10620
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
10522
10621
  function compute(attrName, ui) {
10523
10622
  const data = ui.__, leafPaints = [];
10524
- let paints = data.__input[attrName], hasOpacityPixel;
10623
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
10525
10624
  if (!(paints instanceof Array))
10526
10625
  paints = [paints];
10527
10626
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -10531,29 +10630,55 @@ function compute(attrName, ui) {
10531
10630
  leafPaints.push(item);
10532
10631
  }
10533
10632
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10534
- if (leafPaints.length && leafPaints[0].image)
10535
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
10536
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
10633
+ if (leafPaints.length) {
10634
+ if (leafPaints.every(item => item.isTransparent)) {
10635
+ if (leafPaints.some(item => item.image))
10636
+ isAlphaPixel = true;
10637
+ isTransparent = true;
10638
+ }
10639
+ }
10640
+ if (attrName === 'fill') {
10641
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
10642
+ stintSet(data, '__isTransparentFill', isTransparent);
10643
+ }
10644
+ else {
10645
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10646
+ stintSet(data, '__isTransparentStroke', isTransparent);
10647
+ }
10537
10648
  }
10538
10649
  function getLeafPaint(attrName, paint, ui) {
10539
10650
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
10540
10651
  return undefined;
10652
+ let data;
10541
10653
  const { boxBounds } = ui.__layout;
10542
10654
  switch (paint.type) {
10543
- case 'solid':
10544
- let { type, blendMode, color, opacity } = paint;
10545
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
10546
10655
  case 'image':
10547
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10656
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10657
+ break;
10548
10658
  case 'linear':
10549
- return PaintGradient.linearGradient(paint, boxBounds);
10659
+ data = PaintGradient.linearGradient(paint, boxBounds);
10660
+ break;
10550
10661
  case 'radial':
10551
- return PaintGradient.radialGradient(paint, boxBounds);
10662
+ data = PaintGradient.radialGradient(paint, boxBounds);
10663
+ break;
10552
10664
  case 'angular':
10553
- return PaintGradient.conicGradient(paint, boxBounds);
10665
+ data = PaintGradient.conicGradient(paint, boxBounds);
10666
+ break;
10667
+ case 'solid':
10668
+ const { type, blendMode, color, opacity } = paint;
10669
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
10670
+ break;
10554
10671
  default:
10555
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10672
+ if (paint.r !== undefined)
10673
+ data = { type: 'solid', style: ColorConvert.string(paint) };
10674
+ }
10675
+ if (data) {
10676
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
10677
+ data.isTransparent = true;
10678
+ if (paint.blendMode)
10679
+ data.blendMode = paint.blendMode;
10556
10680
  }
10681
+ return data;
10557
10682
  }
10558
10683
 
10559
10684
  const PaintModule = {
@@ -10619,12 +10744,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
10619
10744
 
10620
10745
  const { get: get$2, translate } = MatrixHelper;
10621
10746
  const tempBox = new Bounds();
10622
- const tempPoint$1 = {};
10623
10747
  const tempScaleData = {};
10748
+ const tempImage = {};
10624
10749
  function createData(leafPaint, image, paint, box) {
10625
- const { blendMode, changeful, sync } = paint;
10626
- if (blendMode)
10627
- leafPaint.blendMode = blendMode;
10750
+ const { changeful, sync } = paint;
10628
10751
  if (changeful)
10629
10752
  leafPaint.changeful = changeful;
10630
10753
  if (sync)
@@ -10632,38 +10755,38 @@ function createData(leafPaint, image, paint, box) {
10632
10755
  leafPaint.data = getPatternData(paint, box, image);
10633
10756
  }
10634
10757
  function getPatternData(paint, box, image) {
10635
- let { width, height } = image;
10636
10758
  if (paint.padding)
10637
10759
  box = tempBox.set(box).shrink(paint.padding);
10638
10760
  if (paint.mode === 'strench')
10639
10761
  paint.mode = 'stretch';
10762
+ let { width, height } = image;
10640
10763
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
10641
10764
  const sameBox = box.width === width && box.height === height;
10642
10765
  const data = { mode };
10643
10766
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10644
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10645
- let x = 0, y = 0, scaleX, scaleY;
10767
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
10768
+ let scaleX, scaleY;
10646
10769
  if (!mode || mode === 'cover' || mode === 'fit') {
10647
10770
  if (!sameBox || rotation) {
10648
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
10649
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10650
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10771
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
10772
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
10773
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
10651
10774
  }
10652
10775
  }
10653
- else if (scale || size) {
10654
- MathHelper.getScaleData(scale, size, image, tempScaleData);
10655
- scaleX = tempScaleData.scaleX;
10656
- scaleY = tempScaleData.scaleY;
10657
- }
10658
- if (align) {
10659
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10660
- if (scaleX)
10661
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10662
- AlignHelper.toPoint(align, imageBounds, box, tempPoint$1, true);
10663
- x += tempPoint$1.x, y += tempPoint$1.y;
10776
+ else {
10777
+ if (scale || size) {
10778
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
10779
+ scaleX = tempScaleData.scaleX;
10780
+ scaleY = tempScaleData.scaleY;
10781
+ }
10782
+ if (align) {
10783
+ if (scaleX)
10784
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
10785
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
10786
+ }
10664
10787
  }
10665
10788
  if (offset)
10666
- x += offset.x, y += offset.y;
10789
+ PointHelper.move(tempImage, offset);
10667
10790
  switch (mode) {
10668
10791
  case 'stretch':
10669
10792
  if (!sameBox)
@@ -10671,12 +10794,12 @@ function getPatternData(paint, box, image) {
10671
10794
  break;
10672
10795
  case 'normal':
10673
10796
  case 'clip':
10674
- if (x || y || scaleX || rotation)
10675
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
10797
+ if (tempImage.x || tempImage.y || scaleX || rotation)
10798
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10676
10799
  break;
10677
10800
  case 'repeat':
10678
10801
  if (!sameBox || scaleX || rotation)
10679
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10802
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
10680
10803
  if (!repeat)
10681
10804
  data.repeat = 'repeat';
10682
10805
  break;
@@ -10684,7 +10807,7 @@ function getPatternData(paint, box, image) {
10684
10807
  case 'cover':
10685
10808
  default:
10686
10809
  if (scaleX)
10687
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10810
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10688
10811
  }
10689
10812
  if (!data.transform) {
10690
10813
  if (box.x || box.y) {
@@ -10717,6 +10840,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10717
10840
  }
10718
10841
  else {
10719
10842
  leafPaint = { type: paint.type, image };
10843
+ if (image.hasAlphaPixel)
10844
+ leafPaint.isTransparent = true;
10720
10845
  cache$1 = image.use > 1 ? { leafPaint, paint, boxBounds: box$1.set(boxBounds) } : null;
10721
10846
  }
10722
10847
  if (firstUse || image.loading)
@@ -10741,7 +10866,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10741
10866
  ignoreRender(ui, false);
10742
10867
  if (!ui.destroyed) {
10743
10868
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10744
- if (image.hasOpacityPixel)
10869
+ if (image.hasAlphaPixel)
10745
10870
  ui.__layout.hitCanvasChanged = true;
10746
10871
  ui.forceUpdate('surface');
10747
10872
  }
@@ -10753,13 +10878,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10753
10878
  onLoadError(ui, event, error);
10754
10879
  leafPaint.loadId = null;
10755
10880
  });
10756
- if (ui.placeholderColor)
10757
- setTimeout(() => {
10758
- if (!(image.ready || image.isPlacehold)) {
10759
- image.isPlacehold = true;
10760
- ui.forceUpdate('surface');
10761
- }
10762
- }, 100);
10881
+ if (ui.placeholderColor) {
10882
+ if (!ui.placeholderDelay)
10883
+ image.isPlacehold = true;
10884
+ else
10885
+ setTimeout(() => {
10886
+ if (!image.ready) {
10887
+ image.isPlacehold = true;
10888
+ ui.forceUpdate('surface');
10889
+ }
10890
+ }, ui.placeholderDelay);
10891
+ }
10763
10892
  }
10764
10893
  return leafPaint;
10765
10894
  }
@@ -10965,32 +11094,33 @@ const PaintImageModule = {
10965
11094
  repeatMode
10966
11095
  };
10967
11096
 
10968
- const { toPoint: toPoint$3 } = AroundHelper;
11097
+ const { toPoint: toPoint$3 } = AroundHelper, { hasTransparent } = ColorConvert;
10969
11098
  const realFrom$2 = {};
10970
11099
  const realTo$2 = {};
10971
11100
  function linearGradient(paint, box) {
10972
- let { from, to, type, blendMode, opacity } = paint;
11101
+ let { from, to, type, opacity } = paint;
10973
11102
  toPoint$3(from || 'top', box, realFrom$2);
10974
11103
  toPoint$3(to || 'bottom', box, realTo$2);
10975
11104
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
10976
- applyStops(style, paint.stops, opacity);
10977
11105
  const data = { type, style };
10978
- if (blendMode)
10979
- data.blendMode = blendMode;
11106
+ applyStops(data, style, paint.stops, opacity);
10980
11107
  return data;
10981
11108
  }
10982
- function applyStops(gradient, stops, opacity) {
11109
+ function applyStops(data, gradient, stops, opacity) {
10983
11110
  if (stops) {
10984
- let stop;
11111
+ let stop, color, offset, isTransparent;
10985
11112
  for (let i = 0, len = stops.length; i < len; i++) {
10986
11113
  stop = stops[i];
10987
- if (typeof stop === 'string') {
10988
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
10989
- }
10990
- else {
10991
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
10992
- }
11114
+ if (typeof stop === 'string')
11115
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
11116
+ else
11117
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
11118
+ gradient.addColorStop(offset, color);
11119
+ if (!isTransparent && hasTransparent(color))
11120
+ isTransparent = true;
10993
11121
  }
11122
+ if (isTransparent)
11123
+ data.isTransparent = true;
10994
11124
  }
10995
11125
  }
10996
11126
 
@@ -11000,17 +11130,15 @@ const { toPoint: toPoint$2 } = AroundHelper;
11000
11130
  const realFrom$1 = {};
11001
11131
  const realTo$1 = {};
11002
11132
  function radialGradient(paint, box) {
11003
- let { from, to, type, opacity, blendMode, stretch } = paint;
11133
+ let { from, to, type, opacity, stretch } = paint;
11004
11134
  toPoint$2(from || 'center', box, realFrom$1);
11005
11135
  toPoint$2(to || 'bottom', box, realTo$1);
11006
11136
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$2(realFrom$1, realTo$1));
11007
- applyStops(style, paint.stops, opacity);
11008
11137
  const data = { type, style };
11138
+ applyStops(data, style, paint.stops, opacity);
11009
11139
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11010
11140
  if (transform)
11011
11141
  data.transform = transform;
11012
- if (blendMode)
11013
- data.blendMode = blendMode;
11014
11142
  return data;
11015
11143
  }
11016
11144
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11036,17 +11164,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
11036
11164
  const realFrom = {};
11037
11165
  const realTo = {};
11038
11166
  function conicGradient(paint, box) {
11039
- let { from, to, type, opacity, blendMode, stretch } = paint;
11167
+ let { from, to, type, opacity, stretch } = paint;
11040
11168
  toPoint$1(from || 'center', box, realFrom);
11041
11169
  toPoint$1(to || 'bottom', box, realTo);
11042
11170
  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$1(realFrom, realTo));
11043
- applyStops(style, paint.stops, opacity);
11044
11171
  const data = { type, style };
11172
+ applyStops(data, style, paint.stops, opacity);
11045
11173
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11046
11174
  if (transform)
11047
11175
  data.transform = transform;
11048
- if (blendMode)
11049
- data.blendMode = blendMode;
11050
11176
  return data;
11051
11177
  }
11052
11178
 
@@ -11379,6 +11505,8 @@ function createRows(drawData, content, style) {
11379
11505
  lastCharType = null;
11380
11506
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11381
11507
  word = { data: [] }, row = { words: [] };
11508
+ if (__letterSpacing)
11509
+ content = [...content];
11382
11510
  for (let i = 0, len = content.length; i < len; i++) {
11383
11511
  char = content[i];
11384
11512
  if (char === '\n') {
@@ -12225,24 +12353,25 @@ class EditSelect extends Group {
12225
12353
  const { app } = editor;
12226
12354
  app.selector.proxy = editor;
12227
12355
  this.__eventIds = [
12228
- editor.on_(EditorEvent.HOVER, this.onHover, this),
12229
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12230
- app.on_(PointerEvent.MOVE, this.onPointerMove, this),
12231
- app.on_(PointerEvent.BEFORE_DOWN, this.onBeforeDown, this),
12232
- app.on_(PointerEvent.TAP, this.onTap, this),
12233
- app.on_(DragEvent.START, this.onDragStart, this, true),
12234
- app.on_(DragEvent.DRAG, this.onDrag, this),
12235
- app.on_(DragEvent.END, this.onDragEnd, this),
12236
- app.on_(MoveEvent.MOVE, this.onAutoMove, this),
12237
- app.on_([ZoomEvent.ZOOM, MoveEvent.MOVE], () => { this.editor.hoverTarget = null; }),
12356
+ editor.on_([
12357
+ [EditorEvent.HOVER, this.onHover, this],
12358
+ [EditorEvent.SELECT, this.onSelect, this]
12359
+ ]),
12360
+ app.on_([
12361
+ [PointerEvent.MOVE, this.onPointerMove, this],
12362
+ [PointerEvent.BEFORE_DOWN, this.onBeforeDown, this],
12363
+ [PointerEvent.TAP, this.onTap, this],
12364
+ [DragEvent.START, this.onDragStart, this, true],
12365
+ [DragEvent.DRAG, this.onDrag, this],
12366
+ [DragEvent.END, this.onDragEnd, this],
12367
+ [MoveEvent.MOVE, this.onAutoMove, this],
12368
+ [[ZoomEvent.ZOOM, MoveEvent.MOVE], () => { this.editor.hoverTarget = null; }],
12369
+ ])
12238
12370
  ];
12239
12371
  });
12240
12372
  }
12241
12373
  __removeListenEvents() {
12242
- if (this.__eventIds) {
12243
- this.off_(this.__eventIds);
12244
- this.__eventIds.length = 0;
12245
- }
12374
+ this.off_(this.__eventIds);
12246
12375
  }
12247
12376
  destroy() {
12248
12377
  this.editor = this.originList = this.needRemoveItem = null;
@@ -12531,6 +12660,10 @@ function toDataURL(svg, rotation) {
12531
12660
  }
12532
12661
 
12533
12662
  class EditPoint extends Box {
12663
+ constructor(data) {
12664
+ super(data);
12665
+ this.useFastShadow = true;
12666
+ }
12534
12667
  }
12535
12668
 
12536
12669
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
@@ -12801,28 +12934,29 @@ class EditBox extends Group {
12801
12934
  const { editor } = this;
12802
12935
  point.direction = direction;
12803
12936
  point.pointType = type;
12804
- point.on_(DragEvent.START, this.onDragStart, this);
12805
- point.on_(DragEvent.DRAG, this.onDrag, this);
12806
- point.on_(DragEvent.END, this.onDragEnd, this);
12807
- point.on_(PointerEvent.LEAVE, () => this.enterPoint = null);
12937
+ const events = [
12938
+ [DragEvent.START, this.onDragStart, this],
12939
+ [DragEvent.DRAG, this.onDrag, this],
12940
+ [DragEvent.END, this.onDragEnd, this],
12941
+ [PointerEvent.LEAVE, () => { this.enterPoint = null; }],
12942
+ ];
12808
12943
  if (point.name !== 'circle')
12809
- point.on_(PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(editor, e); });
12944
+ events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(editor, e); }]);
12945
+ this.__eventIds.push(point.on_(events));
12810
12946
  }
12811
12947
  __listenEvents() {
12812
12948
  const { rect, editor } = this;
12813
- this.__eventIds = [
12814
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12815
- rect.on_(DragEvent.START, this.onDragStart, this),
12816
- rect.on_(DragEvent.DRAG, editor.onMove, editor),
12817
- rect.on_(DragEvent.END, this.onDragEnd, this),
12818
- rect.on_(PointerEvent.ENTER, () => updateMoveCursor(editor)),
12819
- rect.on_(PointerEvent.DOUBLE_TAP, this.onDoubleTap, this),
12820
- rect.on_(PointerEvent.LONG_PRESS, this.onLongPress, this)
12821
- ];
12949
+ this.__eventIds.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
12950
+ [DragEvent.START, this.onDragStart, this],
12951
+ [DragEvent.DRAG, editor.onMove, editor],
12952
+ [DragEvent.END, this.onDragEnd, this],
12953
+ [PointerEvent.ENTER, () => updateMoveCursor(editor)],
12954
+ [PointerEvent.DOUBLE_TAP, this.onDoubleTap, this],
12955
+ [PointerEvent.LONG_PRESS, this.onLongPress, this]
12956
+ ]));
12822
12957
  }
12823
12958
  __removeListenEvents() {
12824
12959
  this.off_(this.__eventIds);
12825
- this.__eventIds.length = 0;
12826
12960
  }
12827
12961
  destroy() {
12828
12962
  this.editor = null;
@@ -13564,12 +13698,14 @@ class Editor extends Group {
13564
13698
  const { app, leafer, editBox, editMask } = this;
13565
13699
  this.targetEventIds = [
13566
13700
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
13567
- app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
13568
- app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13569
- app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13570
- app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13571
- app.on_([KeyEvent.HOLD, KeyEvent.UP], this.onKey, this),
13572
- app.on_(KeyEvent.DOWN, editBox.onArrow, editBox)
13701
+ app.on_([
13702
+ [RenderEvent.CHILD_START, this.onAppRenderStart, this],
13703
+ [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13704
+ [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13705
+ [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13706
+ [[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
13707
+ [KeyEvent.DOWN, editBox.onArrow, editBox]
13708
+ ])
13573
13709
  ];
13574
13710
  if (editMask.visible)
13575
13711
  editMask.forceRender();
@@ -13579,7 +13715,6 @@ class Editor extends Group {
13579
13715
  const { targetEventIds, editMask } = this;
13580
13716
  if (targetEventIds.length) {
13581
13717
  this.off_(targetEventIds);
13582
- targetEventIds.length = 0;
13583
13718
  if (editMask.visible)
13584
13719
  editMask.forceRender();
13585
13720
  }
@@ -14048,7 +14183,12 @@ Box.prototype.__scaleResize = function (scaleX, scaleY) {
14048
14183
  Plugin.add('resize');
14049
14184
 
14050
14185
  Plugin.add('editor', 'resize');
14051
- Creator.editor = function (options) { return new Editor(options); };
14186
+ Creator.editor = function (options, app) {
14187
+ const editor = new Editor(options);
14188
+ if (app)
14189
+ app.sky.add(app.editor = editor);
14190
+ return editor;
14191
+ };
14052
14192
  Box.addAttr('textBox', false, dataType);
14053
14193
  UI.addAttr('editConfig', undefined, dataType);
14054
14194
  UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
@@ -14233,31 +14373,31 @@ let TextEditor = class TextEditor extends InnerEditor {
14233
14373
  textScale *= 12 / text.fontSize;
14234
14374
  }
14235
14375
  this.textScale = textScale;
14236
- const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
14237
14376
  let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14238
14377
  if (!this.inBody)
14239
14378
  x -= window.scrollX, y -= window.scrollY;
14240
- let { width, height } = text;
14379
+ let { width, height } = text, offsetX = 0, offsetY = 0;
14241
14380
  width *= textScale, height *= textScale;
14242
14381
  const data = text.__;
14243
14382
  if (data.__autoWidth && data.autoSizeAlign) {
14244
14383
  width += 20;
14245
14384
  switch (data.textAlign) {
14246
14385
  case 'center':
14247
- x -= width / 2;
14386
+ offsetX = -width / 2;
14248
14387
  break;
14249
- case 'right': x -= width;
14388
+ case 'right': offsetX = -width;
14250
14389
  }
14251
14390
  }
14252
14391
  if (data.__autoHeight && data.autoSizeAlign) {
14253
14392
  height += 20;
14254
14393
  switch (data.verticalAlign) {
14255
14394
  case 'middle':
14256
- y -= height / 2;
14395
+ offsetY = -height / 2;
14257
14396
  break;
14258
- case 'bottom': y -= height;
14397
+ case 'bottom': offsetY = -height;
14259
14398
  }
14260
14399
  }
14400
+ const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale).translateInner(offsetX, offsetY);
14261
14401
  const { style } = this.editDom;
14262
14402
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
14263
14403
  style.left = x + 'px';
@@ -14584,6 +14724,7 @@ interaction.multiTouch = function (data, list) {
14584
14724
  return;
14585
14725
  const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
14586
14726
  Object.assign(data, center);
14727
+ data.multiTouch = true;
14587
14728
  this.pointerWaitCancel();
14588
14729
  this.rotate(getRotateEventData(rotation, data));
14589
14730
  this.zoom(getZoomEventData(scale, data));
@@ -15185,6 +15326,16 @@ Plugin.add('arrow');
15185
15326
  UI.addAttr('startArrow', 'none', arrowType);
15186
15327
  UI.addAttr('endArrow', 'none', arrowType);
15187
15328
  Object.assign(PathArrow, PathArrowModule);
15329
+ Object.assign(Paint, {
15330
+ strokeArrow(_stroke, ui, canvas) {
15331
+ if (ui.__.dashPattern) {
15332
+ canvas.beginPath();
15333
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
15334
+ canvas.dashPattern = null;
15335
+ canvas.stroke();
15336
+ }
15337
+ }
15338
+ });
15188
15339
 
15189
15340
  class FlowData extends BoxData {
15190
15341
  }
@@ -17798,10 +17949,9 @@ const ExportModule = {
17798
17949
  else {
17799
17950
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
17800
17951
  const { worldTransform, isLeafer, leafer, isFrame } = leaf;
17801
- const { slice, clip, trim, padding, onCanvas } = options;
17952
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
17802
17953
  const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
17803
17954
  const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
17804
- const screenshot = options.screenshot || leaf.isApp;
17805
17955
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
17806
17956
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
17807
17957
  if (screenshot) {
@@ -17837,11 +17987,6 @@ const ExportModule = {
17837
17987
  const scaleData = { scaleX: 1, scaleY: 1 };
17838
17988
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
17839
17989
  let pixelRatio = options.pixelRatio || 1;
17840
- if (leaf.isApp) {
17841
- scaleData.scaleX *= pixelRatio;
17842
- scaleData.scaleY *= pixelRatio;
17843
- pixelRatio = leaf.app.pixelRatio;
17844
- }
17845
17990
  let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
17846
17991
  if (clip)
17847
17992
  x += clip.x, y += clip.y, width = clip.width, height = clip.height;
@@ -17996,4 +18141,4 @@ Object.assign(Filter, {
17996
18141
  }
17997
18142
  });
17998
18143
 
17999
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, 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, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$4 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
18144
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, 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, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };