@leafer/miniapp 2.0.0 → 2.0.2

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.
@@ -58,8 +58,8 @@ function isEmptyData(value) {
58
58
 
59
59
  const DataHelper = {
60
60
  default(t, defaultData) {
61
- assign$1(defaultData, t);
62
- assign$1(t, defaultData);
61
+ assign$2(defaultData, t);
62
+ assign$2(t, defaultData);
63
63
  return t;
64
64
  },
65
65
  assign(t, merge, exclude) {
@@ -67,9 +67,9 @@ const DataHelper = {
67
67
  Object.keys(merge).forEach(key => {
68
68
  var _a, _b;
69
69
  value = merge[key];
70
- if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$1(t[key], merge[key], exclude && exclude[key]);
70
+ if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object) return assign$2(t[key], merge[key], exclude && exclude[key]);
71
71
  if (exclude && key in exclude) {
72
- if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$1(t[key] = {}, merge[key], exclude[key]);
72
+ if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object) assign$2(t[key] = {}, merge[key], exclude[key]);
73
73
  return;
74
74
  }
75
75
  t[key] = merge[key];
@@ -95,7 +95,7 @@ const DataHelper = {
95
95
  }
96
96
  };
97
97
 
98
- const {assign: assign$1} = DataHelper;
98
+ const {assign: assign$2} = DataHelper;
99
99
 
100
100
  class LeafData {
101
101
  get __useNaturalRatio() {
@@ -410,7 +410,7 @@ function getMatrixData() {
410
410
 
411
411
  const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
412
412
 
413
- const {float: float$5} = MathHelper;
413
+ const {float: float$6} = MathHelper;
414
414
 
415
415
  const tempPoint$5 = {};
416
416
 
@@ -661,12 +661,12 @@ const MatrixHelper = {
661
661
  const cosR = c / scaleY;
662
662
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
663
663
  }
664
- const cosR = float$5(cos$6(rotation));
664
+ const cosR = float$6(cos$6(rotation));
665
665
  const sinR = sin$6(rotation);
666
- scaleX = float$5(scaleX), scaleY = float$5(scaleY);
667
- skewX = cosR ? float$5((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
668
- skewY = cosR ? float$5((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
669
- rotation = float$5(rotation / OneRadian);
666
+ scaleX = float$6(scaleX), scaleY = float$6(scaleY);
667
+ skewX = cosR ? float$6((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
668
+ skewY = cosR ? float$6((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
669
+ rotation = float$6(rotation / OneRadian);
670
670
  } else {
671
671
  scaleX = a;
672
672
  scaleY = d;
@@ -710,7 +710,7 @@ const MatrixHelper = {
710
710
 
711
711
  const M$b = MatrixHelper;
712
712
 
713
- const {float: float$4} = MathHelper;
713
+ const {float: float$5} = MathHelper;
714
714
 
715
715
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
716
716
 
@@ -851,7 +851,7 @@ const PointHelper = {
851
851
  return points;
852
852
  },
853
853
  isSame(t, point) {
854
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
854
+ return float$5(t.x) === float$5(point.x) && float$5(t.y) === float$5(point.y);
855
855
  },
856
856
  reset(t) {
857
857
  P$7.reset(t);
@@ -1206,7 +1206,7 @@ const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPo
1206
1206
 
1207
1207
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1208
1208
 
1209
- const {float: float$3, fourNumber: fourNumber$1} = MathHelper;
1209
+ const {float: float$4, fourNumber: fourNumber$1} = MathHelper;
1210
1210
 
1211
1211
  const {floor: floor$2, ceil: ceil$2} = Math;
1212
1212
 
@@ -1216,10 +1216,10 @@ const point$2 = {};
1216
1216
 
1217
1217
  const toPoint$5 = {};
1218
1218
 
1219
- const tempBounds$3 = {};
1219
+ const tempBounds$4 = {};
1220
1220
 
1221
1221
  const BoundsHelper = {
1222
- tempBounds: tempBounds$3,
1222
+ tempBounds: tempBounds$4,
1223
1223
  set(t, x = 0, y = 0, width = 0, height = 0) {
1224
1224
  t.x = x;
1225
1225
  t.y = y;
@@ -1288,9 +1288,9 @@ const BoundsHelper = {
1288
1288
  t.height *= scaleY;
1289
1289
  },
1290
1290
  tempToOuterOf(t, matrix) {
1291
- B.copy(tempBounds$3, t);
1292
- B.toOuterOf(tempBounds$3, matrix);
1293
- return tempBounds$3;
1291
+ B.copy(tempBounds$4, t);
1292
+ B.toOuterOf(tempBounds$4, matrix);
1293
+ return tempBounds$4;
1294
1294
  },
1295
1295
  getOuterOf(t, matrix) {
1296
1296
  t = Object.assign({}, t);
@@ -1348,9 +1348,9 @@ const BoundsHelper = {
1348
1348
  put(t, put, align = "center", putScale = 1, changeSize = true, to) {
1349
1349
  to || (to = put);
1350
1350
  if (isString(putScale)) putScale = B.getFitScale(t, put, putScale === "cover");
1351
- tempBounds$3.width = changeSize ? put.width *= putScale : put.width * putScale;
1352
- tempBounds$3.height = changeSize ? put.height *= putScale : put.height * putScale;
1353
- AlignHelper.toPoint(align, tempBounds$3, t, to, true, true);
1351
+ tempBounds$4.width = changeSize ? put.width *= putScale : put.width * putScale;
1352
+ tempBounds$4.height = changeSize ? put.height *= putScale : put.height * putScale;
1353
+ AlignHelper.toPoint(align, tempBounds$4, t, to, true, true);
1354
1354
  },
1355
1355
  getSpread(t, spread, side) {
1356
1356
  const n = {};
@@ -1381,10 +1381,10 @@ const BoundsHelper = {
1381
1381
  }
1382
1382
  },
1383
1383
  float(t, maxLength) {
1384
- t.x = float$3(t.x, maxLength);
1385
- t.y = float$3(t.y, maxLength);
1386
- t.width = float$3(t.width, maxLength);
1387
- t.height = float$3(t.height, maxLength);
1384
+ t.x = float$4(t.x, maxLength);
1385
+ t.y = float$4(t.y, maxLength);
1386
+ t.width = float$4(t.width, maxLength);
1387
+ t.height = float$4(t.height, maxLength);
1388
1388
  },
1389
1389
  add(t, bounds, isPoint) {
1390
1390
  right$4 = t.x + t.width;
@@ -1653,7 +1653,7 @@ class Bounds {
1653
1653
  }
1654
1654
  }
1655
1655
 
1656
- const tempBounds$2 = new Bounds;
1656
+ const tempBounds$3 = new Bounds;
1657
1657
 
1658
1658
  class AutoBounds {
1659
1659
  constructor(top, right, bottom, left, width, height) {
@@ -1727,7 +1727,7 @@ const Platform = {
1727
1727
  resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1728
1728
  const realWidth = max$5(floor$1(width + (xGap || 0)), 1), realHeight = max$5(floor$1(height + (yGap || 0)), 1);
1729
1729
  let interlaceX, interlaceY, interlaceOffset;
1730
- if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1730
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1731
1731
  const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1732
1732
  const ctx = canvas.getContext("2d");
1733
1733
  if (opacity) ctx.globalAlpha = opacity;
@@ -1897,7 +1897,10 @@ const UICreator = {
1897
1897
  list$3[tag] = UI;
1898
1898
  },
1899
1899
  get(tag, data, x, y, width, height) {
1900
- if (!list$3[tag]) debug$h.error("not register " + tag);
1900
+ if (!list$3[tag]) {
1901
+ debug$h.warn("not register " + tag);
1902
+ return undefined;
1903
+ }
1901
1904
  const ui = new list$3[tag](data);
1902
1905
  if (!isUndefined(x)) {
1903
1906
  ui.x = x;
@@ -2931,7 +2934,7 @@ const PathCommandNodeHelper = {
2931
2934
  }
2932
2935
  };
2933
2936
 
2934
- const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2937
+ const {M: M$9, m: m, L: L$9, l: l, H: H, h: h, V: V, v: v, C: C$7, c: c, S: S$1, s: s, Q: Q$6, q: q, T: T, t: t, A: A, a: a, Z: Z$7, z: z, N: N$5, D: D$6, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5} = PathCommandMap;
2935
2938
 
2936
2939
  const {rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1} = BezierHelper;
2937
2940
 
@@ -3064,10 +3067,10 @@ const PathConvert = {
3064
3067
  old[i + 2] += y;
3065
3068
  old[i + 3] += x;
3066
3069
  old[i + 4] += y;
3067
- command = S;
3070
+ command = S$1;
3068
3071
 
3069
- case S:
3070
- smooth = lastCommand === C$7 || lastCommand === S;
3072
+ case S$1:
3073
+ smooth = lastCommand === C$7 || lastCommand === S$1;
3071
3074
  x1 = smooth ? x * 2 - controlX : old[i + 1];
3072
3075
  y1 = smooth ? y * 2 - controlY : old[i + 2];
3073
3076
  controlX = old[i + 1];
@@ -3317,10 +3320,10 @@ const PathCommandDataHelper = {
3317
3320
  data.push(O$5, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3318
3321
  }
3319
3322
  },
3320
- arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3323
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
3321
3324
  if (!isUndefined(lastX)) {
3322
- const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3323
- radius = min$2(radius, min$2(d / 2, d / 2 * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3325
+ const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
3326
+ radius = min$2(radius, min$2(r, r * abs$8(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3324
3327
  }
3325
3328
  data.push(U$4, x1, y1, x2, y2, radius);
3326
3329
  },
@@ -3664,7 +3667,7 @@ const PathCorner = {
3664
3667
  let command, lastCommand, commandLen;
3665
3668
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3666
3669
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3667
- const len = data.length;
3670
+ const len = data.length, three = len === 9;
3668
3671
  const smooth = [];
3669
3672
  while (i < len) {
3670
3673
  command = data[i];
@@ -3676,7 +3679,7 @@ const PathCorner = {
3676
3679
  if (data[i] === L$5) {
3677
3680
  secondX = data[i + 1];
3678
3681
  secondY = data[i + 2];
3679
- smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3682
+ three ? smooth.push(M$5, startX, startY) : smooth.push(M$5, getCenterX(startX, secondX), getCenterY(startY, secondY));
3680
3683
  } else {
3681
3684
  smooth.push(M$5, startX, startY);
3682
3685
  }
@@ -3688,11 +3691,11 @@ const PathCorner = {
3688
3691
  i += 3;
3689
3692
  switch (data[i]) {
3690
3693
  case L$5:
3691
- arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3694
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
3692
3695
  break;
3693
3696
 
3694
3697
  case Z$3:
3695
- arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3698
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
3696
3699
  break;
3697
3700
 
3698
3701
  default:
@@ -3704,7 +3707,7 @@ const PathCorner = {
3704
3707
 
3705
3708
  case Z$3:
3706
3709
  if (lastCommand !== Z$3) {
3707
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3710
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
3708
3711
  smooth.push(Z$3);
3709
3712
  }
3710
3713
  i += 1;
@@ -3754,10 +3757,10 @@ function canvasPatch(drawer) {
3754
3757
  const FileHelper = {
3755
3758
  alphaPixelTypes: [ "png", "webp", "svg" ],
3756
3759
  upperCaseTypeMap: {},
3757
- mineType(type) {
3758
- if (!type || type.startsWith("image")) return type;
3760
+ mimeType(type, base = "image") {
3761
+ if (!type || type.startsWith(base)) return type;
3759
3762
  if (type === "jpg") type = "jpeg";
3760
- return "image/" + type;
3763
+ return base + "/" + type;
3761
3764
  },
3762
3765
  fileType(filename) {
3763
3766
  const l = filename.split(".");
@@ -3790,6 +3793,8 @@ const FileHelper = {
3790
3793
 
3791
3794
  const F$2 = FileHelper;
3792
3795
 
3796
+ F$2.mineType = F$2.mimeType;
3797
+
3793
3798
  F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
3794
3799
 
3795
3800
  const debug$c = Debug.get("TaskProcessor");
@@ -4034,6 +4039,9 @@ const debug$b = Debug.get("Resource");
4034
4039
 
4035
4040
  const Resource = {
4036
4041
  tasker: new TaskProcessor,
4042
+ queue: new TaskProcessor({
4043
+ parallel: 1
4044
+ }),
4037
4045
  map: {},
4038
4046
  get isComplete() {
4039
4047
  return R.tasker.isComplete;
@@ -4070,6 +4078,12 @@ const Resource = {
4070
4078
  R.set(key, value);
4071
4079
  return value;
4072
4080
  },
4081
+ loadFilm(_key, _format) {
4082
+ return undefined;
4083
+ },
4084
+ loadVideo(_key, _format) {
4085
+ return undefined;
4086
+ },
4073
4087
  destroy() {
4074
4088
  R.map = {};
4075
4089
  }
@@ -4080,12 +4094,10 @@ const R = Resource;
4080
4094
  const ImageManager = {
4081
4095
  maxRecycled: 10,
4082
4096
  recycledList: [],
4083
- patternTasker: new TaskProcessor({
4084
- parallel: 1
4085
- }),
4086
- get(config) {
4097
+ patternTasker: Resource.queue,
4098
+ get(config, type) {
4087
4099
  let image = Resource.get(config.url);
4088
- if (!image) Resource.set(config.url, image = Creator.image(config));
4100
+ if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
4089
4101
  image.use++;
4090
4102
  return image;
4091
4103
  },
@@ -4120,7 +4132,7 @@ const ImageManager = {
4120
4132
  if (config.format) return config.format === format;
4121
4133
  const {url: url} = config;
4122
4134
  if (url.startsWith("data:")) {
4123
- if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
4135
+ if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
4124
4136
  } else {
4125
4137
  if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
4126
4138
  }
@@ -4136,6 +4148,9 @@ const I$1 = ImageManager;
4136
4148
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
4137
4149
 
4138
4150
  class LeaferImage {
4151
+ get tag() {
4152
+ return "Image";
4153
+ }
4139
4154
  get url() {
4140
4155
  return this.config.url;
4141
4156
  }
@@ -4164,7 +4179,7 @@ class LeaferImage {
4164
4179
  if (!this.loading) {
4165
4180
  this.loading = true;
4166
4181
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
4167
- return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4182
+ return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4168
4183
  if (thumbSize) this.setThumbView(img);
4169
4184
  this.setView(img);
4170
4185
  }).catch(e => {
@@ -4238,6 +4253,9 @@ class LeaferImage {
4238
4253
  Platform.image.setPatternTransform(pattern, transform, paint);
4239
4254
  return pattern;
4240
4255
  }
4256
+ render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
4257
+ canvas.drawImage(this.view, x, y, width, height);
4258
+ }
4241
4259
  getLoadUrl(_thumbSize) {
4242
4260
  return this.url;
4243
4261
  }
@@ -4264,6 +4282,18 @@ class LeaferImage {
4264
4282
  }
4265
4283
  }
4266
4284
 
4285
+ class LeaferFilm extends LeaferImage {
4286
+ get tag() {
4287
+ return "Film";
4288
+ }
4289
+ }
4290
+
4291
+ class LeaferVideo extends LeaferImage {
4292
+ get tag() {
4293
+ return "Video";
4294
+ }
4295
+ }
4296
+
4267
4297
  function defineKey(target, key, descriptor, noConfigurable) {
4268
4298
  if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
4269
4299
  Object.defineProperty(target, key, descriptor);
@@ -6152,9 +6182,11 @@ const BranchRender = {
6152
6182
  if (this.__hasMask) {
6153
6183
  this.__renderMask(canvas, options);
6154
6184
  } else {
6185
+ let child;
6155
6186
  const {children: children} = this;
6156
6187
  for (let i = 0, len = children.length; i < len; i++) {
6157
- excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
6188
+ child = children[i];
6189
+ excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
6158
6190
  }
6159
6191
  }
6160
6192
  },
@@ -6635,6 +6667,7 @@ let Leaf = class Leaf {
6635
6667
  __drawHitPath(_canvas) {}
6636
6668
  __updateHitCanvas() {}
6637
6669
  __render(_canvas, _options) {}
6670
+ __renderComplex(_canvas, _options) {}
6638
6671
  __drawFast(_canvas, _options) {}
6639
6672
  __draw(_canvas, _options, _originCanvas) {}
6640
6673
  __clip(_canvas, _options) {}
@@ -6754,6 +6787,7 @@ let Branch = class Branch extends Leaf {
6754
6787
  this.add(item, index);
6755
6788
  noIndex || index++;
6756
6789
  }); else child = UICreator.get(child.tag, child);
6790
+ if (!child) return;
6757
6791
  }
6758
6792
  if (child.parent) child.parent.remove(child);
6759
6793
  child.parent = this;
@@ -6979,7 +7013,7 @@ class LeafLevelList {
6979
7013
  }
6980
7014
  }
6981
7015
 
6982
- const version = "2.0.0";
7016
+ const version = "2.0.2";
6983
7017
 
6984
7018
  class LeaferCanvas extends LeaferCanvasBase {
6985
7019
  get allowBackgroundColor() {
@@ -7084,8 +7118,6 @@ class LeaferCanvas extends LeaferCanvasBase {
7084
7118
  }
7085
7119
  }
7086
7120
 
7087
- const {mineType: mineType, fileType: fileType} = FileHelper;
7088
-
7089
7121
  Object.assign(Creator, {
7090
7122
  canvas: (options, manager) => new LeaferCanvas(options, manager),
7091
7123
  image: options => new LeaferImage(options)
@@ -7101,12 +7133,12 @@ function useCanvas(_canvasType, app) {
7101
7133
  };
7102
7134
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
7103
7135
  },
7104
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
7136
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
7105
7137
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
7106
7138
  quality: quality
7107
7139
  }),
7108
7140
  canvasSaveAs: (canvas, filePath, quality) => {
7109
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
7141
+ let data = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filePath)), quality);
7110
7142
  data = data.substring(data.indexOf("64,") + 3);
7111
7143
  return Platform.origin.download(data, filePath);
7112
7144
  },
@@ -7140,7 +7172,7 @@ function useCanvas(_canvasType, app) {
7140
7172
  });
7141
7173
  });
7142
7174
  },
7143
- loadImage(src) {
7175
+ loadImage(src, _crossOrigin, _leaferImage) {
7144
7176
  return new Promise((resolve, reject) => {
7145
7177
  const img = Platform.canvas.view.createImage();
7146
7178
  img.onload = () => {
@@ -7152,6 +7184,14 @@ function useCanvas(_canvasType, app) {
7152
7184
  img.src = Platform.image.getRealURL(src);
7153
7185
  });
7154
7186
  },
7187
+ loadContent(url, responseType = "text") {
7188
+ return new Promise((resolve, reject) => app.request({
7189
+ url: url,
7190
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
7191
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
7192
+ fail: reject
7193
+ }));
7194
+ },
7155
7195
  noRepeat: "repeat-x"
7156
7196
  };
7157
7197
  Platform.miniapp = {
@@ -7703,7 +7743,7 @@ class Renderer {
7703
7743
  getCellList() {
7704
7744
  return undefined;
7705
7745
  }
7706
- addBlock(block) {
7746
+ addBlock(block, _leafList) {
7707
7747
  if (!this.updateBlocks) this.updateBlocks = [];
7708
7748
  this.updateBlocks.push(block);
7709
7749
  }
@@ -7751,7 +7791,8 @@ class Renderer {
7751
7791
  __onLayoutEnd(event) {
7752
7792
  if (event.data) event.data.map(item => {
7753
7793
  let empty;
7754
- if (item.updatedList) item.updatedList.list.some(leaf => {
7794
+ const {updatedList: updatedList} = item;
7795
+ if (updatedList) updatedList.list.some(leaf => {
7755
7796
  empty = !leaf.__world.width || !leaf.__world.height;
7756
7797
  if (empty) {
7757
7798
  if (!leaf.isLeafer) debug$6.tip(leaf.innerName, ": empty");
@@ -7759,7 +7800,7 @@ class Renderer {
7759
7800
  }
7760
7801
  return empty;
7761
7802
  });
7762
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
7803
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
7763
7804
  });
7764
7805
  }
7765
7806
  emitRender(type, bounds, options) {
@@ -8146,16 +8187,16 @@ class UIData extends LeafData {
8146
8187
  return t.fill || t.stroke;
8147
8188
  }
8148
8189
  get __autoWidth() {
8149
- return !this._width;
8190
+ return this._width == null;
8150
8191
  }
8151
8192
  get __autoHeight() {
8152
- return !this._height;
8193
+ return this._height == null;
8153
8194
  }
8154
8195
  get __autoSide() {
8155
- return !this._width || !this._height;
8196
+ return this._width == null || this._height == null;
8156
8197
  }
8157
8198
  get __autoSize() {
8158
- return !this._width && !this._height;
8199
+ return this._width == null && this._height == null;
8159
8200
  }
8160
8201
  setVisible(value) {
8161
8202
  this._visible = value;
@@ -8367,13 +8408,16 @@ class TextData extends UIData {
8367
8408
  }
8368
8409
 
8369
8410
  class ImageData extends RectData {
8411
+ get __urlType() {
8412
+ return "image";
8413
+ }
8370
8414
  setUrl(value) {
8371
8415
  this.__setImageFill(value);
8372
8416
  this._url = value;
8373
8417
  }
8374
8418
  __setImageFill(value) {
8375
8419
  this.fill = value ? {
8376
- type: "image",
8420
+ type: this.__urlType,
8377
8421
  mode: "stretch",
8378
8422
  url: value
8379
8423
  } : undefined;
@@ -8873,7 +8917,10 @@ let Group = class Group extends UI {
8873
8917
  }
8874
8918
  toJSON(options) {
8875
8919
  const data = super.toJSON(options);
8876
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8920
+ if (!this.childlessJSON) {
8921
+ const children = data.children = [];
8922
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8923
+ }
8877
8924
  return data;
8878
8925
  }
8879
8926
  pick(_hitPoint, _options) {
@@ -9022,12 +9069,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9022
9069
  this.emitLeafer(LeaferEvent.STOP);
9023
9070
  }
9024
9071
  }
9025
- unlockLayout() {
9072
+ unlockLayout(updateLayout = true) {
9026
9073
  this.layouter.start();
9027
- this.updateLayout();
9074
+ if (updateLayout) this.updateLayout();
9028
9075
  }
9029
- lockLayout() {
9030
- this.updateLayout();
9076
+ lockLayout(updateLayout = true) {
9077
+ if (updateLayout) this.updateLayout();
9031
9078
  this.layouter.stop();
9032
9079
  }
9033
9080
  resize(size) {
@@ -10111,7 +10158,7 @@ class UIEvent extends Event {
10111
10158
  }
10112
10159
  }
10113
10160
 
10114
- const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$2, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
10161
+ const {min: min$1, max: max$3, abs: abs$7} = Math, {float: float$3, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
10115
10162
 
10116
10163
  const tempContent = new Bounds, tempDragBounds = new Bounds;
10117
10164
 
@@ -10151,8 +10198,8 @@ const DragBoundsHelper = {
10151
10198
  } else {
10152
10199
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
10153
10200
  }
10154
- move.x = float$2(move.x);
10155
- move.y = float$2(move.y);
10201
+ move.x = float$3(move.x);
10202
+ move.y = float$3(move.y);
10156
10203
  return move;
10157
10204
  },
10158
10205
  getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, lockRatio, change) {
@@ -10164,26 +10211,26 @@ const DragBoundsHelper = {
10164
10211
  let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
10165
10212
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
10166
10213
  if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10167
- aSize = float$2(tempContent.minX - tempDragBounds.minX);
10168
- bSize = float$2(tempDragBounds.maxX - tempContent.maxX);
10214
+ aSize = float$3(tempContent.minX - tempDragBounds.minX);
10215
+ bSize = float$3(tempDragBounds.maxX - tempContent.maxX);
10169
10216
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
10170
10217
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
10171
10218
  correctScaleX *= max$3(aScale, bScale);
10172
10219
  } else {
10173
10220
  if (scale.x < 0) {
10174
- if (float$2(minX(content) - minX(dragBounds)) <= 0 || float$2(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10221
+ if (float$3(minX(content) - minX(dragBounds)) <= 0 || float$3(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
10175
10222
  tempContent.unsign();
10176
10223
  }
10177
- aSize = float$2(tempDragBounds.minX - tempContent.minX);
10178
- bSize = float$2(tempContent.maxX - tempDragBounds.maxX);
10224
+ aSize = float$3(tempDragBounds.minX - tempContent.minX);
10225
+ bSize = float$3(tempContent.maxX - tempDragBounds.maxX);
10179
10226
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
10180
10227
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
10181
10228
  correctScaleX *= min$1(aScale, bScale);
10182
10229
  }
10183
10230
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
10184
10231
  if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10185
- aSize = float$2(tempContent.minY - tempDragBounds.minY);
10186
- bSize = float$2(tempDragBounds.maxY - tempContent.maxY);
10232
+ aSize = float$3(tempContent.minY - tempDragBounds.minY);
10233
+ bSize = float$3(tempDragBounds.maxY - tempContent.maxY);
10187
10234
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
10188
10235
  bScale = originBottomScale && bSize > 0 ? 1 + bSize / (originBottomScale * tempContent.height) : 1;
10189
10236
  correctScaleY *= max$3(aScale, bScale);
@@ -10194,11 +10241,11 @@ const DragBoundsHelper = {
10194
10241
  }
10195
10242
  } else {
10196
10243
  if (scale.y < 0) {
10197
- if (float$2(minY(content) - minY(dragBounds)) <= 0 || float$2(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10244
+ if (float$3(minY(content) - minY(dragBounds)) <= 0 || float$3(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10198
10245
  tempContent.unsign();
10199
10246
  }
10200
- aSize = float$2(tempDragBounds.minY - tempContent.minY);
10201
- bSize = float$2(tempContent.maxY - tempDragBounds.maxY);
10247
+ aSize = float$3(tempDragBounds.minY - tempContent.minY);
10248
+ bSize = float$3(tempContent.maxY - tempDragBounds.maxY);
10202
10249
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
10203
10250
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
10204
10251
  correctScaleY *= min$1(aScale, bScale);
@@ -10719,7 +10766,7 @@ function exclude(leaf, excludePath) {
10719
10766
  return excludePath && excludePath.has(leaf);
10720
10767
  }
10721
10768
 
10722
- const config$1 = {
10769
+ const config$2 = {
10723
10770
  wheel: {
10724
10771
  zoomSpeed: .5,
10725
10772
  moveSpeed: .5,
@@ -10793,7 +10840,7 @@ class InteractionBase {
10793
10840
  return this.p.hitRadius;
10794
10841
  }
10795
10842
  constructor(target, canvas, selector, userConfig) {
10796
- this.config = DataHelper.clone(config$1);
10843
+ this.config = DataHelper.clone(config$2);
10797
10844
  this.tapCount = 0;
10798
10845
  this.downKeyMap = {};
10799
10846
  this.target = target;
@@ -10820,6 +10867,7 @@ class InteractionBase {
10820
10867
  this.checkPath(data, useDefaultPath);
10821
10868
  this.downTime = Date.now();
10822
10869
  this.emit(PointerEvent.BEFORE_DOWN, data);
10870
+ if (data.path.needUpdate) this.updateDownData(data);
10823
10871
  this.emit(PointerEvent.DOWN, data);
10824
10872
  if (PointerButton.left(data)) {
10825
10873
  this.tapWait();
@@ -11313,8 +11361,8 @@ ui$5.__updateHitCanvas = function() {
11313
11361
  if (isHitPixel) {
11314
11362
  const {renderBounds: renderBounds} = this.__layout;
11315
11363
  const size = Platform.image.hitCanvasSize;
11316
- const scale = h.hitScale = tempBounds$2.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11317
- const {x: x, y: y, width: width, height: height} = tempBounds$2.set(renderBounds).scale(scale);
11364
+ const scale = h.hitScale = tempBounds$3.set(0, 0, size, size).getFitMatrix(renderBounds).a;
11365
+ const {x: x, y: y, width: width, height: height} = tempBounds$3.set(renderBounds).scale(scale);
11318
11366
  h.resize({
11319
11367
  width: width,
11320
11368
  height: height,
@@ -11374,13 +11422,13 @@ ui$5.__hit = function(inner, forceHitFill) {
11374
11422
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
11375
11423
  };
11376
11424
 
11377
- const ui$4 = UI.prototype, rect = Rect.prototype, box$2 = Box.prototype;
11425
+ const ui$4 = UI.prototype, rect = Rect.prototype, box$3 = Box.prototype;
11378
11426
 
11379
- rect.__updateHitCanvas = box$2.__updateHitCanvas = function() {
11427
+ rect.__updateHitCanvas = box$3.__updateHitCanvas = function() {
11380
11428
  if (this.stroke || this.cornerRadius || (this.fill || this.__.__isCanvas) && this.hitFill === "pixel" || this.hitStroke === "all") ui$4.__updateHitCanvas.call(this); else if (this.__hitCanvas) this.__hitCanvas = null;
11381
11429
  };
11382
11430
 
11383
- rect.__hitFill = box$2.__hitFill = function(inner) {
11431
+ rect.__hitFill = box$3.__hitFill = function(inner) {
11384
11432
  return this.__hitCanvas ? ui$4.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
11385
11433
  };
11386
11434
 
@@ -11412,8 +11460,8 @@ canvas$1.hitStroke = function(point, strokeWidth) {
11412
11460
  canvas$1.hitPixel = function(radiusPoint, offset, scale = 1) {
11413
11461
  let {x: x, y: y, radiusX: radiusX, radiusY: radiusY} = radiusPoint;
11414
11462
  if (offset) x -= offset.x, y -= offset.y;
11415
- tempBounds$2.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11416
- const {data: data} = this.context.getImageData(tempBounds$2.x, tempBounds$2.y, tempBounds$2.width || 1, tempBounds$2.height || 1);
11463
+ tempBounds$3.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
11464
+ const {data: data} = this.context.getImageData(tempBounds$3.x, tempBounds$3.y, tempBounds$3.width || 1, tempBounds$3.height || 1);
11417
11465
  for (let i = 0, len = data.length; i < len; i += 4) {
11418
11466
  if (data[i + 3] > 0) return true;
11419
11467
  }
@@ -11728,14 +11776,14 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
11728
11776
 
11729
11777
  const {getSpread: getSpread, copyAndSpread: copyAndSpread$1, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$7, getIntersectData: getIntersectData} = BoundsHelper;
11730
11778
 
11731
- const tempBounds$1 = {};
11779
+ const tempBounds$2 = {};
11732
11780
 
11733
11781
  function shape(ui, current, options) {
11734
11782
  const canvas = current.getSameCanvas();
11735
11783
  const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
11736
11784
  const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
11737
- toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$1, layout.boxBounds, layout.strokeSpread),
11738
- tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11785
+ toOuterOf(layout.strokeSpread ? (copyAndSpread$1(tempBounds$2, layout.boxBounds, layout.strokeSpread),
11786
+ tempBounds$2) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
11739
11787
  let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
11740
11788
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11741
11789
  if (currentBounds.includes(nowWorldShapeBounds)) {
@@ -11829,11 +11877,14 @@ function compute(attrName, ui) {
11829
11877
  function getLeafPaint(attrName, paint, ui) {
11830
11878
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11831
11879
  let leafPaint;
11832
- const {boxBounds: boxBounds} = ui.__layout;
11833
- switch (paint.type) {
11880
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
11881
+ switch (type) {
11834
11882
  case "image":
11883
+ case "film":
11884
+ case "video":
11835
11885
  if (!paint.url) return undefined;
11836
11886
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11887
+ if (type !== "image") PaintImage[type](leafPaint);
11837
11888
  break;
11838
11889
 
11839
11890
  case "linear":
@@ -11849,7 +11900,7 @@ function getLeafPaint(attrName, paint, ui) {
11849
11900
  break;
11850
11901
 
11851
11902
  case "solid":
11852
- const {type: type, color: color, opacity: opacity} = paint;
11903
+ const {color: color, opacity: opacity} = paint;
11853
11904
  leafPaint = {
11854
11905
  type: type,
11855
11906
  style: ColorConvert.string(color, opacity)
@@ -11887,13 +11938,13 @@ const PaintModule = {
11887
11938
  shape: shape
11888
11939
  };
11889
11940
 
11890
- let cache$1, box$1 = new Bounds;
11941
+ let cache$1, box$2 = new Bounds;
11891
11942
 
11892
11943
  const {isSame: isSame} = BoundsHelper;
11893
11944
 
11894
11945
  function image(ui, attrName, paint, boxBounds, firstUse) {
11895
11946
  let leafPaint, event;
11896
- const image = ImageManager.get(paint);
11947
+ const image = ImageManager.get(paint, paint.type);
11897
11948
  if (cache$1 && paint === cache$1.paint && isSame(boxBounds, cache$1.boxBounds)) {
11898
11949
  leafPaint = cache$1.leafPaint;
11899
11950
  } else {
@@ -11905,7 +11956,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11905
11956
  cache$1 = image.use > 1 ? {
11906
11957
  leafPaint: leafPaint,
11907
11958
  paint: paint,
11908
- boxBounds: box$1.set(boxBounds)
11959
+ boxBounds: box$2.set(boxBounds)
11909
11960
  } : null;
11910
11961
  }
11911
11962
  if (firstUse || image.loading) event = {
@@ -11954,8 +12005,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11954
12005
  }
11955
12006
 
11956
12007
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11957
- if (attrName === "fill" && !ui.__.__naturalWidth) {
11958
- const data = ui.__;
12008
+ const data = ui.__;
12009
+ if (attrName === "fill" && !data.__naturalWidth) {
11959
12010
  data.__naturalWidth = image.width / data.pixelRatio;
11960
12011
  data.__naturalHeight = image.height / data.pixelRatio;
11961
12012
  if (data.__autoSide) {
@@ -11967,7 +12018,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
11967
12018
  return false;
11968
12019
  }
11969
12020
  }
11970
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
12021
+ if (!leafPaint.data) {
12022
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
12023
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
12024
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
12025
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
12026
+ }
11971
12027
  return true;
11972
12028
  }
11973
12029
 
@@ -12010,7 +12066,7 @@ function getPatternData(paint, box, image) {
12010
12066
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
12011
12067
  if (paint.mode === "strench") paint.mode = "stretch";
12012
12068
  const {width: width, height: height} = image;
12013
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
12069
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
12014
12070
  const sameBox = box.width === width && box.height === height;
12015
12071
  const data = {
12016
12072
  mode: mode
@@ -12073,8 +12129,6 @@ function getPatternData(paint, box, image) {
12073
12129
  data.scaleX = scaleX;
12074
12130
  data.scaleY = scaleY;
12075
12131
  }
12076
- if (opacity && opacity < 1) data.opacity = opacity;
12077
- if (filters) data.filters = filters;
12078
12132
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
12079
12133
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
12080
12134
  type: "x",
@@ -12105,7 +12159,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
12105
12159
 
12106
12160
  function stretchMode(data, box, scaleX, scaleY) {
12107
12161
  const transform = get$2(), {x: x, y: y} = box;
12108
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
12162
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
12109
12163
  scaleHelper(transform, scaleX, scaleY);
12110
12164
  data.transform = transform;
12111
12165
  }
@@ -12194,10 +12248,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
12194
12248
  }
12195
12249
 
12196
12250
  function createPattern(paint, ui, canvas, renderOptions) {
12197
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
12251
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12198
12252
  if (paint.patternId !== id && !ui.destroyed) {
12199
12253
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
12200
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12254
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12201
12255
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
12202
12256
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
12203
12257
  width *= scaleX;
@@ -12213,7 +12267,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12213
12267
  if (transform) copy$4(imageMatrix, transform);
12214
12268
  scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
12215
12269
  }
12216
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12270
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12217
12271
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12218
12272
  paint.style = pattern;
12219
12273
  paint.patternId = id;
@@ -12234,15 +12288,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
12234
12288
  }
12235
12289
 
12236
12290
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12237
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
12291
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12238
12292
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
12239
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
12293
+ if (!data || paint.patternId === id && !exporting || snapshot) {
12240
12294
  return false;
12241
12295
  } else {
12242
12296
  if (drawImage) {
12243
12297
  if (data.repeat) {
12244
12298
  drawImage = false;
12245
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12299
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12246
12300
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
12247
12301
  }
12248
12302
  }
@@ -12260,20 +12314,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12260
12314
  }
12261
12315
  }
12262
12316
 
12263
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
12264
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
12265
- let {width: width, height: height} = image, clipUI;
12266
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
12317
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
12318
+ const {data: data, image: image, complex: complex} = paint;
12319
+ let {width: width, height: height} = image;
12320
+ if (complex) {
12321
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
12267
12322
  canvas.save();
12268
- clipUI && canvas.clipUI(ui);
12323
+ complex === 2 && canvas.clipUI(ui);
12269
12324
  blendMode && (canvas.blendMode = blendMode);
12270
12325
  opacity && (canvas.opacity *= opacity);
12271
12326
  transform && canvas.transform(transform);
12272
- canvas.drawImage(view, 0, 0, width, height);
12327
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12273
12328
  canvas.restore();
12274
12329
  } else {
12275
12330
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
12276
- canvas.drawImage(view, 0, 0, width, height);
12331
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12277
12332
  }
12278
12333
  }
12279
12334
 
@@ -12441,7 +12496,7 @@ const PaintGradientModule = {
12441
12496
 
12442
12497
  const {copy: copy$3, move: move$6, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max$2, abs: abs$5} = Math;
12443
12498
 
12444
- const tempBounds = {}, tempMatrix = new Matrix;
12499
+ const tempBounds$1 = {}, tempMatrix = new Matrix;
12445
12500
 
12446
12501
  const offsetOutBounds$1 = {};
12447
12502
 
@@ -12508,9 +12563,9 @@ function drawWorldShadow(canvas, outBounds, shape) {
12508
12563
  const {shapeBounds: shapeBounds} = shape;
12509
12564
  let from, to;
12510
12565
  if (Platform.fullImageShadow) {
12511
- copy$3(tempBounds, canvas.bounds);
12512
- move$6(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12513
- from = canvas.bounds, to = tempBounds;
12566
+ copy$3(tempBounds$1, canvas.bounds);
12567
+ move$6(tempBounds$1, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
12568
+ from = canvas.bounds, to = tempBounds$1;
12514
12569
  } else {
12515
12570
  from = shapeBounds, to = outBounds;
12516
12571
  }
@@ -12993,7 +13048,7 @@ function layoutText(drawData, style) {
12993
13048
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12994
13049
  let starY = __baseLine;
12995
13050
  if (__clipText && realHeight > height) {
12996
- realHeight = Math.max(height, __lineHeight);
13051
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
12997
13052
  if (countRows > 1) drawData.overflow = countRows;
12998
13053
  } else if (height || autoSizeAlign) {
12999
13054
  switch (verticalAlign) {
@@ -13050,10 +13105,10 @@ function layoutText(drawData, style) {
13050
13105
  }
13051
13106
 
13052
13107
  function clipText(drawData, style, x, width) {
13053
- if (!width) return;
13054
13108
  const {rows: rows, overflow: overflow} = drawData;
13055
13109
  let {textOverflow: textOverflow} = style;
13056
- rows.splice(overflow);
13110
+ if (overflow) rows.splice(overflow);
13111
+ if (!width) return;
13057
13112
  if (textOverflow && textOverflow !== "show") {
13058
13113
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
13059
13114
  let char, charRight;
@@ -13378,8 +13433,13 @@ class Stroker extends UI {
13378
13433
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
13379
13434
  }
13380
13435
  data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
13436
+ if (data.shadow) {
13437
+ const shadow = data.shadow[0], {scaleX: scaleX, scaleY: scaleY} = this.getRenderScaleData(true, shadow.scaleFixed);
13438
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
13439
+ }
13381
13440
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
13382
13441
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
13442
+ if (data.shadow) canvas.restore();
13383
13443
  }
13384
13444
  }
13385
13445
  data.strokeWidth = strokeWidth;
@@ -13559,6 +13619,7 @@ class EditSelect extends Group {
13559
13619
  } else {
13560
13620
  editor.target = find;
13561
13621
  }
13622
+ e.path.needUpdate = true;
13562
13623
  } else if (this.allow(e.target)) {
13563
13624
  if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
13564
13625
  }
@@ -14543,7 +14604,7 @@ const rotateSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/s
14543
14604
 
14544
14605
  const skewSVG = `\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${filterStyle$1}\n</filter>\n</defs>\n</svg>\n`;
14545
14606
 
14546
- const config = {
14607
+ const config$1 = {
14547
14608
  editSize: "size",
14548
14609
  keyEvent: true,
14549
14610
  stroke: "#836DFF",
@@ -14777,6 +14838,7 @@ class SimulateElement extends Rect {
14777
14838
  this.checkChange = true;
14778
14839
  this.canChange = true;
14779
14840
  this.visible = this.hittable = false;
14841
+ this.skipJSON = true;
14780
14842
  this.on(PropertyEvent.CHANGE, event => {
14781
14843
  if (this.checkChange && checkMap[event.attrName]) {
14782
14844
  const {attrName: attrName, newValue: newValue, oldValue: oldValue} = event;
@@ -15188,7 +15250,7 @@ let Editor = class Editor extends Group {
15188
15250
  this.selector = new EditSelect(this);
15189
15251
  this.editMask = new EditMask(this);
15190
15252
  this.targetEventIds = [];
15191
- let mergedConfig = DataHelper.clone(config);
15253
+ let mergedConfig = DataHelper.clone(config$1);
15192
15254
  if (userConfig) mergedConfig = DataHelper.default(userConfig, mergedConfig);
15193
15255
  this.mergedConfig = this.config = mergedConfig;
15194
15256
  this.addMany(this.editMask, this.selector, this.editBox);
@@ -15470,7 +15532,10 @@ class InnerEditor {
15470
15532
  return "focus";
15471
15533
  }
15472
15534
  get editBox() {
15473
- return this.editor.editBox;
15535
+ return this._editBox || this.editor.editBox;
15536
+ }
15537
+ set editBox(value) {
15538
+ this._editBox = value;
15474
15539
  }
15475
15540
  constructor(editor) {
15476
15541
  this.eventIds = [];
@@ -15661,7 +15726,7 @@ let LineEditTool = class LineEditTool extends EditTool {
15661
15726
  onSkew(_e) {}
15662
15727
  onUpdate() {
15663
15728
  const {editBox: editBox} = this, {rotatePoints: rotatePoints, resizeLines: resizeLines, resizePoints: resizePoints, rect: rect} = editBox;
15664
- const line = this.editor.element;
15729
+ const line = editBox.target;
15665
15730
  let fromTo, leftOrRight;
15666
15731
  if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path); else if (line.points) fromTo = this.getFromToByPoints(line.__.points);
15667
15732
  if (fromTo) {
@@ -15976,9 +16041,14 @@ function addViewport(leafer, mergeConfig, custom) {
15976
16041
  }), leafer.on_(MoveEvent.END, e => {
15977
16042
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
15978
16043
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
15979
- const {zoomLayer: zoomLayer} = leafer;
16044
+ const {zoomLayer: zoomLayer, layouter: layouter} = leafer;
15980
16045
  const changeScale = leafer.getValidScale(e.scale);
15981
- if (changeScale !== 1) zoomLayer.scaleOfWorld(e, changeScale);
16046
+ if (changeScale !== 1) {
16047
+ layouter.stop();
16048
+ LeafHelper.updateMatrix(leafer);
16049
+ zoomLayer.scaleOfWorld(e, changeScale);
16050
+ layouter.start();
16051
+ }
15982
16052
  }));
15983
16053
  }
15984
16054
 
@@ -17563,7 +17633,7 @@ function autoBoundsType(defaultValue) {
17563
17633
 
17564
17634
  Plugin.add("flow", "resize");
17565
17635
 
17566
- const box = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17636
+ const box$1 = Box.prototype, {__updateBoxBounds: __updateBoxBounds} = Group.prototype;
17567
17637
 
17568
17638
  UI.addAttr("flow", false, autoLayoutType);
17569
17639
 
@@ -17585,7 +17655,7 @@ UI.addAttr("autoBox", undefined, boundsType);
17585
17655
 
17586
17656
  const {copyAndSpread: copyAndSpread} = BoundsHelper;
17587
17657
 
17588
- box.__updateFlowLayout = function() {
17658
+ box$1.__updateFlowLayout = function() {
17589
17659
  const {leaferIsCreated: leaferIsCreated, flow: flow} = this;
17590
17660
  if (leaferIsCreated) this.leafer.created = false;
17591
17661
  switch (flow) {
@@ -17609,7 +17679,7 @@ box.__updateFlowLayout = function() {
17609
17679
  if (leaferIsCreated) this.leafer.created = true;
17610
17680
  };
17611
17681
 
17612
- box.__updateContentBounds = function() {
17682
+ box$1.__updateContentBounds = function() {
17613
17683
  const {padding: padding} = this.__;
17614
17684
  const layout = this.__layout;
17615
17685
  const same = layout.contentBounds === layout.boxBounds;
@@ -17621,7 +17691,7 @@ box.__updateContentBounds = function() {
17621
17691
  }
17622
17692
  };
17623
17693
 
17624
- box.__updateBoxBounds = function(secondLayout) {
17694
+ box$1.__updateBoxBounds = function(secondLayout) {
17625
17695
  if (this.children.length && !this.pathInputed) {
17626
17696
  const data = this.__, {flow: flow} = data;
17627
17697
  if (data.__autoSide) {
@@ -18423,7 +18493,7 @@ const hslMatch = /^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i;
18423
18493
 
18424
18494
  const hslaMatch = /^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i;
18425
18495
 
18426
- const int = parseInt, float$1 = parseFloat, {round: round$1} = Math;
18496
+ const int = parseInt, float$2 = parseFloat, {round: round$1} = Math;
18427
18497
 
18428
18498
  let cache = {}, totalCache = 0;
18429
18499
 
@@ -18536,18 +18606,18 @@ function rgbaToRGBA(color) {
18536
18606
  r: int(match[1]),
18537
18607
  g: int(match[2]),
18538
18608
  b: int(match[3]),
18539
- a: float$1(match[4])
18609
+ a: float$2(match[4])
18540
18610
  };
18541
18611
  }
18542
18612
 
18543
18613
  function hslToRGBA(color) {
18544
18614
  const match = hslMatch.exec(color);
18545
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), 1);
18615
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), 1);
18546
18616
  }
18547
18617
 
18548
18618
  function hslaToRGBA(color) {
18549
18619
  const match = hslaMatch.exec(color);
18550
- return hsla(float$1(match[1]), float$1(match[2]), float$1(match[3]), float$1(match[4]));
18620
+ return hsla(float$2(match[1]), float$2(match[2]), float$2(match[3]), float$2(match[4]));
18551
18621
  }
18552
18622
 
18553
18623
  const n1 = 1 / 6, n2 = .5, n3 = 2 / 3, n4 = 1 / 3;
@@ -18786,7 +18856,7 @@ const HighBezierHelper = {
18786
18856
 
18787
18857
  const {getDistance: getDistance} = HighBezierHelper;
18788
18858
 
18789
- const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float} = MathHelper;
18859
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap, {float: float$1} = MathHelper;
18790
18860
 
18791
18861
  const tempPoint = {}, tempFrom = {};
18792
18862
 
@@ -18941,7 +19011,7 @@ const HighCurveHelper = {
18941
19011
  tempFrom.y = y;
18942
19012
  to.x = toX;
18943
19013
  to.y = toY;
18944
- cutDistance = float(motionDistance - total);
19014
+ cutDistance = float$1(motionDistance - total);
18945
19015
  if (cutDistance) {
18946
19016
  PointHelper.getDistancePoint(tempFrom, to, cutDistance, true);
18947
19017
  path.push(command, to.x, to.y);
@@ -18960,7 +19030,7 @@ const HighCurveHelper = {
18960
19030
  toY = data[i + 6];
18961
19031
  distance = segments[index];
18962
19032
  if (total + distance > motionDistance) {
18963
- cutDistance = float(motionDistance - total);
19033
+ cutDistance = float$1(motionDistance - total);
18964
19034
  if (cutDistance) {
18965
19035
  t = HighBezierHelper.getT(cutDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
18966
19036
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
@@ -19179,21 +19249,21 @@ function getStyle(leaf) {
19179
19249
  const style = {}, button = findParentButton(leaf);
19180
19250
  const state = button ? leaf.state || button.state : leaf.state;
19181
19251
  const stateStyle = state && leaf.states[state];
19182
- if (stateStyle && State.isState(state, leaf, button)) exist = assign(style, stateStyle);
19252
+ if (stateStyle && State.isState(state, leaf, button)) exist = assign$1(style, stateStyle);
19183
19253
  const selectedStyle = style.selectedStyle || leaf.selectedStyle;
19184
- if (selectedStyle && State.isSelected(leaf, button)) exist = assign(style, selectedStyle);
19254
+ if (selectedStyle && State.isSelected(leaf, button)) exist = assign$1(style, selectedStyle);
19185
19255
  const placeholderStyle = style.placeholderStyle || leaf.placeholderStyle;
19186
- if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign(style, placeholderStyle);
19256
+ if (placeholderStyle && State.isPlacehold(leaf, button)) exist = assign$1(style, placeholderStyle);
19187
19257
  if (State.isDisabled(leaf, button)) {
19188
19258
  const disabledStyle = style.disabledStyle || leaf.disabledStyle;
19189
- if (disabledStyle) exist = assign(style, disabledStyle);
19259
+ if (disabledStyle) exist = assign$1(style, disabledStyle);
19190
19260
  } else {
19191
19261
  const focusStyle = style.focusStyle || leaf.focusStyle;
19192
- if (focusStyle && State.isFocus(leaf, button)) exist = assign(style, focusStyle);
19262
+ if (focusStyle && State.isFocus(leaf, button)) exist = assign$1(style, focusStyle);
19193
19263
  const hoverStyle = style.hoverStyle || leaf.hoverStyle;
19194
- if (hoverStyle && State.isHover(leaf, button)) exist = assign(style, hoverStyle);
19264
+ if (hoverStyle && State.isHover(leaf, button)) exist = assign$1(style, hoverStyle);
19195
19265
  const pressStyle = style.pressStyle || leaf.pressStyle;
19196
- if (pressStyle && State.isPress(leaf, button)) exist = assign(style, pressStyle);
19266
+ if (pressStyle && State.isPress(leaf, button)) exist = assign$1(style, pressStyle);
19197
19267
  }
19198
19268
  return exist ? style : undefined;
19199
19269
  }
@@ -19224,7 +19294,7 @@ function getTransition(type, style, data) {
19224
19294
  return isNull(style[name]) ? data[name] : style[name];
19225
19295
  }
19226
19296
 
19227
- function assign(style, stateStyle) {
19297
+ function assign$1(style, stateStyle) {
19228
19298
  Object.assign(style, stateStyle);
19229
19299
  return true;
19230
19300
  }
@@ -19494,6 +19564,9 @@ let Robot = class Robot extends UI {
19494
19564
  constructor(data) {
19495
19565
  super(data);
19496
19566
  }
19567
+ togglePlay() {
19568
+ this.running ? this.pause() : this.play();
19569
+ }
19497
19570
  play() {
19498
19571
  this.running = true;
19499
19572
  }
@@ -20045,4 +20118,258 @@ Plugin.add("bright");
20045
20118
 
20046
20119
  UI.addAttr("bright", false, dimType);
20047
20120
 
20048
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
20121
+ const config = {
20122
+ theme: "light",
20123
+ style: {
20124
+ dragBoundsType: "outer",
20125
+ strokeAlign: "center",
20126
+ strokeWidthFixed: "zoom-in",
20127
+ width: 6,
20128
+ height: 6,
20129
+ opacity: .5,
20130
+ cornerRadius: 3,
20131
+ hoverStyle: {
20132
+ opacity: .6
20133
+ },
20134
+ pressStyle: {
20135
+ opacity: .66
20136
+ }
20137
+ },
20138
+ size: 6,
20139
+ endsMargin: 2,
20140
+ sideMargin: 2,
20141
+ minSize: 10,
20142
+ scaleFixed: "zoom-in",
20143
+ scrollType: "both",
20144
+ hideOnActionEnd: "hover"
20145
+ };
20146
+
20147
+ const tempBounds = new Bounds, {float: float} = MathHelper, {clone: clone, assign: assign} = DataHelper;
20148
+
20149
+ class Scroller extends Group {
20150
+ get canUse() {
20151
+ return this.target.hasScroller;
20152
+ }
20153
+ constructor(target) {
20154
+ super();
20155
+ this.targetWorldBounds = new Bounds;
20156
+ this.viewportBounds = new Bounds;
20157
+ this.contentBounds = new Bounds;
20158
+ this.scrollXBounds = new Bounds;
20159
+ this.scrollYBounds = new Bounds;
20160
+ this.target = target;
20161
+ this.config = clone(config);
20162
+ this.updateConfig();
20163
+ this.__listenEvents();
20164
+ target.waitLeafer(() => {
20165
+ this.parent = target;
20166
+ this.__bindLeafer(target.leafer);
20167
+ });
20168
+ if (this.mergedConfig.hideOnActionEnd) this.opacity = 0;
20169
+ }
20170
+ static registerTheme(theme, themeConfig) {
20171
+ S.themeMap[theme] = themeConfig;
20172
+ }
20173
+ static getTheme(theme) {
20174
+ return theme && S.themeMap[theme];
20175
+ }
20176
+ static hasTheme(theme) {
20177
+ return theme && !!S.themeMap[theme];
20178
+ }
20179
+ updateConfig() {
20180
+ const {scrollConfig: scrollConfig} = this.target;
20181
+ const themeConfig = S.getTheme(scrollConfig && S.hasTheme(scrollConfig.theme) && scrollConfig.theme || this.config.theme);
20182
+ const mergedConfig = this.mergedConfig = clone(this.config);
20183
+ assign(mergedConfig, themeConfig);
20184
+ if (scrollConfig) assign(mergedConfig, scrollConfig);
20185
+ this.updateStyle(mergedConfig.style);
20186
+ }
20187
+ updateStyle(style) {
20188
+ if (!this.scrollXBar) this.addMany(this.scrollXBar = new Box, this.scrollYBar = new Box);
20189
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20190
+ scrollXBar.set(style);
20191
+ scrollYBar.set(style);
20192
+ scrollXBar.draggable = "x";
20193
+ scrollYBar.draggable = "y";
20194
+ }
20195
+ update(check = true) {
20196
+ if (this.dragScrolling) return;
20197
+ const {target: target, targetOverflow: targetOverflow, targetWorldBounds: targetWorldBounds, viewportBounds: viewportBounds, contentBounds: contentBounds} = this, layout = target.__layout, {overflow: overflow} = target.__;
20198
+ const {childrenRenderBounds: childrenRenderBounds} = layout;
20199
+ const {boxBounds: boxBounds, worldBoxBounds: worldBoxBounds} = layout;
20200
+ const isSameWorldBounds = check && targetOverflow === overflow && targetWorldBounds.isSame(worldBoxBounds);
20201
+ const isSameConfig = layout.scrollConfigChanged ? (this.updateConfig(), layout.scrollConfigChanged = false) : true;
20202
+ const nowContentBounds = tempBounds.set(viewportBounds).add(childrenRenderBounds);
20203
+ if (isSameWorldBounds && isSameConfig && contentBounds.isSame(nowContentBounds)) return;
20204
+ this.targetOverflow = overflow;
20205
+ viewportBounds.set(boxBounds);
20206
+ targetWorldBounds.set(worldBoxBounds);
20207
+ contentBounds.set(nowContentBounds);
20208
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this, {size: size, endsMargin: endsMargin, minSize: minSize} = this.mergedConfig, {width: width, height: height} = viewportBounds;
20209
+ this.contentRealX = contentBounds.x - target.scrollX;
20210
+ this.contentRealY = contentBounds.y - target.scrollY;
20211
+ this.ratioX = viewportBounds.width / contentBounds.width;
20212
+ this.ratioY = viewportBounds.height / contentBounds.height;
20213
+ const min = size + endsMargin * 2 + minSize;
20214
+ scrollXBar.visible = float(contentBounds.width) > float(width) && overflow !== "y-scroll" && width > min;
20215
+ scrollYBar.visible = float(contentBounds.height) > float(height) && overflow !== "x-scroll" && height > min;
20216
+ this.updateScrollBar();
20217
+ }
20218
+ updateScrollBar() {
20219
+ const {target: target, viewportBounds: viewportBounds, contentBounds: contentBounds, ratioX: ratioX, ratioY: ratioY, scrollXBar: scrollXBar, scrollYBar: scrollYBar, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20220
+ let {size: size, cornerRadius: cornerRadius, endsMargin: endsMargin, sideMargin: sideMargin, minSize: minSize, scaleFixed: scaleFixed, scrollType: scrollType} = this.mergedConfig;
20221
+ const scale = scaleFixed ? target.getClampRenderScale() : 1;
20222
+ endsMargin /= scale;
20223
+ sideMargin /= scale;
20224
+ size /= scale;
20225
+ if (isUndefined(cornerRadius)) cornerRadius = size / 2;
20226
+ if (scrollXBar.visible) {
20227
+ scrollXBounds.set(viewportBounds).shrink([ endsMargin, scrollYBar.visible ? size + sideMargin : endsMargin, sideMargin, endsMargin ]);
20228
+ const scrollRatioX = this.scrollRatioX = scrollXBounds.width / contentBounds.width;
20229
+ scrollXBar.set({
20230
+ x: scrollXBounds.x - contentBounds.x * scrollRatioX,
20231
+ y: scrollXBounds.maxY - size,
20232
+ width: Math.max(scrollXBounds.width * ratioX, minSize),
20233
+ height: size,
20234
+ cornerRadius: cornerRadius,
20235
+ dragBounds: scrollXBounds,
20236
+ hittable: scrollType !== "move"
20237
+ });
20238
+ }
20239
+ if (scrollYBar.visible) {
20240
+ scrollYBounds.set(viewportBounds).shrink([ endsMargin, sideMargin, scrollXBar.visible ? size + sideMargin : endsMargin, endsMargin ]);
20241
+ const scrollRatioY = this.scrollRatioY = scrollYBounds.height / contentBounds.height;
20242
+ scrollYBar.set({
20243
+ x: scrollYBounds.maxX - size,
20244
+ y: scrollYBounds.y - contentBounds.y * scrollRatioY,
20245
+ width: size,
20246
+ height: Math.max(scrollYBounds.height * ratioY, minSize),
20247
+ cornerRadius: cornerRadius,
20248
+ dragBounds: scrollYBounds,
20249
+ hittable: scrollType !== "move"
20250
+ });
20251
+ }
20252
+ this.x = -this.target.scrollX;
20253
+ this.y = -this.target.scrollY;
20254
+ LeafHelper.updateAllMatrix(this);
20255
+ BranchHelper.updateBounds(this);
20256
+ LeafHelper.updateAllChange(this);
20257
+ }
20258
+ onDrag(e) {
20259
+ if (this.mergedConfig.scrollType === "move") return;
20260
+ this.dragScrolling = true;
20261
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target, scrollXBounds: scrollXBounds, scrollYBounds: scrollYBounds} = this;
20262
+ const scrollX = e.current === scrollXBar;
20263
+ if (scrollX) target.scrollX = -((scrollXBar.x - scrollXBounds.x) / this.scrollRatioX + this.contentRealX); else target.scrollY = -((scrollYBar.y - scrollYBounds.y) / this.scrollRatioY + this.contentRealY);
20264
+ }
20265
+ onDragEnd() {
20266
+ if (this.mergedConfig.scrollType === "move") return;
20267
+ this.dragScrolling = false;
20268
+ }
20269
+ onMove(e) {
20270
+ if (!this.canUse) return;
20271
+ this.onEnter();
20272
+ const {scrollType: scrollType, stopDefault: stopDefault} = this.mergedConfig;
20273
+ if (scrollType === "drag") return;
20274
+ const {viewportBounds: viewportBounds, contentBounds: contentBounds, scrollXBar: scrollXBar, scrollYBar: scrollYBar} = this;
20275
+ if (scrollXBar.visible || scrollYBar.visible) {
20276
+ const move = e.getInnerMove(this.target);
20277
+ DragBoundsHelper.getValidMove(contentBounds, viewportBounds, "inner", move, true);
20278
+ let needStop;
20279
+ if (move.x && scrollXBar.visible) this.target.scrollX += move.x, needStop = true;
20280
+ if (move.y && scrollYBar.visible) this.target.scrollY += move.y, needStop = true;
20281
+ if (needStop || stopDefault) e.stop();
20282
+ if (stopDefault) e.stopDefault();
20283
+ }
20284
+ }
20285
+ onMoveEnd(e) {
20286
+ if (!this.canUse) return;
20287
+ if (!this.target.hit(e)) this.onLeave();
20288
+ }
20289
+ onEnter() {
20290
+ if (!this.canUse) return;
20291
+ clearTimeout(this.hideTimer);
20292
+ this.killAnimate();
20293
+ this.opacity = 1;
20294
+ }
20295
+ onLeave() {
20296
+ if (!this.canUse) return;
20297
+ clearTimeout(this.hideTimer);
20298
+ if (this.mergedConfig.hideOnActionEnd) this.hideTimer = setTimeout(() => {
20299
+ this.set({
20300
+ opacity: 0
20301
+ }, Plugin.has("animate"));
20302
+ }, 600);
20303
+ }
20304
+ onResize() {
20305
+ if (this.canUse) this.update();
20306
+ }
20307
+ __listenEvents() {
20308
+ const {scrollXBar: scrollXBar, scrollYBar: scrollYBar, target: target} = this;
20309
+ this.__eventIds = [ scrollXBar.on_(DragEvent.DRAG, this.onDrag, this), scrollXBar.on_(DragEvent.END, this.onDragEnd, this), scrollYBar.on_(DragEvent.DRAG, this.onDrag, this), scrollYBar.on_(DragEvent.END, this.onDragEnd, this), target.on_(PointerEvent.ENTER, this.onEnter, this), target.on_(PointerEvent.LEAVE, this.onLeave, this), target.on_(MoveEvent.BEFORE_MOVE, this.onMove, this), target.on_(MoveEvent.END, this.onMoveEnd, this), target.on_(BoundsEvent.WORLD, this.onResize, this), target.on_(ChildEvent.DESTROY, this.destroy, this) ];
20310
+ }
20311
+ __removeListenEvents() {
20312
+ this.off_(this.__eventIds);
20313
+ }
20314
+ destroy() {
20315
+ if (!this.destroyed) {
20316
+ this.__removeListenEvents();
20317
+ const {target: target} = this;
20318
+ target.scroller = target.topChildren = target.hasScroller = undefined;
20319
+ this.target = this.config = null;
20320
+ super.destroy();
20321
+ }
20322
+ }
20323
+ }
20324
+
20325
+ Scroller.themeMap = {};
20326
+
20327
+ const S = Scroller;
20328
+
20329
+ function scrollConfigType(defaultValue) {
20330
+ return decorateLeafAttr(defaultValue, key => attr({
20331
+ set(value) {
20332
+ if (this.__setAttr(key, value)) {
20333
+ const layout = this.__layout;
20334
+ layout.scrollConfigChanged = true;
20335
+ doBoundsType(this);
20336
+ }
20337
+ }
20338
+ }));
20339
+ }
20340
+
20341
+ Plugin.add("scroller");
20342
+
20343
+ const box = Box.prototype;
20344
+
20345
+ Box.addAttr("scrollConfig", undefined, scrollConfigType);
20346
+
20347
+ box.__checkScroll = function(isScrollMode) {
20348
+ if (isScrollMode && this.isOverflow) {
20349
+ if (!this.scroller) {
20350
+ this.scroller = new Scroller(this);
20351
+ if (!this.topChildren) this.topChildren = [];
20352
+ this.topChildren.push(this.scroller);
20353
+ }
20354
+ this.hasScroller = true;
20355
+ } else {
20356
+ if (this.hasScroller && !this.scroller.dragScrolling) {
20357
+ this.hasScroller = undefined;
20358
+ this.scroller.update();
20359
+ }
20360
+ }
20361
+ };
20362
+
20363
+ Scroller.registerTheme("light", {
20364
+ style: {
20365
+ fill: "black"
20366
+ }
20367
+ });
20368
+
20369
+ Scroller.registerTheme("dark", {
20370
+ style: {
20371
+ fill: "white"
20372
+ }
20373
+ });
20374
+
20375
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferTypeCreator, LeaferVideo, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, Scroller, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$3 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };