@leafer-ui/miniapp 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$e = 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$9 = 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
  class LeaferCanvas extends LeaferCanvasBase {
6131
6236
  get allowBackgroundColor() { return false; }
@@ -6423,17 +6528,15 @@ class Watcher {
6423
6528
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6424
6529
  this.__updatedList = new LeafList();
6425
6530
  this.totalTimes++;
6426
- this.changed = false;
6427
- this.hasVisible = false;
6428
- this.hasRemove = false;
6429
- this.hasAdd = false;
6531
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6430
6532
  }
6431
6533
  __listenEvents() {
6432
- const { target } = this;
6433
6534
  this.__eventIds = [
6434
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6435
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6436
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6535
+ this.target.on_([
6536
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6537
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6538
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6539
+ ])
6437
6540
  ];
6438
6541
  }
6439
6542
  __removeListenEvents() {
@@ -6443,13 +6546,12 @@ class Watcher {
6443
6546
  if (this.target) {
6444
6547
  this.stop();
6445
6548
  this.__removeListenEvents();
6446
- this.target = null;
6447
- this.__updatedList = null;
6549
+ this.target = this.__updatedList = null;
6448
6550
  }
6449
6551
  }
6450
6552
  }
6451
6553
 
6452
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6554
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6453
6555
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6454
6556
  function updateMatrix(updateList, levelList) {
6455
6557
  let layout;
@@ -6492,15 +6594,7 @@ function updateBounds(boundsList) {
6492
6594
  });
6493
6595
  }
6494
6596
  function updateChange(updateList) {
6495
- let layout;
6496
- updateList.list.forEach(leaf => {
6497
- layout = leaf.__layout;
6498
- if (layout.opacityChanged)
6499
- updateAllWorldOpacity(leaf);
6500
- if (layout.stateStyleChanged)
6501
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6502
- leaf.__updateChange();
6503
- });
6597
+ updateList.list.forEach(updateOneChange);
6504
6598
  }
6505
6599
 
6506
6600
  const { worldBounds } = LeafBoundsHelper;
@@ -6557,7 +6651,7 @@ class Layouter {
6557
6651
  this.disabled = true;
6558
6652
  }
6559
6653
  layout() {
6560
- if (!this.running)
6654
+ if (this.layouting || !this.running)
6561
6655
  return;
6562
6656
  const { target } = this;
6563
6657
  this.times = 0;
@@ -6640,12 +6734,10 @@ class Layouter {
6640
6734
  }
6641
6735
  static fullLayout(target) {
6642
6736
  updateAllMatrix(target, true);
6643
- if (target.isBranch) {
6737
+ if (target.isBranch)
6644
6738
  BranchHelper.updateBounds(target);
6645
- }
6646
- else {
6739
+ else
6647
6740
  LeafHelper.updateBounds(target);
6648
- }
6649
6741
  updateAllChange(target);
6650
6742
  }
6651
6743
  addExtra(leaf) {
@@ -6668,11 +6760,12 @@ class Layouter {
6668
6760
  this.__updatedList = event.data.updatedList;
6669
6761
  }
6670
6762
  __listenEvents() {
6671
- const { target } = this;
6672
6763
  this.__eventIds = [
6673
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6674
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6675
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6764
+ this.target.on_([
6765
+ [LayoutEvent.REQUEST, this.layout, this],
6766
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6767
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6768
+ ])
6676
6769
  ];
6677
6770
  }
6678
6771
  __removeListenEvents() {
@@ -6903,12 +6996,13 @@ class Renderer {
6903
6996
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6904
6997
  }
6905
6998
  __listenEvents() {
6906
- const { target } = this;
6907
6999
  this.__eventIds = [
6908
- target.on_(RenderEvent.REQUEST, this.update, this),
6909
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6910
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6911
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7000
+ this.target.on_([
7001
+ [RenderEvent.REQUEST, this.update, this],
7002
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7003
+ [RenderEvent.AGAIN, this.renderAgain, this],
7004
+ [ResizeEvent.RESIZE, this.__onResize, this]
7005
+ ])
6912
7006
  ];
6913
7007
  }
6914
7008
  __removeListenEvents() {
@@ -7124,8 +7218,32 @@ function zoomLayerType() {
7124
7218
  };
7125
7219
  }
7126
7220
 
7221
+ function hasTransparent$3(color) {
7222
+ if (!color || color.length === 7 || color.length === 4)
7223
+ return false;
7224
+ if (color === 'transparent')
7225
+ return true;
7226
+ const first = color[0];
7227
+ if (first === '#') {
7228
+ switch (color.length) {
7229
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7230
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7231
+ }
7232
+ }
7233
+ else if (first === 'r' || first === 'h') {
7234
+ if (color[3] === 'a') {
7235
+ const i = color.lastIndexOf(',');
7236
+ if (i > -1)
7237
+ return parseFloat(color.slice(i + 1)) < 1;
7238
+ }
7239
+ }
7240
+ return false;
7241
+ }
7242
+
7127
7243
  const TextConvert = {};
7128
- const ColorConvert = {};
7244
+ const ColorConvert = {
7245
+ hasTransparent: hasTransparent$3
7246
+ };
7129
7247
  const UnitConvert = {
7130
7248
  number(value, percentRefer) {
7131
7249
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7151,6 +7269,7 @@ const Transition = {
7151
7269
  };
7152
7270
 
7153
7271
  const { parse, objectToCanvasData } = PathConvert;
7272
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7154
7273
  const emptyPaint = {};
7155
7274
  const debug$2 = Debug.get('UIData');
7156
7275
  class UIData extends LeafData {
@@ -7209,38 +7328,22 @@ class UIData extends LeafData {
7209
7328
  if (this.__naturalWidth)
7210
7329
  this.__removeNaturalSize();
7211
7330
  if (typeof value === 'string' || !value) {
7212
- if (this.__isFills) {
7213
- this.__removeInput('fill');
7214
- PaintImage.recycleImage('fill', this);
7215
- this.__isFills = false;
7216
- this.__pixelFill && (this.__pixelFill = false);
7217
- }
7331
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7332
+ this.__isFills && this.__removePaint('fill', true);
7218
7333
  this._fill = value;
7219
7334
  }
7220
7335
  else if (typeof value === 'object') {
7221
- this.__setInput('fill', value);
7222
- const layout = this.__leaf.__layout;
7223
- layout.boxChanged || layout.boxChange();
7224
- this.__isFills = true;
7225
- this._fill || (this._fill = emptyPaint);
7336
+ this.__setPaint('fill', value);
7226
7337
  }
7227
7338
  }
7228
7339
  setStroke(value) {
7229
7340
  if (typeof value === 'string' || !value) {
7230
- if (this.__isStrokes) {
7231
- this.__removeInput('stroke');
7232
- PaintImage.recycleImage('stroke', this);
7233
- this.__isStrokes = false;
7234
- this.__pixelStroke && (this.__pixelStroke = false);
7235
- }
7341
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7342
+ this.__isStrokes && this.__removePaint('stroke', true);
7236
7343
  this._stroke = value;
7237
7344
  }
7238
7345
  else if (typeof value === 'object') {
7239
- this.__setInput('stroke', value);
7240
- const layout = this.__leaf.__layout;
7241
- layout.boxChanged || layout.boxChange();
7242
- this.__isStrokes = true;
7243
- this._stroke || (this._stroke = emptyPaint);
7346
+ this.__setPaint('stroke', value);
7244
7347
  }
7245
7348
  }
7246
7349
  setPath(value) {
@@ -7270,7 +7373,34 @@ class UIData extends LeafData {
7270
7373
  Paint.compute('fill', this.__leaf);
7271
7374
  if (stroke)
7272
7375
  Paint.compute('stroke', this.__leaf);
7273
- this.__needComputePaint = false;
7376
+ this.__needComputePaint = undefined;
7377
+ }
7378
+ __setPaint(attrName, value) {
7379
+ this.__setInput(attrName, value);
7380
+ const layout = this.__leaf.__layout;
7381
+ layout.boxChanged || layout.boxChange();
7382
+ if (value instanceof Array && !value.length) {
7383
+ this.__removePaint(attrName);
7384
+ }
7385
+ else {
7386
+ if (attrName === 'fill')
7387
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7388
+ else
7389
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7390
+ }
7391
+ }
7392
+ __removePaint(attrName, removeInput) {
7393
+ if (removeInput)
7394
+ this.__removeInput(attrName);
7395
+ PaintImage.recycleImage(attrName, this);
7396
+ if (attrName === 'fill') {
7397
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7398
+ this._fill = this.__isFills = undefined;
7399
+ }
7400
+ else {
7401
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7402
+ this._stroke = this.__isStrokes = undefined;
7403
+ }
7274
7404
  }
7275
7405
  }
7276
7406
  function setArray(data, key, value) {
@@ -7278,10 +7408,10 @@ function setArray(data, key, value) {
7278
7408
  if (value instanceof Array) {
7279
7409
  if (value.some((item) => item.visible === false))
7280
7410
  value = value.filter((item) => item.visible !== false);
7281
- value.length || (value = null);
7411
+ value.length || (value = undefined);
7282
7412
  }
7283
7413
  else
7284
- value = value && value.visible !== false ? [value] : null;
7414
+ value = value && value.visible !== false ? [value] : undefined;
7285
7415
  data['_' + key] = value;
7286
7416
  }
7287
7417
 
@@ -7345,13 +7475,11 @@ class TextData extends UIData {
7345
7475
  setFontWeight(value) {
7346
7476
  if (typeof value === 'string') {
7347
7477
  this.__setInput('fontWeight', value);
7348
- this._fontWeight = fontWeightMap[value] || 400;
7349
- }
7350
- else {
7351
- if (this.__input)
7352
- this.__removeInput('fontWeight');
7353
- this._fontWeight = value;
7478
+ value = fontWeightMap[value] || 400;
7354
7479
  }
7480
+ else if (this.__input)
7481
+ this.__removeInput('fontWeight');
7482
+ this._fontWeight = value;
7355
7483
  }
7356
7484
  setBoxStyle(value) {
7357
7485
  let t = this.__leaf, box = t.__box;
@@ -7386,8 +7514,6 @@ class ImageData extends RectData {
7386
7514
  this._url = value;
7387
7515
  }
7388
7516
  __setImageFill(value) {
7389
- if (this.__leaf.image)
7390
- this.__leaf.image = null;
7391
7517
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7392
7518
  }
7393
7519
  __getData() {
@@ -7453,21 +7579,19 @@ const UIBounds = {
7453
7579
  }
7454
7580
  };
7455
7581
 
7582
+ const { stintSet: stintSet$1 } = DataHelper;
7456
7583
  const UIRender = {
7457
7584
  __updateChange() {
7458
- const data = this.__, w = this.__world;
7585
+ const data = this.__;
7459
7586
  if (data.__useEffect) {
7460
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7461
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7587
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7588
+ 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')));
7589
+ data.__useEffect = !!(shadow || otherEffect);
7462
7590
  }
7463
- const half = data.__hasHalf;
7464
- w.half !== half && (w.half = half);
7591
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7592
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7465
7593
  data.__checkSingle();
7466
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7467
- if (complex)
7468
- data.__complex = true;
7469
- else
7470
- data.__complex && (data.__complex = false);
7594
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7471
7595
  },
7472
7596
  __drawFast(canvas, options) {
7473
7597
  drawFast(this, canvas, options);
@@ -7477,21 +7601,23 @@ const UIRender = {
7477
7601
  if (data.__complex) {
7478
7602
  if (data.__needComputePaint)
7479
7603
  data.__computePaint();
7480
- const { fill, stroke, __drawAfterFill } = data;
7604
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7481
7605
  this.__drawRenderPath(canvas);
7482
- if (data.__useEffect) {
7606
+ if (data.__useEffect && !__isFastShadow) {
7483
7607
  const shape = Paint.shape(this, canvas, options);
7484
7608
  this.__nowWorld = this.__getNowWorld(options);
7485
7609
  const { shadow, innerShadow, filter } = data;
7486
7610
  if (shadow)
7487
7611
  Effect.shadow(this, canvas, shape);
7612
+ if (__fillAfterStroke)
7613
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7488
7614
  if (fill)
7489
7615
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7490
7616
  if (__drawAfterFill)
7491
7617
  this.__drawAfterFill(canvas, options);
7492
7618
  if (innerShadow)
7493
7619
  Effect.innerShadow(this, canvas, shape);
7494
- if (stroke)
7620
+ if (stroke && !__fillAfterStroke)
7495
7621
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7496
7622
  if (filter)
7497
7623
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7500,21 +7626,27 @@ const UIRender = {
7500
7626
  shape.canvas.recycle();
7501
7627
  }
7502
7628
  else {
7629
+ if (__fillAfterStroke)
7630
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7631
+ if (__isFastShadow) {
7632
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7633
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7634
+ }
7503
7635
  if (fill)
7504
7636
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7637
+ if (__isFastShadow)
7638
+ canvas.restore();
7505
7639
  if (__drawAfterFill)
7506
7640
  this.__drawAfterFill(canvas, options);
7507
- if (stroke)
7641
+ if (stroke && !__fillAfterStroke)
7508
7642
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7509
7643
  }
7510
7644
  }
7511
7645
  else {
7512
- if (data.__pathInputed) {
7646
+ if (data.__pathInputed)
7513
7647
  drawFast(this, canvas, options);
7514
- }
7515
- else {
7648
+ else
7516
7649
  this.__drawFast(canvas, options);
7517
- }
7518
7650
  }
7519
7651
  },
7520
7652
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7523,11 +7655,11 @@ const UIRender = {
7523
7655
  const { fill, stroke } = this.__;
7524
7656
  this.__drawRenderPath(canvas);
7525
7657
  if (fill && !ignoreFill)
7526
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7658
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7527
7659
  if (this.__.__isCanvas)
7528
7660
  this.__drawAfterFill(canvas, options);
7529
7661
  if (stroke && !ignoreStroke)
7530
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7662
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7531
7663
  }
7532
7664
  },
7533
7665
  __drawAfterFill(canvas, options) {
@@ -7542,13 +7674,15 @@ const UIRender = {
7542
7674
  }
7543
7675
  };
7544
7676
  function drawFast(ui, canvas, options) {
7545
- const { fill, stroke, __drawAfterFill } = ui.__;
7677
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7546
7678
  ui.__drawRenderPath(canvas);
7679
+ if (__fillAfterStroke)
7680
+ Paint.stroke(stroke, ui, canvas);
7547
7681
  if (fill)
7548
7682
  Paint.fill(fill, ui, canvas);
7549
7683
  if (__drawAfterFill)
7550
7684
  ui.__drawAfterFill(canvas, options);
7551
- if (stroke)
7685
+ if (stroke && !__fillAfterStroke)
7552
7686
  Paint.stroke(stroke, ui, canvas);
7553
7687
  }
7554
7688
 
@@ -7678,6 +7812,9 @@ let UI = UI_1 = class UI extends Leaf {
7678
7812
  else
7679
7813
  drawer.rect(x, y, width, height);
7680
7814
  }
7815
+ drawImagePlaceholder(canvas, _image) {
7816
+ Paint.fill(this.__.placeholderColor, this, canvas);
7817
+ }
7681
7818
  animate(_keyframe, _options, _type, _isTemp) {
7682
7819
  return Plugin.need('animate');
7683
7820
  }
@@ -7914,6 +8051,12 @@ __decorate([
7914
8051
  __decorate([
7915
8052
  effectType()
7916
8053
  ], UI.prototype, "filter", void 0);
8054
+ __decorate([
8055
+ surfaceType()
8056
+ ], UI.prototype, "placeholderColor", void 0);
8057
+ __decorate([
8058
+ dataType(100)
8059
+ ], UI.prototype, "placeholderDelay", void 0);
7917
8060
  __decorate([
7918
8061
  dataType({})
7919
8062
  ], UI.prototype, "data", void 0);
@@ -8315,15 +8458,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8315
8458
  }
8316
8459
  __listenEvents() {
8317
8460
  const runId = Run.start('FirstCreate ' + this.innerName);
8318
- this.once(LeaferEvent.START, () => Run.end(runId));
8319
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8320
- this.once(RenderEvent.START, () => this.__onCreated());
8321
- this.once(RenderEvent.END, () => this.__onViewReady());
8322
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8461
+ this.once([
8462
+ [LeaferEvent.START, () => Run.end(runId)],
8463
+ [LayoutEvent.START, this.updateLazyBounds, this],
8464
+ [RenderEvent.START, this.__onCreated, this],
8465
+ [RenderEvent.END, this.__onViewReady, this]
8466
+ ]);
8467
+ this.__eventIds.push(this.on_([
8468
+ [WatchEvent.DATA, this.__onWatchData, this],
8469
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8470
+ [RenderEvent.NEXT, this.__onNextRender, this]
8471
+ ]));
8323
8472
  }
8324
8473
  __removeListenEvents() {
8325
8474
  this.off_(this.__eventIds);
8326
- this.__eventIds.length = 0;
8327
8475
  }
8328
8476
  destroy(sync) {
8329
8477
  const doDestory = () => {
@@ -8431,13 +8579,13 @@ let Box = class Box extends Group {
8431
8579
  super.__updateRenderBounds();
8432
8580
  copy$3(childrenRenderBounds, renderBounds);
8433
8581
  this.__updateRectRenderBounds();
8434
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8582
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8435
8583
  if (isOverflow && this.__.overflow !== 'hide')
8436
8584
  add(renderBounds, childrenRenderBounds);
8437
8585
  }
8438
8586
  else
8439
8587
  this.__updateRectRenderBounds();
8440
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8588
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8441
8589
  }
8442
8590
  __updateRectRenderBounds() { }
8443
8591
  __updateRectChange() { }
@@ -8741,17 +8889,10 @@ Star = __decorate([
8741
8889
 
8742
8890
  let Image = class Image extends Rect {
8743
8891
  get __tag() { return 'Image'; }
8744
- get ready() { return this.image ? this.image.ready : false; }
8892
+ get ready() { const { image } = this; return image && image.ready; }
8893
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8745
8894
  constructor(data) {
8746
8895
  super(data);
8747
- this.on(ImageEvent.LOADED, (e) => {
8748
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8749
- this.image = e.image;
8750
- });
8751
- }
8752
- destroy() {
8753
- this.image = null;
8754
- super.destroy();
8755
8896
  }
8756
8897
  };
8757
8898
  __decorate([
@@ -8767,11 +8908,11 @@ const MyImage = Image;
8767
8908
 
8768
8909
  let Canvas = class Canvas extends Rect {
8769
8910
  get __tag() { return 'Canvas'; }
8911
+ get context() { return this.canvas.context; }
8770
8912
  get ready() { return !this.url; }
8771
8913
  constructor(data) {
8772
8914
  super(data);
8773
8915
  this.canvas = Creator.canvas(this.__);
8774
- this.context = this.canvas.context;
8775
8916
  if (data && data.url)
8776
8917
  this.drawImage(data.url);
8777
8918
  }
@@ -8815,7 +8956,7 @@ let Canvas = class Canvas extends Rect {
8815
8956
  destroy() {
8816
8957
  if (this.canvas) {
8817
8958
  this.canvas.destroy();
8818
- this.canvas = this.context = null;
8959
+ this.canvas = null;
8819
8960
  }
8820
8961
  super.destroy();
8821
8962
  }
@@ -8861,7 +9002,7 @@ let Text = class Text extends UI {
8861
9002
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8862
9003
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8863
9004
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8864
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
9005
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8865
9006
  }
8866
9007
  __updateBoxBounds() {
8867
9008
  const data = this.__;
@@ -8891,12 +9032,11 @@ let Text = class Text extends UI {
8891
9032
  super.__updateBoxBounds();
8892
9033
  if (italic)
8893
9034
  b.width += fontSize * 0.16;
8894
- const isOverflow = !includes(b, contentBounds) || undefined;
8895
- if (isOverflow)
9035
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
9036
+ if (this.isOverflow)
8896
9037
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8897
9038
  else
8898
9039
  data.__textBoxBounds = b;
8899
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8900
9040
  }
8901
9041
  __onUpdateSize() {
8902
9042
  if (this.__box)
@@ -8959,6 +9099,9 @@ __decorate([
8959
9099
  __decorate([
8960
9100
  boundsType('')
8961
9101
  ], Text.prototype, "text", void 0);
9102
+ __decorate([
9103
+ boundsType('')
9104
+ ], Text.prototype, "placeholder", void 0);
8962
9105
  __decorate([
8963
9106
  boundsType('caption')
8964
9107
  ], Text.prototype, "fontFamily", void 0);
@@ -9094,7 +9237,7 @@ let App = class App extends Leafer {
9094
9237
  if (sky || editor)
9095
9238
  this.sky = this.addLeafer(sky);
9096
9239
  if (editor)
9097
- this.sky.add(this.editor = Creator.editor(editor));
9240
+ Creator.editor(editor, this);
9098
9241
  }
9099
9242
  }
9100
9243
  __setApp() {
@@ -9108,6 +9251,10 @@ let App = class App extends Leafer {
9108
9251
  this.watcher.disable();
9109
9252
  this.layouter.disable();
9110
9253
  }
9254
+ __updateLocalBounds() {
9255
+ this.forEach(leafer => leafer.updateLayout());
9256
+ super.__updateLocalBounds();
9257
+ }
9111
9258
  start() {
9112
9259
  super.start();
9113
9260
  this.forEach(leafer => leafer.start());
@@ -9165,12 +9312,8 @@ let App = class App extends Leafer {
9165
9312
  this.renderer.update();
9166
9313
  }
9167
9314
  __render(canvas, options) {
9168
- if (canvas.context) {
9169
- const m = options.matrix;
9170
- if (m)
9171
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9172
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9173
- }
9315
+ if (canvas.context)
9316
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9174
9317
  }
9175
9318
  __onResize(event) {
9176
9319
  this.forEach(leafer => leafer.resize(event));
@@ -9191,9 +9334,11 @@ let App = class App extends Leafer {
9191
9334
  return config;
9192
9335
  }
9193
9336
  __listenChildEvents(leafer) {
9194
- leafer.once(LayoutEvent.END, () => this.__onReady());
9195
- leafer.once(RenderEvent.START, () => this.__onCreated());
9196
- leafer.once(RenderEvent.END, () => this.__onViewReady());
9337
+ leafer.once([
9338
+ [LayoutEvent.END, this.__onReady, this],
9339
+ [RenderEvent.START, this.__onCreated, this],
9340
+ [RenderEvent.END, this.__onViewReady, this]
9341
+ ]);
9197
9342
  if (this.realCanvas)
9198
9343
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9199
9344
  }
@@ -9404,7 +9549,7 @@ MoveEvent = __decorate([
9404
9549
  registerUIEvent()
9405
9550
  ], MoveEvent);
9406
9551
 
9407
- let RotateEvent = class RotateEvent extends UIEvent {
9552
+ let RotateEvent = class RotateEvent extends PointerEvent {
9408
9553
  };
9409
9554
  RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9410
9555
  RotateEvent.START = 'rotate.start';
@@ -9425,7 +9570,7 @@ SwipeEvent = __decorate([
9425
9570
  registerUIEvent()
9426
9571
  ], SwipeEvent);
9427
9572
 
9428
- let ZoomEvent = class ZoomEvent extends UIEvent {
9573
+ let ZoomEvent = class ZoomEvent extends PointerEvent {
9429
9574
  };
9430
9575
  ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9431
9576
  ZoomEvent.START = 'zoom.start';
@@ -10268,8 +10413,8 @@ ui$1.__updateHitCanvas = function () {
10268
10413
  if (this.__box)
10269
10414
  this.__box.__updateHitCanvas();
10270
10415
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10271
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10272
- const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10416
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10417
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10273
10418
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10274
10419
  if (!this.__hitCanvas)
10275
10420
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10300,11 +10445,11 @@ ui$1.__hit = function (inner) {
10300
10445
  if (data.__isHitPixel && this.__hitPixel(inner))
10301
10446
  return true;
10302
10447
  const { hitFill } = data;
10303
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10448
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10304
10449
  if (needHitFillPath && this.__hitFill(inner))
10305
10450
  return true;
10306
10451
  const { hitStroke, __strokeWidth } = data;
10307
- const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10452
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10308
10453
  if (!needHitFillPath && !needHitStrokePath)
10309
10454
  return false;
10310
10455
  const radiusWidth = inner.radiusX * 2;
@@ -10489,8 +10634,10 @@ class Interaction extends InteractionBase {
10489
10634
  }
10490
10635
 
10491
10636
  function fillText(ui, canvas) {
10492
- let row, data = ui.__.__textDrawData;
10493
- const { rows, decorationY } = data;
10637
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10638
+ if (data.__isPlacehold && data.placeholderColor)
10639
+ canvas.fillStyle = data.placeholderColor;
10640
+ let row;
10494
10641
  for (let i = 0, len = rows.length; i < len; i++) {
10495
10642
  row = rows[i];
10496
10643
  if (row.text)
@@ -10499,7 +10646,7 @@ function fillText(ui, canvas) {
10499
10646
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10500
10647
  }
10501
10648
  if (decorationY) {
10502
- const { decorationColor, decorationHeight } = data;
10649
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10503
10650
  if (decorationColor)
10504
10651
  canvas.fillStyle = decorationColor;
10505
10652
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10508,65 +10655,71 @@ function fillText(ui, canvas) {
10508
10655
 
10509
10656
  function fill(fill, ui, canvas) {
10510
10657
  canvas.fillStyle = fill;
10511
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10658
+ fillPathOrText(ui, canvas);
10512
10659
  }
10513
10660
  function fills(fills, ui, canvas) {
10514
10661
  let item;
10515
- const { windingRule, __font } = ui.__;
10516
10662
  for (let i = 0, len = fills.length; i < len; i++) {
10517
10663
  item = fills[i];
10518
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10519
- continue;
10520
- if (item.style) {
10521
- canvas.fillStyle = item.style;
10522
- if (item.transform) {
10523
- canvas.save();
10524
- canvas.transform(item.transform);
10525
- if (item.blendMode)
10526
- canvas.blendMode = item.blendMode;
10527
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10528
- canvas.restore();
10664
+ if (item.image) {
10665
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10666
+ continue;
10667
+ if (!item.style) {
10668
+ if (!i && item.image.isPlacehold)
10669
+ ui.drawImagePlaceholder(canvas, item.image);
10670
+ continue;
10529
10671
  }
10530
- else {
10531
- if (item.blendMode) {
10532
- canvas.saveBlendMode(item.blendMode);
10533
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10534
- canvas.restoreBlendMode();
10535
- }
10536
- else {
10537
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10538
- }
10672
+ }
10673
+ canvas.fillStyle = item.style;
10674
+ if (item.transform) {
10675
+ canvas.save();
10676
+ canvas.transform(item.transform);
10677
+ if (item.blendMode)
10678
+ canvas.blendMode = item.blendMode;
10679
+ fillPathOrText(ui, canvas);
10680
+ canvas.restore();
10681
+ }
10682
+ else {
10683
+ if (item.blendMode) {
10684
+ canvas.saveBlendMode(item.blendMode);
10685
+ fillPathOrText(ui, canvas);
10686
+ canvas.restoreBlendMode();
10539
10687
  }
10688
+ else
10689
+ fillPathOrText(ui, canvas);
10540
10690
  }
10541
10691
  }
10542
10692
  }
10693
+ function fillPathOrText(ui, canvas) {
10694
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10695
+ }
10543
10696
 
10544
10697
  function strokeText(stroke, ui, canvas) {
10545
- const { strokeAlign } = ui.__;
10546
- const isStrokes = typeof stroke !== 'string';
10547
- switch (strokeAlign) {
10698
+ switch (ui.__.strokeAlign) {
10548
10699
  case 'center':
10549
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10550
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10700
+ drawCenter$1(stroke, 1, ui, canvas);
10551
10701
  break;
10552
10702
  case 'inside':
10553
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10703
+ drawAlign(stroke, 'inside', ui, canvas);
10554
10704
  break;
10555
10705
  case 'outside':
10556
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10706
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10557
10707
  break;
10558
10708
  }
10559
10709
  }
10560
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10561
- const { __strokeWidth, __font } = ui.__;
10710
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10711
+ const data = ui.__;
10712
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10713
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10714
+ }
10715
+ function drawAlign(stroke, align, ui, canvas) {
10562
10716
  const out = canvas.getSameCanvas(true, true);
10563
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10564
- out.font = __font;
10565
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10717
+ out.font = ui.__.__font;
10718
+ drawCenter$1(stroke, 2, ui, out);
10566
10719
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10567
10720
  fillText(ui, out);
10568
10721
  out.blendMode = 'normal';
10569
- if (ui.__worldFlipped)
10722
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10570
10723
  canvas.copyWorldByReset(out, ui.__nowWorld);
10571
10724
  else
10572
10725
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10608,90 +10761,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
10608
10761
  }
10609
10762
 
10610
10763
  function stroke(stroke, ui, canvas) {
10611
- const options = ui.__;
10612
- const { __strokeWidth, strokeAlign, __font } = options;
10613
- if (!__strokeWidth)
10764
+ const data = ui.__;
10765
+ if (!data.__strokeWidth)
10614
10766
  return;
10615
- if (__font) {
10767
+ if (data.__font) {
10616
10768
  strokeText(stroke, ui, canvas);
10617
10769
  }
10618
10770
  else {
10619
- switch (strokeAlign) {
10771
+ switch (data.strokeAlign) {
10620
10772
  case 'center':
10621
- canvas.setStroke(stroke, __strokeWidth, options);
10622
- canvas.stroke();
10623
- if (options.__useArrow)
10624
- strokeArrow(ui, canvas);
10773
+ drawCenter(stroke, 1, ui, canvas);
10625
10774
  break;
10626
10775
  case 'inside':
10627
- canvas.save();
10628
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10629
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10630
- canvas.stroke();
10631
- canvas.restore();
10776
+ drawInside(stroke, ui, canvas);
10632
10777
  break;
10633
10778
  case 'outside':
10634
- const out = canvas.getSameCanvas(true, true);
10635
- out.setStroke(stroke, __strokeWidth * 2, options);
10636
- ui.__drawRenderPath(out);
10637
- out.stroke();
10638
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10639
- out.clearWorld(ui.__layout.renderBounds);
10640
- if (ui.__worldFlipped)
10641
- canvas.copyWorldByReset(out, ui.__nowWorld);
10642
- else
10643
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10644
- out.recycle(ui.__nowWorld);
10779
+ drawOutside(stroke, ui, canvas);
10645
10780
  break;
10646
10781
  }
10647
10782
  }
10648
10783
  }
10649
10784
  function strokes(strokes, ui, canvas) {
10650
- const options = ui.__;
10651
- const { __strokeWidth, strokeAlign, __font } = options;
10652
- if (!__strokeWidth)
10653
- return;
10654
- if (__font) {
10655
- strokeText(strokes, ui, canvas);
10785
+ stroke(strokes, ui, canvas);
10786
+ }
10787
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10788
+ const data = ui.__;
10789
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10790
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10791
+ if (data.__useArrow)
10792
+ Paint.strokeArrow(stroke, ui, canvas);
10793
+ }
10794
+ function drawInside(stroke, ui, canvas) {
10795
+ const data = ui.__;
10796
+ canvas.save();
10797
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
10798
+ drawCenter(stroke, 2, ui, canvas);
10799
+ canvas.restore();
10800
+ }
10801
+ function drawOutside(stroke, ui, canvas) {
10802
+ const data = ui.__;
10803
+ if (data.__fillAfterStroke) {
10804
+ drawCenter(stroke, 2, ui, canvas);
10656
10805
  }
10657
10806
  else {
10658
- switch (strokeAlign) {
10659
- case 'center':
10660
- canvas.setStroke(undefined, __strokeWidth, options);
10661
- drawStrokesStyle(strokes, false, ui, canvas);
10662
- if (options.__useArrow)
10663
- strokeArrow(ui, canvas);
10664
- break;
10665
- case 'inside':
10666
- canvas.save();
10667
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10668
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10669
- drawStrokesStyle(strokes, false, ui, canvas);
10670
- canvas.restore();
10671
- break;
10672
- case 'outside':
10673
- const { renderBounds } = ui.__layout;
10674
- const out = canvas.getSameCanvas(true, true);
10675
- ui.__drawRenderPath(out);
10676
- out.setStroke(undefined, __strokeWidth * 2, options);
10677
- drawStrokesStyle(strokes, false, ui, out);
10678
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10679
- out.clearWorld(renderBounds);
10680
- if (ui.__worldFlipped)
10681
- canvas.copyWorldByReset(out, ui.__nowWorld);
10682
- else
10683
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10684
- out.recycle(ui.__nowWorld);
10685
- break;
10686
- }
10687
- }
10688
- }
10689
- function strokeArrow(ui, canvas) {
10690
- if (ui.__.dashPattern) {
10691
- canvas.beginPath();
10692
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10693
- canvas.dashPattern = null;
10694
- canvas.stroke();
10807
+ const { renderBounds } = ui.__layout;
10808
+ const out = canvas.getSameCanvas(true, true);
10809
+ ui.__drawRenderPath(out);
10810
+ drawCenter(stroke, 2, ui, out);
10811
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
10812
+ out.clearWorld(renderBounds);
10813
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10814
+ canvas.copyWorldByReset(out, ui.__nowWorld);
10815
+ else
10816
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10817
+ out.recycle(ui.__nowWorld);
10695
10818
  }
10696
10819
  }
10697
10820
 
@@ -10738,9 +10861,10 @@ function shape(ui, current, options) {
10738
10861
  }
10739
10862
 
10740
10863
  let recycleMap;
10864
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
10741
10865
  function compute(attrName, ui) {
10742
10866
  const data = ui.__, leafPaints = [];
10743
- let paints = data.__input[attrName], hasOpacityPixel;
10867
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
10744
10868
  if (!(paints instanceof Array))
10745
10869
  paints = [paints];
10746
10870
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -10750,35 +10874,62 @@ function compute(attrName, ui) {
10750
10874
  leafPaints.push(item);
10751
10875
  }
10752
10876
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10753
- if (leafPaints.length && leafPaints[0].image)
10754
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
10755
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
10877
+ if (leafPaints.length) {
10878
+ if (leafPaints.every(item => item.isTransparent)) {
10879
+ if (leafPaints.some(item => item.image))
10880
+ isAlphaPixel = true;
10881
+ isTransparent = true;
10882
+ }
10883
+ }
10884
+ if (attrName === 'fill') {
10885
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
10886
+ stintSet(data, '__isTransparentFill', isTransparent);
10887
+ }
10888
+ else {
10889
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10890
+ stintSet(data, '__isTransparentStroke', isTransparent);
10891
+ }
10756
10892
  }
10757
10893
  function getLeafPaint(attrName, paint, ui) {
10758
10894
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
10759
10895
  return undefined;
10896
+ let data;
10760
10897
  const { boxBounds } = ui.__layout;
10761
10898
  switch (paint.type) {
10762
- case 'solid':
10763
- let { type, blendMode, color, opacity } = paint;
10764
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
10765
10899
  case 'image':
10766
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10900
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10901
+ break;
10767
10902
  case 'linear':
10768
- return PaintGradient.linearGradient(paint, boxBounds);
10903
+ data = PaintGradient.linearGradient(paint, boxBounds);
10904
+ break;
10769
10905
  case 'radial':
10770
- return PaintGradient.radialGradient(paint, boxBounds);
10906
+ data = PaintGradient.radialGradient(paint, boxBounds);
10907
+ break;
10771
10908
  case 'angular':
10772
- return PaintGradient.conicGradient(paint, boxBounds);
10909
+ data = PaintGradient.conicGradient(paint, boxBounds);
10910
+ break;
10911
+ case 'solid':
10912
+ const { type, blendMode, color, opacity } = paint;
10913
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
10914
+ break;
10773
10915
  default:
10774
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10916
+ if (paint.r !== undefined)
10917
+ data = { type: 'solid', style: ColorConvert.string(paint) };
10918
+ }
10919
+ if (data) {
10920
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
10921
+ data.isTransparent = true;
10922
+ if (paint.blendMode)
10923
+ data.blendMode = paint.blendMode;
10775
10924
  }
10925
+ return data;
10776
10926
  }
10777
10927
 
10778
10928
  const PaintModule = {
10779
10929
  compute,
10780
10930
  fill,
10781
10931
  fills,
10932
+ fillPathOrText,
10782
10933
  fillText,
10783
10934
  stroke,
10784
10935
  strokes,
@@ -10837,12 +10988,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
10837
10988
 
10838
10989
  const { get: get$2, translate } = MatrixHelper;
10839
10990
  const tempBox = new Bounds();
10840
- const tempPoint = {};
10841
10991
  const tempScaleData = {};
10992
+ const tempImage = {};
10842
10993
  function createData(leafPaint, image, paint, box) {
10843
- const { blendMode, changeful, sync } = paint;
10844
- if (blendMode)
10845
- leafPaint.blendMode = blendMode;
10994
+ const { changeful, sync } = paint;
10846
10995
  if (changeful)
10847
10996
  leafPaint.changeful = changeful;
10848
10997
  if (sync)
@@ -10850,38 +10999,38 @@ function createData(leafPaint, image, paint, box) {
10850
10999
  leafPaint.data = getPatternData(paint, box, image);
10851
11000
  }
10852
11001
  function getPatternData(paint, box, image) {
10853
- let { width, height } = image;
10854
11002
  if (paint.padding)
10855
11003
  box = tempBox.set(box).shrink(paint.padding);
10856
11004
  if (paint.mode === 'strench')
10857
11005
  paint.mode = 'stretch';
11006
+ let { width, height } = image;
10858
11007
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
10859
11008
  const sameBox = box.width === width && box.height === height;
10860
11009
  const data = { mode };
10861
11010
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10862
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10863
- let x = 0, y = 0, scaleX, scaleY;
11011
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
11012
+ let scaleX, scaleY;
10864
11013
  if (!mode || mode === 'cover' || mode === 'fit') {
10865
11014
  if (!sameBox || rotation) {
10866
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
10867
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10868
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
11015
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
11016
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
11017
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
10869
11018
  }
10870
11019
  }
10871
- else if (scale || size) {
10872
- MathHelper.getScaleData(scale, size, image, tempScaleData);
10873
- scaleX = tempScaleData.scaleX;
10874
- scaleY = tempScaleData.scaleY;
10875
- }
10876
- if (align) {
10877
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10878
- if (scaleX)
10879
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10880
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
10881
- x += tempPoint.x, y += tempPoint.y;
11020
+ else {
11021
+ if (scale || size) {
11022
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
11023
+ scaleX = tempScaleData.scaleX;
11024
+ scaleY = tempScaleData.scaleY;
11025
+ }
11026
+ if (align) {
11027
+ if (scaleX)
11028
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
11029
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
11030
+ }
10882
11031
  }
10883
11032
  if (offset)
10884
- x += offset.x, y += offset.y;
11033
+ PointHelper.move(tempImage, offset);
10885
11034
  switch (mode) {
10886
11035
  case 'stretch':
10887
11036
  if (!sameBox)
@@ -10889,12 +11038,12 @@ function getPatternData(paint, box, image) {
10889
11038
  break;
10890
11039
  case 'normal':
10891
11040
  case 'clip':
10892
- if (x || y || scaleX || rotation)
10893
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
11041
+ if (tempImage.x || tempImage.y || scaleX || rotation)
11042
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10894
11043
  break;
10895
11044
  case 'repeat':
10896
11045
  if (!sameBox || scaleX || rotation)
10897
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
11046
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
10898
11047
  if (!repeat)
10899
11048
  data.repeat = 'repeat';
10900
11049
  break;
@@ -10902,7 +11051,7 @@ function getPatternData(paint, box, image) {
10902
11051
  case 'cover':
10903
11052
  default:
10904
11053
  if (scaleX)
10905
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
11054
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10906
11055
  }
10907
11056
  if (!data.transform) {
10908
11057
  if (box.x || box.y) {
@@ -10935,6 +11084,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10935
11084
  }
10936
11085
  else {
10937
11086
  leafPaint = { type: paint.type, image };
11087
+ if (image.hasAlphaPixel)
11088
+ leafPaint.isTransparent = true;
10938
11089
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
10939
11090
  }
10940
11091
  if (firstUse || image.loading)
@@ -10959,7 +11110,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10959
11110
  ignoreRender(ui, false);
10960
11111
  if (!ui.destroyed) {
10961
11112
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10962
- if (image.hasOpacityPixel)
11113
+ if (image.hasAlphaPixel)
10963
11114
  ui.__layout.hitCanvasChanged = true;
10964
11115
  ui.forceUpdate('surface');
10965
11116
  }
@@ -10971,6 +11122,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10971
11122
  onLoadError(ui, event, error);
10972
11123
  leafPaint.loadId = null;
10973
11124
  });
11125
+ if (ui.placeholderColor) {
11126
+ if (!ui.placeholderDelay)
11127
+ image.isPlacehold = true;
11128
+ else
11129
+ setTimeout(() => {
11130
+ if (!image.ready) {
11131
+ image.isPlacehold = true;
11132
+ ui.forceUpdate('surface');
11133
+ }
11134
+ }, ui.placeholderDelay);
11135
+ }
10974
11136
  }
10975
11137
  return leafPaint;
10976
11138
  }
@@ -11176,32 +11338,33 @@ const PaintImageModule = {
11176
11338
  repeatMode
11177
11339
  };
11178
11340
 
11179
- const { toPoint: toPoint$2 } = AroundHelper;
11341
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
11180
11342
  const realFrom$2 = {};
11181
11343
  const realTo$2 = {};
11182
11344
  function linearGradient(paint, box) {
11183
- let { from, to, type, blendMode, opacity } = paint;
11345
+ let { from, to, type, opacity } = paint;
11184
11346
  toPoint$2(from || 'top', box, realFrom$2);
11185
11347
  toPoint$2(to || 'bottom', box, realTo$2);
11186
11348
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
11187
- applyStops(style, paint.stops, opacity);
11188
11349
  const data = { type, style };
11189
- if (blendMode)
11190
- data.blendMode = blendMode;
11350
+ applyStops(data, style, paint.stops, opacity);
11191
11351
  return data;
11192
11352
  }
11193
- function applyStops(gradient, stops, opacity) {
11353
+ function applyStops(data, gradient, stops, opacity) {
11194
11354
  if (stops) {
11195
- let stop;
11355
+ let stop, color, offset, isTransparent;
11196
11356
  for (let i = 0, len = stops.length; i < len; i++) {
11197
11357
  stop = stops[i];
11198
- if (typeof stop === 'string') {
11199
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
11200
- }
11201
- else {
11202
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
11203
- }
11358
+ if (typeof stop === 'string')
11359
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
11360
+ else
11361
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
11362
+ gradient.addColorStop(offset, color);
11363
+ if (!isTransparent && hasTransparent(color))
11364
+ isTransparent = true;
11204
11365
  }
11366
+ if (isTransparent)
11367
+ data.isTransparent = true;
11205
11368
  }
11206
11369
  }
11207
11370
 
@@ -11211,17 +11374,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
11211
11374
  const realFrom$1 = {};
11212
11375
  const realTo$1 = {};
11213
11376
  function radialGradient(paint, box) {
11214
- let { from, to, type, opacity, blendMode, stretch } = paint;
11377
+ let { from, to, type, opacity, stretch } = paint;
11215
11378
  toPoint$1(from || 'center', box, realFrom$1);
11216
11379
  toPoint$1(to || 'bottom', box, realTo$1);
11217
11380
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11218
- applyStops(style, paint.stops, opacity);
11219
11381
  const data = { type, style };
11382
+ applyStops(data, style, paint.stops, opacity);
11220
11383
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11221
11384
  if (transform)
11222
11385
  data.transform = transform;
11223
- if (blendMode)
11224
- data.blendMode = blendMode;
11225
11386
  return data;
11226
11387
  }
11227
11388
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11247,17 +11408,15 @@ const { toPoint } = AroundHelper;
11247
11408
  const realFrom = {};
11248
11409
  const realTo = {};
11249
11410
  function conicGradient(paint, box) {
11250
- let { from, to, type, opacity, blendMode, stretch } = paint;
11411
+ let { from, to, type, opacity, stretch } = paint;
11251
11412
  toPoint(from || 'center', box, realFrom);
11252
11413
  toPoint(to || 'bottom', box, realTo);
11253
11414
  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));
11254
- applyStops(style, paint.stops, opacity);
11255
11415
  const data = { type, style };
11416
+ applyStops(data, style, paint.stops, opacity);
11256
11417
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11257
11418
  if (transform)
11258
11419
  data.transform = transform;
11259
- if (blendMode)
11260
- data.blendMode = blendMode;
11261
11420
  return data;
11262
11421
  }
11263
11422
 
@@ -11590,6 +11749,8 @@ function createRows(drawData, content, style) {
11590
11749
  lastCharType = null;
11591
11750
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11592
11751
  word = { data: [] }, row = { words: [] };
11752
+ if (__letterSpacing)
11753
+ content = [...content];
11593
11754
  for (let i = 0, len = content.length; i < len; i++) {
11594
11755
  char = content[i];
11595
11756
  if (char === '\n') {
@@ -12015,5 +12176,4 @@ try {
12015
12176
  }
12016
12177
  catch (_a) { }
12017
12178
 
12018
- 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, 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 };
12019
- //# sourceMappingURL=miniapp.module.js.map
12179
+ 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, 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 };