@leafer-editor/worker 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.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$9.toInnerPoint(t, origin, tempPoint$4);
200
- M$9.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
197
+ M$9.toInnerPoint(t, origin, tempPoint$3);
198
+ M$9.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
201
199
  },
202
200
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
203
201
  M$9.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$9.toInnerPoint(t, origin, tempPoint$4);
219
- M$9.rotateOfInner(t, tempPoint$4, rotation);
216
+ M$9.toInnerPoint(t, origin, tempPoint$3);
217
+ M$9.rotateOfInner(t, tempPoint$3, rotation);
220
218
  },
221
219
  rotateOfInner(t, origin, rotation) {
222
220
  M$9.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$9.toInnerPoint(t, origin, tempPoint$4);
241
- M$9.skewOfInner(t, tempPoint$4, skewX, skewY);
238
+ M$9.toInnerPoint(t, origin, tempPoint$3);
239
+ M$9.skewOfInner(t, tempPoint$3, skewX, skewY);
242
240
  },
243
241
  skewOfInner(t, origin, skewX, skewY = 0) {
244
242
  M$9.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$4 } = 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$6 } = AroundHelper;
872
+ const AlignHelper = {
873
+ toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
874
+ toPoint$6(align, box, to, onlyBoxSize, content, onlyContentSize);
875
+ }
876
+ };
877
+
807
878
  const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$4 } = 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$4, bottom$3, boundsRight, boundsBottom;
812
883
  const point$1 = {};
813
- const toPoint$6 = {};
884
+ const toPoint$5 = {};
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$1.x = t.x;
921
993
  point$1.y = t.y;
