leafer-draw 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.
package/dist/web.js CHANGED
@@ -26,8 +26,6 @@ var LeaferUI = (function (exports) {
26
26
  }
27
27
  };
28
28
 
29
- const Creator = {};
30
-
31
29
  const IncrementId = {
32
30
  RUNTIME: 'runtime',
33
31
  LEAF: 'leaf',
@@ -153,7 +151,7 @@ var LeaferUI = (function (exports) {
153
151
 
154
152
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
155
153
  const { float: float$1 } = MathHelper;
156
- const tempPoint$4 = {};
154
+ const tempPoint$3 = {};
157
155
  function getWorld() {
158
156
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
159
157
  }
@@ -196,8 +194,8 @@ var LeaferUI = (function (exports) {
196
194
  t.d *= scaleY;
197
195
  },
198
196
  scaleOfOuter(t, origin, scaleX, scaleY) {
199
- M$6.toInnerPoint(t, origin, tempPoint$4);
200
- M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
197
+ M$6.toInnerPoint(t, origin, tempPoint$3);
198
+ M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
201
199
  },
202
200
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
203
201
  M$6.translateInner(t, origin.x, origin.y);
@@ -215,8 +213,8 @@ var LeaferUI = (function (exports) {
215
213
  t.d = c * sinR + d * cosR;
216
214
  },
217
215
  rotateOfOuter(t, origin, rotation) {
218
- M$6.toInnerPoint(t, origin, tempPoint$4);
219
- M$6.rotateOfInner(t, tempPoint$4, rotation);
216
+ M$6.toInnerPoint(t, origin, tempPoint$3);
217
+ M$6.rotateOfInner(t, tempPoint$3, rotation);
220
218
  },
221
219
  rotateOfInner(t, origin, rotation) {
222
220
  M$6.translateInner(t, origin.x, origin.y);
@@ -237,8 +235,8 @@ var LeaferUI = (function (exports) {
237
235
  }
238
236
  },
239
237
  skewOfOuter(t, origin, skewX, skewY) {
240
- M$6.toInnerPoint(t, origin, tempPoint$4);
241
- M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
238
+ M$6.toInnerPoint(t, origin, tempPoint$3);
239
+ M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
242
240
  },
243
241
  skewOfInner(t, origin, skewX, skewY = 0) {
244
242
  M$6.translateInner(t, origin.x, origin.y);
@@ -467,8 +465,10 @@ var LeaferUI = (function (exports) {
467
465
  t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
468
466
  },
469
467
  move(t, x, y) {
470
- t.x += x;
471
- t.y += y;
468
+ if (typeof x === 'object')
469
+ t.x += x.x, t.y += x.y;
470
+ else
471
+ t.x += x, t.y += y;
472
472
  },
473
473
  scale(t, scaleX, scaleY = scaleX) {
474
474
  if (t.x)
@@ -646,7 +646,7 @@ var LeaferUI = (function (exports) {
646
646
  return this;
647
647
  }
648
648
  }
649
- const tempPoint$3 = new Point();
649
+ const tempPoint$2 = new Point();
650
650
 
651
651
  class Matrix {
652
652
  constructor(a, b, c, d, e, f) {
@@ -804,15 +804,87 @@ var LeaferUI = (function (exports) {
804
804
  };
805
805
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
806
806
 
807
+ exports.Direction4 = void 0;
808
+ (function (Direction4) {
809
+ Direction4[Direction4["top"] = 0] = "top";
810
+ Direction4[Direction4["right"] = 1] = "right";
811
+ Direction4[Direction4["bottom"] = 2] = "bottom";
812
+ Direction4[Direction4["left"] = 3] = "left";
813
+ })(exports.Direction4 || (exports.Direction4 = {}));
814
+ exports.Direction9 = void 0;
815
+ (function (Direction9) {
816
+ Direction9[Direction9["topLeft"] = 0] = "topLeft";
817
+ Direction9[Direction9["top"] = 1] = "top";
818
+ Direction9[Direction9["topRight"] = 2] = "topRight";
819
+ Direction9[Direction9["right"] = 3] = "right";
820
+ Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
821
+ Direction9[Direction9["bottom"] = 5] = "bottom";
822
+ Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
823
+ Direction9[Direction9["left"] = 7] = "left";
824
+ Direction9[Direction9["center"] = 8] = "center";
825
+ Direction9[Direction9["top-left"] = 0] = "top-left";
826
+ Direction9[Direction9["top-right"] = 2] = "top-right";
827
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
828
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
829
+ })(exports.Direction9 || (exports.Direction9 = {}));
830
+
831
+ const directionData = [
832
+ { x: 0, y: 0 },
833
+ { x: 0.5, y: 0 },
834
+ { x: 1, y: 0 },
835
+ { x: 1, y: 0.5 },
836
+ { x: 1, y: 1 },
837
+ { x: 0.5, y: 1 },
838
+ { x: 0, y: 1 },
839
+ { x: 0, y: 0.5 },
840
+ { x: 0.5, y: 0.5 }
841
+ ];
842
+ directionData.forEach(item => item.type = 'percent');
843
+ const AroundHelper = {
844
+ directionData,
845
+ tempPoint: {},
846
+ get: get$4,
847
+ toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
848
+ const point = get$4(around);
849
+ to.x = point.x;
850
+ to.y = point.y;
851
+ if (point.type === 'percent') {
852
+ to.x *= box.width;
853
+ to.y *= box.height;
854
+ if (content) {
855
+ if (!onlyContentSize)
856
+ to.x -= content.x, to.y -= content.y;
857
+ if (point.x)
858
+ to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
859
+ if (point.y)
860
+ to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
861
+ }
862
+ }
863
+ if (!onlyBoxSize)
864
+ to.x += box.x, to.y += box.y;
865
+ }
866
+ };
867
+ function get$4(around) {
868
+ return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
869
+ }
870
+
871
+ const { toPoint: toPoint$5 } = AroundHelper;
872
+ const AlignHelper = {
873
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
874
+ toPoint$5(align, box, to, onlyBoxSize, content, onlyContentSize);
875
+ }
876
+ };
877
+
807
878
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
808
879
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
809
880
  const { float, fourNumber } = MathHelper;
810
881
  const { floor, ceil: ceil$2 } = Math;
811
882
  let right$1, bottom$1, boundsRight, boundsBottom;
812
883
  const point = {};
813
- const toPoint$5 = {};
884
+ const toPoint$4 = {};
885
+ const tempBounds$2 = {};
814
886
  const BoundsHelper = {
815
- tempBounds: {},
887
+ tempBounds: tempBounds$2,
816
888
  set(t, x = 0, y = 0, width = 0, height = 0) {
817
889
  t.x = x;
818
890
  t.y = y;
@@ -875,8 +947,8 @@ var LeaferUI = (function (exports) {
875
947
  }
876
948
  B.move(to, -to.offsetX, -to.offsetY);
877
949
  },
878
- scale(t, scaleX, scaleY = scaleX) {
879
- PointHelper.scale(t, scaleX, scaleY);
950
+ scale(t, scaleX, scaleY = scaleX, onlySize) {
951
+ onlySize || PointHelper.scale(t, scaleX, scaleY);
880
952
  t.width *= scaleX;
881
953
  t.height *= scaleY;
882
954
  },
@@ -886,9 +958,9 @@ var LeaferUI = (function (exports) {
886
958
  t.height *= scaleY;
887
959
  },
888
960
  tempToOuterOf(t, matrix) {
889
- B.copy(B.tempBounds, t);
890
- B.toOuterOf(B.tempBounds, matrix);
891
- return B.tempBounds;
961
+ B.copy(tempBounds$2, t);
962
+ B.toOuterOf(tempBounds$2, matrix);
963
+ return tempBounds$2;
892
964
  },
893
965
  getOuterOf(t, matrix) {
894
966
  t = Object.assign({}, t);
@@ -919,17 +991,17 @@ var LeaferUI = (function (exports) {
919
991
  else {
920
992
  point.x = t.x;
921
993
  point.y = t.y;
922
- toOuterPoint$2(matrix, point, toPoint$5);
923
- setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
994
+ toOuterPoint$2(matrix, point, toPoint$4);
995
+ setPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
924
996
  point.x = t.x + t.width;
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.y = t.y + t.height;
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
  point.x = t.x;
931
- toOuterPoint$2(matrix, point, toPoint$5);
932
- addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
1003
+ toOuterPoint$2(matrix, point, toPoint$4);
1004
+ addPoint$2(tempPointBounds$1, toPoint$4.x, toPoint$4.y);
933
1005
  toBounds$3(tempPointBounds$1, to);
934
1006
  }
935
1007
  },
@@ -939,9 +1011,21 @@ var LeaferUI = (function (exports) {
939
1011
  B.scale(to, 1 / matrix.a, 1 / matrix.d);
940
1012
  },
941
1013
  getFitMatrix(t, put, baseScale = 1) {
942
- const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
1014
+ const scale = Math.min(baseScale, B.getFitScale(t, put));
943
1015
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
944
1016
  },
1017
+ getFitScale(t, put, isCoverMode) {
1018
+ const sw = t.width / put.width, sh = t.height / put.height;
1019
+ return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
1020
+ },
1021
+ put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
1022
+ to || (to = put);
1023
+ if (typeof putScale === 'string')
1024
+ putScale = B.getFitScale(t, put, putScale === 'cover');
1025
+ tempBounds$2.width = changeSize ? put.width *= putScale : put.width * putScale;
1026
+ tempBounds$2.height = changeSize ? put.height *= putScale : put.height * putScale;
1027
+ AlignHelper.toPoint(align, tempBounds$2, t, to, true, true);
1028
+ },
945
1029
  getSpread(t, spread, side) {
946
1030
  const n = {};
947
1031
  B.copyAndSpread(n, t, spread, false, side);
@@ -1115,8 +1199,8 @@ var LeaferUI = (function (exports) {
1115
1199
  BoundsHelper.move(this, x, y);
1116
1200
  return this;
1117
1201
  }
1118
- scale(scaleX, scaleY) {
1119
- BoundsHelper.scale(this, scaleX, scaleY);
1202
+ scale(scaleX, scaleY, onlySize) {
1203
+ BoundsHelper.scale(this, scaleX, scaleY, onlySize);
1120
1204
  return this;
1121
1205
  }
1122
1206
  scaleOf(origin, scaleX, scaleY) {
@@ -1134,6 +1218,9 @@ var LeaferUI = (function (exports) {
1134
1218
  getFitMatrix(put, baseScale) {
1135
1219
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1136
1220
  }
1221
+ put(put, align, putScale) {
1222
+ BoundsHelper.put(this, put, align, putScale);
1223
+ }
1137
1224
  spread(fourNumber, side) {
1138
1225
  BoundsHelper.spread(this, fourNumber, side);
1139
1226
  return this;
@@ -1242,79 +1329,6 @@ var LeaferUI = (function (exports) {
1242
1329
  }
1243
1330
  }
1244
1331
 
1245
- exports.Direction4 = void 0;
1246
- (function (Direction4) {
1247
- Direction4[Direction4["top"] = 0] = "top";
1248
- Direction4[Direction4["right"] = 1] = "right";
1249
- Direction4[Direction4["bottom"] = 2] = "bottom";
1250
- Direction4[Direction4["left"] = 3] = "left";
1251
- })(exports.Direction4 || (exports.Direction4 = {}));
1252
- exports.Direction9 = void 0;
1253
- (function (Direction9) {
1254
- Direction9[Direction9["topLeft"] = 0] = "topLeft";
1255
- Direction9[Direction9["top"] = 1] = "top";
1256
- Direction9[Direction9["topRight"] = 2] = "topRight";
1257
- Direction9[Direction9["right"] = 3] = "right";
1258
- Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
1259
- Direction9[Direction9["bottom"] = 5] = "bottom";
1260
- Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1261
- Direction9[Direction9["left"] = 7] = "left";
1262
- Direction9[Direction9["center"] = 8] = "center";
1263
- Direction9[Direction9["top-left"] = 0] = "top-left";
1264
- Direction9[Direction9["top-right"] = 2] = "top-right";
1265
- Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1266
- Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1267
- })(exports.Direction9 || (exports.Direction9 = {}));
1268
-
1269
- const directionData = [
1270
- { x: 0, y: 0 },
1271
- { x: 0.5, y: 0 },
1272
- { x: 1, y: 0 },
1273
- { x: 1, y: 0.5 },
1274
- { x: 1, y: 1 },
1275
- { x: 0.5, y: 1 },
1276
- { x: 0, y: 1 },
1277
- { x: 0, y: 0.5 },
1278
- { x: 0.5, y: 0.5 }
1279
- ];
1280
- directionData.forEach(item => item.type = 'percent');
1281
- const AroundHelper = {
1282
- directionData,
1283
- tempPoint: {},
1284
- get: get$4,
1285
- toPoint(around, bounds, to, onlySize, pointBounds) {
1286
- const point = get$4(around);
1287
- to.x = point.x;
1288
- to.y = point.y;
1289
- if (point.type === 'percent') {
1290
- to.x *= bounds.width;
1291
- to.y *= bounds.height;
1292
- if (pointBounds) {
1293
- to.x -= pointBounds.x;
1294
- to.y -= pointBounds.y;
1295
- if (point.x)
1296
- to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1297
- if (point.y)
1298
- to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1299
- }
1300
- }
1301
- if (!onlySize) {
1302
- to.x += bounds.x;
1303
- to.y += bounds.y;
1304
- }
1305
- }
1306
- };
1307
- function get$4(around) {
1308
- return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
1309
- }
1310
-
1311
- const { toPoint: toPoint$4 } = AroundHelper;
1312
- const AlignHelper = {
1313
- toPoint(align, contentBounds, bounds, to, onlySize) {
1314
- toPoint$4(align, bounds, to, onlySize, contentBounds);
1315
- }
1316
- };
1317
-
1318
1332
  const StringNumberMap = {
1319
1333
  '0': 1,
1320
1334
  '1': 1,
@@ -1445,11 +1459,17 @@ var LeaferUI = (function (exports) {
1445
1459
  return rs;
1446
1460
  },
1447
1461
  need(name) {
1448
- console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1462
+ console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1449
1463
  }
1450
1464
  };
1451
1465
  setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1452
1466
 
1467
+ const Creator = {
1468
+ editor(_options) {
1469
+ return Plugin.need('editor');
1470
+ }
1471
+ };
1472
+
1453
1473
  const debug$e = Debug.get('UICreator');
1454
1474
  const UICreator = {
1455
1475
  list: {},
@@ -1587,6 +1607,10 @@ var LeaferUI = (function (exports) {
1587
1607
  for (let i = 0, len = list.length; i < len; i++)
1588
1608
  map[list[i]] = true;
1589
1609
  return map;
1610
+ },
1611
+ stintSet(data, attrName, value) {
1612
+ value || (value = undefined);
1613
+ data[attrName] !== value && (data[attrName] = value);
1590
1614
  }
1591
1615
  };
1592
1616
  const { assign } = DataHelper;
@@ -2248,16 +2272,19 @@ var LeaferUI = (function (exports) {
2248
2272
  if (blendMode)
2249
2273
  this.blendMode = 'source-over';
2250
2274
  }
2251
- clearWorld(bounds, ceilPixel) {
2252
- this.setTempBounds(bounds, ceilPixel);
2253
- this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2254
- }
2255
2275
  clipWorld(bounds, ceilPixel) {
2256
2276
  this.beginPath();
2257
2277
  this.setTempBounds(bounds, ceilPixel);
2258
2278
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2259
2279
  this.clip();
2260
2280
  }
2281
+ clipUI(ruleData) {
2282
+ ruleData.windingRule ? this.clip(ruleData.windingRule) : this.clip();
2283
+ }
2284
+ clearWorld(bounds, ceilPixel) {
2285
+ this.setTempBounds(bounds, ceilPixel);
2286
+ this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2287
+ }
2261
2288
  clear() {
2262
2289
  const { pixelRatio } = this;
2263
2290
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
@@ -2388,7 +2415,7 @@ var LeaferUI = (function (exports) {
2388
2415
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2389
2416
  const { set, toNumberPoints } = PointHelper;
2390
2417
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
2391
- const tempPoint$2 = {};
2418
+ const tempPoint$1 = {};
2392
2419
  const BezierHelper = {
2393
2420
  points(data, originPoints, curve, close) {
2394
2421
  let points = toNumberPoints(originPoints);
@@ -2410,6 +2437,8 @@ var LeaferUI = (function (exports) {
2410
2437
  cY = points[i + 3];
2411
2438
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2412
2439
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2440
+ if (!ba && !cb)
2441
+ continue;
2413
2442
  d = ba + cb;
2414
2443
  ba = (t * ba) / d;
2415
2444
  cb = (t * cb) / d;
@@ -2579,8 +2608,8 @@ var LeaferUI = (function (exports) {
2579
2608
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2580
2609
  addPoint$1(pointBounds, toX, toY);
2581
2610
  for (let i = 0, len = tList.length; i < len; i++) {
2582
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2583
- addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
2611
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2612
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2584
2613
  }
2585
2614
  },
2586
2615
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -3389,7 +3418,7 @@ var LeaferUI = (function (exports) {
3389
3418
  }
3390
3419
 
3391
3420
  const FileHelper = {
3392
- opacityTypes: ['png', 'webp', 'svg'],
3421
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3393
3422
  upperCaseTypeMap: {},
3394
3423
  mineType(type) {
3395
3424
  if (!type || type.startsWith('image'))
@@ -3416,7 +3445,7 @@ var LeaferUI = (function (exports) {
3416
3445
  }
3417
3446
  };
3418
3447
  const F = FileHelper;
3419
- F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3448
+ F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3420
3449
 
3421
3450
  const debug$9 = Debug.get('TaskProcessor');
3422
3451
  class TaskItem {
@@ -3733,8 +3762,8 @@ var LeaferUI = (function (exports) {
3733
3762
  list.length = 0;
3734
3763
  }
3735
3764
  },
3736
- hasOpacityPixel(config) {
3737
- return FileHelper.opacityTypes.some(item => I.isFormat(item, config));
3765
+ hasAlphaPixel(config) {
3766
+ return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
3738
3767
  },
3739
3768
  isFormat(format, config) {
3740
3769
  if (config.format === format)
@@ -3772,7 +3801,7 @@ var LeaferUI = (function (exports) {
3772
3801
  this.setView(view.config ? view.view : view);
3773
3802
  }
3774
3803
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3775
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3804
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3776
3805
  }
3777
3806
  load(onSuccess, onError) {
3778
3807
  if (!this.loading) {
@@ -4460,7 +4489,7 @@ var LeaferUI = (function (exports) {
4460
4489
  }
4461
4490
  };
4462
4491
 
4463
- const { updateBounds: updateBounds$2 } = LeafHelper;
4492
+ const { updateBounds: updateBounds$3 } = LeafHelper;
4464
4493
  const BranchHelper = {
4465
4494
  sort(a, b) {
4466
4495
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4522,11 +4551,11 @@ var LeaferUI = (function (exports) {
4522
4551
  branch = branchStack[i];
4523
4552
  children = branch.children;
4524
4553
  for (let j = 0, len = children.length; j < len; j++) {
4525
- updateBounds$2(children[j]);
4554
+ updateBounds$3(children[j]);
4526
4555
  }
4527
4556
  if (exclude && exclude === branch)
4528
4557
  continue;
4529
- updateBounds$2(branch);
4558
+ updateBounds$3(branch);
4530
4559
  }
4531
4560
  }
4532
4561
  };
@@ -4544,7 +4573,7 @@ var LeaferUI = (function (exports) {
4544
4573
  }
4545
4574
  };
4546
4575
 
4547
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4576
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
4548
4577
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4549
4578
  const localContent = '_localContentBounds';
4550
4579
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -4588,7 +4617,9 @@ var LeaferUI = (function (exports) {
4588
4617
  this._localRenderBounds = local;
4589
4618
  }
4590
4619
  update() {
4591
- const { leafer } = this.leaf;
4620
+ const { leaf } = this, { leafer } = leaf;
4621
+ if (leaf.isApp)
4622
+ return updateBounds$2(leaf);
4592
4623
  if (leafer) {
4593
4624
  if (leafer.ready)
4594
4625
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4596,7 +4627,7 @@ var LeaferUI = (function (exports) {
4596
4627
  leafer.start();
4597
4628
  }
4598
4629
  else {
4599
- let root = this.leaf;
4630
+ let root = leaf;
4600
4631
  while (root.parent && !root.parent.leafer) {
4601
4632
  root = root.parent;
4602
4633
  }
@@ -4818,7 +4849,7 @@ var LeaferUI = (function (exports) {
4818
4849
  }
4819
4850
  childrenSortChange() {
4820
4851
  if (!this.childrenSortChanged) {
4821
- this.childrenSortChanged = true;
4852
+ this.childrenSortChanged = this.affectChildrenSort = true;
4822
4853
  this.leaf.forceUpdate('surface');
4823
4854
  }
4824
4855
  }
@@ -4885,6 +4916,40 @@ var LeaferUI = (function (exports) {
4885
4916
  ImageEvent.LOADED = 'image.loaded';
4886
4917
  ImageEvent.ERROR = 'image.error';
4887
4918
 
4919
+ class BoundsEvent extends Event {
4920
+ static checkHas(leaf, type, mode) {
4921
+ if (mode === 'on') {
4922
+ type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
4923
+ }
4924
+ else {
4925
+ leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
4926
+ leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
4927
+ }
4928
+ }
4929
+ static emitLocal(leaf) {
4930
+ if (leaf.leaferIsReady) {
4931
+ const { resized } = leaf.__layout;
4932
+ if (resized !== 'local') {
4933
+ leaf.emit(RESIZE, leaf);
4934
+ if (resized === 'inner')
4935
+ leaf.emit(INNER, leaf);
4936
+ }
4937
+ leaf.emit(LOCAL, leaf);
4938
+ }
4939
+ }
4940
+ static emitWorld(leaf) {
4941
+ if (leaf.leaferIsReady)
4942
+ leaf.emit(WORLD, this);
4943
+ }
4944
+ }
4945
+ BoundsEvent.RESIZE = 'bounds.resize';
4946
+ BoundsEvent.INNER = 'bounds.inner';
4947
+ BoundsEvent.LOCAL = 'bounds.local';
4948
+ BoundsEvent.WORLD = 'bounds.world';
4949
+ const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
4950
+ const boundsEventMap = {};
4951
+ [RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
4952
+
4888
4953
  class ResizeEvent extends Event {
4889
4954
  get bigger() {
4890
4955
  if (!this.old)
@@ -4981,9 +5046,12 @@ var LeaferUI = (function (exports) {
4981
5046
  set event(map) { this.on(map); }
4982
5047
  on(type, listener, options) {
4983
5048
  if (!listener) {
4984
- let event, map = type;
4985
- for (let key in map)
4986
- event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
5049
+ let event;
5050
+ if (type instanceof Array)
5051
+ type.forEach(item => this.on(item[0], item[1], item[2]));
5052
+ else
5053
+ for (let key in type)
5054
+ (event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
4987
5055
  return;
4988
5056
  }
4989
5057
  let capture, once;
@@ -5013,6 +5081,8 @@ var LeaferUI = (function (exports) {
5013
5081
  else {
5014
5082
  map[type] = [item];
5015
5083
  }
5084
+ if (boundsEventMap[type])
5085
+ BoundsEvent.checkHas(this, type, 'on');
5016
5086
  }
5017
5087
  });
5018
5088
  }
@@ -5034,6 +5104,8 @@ var LeaferUI = (function (exports) {
5034
5104
  events.splice(index, 1);
5035
5105
  if (!events.length)
5036
5106
  delete map[type];
5107
+ if (boundsEventMap[type])
5108
+ BoundsEvent.checkHas(this, type, 'off');
5037
5109
  }
5038
5110
  }
5039
5111
  });
@@ -5053,19 +5125,31 @@ var LeaferUI = (function (exports) {
5053
5125
  }
5054
5126
  }
5055
5127
  on_(type, listener, bind, options) {
5056
- if (bind)
5057
- listener = listener.bind(bind);
5058
- this.on(type, listener, options);
5128
+ if (!listener)
5129
+ (type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
5130
+ else
5131
+ this.on(type, bind ? listener = listener.bind(bind) : listener, options);
5059
5132
  return { type, current: this, listener, options };
5060
5133
  }
5061
5134
  off_(id) {
5062
5135
  if (!id)
5063
5136
  return;
5064
5137
  const list = id instanceof Array ? id : [id];
5065
- list.forEach(item => item.current.off(item.type, item.listener, item.options));
5138
+ list.forEach(item => {
5139
+ if (!item.listener)
5140
+ (item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
5141
+ else
5142
+ item.current.off(item.type, item.listener, item.options);
5143
+ });
5066
5144
  list.length = 0;
5067
5145
  }
5068
- once(type, listener, capture) {
5146
+ once(type, listener, captureOrBind, capture) {
5147
+ if (!listener)
5148
+ return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
5149
+ if (typeof captureOrBind === 'object')
5150
+ listener = listener.bind(captureOrBind);
5151
+ else
5152
+ capture = captureOrBind;
5069
5153
  this.on(type, listener, { once: true, capture });
5070
5154
  }
5071
5155
  emit(type, event, capture) {
@@ -5177,7 +5261,7 @@ var LeaferUI = (function (exports) {
5177
5261
  };
5178
5262
 
5179
5263
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5180
- const { toPoint: toPoint$3, tempPoint: tempPoint$1 } = AroundHelper;
5264
+ const { toPoint: toPoint$3, tempPoint } = AroundHelper;
5181
5265
  const LeafMatrix = {
5182
5266
  __updateWorldMatrix() {
5183
5267
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
@@ -5186,19 +5270,19 @@ var LeaferUI = (function (exports) {
5186
5270
  if (this.__local) {
5187
5271
  const layout = this.__layout, local = this.__local, data = this.__;
5188
5272
  if (layout.affectScaleOrRotation) {
5189
- if (layout.scaleChanged || layout.rotationChanged) {
5273
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5190
5274
  setLayout(local, data, null, null, layout.affectRotation);
5191
- layout.scaleChanged = layout.rotationChanged = false;
5275
+ layout.scaleChanged = layout.rotationChanged = undefined;
5192
5276
  }
5193
5277
  }
5194
5278
  local.e = data.x + data.offsetX;
5195
5279
  local.f = data.y + data.offsetY;
5196
5280
  if (data.around || data.origin) {
5197
- toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
5198
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
5281
+ toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint);
5282
+ translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
5199
5283
  }
5200
5284
  }
5201
- this.__layout.matrixChanged = false;
5285
+ this.__layout.matrixChanged = undefined;
5202
5286
  }
5203
5287
  };
5204
5288
 
@@ -5208,11 +5292,17 @@ var LeaferUI = (function (exports) {
5208
5292
  const { toBounds: toBounds$1 } = PathBounds;
5209
5293
  const LeafBounds = {
5210
5294
  __updateWorldBounds() {
5211
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5212
- if (this.__layout.resized) {
5213
- this.__onUpdateSize();
5214
- this.__layout.resized = false;
5295
+ const layout = this.__layout;
5296
+ toOuterOf$1(layout.renderBounds, this.__world, this.__world);
5297
+ if (layout.resized) {
5298
+ if (layout.resized === 'inner')
5299
+ this.__onUpdateSize();
5300
+ if (this.__hasLocalEvent)
5301
+ BoundsEvent.emitLocal(this);
5302
+ layout.resized = undefined;
5215
5303
  }
5304
+ if (this.__hasWorldEvent)
5305
+ BoundsEvent.emitWorld(this);
5216
5306
  },
5217
5307
  __updateLocalBounds() {
5218
5308
  const layout = this.__layout;
@@ -5221,12 +5311,12 @@ var LeaferUI = (function (exports) {
5221
5311
  this.__updatePath();
5222
5312
  this.__updateRenderPath();
5223
5313
  this.__updateBoxBounds();
5224
- layout.resized = true;
5314
+ layout.resized = 'inner';
5225
5315
  }
5226
5316
  if (layout.localBoxChanged) {
5227
5317
  if (this.__local)
5228
5318
  this.__updateLocalBoxBounds();
5229
- layout.localBoxChanged = false;
5319
+ layout.localBoxChanged = undefined;
5230
5320
  if (layout.strokeSpread)
5231
5321
  layout.strokeChanged = true;
5232
5322
  if (layout.renderSpread)
@@ -5234,7 +5324,7 @@ var LeaferUI = (function (exports) {
5234
5324
  if (this.parent)
5235
5325
  this.parent.__layout.boxChange();
5236
5326
  }
5237
- layout.boxChanged = false;
5327
+ layout.boxChanged = undefined;
5238
5328
  if (layout.strokeChanged) {
5239
5329
  layout.strokeSpread = this.__updateStrokeSpread();
5240
5330
  if (layout.strokeSpread) {
@@ -5246,12 +5336,12 @@ var LeaferUI = (function (exports) {
5246
5336
  else {
5247
5337
  layout.spreadStrokeCancel();
5248
5338
  }
5249
- layout.strokeChanged = false;
5339
+ layout.strokeChanged = undefined;
5250
5340
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5251
5341
  layout.renderChanged = true;
5252
5342
  if (this.parent)
5253
5343
  this.parent.__layout.strokeChange();
5254
- layout.resized = true;
5344
+ layout.resized = 'inner';
5255
5345
  }
5256
5346
  if (layout.renderChanged) {
5257
5347
  layout.renderSpread = this.__updateRenderSpread();
@@ -5264,11 +5354,12 @@ var LeaferUI = (function (exports) {
5264
5354
  else {
5265
5355
  layout.spreadRenderCancel();
5266
5356
  }
5267
- layout.renderChanged = false;
5357
+ layout.renderChanged = undefined;
5268
5358
  if (this.parent)
5269
5359
  this.parent.__layout.renderChange();
5270
5360
  }
5271
- layout.boundsChanged = false;
5361
+ layout.resized || (layout.resized = 'local');
5362
+ layout.boundsChanged = undefined;
5272
5363
  },
5273
5364
  __updateLocalBoxBounds() {
5274
5365
  if (this.__hasMotionPath)
@@ -5362,7 +5453,7 @@ var LeaferUI = (function (exports) {
5362
5453
  if (this.__worldOpacity) {
5363
5454
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5364
5455
  this.__drawRenderPath(canvas);
5365
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
5456
+ canvas.clipUI(this);
5366
5457
  }
5367
5458
  },
5368
5459
  __updateWorldOpacity() {
@@ -5808,7 +5899,7 @@ var LeaferUI = (function (exports) {
5808
5899
  off(_type, _listener, _options) { }
5809
5900
  on_(_type, _listener, _bind, _options) { return undefined; }
5810
5901
  off_(_id) { }
5811
- once(_type, _listener, _capture) { }
5902
+ once(_type, _listener, _captureOrBind, _capture) { }
5812
5903
  emit(_type, _event, _capture) { }
5813
5904
  emitEvent(_event, _capture) { }
5814
5905
  hasEvent(_type, _capture) { return false; }
@@ -6145,7 +6236,7 @@ var LeaferUI = (function (exports) {
6145
6236
  }
6146
6237
  }
6147
6238
 
6148
- const version = "1.6.2";
6239
+ const version = "1.6.4";
6149
6240
 
6150
6241
  const debug$4 = Debug.get('LeaferCanvas');
6151
6242
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6485,17 +6576,15 @@ var LeaferUI = (function (exports) {
6485
6576
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6486
6577
  this.__updatedList = new LeafList();
6487
6578
  this.totalTimes++;
6488
- this.changed = false;
6489
- this.hasVisible = false;
6490
- this.hasRemove = false;
6491
- this.hasAdd = false;
6579
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6492
6580
  }
6493
6581
  __listenEvents() {
6494
- const { target } = this;
6495
6582
  this.__eventIds = [
6496
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6497
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6498
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6583
+ this.target.on_([
6584
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6585
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6586
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6587
+ ])
6499
6588
  ];
6500
6589
  }
6501
6590
  __removeListenEvents() {
@@ -6505,8 +6594,7 @@ var LeaferUI = (function (exports) {
6505
6594
  if (this.target) {
6506
6595
  this.stop();
6507
6596
  this.__removeListenEvents();
6508
- this.target = null;
6509
- this.__updatedList = null;
6597
+ this.target = this.__updatedList = null;
6510
6598
  }
6511
6599
  }
6512
6600
  }
@@ -6611,7 +6699,7 @@ var LeaferUI = (function (exports) {
6611
6699
  this.disabled = true;
6612
6700
  }
6613
6701
  layout() {
6614
- if (!this.running)
6702
+ if (this.layouting || !this.running)
6615
6703
  return;
6616
6704
  const { target } = this;
6617
6705
  this.times = 0;
@@ -6694,12 +6782,10 @@ var LeaferUI = (function (exports) {
6694
6782
  }
6695
6783
  static fullLayout(target) {
6696
6784
  updateAllMatrix(target, true);
6697
- if (target.isBranch) {
6785
+ if (target.isBranch)
6698
6786
  BranchHelper.updateBounds(target);
6699
- }
6700
- else {
6787
+ else
6701
6788
  LeafHelper.updateBounds(target);
6702
- }
6703
6789
  updateAllChange(target);
6704
6790
  }
6705
6791
  addExtra(leaf) {
@@ -6722,11 +6808,12 @@ var LeaferUI = (function (exports) {
6722
6808
  this.__updatedList = event.data.updatedList;
6723
6809
  }
6724
6810
  __listenEvents() {
6725
- const { target } = this;
6726
6811
  this.__eventIds = [
6727
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6728
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6729
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6812
+ this.target.on_([
6813
+ [LayoutEvent.REQUEST, this.layout, this],
6814
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6815
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6816
+ ])
6730
6817
  ];
6731
6818
  }
6732
6819
  __removeListenEvents() {
@@ -6957,12 +7044,13 @@ var LeaferUI = (function (exports) {
6957
7044
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6958
7045
  }
6959
7046
  __listenEvents() {
6960
- const { target } = this;
6961
7047
  this.__eventIds = [
6962
- target.on_(RenderEvent.REQUEST, this.update, this),
6963
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6964
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6965
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
7048
+ this.target.on_([
7049
+ [RenderEvent.REQUEST, this.update, this],
7050
+ [LayoutEvent.END, this.__onLayoutEnd, this],
7051
+ [RenderEvent.AGAIN, this.renderAgain, this],
7052
+ [ResizeEvent.RESIZE, this.__onResize, this]
7053
+ ])
6966
7054
  ];
6967
7055
  }
6968
7056
  __removeListenEvents() {
@@ -7021,8 +7109,32 @@ var LeaferUI = (function (exports) {
7021
7109
  };
7022
7110
  }
7023
7111
 
7112
+ function hasTransparent$3(color) {
7113
+ if (!color || color.length === 7 || color.length === 4)
7114
+ return false;
7115
+ if (color === 'transparent')
7116
+ return true;
7117
+ const first = color[0];
7118
+ if (first === '#') {
7119
+ switch (color.length) {
7120
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7121
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7122
+ }
7123
+ }
7124
+ else if (first === 'r' || first === 'h') {
7125
+ if (color[3] === 'a') {
7126
+ const i = color.lastIndexOf(',');
7127
+ if (i > -1)
7128
+ return parseFloat(color.slice(i + 1)) < 1;
7129
+ }
7130
+ }
7131
+ return false;
7132
+ }
7133
+
7024
7134
  const TextConvert = {};
7025
- const ColorConvert = {};
7135
+ const ColorConvert = {
7136
+ hasTransparent: hasTransparent$3
7137
+ };
7026
7138
  const UnitConvert = {
7027
7139
  number(value, percentRefer) {
7028
7140
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7048,6 +7160,7 @@ var LeaferUI = (function (exports) {
7048
7160
  };
7049
7161
 
7050
7162
  const { parse, objectToCanvasData } = PathConvert;
7163
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7051
7164
  const emptyPaint = {};
7052
7165
  const debug$1 = Debug.get('UIData');
7053
7166
  class UIData extends LeafData {
@@ -7106,38 +7219,22 @@ var LeaferUI = (function (exports) {
7106
7219
  if (this.__naturalWidth)
7107
7220
  this.__removeNaturalSize();
7108
7221
  if (typeof value === 'string' || !value) {
7109
- if (this.__isFills) {
7110
- this.__removeInput('fill');
7111
- PaintImage.recycleImage('fill', this);
7112
- this.__isFills = false;
7113
- this.__pixelFill && (this.__pixelFill = false);
7114
- }
7222
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7223
+ this.__isFills && this.__removePaint('fill', true);
7115
7224
  this._fill = value;
7116
7225
  }
7117
7226
  else if (typeof value === 'object') {
7118
- this.__setInput('fill', value);
7119
- const layout = this.__leaf.__layout;
7120
- layout.boxChanged || layout.boxChange();
7121
- this.__isFills = true;
7122
- this._fill || (this._fill = emptyPaint);
7227
+ this.__setPaint('fill', value);
7123
7228
  }
7124
7229
  }
7125
7230
  setStroke(value) {
7126
7231
  if (typeof value === 'string' || !value) {
7127
- if (this.__isStrokes) {
7128
- this.__removeInput('stroke');
7129
- PaintImage.recycleImage('stroke', this);
7130
- this.__isStrokes = false;
7131
- this.__pixelStroke && (this.__pixelStroke = false);
7132
- }
7232
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7233
+ this.__isStrokes && this.__removePaint('stroke', true);
7133
7234
  this._stroke = value;
7134
7235
  }
7135
7236
  else if (typeof value === 'object') {
7136
- this.__setInput('stroke', value);
7137
- const layout = this.__leaf.__layout;
7138
- layout.boxChanged || layout.boxChange();
7139
- this.__isStrokes = true;
7140
- this._stroke || (this._stroke = emptyPaint);
7237
+ this.__setPaint('stroke', value);
7141
7238
  }
7142
7239
  }
7143
7240
  setPath(value) {
@@ -7167,7 +7264,34 @@ var LeaferUI = (function (exports) {
7167
7264
  Paint.compute('fill', this.__leaf);
7168
7265
  if (stroke)
7169
7266
  Paint.compute('stroke', this.__leaf);
7170
- this.__needComputePaint = false;
7267
+ this.__needComputePaint = undefined;
7268
+ }
7269
+ __setPaint(attrName, value) {
7270
+ this.__setInput(attrName, value);
7271
+ const layout = this.__leaf.__layout;
7272
+ layout.boxChanged || layout.boxChange();
7273
+ if (value instanceof Array && !value.length) {
7274
+ this.__removePaint(attrName);
7275
+ }
7276
+ else {
7277
+ if (attrName === 'fill')
7278
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7279
+ else
7280
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7281
+ }
7282
+ }
7283
+ __removePaint(attrName, removeInput) {
7284
+ if (removeInput)
7285
+ this.__removeInput(attrName);
7286
+ PaintImage.recycleImage(attrName, this);
7287
+ if (attrName === 'fill') {
7288
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7289
+ this._fill = this.__isFills = undefined;
7290
+ }
7291
+ else {
7292
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7293
+ this._stroke = this.__isStrokes = undefined;
7294
+ }
7171
7295
  }
7172
7296
  }
7173
7297
  function setArray(data, key, value) {
@@ -7175,10 +7299,10 @@ var LeaferUI = (function (exports) {
7175
7299
  if (value instanceof Array) {
7176
7300
  if (value.some((item) => item.visible === false))
7177
7301
  value = value.filter((item) => item.visible !== false);
7178
- value.length || (value = null);
7302
+ value.length || (value = undefined);
7179
7303
  }
7180
7304
  else
7181
- value = value && value.visible !== false ? [value] : null;
7305
+ value = value && value.visible !== false ? [value] : undefined;
7182
7306
  data['_' + key] = value;
7183
7307
  }
7184
7308
 
@@ -7281,8 +7405,6 @@ var LeaferUI = (function (exports) {
7281
7405
  this._url = value;
7282
7406
  }
7283
7407
  __setImageFill(value) {
7284
- if (this.__leaf.image)
7285
- this.__leaf.image = null;
7286
7408
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7287
7409
  }
7288
7410
  __getData() {
@@ -7348,21 +7470,19 @@ var LeaferUI = (function (exports) {
7348
7470
  }
7349
7471
  };
7350
7472
 
7473
+ const { stintSet: stintSet$1 } = DataHelper;
7351
7474
  const UIRender = {
7352
7475
  __updateChange() {
7353
- const data = this.__, w = this.__world;
7476
+ const data = this.__;
7354
7477
  if (data.__useEffect) {
7355
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7356
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7478
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7479
+ 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')));
7480
+ data.__useEffect = !!(shadow || otherEffect);
7357
7481
  }
7358
- const half = data.__hasHalf;
7359
- w.half !== half && (w.half = half);
7482
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7483
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7360
7484
  data.__checkSingle();
7361
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7362
- if (complex)
7363
- data.__complex = true;
7364
- else
7365
- data.__complex && (data.__complex = false);
7485
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7366
7486
  },
7367
7487
  __drawFast(canvas, options) {
7368
7488
  drawFast(this, canvas, options);
@@ -7372,21 +7492,23 @@ var LeaferUI = (function (exports) {
7372
7492
  if (data.__complex) {
7373
7493
  if (data.__needComputePaint)
7374
7494
  data.__computePaint();
7375
- const { fill, stroke, __drawAfterFill } = data;
7495
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7376
7496
  this.__drawRenderPath(canvas);
7377
- if (data.__useEffect) {
7497
+ if (data.__useEffect && !__isFastShadow) {
7378
7498
  const shape = Paint.shape(this, canvas, options);
7379
7499
  this.__nowWorld = this.__getNowWorld(options);
7380
7500
  const { shadow, innerShadow, filter } = data;
7381
7501
  if (shadow)
7382
7502
  Effect.shadow(this, canvas, shape);
7503
+ if (__fillAfterStroke)
7504
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7383
7505
  if (fill)
7384
7506
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7385
7507
  if (__drawAfterFill)
7386
7508
  this.__drawAfterFill(canvas, options);
7387
7509
  if (innerShadow)
7388
7510
  Effect.innerShadow(this, canvas, shape);
7389
- if (stroke)
7511
+ if (stroke && !__fillAfterStroke)
7390
7512
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7391
7513
  if (filter)
7392
7514
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7395,21 +7517,27 @@ var LeaferUI = (function (exports) {
7395
7517
  shape.canvas.recycle();
7396
7518
  }
7397
7519
  else {
7520
+ if (__fillAfterStroke)
7521
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7522
+ if (__isFastShadow) {
7523
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7524
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7525
+ }
7398
7526
  if (fill)
7399
7527
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7528
+ if (__isFastShadow)
7529
+ canvas.restore();
7400
7530
  if (__drawAfterFill)
7401
7531
  this.__drawAfterFill(canvas, options);
7402
- if (stroke)
7532
+ if (stroke && !__fillAfterStroke)
7403
7533
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7404
7534
  }
7405
7535
  }
7406
7536
  else {
7407
- if (data.__pathInputed) {
7537
+ if (data.__pathInputed)
7408
7538
  drawFast(this, canvas, options);
7409
- }
7410
- else {
7539
+ else
7411
7540
  this.__drawFast(canvas, options);
7412
- }
7413
7541
  }
7414
7542
  },
7415
7543
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7418,17 +7546,17 @@ var LeaferUI = (function (exports) {
7418
7546
  const { fill, stroke } = this.__;
7419
7547
  this.__drawRenderPath(canvas);
7420
7548
  if (fill && !ignoreFill)
7421
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7549
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7422
7550
  if (this.__.__isCanvas)
7423
7551
  this.__drawAfterFill(canvas, options);
7424
7552
  if (stroke && !ignoreStroke)
7425
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7553
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7426
7554
  }
7427
7555
  },
7428
7556
  __drawAfterFill(canvas, options) {
7429
7557
  if (this.__.__clipAfterFill) {
7430
7558
  canvas.save();
7431
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
7559
+ canvas.clipUI();
7432
7560
  this.__drawContent(canvas, options);
7433
7561
  canvas.restore();
7434
7562
  }
@@ -7437,13 +7565,15 @@ var LeaferUI = (function (exports) {
7437
7565
  }
7438
7566
  };
7439
7567
  function drawFast(ui, canvas, options) {
7440
- const { fill, stroke, __drawAfterFill } = ui.__;
7568
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7441
7569
  ui.__drawRenderPath(canvas);
7570
+ if (__fillAfterStroke)
7571
+ Paint.stroke(stroke, ui, canvas);
7442
7572
  if (fill)
7443
7573
  Paint.fill(fill, ui, canvas);
7444
7574
  if (__drawAfterFill)
7445
7575
  ui.__drawAfterFill(canvas, options);
7446
- if (stroke)
7576
+ if (stroke && !__fillAfterStroke)
7447
7577
  Paint.stroke(stroke, ui, canvas);
7448
7578
  }
7449
7579
 
@@ -7815,6 +7945,9 @@ var LeaferUI = (function (exports) {
7815
7945
  __decorate([
7816
7946
  surfaceType()
7817
7947
  ], exports.UI.prototype, "placeholderColor", void 0);
7948
+ __decorate([
7949
+ dataType(100)
7950
+ ], exports.UI.prototype, "placeholderDelay", void 0);
7818
7951
  __decorate([
7819
7952
  dataType({})
7820
7953
  ], exports.UI.prototype, "data", void 0);
@@ -8216,15 +8349,20 @@ var LeaferUI = (function (exports) {
8216
8349
  }
8217
8350
  __listenEvents() {
8218
8351
  const runId = Run.start('FirstCreate ' + this.innerName);
8219
- this.once(LeaferEvent.START, () => Run.end(runId));
8220
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8221
- this.once(RenderEvent.START, () => this.__onCreated());
8222
- this.once(RenderEvent.END, () => this.__onViewReady());
8223
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8352
+ this.once([
8353
+ [LeaferEvent.START, () => Run.end(runId)],
8354
+ [LayoutEvent.START, this.updateLazyBounds, this],
8355
+ [RenderEvent.START, this.__onCreated, this],
8356
+ [RenderEvent.END, this.__onViewReady, this]
8357
+ ]);
8358
+ this.__eventIds.push(this.on_([
8359
+ [WatchEvent.DATA, this.__onWatchData, this],
8360
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8361
+ [RenderEvent.NEXT, this.__onNextRender, this]
8362
+ ]));
8224
8363
  }
8225
8364
  __removeListenEvents() {
8226
8365
  this.off_(this.__eventIds);
8227
- this.__eventIds.length = 0;
8228
8366
  }
8229
8367
  destroy(sync) {
8230
8368
  const doDestory = () => {
@@ -8332,13 +8470,13 @@ var LeaferUI = (function (exports) {
8332
8470
  super.__updateRenderBounds();
8333
8471
  copy$2(childrenRenderBounds, renderBounds);
8334
8472
  this.__updateRectRenderBounds();
8335
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8473
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8336
8474
  if (isOverflow && this.__.overflow !== 'hide')
8337
8475
  add(renderBounds, childrenRenderBounds);
8338
8476
  }
8339
8477
  else
8340
8478
  this.__updateRectRenderBounds();
8341
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8479
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8342
8480
  }
8343
8481
  __updateRectRenderBounds() { }
8344
8482
  __updateRectChange() { }
@@ -8642,18 +8780,10 @@ var LeaferUI = (function (exports) {
8642
8780
 
8643
8781
  exports.Image = class Image extends exports.Rect {
8644
8782
  get __tag() { return 'Image'; }
8645
- get ready() { return this.image ? this.image.ready : false; }
8783
+ get ready() { const { image } = this; return image && image.ready; }
8784
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8646
8785
  constructor(data) {
8647
8786
  super(data);
8648
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
8649
- }
8650
- __onLoaded(e) {
8651
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8652
- this.image = e.image;
8653
- }
8654
- destroy() {
8655
- this.image = null;
8656
- super.destroy();
8657
8787
  }
8658
8788
  };
8659
8789
  __decorate([
@@ -8669,11 +8799,11 @@ var LeaferUI = (function (exports) {
8669
8799
 
8670
8800
  exports.Canvas = class Canvas extends exports.Rect {
8671
8801
  get __tag() { return 'Canvas'; }
8802
+ get context() { return this.canvas.context; }
8672
8803
  get ready() { return !this.url; }
8673
8804
  constructor(data) {
8674
8805
  super(data);
8675
8806
  this.canvas = Creator.canvas(this.__);
8676
- this.context = this.canvas.context;
8677
8807
  if (data && data.url)
8678
8808
  this.drawImage(data.url);
8679
8809
  }
@@ -8717,7 +8847,7 @@ var LeaferUI = (function (exports) {
8717
8847
  destroy() {
8718
8848
  if (this.canvas) {
8719
8849
  this.canvas.destroy();
8720
- this.canvas = this.context = null;
8850
+ this.canvas = null;
8721
8851
  }
8722
8852
  super.destroy();
8723
8853
  }
@@ -8793,12 +8923,11 @@ var LeaferUI = (function (exports) {
8793
8923
  super.__updateBoxBounds();
8794
8924
  if (italic)
8795
8925
  b.width += fontSize * 0.16;
8796
- const isOverflow = !includes(b, contentBounds) || undefined;
8797
- if (isOverflow)
8926
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8927
+ if (this.isOverflow)
8798
8928
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8799
8929
  else
8800
8930
  data.__textBoxBounds = b;
8801
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8802
8931
  }
8803
8932
  __onUpdateSize() {
8804
8933
  if (this.__box)
@@ -8912,6 +9041,9 @@ var LeaferUI = (function (exports) {
8912
9041
  __decorate([
8913
9042
  boundsType('show')
8914
9043
  ], exports.Text.prototype, "textOverflow", void 0);
9044
+ __decorate([
9045
+ surfaceType(false)
9046
+ ], exports.Text.prototype, "textEditing", void 0);
8915
9047
  exports.Text = __decorate([
8916
9048
  registerUI()
8917
9049
  ], exports.Text);
@@ -9044,35 +9176,38 @@ var LeaferUI = (function (exports) {
9044
9176
  }
9045
9177
 
9046
9178
  function strokeText(stroke, ui, canvas) {
9047
- const { strokeAlign } = ui.__;
9048
- const isStrokes = typeof stroke !== 'string';
9049
- switch (strokeAlign) {
9179
+ switch (ui.__.strokeAlign) {
9050
9180
  case 'center':
9051
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
9052
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9181
+ drawCenter$1(stroke, 1, ui, canvas);
9053
9182
  break;
9054
9183
  case 'inside':
9055
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
9184
+ drawAlign(stroke, 'inside', ui, canvas);
9056
9185
  break;
9057
9186
  case 'outside':
9058
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
9187
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
9059
9188
  break;
9060
9189
  }
9061
9190
  }
9062
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
9063
- const { __strokeWidth, __font } = ui.__;
9191
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
9192
+ const data = ui.__;
9193
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
9194
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9195
+ }
9196
+ function drawAlign(stroke, align, ui, canvas) {
9064
9197
  const out = canvas.getSameCanvas(true, true);
9065
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
9066
- out.font = __font;
9067
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
9198
+ out.font = ui.__.__font;
9199
+ drawCenter$1(stroke, 2, ui, out);
9068
9200
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9069
9201
  fillText(ui, out);
9070
9202
  out.blendMode = 'normal';
9071
- if (ui.__worldFlipped)
9203
+ copyWorld(canvas, out, ui);
9204
+ out.recycle(ui.__nowWorld);
9205
+ }
9206
+ function copyWorld(canvas, out, ui) {
9207
+ if (ui.__worldFlipped || Platform.fullImageShadow)
9072
9208
  canvas.copyWorldByReset(out, ui.__nowWorld);
9073
9209
  else
9074
9210
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9075
- out.recycle(ui.__nowWorld);
9076
9211
  }
9077
9212
  function drawTextStroke(ui, canvas) {
9078
9213
  let row, data = ui.__.__textDrawData;
@@ -9110,90 +9245,56 @@ var LeaferUI = (function (exports) {
9110
9245
  }
9111
9246
 
9112
9247
  function stroke(stroke, ui, canvas) {
9113
- const options = ui.__;
9114
- const { __strokeWidth, strokeAlign, __font } = options;
9115
- if (!__strokeWidth)
9248
+ const data = ui.__;
9249
+ if (!data.__strokeWidth)
9116
9250
  return;
9117
- if (__font) {
9251
+ if (data.__font) {
9118
9252
  strokeText(stroke, ui, canvas);
9119
9253
  }
9120
9254
  else {
9121
- switch (strokeAlign) {
9255
+ switch (data.strokeAlign) {
9122
9256
  case 'center':
9123
- canvas.setStroke(stroke, __strokeWidth, options);
9124
- canvas.stroke();
9125
- if (options.__useArrow)
9126
- strokeArrow(ui, canvas);
9257
+ drawCenter(stroke, 1, ui, canvas);
9127
9258
  break;
9128
9259
  case 'inside':
9129
- canvas.save();
9130
- canvas.setStroke(stroke, __strokeWidth * 2, options);
9131
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9132
- canvas.stroke();
9133
- canvas.restore();
9260
+ drawInside(stroke, ui, canvas);
9134
9261
  break;
9135
9262
  case 'outside':
9136
- const out = canvas.getSameCanvas(true, true);
9137
- out.setStroke(stroke, __strokeWidth * 2, options);
9138
- ui.__drawRenderPath(out);
9139
- out.stroke();
9140
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9141
- out.clearWorld(ui.__layout.renderBounds);
9142
- if (ui.__worldFlipped)
9143
- canvas.copyWorldByReset(out, ui.__nowWorld);
9144
- else
9145
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
9146
- out.recycle(ui.__nowWorld);
9263
+ drawOutside(stroke, ui, canvas);
9147
9264
  break;
9148
9265
  }
9149
9266
  }
9150
9267
  }
9151
9268
  function strokes(strokes, ui, canvas) {
9152
- const options = ui.__;
9153
- const { __strokeWidth, strokeAlign, __font } = options;
9154
- if (!__strokeWidth)
9155
- return;
9156
- if (__font) {
9157
- strokeText(strokes, ui, canvas);
9269
+ stroke(strokes, ui, canvas);
9270
+ }
9271
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
9272
+ const data = ui.__;
9273
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
9274
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
9275
+ if (data.__useArrow)
9276
+ Paint.strokeArrow(stroke, ui, canvas);
9277
+ }
9278
+ function drawInside(stroke, ui, canvas) {
9279
+ canvas.save();
9280
+ canvas.clipUI(ui);
9281
+ drawCenter(stroke, 2, ui, canvas);
9282
+ canvas.restore();
9283
+ }
9284
+ function drawOutside(stroke, ui, canvas) {
9285
+ const data = ui.__;
9286
+ if (data.__fillAfterStroke) {
9287
+ drawCenter(stroke, 2, ui, canvas);
9158
9288
  }
9159
9289
  else {
9160
- switch (strokeAlign) {
9161
- case 'center':
9162
- canvas.setStroke(undefined, __strokeWidth, options);
9163
- drawStrokesStyle(strokes, false, ui, canvas);
9164
- if (options.__useArrow)
9165
- strokeArrow(ui, canvas);
9166
- break;
9167
- case 'inside':
9168
- canvas.save();
9169
- canvas.setStroke(undefined, __strokeWidth * 2, options);
9170
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9171
- drawStrokesStyle(strokes, false, ui, canvas);
9172
- canvas.restore();
9173
- break;
9174
- case 'outside':
9175
- const { renderBounds } = ui.__layout;
9176
- const out = canvas.getSameCanvas(true, true);
9177
- ui.__drawRenderPath(out);
9178
- out.setStroke(undefined, __strokeWidth * 2, options);
9179
- drawStrokesStyle(strokes, false, ui, out);
9180
- options.windingRule ? out.clip(options.windingRule) : out.clip();
9181
- out.clearWorld(renderBounds);
9182
- if (ui.__worldFlipped)
9183
- canvas.copyWorldByReset(out, ui.__nowWorld);
9184
- else
9185
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
9186
- out.recycle(ui.__nowWorld);
9187
- break;
9188
- }
9189
- }
9190
- }
9191
- function strokeArrow(ui, canvas) {
9192
- if (ui.__.dashPattern) {
9193
- canvas.beginPath();
9194
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
9195
- canvas.dashPattern = null;
9196
- canvas.stroke();
9290
+ const { renderBounds } = ui.__layout;
9291
+ const out = canvas.getSameCanvas(true, true);
9292
+ ui.__drawRenderPath(out);
9293
+ drawCenter(stroke, 2, ui, out);
9294
+ out.clipUI(data);
9295
+ out.clearWorld(renderBounds);
9296
+ copyWorld(canvas, out, ui);
9297
+ out.recycle(ui.__nowWorld);
9197
9298
  }
9198
9299
  }
9199
9300
 
@@ -9240,41 +9341,66 @@ var LeaferUI = (function (exports) {
9240
9341
  }
9241
9342
 
9242
9343
  let recycleMap;
9344
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
9243
9345
  function compute(attrName, ui) {
9244
9346
  const data = ui.__, leafPaints = [];
9245
- let paints = data.__input[attrName], hasOpacityPixel;
9347
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
9246
9348
  if (!(paints instanceof Array))
9247
9349
  paints = [paints];
9248
9350
  recycleMap = PaintImage.recycleImage(attrName, data);
9249
9351
  for (let i = 0, len = paints.length, item; i < len; i++) {
9250
- item = getLeafPaint(attrName, paints[i], ui);
9251
- if (item)
9252
- leafPaints.push(item);
9352
+ (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
9253
9353
  }
9254
9354
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
9255
- if (leafPaints.length && leafPaints[0].image)
9256
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
9257
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
9355
+ if (leafPaints.length) {
9356
+ if (leafPaints.every(item => item.isTransparent)) {
9357
+ if (leafPaints.some(item => item.image))
9358
+ isAlphaPixel = true;
9359
+ isTransparent = true;
9360
+ }
9361
+ }
9362
+ if (attrName === 'fill') {
9363
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
9364
+ stintSet(data, '__isTransparentFill', isTransparent);
9365
+ }
9366
+ else {
9367
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
9368
+ stintSet(data, '__isTransparentStroke', isTransparent);
9369
+ }
9258
9370
  }
9259
9371
  function getLeafPaint(attrName, paint, ui) {
9260
9372
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
9261
9373
  return undefined;
9374
+ let data;
9262
9375
  const { boxBounds } = ui.__layout;
9263
9376
  switch (paint.type) {
9264
- case 'solid':
9265
- let { type, blendMode, color, opacity } = paint;
9266
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
9267
9377
  case 'image':
9268
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9378
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9379
+ break;
9269
9380
  case 'linear':
9270
- return PaintGradient.linearGradient(paint, boxBounds);
9381
+ data = PaintGradient.linearGradient(paint, boxBounds);
9382
+ break;
9271
9383
  case 'radial':
9272
- return PaintGradient.radialGradient(paint, boxBounds);
9384
+ data = PaintGradient.radialGradient(paint, boxBounds);
9385
+ break;
9273
9386
  case 'angular':
9274
- return PaintGradient.conicGradient(paint, boxBounds);
9387
+ data = PaintGradient.conicGradient(paint, boxBounds);
9388
+ break;
9389
+ case 'solid':
9390
+ const { type, color, opacity } = paint;
9391
+ data = { type, style: ColorConvert.string(color, opacity) };
9392
+ break;
9275
9393
  default:
9276
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
9394
+ if (paint.r !== undefined)
9395
+ data = { type: 'solid', style: ColorConvert.string(paint) };
9277
9396
  }
9397
+ if (data) {
9398
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
9399
+ data.isTransparent = true;
9400
+ if (paint.blendMode)
9401
+ data.blendMode = paint.blendMode;
9402
+ }
9403
+ return data;
9278
9404
  }
9279
9405
 
9280
9406
  const PaintModule = {
@@ -9340,12 +9466,10 @@ var LeaferUI = (function (exports) {
9340
9466
 
9341
9467
  const { get: get$2, translate } = MatrixHelper;
9342
9468
  const tempBox = new Bounds();
9343
- const tempPoint = {};
9344
9469
  const tempScaleData = {};
9470
+ const tempImage = {};
9345
9471
  function createData(leafPaint, image, paint, box) {
9346
- const { blendMode, changeful, sync } = paint;
9347
- if (blendMode)
9348
- leafPaint.blendMode = blendMode;
9472
+ const { changeful, sync } = paint;
9349
9473
  if (changeful)
9350
9474
  leafPaint.changeful = changeful;
9351
9475
  if (sync)
@@ -9353,38 +9477,38 @@ var LeaferUI = (function (exports) {
9353
9477
  leafPaint.data = getPatternData(paint, box, image);
9354
9478
  }
9355
9479
  function getPatternData(paint, box, image) {
9356
- let { width, height } = image;
9357
9480
  if (paint.padding)
9358
9481
  box = tempBox.set(box).shrink(paint.padding);
9359
9482
  if (paint.mode === 'strench')
9360
9483
  paint.mode = 'stretch';
9484
+ let { width, height } = image;
9361
9485
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
9362
9486
  const sameBox = box.width === width && box.height === height;
9363
9487
  const data = { mode };
9364
9488
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
9365
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
9366
- let x = 0, y = 0, scaleX, scaleY;
9489
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
9490
+ let scaleX, scaleY;
9367
9491
  if (!mode || mode === 'cover' || mode === 'fit') {
9368
9492
  if (!sameBox || rotation) {
9369
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
9370
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
9371
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
9493
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
9494
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
9495
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9372
9496
  }
9373
9497
  }
9374
- else if (scale || size) {
9375
- MathHelper.getScaleData(scale, size, image, tempScaleData);
9376
- scaleX = tempScaleData.scaleX;
9377
- scaleY = tempScaleData.scaleY;
9378
- }
9379
- if (align) {
9380
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
9381
- if (scaleX)
9382
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
9383
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
9384
- x += tempPoint.x, y += tempPoint.y;
9498
+ else {
9499
+ if (scale || size) {
9500
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
9501
+ scaleX = tempScaleData.scaleX;
9502
+ scaleY = tempScaleData.scaleY;
9503
+ }
9504
+ if (align) {
9505
+ if (scaleX)
9506
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
9507
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
9508
+ }
9385
9509
  }
9386
9510
  if (offset)
9387
- x += offset.x, y += offset.y;
9511
+ PointHelper.move(tempImage, offset);
9388
9512
  switch (mode) {
9389
9513
  case 'stretch':
9390
9514
  if (!sameBox)
@@ -9392,12 +9516,12 @@ var LeaferUI = (function (exports) {
9392
9516
  break;
9393
9517
  case 'normal':
9394
9518
  case 'clip':
9395
- if (x || y || scaleX || rotation)
9396
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
9519
+ if (tempImage.x || tempImage.y || scaleX || rotation)
9520
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9397
9521
  break;
9398
9522
  case 'repeat':
9399
9523
  if (!sameBox || scaleX || rotation)
9400
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
9524
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
9401
9525
  if (!repeat)
9402
9526
  data.repeat = 'repeat';
9403
9527
  break;
@@ -9405,7 +9529,7 @@ var LeaferUI = (function (exports) {
9405
9529
  case 'cover':
9406
9530
  default:
9407
9531
  if (scaleX)
9408
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
9532
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9409
9533
  }
9410
9534
  if (!data.transform) {
9411
9535
  if (box.x || box.y) {
@@ -9438,6 +9562,8 @@ var LeaferUI = (function (exports) {
9438
9562
  }
9439
9563
  else {
9440
9564
  leafPaint = { type: paint.type, image };
9565
+ if (image.hasAlphaPixel)
9566
+ leafPaint.isTransparent = true;
9441
9567
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
9442
9568
  }
9443
9569
  if (firstUse || image.loading)
@@ -9462,7 +9588,7 @@ var LeaferUI = (function (exports) {
9462
9588
  ignoreRender(ui, false);
9463
9589
  if (!ui.destroyed) {
9464
9590
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
9465
- if (image.hasOpacityPixel)
9591
+ if (image.hasAlphaPixel)
9466
9592
  ui.__layout.hitCanvasChanged = true;
9467
9593
  ui.forceUpdate('surface');
9468
9594
  }
@@ -9474,13 +9600,17 @@ var LeaferUI = (function (exports) {
9474
9600
  onLoadError(ui, event, error);
9475
9601
  leafPaint.loadId = null;
9476
9602
  });
9477
- if (ui.placeholderColor)
9478
- setTimeout(() => {
9479
- if (!(image.ready || image.isPlacehold)) {
9480
- image.isPlacehold = true;
9481
- ui.forceUpdate('surface');
9482
- }
9483
- }, 100);
9603
+ if (ui.placeholderColor) {
9604
+ if (!ui.placeholderDelay)
9605
+ image.isPlacehold = true;
9606
+ else
9607
+ setTimeout(() => {
9608
+ if (!image.ready) {
9609
+ image.isPlacehold = true;
9610
+ ui.forceUpdate('surface');
9611
+ }
9612
+ }, ui.placeholderDelay);
9613
+ }
9484
9614
  }
9485
9615
  return leafPaint;
9486
9616
  }
@@ -9635,7 +9765,7 @@ var LeaferUI = (function (exports) {
9635
9765
  }
9636
9766
  function drawImage(ui, canvas, paint, data) {
9637
9767
  canvas.save();
9638
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
9768
+ canvas.clipUI(ui);
9639
9769
  if (paint.blendMode)
9640
9770
  canvas.blendMode = paint.blendMode;
9641
9771
  if (data.opacity)
@@ -9686,32 +9816,33 @@ var LeaferUI = (function (exports) {
9686
9816
  repeatMode
9687
9817
  };
9688
9818
 
9689
- const { toPoint: toPoint$2 } = AroundHelper;
9819
+ const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
9690
9820
  const realFrom$2 = {};
9691
9821
  const realTo$2 = {};
9692
9822
  function linearGradient(paint, box) {
9693
- let { from, to, type, blendMode, opacity } = paint;
9823
+ let { from, to, type, opacity } = paint;
9694
9824
  toPoint$2(from || 'top', box, realFrom$2);
9695
9825
  toPoint$2(to || 'bottom', box, realTo$2);
9696
9826
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
9697
- applyStops(style, paint.stops, opacity);
9698
9827
  const data = { type, style };
9699
- if (blendMode)
9700
- data.blendMode = blendMode;
9828
+ applyStops(data, style, paint.stops, opacity);
9701
9829
  return data;
9702
9830
  }
9703
- function applyStops(gradient, stops, opacity) {
9831
+ function applyStops(data, gradient, stops, opacity) {
9704
9832
  if (stops) {
9705
- let stop;
9833
+ let stop, color, offset, isTransparent;
9706
9834
  for (let i = 0, len = stops.length; i < len; i++) {
9707
9835
  stop = stops[i];
9708
- if (typeof stop === 'string') {
9709
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
9710
- }
9711
- else {
9712
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
9713
- }
9836
+ if (typeof stop === 'string')
9837
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
9838
+ else
9839
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
9840
+ gradient.addColorStop(offset, color);
9841
+ if (!isTransparent && hasTransparent(color))
9842
+ isTransparent = true;
9714
9843
  }
9844
+ if (isTransparent)
9845
+ data.isTransparent = true;
9715
9846
  }
9716
9847
  }
9717
9848
 
@@ -9721,17 +9852,15 @@ var LeaferUI = (function (exports) {
9721
9852
  const realFrom$1 = {};
9722
9853
  const realTo$1 = {};
9723
9854
  function radialGradient(paint, box) {
9724
- let { from, to, type, opacity, blendMode, stretch } = paint;
9855
+ let { from, to, type, opacity, stretch } = paint;
9725
9856
  toPoint$1(from || 'center', box, realFrom$1);
9726
9857
  toPoint$1(to || 'bottom', box, realTo$1);
9727
9858
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
9728
- applyStops(style, paint.stops, opacity);
9729
9859
  const data = { type, style };
9860
+ applyStops(data, style, paint.stops, opacity);
9730
9861
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
9731
9862
  if (transform)
9732
9863
  data.transform = transform;
9733
- if (blendMode)
9734
- data.blendMode = blendMode;
9735
9864
  return data;
9736
9865
  }
9737
9866
  function getTransform(box, from, to, stretch, rotate90) {
@@ -9757,17 +9886,15 @@ var LeaferUI = (function (exports) {
9757
9886
  const realFrom = {};
9758
9887
  const realTo = {};
9759
9888
  function conicGradient(paint, box) {
9760
- let { from, to, type, opacity, blendMode, stretch } = paint;
9889
+ let { from, to, type, opacity, stretch } = paint;
9761
9890
  toPoint(from || 'center', box, realFrom);
9762
9891
  toPoint(to || 'bottom', box, realTo);
9763
9892
  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));
9764
- applyStops(style, paint.stops, opacity);
9765
9893
  const data = { type, style };
9894
+ applyStops(data, style, paint.stops, opacity);
9766
9895
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
9767
9896
  if (transform)
9768
9897
  data.transform = transform;
9769
- if (blendMode)
9770
- data.blendMode = blendMode;
9771
9898
  return data;
9772
9899
  }
9773
9900
 
@@ -9803,12 +9930,10 @@ var LeaferUI = (function (exports) {
9803
9930
  }
9804
9931
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9805
9932
  }
9806
- if (ui.__worldFlipped) {
9933
+ if (ui.__worldFlipped)
9807
9934
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9808
- }
9809
- else {
9935
+ else
9810
9936
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9811
- }
9812
9937
  if (end && index < end)
9813
9938
  other.clearWorld(copyBounds, true);
9814
9939
  });
@@ -9867,12 +9992,10 @@ var LeaferUI = (function (exports) {
9867
9992
  copyBounds = bounds;
9868
9993
  }
9869
9994
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
9870
- if (ui.__worldFlipped) {
9995
+ if (ui.__worldFlipped)
9871
9996
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
9872
- }
9873
- else {
9997
+ else
9874
9998
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
9875
- }
9876
9999
  if (end && index < end)
9877
10000
  other.clearWorld(copyBounds, true);
9878
10001
  });
@@ -10100,6 +10223,8 @@ var LeaferUI = (function (exports) {
10100
10223
  lastCharType = null;
10101
10224
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
10102
10225
  word = { data: [] }, row = { words: [] };
10226
+ if (__letterSpacing)
10227
+ content = [...content];
10103
10228
  for (let i = 0, len = content.length; i < len; i++) {
10104
10229
  char = content[i];
10105
10230
  if (char === '\n') {
@@ -10518,6 +10643,7 @@ var LeaferUI = (function (exports) {
10518
10643
  exports.AutoBounds = AutoBounds;
10519
10644
  exports.BezierHelper = BezierHelper;
10520
10645
  exports.Bounds = Bounds;
10646
+ exports.BoundsEvent = BoundsEvent;
10521
10647
  exports.BoundsHelper = BoundsHelper;
10522
10648
  exports.BoxData = BoxData;
10523
10649
  exports.BranchHelper = BranchHelper;
@@ -10664,7 +10790,7 @@ var LeaferUI = (function (exports) {
10664
10790
  exports.surfaceType = surfaceType;
10665
10791
  exports.tempBounds = tempBounds$1;
10666
10792
  exports.tempMatrix = tempMatrix;
10667
- exports.tempPoint = tempPoint$3;
10793
+ exports.tempPoint = tempPoint$2;
10668
10794
  exports.useCanvas = useCanvas;
10669
10795
  exports.useModule = useModule;
10670
10796
  exports.version = version;