leafer-ui 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$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
152
150
  const { float: float$1 } = MathHelper;
153
- const tempPoint$4 = {};
151
+ const tempPoint$3 = {};
154
152
  function getWorld() {
155
153
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
156
154
  }
@@ -193,8 +191,8 @@ const MatrixHelper = {
193
191
  t.d *= scaleY;
194
192
  },
195
193
  scaleOfOuter(t, origin, scaleX, scaleY) {
196
- M$6.toInnerPoint(t, origin, tempPoint$4);
197
- M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
194
+ M$6.toInnerPoint(t, origin, tempPoint$3);
195
+ M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
198
196
  },
199
197
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
200
198
  M$6.translateInner(t, origin.x, origin.y);
@@ -212,8 +210,8 @@ const MatrixHelper = {
212
210
  t.d = c * sinR + d * cosR;
213
211
  },
214
212
  rotateOfOuter(t, origin, rotation) {
215
- M$6.toInnerPoint(t, origin, tempPoint$4);
216
- M$6.rotateOfInner(t, tempPoint$4, rotation);
213
+ M$6.toInnerPoint(t, origin, tempPoint$3);
214
+ M$6.rotateOfInner(t, tempPoint$3, rotation);
217
215
  },
218
216
  rotateOfInner(t, origin, rotation) {
219
217
  M$6.translateInner(t, origin.x, origin.y);
@@ -234,8 +232,8 @@ const MatrixHelper = {
234
232
  }
235
233
  },
236
234
  skewOfOuter(t, origin, skewX, skewY) {
237
- M$6.toInnerPoint(t, origin, tempPoint$4);
238
- M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
235
+ M$6.toInnerPoint(t, origin, tempPoint$3);
236
+ M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
239
237
  },