922
- toOuterPoint$2(matrix, point$1, toPoint$6);
923
- setPoint$5(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
994
+ toOuterPoint$2(matrix, point$1, toPoint$5);
995
+ setPoint$5(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
924
996
  point$1.x = t.x + t.width;
925
- toOuterPoint$2(matrix, point$1, toPoint$6);
926
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
997
+ toOuterPoint$2(matrix, point$1, toPoint$5);
998
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
927
999
  point$1.y = t.y + t.height;
928
- toOuterPoint$2(matrix, point$1, toPoint$6);
929
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
1000
+ toOuterPoint$2(matrix, point$1, toPoint$5);
1001
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
930
1002
  point$1.x = t.x;
931
- toOuterPoint$2(matrix, point$1, toPoint$6);
932
- addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
1003
+ toOuterPoint$2(matrix, point$1, toPoint$5);
1004
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
933
1005
  toBounds$4(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$5 } = AroundHelper;
1312
- const AlignHelper = {
1313
- toPoint(align, contentBounds, bounds, to, onlySize) {
1314
- toPoint$5(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$h = 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;
@@ -2388,7 +2412,7 @@ var LeaferUI = (function (exports) {
2388
2412
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2389
2413
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2390
2414
  const { M: M$8, L: L$9, C: C$7, Q: Q$7, Z: Z$7 } = PathCommandMap;
2391
- const tempPoint$2 = {};
2415
+ const tempPoint$1 = {};
2392
2416
  const BezierHelper = {
2393
2417
  points(data, originPoints, curve, close) {
2394
2418
  let points = toNumberPoints$1(originPoints);
@@ -2410,6 +2434,8 @@ var LeaferUI = (function (exports) {
2410
2434
  cY = points[i + 3];
2411
2435
  ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
2412
2436
  cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
2437
+ if (!ba && !cb)
2438
+ continue;
2413
2439
  d = ba + cb;
2414
2440
  ba = (t * ba) / d;
2415
2441
  cb = (t * cb) / d;
@@ -2579,8 +2605,8 @@ var LeaferUI = (function (exports) {
2579
2605
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$4(pointBounds, fromX, fromY);
2580
2606
  addPoint$2(pointBounds, toX, toY);
2581
2607
  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$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2608
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2609
+ addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2584
2610
  }
2585
2611
  },
2586
2612
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2592,7 +2618,11 @@ var LeaferUI = (function (exports) {
2592
2618
  const point = {};
2593
2619
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
2594
2620
  return point;
2595
- }
2621
+ },
2622
+ getDerivative(t, fromV, v1, v2, toV) {
2623
+ const o = 1 - t;
2624
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2625
+ },
2596
2626
  };
2597
2627
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
2598
2628
 
@@ -3385,7 +3415,7 @@ var LeaferUI = (function (exports) {
3385
3415
  }
3386
3416
 
3387
3417
  const FileHelper = {
3388
- opacityTypes: ['png', 'webp', 'svg'],
3418
+ alphaPixelTypes: ['png', 'webp', 'svg'],
3389
3419
  upperCaseTypeMap: {},
3390
3420
  mineType(type) {
3391
3421
  if (!type || type.startsWith('image'))
@@ -3412,7 +3442,7 @@ var LeaferUI = (function (exports) {
3412
3442
  }
3413
3443
  };
3414
3444
  const F$2 = FileHelper;
3415
- F$2.opacityTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3445
+ F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3416
3446
 
3417
3447
  const debug$c = Debug.get('TaskProcessor');
3418
3448
  class TaskItem {
@@ -3729,8 +3759,8 @@ var LeaferUI = (function (exports) {
3729
3759
  list.length = 0;
3730
3760
  }
3731
3761
  },
3732
- hasOpacityPixel(config) {
3733
- return FileHelper.opacityTypes.some(item => I$1.isFormat(item, config));
3762
+ hasAlphaPixel(config) {
3763
+ return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
3734
3764
  },
3735
3765
  isFormat(format, config) {
3736
3766
  if (config.format === format)
@@ -3768,13 +3798,16 @@ var LeaferUI = (function (exports) {
3768
3798
  this.setView(view.config ? view.view : view);
3769
3799
  }
3770
3800
  ImageManager.isFormat('svg', config) && (this.isSVG = true);
3771
- ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
3801
+ ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3772
3802
  }
3773
3803
  load(onSuccess, onError) {
3774
3804
  if (!this.loading) {
3775
3805
  this.loading = true;
3806
+ let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
3807
+ if (onProgress)
3808
+ loadImage = loadImageWithProgress;
3776
3809
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
3777
- return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
3810
+ return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
3778
3811
  this.error = e;
3779
3812
  this.onComplete(false);
3780
3813
  });
@@ -3799,6 +3832,9 @@ var LeaferUI = (function (exports) {
3799
3832
  this.view = img;
3800
3833
  this.onComplete(true);
3801
3834
  }
3835
+ onProgress(progress) {
3836
+ this.progress = progress;
3837
+ }
3802
3838
  onComplete(isSuccess) {
3803
3839
  let odd;
3804
3840
  this.waitComplete.forEach((item, index) => {
@@ -4264,13 +4300,20 @@ var LeaferUI = (function (exports) {
4264
4300
  if (leaf.isBranch) {
4265
4301
  const { children } = leaf;
4266
4302
  for (let i = 0, len = children.length; i < len; i++) {
4267
- updateAllWorldOpacity$1(children[i]);
4303
+ updateAllWorldOpacity(children[i]);
4268
4304
  }
4269
4305
  }
4270
4306
  },
4271
- updateAllChange(leaf) {
4272
- updateAllWorldOpacity$1(leaf);
4307
+ updateChange(leaf) {
4308
+ const layout = leaf.__layout;
4309
+ if (layout.stateStyleChanged)
4310
+ leaf.updateState();
4311
+ if (layout.opacityChanged)
4312
+ updateAllWorldOpacity(leaf);
4273
4313
  leaf.__updateChange();
4314
+ },
4315
+ updateAllChange(leaf) {
4316
+ updateChange$1(leaf);
4274
4317
  if (leaf.isBranch) {
4275
4318
  const { children } = leaf;
4276
4319
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4406,7 +4449,7 @@ var LeaferUI = (function (exports) {
4406
4449
  }
4407
4450
  };
4408
4451
  const L$3 = LeafHelper;
4409
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
4452
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1 } = L$3;
4410
4453
  function getTempLocal(t, world) {
4411
4454
  t.__layout.update();
4412
4455
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -4443,7 +4486,7 @@ var LeaferUI = (function (exports) {
4443
4486
  }
4444
4487
  };
4445
4488
 
4446
- const { updateBounds: updateBounds$2 } = LeafHelper;
4489
+ const { updateBounds: updateBounds$3 } = LeafHelper;
4447
4490
  const BranchHelper = {
4448
4491
  sort(a, b) {
4449
4492
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
@@ -4505,11 +4548,11 @@ var LeaferUI = (function (exports) {
4505
4548
  branch = branchStack[i];
4506
4549
  children = branch.children;
4507
4550
  for (let j = 0, len = children.length; j < len; j++) {
4508
- updateBounds$2(children[j]);
4551
+ updateBounds$3(children[j]);
4509
4552
  }
4510
4553
  if (exclude && exclude === branch)
4511
4554
  continue;
4512
- updateBounds$2(branch);
4555
+ updateBounds$3(branch);
4513
4556
  }
4514
4557
  }
4515
4558
  };
@@ -4527,7 +4570,7 @@ var LeaferUI = (function (exports) {
4527
4570
  }
4528
4571
  };
4529
4572
 
4530
- const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4573
+ const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2 } = LeafHelper;
4531
4574
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$9 } = BoundsHelper;
4532
4575
  const localContent = '_localContentBounds';
4533
4576
  const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
@@ -4571,7 +4614,9 @@ var LeaferUI = (function (exports) {
4571
4614
  this._localRenderBounds = local;
4572
4615
  }
4573
4616
  update() {
4574
- const { leafer } = this.leaf;
4617
+ const { leaf } = this, { leafer } = leaf;
4618
+ if (leaf.isApp)
4619
+ return updateBounds$2(leaf);
4575
4620
  if (leafer) {
4576
4621
  if (leafer.ready)
4577
4622
  leafer.watcher.changed && leafer.layouter.layout();
@@ -4579,7 +4624,7 @@ var LeaferUI = (function (exports) {
4579
4624
  leafer.start();
4580
4625
  }
4581
4626
  else {
4582
- let root = this.leaf;
4627
+ let root = leaf;
4583
4628
  while (root.parent && !root.parent.leafer) {
4584
4629
  root = root.parent;
4585
4630
  }
@@ -4801,7 +4846,7 @@ var LeaferUI = (function (exports) {
4801
4846
  }
4802
4847
  childrenSortChange() {
4803
4848
  if (!this.childrenSortChanged) {
4804
- this.childrenSortChanged = true;
4849
+ this.childrenSortChanged = this.affectChildrenSort = true;
4805
4850
  this.leaf.forceUpdate('surface');
4806
4851
  }
4807
4852
  }
@@ -4868,6 +4913,40 @@ var LeaferUI = (function (exports) {
4868
4913
  ImageEvent.LOADED = 'image.loaded';
4869
4914
  ImageEvent.ERROR = 'image.error';
4870
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
+
4871
4950
  class ResizeEvent extends Event {
4872
4951
  get bigger() {
4873
4952
  if (!this.old)
@@ -4964,9 +5043,12 @@ var LeaferUI = (function (exports) {
4964
5043
  set event(map) { this.on(map); }
4965
5044
  on(type, listener, options) {
4966
5045
  if (!listener) {
4967
- let event, map = type;
4968
- for (let key in map)
4969
- 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);
4970
5052
  return;
4971
5053
  }
4972
5054
  let capture, once;
@@ -4996,6 +5078,8 @@ var LeaferUI = (function (exports) {
4996
5078
  else {
4997
5079
  map[type] = [item];
4998
5080
  }
5081
+ if (boundsEventMap[type])
5082
+ BoundsEvent.checkHas(this, type, 'on');
4999
5083
  }
5000
5084
  });
5001
5085
  }
@@ -5017,6 +5101,8 @@ var LeaferUI = (function (exports) {
5017
5101
  events.splice(index, 1);
5018
5102
  if (!events.length)
5019
5103
  delete map[type];
5104
+ if (boundsEventMap[type])
5105
+ BoundsEvent.checkHas(this, type, 'off');
5020
5106
  }
5021
5107
  }
5022
5108
  });
@@ -5036,19 +5122,31 @@ var LeaferUI = (function (exports) {
5036
5122
  }
5037
5123
  }
5038
5124
  on_(type, listener, bind, options) {
5039
- if (bind)
5040
- listener = listener.bind(bind);
5041
- 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);
5042
5129
  return { type, current: this, listener, options };
5043
5130
  }
5044
5131
  off_(id) {
5045
5132
  if (!id)
5046
5133
  return;
5047
5134
  const list = id instanceof Array ? id : [id];
5048
- 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
+ });
5049
5141
  list.length = 0;
5050
5142
  }
5051
- 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;
5052
5150
  this.on(type, listener, { once: true, capture });
5053
5151
  }
5054
5152
  emit(type, event, capture) {
@@ -5160,7 +5258,7 @@ var LeaferUI = (function (exports) {
5160
5258
  };
5161
5259
 
5162
5260
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5163
- const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = AroundHelper;
5261
+ const { toPoint: toPoint$4, tempPoint } = AroundHelper;
5164
5262
  const LeafMatrix = {
5165
5263
  __updateWorldMatrix() {
5166
5264
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
@@ -5169,19 +5267,19 @@ var LeaferUI = (function (exports) {
5169
5267
  if (this.__local) {
5170
5268
  const layout = this.__layout, local = this.__local, data = this.__;
5171
5269
  if (layout.affectScaleOrRotation) {
5172
- if (layout.scaleChanged || layout.rotationChanged) {
5270
+ if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5173
5271
  setLayout(local, data, null, null, layout.affectRotation);
5174
- layout.scaleChanged = layout.rotationChanged = false;
5272
+ layout.scaleChanged = layout.rotationChanged = undefined;
5175
5273
  }
5176
5274
  }
5177
5275
  local.e = data.x + data.offsetX;
5178
5276
  local.f = data.y + data.offsetY;
5179
5277
  if (data.around || data.origin) {
5180
- toPoint$4(data.around || data.origin, layout.boxBounds, tempPoint$1);
5181
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
5278
+ toPoint$4(data.around || data.origin, layout.boxBounds, tempPoint);
5279
+ translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
5182
5280
  }
5183
5281
  }
5184
- this.__layout.matrixChanged = false;
5282
+ this.__layout.matrixChanged = undefined;
5185
5283
  }
5186
5284
  };
5187
5285
 
@@ -5191,11 +5289,17 @@ var LeaferUI = (function (exports) {
5191
5289
  const { toBounds: toBounds$2 } = PathBounds;
5192
5290
  const LeafBounds = {
5193
5291
  __updateWorldBounds() {
5194
- toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
5195
- if (this.__layout.resized) {
5196
- this.__onUpdateSize();
5197
- 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;
5198
5300
  }
5301
+ if (this.__hasWorldEvent)
5302
+ BoundsEvent.emitWorld(this);
5199
5303
  },
5200
5304
  __updateLocalBounds() {
5201
5305
  const layout = this.__layout;
@@ -5204,12 +5308,12 @@ var LeaferUI = (function (exports) {
5204
5308
  this.__updatePath();
5205
5309
  this.__updateRenderPath();
5206
5310
  this.__updateBoxBounds();
5207
- layout.resized = true;
5311
+ layout.resized = 'inner';
5208
5312
  }
5209
5313
  if (layout.localBoxChanged) {
5210
5314
  if (this.__local)
5211
5315
  this.__updateLocalBoxBounds();
5212
- layout.localBoxChanged = false;
5316
+ layout.localBoxChanged = undefined;
5213
5317
  if (layout.strokeSpread)
5214
5318
  layout.strokeChanged = true;
5215
5319
  if (layout.renderSpread)
@@ -5217,7 +5321,7 @@ var LeaferUI = (function (exports) {
5217
5321
  if (this.parent)
5218
5322
  this.parent.__layout.boxChange();
5219
5323
  }
5220
- layout.boxChanged = false;
5324
+ layout.boxChanged = undefined;
5221
5325
  if (layout.strokeChanged) {
5222
5326
  layout.strokeSpread = this.__updateStrokeSpread();
5223
5327
  if (layout.strokeSpread) {
@@ -5229,12 +5333,12 @@ var LeaferUI = (function (exports) {
5229
5333
  else {
5230
5334
  layout.spreadStrokeCancel();
5231
5335
  }
5232
- layout.strokeChanged = false;
5336
+ layout.strokeChanged = undefined;
5233
5337
  if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
5234
5338
  layout.renderChanged = true;
5235
5339
  if (this.parent)
5236
5340
  this.parent.__layout.strokeChange();
5237
- layout.resized = true;
5341
+ layout.resized = 'inner';
5238
5342
  }
5239
5343
  if (layout.renderChanged) {
5240
5344
  layout.renderSpread = this.__updateRenderSpread();
@@ -5247,11 +5351,12 @@ var LeaferUI = (function (exports) {
5247
5351
  else {
5248
5352
  layout.spreadRenderCancel();
5249
5353
  }
5250
- layout.renderChanged = false;
5354
+ layout.renderChanged = undefined;
5251
5355
  if (this.parent)
5252
5356
  this.parent.__layout.renderChange();
5253
5357
  }
5254
- layout.boundsChanged = false;
5358
+ layout.resized || (layout.resized = 'local');
5359
+ layout.boundsChanged = undefined;
5255
5360
  },
5256
5361
  __updateLocalBoxBounds() {
5257
5362
  if (this.__hasMotionPath)
@@ -5791,7 +5896,7 @@ var LeaferUI = (function (exports) {
5791
5896
  off(_type, _listener, _options) { }
5792
5897
  on_(_type, _listener, _bind, _options) { return undefined; }
5793
5898
  off_(_id) { }
5794
- once(_type, _listener, _capture) { }
5899
+ once(_type, _listener, _captureOrBind, _capture) { }
5795
5900
  emit(_type, _event, _capture) { }
5796
5901
  emitEvent(_event, _capture) { }
5797
5902
  hasEvent(_type, _capture) { return false; }
@@ -6128,7 +6233,7 @@ var LeaferUI = (function (exports) {
6128
6233
  }
6129
6234
  }
6130
6235
 
6131
- const version = "1.6.1";
6236
+ const version = "1.6.3";
6132
6237
 
6133
6238
  class LeaferCanvas extends LeaferCanvasBase {
6134
6239
  get allowBackgroundColor() { return true; }
@@ -6287,17 +6392,15 @@ var LeaferUI = (function (exports) {
6287
6392
  this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
6288
6393
  this.__updatedList = new LeafList();
6289
6394
  this.totalTimes++;
6290
- this.changed = false;
6291
- this.hasVisible = false;
6292
- this.hasRemove = false;
6293
- this.hasAdd = false;
6395
+ this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
6294
6396
  }
6295
6397
  __listenEvents() {
6296
- const { target } = this;
6297
6398
  this.__eventIds = [
6298
- target.on_(PropertyEvent.CHANGE, this.__onAttrChange, this),
6299
- target.on_([ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this),
6300
- target.on_(WatchEvent.REQUEST, this.__onRquestData, this)
6399
+ this.target.on_([
6400
+ [PropertyEvent.CHANGE, this.__onAttrChange, this],
6401
+ [[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
6402
+ [WatchEvent.REQUEST, this.__onRquestData, this]
6403
+ ])
6301
6404
  ];
6302
6405
  }
6303
6406
  __removeListenEvents() {
@@ -6307,13 +6410,12 @@ var LeaferUI = (function (exports) {
6307
6410
  if (this.target) {
6308
6411
  this.stop();
6309
6412
  this.__removeListenEvents();
6310
- this.target = null;
6311
- this.__updatedList = null;
6413
+ this.target = this.__updatedList = null;
6312
6414
  }
6313
6415
  }
6314
6416
  }
6315
6417
 
6316
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6418
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
6317
6419
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6318
6420
  function updateMatrix$1(updateList, levelList) {
6319
6421
  let layout;
@@ -6356,15 +6458,7 @@ var LeaferUI = (function (exports) {
6356
6458
  });
6357
6459
  }
6358
6460
  function updateChange(updateList) {
6359
- let layout;
6360
- updateList.list.forEach(leaf => {
6361
- layout = leaf.__layout;
6362
- if (layout.opacityChanged)
6363
- updateAllWorldOpacity(leaf);
6364
- if (layout.stateStyleChanged)
6365
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
6366
- leaf.__updateChange();
6367
- });
6461
+ updateList.list.forEach(updateOneChange);
6368
6462
  }
6369
6463
 
6370
6464
  const { worldBounds: worldBounds$1 } = LeafBoundsHelper;
@@ -6421,7 +6515,7 @@ var LeaferUI = (function (exports) {
6421
6515
  this.disabled = true;
6422
6516
  }
6423
6517
  layout() {
6424
- if (!this.running)
6518
+ if (this.layouting || !this.running)
6425
6519
  return;
6426
6520
  const { target } = this;
6427
6521
  this.times = 0;
@@ -6504,12 +6598,10 @@ var LeaferUI = (function (exports) {
6504
6598
  }
6505
6599
  static fullLayout(target) {
6506
6600
  updateAllMatrix(target, true);
6507
- if (target.isBranch) {
6601
+ if (target.isBranch)
6508
6602
  BranchHelper.updateBounds(target);
6509
- }
6510
- else {
6603
+ else
6511
6604
  LeafHelper.updateBounds(target);
6512
- }
6513
6605
  updateAllChange(target);
6514
6606
  }
6515
6607
  addExtra(leaf) {
@@ -6532,11 +6624,12 @@ var LeaferUI = (function (exports) {
6532
6624
  this.__updatedList = event.data.updatedList;
6533
6625
  }
6534
6626
  __listenEvents() {
6535
- const { target } = this;
6536
6627
  this.__eventIds = [
6537
- target.on_(LayoutEvent.REQUEST, this.layout, this),
6538
- target.on_(LayoutEvent.AGAIN, this.layoutAgain, this),
6539
- target.on_(WatchEvent.DATA, this.__onReceiveWatchData, this)
6628
+ this.target.on_([
6629
+ [LayoutEvent.REQUEST, this.layout, this],
6630
+ [LayoutEvent.AGAIN, this.layoutAgain, this],
6631
+ [WatchEvent.DATA, this.__onReceiveWatchData, this]
6632
+ ])
6540
6633
  ];
6541
6634
  }
6542
6635
  __removeListenEvents() {
@@ -6767,12 +6860,13 @@ var LeaferUI = (function (exports) {
6767
6860
  this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
6768
6861
  }
6769
6862
  __listenEvents() {
6770
- const { target } = this;
6771
6863
  this.__eventIds = [
6772
- target.on_(RenderEvent.REQUEST, this.update, this),
6773
- target.on_(LayoutEvent.END, this.__onLayoutEnd, this),
6774
- target.on_(RenderEvent.AGAIN, this.renderAgain, this),
6775
- target.on_(ResizeEvent.RESIZE, this.__onResize, this)
6864
+ this.target.on_([
6865
+ [RenderEvent.REQUEST, this.update, this],
6866
+ [LayoutEvent.END, this.__onLayoutEnd, this],
6867
+ [RenderEvent.AGAIN, this.renderAgain, this],
6868
+ [ResizeEvent.RESIZE, this.__onResize, this]
6869
+ ])
6776
6870
  ];
6777
6871
  }
6778
6872
  __removeListenEvents() {
@@ -6988,8 +7082,32 @@ var LeaferUI = (function (exports) {
6988
7082
  };
6989
7083
  }
6990
7084
 
7085
+ function hasTransparent$3(color) {
7086
+ if (!color || color.length === 7 || color.length === 4)
7087
+ return false;
7088
+ if (color === 'transparent')
7089
+ return true;
7090
+ const first = color[0];
7091
+ if (first === '#') {
7092
+ switch (color.length) {
7093
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
7094
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
7095
+ }
7096
+ }
7097
+ else if (first === 'r' || first === 'h') {
7098
+ if (color[3] === 'a') {
7099
+ const i = color.lastIndexOf(',');
7100
+ if (i > -1)
7101
+ return parseFloat(color.slice(i + 1)) < 1;
7102
+ }
7103
+ }
7104
+ return false;
7105
+ }
7106
+
6991
7107
  const TextConvert = {};
6992
- const ColorConvert = {};
7108
+ const ColorConvert = {
7109
+ hasTransparent: hasTransparent$3
7110
+ };
6993
7111
  const UnitConvert = {
6994
7112
  number(value, percentRefer) {
6995
7113
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -7015,6 +7133,7 @@ var LeaferUI = (function (exports) {
7015
7133
  };
7016
7134
 
7017
7135
  const { parse, objectToCanvasData } = PathConvert;
7136
+ const { stintSet: stintSet$2 } = DataHelper, { hasTransparent: hasTransparent$2 } = ColorConvert;
7018
7137
  const emptyPaint = {};
7019
7138
  const debug$5 = Debug.get('UIData');
7020
7139
  class UIData extends LeafData {
@@ -7073,38 +7192,22 @@ var LeaferUI = (function (exports) {
7073
7192
  if (this.__naturalWidth)
7074
7193
  this.__removeNaturalSize();
7075
7194
  if (typeof value === 'string' || !value) {
7076
- if (this.__isFills) {
7077
- this.__removeInput('fill');
7078
- PaintImage.recycleImage('fill', this);
7079
- this.__isFills = false;
7080
- this.__pixelFill && (this.__pixelFill = false);
7081
- }
7195
+ stintSet$2(this, '__isTransparentFill', hasTransparent$2(value));
7196
+ this.__isFills && this.__removePaint('fill', true);
7082
7197
  this._fill = value;
7083
7198
  }
7084
7199
  else if (typeof value === 'object') {
7085
- this.__setInput('fill', value);
7086
- const layout = this.__leaf.__layout;
7087
- layout.boxChanged || layout.boxChange();
7088
- this.__isFills = true;
7089
- this._fill || (this._fill = emptyPaint);
7200
+ this.__setPaint('fill', value);
7090
7201
  }
7091
7202
  }
7092
7203
  setStroke(value) {
7093
7204
  if (typeof value === 'string' || !value) {
7094
- if (this.__isStrokes) {
7095
- this.__removeInput('stroke');
7096
- PaintImage.recycleImage('stroke', this);
7097
- this.__isStrokes = false;
7098
- this.__pixelStroke && (this.__pixelStroke = false);
7099
- }
7205
+ stintSet$2(this, '__isTransparentStroke', hasTransparent$2(value));
7206
+ this.__isStrokes && this.__removePaint('stroke', true);
7100
7207
  this._stroke = value;
7101
7208
  }
7102
7209
  else if (typeof value === 'object') {
7103
- this.__setInput('stroke', value);
7104
- const layout = this.__leaf.__layout;
7105
- layout.boxChanged || layout.boxChange();
7106
- this.__isStrokes = true;
7107
- this._stroke || (this._stroke = emptyPaint);
7210
+ this.__setPaint('stroke', value);
7108
7211
  }
7109
7212
  }
7110
7213
  setPath(value) {
@@ -7134,7 +7237,34 @@ var LeaferUI = (function (exports) {
7134
7237
  Paint.compute('fill', this.__leaf);
7135
7238
  if (stroke)
7136
7239
  Paint.compute('stroke', this.__leaf);
7137
- this.__needComputePaint = false;
7240
+ this.__needComputePaint = undefined;
7241
+ }
7242
+ __setPaint(attrName, value) {
7243
+ this.__setInput(attrName, value);
7244
+ const layout = this.__leaf.__layout;
7245
+ layout.boxChanged || layout.boxChange();
7246
+ if (value instanceof Array && !value.length) {
7247
+ this.__removePaint(attrName);
7248
+ }
7249
+ else {
7250
+ if (attrName === 'fill')
7251
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
7252
+ else
7253
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
7254
+ }
7255
+ }
7256
+ __removePaint(attrName, removeInput) {
7257
+ if (removeInput)
7258
+ this.__removeInput(attrName);
7259
+ PaintImage.recycleImage(attrName, this);
7260
+ if (attrName === 'fill') {
7261
+ stintSet$2(this, '__isAlphaPixelFill', undefined);
7262
+ this._fill = this.__isFills = undefined;
7263
+ }
7264
+ else {
7265
+ stintSet$2(this, '__isAlphaPixelStroke', undefined);
7266
+ this._stroke = this.__isStrokes = undefined;
7267
+ }
7138
7268
  }
7139
7269
  }
7140
7270
  function setArray(data, key, value) {
@@ -7142,10 +7272,10 @@ var LeaferUI = (function (exports) {
7142
7272
  if (value instanceof Array) {
7143
7273
  if (value.some((item) => item.visible === false))
7144
7274
  value = value.filter((item) => item.visible !== false);
7145
- value.length || (value = null);
7275
+ value.length || (value = undefined);
7146
7276
  }
7147
7277
  else
7148
- value = value && value.visible !== false ? [value] : null;
7278
+ value = value && value.visible !== false ? [value] : undefined;
7149
7279
  data['_' + key] = value;
7150
7280
  }
7151
7281
 
@@ -7209,13 +7339,11 @@ var LeaferUI = (function (exports) {
7209
7339
  setFontWeight(value) {
7210
7340
  if (typeof value === 'string') {
7211
7341
  this.__setInput('fontWeight', value);
7212
- this._fontWeight = fontWeightMap[value] || 400;
7213
- }
7214
- else {
7215
- if (this.__input)
7216
- this.__removeInput('fontWeight');
7217
- this._fontWeight = value;
7342
+ value = fontWeightMap[value] || 400;
7218
7343
  }
7344
+ else if (this.__input)
7345
+ this.__removeInput('fontWeight');
7346
+ this._fontWeight = value;
7219
7347
  }
7220
7348
  setBoxStyle(value) {
7221
7349
  let t = this.__leaf, box = t.__box;
@@ -7250,8 +7378,6 @@ var LeaferUI = (function (exports) {
7250
7378
  this._url = value;
7251
7379
  }
7252
7380
  __setImageFill(value) {
7253
- if (this.__leaf.image)
7254
- this.__leaf.image = null;
7255
7381
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
7256
7382
  }
7257
7383
  __getData() {
@@ -7317,21 +7443,19 @@ var LeaferUI = (function (exports) {
7317
7443
  }
7318
7444
  };
7319
7445
 
7446
+ const { stintSet: stintSet$1 } = DataHelper;
7320
7447
  const UIRender = {
7321
7448
  __updateChange() {
7322
- const data = this.__, w = this.__world;
7449
+ const data = this.__;
7323
7450
  if (data.__useEffect) {
7324
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7325
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7451
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7452
+ 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')));
7453
+ data.__useEffect = !!(shadow || otherEffect);
7326
7454
  }
7327
- const half = data.__hasHalf;
7328
- w.half !== half && (w.half = half);
7455
+ stintSet$1(this.__world, 'half', data.__hasHalf);
7456
+ stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7329
7457
  data.__checkSingle();
7330
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7331
- if (complex)
7332
- data.__complex = true;
7333
- else
7334
- data.__complex && (data.__complex = false);
7458
+ stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7335
7459
  },
7336
7460
  __drawFast(canvas, options) {
7337
7461
  drawFast(this, canvas, options);
@@ -7341,21 +7465,23 @@ var LeaferUI = (function (exports) {
7341
7465
  if (data.__complex) {
7342
7466
  if (data.__needComputePaint)
7343
7467
  data.__computePaint();
7344
- const { fill, stroke, __drawAfterFill } = data;
7468
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
7345
7469
  this.__drawRenderPath(canvas);
7346
- if (data.__useEffect) {
7470
+ if (data.__useEffect && !__isFastShadow) {
7347
7471
  const shape = Paint.shape(this, canvas, options);
7348
7472
  this.__nowWorld = this.__getNowWorld(options);
7349
7473
  const { shadow, innerShadow, filter } = data;
7350
7474
  if (shadow)
7351
7475
  Effect.shadow(this, canvas, shape);
7476
+ if (__fillAfterStroke)
7477
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7352
7478
  if (fill)
7353
7479
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7354
7480
  if (__drawAfterFill)
7355
7481
  this.__drawAfterFill(canvas, options);
7356
7482
  if (innerShadow)
7357
7483
  Effect.innerShadow(this, canvas, shape);
7358
- if (stroke)
7484
+ if (stroke && !__fillAfterStroke)
7359
7485
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7360
7486
  if (filter)
7361
7487
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -7364,21 +7490,27 @@ var LeaferUI = (function (exports) {
7364
7490
  shape.canvas.recycle();
7365
7491
  }
7366
7492
  else {
7493
+ if (__fillAfterStroke)
7494
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7495
+ if (__isFastShadow) {
7496
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
7497
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
7498
+ }
7367
7499
  if (fill)
7368
7500
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7501
+ if (__isFastShadow)
7502
+ canvas.restore();
7369
7503
  if (__drawAfterFill)
7370
7504
  this.__drawAfterFill(canvas, options);
7371
- if (stroke)
7505
+ if (stroke && !__fillAfterStroke)
7372
7506
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
7373
7507
  }
7374
7508
  }
7375
7509
  else {
7376
- if (data.__pathInputed) {
7510
+ if (data.__pathInputed)
7377
7511
  drawFast(this, canvas, options);
7378
- }
7379
- else {
7512
+ else
7380
7513
  this.__drawFast(canvas, options);
7381
- }
7382
7514
  }
7383
7515
  },
7384
7516
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -7387,11 +7519,11 @@ var LeaferUI = (function (exports) {
7387
7519
  const { fill, stroke } = this.__;
7388
7520
  this.__drawRenderPath(canvas);
7389
7521
  if (fill && !ignoreFill)
7390
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7522
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7391
7523
  if (this.__.__isCanvas)
7392
7524
  this.__drawAfterFill(canvas, options);
7393
7525
  if (stroke && !ignoreStroke)
7394
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7526
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7395
7527
  }
7396
7528
  },
7397
7529
  __drawAfterFill(canvas, options) {
@@ -7406,13 +7538,15 @@ var LeaferUI = (function (exports) {
7406
7538
  }
7407
7539
  };
7408
7540
  function drawFast(ui, canvas, options) {
7409
- const { fill, stroke, __drawAfterFill } = ui.__;
7541
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
7410
7542
  ui.__drawRenderPath(canvas);
7543
+ if (__fillAfterStroke)
7544
+ Paint.stroke(stroke, ui, canvas);
7411
7545
  if (fill)
7412
7546
  Paint.fill(fill, ui, canvas);
7413
7547
  if (__drawAfterFill)
7414
7548
  ui.__drawAfterFill(canvas, options);
7415
- if (stroke)
7549
+ if (stroke && !__fillAfterStroke)
7416
7550
  Paint.stroke(stroke, ui, canvas);
7417
7551
  }
7418
7552
 
@@ -7542,6 +7676,9 @@ var LeaferUI = (function (exports) {
7542
7676
  else
7543
7677
  drawer.rect(x, y, width, height);
7544
7678
  }
7679
+ drawImagePlaceholder(canvas, _image) {
7680
+ Paint.fill(this.__.placeholderColor, this, canvas);
7681
+ }
7545
7682
  animate(_keyframe, _options, _type, _isTemp) {
7546
7683
  return Plugin.need('animate');
7547
7684
  }
@@ -7778,6 +7915,12 @@ var LeaferUI = (function (exports) {
7778
7915
  __decorate([
7779
7916
  effectType()
7780
7917
  ], exports.UI.prototype, "filter", void 0);
7918
+ __decorate([
7919
+ surfaceType()
7920
+ ], exports.UI.prototype, "placeholderColor", void 0);
7921
+ __decorate([
7922
+ dataType(100)
7923
+ ], exports.UI.prototype, "placeholderDelay", void 0);
7781
7924
  __decorate([
7782
7925
  dataType({})
7783
7926
  ], exports.UI.prototype, "data", void 0);
@@ -8179,15 +8322,20 @@ var LeaferUI = (function (exports) {
8179
8322
  }
8180
8323
  __listenEvents() {
8181
8324
  const runId = Run.start('FirstCreate ' + this.innerName);
8182
- this.once(LeaferEvent.START, () => Run.end(runId));
8183
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
8184
- this.once(RenderEvent.START, () => this.__onCreated());
8185
- this.once(RenderEvent.END, () => this.__onViewReady());
8186
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8325
+ this.once([
8326
+ [LeaferEvent.START, () => Run.end(runId)],
8327
+ [LayoutEvent.START, this.updateLazyBounds, this],
8328
+ [RenderEvent.START, this.__onCreated, this],
8329
+ [RenderEvent.END, this.__onViewReady, this]
8330
+ ]);
8331
+ this.__eventIds.push(this.on_([
8332
+ [WatchEvent.DATA, this.__onWatchData, this],
8333
+ [LayoutEvent.END, this.__onLayoutEnd, this],
8334
+ [RenderEvent.NEXT, this.__onNextRender, this]
8335
+ ]));
8187
8336
  }
8188
8337
  __removeListenEvents() {
8189
8338
  this.off_(this.__eventIds);
8190
- this.__eventIds.length = 0;
8191
8339
  }
8192
8340
  destroy(sync) {
8193
8341
  const doDestory = () => {
@@ -8295,13 +8443,13 @@ var LeaferUI = (function (exports) {
8295
8443
  super.__updateRenderBounds();
8296
8444
  copy$6(childrenRenderBounds, renderBounds);
8297
8445
  this.__updateRectRenderBounds();
8298
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8446
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8299
8447
  if (isOverflow && this.__.overflow !== 'hide')
8300
8448
  add(renderBounds, childrenRenderBounds);
8301
8449
  }
8302
8450
  else
8303
8451
  this.__updateRectRenderBounds();
8304
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8452
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
8305
8453
  }
8306
8454
  __updateRectRenderBounds() { }
8307
8455
  __updateRectChange() { }
@@ -8605,17 +8753,10 @@ var LeaferUI = (function (exports) {
8605
8753
 
8606
8754
  exports.Image = class Image extends exports.Rect {
8607
8755
  get __tag() { return 'Image'; }
8608
- get ready() { return this.image ? this.image.ready : false; }
8756
+ get ready() { const { image } = this; return image && image.ready; }
8757
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
8609
8758
  constructor(data) {
8610
8759
  super(data);
8611
- this.on(ImageEvent.LOADED, (e) => {
8612
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
8613
- this.image = e.image;
8614
- });
8615
- }
8616
- destroy() {
8617
- this.image = null;
8618
- super.destroy();
8619
8760
  }
8620
8761
  };
8621
8762
  __decorate([
@@ -8631,11 +8772,11 @@ var LeaferUI = (function (exports) {
8631
8772
 
8632
8773
  exports.Canvas = class Canvas extends exports.Rect {
8633
8774
  get __tag() { return 'Canvas'; }
8775
+ get context() { return this.canvas.context; }
8634
8776
  get ready() { return !this.url; }
8635
8777
  constructor(data) {
8636
8778
  super(data);
8637
8779
  this.canvas = Creator.canvas(this.__);
8638
- this.context = this.canvas.context;
8639
8780
  if (data && data.url)
8640
8781
  this.drawImage(data.url);
8641
8782
  }
@@ -8679,7 +8820,7 @@ var LeaferUI = (function (exports) {
8679
8820
  destroy() {
8680
8821
  if (this.canvas) {
8681
8822
  this.canvas.destroy();
8682
- this.canvas = this.context = null;
8823
+ this.canvas = null;
8683
8824
  }
8684
8825
  super.destroy();
8685
8826
  }
@@ -8725,7 +8866,7 @@ var LeaferUI = (function (exports) {
8725
8866
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8726
8867
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8727
8868
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8728
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8869
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
8729
8870
  }
8730
8871
  __updateBoxBounds() {
8731
8872
  const data = this.__;
@@ -8755,12 +8896,11 @@ var LeaferUI = (function (exports) {
8755
8896
  super.__updateBoxBounds();
8756
8897
  if (italic)
8757
8898
  b.width += fontSize * 0.16;
8758
- const isOverflow = !includes(b, contentBounds) || undefined;
8759
- if (isOverflow)
8899
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
8900
+ if (this.isOverflow)
8760
8901
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8761
8902
  else
8762
8903
  data.__textBoxBounds = b;
8763
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8764
8904
  }
8765
8905
  __onUpdateSize() {
8766
8906
  if (this.__box)
@@ -8823,6 +8963,9 @@ var LeaferUI = (function (exports) {
8823
8963
  __decorate([
8824
8964
  boundsType('')
8825
8965
  ], exports.Text.prototype, "text", void 0);
8966
+ __decorate([
8967
+ boundsType('')
8968
+ ], exports.Text.prototype, "placeholder", void 0);
8826
8969
  __decorate([
8827
8970
  boundsType('caption')
8828
8971
  ], exports.Text.prototype, "fontFamily", void 0);
@@ -8958,7 +9101,7 @@ var LeaferUI = (function (exports) {
8958
9101
  if (sky || editor)
8959
9102
  this.sky = this.addLeafer(sky);
8960
9103
  if (editor)
8961
- this.sky.add(this.editor = Creator.editor(editor));
9104
+ Creator.editor(editor, this);
8962
9105
  }
8963
9106
  }
8964
9107
  __setApp() {
@@ -8972,6 +9115,10 @@ var LeaferUI = (function (exports) {
8972
9115
  this.watcher.disable();
8973
9116
  this.layouter.disable();
8974
9117
  }
9118
+ __updateLocalBounds() {
9119
+ this.forEach(leafer => leafer.updateLayout());
9120
+ super.__updateLocalBounds();
9121
+ }
8975
9122
  start() {
8976
9123
  super.start();
8977
9124
  this.forEach(leafer => leafer.start());
@@ -9029,12 +9176,8 @@ var LeaferUI = (function (exports) {
9029
9176
  this.renderer.update();
9030
9177
  }
9031
9178
  __render(canvas, options) {
9032
- if (canvas.context) {
9033
- const m = options.matrix;
9034
- if (m)
9035
- canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9036
- this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9037
- }
9179
+ if (canvas.context)
9180
+ this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds));
9038
9181
  }
9039
9182
  __onResize(event) {
9040
9183
  this.forEach(leafer => leafer.resize(event));
@@ -9055,9 +9198,11 @@ var LeaferUI = (function (exports) {
9055
9198
  return config;
9056
9199
  }
9057
9200
  __listenChildEvents(leafer) {
9058
- leafer.once(LayoutEvent.END, () => this.__onReady());
9059
- leafer.once(RenderEvent.START, () => this.__onCreated());
9060
- leafer.once(RenderEvent.END, () => this.__onViewReady());
9201
+ leafer.once([
9202
+ [LayoutEvent.END, this.__onReady, this],
9203
+ [RenderEvent.START, this.__onCreated, this],
9204
+ [RenderEvent.END, this.__onViewReady, this]
9205
+ ]);
9061
9206
  if (this.realCanvas)
9062
9207
  this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
9063
9208
  }
@@ -9268,7 +9413,7 @@ var LeaferUI = (function (exports) {
9268
9413
  registerUIEvent()
9269
9414
  ], exports.MoveEvent);
9270
9415
 
9271
- exports.RotateEvent = class RotateEvent extends UIEvent {
9416
+ exports.RotateEvent = class RotateEvent extends exports.PointerEvent {
9272
9417
  };
9273
9418
  exports.RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
9274
9419
  exports.RotateEvent.START = 'rotate.start';
@@ -9289,7 +9434,7 @@ var LeaferUI = (function (exports) {
9289
9434
  registerUIEvent()
9290
9435
  ], exports.SwipeEvent);
9291
9436
 
9292
- exports.ZoomEvent = class ZoomEvent extends UIEvent {
9437
+ exports.ZoomEvent = class ZoomEvent extends exports.PointerEvent {
9293
9438
  };
9294
9439
  exports.ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
9295
9440
  exports.ZoomEvent.START = 'zoom.start';
@@ -10132,8 +10277,8 @@ var LeaferUI = (function (exports) {
10132
10277
  if (this.__box)
10133
10278
  this.__box.__updateHitCanvas();
10134
10279
  const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10135
- const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10136
- const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10280
+ const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10281
+ const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10137
10282
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
10138
10283
  if (!this.__hitCanvas)
10139
10284
  this.__hitCanvas = isHitPixel ? hitCanvasManager.getPixelType(this, { contextSettings: { willReadFrequently: true } }) : hitCanvasManager.getPathType(this);
@@ -10164,11 +10309,11 @@ var LeaferUI = (function (exports) {
10164
10309
  if (data.__isHitPixel && this.__hitPixel(inner))
10165
10310
  return true;
10166
10311
  const { hitFill } = data;
10167
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
10312
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10168
10313
  if (needHitFillPath && this.__hitFill(inner))
10169
10314
  return true;
10170
10315
  const { hitStroke, __strokeWidth } = data;
10171
- const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
10316
+ const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10172
10317
  if (!needHitFillPath && !needHitStrokePath)
10173
10318
  return false;
10174
10319
  const radiusWidth = inner.radiusX * 2;
@@ -10248,8 +10393,10 @@ var LeaferUI = (function (exports) {
10248
10393
  };
10249
10394
 
10250
10395
  function fillText(ui, canvas) {
10251
- let row, data = ui.__.__textDrawData;
10252
- const { rows, decorationY } = data;
10396
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
10397
+ if (data.__isPlacehold && data.placeholderColor)
10398
+ canvas.fillStyle = data.placeholderColor;
10399
+ let row;
10253
10400
  for (let i = 0, len = rows.length; i < len; i++) {
10254
10401
  row = rows[i];
10255
10402
  if (row.text)
@@ -10258,7 +10405,7 @@ var LeaferUI = (function (exports) {
10258
10405
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10259
10406
  }
10260
10407
  if (decorationY) {
10261
- const { decorationColor, decorationHeight } = data;
10408
+ const { decorationColor, decorationHeight } = data.__textDrawData;
10262
10409
  if (decorationColor)
10263
10410
  canvas.fillStyle = decorationColor;
10264
10411
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -10267,65 +10414,71 @@ var LeaferUI = (function (exports) {
10267
10414
 
10268
10415
  function fill(fill, ui, canvas) {
10269
10416
  canvas.fillStyle = fill;
10270
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10417
+ fillPathOrText(ui, canvas);
10271
10418
  }
10272
10419
  function fills(fills, ui, canvas) {
10273
10420
  let item;
10274
- const { windingRule, __font } = ui.__;
10275
10421
  for (let i = 0, len = fills.length; i < len; i++) {
10276
10422
  item = fills[i];
10277
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
10278
- continue;
10279
- if (item.style) {
10280
- canvas.fillStyle = item.style;
10281
- if (item.transform) {
10282
- canvas.save();
10283
- canvas.transform(item.transform);
10284
- if (item.blendMode)
10285
- canvas.blendMode = item.blendMode;
10286
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10287
- canvas.restore();
10423
+ if (item.image) {
10424
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
10425
+ continue;
10426
+ if (!item.style) {
10427
+ if (!i && item.image.isPlacehold)
10428
+ ui.drawImagePlaceholder(canvas, item.image);
10429
+ continue;
10288
10430
  }
10289
- else {
10290
- if (item.blendMode) {
10291
- canvas.saveBlendMode(item.blendMode);
10292
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10293
- canvas.restoreBlendMode();
10294
- }
10295
- else {
10296
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
10297
- }
10431
+ }
10432
+ canvas.fillStyle = item.style;
10433
+ if (item.transform) {
10434
+ canvas.save();
10435
+ canvas.transform(item.transform);
10436
+ if (item.blendMode)
10437
+ canvas.blendMode = item.blendMode;
10438
+ fillPathOrText(ui, canvas);
10439
+ canvas.restore();
10440
+ }
10441
+ else {
10442
+ if (item.blendMode) {
10443
+ canvas.saveBlendMode(item.blendMode);
10444
+ fillPathOrText(ui, canvas);
10445
+ canvas.restoreBlendMode();
10298
10446
  }
10447
+ else
10448
+ fillPathOrText(ui, canvas);
10299
10449
  }
10300
10450
  }
10301
10451
  }
10452
+ function fillPathOrText(ui, canvas) {
10453
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
10454
+ }
10302
10455
 
10303
10456
  function strokeText(stroke, ui, canvas) {
10304
- const { strokeAlign } = ui.__;
10305
- const isStrokes = typeof stroke !== 'string';
10306
- switch (strokeAlign) {
10457
+ switch (ui.__.strokeAlign) {
10307
10458
  case 'center':
10308
- canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
10309
- isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10459
+ drawCenter$1(stroke, 1, ui, canvas);
10310
10460
  break;
10311
10461
  case 'inside':
10312
- drawAlignStroke('inside', stroke, isStrokes, ui, canvas);
10462
+ drawAlign(stroke, 'inside', ui, canvas);
10313
10463
  break;
10314
10464
  case 'outside':
10315
- drawAlignStroke('outside', stroke, isStrokes, ui, canvas);
10465
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
10316
10466
  break;
10317
10467
  }
10318
10468
  }
10319
- function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10320
- const { __strokeWidth, __font } = ui.__;
10469
+ function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10470
+ const data = ui.__;
10471
+ canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10472
+ data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10473
+ }
10474
+ function drawAlign(stroke, align, ui, canvas) {
10321
10475
  const out = canvas.getSameCanvas(true, true);
10322
- out.setStroke(isStrokes ? undefined : stroke, __strokeWidth * 2, ui.__);
10323
- out.font = __font;
10324
- isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
10476
+ out.font = ui.__.__font;
10477
+ drawCenter$1(stroke, 2, ui, out);
10325
10478
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10326
10479
  fillText(ui, out);
10327
10480
  out.blendMode = 'normal';
10328
- if (ui.__worldFlipped)
10481
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10329
10482
  canvas.copyWorldByReset(out, ui.__nowWorld);
10330
10483
  else
10331
10484
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
@@ -10367,90 +10520,60 @@ var LeaferUI = (function (exports) {
10367
10520
  }
10368
10521
 
10369
10522
  function stroke(stroke, ui, canvas) {
10370
- const options = ui.__;
10371
- const { __strokeWidth, strokeAlign, __font } = options;
10372
- if (!__strokeWidth)
10523
+ const data = ui.__;
10524
+ if (!data.__strokeWidth)
10373
10525
  return;
10374
- if (__font) {
10526
+ if (data.__font) {
10375
10527
  strokeText(stroke, ui, canvas);
10376
10528
  }
10377
10529
  else {
10378
- switch (strokeAlign) {
10530
+ switch (data.strokeAlign) {
10379
10531
  case 'center':
10380
- canvas.setStroke(stroke, __strokeWidth, options);
10381
- canvas.stroke();
10382
- if (options.__useArrow)
10383
- strokeArrow(ui, canvas);
10532
+ drawCenter(stroke, 1, ui, canvas);
10384
10533
  break;
10385
10534
  case 'inside':
10386
- canvas.save();
10387
- canvas.setStroke(stroke, __strokeWidth * 2, options);
10388
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10389
- canvas.stroke();
10390
- canvas.restore();
10535
+ drawInside(stroke, ui, canvas);
10391
10536
  break;
10392
10537
  case 'outside':
10393
- const out = canvas.getSameCanvas(true, true);
10394
- out.setStroke(stroke, __strokeWidth * 2, options);
10395
- ui.__drawRenderPath(out);
10396
- out.stroke();
10397
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10398
- out.clearWorld(ui.__layout.renderBounds);
10399
- if (ui.__worldFlipped)
10400
- canvas.copyWorldByReset(out, ui.__nowWorld);
10401
- else
10402
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10403
- out.recycle(ui.__nowWorld);
10538
+ drawOutside(stroke, ui, canvas);
10404
10539
  break;
10405
10540
  }
10406
10541
  }
10407
10542
  }
10408
10543
  function strokes(strokes, ui, canvas) {
10409
- const options = ui.__;
10410
- const { __strokeWidth, strokeAlign, __font } = options;
10411
- if (!__strokeWidth)
10412
- return;
10413
- if (__font) {
10414
- strokeText(strokes, ui, canvas);
10544
+ stroke(strokes, ui, canvas);
10545
+ }
10546
+ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10547
+ const data = ui.__;
10548
+ canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10549
+ data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10550
+ if (data.__useArrow)
10551
+ Paint.strokeArrow(stroke, ui, canvas);
10552
+ }
10553
+ function drawInside(stroke, ui, canvas) {
10554
+ const data = ui.__;
10555
+ canvas.save();
10556
+ data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
10557
+ drawCenter(stroke, 2, ui, canvas);
10558
+ canvas.restore();
10559
+ }
10560
+ function drawOutside(stroke, ui, canvas) {
10561
+ const data = ui.__;
10562
+ if (data.__fillAfterStroke) {
10563
+ drawCenter(stroke, 2, ui, canvas);
10415
10564
  }
10416
10565
  else {
10417
- switch (strokeAlign) {
10418
- case 'center':
10419
- canvas.setStroke(undefined, __strokeWidth, options);
10420
- drawStrokesStyle(strokes, false, ui, canvas);
10421
- if (options.__useArrow)
10422
- strokeArrow(ui, canvas);
10423
- break;
10424
- case 'inside':
10425
- canvas.save();
10426
- canvas.setStroke(undefined, __strokeWidth * 2, options);
10427
- options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
10428
- drawStrokesStyle(strokes, false, ui, canvas);
10429
- canvas.restore();
10430
- break;
10431
- case 'outside':
10432
- const { renderBounds } = ui.__layout;
10433
- const out = canvas.getSameCanvas(true, true);
10434
- ui.__drawRenderPath(out);
10435
- out.setStroke(undefined, __strokeWidth * 2, options);
10436
- drawStrokesStyle(strokes, false, ui, out);
10437
- options.windingRule ? out.clip(options.windingRule) : out.clip();
10438
- out.clearWorld(renderBounds);
10439
- if (ui.__worldFlipped)
10440
- canvas.copyWorldByReset(out, ui.__nowWorld);
10441
- else
10442
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10443
- out.recycle(ui.__nowWorld);
10444
- break;
10445
- }
10446
- }
10447
- }
10448
- function strokeArrow(ui, canvas) {
10449
- if (ui.__.dashPattern) {
10450
- canvas.beginPath();
10451
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10452
- canvas.dashPattern = null;
10453
- canvas.stroke();
10566
+ const { renderBounds } = ui.__layout;
10567
+ const out = canvas.getSameCanvas(true, true);
10568
+ ui.__drawRenderPath(out);
10569
+ drawCenter(stroke, 2, ui, out);
10570
+ data.windingRule ? out.clip(data.windingRule) : out.clip();
10571
+ out.clearWorld(renderBounds);
10572
+ if (ui.__worldFlipped || Platform.fullImageShadow)
10573
+ canvas.copyWorldByReset(out, ui.__nowWorld);
10574
+ else
10575
+ canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10576
+ out.recycle(ui.__nowWorld);
10454
10577
  }
10455
10578
  }
10456
10579
 
@@ -10497,9 +10620,10 @@ var LeaferUI = (function (exports) {
10497
10620
  }
10498
10621
 
10499
10622
  let recycleMap;
10623
+ const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
10500
10624
  function compute(attrName, ui) {
10501
10625
  const data = ui.__, leafPaints = [];
10502
- let paints = data.__input[attrName], hasOpacityPixel;
10626
+ let paints = data.__input[attrName], isAlphaPixel, isTransparent;
10503
10627
  if (!(paints instanceof Array))
10504
10628
  paints = [paints];
10505
10629
  recycleMap = PaintImage.recycleImage(attrName, data);
@@ -10509,35 +10633,62 @@ var LeaferUI = (function (exports) {
10509
10633
  leafPaints.push(item);
10510
10634
  }
10511
10635
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10512
- if (leafPaints.length && leafPaints[0].image)
10513
- hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
10514
- attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
10636
+ if (leafPaints.length) {
10637
+ if (leafPaints.every(item => item.isTransparent)) {
10638
+ if (leafPaints.some(item => item.image))
10639
+ isAlphaPixel = true;
10640
+ isTransparent = true;
10641
+ }
10642
+ }
10643
+ if (attrName === 'fill') {
10644
+ stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
10645
+ stintSet(data, '__isTransparentFill', isTransparent);
10646
+ }
10647
+ else {
10648
+ stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10649
+ stintSet(data, '__isTransparentStroke', isTransparent);
10650
+ }
10515
10651
  }
10516
10652
  function getLeafPaint(attrName, paint, ui) {
10517
10653
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
10518
10654
  return undefined;
10655
+ let data;
10519
10656
  const { boxBounds } = ui.__layout;
10520
10657
  switch (paint.type) {
10521
- case 'solid':
10522
- let { type, blendMode, color, opacity } = paint;
10523
- return { type, blendMode, style: ColorConvert.string(color, opacity) };
10524
10658
  case 'image':
10525
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10659
+ data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10660
+ break;
10526
10661
  case 'linear':
10527
- return PaintGradient.linearGradient(paint, boxBounds);
10662
+ data = PaintGradient.linearGradient(paint, boxBounds);
10663
+ break;
10528
10664
  case 'radial':
10529
- return PaintGradient.radialGradient(paint, boxBounds);
10665
+ data = PaintGradient.radialGradient(paint, boxBounds);
10666
+ break;
10530
10667
  case 'angular':
10531
- return PaintGradient.conicGradient(paint, boxBounds);
10668
+ data = PaintGradient.conicGradient(paint, boxBounds);
10669
+ break;
10670
+ case 'solid':
10671
+ const { type, blendMode, color, opacity } = paint;
10672
+ data = { type, blendMode, style: ColorConvert.string(color, opacity) };
10673
+ break;
10532
10674
  default:
10533
- return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10675
+ if (paint.r !== undefined)
10676
+ data = { type: 'solid', style: ColorConvert.string(paint) };
10534
10677
  }
10678
+ if (data) {
10679
+ if (typeof data.style === 'string' && hasTransparent$1(data.style))
10680
+ data.isTransparent = true;
10681
+ if (paint.blendMode)
10682
+ data.blendMode = paint.blendMode;
10683
+ }
10684
+ return data;
10535
10685
  }
10536
10686
 
10537
10687
  const PaintModule = {
10538
10688
  compute,
10539
10689
  fill,
10540
10690
  fills,
10691
+ fillPathOrText,
10541
10692
  fillText,
10542
10693
  stroke,
10543
10694
  strokes,
@@ -10596,12 +10747,10 @@ var LeaferUI = (function (exports) {
10596
10747
 
10597
10748
  const { get: get$2, translate } = MatrixHelper;
10598
10749
  const tempBox = new Bounds();
10599
- const tempPoint = {};
10600
10750
  const tempScaleData = {};
10751
+ const tempImage = {};
10601
10752
  function createData(leafPaint, image, paint, box) {
10602
- const { blendMode, changeful, sync } = paint;
10603
- if (blendMode)
10604
- leafPaint.blendMode = blendMode;
10753
+ const { changeful, sync } = paint;
10605
10754
  if (changeful)
10606
10755
  leafPaint.changeful = changeful;
10607
10756
  if (sync)
@@ -10609,38 +10758,38 @@ var LeaferUI = (function (exports) {
10609
10758
  leafPaint.data = getPatternData(paint, box, image);
10610
10759
  }
10611
10760
  function getPatternData(paint, box, image) {
10612
- let { width, height } = image;
10613
10761
  if (paint.padding)
10614
10762
  box = tempBox.set(box).shrink(paint.padding);
10615
10763
  if (paint.mode === 'strench')
10616
10764
  paint.mode = 'stretch';
10765
+ let { width, height } = image;
10617
10766
  const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
10618
10767
  const sameBox = box.width === width && box.height === height;
10619
10768
  const data = { mode };
10620
10769
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10621
- const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10622
- let x = 0, y = 0, scaleX, scaleY;
10770
+ BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
10771
+ let scaleX, scaleY;
10623
10772
  if (!mode || mode === 'cover' || mode === 'fit') {
10624
10773
  if (!sameBox || rotation) {
10625
- const sw = box.width / swapWidth, sh = box.height / swapHeight;
10626
- scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10627
- x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10774
+ scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
10775
+ BoundsHelper.put(box, image, align, scaleX, false, tempImage);
10776
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
10628
10777
  }
10629
10778
  }
10630
- else if (scale || size) {
10631
- MathHelper.getScaleData(scale, size, image, tempScaleData);
10632
- scaleX = tempScaleData.scaleX;
10633
- scaleY = tempScaleData.scaleY;
10634
- }
10635
- if (align) {
10636
- const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10637
- if (scaleX)
10638
- imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10639
- AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
10640
- x += tempPoint.x, y += tempPoint.y;
10779
+ else {
10780
+ if (scale || size) {
10781
+ MathHelper.getScaleData(scale, size, image, tempScaleData);
10782
+ scaleX = tempScaleData.scaleX;
10783
+ scaleY = tempScaleData.scaleY;
10784
+ }
10785
+ if (align) {
10786
+ if (scaleX)
10787
+ BoundsHelper.scale(tempImage, scaleX, scaleY, true);
10788
+ AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
10789
+ }
10641
10790
  }
10642
10791
  if (offset)
10643
- x += offset.x, y += offset.y;
10792
+ PointHelper.move(tempImage, offset);
10644
10793
  switch (mode) {
10645
10794
  case 'stretch':
10646
10795
  if (!sameBox)
@@ -10648,12 +10797,12 @@ var LeaferUI = (function (exports) {
10648
10797
  break;
10649
10798
  case 'normal':
10650
10799
  case 'clip':
10651
- if (x || y || scaleX || rotation)
10652
- clipMode(data, box, x, y, scaleX, scaleY, rotation);
10800
+ if (tempImage.x || tempImage.y || scaleX || rotation)
10801
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10653
10802
  break;
10654
10803
  case 'repeat':
10655
10804
  if (!sameBox || scaleX || rotation)
10656
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
10805
+ repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
10657
10806
  if (!repeat)
10658
10807
  data.repeat = 'repeat';
10659
10808
  break;
@@ -10661,7 +10810,7 @@ var LeaferUI = (function (exports) {
10661
10810
  case 'cover':
10662
10811
  default:
10663
10812
  if (scaleX)
10664
- fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10813
+ fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10665
10814
  }
10666
10815
  if (!data.transform) {
10667
10816
  if (box.x || box.y) {
@@ -10694,6 +10843,8 @@ var LeaferUI = (function (exports) {
10694
10843
  }
10695
10844
  else {
10696
10845
  leafPaint = { type: paint.type, image };
10846
+ if (image.hasAlphaPixel)
10847
+ leafPaint.isTransparent = true;
10697
10848
  cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
10698
10849
  }
10699
10850
  if (firstUse || image.loading)
@@ -10718,7 +10869,7 @@ var LeaferUI = (function (exports) {
10718
10869
  ignoreRender(ui, false);
10719
10870
  if (!ui.destroyed) {
10720
10871
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
10721
- if (image.hasOpacityPixel)
10872
+ if (image.hasAlphaPixel)
10722
10873
  ui.__layout.hitCanvasChanged = true;
10723
10874
  ui.forceUpdate('surface');
10724
10875
  }
@@ -10730,6 +10881,17 @@ var LeaferUI = (function (exports) {
10730
10881
  onLoadError(ui, event, error);
10731
10882
  leafPaint.loadId = null;
10732
10883
  });
10884
+ if (ui.placeholderColor) {
10885
+ if (!ui.placeholderDelay)
10886
+ image.isPlacehold = true;
10887
+ else
10888
+ setTimeout(() => {
10889
+ if (!image.ready) {
10890
+ image.isPlacehold = true;
10891
+ ui.forceUpdate('surface');
10892
+ }
10893
+ }, ui.placeholderDelay);
10894
+ }
10733
10895
  }
10734
10896
  return leafPaint;
10735
10897
  }
@@ -10935,32 +11097,33 @@ var LeaferUI = (function (exports) {
10935
11097
  repeatMode
10936
11098
  };
10937
11099
 
10938
- const { toPoint: toPoint$3 } = AroundHelper;
11100
+ const { toPoint: toPoint$3 } = AroundHelper, { hasTransparent } = ColorConvert;
10939
11101
  const realFrom$2 = {};
10940
11102
  const realTo$2 = {};
10941
11103
  function linearGradient(paint, box) {
10942
- let { from, to, type, blendMode, opacity } = paint;
11104
+ let { from, to, type, opacity } = paint;
10943
11105
  toPoint$3(from || 'top', box, realFrom$2);
10944
11106
  toPoint$3(to || 'bottom', box, realTo$2);
10945
11107
  const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
10946
- applyStops(style, paint.stops, opacity);
10947
11108
  const data = { type, style };
10948
- if (blendMode)
10949
- data.blendMode = blendMode;
11109
+ applyStops(data, style, paint.stops, opacity);
10950
11110
  return data;
10951
11111
  }
10952
- function applyStops(gradient, stops, opacity) {
11112
+ function applyStops(data, gradient, stops, opacity) {
10953
11113
  if (stops) {
10954
- let stop;
11114
+ let stop, color, offset, isTransparent;
10955
11115
  for (let i = 0, len = stops.length; i < len; i++) {
10956
11116
  stop = stops[i];
10957
- if (typeof stop === 'string') {
10958
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
10959
- }
10960
- else {
10961
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
10962
- }
11117
+ if (typeof stop === 'string')
11118
+ offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
11119
+ else
11120
+ offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
11121
+ gradient.addColorStop(offset, color);
11122
+ if (!isTransparent && hasTransparent(color))
11123
+ isTransparent = true;
10963
11124
  }
11125
+ if (isTransparent)
11126
+ data.isTransparent = true;
10964
11127
  }
10965
11128
  }
10966
11129
 
@@ -10970,17 +11133,15 @@ var LeaferUI = (function (exports) {
10970
11133
  const realFrom$1 = {};
10971
11134
  const realTo$1 = {};
10972
11135
  function radialGradient(paint, box) {
10973
- let { from, to, type, opacity, blendMode, stretch } = paint;
11136
+ let { from, to, type, opacity, stretch } = paint;
10974
11137
  toPoint$2(from || 'center', box, realFrom$1);
10975
11138
  toPoint$2(to || 'bottom', box, realTo$1);
10976
11139
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
10977
- applyStops(style, paint.stops, opacity);
10978
11140
  const data = { type, style };
11141
+ applyStops(data, style, paint.stops, opacity);
10979
11142
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
10980
11143
  if (transform)
10981
11144
  data.transform = transform;
10982
- if (blendMode)
10983
- data.blendMode = blendMode;
10984
11145
  return data;
10985
11146
  }
10986
11147
  function getTransform(box, from, to, stretch, rotate90) {
@@ -11006,17 +11167,15 @@ var LeaferUI = (function (exports) {
11006
11167
  const realFrom = {};
11007
11168
  const realTo = {};
11008
11169
  function conicGradient(paint, box) {
11009
- let { from, to, type, opacity, blendMode, stretch } = paint;
11170
+ let { from, to, type, opacity, stretch } = paint;
11010
11171
  toPoint$1(from || 'center', box, realFrom);
11011
11172
  toPoint$1(to || 'bottom', box, realTo);
11012
11173
  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));
11013
- applyStops(style, paint.stops, opacity);
11014
11174
  const data = { type, style };
11175
+ applyStops(data, style, paint.stops, opacity);
11015
11176
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11016
11177
  if (transform)
11017
11178
  data.transform = transform;
11018
- if (blendMode)
11019
- data.blendMode = blendMode;
11020
11179
  return data;
11021
11180
  }
11022
11181
 
@@ -11349,6 +11508,8 @@ var LeaferUI = (function (exports) {
11349
11508
  lastCharType = null;
11350
11509
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
11351
11510
  word = { data: [] }, row = { words: [] };
11511
+ if (__letterSpacing)
11512
+ content = [...content];
11352
11513
  for (let i = 0, len = content.length; i < len; i++) {
11353
11514
  char = content[i];
11354
11515
  if (char === '\n') {
@@ -12195,24 +12356,25 @@ var LeaferUI = (function (exports) {
12195
12356
  const { app } = editor;
12196
12357
  app.selector.proxy = editor;
12197
12358
  this.__eventIds = [
12198
- editor.on_(EditorEvent.HOVER, this.onHover, this),
12199
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12200
- app.on_(exports.PointerEvent.MOVE, this.onPointerMove, this),
12201
- app.on_(exports.PointerEvent.BEFORE_DOWN, this.onBeforeDown, this),
12202
- app.on_(exports.PointerEvent.TAP, this.onTap, this),
12203
- app.on_(exports.DragEvent.START, this.onDragStart, this, true),
12204
- app.on_(exports.DragEvent.DRAG, this.onDrag, this),
12205
- app.on_(exports.DragEvent.END, this.onDragEnd, this),
12206
- app.on_(exports.MoveEvent.MOVE, this.onAutoMove, this),
12207
- app.on_([exports.ZoomEvent.ZOOM, exports.MoveEvent.MOVE], () => { this.editor.hoverTarget = null; }),
12359
+ editor.on_([
12360
+ [EditorEvent.HOVER, this.onHover, this],
12361
+ [EditorEvent.SELECT, this.onSelect, this]
12362
+ ]),
12363
+ app.on_([
12364
+ [exports.PointerEvent.MOVE, this.onPointerMove, this],
12365
+ [exports.PointerEvent.BEFORE_DOWN, this.onBeforeDown, this],
12366
+ [exports.PointerEvent.TAP, this.onTap, this],
12367
+ [exports.DragEvent.START, this.onDragStart, this, true],
12368
+ [exports.DragEvent.DRAG, this.onDrag, this],
12369
+ [exports.DragEvent.END, this.onDragEnd, this],
12370
+ [exports.MoveEvent.MOVE, this.onAutoMove, this],
12371
+ [[exports.ZoomEvent.ZOOM, exports.MoveEvent.MOVE], () => { this.editor.hoverTarget = null; }],
12372
+ ])
12208
12373
  ];
12209
12374
  });
12210
12375
  }
12211
12376
  __removeListenEvents() {
12212
- if (this.__eventIds) {
12213
- this.off_(this.__eventIds);
12214
- this.__eventIds.length = 0;
12215
- }
12377
+ this.off_(this.__eventIds);
12216
12378
  }
12217
12379
  destroy() {
12218
12380
  this.editor = this.originList = this.needRemoveItem = null;
@@ -12283,8 +12445,10 @@ var LeaferUI = (function (exports) {
12283
12445
  align = 'top-right';
12284
12446
  }
12285
12447
  if (lockRatio) {
12286
- const unlockSide = lockRatio === 'corner' && direction % 2;
12287
- if (!unlockSide) {
12448
+ if (lockRatio === 'corner' && direction % 2) {
12449
+ lockRatio = false;
12450
+ }
12451
+ else {
12288
12452
  let scale;
12289
12453
  switch (direction) {
12290
12454
  case top$1:
@@ -12499,6 +12663,10 @@ var LeaferUI = (function (exports) {
12499
12663
  }
12500
12664
 
12501
12665
  class EditPoint extends exports.Box {
12666
+ constructor(data) {
12667
+ super(data);
12668
+ this.useFastShadow = true;
12669
+ }
12502
12670
  }
12503
12671
 
12504
12672
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
@@ -12769,28 +12937,29 @@ var LeaferUI = (function (exports) {
12769
12937
  const { editor } = this;
12770
12938
  point.direction = direction;
12771
12939
  point.pointType = type;
12772
- point.on_(exports.DragEvent.START, this.onDragStart, this);
12773
- point.on_(exports.DragEvent.DRAG, this.onDrag, this);
12774
- point.on_(exports.DragEvent.END, this.onDragEnd, this);
12775
- point.on_(exports.PointerEvent.LEAVE, () => this.enterPoint = null);
12940
+ const events = [
12941
+ [exports.DragEvent.START, this.onDragStart, this],
12942
+ [exports.DragEvent.DRAG, this.onDrag, this],
12943
+ [exports.DragEvent.END, this.onDragEnd, this],
12944
+ [exports.PointerEvent.LEAVE, () => { this.enterPoint = null; }],
12945
+ ];
12776
12946
  if (point.name !== 'circle')
12777
- point.on_(exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(editor, e); });
12947
+ events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(editor, e); }]);
12948
+ this.__eventIds.push(point.on_(events));
12778
12949
  }
12779
12950
  __listenEvents() {
12780
12951
  const { rect, editor } = this;
12781
- this.__eventIds = [
12782
- editor.on_(EditorEvent.SELECT, this.onSelect, this),
12783
- rect.on_(exports.DragEvent.START, this.onDragStart, this),
12784
- rect.on_(exports.DragEvent.DRAG, editor.onMove, editor),
12785
- rect.on_(exports.DragEvent.END, this.onDragEnd, this),
12786
- rect.on_(exports.PointerEvent.ENTER, () => updateMoveCursor(editor)),
12787
- rect.on_(exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this),
12788
- rect.on_(exports.PointerEvent.LONG_PRESS, this.onLongPress, this)
12789
- ];
12952
+ this.__eventIds.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
12953
+ [exports.DragEvent.START, this.onDragStart, this],
12954
+ [exports.DragEvent.DRAG, editor.onMove, editor],
12955
+ [exports.DragEvent.END, this.onDragEnd, this],
12956
+ [exports.PointerEvent.ENTER, () => updateMoveCursor(editor)],
12957
+ [exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this],
12958
+ [exports.PointerEvent.LONG_PRESS, this.onLongPress, this]
12959
+ ]));
12790
12960
  }
12791
12961
  __removeListenEvents() {
12792
12962
  this.off_(this.__eventIds);
12793
- this.__eventIds.length = 0;
12794
12963
  }
12795
12964
  destroy() {
12796
12965
  this.editor = null;
@@ -13532,12 +13701,14 @@ ${filterStyle}
13532
13701
  const { app, leafer, editBox, editMask } = this;
13533
13702
  this.targetEventIds = [
13534
13703
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
13535
- app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
13536
- app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13537
- app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13538
- app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13539
- app.on_([exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this),
13540
- app.on_(exports.KeyEvent.DOWN, editBox.onArrow, editBox)
13704
+ app.on_([
13705
+ [RenderEvent.CHILD_START, this.onAppRenderStart, this],
13706
+ [exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13707
+ [exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13708
+ [exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13709
+ [[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
13710
+ [exports.KeyEvent.DOWN, editBox.onArrow, editBox]
13711
+ ])
13541
13712
  ];
13542
13713
  if (editMask.visible)
13543
13714
  editMask.forceRender();
@@ -13547,7 +13718,6 @@ ${filterStyle}
13547
13718
  const { targetEventIds, editMask } = this;
13548
13719
  if (targetEventIds.length) {
13549
13720
  this.off_(targetEventIds);
13550
- targetEventIds.length = 0;
13551
13721
  if (editMask.visible)
13552
13722
  editMask.forceRender();
13553
13723
  }
@@ -14016,7 +14186,12 @@ ${filterStyle}
14016
14186
  Plugin.add('resize');
14017
14187
 
14018
14188
  Plugin.add('editor', 'resize');
14019
- Creator.editor = function (options) { return new Editor(options); };
14189
+ Creator.editor = function (options, app) {
14190
+ const editor = new Editor(options);
14191
+ if (app)
14192
+ app.sky.add(app.editor = editor);
14193
+ return editor;
14194
+ };
14020
14195
  exports.Box.addAttr('textBox', false, dataType);
14021
14196
  exports.UI.addAttr('editConfig', undefined, dataType);
14022
14197
  exports.UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
@@ -14319,6 +14494,7 @@ ${filterStyle}
14319
14494
  return;
14320
14495
  const { move, rotation, scale, center } = MultiTouchHelper.getData(list);
14321
14496
  Object.assign(data, center);
14497
+ data.multiTouch = true;
14322
14498
  this.pointerWaitCancel();
14323
14499
  this.rotate(getRotateEventData(rotation, data));
14324
14500
  this.zoom(getZoomEventData(scale, data));
@@ -14858,6 +15034,16 @@ ${filterStyle}
14858
15034
  exports.UI.addAttr('startArrow', 'none', arrowType);
14859
15035
  exports.UI.addAttr('endArrow', 'none', arrowType);
14860
15036
  Object.assign(PathArrow, PathArrowModule);
15037
+ Object.assign(Paint, {
15038
+ strokeArrow(_stroke, ui, canvas) {
15039
+ if (ui.__.dashPattern) {
15040
+ canvas.beginPath();
15041
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
15042
+ canvas.dashPattern = null;
15043
+ canvas.stroke();
15044
+ }
15045
+ }
15046
+ });
14861
15047
 
14862
15048
  const { Yes, NoAndSkip, YesAndSkip } = exports.Answer;
14863
15049
  const idCondition = {}, classNameCondition = {}, tagCondition = {};
@@ -15043,10 +15229,9 @@ ${filterStyle}
15043
15229
  else {
15044
15230
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
15045
15231
  const { worldTransform, isLeafer, leafer, isFrame } = leaf;
15046
- const { slice, trim, padding, onCanvas } = options;
15232
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
15047
15233
  const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
15048
15234
  const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
15049
- const screenshot = options.screenshot || leaf.isApp;
15050
15235
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
15051
15236
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
15052
15237
  if (screenshot) {
@@ -15082,12 +15267,9 @@ ${filterStyle}
15082
15267
  const scaleData = { scaleX: 1, scaleY: 1 };
15083
15268
  MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
15084
15269
  let pixelRatio = options.pixelRatio || 1;
15085
- if (leaf.isApp) {
15086
- scaleData.scaleX *= pixelRatio;
15087
- scaleData.scaleY *= pixelRatio;
15088
- pixelRatio = leaf.app.pixelRatio;
15089
- }
15090
- const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
15270
+ let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
15271
+ if (clip)
15272
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
15091
15273
  const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
15092
15274
  let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
15093
15275
  let sliceLeaf;
@@ -15388,31 +15570,31 @@ ${filterStyle}
15388
15570
  textScale *= 12 / text.fontSize;
15389
15571
  }
15390
15572
  this.textScale = textScale;
15391
- const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
15392
15573
  let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
15393
15574
  if (!this.inBody)
15394
15575
  x -= window.scrollX, y -= window.scrollY;
15395
- let { width, height } = text;
15576
+ let { width, height } = text, offsetX = 0, offsetY = 0;
15396
15577
  width *= textScale, height *= textScale;
15397
15578
  const data = text.__;
15398
15579
  if (data.__autoWidth && data.autoSizeAlign) {
15399
15580
  width += 20;
15400
15581
  switch (data.textAlign) {
15401
15582
  case 'center':
15402
- x -= width / 2;
15583
+ offsetX = -width / 2;
15403
15584
  break;
15404
- case 'right': x -= width;
15585
+ case 'right': offsetX = -width;
15405
15586
  }
15406
15587
  }
15407
15588
  if (data.__autoHeight && data.autoSizeAlign) {
15408
15589
  height += 20;
15409
15590
  switch (data.verticalAlign) {
15410
15591
  case 'middle':
15411
- y -= height / 2;
15592
+ offsetY = -height / 2;
15412
15593
  break;
15413
- case 'bottom': y -= height;
15594
+ case 'bottom': offsetY = -height;
15414
15595
  }
15415
15596
  }
15597
+ const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale).translateInner(offsetX, offsetY);
15416
15598
  const { style } = this.editDom;
15417
15599
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
15418
15600
  style.left = x + 'px';
@@ -15425,6 +15607,8 @@ ${filterStyle}
15425
15607
  const { editTarget: text, editor, editDom: dom } = this;
15426
15608
  if (text) {
15427
15609
  this.onInput();
15610
+ if (text.text === '\n')
15611
+ text.text = '';
15428
15612
  text.textEditing = undefined;
15429
15613
  if (editor.app)
15430
15614
  editor.app.config.keyEvent = this._keyEvent;
@@ -15513,6 +15697,7 @@ ${filterStyle}
15513
15697
  exports.AutoBounds = AutoBounds;
15514
15698
  exports.BezierHelper = BezierHelper;
15515
15699
  exports.Bounds = Bounds;
15700
+ exports.BoundsEvent = BoundsEvent;
15516
15701
  exports.BoundsHelper = BoundsHelper;
15517
15702
  exports.BoxData = BoxData;
15518
15703
  exports.BranchHelper = BranchHelper;
@@ -15703,7 +15888,7 @@ ${filterStyle}
15703
15888
  exports.surfaceType = surfaceType;
15704
15889
  exports.tempBounds = tempBounds$1;
15705
15890
  exports.tempMatrix = tempMatrix;
15706
- exports.tempPoint = tempPoint$3;
15891
+ exports.tempPoint = tempPoint$2;
15707
15892
  exports.useCanvas = useCanvas;
15708
15893
  exports.useModule = useModule;
15709
15894
  exports.version = version;
@@ -15713,4 +15898,7 @@ ${filterStyle}
15713
15898
  return exports;
15714
15899
 
15715
15900
  })({});
15716
- //# sourceMappingURL=worker.js.map
15901
+
15902
+ function Leafer(opt) { return new LeaferUI.Leafer(opt); }
15903
+ Object.setPrototypeOf(Leafer, LeaferUI);
15904
+ Leafer.prototype = LeaferUI.Leafer.prototype;