@leafer/worker 1.6.1 → 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) {
@@ -2589,7 +2615,11 @@ const BezierHelper = {
2589
2615
  const point = {};
2590
2616
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
2591
2617
  return point;
2592
- }
2618
+ },
2619
+ getDerivative(t, fromV, v1, v2, toV) {
2620
+ const o = 1 - t;
2621
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2622
+ },
2593
2623
  };
2594
2624
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
2595
2625
 
@@ -3382,7 +3412,7 @@ function canvasPatch(drawer) {
3382
3412
  }
3383
3413
 
3384
3414
  const FileHelper = {
3385
- opacityTypes: ['png', 'webp', 'svg'],
3415
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3386
3416
  upperCaseTypeMap: {},
3387
3417
  mineType(type) {
3388
3418
  if (!type || type.startsWith('image'))
@@ -3409,7 +3439,7 @@ const FileHelper = {
3409
3439
  }
3410
3440
  };
3411
3441
  const F$2 = FileHelper;
3412
- F$2.opacityTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3442
+ F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3413
3443
 
3414
3444
  const debug$c = Debug.get('TaskProcessor');
3415
3445
  class TaskItem {
@@ -3726,8 +3756,8 @@ const ImageManager = {
3726
3756
  list.length = 0;
3727
3757
  }
3728
3758
  },
3729
- hasOpacityPixel(config) {
3730
- return FileHelper.opacityTypes.some(item => I$1.isFormat(item, config));
3759
+ hasAlphaPixel(config) {
3760
+ return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3731
3761
  },
3732
3762
  isFormat(format, config) {
3733
3763
  if (config.format === format)
@@ -3765,13 +3795,16 @@ class LeaferImage {
3765
3795
  this.setView(view.config ? view.view : view);
3766
3796
  }
3767
3797
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3768
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3798
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3769
3799
  }
3770
3800
  load(onSuccess, onError) {
3771
3801
  if (!this.loading) {
3772
3802
  this.loading = true;
3803
+ let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
3804
+ if (onProgress)
3805
+ loadImage = loadImageWithProgress;
3773
3806
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
3774
- return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
3807
+ return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
3775
3808
  this.error = e;
3776
3809
  this.onComplete(false);
3777
3810
  });
@@ -3796,6 +3829,9 @@ class LeaferImage {
3796
3829
  this.view = img;
3797
3830
  this.onComplete(true);
3798
3831
  }
3832
+ onProgress(progress) {
3833
+ this.progress = progress;
3834
+ }
3799
3835
  onComplete(isSuccess) {
3800
3836
  let odd;
3801
3837
  this.waitComplete.forEach((item, index) => {
@@ -4261,13 +4297,20 @@ const LeafHelper = {
4261
4297
  if (leaf.isBranch) {
4262
4298
  const { children } = leaf;
4263
4299
  for (let i = 0, len = children.length; i < len; i++) {
4264
- updateAllWorldOpacity$1(children[i]);
4300
+ updateAllWorldOpacity(children[i]);
4265
4301
  }
4266
4302
  }
4267
4303
  },
4268
- updateAllChange(leaf) {
4269
- updateAllWorldOpacity$1(leaf);
4304
+ updateChange(leaf) {
4305
+ const layout = leaf.__layout;
4306
+ if (layout.stateStyleChanged)
4307
+ leaf.updateState();
4308
+ if (layout.opacityChanged)
4309
+ updateAllWorldOpacity(leaf);
4270
4310
  leaf.__updateChange();
4311
+ },
4312
+ updateAllChange(leaf) {
4313
+ updateChange$1(leaf);
4271
4314
  if (leaf.isBranch) {
4272
4315
  const { children } = leaf;
4273
4316
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4403,7 +4446,7 @@ const LeafHelper = {
4403
4446
  }
4404
4447
  };
4405
4448
  const L$4 = LeafHelper;
4406
- const { updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$4, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$4;
4449
+ const { updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$4, updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1 } = L$4;
4407
4450
  function getTempLocal(t, world) {
4408
4451
  t.__layout.update();
4409
4452
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -4440,7 +4483,7 @@ const LeafBoundsHelper = {
4440
4483
  }
4441
4484
  };
4442
4485
 
4443
- const { updateBounds: updateBounds$3 } = LeafHelper;
4486
+ const { updateBounds: updateBounds$4 } = LeafHelper;
4444
4487
  const BranchHelper = {
4445
4488
  sort(a, b) {
4446
4489
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4502,11 +4545,11 @@ const BranchHelper = {
4502
4545
  branch = branchStack[i];
4503
4546
  children = branch.children;
4504
4547
  for (let j = 0, len = children.length; j < len; j++) {
4505
- updateBounds$3(children[j]);
4548
+ updateBounds$4(children[j]);
4506
4549
  }
4507
4550
  if (exclude && exclude === branch)
4508
4551
  continue;
4509
- updateBounds$3(branch);
4552
+ updateBounds$4(branch);
4510
4553
  }
4511
4554
  }
4512
4555
  };
@@ -4524,7 +4567,7 @@ const WaitHelper = {
4524
4567
  }
4525
4568
  };
4526
4569
 
4527
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4570
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$3 } = LeafHelper;
4528
4571
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$9 } = BoundsHelper;
4529
4572
  const localContent = '_localContentBounds';
4530
4573
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -4568,7 +4611,9 @@ class LeafLayout {
4568
4611
  this._localRenderBounds = local;
4569
4612
  }
4570
4613
  update() {
4571
- const { leafer } = this.leaf;
4614
+ const { leaf } = this, { leafer } = leaf;
4615
+ if (leaf.isApp)
4616
+ return updateBounds$3(leaf);
4572
4617
  if (leafer) {
4573
4618
  if (leafer.ready)
4574
4619
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4576,7 +4621,7 @@ class LeafLayout {
4576
4621
  leafer.start();
4577
4622
  }
4578
4623
  else {
4579
- let root = this.leaf;
4624
+ let root = leaf;
4580
4625
  while (root.parent && !root.parent.leafer) {
4581
4626
  root = root.parent;
4582
4627
  }
@@ -4798,7 +4843,7 @@ class LeafLayout {
4798
4843
  }
4799
4844
  childrenSortChange() {
4800
4845
  if (!this.childrenSortChanged) {
4801
- this.childrenSortChanged = true;
4846
+ this.childrenSortChanged = this.affectChildrenSort = true;
4802
4847
  this.leaf.forceUpdate('surface');
4803
4848
  }
4804
4849
  }
@@ -4865,6 +4910,40 @@ ImageEvent.LOAD = 'image.load';
4865
4910
  ImageEvent.LOADED = 'image.loaded';
4866
4911
  ImageEvent.ERROR = 'image.error';
4867
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
+
4868
4947
  class ResizeEvent extends Event {
4869
4948
  get bigger() {
4870
4949
  if (!this.old)
@@ -4961,9 +5040,12 @@ class Eventer {
4961
5040
  set event(map) { this.on(map); }
4962
5041
  on(type, listener, options) {
4963
5042
  if (!listener) {
4964
- let event, map = type;
4965
- for (let key in map)
4966
- 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);
4967
5049
  return;
4968
5050
  }
4969
5051
  let capture, once;
@@ -4993,6 +5075,8 @@ class Eventer {
4993
5075
  else {
4994
5076
  map[type] = [item];
4995
5077
  }
5078
+ if (boundsEventMap[type])
5079
+ BoundsEvent.checkHas(this, type, 'on');
4996
5080
  }
4997
5081
  });
4998
5082
  }
@@ -5014,6 +5098,8 @@ class Eventer {
5014
5098
  events.splice(index, 1);
5015
5099
  if (!events.length)
5016
5100
  delete map[type];
5101
+ if (boundsEventMap[type])
5102
+ BoundsEvent.checkHas(this, type, 'off');
5017
5103
  }
5018
5104
  }
5019
5105
  });
@@ -5033,19 +5119,31 @@ class Eventer {
5033
5119
  }
5034
5120
  }
5035
5121
  on_(type, listener, bind, options) {
5036
- if (bind)
5037
- listener = listener.bind(bind);
5038
- 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);
5039
5126
  return { type, current: this, listener, options };
5040
5127
  }
5041
5128
  off_(id) {
5042
5129
  if (!id)
5043
5130
  return;
5044
5131
  const list = id instanceof Array ? id : [id];
5045
- 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
+ });
5046
5138
  list.length = 0;
5047
5139
  }
5048
- 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;
5049
5147
  this.on(type, listener, { once: true, capture });
5050
5148
  }
5051
5149
  emit(type, event, capture) {
@@ -5157,7 +5255,7 @@ const LeafDataProxy = {
5157
5255
  };
5158
5256
 
5159
5257
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5160
- const { toPoint: toPoint$4, tempPoint: tempPoint$2 } = AroundHelper;
5258
+ const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = AroundHelper;
5161
5259
  const LeafMatrix = {
5162
5260
  __updateWorldMatrix() {
5163
5261
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
@@ -5166,19 +5264,19 @@ const LeafMatrix = {
5166
5264
  if (this.__local) {
5167
5265
  const layout = this.__layout, local = this.__local, data = this.__;
5168
5266
  if (layout.affectScaleOrRotation) {
5169
- if (layout.scaleChanged || layout.rotationChanged) {
5267
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5170
5268
  setLayout(local, data, null, null, layout.affectRotation);
5171
- layout.scaleChanged = layout.rotationChanged = false;
5269
+ layout.scaleChanged = layout.rotationChanged = undefined;
5172
5270
  }
5173
5271
  }
5174
5272
  local.e = data.x + data.offsetX;
5175
5273
  local.f = data.y + data.offsetY;
5176
5274
  if (data.around || data.origin) {
5177
- toPoint$4(data.around || data.origin, layout.boxBounds, tempPoint$2);
5178
- 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);
5179
5277
  }
5180
5278
  }
5181
- this.__layout.matrixChanged = false;
5279
+ this.__layout.matrixChanged = undefined;
5182
5280
  }
5183
5281
  };
5184
5282
 
@@ -5188,11 +5286,17 @@ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$8 } =
5188
5286
  const { toBounds: toBounds$2 } = PathBounds;
5189
5287
  const LeafBounds = {
5190
5288
  __updateWorldBounds() {
5191
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5192
- if (this.__layout.resized) {
5193
- this.__onUpdateSize();
5194
- this.__layout.resized = false;
5195
- }
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;
5297
+ }
5298
+ if (this.__hasWorldEvent)
5299
+ BoundsEvent.emitWorld(this);
5196
5300
  },
5197
5301
  __updateLocalBounds() {
5198
5302
  const layout = this.__layout;
@@ -5201,12 +5305,12 @@ const LeafBounds = {
5201
5305
  this.__updatePath();
5202
5306
  this.__updateRenderPath();
5203
5307
  this.__updateBoxBounds();
5204
- layout.resized = true;
5308
+ layout.resized = 'inner';
5205
5309
  }
5206
5310
  if (layout.localBoxChanged) {
5207
5311
  if (this.__local)
5208
5312
  this.__updateLocalBoxBounds();
5209
- layout.localBoxChanged = false;
5313
+ layout.localBoxChanged = undefined;
5210
5314
  if (layout.strokeSpread)
5211
5315
  layout.strokeChanged = true;
5212
5316
  if (layout.renderSpread)
@@ -5214,7 +5318,7 @@ const LeafBounds = {
5214
5318
  if (this.parent)
5215
5319
  this.parent.__layout.boxChange();
5216
5320
  }
5217
- layout.boxChanged = false;
5321
+ layout.boxChanged = undefined;
5218
5322
  if (layout.strokeChanged) {
5219
5323
  layout.strokeSpread = this.__updateStrokeSpread();
5220
5324
  if (layout.strokeSpread) {
@@ -5226,12 +5330,12 @@ const LeafBounds = {
5226
5330
  else {
5227
5331
  layout.spreadStrokeCancel();
5228
5332
  }
5229
- layout.strokeChanged = false;
5333
+ layout.strokeChanged = undefined;
5230
5334
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5231
5335
  layout.renderChanged = true;
5232
5336
  if (this.parent)
5233
5337
  this.parent.__layout.strokeChange();
5234
- layout.resized = true;
5338
+ layout.resized = 'inner';
5235
5339
  }
5236
5340
  if (layout.renderChanged) {
5237
5341
  layout.renderSpread = this.__updateRenderSpread();
@@ -5244,11 +5348,12 @@ const LeafBounds = {
5244
5348
  else {
5245
5349
  layout.spreadRenderCancel();
5246
5350
  }
5247
- layout.renderChanged = false;
5351
+ layout.renderChanged = undefined;
5248
5352
  if (this.parent)
5249
5353
  this.parent.__layout.renderChange();
5250
5354
  }
5251
- layout.boundsChanged = false;
5355
+ layout.resized || (layout.resized = 'local');
5356
+ layout.boundsChanged = undefined;
5252
5357
  },
5253
5358
  __updateLocalBoxBounds() {
5254
5359
  if (this.__hasMotionPath)
@@ -5788,7 +5893,7 @@ let Leaf = class Leaf {
5788
5893
  off(_type, _listener, _options) { }
5789
5894
  on_(_type, _listener, _bind, _options) { return undefined; }
5790
5895
  off_(_id) { }
5791
- once(_type, _listener, _capture) { }
5896
+ once(_type, _listener, _captureOrBind, _capture) { }
5792
5897
  emit(_type, _event, _capture) { }
5793
5898
  emitEvent(_event, _capture) { }
5794
5899
  hasEvent(_type, _capture) { return false; }
@@ -6125,7 +6230,7 @@ class LeafLevelList {
6125
6230
  }
6126
6231
  }
6127
6232
 
6128
- const version = "1.6.1";
6233
+ const version = "1.6.3";
6129
6234
 
6130
6235
  class LeaferCanvas extends LeaferCanvasBase {
6131
6236
  get allowBackgroundColor() { return true; }
@@ -6284,17 +6389,15 @@ class Watcher {
6284
6389
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6285
6390
  this.__updatedList = new LeafList();
6286
6391
  this.totalTimes++;
6287
- this.changed = false;
6288
- this.hasVisible = false;
6289
- this.hasRemove = false;
6290
- this.hasAdd = false;
6392
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6291
6393
  }
6292
6394
  __listenEvents() {
6293
- const { target } = this;
6294
6395
  this.__eventIds = [
6295
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6296
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6297
- 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
+ ])
6298
6401
  ];
6299
6402
  }
6300
6403
  __removeListenEvents() {
@@ -6304,13 +6407,12 @@ class Watcher {
6304
6407
  if (this.target) {
6305
6408
  this.stop();
6306
6409
  this.__removeListenEvents();
6307
- this.target = null;
6308
- this.__updatedList = null;
6410
+ this.target = this.__updatedList = null;
6309
6411
  }
6310
6412
  }
6311
6413
  }
6312
6414
 
6313
- const { updateAllMatrix: updateAllMatrix$2, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6415
+ const { updateAllMatrix: updateAllMatrix$2, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6314
6416
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6315
6417
  function updateMatrix$2(updateList, levelList) {
6316
6418
  let layout;
@@ -6353,15 +6455,7 @@ function updateBounds$1(boundsList) {
6353
6455
  });
6354
6456
  }
6355
6457
  function updateChange(updateList) {
6356
- let layout;
6357
- updateList.list.forEach(leaf => {
6358
- layout = leaf.__layout;
6359
- if (layout.opacityChanged)
6360
- updateAllWorldOpacity(leaf);
6361
- if (layout.stateStyleChanged)
6362
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6363
- leaf.__updateChange();
6364
- });
6458
+ updateList.list.forEach(updateOneChange);
6365
6459
  }
6366
6460
 
6367
6461
  const { worldBounds: worldBounds$1 } = LeafBoundsHelper;
@@ -6418,7 +6512,7 @@ class Layouter {
6418
6512
  this.disabled = true;
6419
6513
  }
6420
6514
  layout() {
6421
- if (!this.running)
6515
+ if (this.layouting || !this.running)
6422
6516
  return;
6423
6517
  const { target } = this;
6424
6518
  this.times = 0;
@@ -6501,12 +6595,10 @@ class Layouter {
6501
6595
  }
6502
6596
  static fullLayout(target) {
6503
6597
  updateAllMatrix$1(target, true);
6504
- if (target.isBranch) {
6598
+ if (target.isBranch)
6505
6599
  BranchHelper.updateBounds(target);
6506
- }
6507
- else {
6600
+ else
6508
6601
  LeafHelper.updateBounds(target);
6509
- }
6510
6602
  updateAllChange(target);
6511
6603
  }
6512
6604
  addExtra(leaf) {
@@ -6529,11 +6621,12 @@ class Layouter {
6529
6621
  this.__updatedList = event.data.updatedList;
6530
6622
  }
6531
6623
  __listenEvents() {
6532
- const { target } = this;
6533
6624
  this.__eventIds = [
6534
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6535
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6536
- 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
+ ])
6537
6630
  ];
6538
6631
  }
6539
6632
  __removeListenEvents() {
@@ -6764,12 +6857,13 @@ class Renderer {
6764
6857
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6765
6858
  }
6766
6859
  __listenEvents() {
6767
- const { target } = this;
6768
6860
  this.__eventIds = [
6769
- target.on_(RenderEvent.REQUEST, this.update, this),
6770
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6771
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6772
- 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
+ ])
6773
6867
  ];
6774
6868
  }
6775
6869
  __removeListenEvents() {
@@ -6985,8 +7079,32 @@ function zoomLayerType() {
6985
7079
  };
6986
7080
  }
6987
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
+
6988
7104
  const TextConvert = {};
6989
- const ColorConvert = {};
7105
+ const ColorConvert = {
7106
+ hasTransparent: hasTransparent$3
7107
+ };
6990
7108
  const UnitConvert = {
6991
7109
  number(value, percentRefer) {
6992
7110
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7012,6 +7130,7 @@ const Transition = {
7012
7130
  };
7013
7131
 
7014
7132
  const { parse, objectToCanvasData } = PathConvert;
7133
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7015
7134
  const emptyPaint = {};
7016
7135
  const debug$5 = Debug.get('UIData');
7017
7136
  class UIData extends LeafData {
@@ -7070,38 +7189,22 @@ class UIData extends LeafData {
7070
7189
  if (this.__naturalWidth)
7071
7190
  this.__removeNaturalSize();
7072
7191
  if (typeof value === 'string' || !value) {
7073
- if (this.__isFills) {
7074
- this.__removeInput('fill');
7075
- PaintImage.recycleImage('fill', this);
7076
- this.__isFills = false;
7077
- this.__pixelFill && (this.__pixelFill = false);
7078
- }
7192
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7193
+ this.__isFills && this.__removePaint('fill', true);
7079
7194
  this._fill = value;
7080
7195
  }
7081
7196
  else if (typeof value === 'object') {
7082
- this.__setInput('fill', value);
7083
- const layout = this.__leaf.__layout;
7084
- layout.boxChanged || layout.boxChange();
7085
- this.__isFills = true;
7086
- this._fill || (this._fill = emptyPaint);
7197
+ this.__setPaint('fill', value);
7087
7198
  }
7088
7199
  }
7089
7200
  setStroke(value) {
7090
7201
  if (typeof value === 'string' || !value) {
7091
- if (this.__isStrokes) {
7092
- this.__removeInput('stroke');
7093
- PaintImage.recycleImage('stroke', this);
7094
- this.__isStrokes = false;
7095
- this.__pixelStroke && (this.__pixelStroke = false);
7096
- }
7202
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7203
+ this.__isStrokes && this.__removePaint('stroke', true);
7097
7204
  this._stroke = value;
7098
7205
  }
7099
7206
  else if (typeof value === 'object') {
7100
- this.__setInput('stroke', value);
7101
- const layout = this.__leaf.__layout;
7102
- layout.boxChanged || layout.boxChange();
7103
- this.__isStrokes = true;
7104
- this._stroke || (this._stroke = emptyPaint);
7207
+ this.__setPaint('stroke', value);
7105
7208
  }
7106
7209
  }
7107
7210
  setPath(value) {
@@ -7131,7 +7234,34 @@ class UIData extends LeafData {
7131
7234
  Paint.compute('fill', this.__leaf);
7132
7235
  if (stroke)
7133
7236
  Paint.compute('stroke', this.__leaf);
7134
- 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
+ }
7135
7265
  }
7136
7266
  }
7137
7267
  function setArray(data, key, value) {
@@ -7139,10 +7269,10 @@ function setArray(data, key, value) {
7139
7269
  if (value instanceof Array) {
7140
7270
  if (value.some((item) => item.visible === false))
7141
7271
  value = value.filter((item) => item.visible !== false);
7142
- value.length || (value = null);
7272
+ value.length || (value = undefined);
7143
7273
  }
7144
7274
  else
7145
- value = value && value.visible !== false ? [value] : null;
7275
+ value = value && value.visible !== false ? [value] : undefined;
7146
7276
  data['_' + key] = value;
7147
7277
  }
7148
7278
 
@@ -7206,13 +7336,11 @@ class TextData extends UIData {
7206
7336
  setFontWeight(value) {
7207
7337
  if (typeof value === 'string') {
7208
7338
  this.__setInput('fontWeight', value);
7209
- this._fontWeight = fontWeightMap[value] || 400;
7210
- }
7211
- else {
7212
- if (this.__input)
7213
- this.__removeInput('fontWeight');
7214
- this._fontWeight = value;
7339
+ value = fontWeightMap[value] || 400;
7215
7340
  }
7341
+ else if (this.__input)
7342
+ this.__removeInput('fontWeight');
7343
+ this._fontWeight = value;
7216
7344
  }
7217
7345
  setBoxStyle(value) {
7218
7346
  let t = this.__leaf, box = t.__box;
@@ -7247,8 +7375,6 @@ class ImageData extends RectData {
7247
7375
  this._url = value;
7248
7376
  }
7249
7377
  __setImageFill(value) {
7250
- if (this.__leaf.image)
7251
- this.__leaf.image = null;
7252
7378
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7253
7379
  }
7254
7380
  __getData() {
@@ -7314,21 +7440,19 @@ const UIBounds = {
7314
7440
  }
7315
7441
  };
7316
7442
 
7443
+ const { stintSet: stintSet$1 } = DataHelper;
7317
7444
  const UIRender = {
7318
7445
  __updateChange() {
7319
- const data = this.__, w = this.__world;
7446
+ const data = this.__;
7320
7447
  if (data.__useEffect) {
7321
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7322
- 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);
7323
7451
  }
7324
- const half = data.__hasHalf;
7325
- 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);
7326
7454
  data.__checkSingle();
7327
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7328
- if (complex)
7329
- data.__complex = true;
7330
- else
7331
- data.__complex && (data.__complex = false);
7455
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7332
7456
  },
7333
7457
  __drawFast(canvas, options) {
7334
7458
  drawFast(this, canvas, options);
@@ -7338,21 +7462,23 @@ const UIRender = {
7338
7462
  if (data.__complex) {
7339
7463
  if (data.__needComputePaint)
7340
7464
  data.__computePaint();
7341
- const { fill, stroke, __drawAfterFill } = data;
7465
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7342
7466
  this.__drawRenderPath(canvas);
7343
- if (data.__useEffect) {
7467
+ if (data.__useEffect && !__isFastShadow) {
7344
7468
  const shape = Paint.shape(this, canvas, options);
7345
7469
  this.__nowWorld = this.__getNowWorld(options);
7346
7470
  const { shadow, innerShadow, filter } = data;
7347
7471
  if (shadow)
7348
7472
  Effect.shadow(this, canvas, shape);
7473
+ if (__fillAfterStroke)
7474
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7349
7475
  if (fill)
7350
7476
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7351
7477
  if (__drawAfterFill)
7352
7478
  this.__drawAfterFill(canvas, options);
7353
7479
  if (innerShadow)
7354
7480
  Effect.innerShadow(this, canvas, shape);
7355
- if (stroke)
7481
+ if (stroke && !__fillAfterStroke)
7356
7482
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7357
7483
  if (filter)
7358
7484
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7361,21 +7487,27 @@ const UIRender = {
7361
7487
  shape.canvas.recycle();
7362
7488
  }
7363
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
+ }
7364
7496
  if (fill)
7365
7497
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7498
+ if (__isFastShadow)
7499
+ canvas.restore();
7366
7500
  if (__drawAfterFill)
7367
7501
  this.__drawAfterFill(canvas, options);
7368
- if (stroke)
7502
+ if (stroke && !__fillAfterStroke)
7369
7503
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7370
7504
  }
7371
7505
  }
7372
7506
  else {
7373
- if (data.__pathInputed) {
7507
+ if (data.__pathInputed)
7374
7508
  drawFast(this, canvas, options);
7375
- }
7376
- else {
7509
+ else
7377
7510
  this.__drawFast(canvas, options);
7378
- }
7379
7511
  }
7380
7512
  },
7381
7513
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7384,11 +7516,11 @@ const UIRender = {
7384
7516
  const { fill, stroke } = this.__;
7385
7517
  this.__drawRenderPath(canvas);
7386
7518
  if (fill && !ignoreFill)
7387
- 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);
7388
7520
  if (this.__.__isCanvas)
7389
7521
  this.__drawAfterFill(canvas, options);
7390
7522
  if (stroke && !ignoreStroke)
7391
- 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);
7392
7524
  }
7393
7525
  },
7394
7526
  __drawAfterFill(canvas, options) {
@@ -7403,13 +7535,15 @@ const UIRender = {
7403
7535
  }
7404
7536
  };
7405
7537
  function drawFast(ui, canvas, options) {
7406
- const { fill, stroke, __drawAfterFill } = ui.__;
7538
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7407
7539
  ui.__drawRenderPath(canvas);
7540
+ if (__fillAfterStroke)
7541
+ Paint.stroke(stroke, ui, canvas);
7408
7542
  if (fill)
7409
7543
  Paint.fill(fill, ui, canvas);
7410
7544
  if (__drawAfterFill)
7411
7545
  ui.__drawAfterFill(canvas, options);
7412
- if (stroke)
7546
+ if (stroke && !__fillAfterStroke)
7413
7547
  Paint.stroke(stroke, ui, canvas);
7414
7548
  }
7415
7549
 
@@ -7539,6 +7673,9 @@ let UI = UI_1 = class UI extends Leaf {
7539
7673
  else
7540
7674
  drawer.rect(x, y, width, height);
7541
7675
  }
7676
+ drawImagePlaceholder(canvas, _image) {
7677
+ Paint.fill(this.__.placeholderColor, this, canvas);
7678
+ }
7542
7679
  animate(_keyframe, _options, _type, _isTemp) {
7543
7680
  return Plugin.need('animate');
7544
7681
  }
@@ -7775,6 +7912,12 @@ __decorate([
7775
7912
  __decorate([
7776
7913
  effectType()
7777
7914
  ], UI.prototype, "filter", void 0);
7915
+ __decorate([
7916
+ surfaceType()
7917
+ ], UI.prototype, "placeholderColor", void 0);
7918
+ __decorate([
7919
+ dataType(100)
7920
+ ], UI.prototype, "placeholderDelay", void 0);
7778
7921
  __decorate([
7779
7922
  dataType({})
7780
7923
  ], UI.prototype, "data", void 0);
@@ -8176,15 +8319,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8176
8319
  }
8177
8320
  __listenEvents() {
8178
8321
  const runId = Run.start('FirstCreate ' + this.innerName);
8179
- this.once(LeaferEvent.START, () => Run.end(runId));
8180
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8181
- this.once(RenderEvent.START, () => this.__onCreated());
8182
- this.once(RenderEvent.END, () => this.__onViewReady());
8183
- 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
+ ]));
8184
8333
  }
8185
8334
  __removeListenEvents() {
8186
8335
  this.off_(this.__eventIds);
8187
- this.__eventIds.length = 0;
8188
8336
  }
8189
8337
  destroy(sync) {
8190
8338
  const doDestory = () => {
@@ -8292,13 +8440,13 @@ let Box = class Box extends Group {
8292
8440
  super.__updateRenderBounds();
8293
8441
  copy$6(childrenRenderBounds, renderBounds);
8294
8442
  this.__updateRectRenderBounds();
8295
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8443
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8296
8444
  if (isOverflow && this.__.overflow !== 'hide')
8297
8445
  add(renderBounds, childrenRenderBounds);
8298
8446
  }
8299
8447
  else
8300
8448
  this.__updateRectRenderBounds();
8301
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8449
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8302
8450
  }
8303
8451
  __updateRectRenderBounds() { }
8304
8452
  __updateRectChange() { }
@@ -8602,17 +8750,10 @@ Star = __decorate([
8602
8750
 
8603
8751
  let Image = class Image extends Rect {
8604
8752
  get __tag() { return 'Image'; }
8605
- 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; }
8606
8755
  constructor(data) {
8607
8756
  super(data);
8608
- this.on(ImageEvent.LOADED, (e) => {
8609
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8610
- this.image = e.image;
8611
- });
8612
- }
8613
- destroy() {
8614
- this.image = null;
8615
- super.destroy();
8616
8757
  }
8617
8758
  };
8618
8759
  __decorate([
@@ -8628,11 +8769,11 @@ const MyImage = Image;
8628
8769
 
8629
8770
  let Canvas = class Canvas extends Rect {
8630
8771
  get __tag() { return 'Canvas'; }
8772
+ get context() { return this.canvas.context; }
8631
8773
  get ready() { return !this.url; }
8632
8774
  constructor(data) {
8633
8775
  super(data);
8634
8776
  this.canvas = Creator.canvas(this.__);
8635
- this.context = this.canvas.context;
8636
8777
  if (data && data.url)
8637
8778
  this.drawImage(data.url);
8638
8779
  }
@@ -8676,7 +8817,7 @@ let Canvas = class Canvas extends Rect {
8676
8817
  destroy() {
8677
8818
  if (this.canvas) {
8678
8819
  this.canvas.destroy();
8679
- this.canvas = this.context = null;
8820
+ this.canvas = null;
8680
8821
  }
8681
8822
  super.destroy();
8682
8823
  }
@@ -8722,7 +8863,7 @@ let Text = class Text extends UI {
8722
8863
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8723
8864
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8724
8865
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8725
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8866
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8726
8867
  }
8727
8868
  __updateBoxBounds() {
8728
8869
  const data = this.__;
@@ -8752,12 +8893,11 @@ let Text = class Text extends UI {
8752
8893
  super.__updateBoxBounds();
8753
8894
  if (italic)
8754
8895
  b.width += fontSize * 0.16;
8755
- const isOverflow = !includes(b, contentBounds) || undefined;
8756
- if (isOverflow)
8896
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8897
+ if (this.isOverflow)
8757
8898
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8758
8899
  else
8759
8900
  data.__textBoxBounds = b;
8760
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8761
8901
  }
8762
8902
  __onUpdateSize() {
8763
8903
  if (this.__box)
@@ -8820,6 +8960,9 @@ __decorate([
8820
8960
  __decorate([
8821
8961
  boundsType('')
8822
8962
  ], Text.prototype, "text", void 0);
8963
+ __decorate([
8964
+ boundsType('')
8965
+ ], Text.prototype, "placeholder", void 0);
8823
8966
  __decorate([
8824
8967
  boundsType('caption')
8825
8968
  ], Text.prototype, "fontFamily", void 0);
@@ -8955,7 +9098,7 @@ let App = class App extends Leafer {
8955
9098
  if (sky || editor)
8956
9099
  this.sky = this.addLeafer(sky);
8957
9100
  if (editor)
8958
- this.sky.add(this.editor = Creator.editor(editor));
9101
+ Creator.editor(editor, this);
8959
9102
  }
8960
9103
  }
8961
9104
  __setApp() {
@@ -8969,6 +9112,10 @@ let App = class App extends Leafer {
8969
9112
  this.watcher.disable();
8970
9113
  this.layouter.disable();
8971
9114
  }
9115
+ __updateLocalBounds() {
9116
+ this.forEach(leafer => leafer.updateLayout());
9117
+ super.__updateLocalBounds();
9118
+ }
8972
9119
  start() {
8973
9120
  super.start();
8974
9121
  this.forEach(leafer => leafer.start());
@@ -9026,12 +9173,8 @@ let App = class App extends Leafer {
9026
9173
  this.renderer.update();
9027
9174
  }
9028
9175
  __render(canvas, options) {
9029
- if (canvas.context) {
9030
- const m = options.matrix;
9031
- if (m)
9032
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9033
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9034
- }
9176
+ if (canvas.context)
9177
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9035
9178
  }
9036
9179
  __onResize(event) {
9037
9180
  this.forEach(leafer => leafer.resize(event));
@@ -9052,9 +9195,11 @@ let App = class App extends Leafer {
9052
9195
  return config;
9053
9196
  }
9054
9197
  __listenChildEvents(leafer) {
9055
- leafer.once(LayoutEvent.END, () => this.__onReady());
9056
- leafer.once(RenderEvent.START, () => this.__onCreated());
9057
- 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
+ ]);
9058
9203
  if (this.realCanvas)
9059
9204
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9060
9205
  }
@@ -9265,7 +9410,7 @@ MoveEvent = __decorate([
9265
9410
  registerUIEvent()
9266
9411
  ], MoveEvent);
9267
9412
 
9268
- let RotateEvent = class RotateEvent extends UIEvent {
9413
+ let RotateEvent = class RotateEvent extends PointerEvent {
9269
9414
  };
9270
9415
  RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9271
9416
  RotateEvent.START = 'rotate.start';
@@ -9286,7 +9431,7 @@ SwipeEvent = __decorate([
9286
9431
  registerUIEvent()
9287
9432
  ], SwipeEvent);
9288
9433
 
9289
- let ZoomEvent = class ZoomEvent extends UIEvent {
9434
+ let ZoomEvent = class ZoomEvent extends PointerEvent {
9290
9435
  };
9291
9436
  ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9292
9437
  ZoomEvent.START = 'zoom.start';
@@ -10129,8 +10274,8 @@ ui$5.__updateHitCanvas = function () {
10129
10274
  if (this.__box)
10130
10275
  this.__box.__updateHitCanvas();
10131
10276
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10132
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10133
- 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';
10134
10279
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10135
10280
  if (!this.__hitCanvas)
10136
10281
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10161,11 +10306,11 @@ ui$5.__hit = function (inner) {
10161
10306
  if (data.__isHitPixel && this.__hitPixel(inner))
10162
10307
  return true;
10163
10308
  const { hitFill } = data;
10164
- 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';
10165
10310
  if (needHitFillPath && this.__hitFill(inner))
10166
10311
  return true;
10167
10312
  const { hitStroke, __strokeWidth } = data;
10168
- 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';
10169
10314
  if (!needHitFillPath && !needHitStrokePath)
10170
10315
  return false;
10171
10316
  const radiusWidth = inner.radiusX * 2;
@@ -10245,8 +10390,10 @@ canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10245
10390
  };
10246
10391
 
10247
10392
  function fillText(ui, canvas) {
10248
- let row, data = ui.__.__textDrawData;
10249
- const { rows, decorationY } = data;
10393
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10394
+ if (data.__isPlacehold && data.placeholderColor)
10395
+ canvas.fillStyle = data.placeholderColor;
10396
+ let row;
10250
10397
  for (let i = 0, len = rows.length; i < len; i++) {
10251
10398
  row = rows[i];
10252
10399
  if (row.text)
@@ -10255,7 +10402,7 @@ function fillText(ui, canvas) {
10255
10402
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10256
10403
  }
10257
10404
  if (decorationY) {
10258
- const { decorationColor, decorationHeight } = data;
10405
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10259
10406
  if (decorationColor)
10260
10407
  canvas.fillStyle = decorationColor;
10261
10408
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10264,65 +10411,71 @@ function fillText(ui, canvas) {
10264
10411
 
10265
10412
  function fill(fill, ui, canvas) {
10266
10413
  canvas.fillStyle = fill;
10267
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10414
+ fillPathOrText(ui, canvas);
10268
10415
  }
10269
10416
  function fills(fills, ui, canvas) {
10270
10417
  let item;
10271
- const { windingRule, __font } = ui.__;
10272
10418
  for (let i = 0, len = fills.length; i < len; i++) {
10273
10419
  item = fills[i];
10274
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10275
- continue;
10276
- if (item.style) {
10277
- canvas.fillStyle = item.style;
10278
- if (item.transform) {
10279
- canvas.save();
10280
- canvas.transform(item.transform);
10281
- if (item.blendMode)
10282
- canvas.blendMode = item.blendMode;
10283
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10284
- canvas.restore();
10420
+ if (item.image) {
10421
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10422
+ continue;
10423
+ if (!item.style) {
10424
+ if (!i && item.image.isPlacehold)
10425
+ ui.drawImagePlaceholder(canvas, item.image);
10426
+ continue;
10285
10427
  }
10286
- else {
10287
- if (item.blendMode) {
10288
- canvas.saveBlendMode(item.blendMode);
10289
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10290
- canvas.restoreBlendMode();
10291
- }
10292
- else {
10293
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10294
- }
10428
+ }
10429
+ canvas.fillStyle = item.style;
10430
+ if (item.transform) {
10431
+ canvas.save();
10432
+ canvas.transform(item.transform);
10433
+ if (item.blendMode)
10434
+ canvas.blendMode = item.blendMode;
10435
+ fillPathOrText(ui, canvas);
10436
+ canvas.restore();
10437
+ }
10438
+ else {
10439
+ if (item.blendMode) {
10440
+ canvas.saveBlendMode(item.blendMode);
10441
+ fillPathOrText(ui, canvas);
10442
+ canvas.restoreBlendMode();
10295
10443
  }
10444
+ else
10445
+ fillPathOrText(ui, canvas);
10296
10446
  }
10297
10447
  }
10298
10448
  }
10449
+ function fillPathOrText(ui, canvas) {
10450
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10451
+ }
10299
10452
 
10300
10453
  function strokeText(stroke, ui, canvas) {
10301
- const { strokeAlign } = ui.__;
10302
- const isStrokes = typeof stroke !== 'string';
10303
- switch (strokeAlign) {
10454
+ switch (ui.__.strokeAlign) {
10304
10455
  case 'center':
10305
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10306
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10456
+ drawCenter$1(stroke, 1, ui, canvas);
10307
10457
  break;
10308
10458
  case 'inside':
10309
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10459
+ drawAlign(stroke, 'inside', ui, canvas);
10310
10460
  break;
10311
10461
  case 'outside':
10312
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10462
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10313
10463
  break;
10314
10464
  }
10315
10465
  }
10316
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10317
- 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) {
10318
10472
  const out = canvas.getSameCanvas(true, true);
10319
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10320
- out.font = __font;
10321
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10473
+ out.font = ui.__.__font;
10474
+ drawCenter$1(stroke, 2, ui, out);
10322
10475
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10323
10476
  fillText(ui, out);
10324
10477
  out.blendMode = 'normal';
10325
- if (ui.__worldFlipped)
10478
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10326
10479
  canvas.copyWorldByReset(out, ui.__nowWorld);
10327
10480
  else
10328
10481
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10364,90 +10517,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
10364
10517
  }
10365
10518
 
10366
10519
  function stroke(stroke, ui, canvas) {
10367
- const options = ui.__;
10368
- const { __strokeWidth, strokeAlign, __font } = options;
10369
- if (!__strokeWidth)
10520
+ const data = ui.__;
10521
+ if (!data.__strokeWidth)
10370
10522
  return;
10371
- if (__font) {
10523
+ if (data.__font) {
10372
10524
  strokeText(stroke, ui, canvas);
10373
10525
  }
10374
10526
  else {
10375
- switch (strokeAlign) {
10527
+ switch (data.strokeAlign) {
10376
10528
  case 'center':
10377
- canvas.setStroke(stroke, __strokeWidth, options);
10378
- canvas.stroke();
10379
- if (options.__useArrow)
10380
- strokeArrow(ui, canvas);
10529
+ drawCenter(stroke, 1, ui, canvas);
10381
10530
  break;
10382
10531
  case 'inside':
10383
- canvas.save();
10384
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10385
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10386
- canvas.stroke();
10387
- canvas.restore();
10532
+ drawInside(stroke, ui, canvas);
10388
10533
  break;
10389
10534
  case 'outside':
10390
- const out = canvas.getSameCanvas(true, true);
10391
- out.setStroke(stroke, __strokeWidth * 2, options);
10392
- ui.__drawRenderPath(out);
10393
- out.stroke();
10394
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10395
- out.clearWorld(ui.__layout.renderBounds);
10396
- if (ui.__worldFlipped)
10397
- canvas.copyWorldByReset(out, ui.__nowWorld);
10398
- else
10399
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10400
- out.recycle(ui.__nowWorld);
10535
+ drawOutside(stroke, ui, canvas);
10401
10536
  break;
10402
10537
  }
10403
10538
  }
10404
10539
  }
10405
10540
  function strokes(strokes, ui, canvas) {
10406
- const options = ui.__;
10407
- const { __strokeWidth, strokeAlign, __font } = options;
10408
- if (!__strokeWidth)
10409
- return;
10410
- if (__font) {
10411
- 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);
10412
10561
  }
10413
10562
  else {
10414
- switch (strokeAlign) {
10415
- case 'center':
10416
- canvas.setStroke(undefined, __strokeWidth, options);
10417
- drawStrokesStyle(strokes, false, ui, canvas);
10418
- if (options.__useArrow)
10419
- strokeArrow(ui, canvas);
10420
- break;
10421
- case 'inside':
10422
- canvas.save();
10423
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10424
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10425
- drawStrokesStyle(strokes, false, ui, canvas);
10426
- canvas.restore();
10427
- break;
10428
- case 'outside':
10429
- const { renderBounds } = ui.__layout;
10430
- const out = canvas.getSameCanvas(true, true);
10431
- ui.__drawRenderPath(out);
10432
- out.setStroke(undefined, __strokeWidth * 2, options);
10433
- drawStrokesStyle(strokes, false, ui, out);
10434
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10435
- out.clearWorld(renderBounds);
10436
- if (ui.__worldFlipped)
10437
- canvas.copyWorldByReset(out, ui.__nowWorld);
10438
- else
10439
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10440
- out.recycle(ui.__nowWorld);
10441
- break;
10442
- }
10443
- }
10444
- }
10445
- function strokeArrow(ui, canvas) {
10446
- if (ui.__.dashPattern) {
10447
- canvas.beginPath();
10448
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10449
- canvas.dashPattern = null;
10450
- 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);
10451
10574
  }
10452
10575
  }
10453
10576
 
@@ -10494,9 +10617,10 @@ function shape(ui, current, options) {
10494
10617
  }
10495
10618
 
10496
10619
  let recycleMap;
10620
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
10497
10621
  function compute(attrName, ui) {
10498
10622
  const data = ui.__, leafPaints = [];
10499
- let paints = data.__input[attrName], hasOpacityPixel;
10623
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
10500
10624
  if (!(paints instanceof Array))
10501
10625
  paints = [paints];
10502
10626
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -10506,35 +10630,62 @@ function compute(attrName, ui) {
10506
10630
  leafPaints.push(item);
10507
10631
  }
10508
10632
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10509
- if (leafPaints.length && leafPaints[0].image)
10510
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
10511
- 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
+ }
10512
10648
  }
10513
10649
  function getLeafPaint(attrName, paint, ui) {
10514
10650
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
10515
10651
  return undefined;
10652
+ let data;
10516
10653
  const { boxBounds } = ui.__layout;
10517
10654
  switch (paint.type) {
10518
- case 'solid':
10519
- let { type, blendMode, color, opacity } = paint;
10520
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
10521
10655
  case 'image':
10522
- 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;
10523
10658
  case 'linear':
10524
- return PaintGradient.linearGradient(paint, boxBounds);
10659
+ data = PaintGradient.linearGradient(paint, boxBounds);
10660
+ break;
10525
10661
  case 'radial':
10526
- return PaintGradient.radialGradient(paint, boxBounds);
10662
+ data = PaintGradient.radialGradient(paint, boxBounds);
10663
+ break;
10527
10664
  case 'angular':
10528
- 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;
10529
10671
  default:
10530
- 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;
10531
10680
  }
10681
+ return data;
10532
10682
  }
10533
10683
 
10534
10684
  const PaintModule = {
10535
10685
  compute,
10536
10686
  fill,
10537
10687
  fills,
10688
+ fillPathOrText,
10538
10689
  fillText,
10539
10690
  stroke,
10540
10691
  strokes,
@@ -10593,12 +10744,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
10593
10744
 
10594
10745
  const { get: get$2, translate } = MatrixHelper;
10595
10746
  const tempBox = new Bounds();
10596
- const tempPoint$1 = {};
10597
10747
  const tempScaleData = {};
10748
+ const tempImage = {};
10598
10749
  function createData(leafPaint, image, paint, box) {
10599
- const { blendMode, changeful, sync } = paint;
10600
- if (blendMode)
10601
- leafPaint.blendMode = blendMode;
10750
+ const { changeful, sync } = paint;
10602
10751
  if (changeful)
10603
10752
  leafPaint.changeful = changeful;
10604
10753
  if (sync)
@@ -10606,38 +10755,38 @@ function createData(leafPaint, image, paint, box) {
10606
10755
  leafPaint.data = getPatternData(paint, box, image);
10607
10756
  }
10608
10757
  function getPatternData(paint, box, image) {
10609
- let { width, height } = image;
10610
10758
  if (paint.padding)
10611
10759
  box = tempBox.set(box).shrink(paint.padding);
10612
10760
  if (paint.mode === 'strench')
10613
10761
  paint.mode = 'stretch';
10762
+ let { width, height } = image;
10614
10763
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
10615
10764
  const sameBox = box.width === width && box.height === height;
10616
10765
  const data = { mode };
10617
10766
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10618
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10619
- let x = 0, y = 0, scaleX, scaleY;
10767
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
10768
+ let scaleX, scaleY;
10620
10769
  if (!mode || mode === 'cover' || mode === 'fit') {
10621
10770
  if (!sameBox || rotation) {
10622
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
10623
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10624
- 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);
10625
10774
  }
10626
10775
  }
10627
- else if (scale || size) {
10628
- MathHelper.getScaleData(scale, size, image, tempScaleData);
10629
- scaleX = tempScaleData.scaleX;
10630
- scaleY = tempScaleData.scaleY;
10631
- }
10632
- if (align) {
10633
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10634
- if (scaleX)
10635
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10636
- AlignHelper.toPoint(align, imageBounds, box, tempPoint$1, true);
10637
- 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
+ }
10638
10787
  }
10639
10788
  if (offset)
10640
- x += offset.x, y += offset.y;
10789
+ PointHelper.move(tempImage, offset);
10641
10790
  switch (mode) {
10642
10791
  case 'stretch':
10643
10792
  if (!sameBox)
@@ -10645,12 +10794,12 @@ function getPatternData(paint, box, image) {
10645
10794
  break;
10646
10795
  case 'normal':
10647
10796
  case 'clip':
10648
- if (x || y || scaleX || rotation)
10649
- 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);
10650
10799
  break;
10651
10800
  case 'repeat':
10652
10801
  if (!sameBox || scaleX || rotation)
10653
- 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);
10654
10803
  if (!repeat)
10655
10804
  data.repeat = 'repeat';
10656
10805
  break;
@@ -10658,7 +10807,7 @@ function getPatternData(paint, box, image) {
10658
10807
  case 'cover':
10659
10808
  default:
10660
10809
  if (scaleX)
10661
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10810
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10662
10811
  }
10663
10812
  if (!data.transform) {
10664
10813
  if (box.x || box.y) {
@@ -10691,6 +10840,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10691
10840
  }
10692
10841
  else {
10693
10842
  leafPaint = { type: paint.type, image };
10843
+ if (image.hasAlphaPixel)
10844
+ leafPaint.isTransparent = true;
10694
10845
  cache$1 = image.use > 1 ? { leafPaint, paint, boxBounds: box$1.set(boxBounds) } : null;
10695
10846
  }
10696
10847
  if (firstUse || image.loading)
@@ -10715,7 +10866,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10715
10866
  ignoreRender(ui, false);
10716
10867
  if (!ui.destroyed) {
10717
10868
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10718
- if (image.hasOpacityPixel)
10869
+ if (image.hasAlphaPixel)
10719
10870
  ui.__layout.hitCanvasChanged = true;
10720
10871
  ui.forceUpdate('surface');
10721
10872
  }
@@ -10727,6 +10878,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10727
10878
  onLoadError(ui, event, error);
10728
10879
  leafPaint.loadId = null;
10729
10880
  });
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
+ }
10730
10892
  }
10731
10893
  return leafPaint;
10732
10894
  }
@@ -10932,32 +11094,33 @@ const PaintImageModule = {
10932
11094
  repeatMode
10933
11095
  };
10934
11096
 
10935
- const { toPoint: toPoint$3 } = AroundHelper;
11097
+ const { toPoint: toPoint$3 } = AroundHelper, { hasTransparent } = ColorConvert;
10936
11098
  const realFrom$2 = {};
10937
11099
  const realTo$2 = {};
10938
11100
  function linearGradient(paint, box) {
10939
- let { from, to, type, blendMode, opacity } = paint;
11101
+ let { from, to, type, opacity } = paint;
10940
11102
  toPoint$3(from || 'top', box, realFrom$2);
10941
11103
  toPoint$3(to || 'bottom', box, realTo$2);
10942
11104
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
10943
- applyStops(style, paint.stops, opacity);
10944
11105
  const data = { type, style };
10945
- if (blendMode)
10946
- data.blendMode = blendMode;
11106
+ applyStops(data, style, paint.stops, opacity);
10947
11107
  return data;
10948
11108
  }
10949
- function applyStops(gradient, stops, opacity) {
11109
+ function applyStops(data, gradient, stops, opacity) {
10950
11110
  if (stops) {
10951
- let stop;
11111
+ let stop, color, offset, isTransparent;
10952
11112
  for (let i = 0, len = stops.length; i < len; i++) {
10953
11113
  stop = stops[i];
10954
- if (typeof stop === 'string') {
10955
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
10956
- }
10957
- else {
10958
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
10959
- }
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;
10960
11121
  }
11122
+ if (isTransparent)
11123
+ data.isTransparent = true;
10961
11124
  }
10962
11125
  }
10963
11126
 
@@ -10967,17 +11130,15 @@ const { toPoint: toPoint$2 } = AroundHelper;
10967
11130
  const realFrom$1 = {};
10968
11131
  const realTo$1 = {};
10969
11132
  function radialGradient(paint, box) {
10970
- let { from, to, type, opacity, blendMode, stretch } = paint;
11133
+ let { from, to, type, opacity, stretch } = paint;
10971
11134
  toPoint$2(from || 'center', box, realFrom$1);
10972
11135
  toPoint$2(to || 'bottom', box, realTo$1);
10973
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));
10974
- applyStops(style, paint.stops, opacity);
10975
11137
  const data = { type, style };
11138
+ applyStops(data, style, paint.stops, opacity);
10976
11139
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
10977
11140
  if (transform)
10978
11141
  data.transform = transform;
10979
- if (blendMode)
10980
- data.blendMode = blendMode;
10981
11142
  return data;
10982
11143
  }
10983
11144
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11003,17 +11164,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
11003
11164
  const realFrom = {};
11004
11165
  const realTo = {};
11005
11166
  function conicGradient(paint, box) {
11006
- let { from, to, type, opacity, blendMode, stretch } = paint;
11167
+ let { from, to, type, opacity, stretch } = paint;
11007
11168
  toPoint$1(from || 'center', box, realFrom);
11008
11169
  toPoint$1(to || 'bottom', box, realTo);
11009
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));
11010
- applyStops(style, paint.stops, opacity);
11011
11171
  const data = { type, style };
11172
+ applyStops(data, style, paint.stops, opacity);
11012
11173
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11013
11174
  if (transform)
11014
11175
  data.transform = transform;
11015
- if (blendMode)
11016
- data.blendMode = blendMode;
11017
11176
  return data;
11018
11177
  }
11019
11178
 
@@ -11346,6 +11505,8 @@ function createRows(drawData, content, style) {
11346
11505
  lastCharType = null;
11347
11506
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11348
11507
  word = { data: [] }, row = { words: [] };
11508
+ if (__letterSpacing)
11509
+ content = [...content];
11349
11510
  for (let i = 0, len = content.length; i < len; i++) {
11350
11511
  char = content[i];
11351
11512
  if (char === '\n') {
@@ -12192,24 +12353,25 @@ class EditSelect extends Group {
12192
12353
  const { app } = editor;
12193
12354
  app.selector.proxy = editor;
12194
12355
  this.__eventIds = [
12195
- editor.on_(EditorEvent.HOVER, this.onHover, this),
12196
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12197
- app.on_(PointerEvent.MOVE, this.onPointerMove, this),
12198
- app.on_(PointerEvent.BEFORE_DOWN, this.onBeforeDown, this),
12199
- app.on_(PointerEvent.TAP, this.onTap, this),
12200
- app.on_(DragEvent.START, this.onDragStart, this, true),
12201
- app.on_(DragEvent.DRAG, this.onDrag, this),
12202
- app.on_(DragEvent.END, this.onDragEnd, this),
12203
- app.on_(MoveEvent.MOVE, this.onAutoMove, this),
12204
- 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
+ ])
12205
12370
  ];
12206
12371
  });
12207
12372
  }
12208
12373
  __removeListenEvents() {
12209
- if (this.__eventIds) {
12210
- this.off_(this.__eventIds);
12211
- this.__eventIds.length = 0;
12212
- }
12374
+ this.off_(this.__eventIds);
12213
12375
  }
12214
12376
  destroy() {
12215
12377
  this.editor = this.originList = this.needRemoveItem = null;
@@ -12280,8 +12442,10 @@ const EditDataHelper = {
12280
12442
  align = 'top-right';
12281
12443
  }
12282
12444
  if (lockRatio) {
12283
- const unlockSide = lockRatio === 'corner' && direction % 2;
12284
- if (!unlockSide) {
12445
+ if (lockRatio === 'corner' && direction % 2) {
12446
+ lockRatio = false;
12447
+ }
12448
+ else {
12285
12449
  let scale;
12286
12450
  switch (direction) {
12287
12451
  case top$1:
@@ -12496,6 +12660,10 @@ function toDataURL(svg, rotation) {
12496
12660
  }
12497
12661
 
12498
12662
  class EditPoint extends Box {
12663
+ constructor(data) {
12664
+ super(data);
12665
+ this.useFastShadow = true;
12666
+ }
12499
12667
  }
12500
12668
 
12501
12669
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
@@ -12766,28 +12934,29 @@ class EditBox extends Group {
12766
12934
  const { editor } = this;
12767
12935
  point.direction = direction;
12768
12936
  point.pointType = type;
12769
- point.on_(DragEvent.START, this.onDragStart, this);
12770
- point.on_(DragEvent.DRAG, this.onDrag, this);
12771
- point.on_(DragEvent.END, this.onDragEnd, this);
12772
- 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
+ ];
12773
12943
  if (point.name !== 'circle')
12774
- 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));
12775
12946
  }
12776
12947
  __listenEvents() {
12777
12948
  const { rect, editor } = this;
12778
- this.__eventIds = [
12779
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12780
- rect.on_(DragEvent.START, this.onDragStart, this),
12781
- rect.on_(DragEvent.DRAG, editor.onMove, editor),
12782
- rect.on_(DragEvent.END, this.onDragEnd, this),
12783
- rect.on_(PointerEvent.ENTER, () => updateMoveCursor(editor)),
12784
- rect.on_(PointerEvent.DOUBLE_TAP, this.onDoubleTap, this),
12785
- rect.on_(PointerEvent.LONG_PRESS, this.onLongPress, this)
12786
- ];
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
+ ]));
12787
12957
  }
12788
12958
  __removeListenEvents() {
12789
12959
  this.off_(this.__eventIds);
12790
- this.__eventIds.length = 0;
12791
12960
  }
12792
12961
  destroy() {
12793
12962
  this.editor = null;
@@ -13529,12 +13698,14 @@ class Editor extends Group {
13529
13698
  const { app, leafer, editBox, editMask } = this;
13530
13699
  this.targetEventIds = [
13531
13700
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
13532
- app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
13533
- app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13534
- app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13535
- app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13536
- app.on_([KeyEvent.HOLD, KeyEvent.UP], this.onKey, this),
13537
- 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
+ ])
13538
13709
  ];
13539
13710
  if (editMask.visible)
13540
13711
  editMask.forceRender();
@@ -13544,7 +13715,6 @@ class Editor extends Group {
13544
13715
  const { targetEventIds, editMask } = this;
13545
13716
  if (targetEventIds.length) {
13546
13717
  this.off_(targetEventIds);
13547
- targetEventIds.length = 0;
13548
13718
  if (editMask.visible)
13549
13719
  editMask.forceRender();
13550
13720
  }
@@ -14013,7 +14183,12 @@ Box.prototype.__scaleResize = function (scaleX, scaleY) {
14013
14183
  Plugin.add('resize');
14014
14184
 
14015
14185
  Plugin.add('editor', 'resize');
14016
- 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
+ };
14017
14192
  Box.addAttr('textBox', false, dataType);
14018
14193
  UI.addAttr('editConfig', undefined, dataType);
14019
14194
  UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
@@ -14198,31 +14373,31 @@ let TextEditor = class TextEditor extends InnerEditor {
14198
14373
  textScale *= 12 / text.fontSize;
14199
14374
  }
14200
14375
  this.textScale = textScale;
14201
- const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
14202
14376
  let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14203
14377
  if (!this.inBody)
14204
14378
  x -= window.scrollX, y -= window.scrollY;
14205
- let { width, height } = text;
14379
+ let { width, height } = text, offsetX = 0, offsetY = 0;
14206
14380
  width *= textScale, height *= textScale;
14207
14381
  const data = text.__;
14208
14382
  if (data.__autoWidth && data.autoSizeAlign) {
14209
14383
  width += 20;
14210
14384
  switch (data.textAlign) {
14211
14385
  case 'center':
14212
- x -= width / 2;
14386
+ offsetX = -width / 2;
14213
14387
  break;
14214
- case 'right': x -= width;
14388
+ case 'right': offsetX = -width;
14215
14389
  }
14216
14390
  }
14217
14391
  if (data.__autoHeight && data.autoSizeAlign) {
14218
14392
  height += 20;
14219
14393
  switch (data.verticalAlign) {
14220
14394
  case 'middle':
14221
- y -= height / 2;
14395
+ offsetY = -height / 2;
14222
14396
  break;
14223
- case 'bottom': y -= height;
14397
+ case 'bottom': offsetY = -height;
14224
14398
  }
14225
14399
  }
14400
+ const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale).translateInner(offsetX, offsetY);
14226
14401
  const { style } = this.editDom;
14227
14402
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
14228
14403
  style.left = x + 'px';
@@ -14235,6 +14410,8 @@ let TextEditor = class TextEditor extends InnerEditor {
14235
14410
  const { editTarget: text, editor, editDom: dom } = this;
14236
14411
  if (text) {
14237
14412
  this.onInput();
14413
+ if (text.text === '\n')
14414
+ text.text = '';
14238
14415
  text.textEditing = undefined;
14239
14416
  if (editor.app)
14240
14417
  editor.app.config.keyEvent = this._keyEvent;
@@ -14547,6 +14724,7 @@ interaction.multiTouch = function (data, list) {
14547
14724
  return;
14548
14725
  const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
14549
14726
  Object.assign(data, center);
14727
+ data.multiTouch = true;
14550
14728
  this.pointerWaitCancel();
14551
14729
  this.rotate(getRotateEventData(rotation, data));
14552
14730
  this.zoom(getZoomEventData(scale, data));
@@ -15148,6 +15326,16 @@ Plugin.add('arrow');
15148
15326
  UI.addAttr('startArrow', 'none', arrowType);
15149
15327
  UI.addAttr('endArrow', 'none', arrowType);
15150
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
+ });
15151
15339
 
15152
15340
  class FlowData extends BoxData {
15153
15341
  }
@@ -16734,6 +16922,7 @@ ui$3.__runAnimation = function (type, complete) {
16734
16922
  const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285];
16735
16923
  const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
16736
16924
  const { sqrt } = Math;
16925
+ const { getDerivative } = BezierHelper;
16737
16926
  const HighBezierHelper = {
16738
16927
  getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
16739
16928
  let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
@@ -16748,10 +16937,6 @@ const HighBezierHelper = {
16748
16937
  }
16749
16938
  return distance * half;
16750
16939
  },
16751
- getDerivative(t, fromV, v1, v2, toV) {
16752
- const o = 1 - t;
16753
- return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
16754
- },
16755
16940
  getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
16756
16941
  const dx = getDerivative(t, fromX, x1, x2, toX);
16757
16942
  const dy = getDerivative(t, fromY, y1, y2, toY);
@@ -16780,7 +16965,7 @@ const HighBezierHelper = {
16780
16965
  data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
16781
16966
  }
16782
16967
  };
16783
- const { getDerivative, getDistance } = HighBezierHelper;
16968
+ const { getDistance } = HighBezierHelper;
16784
16969
 
16785
16970
  const { M, L, C, Z } = PathCommandMap;
16786
16971
  const tempPoint = {}, tempFrom = {};
@@ -17078,7 +17263,10 @@ function stateType(defaultValue, styleName) {
17078
17263
  return decorateLeafAttr(defaultValue, (key) => attr({
17079
17264
  set(value) {
17080
17265
  this.__setAttr(key, value);
17081
- this.waitLeafer(() => styleName ? State.setStyleName(this, styleName, value) : State.set(this, value));
17266
+ if (this.leaferIsReady)
17267
+ styleName ? State.setStyleName(this, styleName, value) : State.set(this, value);
17268
+ else
17269
+ this.__layout.stateStyleChanged = true;
17082
17270
  }
17083
17271
  }));
17084
17272
  }
@@ -17175,6 +17363,9 @@ function getStyle(leaf) {
17175
17363
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
17176
17364
  if (selectedStyle && State.isSelected(leaf, button))
17177
17365
  exist = assign(style, selectedStyle);
17366
+ const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
17367
+ if (placeholderStyle && State.isPlacehold(leaf, button))
17368
+ exist = assign(style, placeholderStyle);
17178
17369
  if (State.isDisabled(leaf, button)) {
17179
17370
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
17180
17371
  if (disabledStyle)
@@ -17354,12 +17545,14 @@ State.animateExcludes = {
17354
17545
  transitionOut: 1,
17355
17546
  states: 1,
17356
17547
  state: 1,
17548
+ placeholder: 1,
17357
17549
  normalStyle: 1,
17358
17550
  hoverStyle: 1,
17359
17551
  pressStyle: 1,
17360
17552
  focusStyle: 1,
17361
17553
  selectedStyle: 1,
17362
- disabledStyle: 1
17554
+ disabledStyle: 1,
17555
+ placeholderStyle: 1
17363
17556
  };
17364
17557
  State.isState = function (state, leaf, button) { return checkState(state, leaf, button); };
17365
17558
  State.isSelected = function (leaf, button) { return checkFixedState('selected', leaf, button); };
@@ -17367,6 +17560,7 @@ State.isDisabled = function (leaf, button) { return checkFixedState('disabled',
17367
17560
  State.isFocus = function (leaf, button) { return checkPointerState('isFocus', leaf, button); };
17368
17561
  State.isHover = function (leaf, button) { return checkPointerState('isHover', leaf, button); };
17369
17562
  State.isPress = function (leaf, button) { return checkPointerState('isPress', leaf, button); };
17563
+ State.isPlacehold = function (leaf, _button) { return leaf.__.__isPlacehold; };
17370
17564
  State.isDrag = function (leaf, button) { return checkPointerState('isDrag', leaf, button); };
17371
17565
  State.setStyleName = function (leaf, stateType, value) { value ? setState(leaf, stateType, leaf[stateType]) : unsetState(leaf, stateType, leaf[stateType]); };
17372
17566
  State.set = function (leaf, stateName) { const style = leaf.states[stateName]; style ? setState(leaf, stateName, style) : unsetState(leaf, stateName, style); };
@@ -17384,6 +17578,7 @@ UI.addAttr('pressStyle', undefined, stateStyleType);
17384
17578
  UI.addAttr('focusStyle', undefined, stateStyleType);
17385
17579
  UI.addAttr('selectedStyle', undefined, stateStyleType);
17386
17580
  UI.addAttr('disabledStyle', undefined, stateStyleType);
17581
+ UI.addAttr('placeholderStyle', undefined, stateStyleType);
17387
17582
  UI.addAttr('button', false, dataType);
17388
17583
  ui$1.focus = function (value = true) {
17389
17584
  this.waitLeafer(() => {
@@ -17402,6 +17597,15 @@ ui$1.focus = function (value = true) {
17402
17597
  ui$1.updateState = function () {
17403
17598
  State.updateStyle(this, undefined, 'in');
17404
17599
  };
17600
+ const text = Text.prototype, textKey = 'text';
17601
+ defineKey(text, textKey, Object.assign(Object.assign({}, getDescriptor(text, textKey)), { set(value) {
17602
+ const t = this, oldValue = t.text;
17603
+ if (t.__setAttr(textKey, value)) {
17604
+ doBoundsType(t);
17605
+ if (t.placeholderStyle && t.placeholder && (oldValue === '' || value === ''))
17606
+ t.__layout.stateStyleChanged = true;
17607
+ }
17608
+ } }));
17405
17609
 
17406
17610
  class RobotData extends UIData {
17407
17611
  get __drawAfterFill() { return true; }
@@ -17745,10 +17949,9 @@ const ExportModule = {
17745
17949
  else {
17746
17950
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
17747
17951
  const { worldTransform, isLeafer, leafer, isFrame } = leaf;
17748
- const { slice, trim, padding, onCanvas } = options;
17952
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
17749
17953
  const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
17750
17954
  const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
17751
- const screenshot = options.screenshot || leaf.isApp;
17752
17955
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
17753
17956
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
17754
17957
  if (screenshot) {
@@ -17784,12 +17987,9 @@ const ExportModule = {
17784
17987
  const scaleData = { scaleX: 1, scaleY: 1 };
17785
17988
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
17786
17989
  let pixelRatio = options.pixelRatio || 1;
17787
- if (leaf.isApp) {
17788
- scaleData.scaleX *= pixelRatio;
17789
- scaleData.scaleY *= pixelRatio;
17790
- pixelRatio = leaf.app.pixelRatio;
17791
- }
17792
- const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
17990
+ let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
17991
+ if (clip)
17992
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
17793
17993
  const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
17794
17994
  let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
17795
17995
  let sliceLeaf;
@@ -17941,5 +18141,4 @@ Object.assign(Filter, {
17941
18141
  }
17942
18142
  });
17943
18143
 
17944
- 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 };
17945
- //# sourceMappingURL=worker.module.js.map
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 };