240
238
  skewOfInner(t, origin, skewX, skewY = 0) {
241
239
  M$6.translateInner(t, origin.x, origin.y);
@@ -464,8 +462,10 @@ const PointHelper = {
464
462
  t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
465
463
  },
466
464
  move(t, x, y) {
467
- t.x += x;
468
- t.y += y;
465
+ if (typeof x === 'object')
466
+ t.x += x.x, t.y += x.y;
467
+ else
468
+ t.x += x, t.y += y;
469
469
  },
470
470
  scale(t, scaleX, scaleY = scaleX) {
471
471
  if (t.x)
@@ -643,7 +643,7 @@ class Point {
643
643
  return this;
644
644
  }
645
645
  }
646
- const tempPoint$3 = new Point();
646
+ const tempPoint$2 = new Point();
647
647
 
648
648
  class Matrix {
649
649
  constructor(a, b, c, d, e, f) {
@@ -801,15 +801,87 @@ const TwoPointBoundsHelper = {
801
801
  };
802
802
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
803
803
 
804
+ var Direction4;
805
+ (function (Direction4) {
806
+ Direction4[Direction4["top"] = 0] = "top";
807
+ Direction4[Direction4["right"] = 1] = "right";
808
+ Direction4[Direction4["bottom"] = 2] = "bottom";
809
+ Direction4[Direction4["left"] = 3] = "left";
810
+ })(Direction4 || (Direction4 = {}));
811
+ var Direction9;
812
+ (function (Direction9) {
813
+ Direction9[Direction9["topLeft"] = 0] = "topLeft";
814
+ Direction9[Direction9["top"] = 1] = "top";
815
+ Direction9[Direction9["topRight"] = 2] = "topRight";
816
+ Direction9[Direction9["right"] = 3] = "right";
817
+ Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
818
+ Direction9[Direction9["bottom"] = 5] = "bottom";
819
+ Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
820
+ Direction9[Direction9["left"] = 7] = "left";
821
+ Direction9[Direction9["center"] = 8] = "center";
822
+ Direction9[Direction9["top-left"] = 0] = "top-left";
823
+ Direction9[Direction9["top-right"] = 2] = "top-right";
824
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
825
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
826
+ })(Direction9 || (Direction9 = {}));
827
+
828
+ const directionData = [
829
+ { x: 0, y: 0 },
830
+ { x: 0.5, y: 0 },
831
+ { x: 1, y: 0 },
832
+ { x: 1, y: 0.5 },
833
+ { x: 1, y: 1 },
834
+ { x: 0.5, y: 1 },
835
+ { x: 0, y: 1 },
836
+ { x: 0, y: 0.5 },
837
+ { x: 0.5, y: 0.5 }
838
+ ];
839
+ directionData.forEach(item => item.type = 'percent');
840
+ const AroundHelper = {
841
+ directionData,
842
+ tempPoint: {},
843
+ get: get$4,
844
+ toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
845
+ const point = get$4(around);
846
+ to.x = point.x;
847
+ to.y = point.y;
848
+ if (point.type === 'percent') {
849
+ to.x *= box.width;
850
+ to.y *= box.height;
851
+ if (content) {
852
+ if (!onlyContentSize)
853
+ to.x -= content.x, to.y -= content.y;
854
+ if (point.x)
855
+ to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
856
+ if (point.y)
857
+ to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
858
+ }
859
+ }
860
+ if (!onlyBoxSize)
861
+ to.x += box.x, to.y += box.y;
862
+ }
863
+ };
864
+ function get$4(around) {
865
+ return typeof around === 'string' ? directionData[Direction9[around]] : around;
866
+ }
867
+
868
+ const { toPoint: toPoint$5 } = AroundHelper;
869
+ const AlignHelper = {
870
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
871
+ toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
872
+ }
873
+ };
874
+
804
875
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
805
876
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
806
877
  const { float, fourNumber } = MathHelper;
807
878
  const { floor, ceil: ceil$2 } = Math;
808
879
  let right$1, bottom$1, boundsRight, boundsBottom;
809
880
  const point = {};
810
- const toPoint$5 = {};
881
+ const toPoint$4 = {};
882
+ const tempBounds$2 = {};
811
883
  const BoundsHelper = {
812
- tempBounds: {},
884
+ tempBounds: tempBounds$2,
813
885
  set(t, x = 0, y = 0, width = 0, height = 0) {
814
886
  t.x = x;
815
887
  t.y = y;
@@ -872,8 +944,8 @@ const BoundsHelper = {
872
944
  }
873
945
  B.move(to, -to.offsetX, -to.offsetY);
874
946
  },
875
- scale(t, scaleX, scaleY = scaleX) {
876
- PointHelper.scale(t, scaleX, scaleY);
947
+ scale(t, scaleX, scaleY = scaleX, onlySize) {
948
+ onlySize || PointHelper.scale(t, scaleX, scaleY);
877
949
  t.width *= scaleX;
878
950
  t.height *= scaleY;
879
951
  },
@@ -883,9 +955,9 @@ const BoundsHelper = {
883
955
  t.height *= scaleY;
884
956
  },
885
957
  tempToOuterOf(t, matrix) {
886
- B.copy(B.tempBounds, t);
887
- B.toOuterOf(B.tempBounds, matrix);
888
- return B.tempBounds;
958
+ B.copy(tempBounds$2, t);
959
+ B.toOuterOf(tempBounds$2, matrix);
960
+ return tempBounds$2;
889
961
  },
890
962
  getOuterOf(t, matrix) {
891
963
  t = Object.assign({}, t);
@@ -916,17 +988,17 @@ const BoundsHelper = {
916
988
  else {
917
989
  point.x = t.x;
918
990
  point.y = t.y;
919
- toOuterPoint$2(matrix, point, toPoint$5);
920
- setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
991
+ toOuterPoint$2(matrix, point, toPoint$4);
992
+ setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
921
993
  point.x = t.x + t.width;
922
- toOuterPoint$2(matrix, point, toPoint$5);
923
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
994
+ toOuterPoint$2(matrix, point, toPoint$4);
995
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
924
996
  point.y = t.y + t.height;
925
- toOuterPoint$2(matrix, point, toPoint$5);
926
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
997
+ toOuterPoint$2(matrix, point, toPoint$4);
998
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
927
999
  point.x = t.x;
928
- toOuterPoint$2(matrix, point, toPoint$5);
929
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
1000
+ toOuterPoint$2(matrix, point, toPoint$4);
1001
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
930
1002
  toBounds$3(tempPointBounds$1, to);
931
1003
  }
932
1004
  },
@@ -936,9 +1008,21 @@ const BoundsHelper = {
936
1008
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
937
1009
  },
938
1010
  getFitMatrix(t, put, baseScale = 1) {
939
- const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
1011
+ const scale = Math.min(baseScale, B.getFitScale(t, put));
940
1012
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
941
1013
  },
1014
+ getFitScale(t, put, isCoverMode) {
1015
+ const sw = t.width / put.width, sh = t.height / put.height;
1016
+ return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
1017
+ },
1018
+ put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
1019
+ to || (to = put);
1020
+ if (typeof putScale === 'string')
1021
+ putScale = B.getFitScale(t, put, putScale === 'cover');
1022
+ tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1023
+ tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1024
+ AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1025
+ },
942
1026
  getSpread(t, spread, side) {
943
1027
  const n = {};
944
1028
  B.copyAndSpread(n, t, spread, false, side);
@@ -1112,8 +1196,8 @@ class Bounds {
1112
1196
  BoundsHelper.move(this, x, y);
1113
1197
  return this;
1114
1198
  }
1115
- scale(scaleX, scaleY) {
1116
- BoundsHelper.scale(this, scaleX, scaleY);
1199
+ scale(scaleX, scaleY, onlySize) {
1200
+ BoundsHelper.scale(this, scaleX, scaleY, onlySize);
1117
1201
  return this;
1118
1202
  }
1119
1203
  scaleOf(origin, scaleX, scaleY) {
@@ -1131,6 +1215,9 @@ class Bounds {
1131
1215
  getFitMatrix(put, baseScale) {
1132
1216
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1133
1217
  }
1218
+ put(put, align, putScale) {
1219
+ BoundsHelper.put(this, put, align, putScale);
1220
+ }
1134
1221
  spread(fourNumber, side) {
1135
1222
  BoundsHelper.spread(this, fourNumber, side);
1136
1223
  return this;
@@ -1239,79 +1326,6 @@ class AutoBounds {
1239
1326
  }
1240
1327
  }
1241
1328
 
1242
- var Direction4;
1243
- (function (Direction4) {
1244
- Direction4[Direction4["top"] = 0] = "top";
1245
- Direction4[Direction4["right"] = 1] = "right";
1246
- Direction4[Direction4["bottom"] = 2] = "bottom";
1247
- Direction4[Direction4["left"] = 3] = "left";
1248
- })(Direction4 || (Direction4 = {}));
1249
- var Direction9;
1250
- (function (Direction9) {
1251
- Direction9[Direction9["topLeft"] = 0] = "topLeft";
1252
- Direction9[Direction9["top"] = 1] = "top";
1253
- Direction9[Direction9["topRight"] = 2] = "topRight";
1254
- Direction9[Direction9["right"] = 3] = "right";
1255
- Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
1256
- Direction9[Direction9["bottom"] = 5] = "bottom";
1257
- Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1258
- Direction9[Direction9["left"] = 7] = "left";
1259
- Direction9[Direction9["center"] = 8] = "center";
1260
- Direction9[Direction9["top-left"] = 0] = "top-left";
1261
- Direction9[Direction9["top-right"] = 2] = "top-right";
1262
- Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1263
- Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1264
- })(Direction9 || (Direction9 = {}));
1265
-
1266
- const directionData = [
1267
- { x: 0, y: 0 },
1268
- { x: 0.5, y: 0 },
1269
- { x: 1, y: 0 },
1270
- { x: 1, y: 0.5 },
1271
- { x: 1, y: 1 },
1272
- { x: 0.5, y: 1 },
1273
- { x: 0, y: 1 },
1274
- { x: 0, y: 0.5 },
1275
- { x: 0.5, y: 0.5 }
1276
- ];
1277
- directionData.forEach(item => item.type = 'percent');
1278
- const AroundHelper = {
1279
- directionData,
1280
- tempPoint: {},
1281
- get: get$4,
1282
- toPoint(around, bounds, to, onlySize, pointBounds) {
1283
- const point = get$4(around);
1284
- to.x = point.x;
1285
- to.y = point.y;
1286
- if (point.type === 'percent') {
1287
- to.x *= bounds.width;
1288
- to.y *= bounds.height;
1289
- if (pointBounds) {
1290
- to.x -= pointBounds.x;
1291
- to.y -= pointBounds.y;
1292
- if (point.x)
1293
- to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1294
- if (point.y)
1295
- to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1296
- }
1297
- }
1298
- if (!onlySize) {
1299
- to.x += bounds.x;
1300
- to.y += bounds.y;
1301
- }
1302
- }
1303
- };
1304
- function get$4(around) {
1305
- return typeof around === 'string' ? directionData[Direction9[around]] : around;
1306
- }
1307
-
1308
- const { toPoint: toPoint$4 } = AroundHelper;
1309
- const AlignHelper = {
1310
- toPoint(align, contentBounds, bounds, to, onlySize) {
1311
- toPoint$4(align, bounds, to, onlySize, contentBounds);
1312
- }
1313
- };
1314
-
1315
1329
  const StringNumberMap = {
1316
1330
  '0': 1,
1317
1331
  '1': 1,
@@ -1442,11 +1456,17 @@ const Plugin = {
1442
1456
  return rs;
1443
1457
  },
1444
1458
  need(name) {
1445
- console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1459
+ console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1446
1460
  }
1447
1461
  };
1448
1462
  setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1449
1463
 
1464
+ const Creator = {
1465
+ editor(_options) {
1466
+ return Plugin.need('editor');
1467
+ }
1468
+ };
1469
+
1450
1470
  const debug$f = Debug.get('UICreator');
1451
1471
  const UICreator = {
1452
1472
  list: {},
@@ -1584,6 +1604,10 @@ const DataHelper = {
1584
1604
  for (let i = 0, len = list.length; i < len; i++)
1585
1605
  map[list[i]] = true;
1586
1606
  return map;
1607
+ },
1608
+ stintSet(data, attrName, value) {
1609
+ value || (value = undefined);
1610
+ data[attrName] !== value && (data[attrName] = value);
1587
1611
  }
1588
1612
  };
1589
1613
  const { assign } = DataHelper;
@@ -2385,7 +2409,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2385
2409
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2386
2410
  const { set, toNumberPoints } = PointHelper;
2387
2411
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
2388
- const tempPoint$2 = {};
2412
+ const tempPoint$1 = {};
2389
2413
  const BezierHelper = {
2390
2414
  points(data, originPoints, curve, close) {
2391
2415
  let points = toNumberPoints(originPoints);
@@ -2407,6 +2431,8 @@ const BezierHelper = {
2407
2431
  cY = points[i + 3];
2408
2432
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2409
2433
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2434
+ if (!ba && !cb)
2435
+ continue;
2410
2436
  d = ba + cb;
2411
2437
  ba = (t * ba) / d;
2412
2438
  cb = (t * cb) / d;
@@ -2576,8 +2602,8 @@ const BezierHelper = {
2576
2602
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2577
2603
  addPoint$1(pointBounds, toX, toY);
2578
2604
  for (let i = 0, len = tList.length; i < len; i++) {
2579
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2580
- addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
2605
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2606
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2581
2607
  }
2582
2608
  },
2583
2609
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -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 = FileHelper;
3412
- F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3442
+ F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3413
3443
 
3414
3444
  const debug$a = 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 = LeafHelper;
4406
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4449
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1 } = L;
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$2 } = LeafHelper;
4486
+ const { updateBounds: updateBounds$3 } = 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$2(children[j]);
4548
+ updateBounds$3(children[j]);
4506
4549
  }
4507
4550
  if (exclude && exclude === branch)
4508
4551
  continue;
4509
- updateBounds$2(branch);
4552
+ updateBounds$3(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$2 } = LeafHelper;
4528
4571
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$6 } = 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$2(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$3, tempPoint: tempPoint$1 } = AroundHelper;
5258
+ const { toPoint: toPoint$3, tempPoint } = 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$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
5178
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
5275
+ toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
5276
+ translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
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$1, copy: copy$5 } =
5188
5286
  const { toBounds: toBounds$1 } = 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;
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;
5195
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
  const debug$5 = Debug.get('LeaferCanvas');
6131
6236
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6465,17 +6570,15 @@ class Watcher {
6465
6570
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6466
6571
  this.__updatedList = new LeafList();
6467
6572
  this.totalTimes++;
6468
- this.changed = false;
6469
- this.hasVisible = false;
6470
- this.hasRemove = false;
6471
- this.hasAdd = false;
6573
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6472
6574
  }
6473
6575
  __listenEvents() {
6474
- const { target } = this;
6475
6576
  this.__eventIds = [
6476
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6477
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6478
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6577
+ this.target.on_([
6578
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6579
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6580
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6581
+ ])
6479
6582
  ];
6480
6583
  }
6481
6584
  __removeListenEvents() {
@@ -6485,13 +6588,12 @@ class Watcher {
6485
6588
  if (this.target) {
6486
6589
  this.stop();
6487
6590
  this.__removeListenEvents();
6488
- this.target = null;
6489
- this.__updatedList = null;
6591
+ this.target = this.__updatedList = null;
6490
6592
  }
6491
6593
  }
6492
6594
  }
6493
6595
 
6494
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6596
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6495
6597
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6496
6598
  function updateMatrix(updateList, levelList) {
6497
6599
  let layout;
@@ -6534,15 +6636,7 @@ function updateBounds(boundsList) {
6534
6636
  });
6535
6637
  }
6536
6638
  function updateChange(updateList) {
6537
- let layout;
6538
- updateList.list.forEach(leaf => {
6539
- layout = leaf.__layout;
6540
- if (layout.opacityChanged)
6541
- updateAllWorldOpacity(leaf);
6542
- if (layout.stateStyleChanged)
6543
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6544
- leaf.__updateChange();
6545
- });
6639
+ updateList.list.forEach(updateOneChange);
6546
6640
  }
6547
6641
 
6548
6642
  const { worldBounds } = LeafBoundsHelper;
@@ -6599,7 +6693,7 @@ class Layouter {
6599
6693
  this.disabled = true;
6600
6694
  }
6601
6695
  layout() {
6602
- if (!this.running)
6696
+ if (this.layouting || !this.running)
6603
6697
  return;
6604
6698
  const { target } = this;
6605
6699
  this.times = 0;
@@ -6682,12 +6776,10 @@ class Layouter {
6682
6776
  }
6683
6777
  static fullLayout(target) {
6684
6778
  updateAllMatrix(target, true);
6685
- if (target.isBranch) {
6779
+ if (target.isBranch)
6686
6780
  BranchHelper.updateBounds(target);
6687
- }
6688
- else {
6781
+ else
6689
6782
  LeafHelper.updateBounds(target);
6690
- }
6691
6783
  updateAllChange(target);
6692
6784
  }
6693
6785
  addExtra(leaf) {
@@ -6710,11 +6802,12 @@ class Layouter {
6710
6802
  this.__updatedList = event.data.updatedList;
6711
6803
  }
6712
6804
  __listenEvents() {
6713
- const { target } = this;
6714
6805
  this.__eventIds = [
6715
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6716
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6717
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6806
+ this.target.on_([
6807
+ [LayoutEvent.REQUEST, this.layout, this],
6808
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6809
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6810
+ ])
6718
6811
  ];
6719
6812
  }
6720
6813
  __removeListenEvents() {
@@ -6945,12 +7038,13 @@ class Renderer {
6945
7038
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6946
7039
  }
6947
7040
  __listenEvents() {
6948
- const { target } = this;
6949
7041
  this.__eventIds = [
6950
- target.on_(RenderEvent.REQUEST, this.update, this),
6951
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6952
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6953
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7042
+ this.target.on_([
7043
+ [RenderEvent.REQUEST, this.update, this],
7044
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7045
+ [RenderEvent.AGAIN, this.renderAgain, this],
7046
+ [ResizeEvent.RESIZE, this.__onResize, this]
7047
+ ])
6954
7048
  ];
6955
7049
  }
6956
7050
  __removeListenEvents() {
@@ -7166,8 +7260,32 @@ function zoomLayerType() {
7166
7260
  };
7167
7261
  }
7168
7262
 
7263
+ function hasTransparent$3(color) {
7264
+ if (!color || color.length === 7 || color.length === 4)
7265
+ return false;
7266
+ if (color === 'transparent')
7267
+ return true;
7268
+ const first = color[0];
7269
+ if (first === '#') {
7270
+ switch (color.length) {
7271
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7272
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7273
+ }
7274
+ }
7275
+ else if (first === 'r' || first === 'h') {
7276
+ if (color[3] === 'a') {
7277
+ const i = color.lastIndexOf(',');
7278
+ if (i > -1)
7279
+ return parseFloat(color.slice(i + 1)) < 1;
7280
+ }
7281
+ }
7282
+ return false;
7283
+ }
7284
+
7169
7285
  const TextConvert = {};
7170
- const ColorConvert = {};
7286
+ const ColorConvert = {
7287
+ hasTransparent: hasTransparent$3
7288
+ };
7171
7289
  const UnitConvert = {
7172
7290
  number(value, percentRefer) {
7173
7291
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7193,6 +7311,7 @@ const Transition = {
7193
7311
  };
7194
7312
 
7195
7313
  const { parse, objectToCanvasData } = PathConvert;
7314
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7196
7315
  const emptyPaint = {};
7197
7316
  const debug$2 = Debug.get('UIData');
7198
7317
  class UIData extends LeafData {
@@ -7251,38 +7370,22 @@ class UIData extends LeafData {
7251
7370
  if (this.__naturalWidth)
7252
7371
  this.__removeNaturalSize();
7253
7372
  if (typeof value === 'string' || !value) {
7254
- if (this.__isFills) {
7255
- this.__removeInput('fill');
7256
- PaintImage.recycleImage('fill', this);
7257
- this.__isFills = false;
7258
- this.__pixelFill && (this.__pixelFill = false);
7259
- }
7373
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7374
+ this.__isFills && this.__removePaint('fill', true);
7260
7375
  this._fill = value;
7261
7376
  }
7262
7377
  else if (typeof value === 'object') {
7263
- this.__setInput('fill', value);
7264
- const layout = this.__leaf.__layout;
7265
- layout.boxChanged || layout.boxChange();
7266
- this.__isFills = true;
7267
- this._fill || (this._fill = emptyPaint);
7378
+ this.__setPaint('fill', value);
7268
7379
  }
7269
7380
  }
7270
7381
  setStroke(value) {
7271
7382
  if (typeof value === 'string' || !value) {
7272
- if (this.__isStrokes) {
7273
- this.__removeInput('stroke');
7274
- PaintImage.recycleImage('stroke', this);
7275
- this.__isStrokes = false;
7276
- this.__pixelStroke && (this.__pixelStroke = false);
7277
- }
7383
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7384
+ this.__isStrokes && this.__removePaint('stroke', true);
7278
7385
  this._stroke = value;
7279
7386
  }
7280
7387
  else if (typeof value === 'object') {
7281
- this.__setInput('stroke', value);
7282
- const layout = this.__leaf.__layout;
7283
- layout.boxChanged || layout.boxChange();
7284
- this.__isStrokes = true;
7285
- this._stroke || (this._stroke = emptyPaint);
7388
+ this.__setPaint('stroke', value);
7286
7389
  }
7287
7390
  }
7288
7391
  setPath(value) {
@@ -7312,7 +7415,34 @@ class UIData extends LeafData {
7312
7415
  Paint.compute('fill', this.__leaf);
7313
7416
  if (stroke)
7314
7417
  Paint.compute('stroke', this.__leaf);
7315
- this.__needComputePaint = false;
7418
+ this.__needComputePaint = undefined;
7419
+ }
7420
+ __setPaint(attrName, value) {
7421
+ this.__setInput(attrName, value);
7422
+ const layout = this.__leaf.__layout;
7423
+ layout.boxChanged || layout.boxChange();
7424
+ if (value instanceof Array && !value.length) {
7425
+ this.__removePaint(attrName);
7426
+ }
7427
+ else {
7428
+ if (attrName === 'fill')
7429
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7430
+ else
7431
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7432
+ }
7433
+ }
7434
+ __removePaint(attrName, removeInput) {
7435
+ if (removeInput)
7436
+ this.__removeInput(attrName);
7437
+ PaintImage.recycleImage(attrName, this);
7438
+ if (attrName === 'fill') {
7439
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7440
+ this._fill = this.__isFills = undefined;
7441
+ }
7442
+ else {
7443
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7444
+ this._stroke = this.__isStrokes = undefined;
7445
+ }
7316
7446
  }
7317
7447
  }
7318
7448
  function setArray(data, key, value) {
@@ -7320,10 +7450,10 @@ function setArray(data, key, value) {
7320
7450
  if (value instanceof Array) {
7321
7451
  if (value.some((item) => item.visible === false))
7322
7452
  value = value.filter((item) => item.visible !== false);
7323
- value.length || (value = null);
7453
+ value.length || (value = undefined);
7324
7454
  }
7325
7455
  else
7326
- value = value && value.visible !== false ? [value] : null;
7456
+ value = value && value.visible !== false ? [value] : undefined;
7327
7457
  data['_' + key] = value;
7328
7458
  }
7329
7459
 
@@ -7387,13 +7517,11 @@ class TextData extends UIData {
7387
7517
  setFontWeight(value) {
7388
7518
  if (typeof value === 'string') {
7389
7519
  this.__setInput('fontWeight', value);
7390
- this._fontWeight = fontWeightMap[value] || 400;
7391
- }
7392
- else {
7393
- if (this.__input)
7394
- this.__removeInput('fontWeight');
7395
- this._fontWeight = value;
7520
+ value = fontWeightMap[value] || 400;
7396
7521
  }
7522
+ else if (this.__input)
7523
+ this.__removeInput('fontWeight');
7524
+ this._fontWeight = value;
7397
7525
  }
7398
7526
  setBoxStyle(value) {
7399
7527
  let t = this.__leaf, box = t.__box;
@@ -7428,8 +7556,6 @@ class ImageData extends RectData {
7428
7556
  this._url = value;
7429
7557
  }
7430
7558
  __setImageFill(value) {
7431
- if (this.__leaf.image)
7432
- this.__leaf.image = null;
7433
7559
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7434
7560
  }
7435
7561
  __getData() {
@@ -7495,21 +7621,19 @@ const UIBounds = {
7495
7621
  }
7496
7622
  };
7497
7623
 
7624
+ const { stintSet: stintSet$1 } = DataHelper;
7498
7625
  const UIRender = {
7499
7626
  __updateChange() {
7500
- const data = this.__, w = this.__world;
7627
+ const data = this.__;
7501
7628
  if (data.__useEffect) {
7502
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7503
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7629
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7630
+ stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7631
+ data.__useEffect = !!(shadow || otherEffect);
7504
7632
  }
7505
- const half = data.__hasHalf;
7506
- w.half !== half && (w.half = half);
7633
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7634
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7507
7635
  data.__checkSingle();
7508
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7509
- if (complex)
7510
- data.__complex = true;
7511
- else
7512
- data.__complex && (data.__complex = false);
7636
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7513
7637
  },
7514
7638
  __drawFast(canvas, options) {
7515
7639
  drawFast(this, canvas, options);
@@ -7519,21 +7643,23 @@ const UIRender = {
7519
7643
  if (data.__complex) {
7520
7644
  if (data.__needComputePaint)
7521
7645
  data.__computePaint();
7522
- const { fill, stroke, __drawAfterFill } = data;
7646
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7523
7647
  this.__drawRenderPath(canvas);
7524
- if (data.__useEffect) {
7648
+ if (data.__useEffect && !__isFastShadow) {
7525
7649
  const shape = Paint.shape(this, canvas, options);
7526
7650
  this.__nowWorld = this.__getNowWorld(options);
7527
7651
  const { shadow, innerShadow, filter } = data;
7528
7652
  if (shadow)
7529
7653
  Effect.shadow(this, canvas, shape);
7654
+ if (__fillAfterStroke)
7655
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7530
7656
  if (fill)
7531
7657
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7532
7658
  if (__drawAfterFill)
7533
7659
  this.__drawAfterFill(canvas, options);
7534
7660
  if (innerShadow)
7535
7661
  Effect.innerShadow(this, canvas, shape);
7536
- if (stroke)
7662
+ if (stroke && !__fillAfterStroke)
7537
7663
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7538
7664
  if (filter)
7539
7665
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7542,21 +7668,27 @@ const UIRender = {
7542
7668
  shape.canvas.recycle();
7543
7669
  }
7544
7670
  else {
7671
+ if (__fillAfterStroke)
7672
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7673
+ if (__isFastShadow) {
7674
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7675
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7676
+ }
7545
7677
  if (fill)
7546
7678
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7679
+ if (__isFastShadow)
7680
+ canvas.restore();
7547
7681
  if (__drawAfterFill)
7548
7682
  this.__drawAfterFill(canvas, options);
7549
- if (stroke)
7683
+ if (stroke && !__fillAfterStroke)
7550
7684
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7551
7685
  }
7552
7686
  }
7553
7687
  else {
7554
- if (data.__pathInputed) {
7688
+ if (data.__pathInputed)
7555
7689
  drawFast(this, canvas, options);
7556
- }
7557
- else {
7690
+ else
7558
7691
  this.__drawFast(canvas, options);
7559
- }
7560
7692
  }
7561
7693
  },
7562
7694
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7565,11 +7697,11 @@ const UIRender = {
7565
7697
  const { fill, stroke } = this.__;
7566
7698
  this.__drawRenderPath(canvas);
7567
7699
  if (fill && !ignoreFill)
7568
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7700
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7569
7701
  if (this.__.__isCanvas)
7570
7702
  this.__drawAfterFill(canvas, options);
7571
7703
  if (stroke && !ignoreStroke)
7572
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7704
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7573
7705
  }
7574
7706
  },
7575
7707
  __drawAfterFill(canvas, options) {
@@ -7584,13 +7716,15 @@ const UIRender = {
7584
7716
  }
7585
7717
  };
7586
7718
  function drawFast(ui, canvas, options) {
7587
- const { fill, stroke, __drawAfterFill } = ui.__;
7719
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7588
7720
  ui.__drawRenderPath(canvas);
7721
+ if (__fillAfterStroke)
7722
+ Paint.stroke(stroke, ui, canvas);
7589
7723
  if (fill)
7590
7724
  Paint.fill(fill, ui, canvas);
7591
7725
  if (__drawAfterFill)
7592
7726
  ui.__drawAfterFill(canvas, options);
7593
- if (stroke)
7727
+ if (stroke && !__fillAfterStroke)
7594
7728
  Paint.stroke(stroke, ui, canvas);
7595
7729
  }
7596
7730
 
@@ -7720,6 +7854,9 @@ let UI = UI_1 = class UI extends Leaf {
7720
7854
  else
7721
7855
  drawer.rect(x, y, width, height);
7722
7856
  }
7857
+ drawImagePlaceholder(canvas, _image) {
7858
+ Paint.fill(this.__.placeholderColor, this, canvas);
7859
+ }
7723
7860
  animate(_keyframe, _options, _type, _isTemp) {
7724
7861
  return Plugin.need('animate');
7725
7862
  }
@@ -7956,6 +8093,12 @@ __decorate([
7956
8093
  __decorate([
7957
8094
  effectType()
7958
8095
  ], UI.prototype, "filter", void 0);
8096
+ __decorate([
8097
+ surfaceType()
8098
+ ], UI.prototype, "placeholderColor", void 0);
8099
+ __decorate([
8100
+ dataType(100)
8101
+ ], UI.prototype, "placeholderDelay", void 0);
7959
8102
  __decorate([
7960
8103
  dataType({})
7961
8104
  ], UI.prototype, "data", void 0);
@@ -8357,15 +8500,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8357
8500
  }
8358
8501
  __listenEvents() {
8359
8502
  const runId = Run.start('FirstCreate ' + this.innerName);
8360
- this.once(LeaferEvent.START, () => Run.end(runId));
8361
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8362
- this.once(RenderEvent.START, () => this.__onCreated());
8363
- this.once(RenderEvent.END, () => this.__onViewReady());
8364
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8503
+ this.once([
8504
+ [LeaferEvent.START, () => Run.end(runId)],
8505
+ [LayoutEvent.START, this.updateLazyBounds, this],
8506
+ [RenderEvent.START, this.__onCreated, this],
8507
+ [RenderEvent.END, this.__onViewReady, this]
8508
+ ]);
8509
+ this.__eventIds.push(this.on_([
8510
+ [WatchEvent.DATA, this.__onWatchData, this],
8511
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8512
+ [RenderEvent.NEXT, this.__onNextRender, this]
8513
+ ]));
8365
8514
  }
8366
8515
  __removeListenEvents() {
8367
8516
  this.off_(this.__eventIds);
8368
- this.__eventIds.length = 0;
8369
8517
  }
8370
8518
  destroy(sync) {
8371
8519
  const doDestory = () => {
@@ -8473,13 +8621,13 @@ let Box = class Box extends Group {
8473
8621
  super.__updateRenderBounds();
8474
8622
  copy$3(childrenRenderBounds, renderBounds);
8475
8623
  this.__updateRectRenderBounds();
8476
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8624
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8477
8625
  if (isOverflow && this.__.overflow !== 'hide')
8478
8626
  add(renderBounds, childrenRenderBounds);
8479
8627
  }
8480
8628
  else
8481
8629
  this.__updateRectRenderBounds();
8482
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8630
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8483
8631
  }
8484
8632
  __updateRectRenderBounds() { }
8485
8633
  __updateRectChange() { }
@@ -8783,17 +8931,10 @@ Star = __decorate([
8783
8931
 
8784
8932
  let Image$1 = class Image extends Rect {
8785
8933
  get __tag() { return 'Image'; }
8786
- get ready() { return this.image ? this.image.ready : false; }
8934
+ get ready() { const { image } = this; return image && image.ready; }
8935
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8787
8936
  constructor(data) {
8788
8937
  super(data);
8789
- this.on(ImageEvent.LOADED, (e) => {
8790
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8791
- this.image = e.image;
8792
- });
8793
- }
8794
- destroy() {
8795
- this.image = null;
8796
- super.destroy();
8797
8938
  }
8798
8939
  };
8799
8940
  __decorate([
@@ -8809,11 +8950,11 @@ const MyImage = Image$1;
8809
8950
 
8810
8951
  let Canvas = class Canvas extends Rect {
8811
8952
  get __tag() { return 'Canvas'; }
8953
+ get context() { return this.canvas.context; }
8812
8954
  get ready() { return !this.url; }
8813
8955
  constructor(data) {
8814
8956
  super(data);
8815
8957
  this.canvas = Creator.canvas(this.__);
8816
- this.context = this.canvas.context;
8817
8958
  if (data && data.url)
8818
8959
  this.drawImage(data.url);
8819
8960
  }
@@ -8857,7 +8998,7 @@ let Canvas = class Canvas extends Rect {
8857
8998
  destroy() {
8858
8999
  if (this.canvas) {
8859
9000
  this.canvas.destroy();
8860
- this.canvas = this.context = null;
9001
+ this.canvas = null;
8861
9002
  }
8862
9003
  super.destroy();
8863
9004
  }
@@ -8903,7 +9044,7 @@ let Text = class Text extends UI {
8903
9044
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8904
9045
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8905
9046
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8906
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
9047
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8907
9048
  }
8908
9049
  __updateBoxBounds() {
8909
9050
  const data = this.__;
@@ -8933,12 +9074,11 @@ let Text = class Text extends UI {
8933
9074
  super.__updateBoxBounds();
8934
9075
  if (italic)
8935
9076
  b.width += fontSize * 0.16;
8936
- const isOverflow = !includes(b, contentBounds) || undefined;
8937
- if (isOverflow)
9077
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
9078
+ if (this.isOverflow)
8938
9079
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8939
9080
  else
8940
9081
  data.__textBoxBounds = b;
8941
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8942
9082
  }
8943
9083
  __onUpdateSize() {
8944
9084
  if (this.__box)
@@ -9001,6 +9141,9 @@ __decorate([
9001
9141
  __decorate([
9002
9142
  boundsType('')
9003
9143
  ], Text.prototype, "text", void 0);
9144
+ __decorate([
9145
+ boundsType('')
9146
+ ], Text.prototype, "placeholder", void 0);
9004
9147
  __decorate([
9005
9148
  boundsType('caption')
9006
9149
  ], Text.prototype, "fontFamily", void 0);
@@ -9136,7 +9279,7 @@ let App = class App extends Leafer {
9136
9279
  if (sky || editor)
9137
9280
  this.sky = this.addLeafer(sky);
9138
9281
  if (editor)
9139
- this.sky.add(this.editor = Creator.editor(editor));
9282
+ Creator.editor(editor, this);
9140
9283
  }
9141
9284
  }
9142
9285
  __setApp() {
@@ -9150,6 +9293,10 @@ let App = class App extends Leafer {
9150
9293
  this.watcher.disable();
9151
9294
  this.layouter.disable();
9152
9295
  }
9296
+ __updateLocalBounds() {
9297
+ this.forEach(leafer => leafer.updateLayout());
9298
+ super.__updateLocalBounds();
9299
+ }
9153
9300
  start() {
9154
9301
  super.start();
9155
9302
  this.forEach(leafer => leafer.start());
@@ -9207,12 +9354,8 @@ let App = class App extends Leafer {
9207
9354
  this.renderer.update();
9208
9355
  }
9209
9356
  __render(canvas, options) {
9210
- if (canvas.context) {
9211
- const m = options.matrix;
9212
- if (m)
9213
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9214
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9215
- }
9357
+ if (canvas.context)
9358
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9216
9359
  }
9217
9360
  __onResize(event) {
9218
9361
  this.forEach(leafer => leafer.resize(event));
@@ -9233,9 +9376,11 @@ let App = class App extends Leafer {
9233
9376
  return config;
9234
9377
  }
9235
9378
  __listenChildEvents(leafer) {
9236
- leafer.once(LayoutEvent.END, () => this.__onReady());
9237
- leafer.once(RenderEvent.START, () => this.__onCreated());
9238
- leafer.once(RenderEvent.END, () => this.__onViewReady());
9379
+ leafer.once([
9380
+ [LayoutEvent.END, this.__onReady, this],
9381
+ [RenderEvent.START, this.__onCreated, this],
9382
+ [RenderEvent.END, this.__onViewReady, this]
9383
+ ]);
9239
9384
  if (this.realCanvas)
9240
9385
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9241
9386
  }
@@ -9446,7 +9591,7 @@ MoveEvent = __decorate([
9446
9591
  registerUIEvent()
9447
9592
  ], MoveEvent);
9448
9593
 
9449
- let RotateEvent = class RotateEvent extends UIEvent {
9594
+ let RotateEvent = class RotateEvent extends PointerEvent$1 {
9450
9595
  };
9451
9596
  RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9452
9597
  RotateEvent.START = 'rotate.start';
@@ -9467,7 +9612,7 @@ SwipeEvent = __decorate([
9467
9612
  registerUIEvent()
9468
9613
  ], SwipeEvent);
9469
9614
 
9470
- let ZoomEvent = class ZoomEvent extends UIEvent {
9615
+ let ZoomEvent = class ZoomEvent extends PointerEvent$1 {
9471
9616
  };
9472
9617
  ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9473
9618
  ZoomEvent.START = 'zoom.start';
@@ -10310,8 +10455,8 @@ ui$1.__updateHitCanvas = function () {
10310
10455
  if (this.__box)
10311
10456
  this.__box.__updateHitCanvas();
10312
10457
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10313
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10314
- const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10458
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10459
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10315
10460
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10316
10461
  if (!this.__hitCanvas)
10317
10462
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10342,11 +10487,11 @@ ui$1.__hit = function (inner) {
10342
10487
  if (data.__isHitPixel && this.__hitPixel(inner))
10343
10488
  return true;
10344
10489
  const { hitFill } = data;
10345
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10490
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10346
10491
  if (needHitFillPath && this.__hitFill(inner))
10347
10492
  return true;
10348
10493
  const { hitStroke, __strokeWidth } = data;
10349
- const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10494
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10350
10495
  if (!needHitFillPath && !needHitStrokePath)
10351
10496
  return false;
10352
10497
  const radiusWidth = inner.radiusX * 2;
@@ -10735,8 +10880,10 @@ class Interaction extends InteractionBase {
10735
10880
  }
10736
10881
 
10737
10882
  function fillText(ui, canvas) {
10738
- let row, data = ui.__.__textDrawData;
10739
- const { rows, decorationY } = data;
10883
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10884
+ if (data.__isPlacehold && data.placeholderColor)
10885
+ canvas.fillStyle = data.placeholderColor;
10886
+ let row;
10740
10887
  for (let i = 0, len = rows.length; i < len; i++) {
10741
10888
  row = rows[i];
10742
10889
  if (row.text)
@@ -10745,7 +10892,7 @@ function fillText(ui, canvas) {
10745
10892
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10746
10893
  }
10747
10894
  if (decorationY) {
10748
- const { decorationColor, decorationHeight } = data;
10895
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10749
10896
  if (decorationColor)
10750
10897
  canvas.fillStyle = decorationColor;
10751
10898
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10754,65 +10901,71 @@ function fillText(ui, canvas) {
10754
10901
 
10755
10902
  function fill(fill, ui, canvas) {
10756
10903
  canvas.fillStyle = fill;
10757
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10904
+ fillPathOrText(ui, canvas);
10758
10905
  }
10759
10906
  function fills(fills, ui, canvas) {
10760
10907
  let item;
10761
- const { windingRule, __font } = ui.__;
10762
10908
  for (let i = 0, len = fills.length; i < len; i++) {
10763
10909
  item = fills[i];
10764
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10765
- continue;
10766
- if (item.style) {
10767
- canvas.fillStyle = item.style;
10768
- if (item.transform) {
10769
- canvas.save();
10770
- canvas.transform(item.transform);
10771
- if (item.blendMode)
10772
- canvas.blendMode = item.blendMode;
10773
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10774
- canvas.restore();
10910
+ if (item.image) {
10911
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10912
+ continue;
10913
+ if (!item.style) {
10914
+ if (!i && item.image.isPlacehold)
10915
+ ui.drawImagePlaceholder(canvas, item.image);
10916
+ continue;
10775
10917
  }
10776
- else {
10777
- if (item.blendMode) {
10778
- canvas.saveBlendMode(item.blendMode);
10779
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10780
- canvas.restoreBlendMode();
10781
- }
10782
- else {
10783
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10784
- }
10918
+ }
10919
+ canvas.fillStyle = item.style;
10920
+ if (item.transform) {
10921
+ canvas.save();
10922
+ canvas.transform(item.transform);
10923
+ if (item.blendMode)
10924
+ canvas.blendMode = item.blendMode;
10925
+ fillPathOrText(ui, canvas);
10926
+ canvas.restore();
10927
+ }
10928
+ else {
10929
+ if (item.blendMode) {
10930
+ canvas.saveBlendMode(item.blendMode);
10931
+ fillPathOrText(ui, canvas);
10932
+ canvas.restoreBlendMode();
10785
10933
  }
10934
+ else
10935
+ fillPathOrText(ui, canvas);
10786
10936
  }
10787
10937
  }
10788
10938
  }
10939
+ function fillPathOrText(ui, canvas) {
10940
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10941
+ }
10789
10942
 
10790
10943
  function strokeText(stroke, ui, canvas) {
10791
- const { strokeAlign } = ui.__;
10792
- const isStrokes = typeof stroke !== 'string';
10793
- switch (strokeAlign) {
10944
+ switch (ui.__.strokeAlign) {
10794
10945
  case 'center':
10795
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10796
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10946
+ drawCenter$1(stroke, 1, ui, canvas);
10797
10947
  break;
10798
10948
  case 'inside':
10799
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10949
+ drawAlign(stroke, 'inside', ui, canvas);
10800
10950
  break;
10801
10951
  case 'outside':
10802
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10952
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10803
10953
  break;
10804
10954
  }
10805
10955
  }
10806
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10807
- const { __strokeWidth, __font } = ui.__;
10956
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10957
+ const data = ui.__;
10958
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10959
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10960
+ }
10961
+ function drawAlign(stroke, align, ui, canvas) {
10808
10962
  const out = canvas.getSameCanvas(true, true);
10809
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10810
- out.font = __font;
10811
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10963
+ out.font = ui.__.__font;
10964
+ drawCenter$1(stroke, 2, ui, out);
10812
10965
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10813
10966
  fillText(ui, out);
10814
10967
  out.blendMode = 'normal';
10815
- if (ui.__worldFlipped)
10968
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10816
10969
  canvas.copyWorldByReset(out, ui.__nowWorld);
10817
10970
  else
10818
10971
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10854,90 +11007,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
10854
11007
  }
10855
11008
 
10856
11009
  function stroke(stroke, ui, canvas) {
10857
- const options = ui.__;
10858
- const { __strokeWidth, strokeAlign, __font } = options;
10859
- if (!__strokeWidth)
11010
+ const data = ui.__;
11011
+ if (!data.__strokeWidth)
10860
11012
  return;
10861
- if (__font) {
11013
+ if (data.__font) {
10862
11014
  strokeText(stroke, ui, canvas);
10863
11015
  }
10864
11016
  else {
10865
- switch (strokeAlign) {
11017
+ switch (data.strokeAlign) {
10866
11018
  case 'center':
10867
- canvas.setStroke(stroke, __strokeWidth, options);
10868
- canvas.stroke();
10869
- if (options.__useArrow)
10870
- strokeArrow(ui, canvas);
11019
+ drawCenter(stroke, 1, ui, canvas);
10871
11020
  break;
10872
11021
  case 'inside':
10873
- canvas.save();
10874
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10875
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10876
- canvas.stroke();
10877
- canvas.restore();
11022
+ drawInside(stroke, ui, canvas);
10878
11023
  break;
10879
11024
  case 'outside':
10880
- const out = canvas.getSameCanvas(true, true);
10881
- out.setStroke(stroke, __strokeWidth * 2, options);
10882
- ui.__drawRenderPath(out);
10883
- out.stroke();
10884
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10885
- out.clearWorld(ui.__layout.renderBounds);
10886
- if (ui.__worldFlipped)
10887
- canvas.copyWorldByReset(out, ui.__nowWorld);
10888
- else
10889
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10890
- out.recycle(ui.__nowWorld);
11025
+ drawOutside(stroke, ui, canvas);
10891
11026
  break;
10892
11027
  }
10893
11028
  }
10894
11029
  }
10895
11030
  function strokes(strokes, ui, canvas) {
10896
- const options = ui.__;
10897
- const { __strokeWidth, strokeAlign, __font } = options;
10898
- if (!__strokeWidth)
10899
- return;
10900
- if (__font) {
10901
- strokeText(strokes, ui, canvas);
11031
+ stroke(strokes, ui, canvas);
11032
+ }
11033
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
11034
+ const data = ui.__;
11035
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
11036
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
11037
+ if (data.__useArrow)
11038
+ Paint.strokeArrow(stroke, ui, canvas);
11039
+ }
11040
+ function drawInside(stroke, ui, canvas) {
11041
+ const data = ui.__;
11042
+ canvas.save();
11043
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
11044
+ drawCenter(stroke, 2, ui, canvas);
11045
+ canvas.restore();
11046
+ }
11047
+ function drawOutside(stroke, ui, canvas) {
11048
+ const data = ui.__;
11049
+ if (data.__fillAfterStroke) {
11050
+ drawCenter(stroke, 2, ui, canvas);
10902
11051
  }
10903
11052
  else {
10904
- switch (strokeAlign) {
10905
- case 'center':
10906
- canvas.setStroke(undefined, __strokeWidth, options);
10907
- drawStrokesStyle(strokes, false, ui, canvas);
10908
- if (options.__useArrow)
10909
- strokeArrow(ui, canvas);
10910
- break;
10911
- case 'inside':
10912
- canvas.save();
10913
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10914
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10915
- drawStrokesStyle(strokes, false, ui, canvas);
10916
- canvas.restore();
10917
- break;
10918
- case 'outside':
10919
- const { renderBounds } = ui.__layout;
10920
- const out = canvas.getSameCanvas(true, true);
10921
- ui.__drawRenderPath(out);
10922
- out.setStroke(undefined, __strokeWidth * 2, options);
10923
- drawStrokesStyle(strokes, false, ui, out);
10924
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10925
- out.clearWorld(renderBounds);
10926
- if (ui.__worldFlipped)
10927
- canvas.copyWorldByReset(out, ui.__nowWorld);
10928
- else
10929
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10930
- out.recycle(ui.__nowWorld);
10931
- break;
10932
- }
10933
- }
10934
- }
10935
- function strokeArrow(ui, canvas) {
10936
- if (ui.__.dashPattern) {
10937
- canvas.beginPath();
10938
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10939
- canvas.dashPattern = null;
10940
- canvas.stroke();
11053
+ const { renderBounds } = ui.__layout;
11054
+ const out = canvas.getSameCanvas(true, true);
11055
+ ui.__drawRenderPath(out);
11056
+ drawCenter(stroke, 2, ui, out);
11057
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
11058
+ out.clearWorld(renderBounds);
11059
+ if (ui.__worldFlipped || Platform.fullImageShadow)
11060
+ canvas.copyWorldByReset(out, ui.__nowWorld);
11061
+ else
11062
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
11063
+ out.recycle(ui.__nowWorld);
10941
11064
  }
10942
11065
  }
10943
11066
 
@@ -10984,9 +11107,10 @@ function shape(ui, current, options) {
10984
11107
  }
10985
11108
 
10986
11109
  let recycleMap;
11110
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
10987
11111
  function compute(attrName, ui) {
10988
11112
  const data = ui.__, leafPaints = [];
10989
- let paints = data.__input[attrName], hasOpacityPixel;
11113
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
10990
11114
  if (!(paints instanceof Array))
10991
11115
  paints = [paints];
10992
11116
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -10996,35 +11120,62 @@ function compute(attrName, ui) {
10996
11120
  leafPaints.push(item);
10997
11121
  }
10998
11122
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10999
- if (leafPaints.length && leafPaints[0].image)
11000
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
11001
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
11123
+ if (leafPaints.length) {
11124
+ if (leafPaints.every(item => item.isTransparent)) {
11125
+ if (leafPaints.some(item => item.image))
11126
+ isAlphaPixel = true;
11127
+ isTransparent = true;
11128
+ }
11129
+ }
11130
+ if (attrName === 'fill') {
11131
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
11132
+ stintSet(data, '__isTransparentFill', isTransparent);
11133
+ }
11134
+ else {
11135
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
11136
+ stintSet(data, '__isTransparentStroke', isTransparent);
11137
+ }
11002
11138
  }
11003
11139
  function getLeafPaint(attrName, paint, ui) {
11004
11140
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
11005
11141
  return undefined;
11142
+ let data;
11006
11143
  const { boxBounds } = ui.__layout;
11007
11144
  switch (paint.type) {
11008
- case 'solid':
11009
- let { type, blendMode, color, opacity } = paint;
11010
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
11011
11145
  case 'image':
11012
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11146
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11147
+ break;
11013
11148
  case 'linear':
11014
- return PaintGradient.linearGradient(paint, boxBounds);
11149
+ data = PaintGradient.linearGradient(paint, boxBounds);
11150
+ break;
11015
11151
  case 'radial':
11016
- return PaintGradient.radialGradient(paint, boxBounds);
11152
+ data = PaintGradient.radialGradient(paint, boxBounds);
11153
+ break;
11017
11154
  case 'angular':
11018
- return PaintGradient.conicGradient(paint, boxBounds);
11155
+ data = PaintGradient.conicGradient(paint, boxBounds);
11156
+ break;
11157
+ case 'solid':
11158
+ const { type, blendMode, color, opacity } = paint;
11159
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
11160
+ break;
11019
11161
  default:
11020
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
11162
+ if (paint.r !== undefined)
11163
+ data = { type: 'solid', style: ColorConvert.string(paint) };
11164
+ }
11165
+ if (data) {
11166
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
11167
+ data.isTransparent = true;
11168
+ if (paint.blendMode)
11169
+ data.blendMode = paint.blendMode;
11021
11170
  }
11171
+ return data;
11022
11172
  }
11023
11173
 
11024
11174
  const PaintModule = {
11025
11175
  compute,
11026
11176
  fill,
11027
11177
  fills,
11178
+ fillPathOrText,
11028
11179
  fillText,
11029
11180
  stroke,
11030
11181
  strokes,
@@ -11083,12 +11234,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
11083
11234
 
11084
11235
  const { get: get$2, translate } = MatrixHelper;
11085
11236
  const tempBox = new Bounds();
11086
- const tempPoint = {};
11087
11237
  const tempScaleData = {};
11238
+ const tempImage = {};
11088
11239
  function createData(leafPaint, image, paint, box) {
11089
- const { blendMode, changeful, sync } = paint;
11090
- if (blendMode)
11091
- leafPaint.blendMode = blendMode;
11240
+ const { changeful, sync } = paint;
11092
11241
  if (changeful)
11093
11242
  leafPaint.changeful = changeful;
11094
11243
  if (sync)
@@ -11096,38 +11245,38 @@ function createData(leafPaint, image, paint, box) {
11096
11245
  leafPaint.data = getPatternData(paint, box, image);
11097
11246
  }
11098
11247
  function getPatternData(paint, box, image) {
11099
- let { width, height } = image;
11100
11248
  if (paint.padding)
11101
11249
  box = tempBox.set(box).shrink(paint.padding);
11102
11250
  if (paint.mode === 'strench')
11103
11251
  paint.mode = 'stretch';
11252
+ let { width, height } = image;
11104
11253
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
11105
11254
  const sameBox = box.width === width && box.height === height;
11106
11255
  const data = { mode };
11107
11256
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
11108
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
11109
- let x = 0, y = 0, scaleX, scaleY;
11257
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
11258
+ let scaleX, scaleY;
11110
11259
  if (!mode || mode === 'cover' || mode === 'fit') {
11111
11260
  if (!sameBox || rotation) {
11112
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
11113
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
11114
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
11261
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
11262
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
11263
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
11115
11264
  }
11116
11265
  }
11117
- else if (scale || size) {
11118
- MathHelper.getScaleData(scale, size, image, tempScaleData);
11119
- scaleX = tempScaleData.scaleX;
11120
- scaleY = tempScaleData.scaleY;
11121
- }
11122
- if (align) {
11123
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
11124
- if (scaleX)
11125
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
11126
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
11127
- x += tempPoint.x, y += tempPoint.y;
11266
+ else {
11267
+ if (scale || size) {
11268
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
11269
+ scaleX = tempScaleData.scaleX;
11270
+ scaleY = tempScaleData.scaleY;
11271
+ }
11272
+ if (align) {
11273
+ if (scaleX)
11274
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
11275
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
11276
+ }
11128
11277
  }
11129
11278
  if (offset)
11130
- x += offset.x, y += offset.y;
11279
+ PointHelper.move(tempImage, offset);
11131
11280
  switch (mode) {
11132
11281
  case 'stretch':
11133
11282
  if (!sameBox)
@@ -11135,12 +11284,12 @@ function getPatternData(paint, box, image) {
11135
11284
  break;
11136
11285
  case 'normal':
11137
11286
  case 'clip':
11138
- if (x || y || scaleX || rotation)
11139
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
11287
+ if (tempImage.x || tempImage.y || scaleX || rotation)
11288
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11140
11289
  break;
11141
11290
  case 'repeat':
11142
11291
  if (!sameBox || scaleX || rotation)
11143
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
11292
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
11144
11293
  if (!repeat)
11145
11294
  data.repeat = 'repeat';
11146
11295
  break;
@@ -11148,7 +11297,7 @@ function getPatternData(paint, box, image) {
11148
11297
  case 'cover':
11149
11298
  default:
11150
11299
  if (scaleX)
11151
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
11300
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
11152
11301
  }
11153
11302
  if (!data.transform) {
11154
11303
  if (box.x || box.y) {
@@ -11181,6 +11330,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11181
11330
  }
11182
11331
  else {
11183
11332
  leafPaint = { type: paint.type, image };
11333
+ if (image.hasAlphaPixel)
11334
+ leafPaint.isTransparent = true;
11184
11335
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
11185
11336
  }
11186
11337
  if (firstUse || image.loading)
@@ -11205,7 +11356,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11205
11356
  ignoreRender(ui, false);
11206
11357
  if (!ui.destroyed) {
11207
11358
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
11208
- if (image.hasOpacityPixel)
11359
+ if (image.hasAlphaPixel)
11209
11360
  ui.__layout.hitCanvasChanged = true;
11210
11361
  ui.forceUpdate('surface');
11211
11362
  }
@@ -11217,6 +11368,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11217
11368
  onLoadError(ui, event, error);
11218
11369
  leafPaint.loadId = null;
11219
11370
  });
11371
+ if (ui.placeholderColor) {
11372
+ if (!ui.placeholderDelay)
11373
+ image.isPlacehold = true;
11374
+ else
11375
+ setTimeout(() => {
11376
+ if (!image.ready) {
11377
+ image.isPlacehold = true;
11378
+ ui.forceUpdate('surface');
11379
+ }
11380
+ }, ui.placeholderDelay);
11381
+ }
11220
11382
  }
11221
11383
  return leafPaint;
11222
11384
  }
@@ -11422,32 +11584,33 @@ const PaintImageModule = {
11422
11584
  repeatMode
11423
11585
  };
11424
11586
 
11425
- const { toPoint: toPoint$2 } = AroundHelper;
11587
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
11426
11588
  const realFrom$2 = {};
11427
11589
  const realTo$2 = {};
11428
11590
  function linearGradient(paint, box) {
11429
- let { from, to, type, blendMode, opacity } = paint;
11591
+ let { from, to, type, opacity } = paint;
11430
11592
  toPoint$2(from || 'top', box, realFrom$2);
11431
11593
  toPoint$2(to || 'bottom', box, realTo$2);
11432
11594
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
11433
- applyStops(style, paint.stops, opacity);
11434
11595
  const data = { type, style };
11435
- if (blendMode)
11436
- data.blendMode = blendMode;
11596
+ applyStops(data, style, paint.stops, opacity);
11437
11597
  return data;
11438
11598
  }
11439
- function applyStops(gradient, stops, opacity) {
11599
+ function applyStops(data, gradient, stops, opacity) {
11440
11600
  if (stops) {
11441
- let stop;
11601
+ let stop, color, offset, isTransparent;
11442
11602
  for (let i = 0, len = stops.length; i < len; i++) {
11443
11603
  stop = stops[i];
11444
- if (typeof stop === 'string') {
11445
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
11446
- }
11447
- else {
11448
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
11449
- }
11604
+ if (typeof stop === 'string')
11605
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
11606
+ else
11607
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
11608
+ gradient.addColorStop(offset, color);
11609
+ if (!isTransparent && hasTransparent(color))
11610
+ isTransparent = true;
11450
11611
  }
11612
+ if (isTransparent)
11613
+ data.isTransparent = true;
11451
11614
  }
11452
11615
  }
11453
11616
 
@@ -11457,17 +11620,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
11457
11620
  const realFrom$1 = {};
11458
11621
  const realTo$1 = {};
11459
11622
  function radialGradient(paint, box) {
11460
- let { from, to, type, opacity, blendMode, stretch } = paint;
11623
+ let { from, to, type, opacity, stretch } = paint;
11461
11624
  toPoint$1(from || 'center', box, realFrom$1);
11462
11625
  toPoint$1(to || 'bottom', box, realTo$1);
11463
11626
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11464
- applyStops(style, paint.stops, opacity);
11465
11627
  const data = { type, style };
11628
+ applyStops(data, style, paint.stops, opacity);
11466
11629
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11467
11630
  if (transform)
11468
11631
  data.transform = transform;
11469
- if (blendMode)
11470
- data.blendMode = blendMode;
11471
11632
  return data;
11472
11633
  }
11473
11634
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11493,17 +11654,15 @@ const { toPoint } = AroundHelper;
11493
11654
  const realFrom = {};
11494
11655
  const realTo = {};
11495
11656
  function conicGradient(paint, box) {
11496
- let { from, to, type, opacity, blendMode, stretch } = paint;
11657
+ let { from, to, type, opacity, stretch } = paint;
11497
11658
  toPoint(from || 'center', box, realFrom);
11498
11659
  toPoint(to || 'bottom', box, realTo);
11499
11660
  const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
11500
- applyStops(style, paint.stops, opacity);
11501
11661
  const data = { type, style };
11662
+ applyStops(data, style, paint.stops, opacity);
11502
11663
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11503
11664
  if (transform)
11504
11665
  data.transform = transform;
11505
- if (blendMode)
11506
- data.blendMode = blendMode;
11507
11666
  return data;
11508
11667
  }
11509
11668
 
@@ -11836,6 +11995,8 @@ function createRows(drawData, content, style) {
11836
11995
  lastCharType = null;
11837
11996
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11838
11997
  word = { data: [] }, row = { words: [] };
11998
+ if (__letterSpacing)
11999
+ content = [...content];
11839
12000
  for (let i = 0, len = content.length; i < len; i++) {
11840
12001
  char = content[i];
11841
12002
  if (char === '\n') {
@@ -12254,5 +12415,4 @@ Object.assign(Creator, {
12254
12415
  });
12255
12416
  useCanvas();
12256
12417
 
12257
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
12258
- //# sourceMappingURL=web.module.js.map
12418
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$2 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };