@leafer-draw/miniapp 1.6.2 → 1.6.4

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$d = 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;
@@ -2245,16 +2269,19 @@ class LeaferCanvasBase extends Canvas$1 {
2245
2269
  if (blendMode)
2246
2270
  this.blendMode = 'source-over';
2247
2271
  }
2248
- clearWorld(bounds, ceilPixel) {
2249
- this.setTempBounds(bounds, ceilPixel);
2250
- this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2251
- }
2252
2272
  clipWorld(bounds, ceilPixel) {
2253
2273
  this.beginPath();
2254
2274
  this.setTempBounds(bounds, ceilPixel);
2255
2275
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2256
2276
  this.clip();
2257
2277
  }
2278
+ clipUI(ruleData) {
2279
+ ruleData.windingRule ? this.clip(ruleData.windingRule) : this.clip();
2280
+ }
2281
+ clearWorld(bounds, ceilPixel) {
2282
+ this.setTempBounds(bounds, ceilPixel);
2283
+ this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2284
+ }
2258
2285
  clear() {
2259
2286
  const { pixelRatio } = this;
2260
2287
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
@@ -2385,7 +2412,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2385
2412
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2386
2413
  const { set, toNumberPoints } = PointHelper;
2387
2414
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
2388
- const tempPoint$2 = {};
2415
+ const tempPoint$1 = {};
2389
2416
  const BezierHelper = {
2390
2417
  points(data, originPoints, curve, close) {
2391
2418
  let points = toNumberPoints(originPoints);
@@ -2407,6 +2434,8 @@ const BezierHelper = {
2407
2434
  cY = points[i + 3];
2408
2435
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2409
2436
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2437
+ if (!ba && !cb)
2438
+ continue;
2410
2439
  d = ba + cb;
2411
2440
  ba = (t * ba) / d;
2412
2441
  cb = (t * cb) / d;
@@ -2576,8 +2605,8 @@ const BezierHelper = {
2576
2605
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2577
2606
  addPoint$1(pointBounds, toX, toY);
2578
2607
  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);
2608
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2609
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2581
2610
  }
2582
2611
  },
2583
2612
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -3386,7 +3415,7 @@ function canvasPatch(drawer) {
3386
3415
  }
3387
3416
 
3388
3417
  const FileHelper = {
3389
- opacityTypes: ['png', 'webp', 'svg'],
3418
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3390
3419
  upperCaseTypeMap: {},
3391
3420
  mineType(type) {
3392
3421
  if (!type || type.startsWith('image'))
@@ -3413,7 +3442,7 @@ const FileHelper = {
3413
3442
  }
3414
3443
  };
3415
3444
  const F = FileHelper;
3416
- F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3445
+ F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3417
3446
 
3418
3447
  const debug$8 = Debug.get('TaskProcessor');
3419
3448
  class TaskItem {
@@ -3730,8 +3759,8 @@ const ImageManager = {
3730
3759
  list.length = 0;
3731
3760
  }
3732
3761
  },
3733
- hasOpacityPixel(config) {
3734
- return FileHelper.opacityTypes.some(item => I.isFormat(item, config));
3762
+ hasAlphaPixel(config) {
3763
+ return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3735
3764
  },
3736
3765
  isFormat(format, config) {
3737
3766
  if (config.format === format)
@@ -3769,7 +3798,7 @@ class LeaferImage {
3769
3798
  this.setView(view.config ? view.view : view);
3770
3799
  }
3771
3800
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3772
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3801
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3773
3802
  }
3774
3803
  load(onSuccess, onError) {
3775
3804
  if (!this.loading) {
@@ -4457,7 +4486,7 @@ const LeafBoundsHelper = {
4457
4486
  }
4458
4487
  };
4459
4488
 
4460
- const { updateBounds: updateBounds$2 } = LeafHelper;
4489
+ const { updateBounds: updateBounds$3 } = LeafHelper;
4461
4490
  const BranchHelper = {
4462
4491
  sort(a, b) {
4463
4492
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4519,11 +4548,11 @@ const BranchHelper = {
4519
4548
  branch = branchStack[i];
4520
4549
  children = branch.children;
4521
4550
  for (let j = 0, len = children.length; j < len; j++) {
4522
- updateBounds$2(children[j]);
4551
+ updateBounds$3(children[j]);
4523
4552
  }
4524
4553
  if (exclude && exclude === branch)
4525
4554
  continue;
4526
- updateBounds$2(branch);
4555
+ updateBounds$3(branch);
4527
4556
  }
4528
4557
  }
4529
4558
  };
@@ -4541,7 +4570,7 @@ const WaitHelper = {
4541
4570
  }
4542
4571
  };
4543
4572
 
4544
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4573
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
4545
4574
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4546
4575
  const localContent = '_localContentBounds';
4547
4576
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -4585,7 +4614,9 @@ class LeafLayout {
4585
4614
  this._localRenderBounds = local;
4586
4615
  }
4587
4616
  update() {
4588
- const { leafer } = this.leaf;
4617
+ const { leaf } = this, { leafer } = leaf;
4618
+ if (leaf.isApp)
4619
+ return updateBounds$2(leaf);
4589
4620
  if (leafer) {
4590
4621
  if (leafer.ready)
4591
4622
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4593,7 +4624,7 @@ class LeafLayout {
4593
4624
  leafer.start();
4594
4625
  }
4595
4626
  else {
4596
- let root = this.leaf;
4627
+ let root = leaf;
4597
4628
  while (root.parent && !root.parent.leafer) {
4598
4629
  root = root.parent;
4599
4630
  }
@@ -4815,7 +4846,7 @@ class LeafLayout {
4815
4846
  }
4816
4847
  childrenSortChange() {
4817
4848
  if (!this.childrenSortChanged) {
4818
- this.childrenSortChanged = true;
4849
+ this.childrenSortChanged = this.affectChildrenSort = true;
4819
4850
  this.leaf.forceUpdate('surface');
4820
4851
  }
4821
4852
  }
@@ -4882,6 +4913,40 @@ ImageEvent.LOAD = 'image.load';
4882
4913
  ImageEvent.LOADED = 'image.loaded';
4883
4914
  ImageEvent.ERROR = 'image.error';
4884
4915
 
4916
+ class BoundsEvent extends Event {
4917
+ static checkHas(leaf, type, mode) {
4918
+ if (mode === 'on') {
4919
+ type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
4920
+ }
4921
+ else {
4922
+ leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
4923
+ leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
4924
+ }
4925
+ }
4926
+ static emitLocal(leaf) {
4927
+ if (leaf.leaferIsReady) {
4928
+ const { resized } = leaf.__layout;
4929
+ if (resized !== 'local') {
4930
+ leaf.emit(RESIZE, leaf);
4931
+ if (resized === 'inner')
4932
+ leaf.emit(INNER, leaf);
4933
+ }
4934
+ leaf.emit(LOCAL, leaf);
4935
+ }
4936
+ }
4937
+ static emitWorld(leaf) {
4938
+ if (leaf.leaferIsReady)
4939
+ leaf.emit(WORLD, this);
4940
+ }
4941
+ }
4942
+ BoundsEvent.RESIZE = 'bounds.resize';
4943
+ BoundsEvent.INNER = 'bounds.inner';
4944
+ BoundsEvent.LOCAL = 'bounds.local';
4945
+ BoundsEvent.WORLD = 'bounds.world';
4946
+ const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
4947
+ const boundsEventMap = {};
4948
+ [RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
4949
+
4885
4950
  class ResizeEvent extends Event {
4886
4951
  get bigger() {
4887
4952
  if (!this.old)
@@ -4978,9 +5043,12 @@ class Eventer {
4978
5043
  set event(map) { this.on(map); }
4979
5044
  on(type, listener, options) {
4980
5045
  if (!listener) {
4981
- let event, map = type;
4982
- for (let key in map)
4983
- event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
5046
+ let event;
5047
+ if (type instanceof Array)
5048
+ type.forEach(item => this.on(item[0], item[1], item[2]));
5049
+ else
5050
+ for (let key in type)
5051
+ (event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
4984
5052
  return;
4985
5053
  }
4986
5054
  let capture, once;
@@ -5010,6 +5078,8 @@ class Eventer {
5010
5078
  else {
5011
5079
  map[type] = [item];
5012
5080
  }
5081
+ if (boundsEventMap[type])
5082
+ BoundsEvent.checkHas(this, type, 'on');
5013
5083
  }
5014
5084
  });
5015
5085
  }
@@ -5031,6 +5101,8 @@ class Eventer {
5031
5101
  events.splice(index, 1);
5032
5102
  if (!events.length)
5033
5103
  delete map[type];
5104
+ if (boundsEventMap[type])
5105
+ BoundsEvent.checkHas(this, type, 'off');
5034
5106
  }
5035
5107
  }
5036
5108
  });
@@ -5050,19 +5122,31 @@ class Eventer {
5050
5122
  }
5051
5123
  }
5052
5124
  on_(type, listener, bind, options) {
5053
- if (bind)
5054
- listener = listener.bind(bind);
5055
- this.on(type, listener, options);
5125
+ if (!listener)
5126
+ (type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
5127
+ else
5128
+ this.on(type, bind ? listener = listener.bind(bind) : listener, options);
5056
5129
  return { type, current: this, listener, options };
5057
5130
  }
5058
5131
  off_(id) {
5059
5132
  if (!id)
5060
5133
  return;
5061
5134
  const list = id instanceof Array ? id : [id];
5062
- list.forEach(item => item.current.off(item.type, item.listener, item.options));
5135
+ list.forEach(item => {
5136
+ if (!item.listener)
5137
+ (item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
5138
+ else
5139
+ item.current.off(item.type, item.listener, item.options);
5140
+ });
5063
5141
  list.length = 0;
5064
5142
  }
5065
- once(type, listener, capture) {
5143
+ once(type, listener, captureOrBind, capture) {
5144
+ if (!listener)
5145
+ return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
5146
+ if (typeof captureOrBind === 'object')
5147
+ listener = listener.bind(captureOrBind);
5148
+ else
5149
+ capture = captureOrBind;
5066
5150
  this.on(type, listener, { once: true, capture });
5067
5151
  }
5068
5152
  emit(type, event, capture) {
@@ -5174,7 +5258,7 @@ const LeafDataProxy = {
5174
5258
  };
5175
5259
 
5176
5260
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5177
- const { toPoint: toPoint$3, tempPoint: tempPoint$1 } = AroundHelper;
5261
+ const { toPoint: toPoint$3, tempPoint } = AroundHelper;
5178
5262
  const LeafMatrix = {
5179
5263
  __updateWorldMatrix() {
5180
5264
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
@@ -5183,19 +5267,19 @@ const LeafMatrix = {
5183
5267
  if (this.__local) {
5184
5268
  const layout = this.__layout, local = this.__local, data = this.__;
5185
5269
  if (layout.affectScaleOrRotation) {
5186
- if (layout.scaleChanged || layout.rotationChanged) {
5270
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5187
5271
  setLayout(local, data, null, null, layout.affectRotation);
5188
- layout.scaleChanged = layout.rotationChanged = false;
5272
+ layout.scaleChanged = layout.rotationChanged = undefined;
5189
5273
  }
5190
5274
  }
5191
5275
  local.e = data.x + data.offsetX;
5192
5276
  local.f = data.y + data.offsetY;
5193
5277
  if (data.around || data.origin) {
5194
- toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
5195
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
5278
+ toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
5279
+ translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
5196
5280
  }
5197
5281
  }
5198
- this.__layout.matrixChanged = false;
5282
+ this.__layout.matrixChanged = undefined;
5199
5283
  }
5200
5284
  };
5201
5285
 
@@ -5205,11 +5289,17 @@ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } =
5205
5289
  const { toBounds: toBounds$1 } = PathBounds;
5206
5290
  const LeafBounds = {
5207
5291
  __updateWorldBounds() {
5208
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5209
- if (this.__layout.resized) {
5210
- this.__onUpdateSize();
5211
- this.__layout.resized = false;
5292
+ const layout = this.__layout;
5293
+ toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5294
+ if (layout.resized) {
5295
+ if (layout.resized === 'inner')
5296
+ this.__onUpdateSize();
5297
+ if (this.__hasLocalEvent)
5298
+ BoundsEvent.emitLocal(this);
5299
+ layout.resized = undefined;
5212
5300
  }
5301
+ if (this.__hasWorldEvent)
5302
+ BoundsEvent.emitWorld(this);
5213
5303
  },
5214
5304
  __updateLocalBounds() {
5215
5305
  const layout = this.__layout;
@@ -5218,12 +5308,12 @@ const LeafBounds = {
5218
5308
  this.__updatePath();
5219
5309
  this.__updateRenderPath();
5220
5310
  this.__updateBoxBounds();
5221
- layout.resized = true;
5311
+ layout.resized = 'inner';
5222
5312
  }
5223
5313
  if (layout.localBoxChanged) {
5224
5314
  if (this.__local)
5225
5315
  this.__updateLocalBoxBounds();
5226
- layout.localBoxChanged = false;
5316
+ layout.localBoxChanged = undefined;
5227
5317
  if (layout.strokeSpread)
5228
5318
  layout.strokeChanged = true;
5229
5319
  if (layout.renderSpread)
@@ -5231,7 +5321,7 @@ const LeafBounds = {
5231
5321
  if (this.parent)
5232
5322
  this.parent.__layout.boxChange();
5233
5323
  }
5234
- layout.boxChanged = false;
5324
+ layout.boxChanged = undefined;
5235
5325
  if (layout.strokeChanged) {
5236
5326
  layout.strokeSpread = this.__updateStrokeSpread();
5237
5327
  if (layout.strokeSpread) {
@@ -5243,12 +5333,12 @@ const LeafBounds = {
5243
5333
  else {
5244
5334
  layout.spreadStrokeCancel();
5245
5335
  }
5246
- layout.strokeChanged = false;
5336
+ layout.strokeChanged = undefined;
5247
5337
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5248
5338
  layout.renderChanged = true;
5249
5339
  if (this.parent)
5250
5340
  this.parent.__layout.strokeChange();
5251
- layout.resized = true;
5341
+ layout.resized = 'inner';
5252
5342
  }
5253
5343
  if (layout.renderChanged) {
5254
5344
  layout.renderSpread = this.__updateRenderSpread();
@@ -5261,11 +5351,12 @@ const LeafBounds = {
5261
5351
  else {
5262
5352
  layout.spreadRenderCancel();
5263
5353
  }
5264
- layout.renderChanged = false;
5354
+ layout.renderChanged = undefined;
5265
5355
  if (this.parent)
5266
5356
  this.parent.__layout.renderChange();
5267
5357
  }
5268
- layout.boundsChanged = false;
5358
+ layout.resized || (layout.resized = 'local');
5359
+ layout.boundsChanged = undefined;
5269
5360
  },
5270
5361
  __updateLocalBoxBounds() {
5271
5362
  if (this.__hasMotionPath)
@@ -5359,7 +5450,7 @@ const LeafRender = {
5359
5450
  if (this.__worldOpacity) {
5360
5451
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5361
5452
  this.__drawRenderPath(canvas);
5362
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
5453
+ canvas.clipUI(this);
5363
5454
  }
5364
5455
  },
5365
5456
  __updateWorldOpacity() {
@@ -5805,7 +5896,7 @@ let Leaf = class Leaf {
5805
5896
  off(_type, _listener, _options) { }
5806
5897
  on_(_type, _listener, _bind, _options) { return undefined; }
5807
5898
  off_(_id) { }
5808
- once(_type, _listener, _capture) { }
5899
+ once(_type, _listener, _captureOrBind, _capture) { }
5809
5900
  emit(_type, _event, _capture) { }
5810
5901
  emitEvent(_event, _capture) { }
5811
5902
  hasEvent(_type, _capture) { return false; }
@@ -6142,7 +6233,7 @@ class LeafLevelList {
6142
6233
  }
6143
6234
  }
6144
6235
 
6145
- const version = "1.6.2";
6236
+ const version = "1.6.4";
6146
6237
 
6147
6238
  class LeaferCanvas extends LeaferCanvasBase {
6148
6239
  get allowBackgroundColor() { return false; }
@@ -6440,17 +6531,15 @@ class Watcher {
6440
6531
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6441
6532
  this.__updatedList = new LeafList();
6442
6533
  this.totalTimes++;
6443
- this.changed = false;
6444
- this.hasVisible = false;
6445
- this.hasRemove = false;
6446
- this.hasAdd = false;
6534
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6447
6535
  }
6448
6536
  __listenEvents() {
6449
- const { target } = this;
6450
6537
  this.__eventIds = [
6451
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6452
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6453
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6538
+ this.target.on_([
6539
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6540
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6541
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6542
+ ])
6454
6543
  ];
6455
6544
  }
6456
6545
  __removeListenEvents() {
@@ -6460,8 +6549,7 @@ class Watcher {
6460
6549
  if (this.target) {
6461
6550
  this.stop();
6462
6551
  this.__removeListenEvents();
6463
- this.target = null;
6464
- this.__updatedList = null;
6552
+ this.target = this.__updatedList = null;
6465
6553
  }
6466
6554
  }
6467
6555
  }
@@ -6566,7 +6654,7 @@ class Layouter {
6566
6654
  this.disabled = true;
6567
6655
  }
6568
6656
  layout() {
6569
- if (!this.running)
6657
+ if (this.layouting || !this.running)
6570
6658
  return;
6571
6659
  const { target } = this;
6572
6660
  this.times = 0;
@@ -6649,12 +6737,10 @@ class Layouter {
6649
6737
  }
6650
6738
  static fullLayout(target) {
6651
6739
  updateAllMatrix(target, true);
6652
- if (target.isBranch) {
6740
+ if (target.isBranch)
6653
6741
  BranchHelper.updateBounds(target);
6654
- }
6655
- else {
6742
+ else
6656
6743
  LeafHelper.updateBounds(target);
6657
- }
6658
6744
  updateAllChange(target);
6659
6745
  }
6660
6746
  addExtra(leaf) {
@@ -6677,11 +6763,12 @@ class Layouter {
6677
6763
  this.__updatedList = event.data.updatedList;
6678
6764
  }
6679
6765
  __listenEvents() {
6680
- const { target } = this;
6681
6766
  this.__eventIds = [
6682
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6683
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6684
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6767
+ this.target.on_([
6768
+ [LayoutEvent.REQUEST, this.layout, this],
6769
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6770
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6771
+ ])
6685
6772
  ];
6686
6773
  }
6687
6774
  __removeListenEvents() {
@@ -6912,12 +6999,13 @@ class Renderer {
6912
6999
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6913
7000
  }
6914
7001
  __listenEvents() {
6915
- const { target } = this;
6916
7002
  this.__eventIds = [
6917
- target.on_(RenderEvent.REQUEST, this.update, this),
6918
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6919
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6920
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7003
+ this.target.on_([
7004
+ [RenderEvent.REQUEST, this.update, this],
7005
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7006
+ [RenderEvent.AGAIN, this.renderAgain, this],
7007
+ [ResizeEvent.RESIZE, this.__onResize, this]
7008
+ ])
6921
7009
  ];
6922
7010
  }
6923
7011
  __removeListenEvents() {
@@ -6976,8 +7064,32 @@ function zoomLayerType() {
6976
7064
  };
6977
7065
  }
6978
7066
 
7067
+ function hasTransparent$3(color) {
7068
+ if (!color || color.length === 7 || color.length === 4)
7069
+ return false;
7070
+ if (color === 'transparent')
7071
+ return true;
7072
+ const first = color[0];
7073
+ if (first === '#') {
7074
+ switch (color.length) {
7075
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7076
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7077
+ }
7078
+ }
7079
+ else if (first === 'r' || first === 'h') {
7080
+ if (color[3] === 'a') {
7081
+ const i = color.lastIndexOf(',');
7082
+ if (i > -1)
7083
+ return parseFloat(color.slice(i + 1)) < 1;
7084
+ }
7085
+ }
7086
+ return false;
7087
+ }
7088
+
6979
7089
  const TextConvert = {};
6980
- const ColorConvert = {};
7090
+ const ColorConvert = {
7091
+ hasTransparent: hasTransparent$3
7092
+ };
6981
7093
  const UnitConvert = {
6982
7094
  number(value, percentRefer) {
6983
7095
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7003,6 +7115,7 @@ const Transition = {
7003
7115
  };
7004
7116
 
7005
7117
  const { parse, objectToCanvasData } = PathConvert;
7118
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7006
7119
  const emptyPaint = {};
7007
7120
  const debug$1 = Debug.get('UIData');
7008
7121
  class UIData extends LeafData {
@@ -7061,38 +7174,22 @@ class UIData extends LeafData {
7061
7174
  if (this.__naturalWidth)
7062
7175
  this.__removeNaturalSize();
7063
7176
  if (typeof value === 'string' || !value) {
7064
- if (this.__isFills) {
7065
- this.__removeInput('fill');
7066
- PaintImage.recycleImage('fill', this);
7067
- this.__isFills = false;
7068
- this.__pixelFill && (this.__pixelFill = false);
7069
- }
7177
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7178
+ this.__isFills && this.__removePaint('fill', true);
7070
7179
  this._fill = value;
7071
7180
  }
7072
7181
  else if (typeof value === 'object') {
7073
- this.__setInput('fill', value);
7074
- const layout = this.__leaf.__layout;
7075
- layout.boxChanged || layout.boxChange();
7076
- this.__isFills = true;
7077
- this._fill || (this._fill = emptyPaint);
7182
+ this.__setPaint('fill', value);
7078
7183
  }
7079
7184
  }
7080
7185
  setStroke(value) {
7081
7186
  if (typeof value === 'string' || !value) {
7082
- if (this.__isStrokes) {
7083
- this.__removeInput('stroke');
7084
- PaintImage.recycleImage('stroke', this);
7085
- this.__isStrokes = false;
7086
- this.__pixelStroke && (this.__pixelStroke = false);
7087
- }
7187
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7188
+ this.__isStrokes && this.__removePaint('stroke', true);
7088
7189
  this._stroke = value;
7089
7190
  }
7090
7191
  else if (typeof value === 'object') {
7091
- this.__setInput('stroke', value);
7092
- const layout = this.__leaf.__layout;
7093
- layout.boxChanged || layout.boxChange();
7094
- this.__isStrokes = true;
7095
- this._stroke || (this._stroke = emptyPaint);
7192
+ this.__setPaint('stroke', value);
7096
7193
  }
7097
7194
  }
7098
7195
  setPath(value) {
@@ -7122,7 +7219,34 @@ class UIData extends LeafData {
7122
7219
  Paint.compute('fill', this.__leaf);
7123
7220
  if (stroke)
7124
7221
  Paint.compute('stroke', this.__leaf);
7125
- this.__needComputePaint = false;
7222
+ this.__needComputePaint = undefined;
7223
+ }
7224
+ __setPaint(attrName, value) {
7225
+ this.__setInput(attrName, value);
7226
+ const layout = this.__leaf.__layout;
7227
+ layout.boxChanged || layout.boxChange();
7228
+ if (value instanceof Array && !value.length) {
7229
+ this.__removePaint(attrName);
7230
+ }
7231
+ else {
7232
+ if (attrName === 'fill')
7233
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7234
+ else
7235
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7236
+ }
7237
+ }
7238
+ __removePaint(attrName, removeInput) {
7239
+ if (removeInput)
7240
+ this.__removeInput(attrName);
7241
+ PaintImage.recycleImage(attrName, this);
7242
+ if (attrName === 'fill') {
7243
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7244
+ this._fill = this.__isFills = undefined;
7245
+ }
7246
+ else {
7247
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7248
+ this._stroke = this.__isStrokes = undefined;
7249
+ }
7126
7250
  }
7127
7251
  }
7128
7252
  function setArray(data, key, value) {
@@ -7130,10 +7254,10 @@ function setArray(data, key, value) {
7130
7254
  if (value instanceof Array) {
7131
7255
  if (value.some((item) => item.visible === false))
7132
7256
  value = value.filter((item) => item.visible !== false);
7133
- value.length || (value = null);
7257
+ value.length || (value = undefined);
7134
7258
  }
7135
7259
  else
7136
- value = value && value.visible !== false ? [value] : null;
7260
+ value = value && value.visible !== false ? [value] : undefined;
7137
7261
  data['_' + key] = value;
7138
7262
  }
7139
7263
 
@@ -7236,8 +7360,6 @@ class ImageData extends RectData {
7236
7360
  this._url = value;
7237
7361
  }
7238
7362
  __setImageFill(value) {
7239
- if (this.__leaf.image)
7240
- this.__leaf.image = null;
7241
7363
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7242
7364
  }
7243
7365
  __getData() {
@@ -7303,21 +7425,19 @@ const UIBounds = {
7303
7425
  }
7304
7426
  };
7305
7427
 
7428
+ const { stintSet: stintSet$1 } = DataHelper;
7306
7429
  const UIRender = {
7307
7430
  __updateChange() {
7308
- const data = this.__, w = this.__world;
7431
+ const data = this.__;
7309
7432
  if (data.__useEffect) {
7310
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7311
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7433
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7434
+ 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')));
7435
+ data.__useEffect = !!(shadow || otherEffect);
7312
7436
  }
7313
- const half = data.__hasHalf;
7314
- w.half !== half && (w.half = half);
7437
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7438
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7315
7439
  data.__checkSingle();
7316
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7317
- if (complex)
7318
- data.__complex = true;
7319
- else
7320
- data.__complex && (data.__complex = false);
7440
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7321
7441
  },
7322
7442
  __drawFast(canvas, options) {
7323
7443
  drawFast(this, canvas, options);
@@ -7327,21 +7447,23 @@ const UIRender = {
7327
7447
  if (data.__complex) {
7328
7448
  if (data.__needComputePaint)
7329
7449
  data.__computePaint();
7330
- const { fill, stroke, __drawAfterFill } = data;
7450
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7331
7451
  this.__drawRenderPath(canvas);
7332
- if (data.__useEffect) {
7452
+ if (data.__useEffect && !__isFastShadow) {
7333
7453
  const shape = Paint.shape(this, canvas, options);
7334
7454
  this.__nowWorld = this.__getNowWorld(options);
7335
7455
  const { shadow, innerShadow, filter } = data;
7336
7456
  if (shadow)
7337
7457
  Effect.shadow(this, canvas, shape);
7458
+ if (__fillAfterStroke)
7459
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7338
7460
  if (fill)
7339
7461
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7340
7462
  if (__drawAfterFill)
7341
7463
  this.__drawAfterFill(canvas, options);
7342
7464
  if (innerShadow)
7343
7465
  Effect.innerShadow(this, canvas, shape);
7344
- if (stroke)
7466
+ if (stroke && !__fillAfterStroke)
7345
7467
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7346
7468
  if (filter)
7347
7469
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7350,21 +7472,27 @@ const UIRender = {
7350
7472
  shape.canvas.recycle();
7351
7473
  }
7352
7474
  else {
7475
+ if (__fillAfterStroke)
7476
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7477
+ if (__isFastShadow) {
7478
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7479
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7480
+ }
7353
7481
  if (fill)
7354
7482
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7483
+ if (__isFastShadow)
7484
+ canvas.restore();
7355
7485
  if (__drawAfterFill)
7356
7486
  this.__drawAfterFill(canvas, options);
7357
- if (stroke)
7487
+ if (stroke && !__fillAfterStroke)
7358
7488
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7359
7489
  }
7360
7490
  }
7361
7491
  else {
7362
- if (data.__pathInputed) {
7492
+ if (data.__pathInputed)
7363
7493
  drawFast(this, canvas, options);
7364
- }
7365
- else {
7494
+ else
7366
7495
  this.__drawFast(canvas, options);
7367
- }
7368
7496
  }
7369
7497
  },
7370
7498
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7373,17 +7501,17 @@ const UIRender = {
7373
7501
  const { fill, stroke } = this.__;
7374
7502
  this.__drawRenderPath(canvas);
7375
7503
  if (fill && !ignoreFill)
7376
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7504
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7377
7505
  if (this.__.__isCanvas)
7378
7506
  this.__drawAfterFill(canvas, options);
7379
7507
  if (stroke && !ignoreStroke)
7380
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7508
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7381
7509
  }
7382
7510
  },
7383
7511
  __drawAfterFill(canvas, options) {
7384
7512
  if (this.__.__clipAfterFill) {
7385
7513
  canvas.save();
7386
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
7514
+ canvas.clipUI();
7387
7515
  this.__drawContent(canvas, options);
7388
7516
  canvas.restore();
7389
7517
  }
@@ -7392,13 +7520,15 @@ const UIRender = {
7392
7520
  }
7393
7521
  };
7394
7522
  function drawFast(ui, canvas, options) {
7395
- const { fill, stroke, __drawAfterFill } = ui.__;
7523
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7396
7524
  ui.__drawRenderPath(canvas);
7525
+ if (__fillAfterStroke)
7526
+ Paint.stroke(stroke, ui, canvas);
7397
7527
  if (fill)
7398
7528
  Paint.fill(fill, ui, canvas);
7399
7529
  if (__drawAfterFill)
7400
7530
  ui.__drawAfterFill(canvas, options);
7401
- if (stroke)
7531
+ if (stroke && !__fillAfterStroke)
7402
7532
  Paint.stroke(stroke, ui, canvas);
7403
7533
  }
7404
7534
 
@@ -7770,6 +7900,9 @@ __decorate([
7770
7900
  __decorate([
7771
7901
  surfaceType()
7772
7902
  ], UI.prototype, "placeholderColor", void 0);
7903
+ __decorate([
7904
+ dataType(100)
7905
+ ], UI.prototype, "placeholderDelay", void 0);
7773
7906
  __decorate([
7774
7907
  dataType({})
7775
7908
  ], UI.prototype, "data", void 0);
@@ -8171,15 +8304,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8171
8304
  }
8172
8305
  __listenEvents() {
8173
8306
  const runId = Run.start('FirstCreate ' + this.innerName);
8174
- this.once(LeaferEvent.START, () => Run.end(runId));
8175
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8176
- this.once(RenderEvent.START, () => this.__onCreated());
8177
- this.once(RenderEvent.END, () => this.__onViewReady());
8178
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8307
+ this.once([
8308
+ [LeaferEvent.START, () => Run.end(runId)],
8309
+ [LayoutEvent.START, this.updateLazyBounds, this],
8310
+ [RenderEvent.START, this.__onCreated, this],
8311
+ [RenderEvent.END, this.__onViewReady, this]
8312
+ ]);
8313
+ this.__eventIds.push(this.on_([
8314
+ [WatchEvent.DATA, this.__onWatchData, this],
8315
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8316
+ [RenderEvent.NEXT, this.__onNextRender, this]
8317
+ ]));
8179
8318
  }
8180
8319
  __removeListenEvents() {
8181
8320
  this.off_(this.__eventIds);
8182
- this.__eventIds.length = 0;
8183
8321
  }
8184
8322
  destroy(sync) {
8185
8323
  const doDestory = () => {
@@ -8287,13 +8425,13 @@ let Box = class Box extends Group {
8287
8425
  super.__updateRenderBounds();
8288
8426
  copy$2(childrenRenderBounds, renderBounds);
8289
8427
  this.__updateRectRenderBounds();
8290
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8428
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8291
8429
  if (isOverflow && this.__.overflow !== 'hide')
8292
8430
  add(renderBounds, childrenRenderBounds);
8293
8431
  }
8294
8432
  else
8295
8433
  this.__updateRectRenderBounds();
8296
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8434
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8297
8435
  }
8298
8436
  __updateRectRenderBounds() { }
8299
8437
  __updateRectChange() { }
@@ -8597,18 +8735,10 @@ Star = __decorate([
8597
8735
 
8598
8736
  let Image = class Image extends Rect {
8599
8737
  get __tag() { return 'Image'; }
8600
- get ready() { return this.image ? this.image.ready : false; }
8738
+ get ready() { const { image } = this; return image && image.ready; }
8739
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8601
8740
  constructor(data) {
8602
8741
  super(data);
8603
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8604
- }
8605
- __onLoaded(e) {
8606
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8607
- this.image = e.image;
8608
- }
8609
- destroy() {
8610
- this.image = null;
8611
- super.destroy();
8612
8742
  }
8613
8743
  };
8614
8744
  __decorate([
@@ -8624,11 +8754,11 @@ const MyImage = Image;
8624
8754
 
8625
8755
  let Canvas = class Canvas extends Rect {
8626
8756
  get __tag() { return 'Canvas'; }
8757
+ get context() { return this.canvas.context; }
8627
8758
  get ready() { return !this.url; }
8628
8759
  constructor(data) {
8629
8760
  super(data);
8630
8761
  this.canvas = Creator.canvas(this.__);
8631
- this.context = this.canvas.context;
8632
8762
  if (data && data.url)
8633
8763
  this.drawImage(data.url);
8634
8764
  }
@@ -8672,7 +8802,7 @@ let Canvas = class Canvas extends Rect {
8672
8802
  destroy() {
8673
8803
  if (this.canvas) {
8674
8804
  this.canvas.destroy();
8675
- this.canvas = this.context = null;
8805
+ this.canvas = null;
8676
8806
  }
8677
8807
  super.destroy();
8678
8808
  }
@@ -8748,12 +8878,11 @@ let Text = class Text extends UI {
8748
8878
  super.__updateBoxBounds();
8749
8879
  if (italic)
8750
8880
  b.width += fontSize * 0.16;
8751
- const isOverflow = !includes(b, contentBounds) || undefined;
8752
- if (isOverflow)
8881
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8882
+ if (this.isOverflow)
8753
8883
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8754
8884
  else
8755
8885
  data.__textBoxBounds = b;
8756
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8757
8886
  }
8758
8887
  __onUpdateSize() {
8759
8888
  if (this.__box)
@@ -8867,6 +8996,9 @@ __decorate([
8867
8996
  __decorate([
8868
8997
  boundsType('show')
8869
8998
  ], Text.prototype, "textOverflow", void 0);
8999
+ __decorate([
9000
+ surfaceType(false)
9001
+ ], Text.prototype, "textEditing", void 0);
8870
9002
  Text = __decorate([
8871
9003
  registerUI()
8872
9004
  ], Text);
@@ -8999,35 +9131,38 @@ function fillPathOrText(ui, canvas) {
8999
9131
  }
9000
9132
 
9001
9133
  function strokeText(stroke, ui, canvas) {
9002
- const { strokeAlign } = ui.__;
9003
- const isStrokes = typeof stroke !== 'string';
9004
- switch (strokeAlign) {
9134
+ switch (ui.__.strokeAlign) {
9005
9135
  case 'center':
9006
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
9007
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9136
+ drawCenter$1(stroke, 1, ui, canvas);
9008
9137
  break;
9009
9138
  case 'inside':
9010
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
9139
+ drawAlign(stroke, 'inside', ui, canvas);
9011
9140
  break;
9012
9141
  case 'outside':
9013
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
9142
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
9014
9143
  break;
9015
9144
  }
9016
9145
  }
9017
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
9018
- const { __strokeWidth, __font } = ui.__;
9146
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
9147
+ const data = ui.__;
9148
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
9149
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9150
+ }
9151
+ function drawAlign(stroke, align, ui, canvas) {
9019
9152
  const out = canvas.getSameCanvas(true, true);
9020
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
9021
- out.font = __font;
9022
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
9153
+ out.font = ui.__.__font;
9154
+ drawCenter$1(stroke, 2, ui, out);
9023
9155
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9024
9156
  fillText(ui, out);
9025
9157
  out.blendMode = 'normal';
9026
- if (ui.__worldFlipped)
9158
+ copyWorld(canvas, out, ui);
9159
+ out.recycle(ui.__nowWorld);
9160
+ }
9161
+ function copyWorld(canvas, out, ui) {
9162
+ if (ui.__worldFlipped || Platform.fullImageShadow)
9027
9163
  canvas.copyWorldByReset(out, ui.__nowWorld);
9028
9164
  else
9029
9165
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9030
- out.recycle(ui.__nowWorld);
9031
9166
  }
9032
9167
  function drawTextStroke(ui, canvas) {
9033
9168
  let row, data = ui.__.__textDrawData;
@@ -9065,90 +9200,56 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
9065
9200
  }
9066
9201
 
9067
9202
  function stroke(stroke, ui, canvas) {
9068
- const options = ui.__;
9069
- const { __strokeWidth, strokeAlign, __font } = options;
9070
- if (!__strokeWidth)
9203
+ const data = ui.__;
9204
+ if (!data.__strokeWidth)
9071
9205
  return;
9072
- if (__font) {
9206
+ if (data.__font) {
9073
9207
  strokeText(stroke, ui, canvas);
9074
9208
  }
9075
9209
  else {
9076
- switch (strokeAlign) {
9210
+ switch (data.strokeAlign) {
9077
9211
  case 'center':
9078
- canvas.setStroke(stroke, __strokeWidth, options);
9079
- canvas.stroke();
9080
- if (options.__useArrow)
9081
- strokeArrow(ui, canvas);
9212
+ drawCenter(stroke, 1, ui, canvas);
9082
9213
  break;
9083
9214
  case 'inside':
9084
- canvas.save();
9085
- canvas.setStroke(stroke, __strokeWidth * 2, options);
9086
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9087
- canvas.stroke();
9088
- canvas.restore();
9215
+ drawInside(stroke, ui, canvas);
9089
9216
  break;
9090
9217
  case 'outside':
9091
- const out = canvas.getSameCanvas(true, true);
9092
- out.setStroke(stroke, __strokeWidth * 2, options);
9093
- ui.__drawRenderPath(out);
9094
- out.stroke();
9095
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9096
- out.clearWorld(ui.__layout.renderBounds);
9097
- if (ui.__worldFlipped)
9098
- canvas.copyWorldByReset(out, ui.__nowWorld);
9099
- else
9100
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9101
- out.recycle(ui.__nowWorld);
9218
+ drawOutside(stroke, ui, canvas);
9102
9219
  break;
9103
9220
  }
9104
9221
  }
9105
9222
  }
9106
9223
  function strokes(strokes, ui, canvas) {
9107
- const options = ui.__;
9108
- const { __strokeWidth, strokeAlign, __font } = options;
9109
- if (!__strokeWidth)
9110
- return;
9111
- if (__font) {
9112
- strokeText(strokes, ui, canvas);
9224
+ stroke(strokes, ui, canvas);
9225
+ }
9226
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
9227
+ const data = ui.__;
9228
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
9229
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
9230
+ if (data.__useArrow)
9231
+ Paint.strokeArrow(stroke, ui, canvas);
9232
+ }
9233
+ function drawInside(stroke, ui, canvas) {
9234
+ canvas.save();
9235
+ canvas.clipUI(ui);
9236
+ drawCenter(stroke, 2, ui, canvas);
9237
+ canvas.restore();
9238
+ }
9239
+ function drawOutside(stroke, ui, canvas) {
9240
+ const data = ui.__;
9241
+ if (data.__fillAfterStroke) {
9242
+ drawCenter(stroke, 2, ui, canvas);
9113
9243
  }
9114
9244
  else {
9115
- switch (strokeAlign) {
9116
- case 'center':
9117
- canvas.setStroke(undefined, __strokeWidth, options);
9118
- drawStrokesStyle(strokes, false, ui, canvas);
9119
- if (options.__useArrow)
9120
- strokeArrow(ui, canvas);
9121
- break;
9122
- case 'inside':
9123
- canvas.save();
9124
- canvas.setStroke(undefined, __strokeWidth * 2, options);
9125
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9126
- drawStrokesStyle(strokes, false, ui, canvas);
9127
- canvas.restore();
9128
- break;
9129
- case 'outside':
9130
- const { renderBounds } = ui.__layout;
9131
- const out = canvas.getSameCanvas(true, true);
9132
- ui.__drawRenderPath(out);
9133
- out.setStroke(undefined, __strokeWidth * 2, options);
9134
- drawStrokesStyle(strokes, false, ui, out);
9135
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9136
- out.clearWorld(renderBounds);
9137
- if (ui.__worldFlipped)
9138
- canvas.copyWorldByReset(out, ui.__nowWorld);
9139
- else
9140
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
9141
- out.recycle(ui.__nowWorld);
9142
- break;
9143
- }
9144
- }
9145
- }
9146
- function strokeArrow(ui, canvas) {
9147
- if (ui.__.dashPattern) {
9148
- canvas.beginPath();
9149
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
9150
- canvas.dashPattern = null;
9151
- canvas.stroke();
9245
+ const { renderBounds } = ui.__layout;
9246
+ const out = canvas.getSameCanvas(true, true);
9247
+ ui.__drawRenderPath(out);
9248
+ drawCenter(stroke, 2, ui, out);
9249
+ out.clipUI(data);
9250
+ out.clearWorld(renderBounds);
9251
+ copyWorld(canvas, out, ui);
9252
+ out.recycle(ui.__nowWorld);
9152
9253
  }
9153
9254
  }
9154
9255
 
@@ -9195,41 +9296,66 @@ function shape(ui, current, options) {
9195
9296
  }
9196
9297
 
9197
9298
  let recycleMap;
9299
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
9198
9300
  function compute(attrName, ui) {
9199
9301
  const data = ui.__, leafPaints = [];
9200
- let paints = data.__input[attrName], hasOpacityPixel;
9302
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
9201
9303
  if (!(paints instanceof Array))
9202
9304
  paints = [paints];
9203
9305
  recycleMap = PaintImage.recycleImage(attrName, data);
9204
9306
  for (let i = 0, len = paints.length, item; i < len; i++) {
9205
- item = getLeafPaint(attrName, paints[i], ui);
9206
- if (item)
9207
- leafPaints.push(item);
9307
+ (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
9208
9308
  }
9209
9309
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
9210
- if (leafPaints.length && leafPaints[0].image)
9211
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
9212
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
9310
+ if (leafPaints.length) {
9311
+ if (leafPaints.every(item => item.isTransparent)) {
9312
+ if (leafPaints.some(item => item.image))
9313
+ isAlphaPixel = true;
9314
+ isTransparent = true;
9315
+ }
9316
+ }
9317
+ if (attrName === 'fill') {
9318
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
9319
+ stintSet(data, '__isTransparentFill', isTransparent);
9320
+ }
9321
+ else {
9322
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
9323
+ stintSet(data, '__isTransparentStroke', isTransparent);
9324
+ }
9213
9325
  }
9214
9326
  function getLeafPaint(attrName, paint, ui) {
9215
9327
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
9216
9328
  return undefined;
9329
+ let data;
9217
9330
  const { boxBounds } = ui.__layout;
9218
9331
  switch (paint.type) {
9219
- case 'solid':
9220
- let { type, blendMode, color, opacity } = paint;
9221
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
9222
9332
  case 'image':
9223
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9333
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9334
+ break;
9224
9335
  case 'linear':
9225
- return PaintGradient.linearGradient(paint, boxBounds);
9336
+ data = PaintGradient.linearGradient(paint, boxBounds);
9337
+ break;
9226
9338
  case 'radial':
9227
- return PaintGradient.radialGradient(paint, boxBounds);
9339
+ data = PaintGradient.radialGradient(paint, boxBounds);
9340
+ break;
9228
9341
  case 'angular':
9229
- return PaintGradient.conicGradient(paint, boxBounds);
9342
+ data = PaintGradient.conicGradient(paint, boxBounds);
9343
+ break;
9344
+ case 'solid':
9345
+ const { type, color, opacity } = paint;
9346
+ data = { type, style: ColorConvert.string(color, opacity) };
9347
+ break;
9230
9348
  default:
9231
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
9349
+ if (paint.r !== undefined)
9350
+ data = { type: 'solid', style: ColorConvert.string(paint) };
9232
9351
  }
9352
+ if (data) {
9353
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
9354
+ data.isTransparent = true;
9355
+ if (paint.blendMode)
9356
+ data.blendMode = paint.blendMode;
9357
+ }
9358
+ return data;
9233
9359
  }
9234
9360
 
9235
9361
  const PaintModule = {
@@ -9295,12 +9421,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
9295
9421
 
9296
9422
  const { get: get$2, translate } = MatrixHelper;
9297
9423
  const tempBox = new Bounds();
9298
- const tempPoint = {};
9299
9424
  const tempScaleData = {};
9425
+ const tempImage = {};
9300
9426
  function createData(leafPaint, image, paint, box) {
9301
- const { blendMode, changeful, sync } = paint;
9302
- if (blendMode)
9303
- leafPaint.blendMode = blendMode;
9427
+ const { changeful, sync } = paint;
9304
9428
  if (changeful)
9305
9429
  leafPaint.changeful = changeful;
9306
9430
  if (sync)
@@ -9308,38 +9432,38 @@ function createData(leafPaint, image, paint, box) {
9308
9432
  leafPaint.data = getPatternData(paint, box, image);
9309
9433
  }
9310
9434
  function getPatternData(paint, box, image) {
9311
- let { width, height } = image;
9312
9435
  if (paint.padding)
9313
9436
  box = tempBox.set(box).shrink(paint.padding);
9314
9437
  if (paint.mode === 'strench')
9315
9438
  paint.mode = 'stretch';
9439
+ let { width, height } = image;
9316
9440
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
9317
9441
  const sameBox = box.width === width && box.height === height;
9318
9442
  const data = { mode };
9319
9443
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
9320
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
9321
- let x = 0, y = 0, scaleX, scaleY;
9444
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
9445
+ let scaleX, scaleY;
9322
9446
  if (!mode || mode === 'cover' || mode === 'fit') {
9323
9447
  if (!sameBox || rotation) {
9324
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
9325
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
9326
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
9448
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
9449
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
9450
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9327
9451
  }
9328
9452
  }
9329
- else if (scale || size) {
9330
- MathHelper.getScaleData(scale, size, image, tempScaleData);
9331
- scaleX = tempScaleData.scaleX;
9332
- scaleY = tempScaleData.scaleY;
9333
- }
9334
- if (align) {
9335
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
9336
- if (scaleX)
9337
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
9338
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
9339
- x += tempPoint.x, y += tempPoint.y;
9453
+ else {
9454
+ if (scale || size) {
9455
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
9456
+ scaleX = tempScaleData.scaleX;
9457
+ scaleY = tempScaleData.scaleY;
9458
+ }
9459
+ if (align) {
9460
+ if (scaleX)
9461
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9462
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
9463
+ }
9340
9464
  }
9341
9465
  if (offset)
9342
- x += offset.x, y += offset.y;
9466
+ PointHelper.move(tempImage, offset);
9343
9467
  switch (mode) {
9344
9468
  case 'stretch':
9345
9469
  if (!sameBox)
@@ -9347,12 +9471,12 @@ function getPatternData(paint, box, image) {
9347
9471
  break;
9348
9472
  case 'normal':
9349
9473
  case 'clip':
9350
- if (x || y || scaleX || rotation)
9351
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
9474
+ if (tempImage.x || tempImage.y || scaleX || rotation)
9475
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9352
9476
  break;
9353
9477
  case 'repeat':
9354
9478
  if (!sameBox || scaleX || rotation)
9355
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
9479
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
9356
9480
  if (!repeat)
9357
9481
  data.repeat = 'repeat';
9358
9482
  break;
@@ -9360,7 +9484,7 @@ function getPatternData(paint, box, image) {
9360
9484
  case 'cover':
9361
9485
  default:
9362
9486
  if (scaleX)
9363
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
9487
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9364
9488
  }
9365
9489
  if (!data.transform) {
9366
9490
  if (box.x || box.y) {
@@ -9393,6 +9517,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9393
9517
  }
9394
9518
  else {
9395
9519
  leafPaint = { type: paint.type, image };
9520
+ if (image.hasAlphaPixel)
9521
+ leafPaint.isTransparent = true;
9396
9522
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
9397
9523
  }
9398
9524
  if (firstUse || image.loading)
@@ -9417,7 +9543,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9417
9543
  ignoreRender(ui, false);
9418
9544
  if (!ui.destroyed) {
9419
9545
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
9420
- if (image.hasOpacityPixel)
9546
+ if (image.hasAlphaPixel)
9421
9547
  ui.__layout.hitCanvasChanged = true;
9422
9548
  ui.forceUpdate('surface');
9423
9549
  }
@@ -9429,13 +9555,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
9429
9555
  onLoadError(ui, event, error);
9430
9556
  leafPaint.loadId = null;
9431
9557
  });
9432
- if (ui.placeholderColor)
9433
- setTimeout(() => {
9434
- if (!(image.ready || image.isPlacehold)) {
9435
- image.isPlacehold = true;
9436
- ui.forceUpdate('surface');
9437
- }
9438
- }, 100);
9558
+ if (ui.placeholderColor) {
9559
+ if (!ui.placeholderDelay)
9560
+ image.isPlacehold = true;
9561
+ else
9562
+ setTimeout(() => {
9563
+ if (!image.ready) {
9564
+ image.isPlacehold = true;
9565
+ ui.forceUpdate('surface');
9566
+ }
9567
+ }, ui.placeholderDelay);
9568
+ }
9439
9569
  }
9440
9570
  return leafPaint;
9441
9571
  }
@@ -9590,7 +9720,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
9590
9720
  }
9591
9721
  function drawImage(ui, canvas, paint, data) {
9592
9722
  canvas.save();
9593
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
9723
+ canvas.clipUI(ui);
9594
9724
  if (paint.blendMode)
9595
9725
  canvas.blendMode = paint.blendMode;
9596
9726
  if (data.opacity)
@@ -9641,32 +9771,33 @@ const PaintImageModule = {
9641
9771
  repeatMode
9642
9772
  };
9643
9773
 
9644
- const { toPoint: toPoint$2 } = AroundHelper;
9774
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
9645
9775
  const realFrom$2 = {};
9646
9776
  const realTo$2 = {};
9647
9777
  function linearGradient(paint, box) {
9648
- let { from, to, type, blendMode, opacity } = paint;
9778
+ let { from, to, type, opacity } = paint;
9649
9779
  toPoint$2(from || 'top', box, realFrom$2);
9650
9780
  toPoint$2(to || 'bottom', box, realTo$2);
9651
9781
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
9652
- applyStops(style, paint.stops, opacity);
9653
9782
  const data = { type, style };
9654
- if (blendMode)
9655
- data.blendMode = blendMode;
9783
+ applyStops(data, style, paint.stops, opacity);
9656
9784
  return data;
9657
9785
  }
9658
- function applyStops(gradient, stops, opacity) {
9786
+ function applyStops(data, gradient, stops, opacity) {
9659
9787
  if (stops) {
9660
- let stop;
9788
+ let stop, color, offset, isTransparent;
9661
9789
  for (let i = 0, len = stops.length; i < len; i++) {
9662
9790
  stop = stops[i];
9663
- if (typeof stop === 'string') {
9664
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
9665
- }
9666
- else {
9667
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
9668
- }
9791
+ if (typeof stop === 'string')
9792
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
9793
+ else
9794
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
9795
+ gradient.addColorStop(offset, color);
9796
+ if (!isTransparent && hasTransparent(color))
9797
+ isTransparent = true;
9669
9798
  }
9799
+ if (isTransparent)
9800
+ data.isTransparent = true;
9670
9801
  }
9671
9802
  }
9672
9803
 
@@ -9676,17 +9807,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
9676
9807
  const realFrom$1 = {};
9677
9808
  const realTo$1 = {};
9678
9809
  function radialGradient(paint, box) {
9679
- let { from, to, type, opacity, blendMode, stretch } = paint;
9810
+ let { from, to, type, opacity, stretch } = paint;
9680
9811
  toPoint$1(from || 'center', box, realFrom$1);
9681
9812
  toPoint$1(to || 'bottom', box, realTo$1);
9682
9813
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
9683
- applyStops(style, paint.stops, opacity);
9684
9814
  const data = { type, style };
9815
+ applyStops(data, style, paint.stops, opacity);
9685
9816
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
9686
9817
  if (transform)
9687
9818
  data.transform = transform;
9688
- if (blendMode)
9689
- data.blendMode = blendMode;
9690
9819
  return data;
9691
9820
  }
9692
9821
  function getTransform(box, from, to, stretch, rotate90) {
@@ -9712,17 +9841,15 @@ const { toPoint } = AroundHelper;
9712
9841
  const realFrom = {};
9713
9842
  const realTo = {};
9714
9843
  function conicGradient(paint, box) {
9715
- let { from, to, type, opacity, blendMode, stretch } = paint;
9844
+ let { from, to, type, opacity, stretch } = paint;
9716
9845
  toPoint(from || 'center', box, realFrom);
9717
9846
  toPoint(to || 'bottom', box, realTo);
9718
9847
  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));
9719
- applyStops(style, paint.stops, opacity);
9720
9848
  const data = { type, style };
9849
+ applyStops(data, style, paint.stops, opacity);
9721
9850
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
9722
9851
  if (transform)
9723
9852
  data.transform = transform;
9724
- if (blendMode)
9725
- data.blendMode = blendMode;
9726
9853
  return data;
9727
9854
  }
9728
9855
 
@@ -9758,12 +9885,10 @@ function shadow(ui, current, shape) {
9758
9885
  }
9759
9886
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9760
9887
  }
9761
- if (ui.__worldFlipped) {
9888
+ if (ui.__worldFlipped)
9762
9889
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9763
- }
9764
- else {
9890
+ else
9765
9891
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9766
- }
9767
9892
  if (end && index < end)
9768
9893
  other.clearWorld(copyBounds, true);
9769
9894
  });
@@ -9822,12 +9947,10 @@ function innerShadow(ui, current, shape) {
9822
9947
  copyBounds = bounds;
9823
9948
  }
9824
9949
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
9825
- if (ui.__worldFlipped) {
9950
+ if (ui.__worldFlipped)
9826
9951
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9827
- }
9828
- else {
9952
+ else
9829
9953
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9830
- }
9831
9954
  if (end && index < end)
9832
9955
  other.clearWorld(copyBounds, true);
9833
9956
  });
@@ -10055,6 +10178,8 @@ function createRows(drawData, content, style) {
10055
10178
  lastCharType = null;
10056
10179
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
10057
10180
  word = { data: [] }, row = { words: [] };
10181
+ if (__letterSpacing)
10182
+ content = [...content];
10058
10183
  for (let i = 0, len = content.length; i < len; i++) {
10059
10184
  char = content[i];
10060
10185
  if (char === '\n') {
@@ -10472,4 +10597,4 @@ try {
10472
10597
  }
10473
10598
  catch (_a) { }
10474
10599
 
10475
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, 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, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, 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 };
10600
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, 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, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, 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 };