leafer-game 2.0.1 → 2.0.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/web.js CHANGED
@@ -7,6 +7,42 @@ var LeaferUI = function(exports) {
7
7
  PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
8
8
  PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
9
9
  })(exports.PathNodeHandleType || (exports.PathNodeHandleType = {}));
10
+ function __decorate(decorators, target, key, desc) {
11
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ }
15
+ function __awaiter(thisArg, _arguments, P, generator) {
16
+ function adopt(value) {
17
+ return value instanceof P ? value : new P(function(resolve) {
18
+ resolve(value);
19
+ });
20
+ }
21
+ return new (P || (P = Promise))(function(resolve, reject) {
22
+ function fulfilled(value) {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ }
29
+ function rejected(value) {
30
+ try {
31
+ step(generator["throw"](value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ }
36
+ function step(result) {
37
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
38
+ }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ }
42
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
43
+ var e = new Error(message);
44
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45
+ };
10
46
  exports.Answer = void 0;
11
47
  (function(Answer) {
12
48
  Answer[Answer["No"] = 0] = "No";
@@ -197,6 +233,7 @@ var LeaferUI = function(exports) {
197
233
  }
198
234
  destroy() {
199
235
  this.__input = this.__middle = null;
236
+ if (this.__complexData) this.__complexData.destroy();
200
237
  }
201
238
  }
202
239
  const IncrementId = {
@@ -287,6 +324,7 @@ var LeaferUI = function(exports) {
287
324
  };
288
325
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
289
326
  const {round: round$6, pow: pow$2, max: max$4, floor: floor$3, PI: PI$4} = Math;
327
+ const tempScaleData$1 = {};
290
328
  const MathHelper = {
291
329
  within(value, min, max) {
292
330
  if (isObject(min)) max = min.max, min = min.min;
@@ -330,6 +368,24 @@ var LeaferUI = function(exports) {
330
368
  } else if (scale) MathHelper.assignScale(scaleData, scale);
331
369
  return scaleData;
332
370
  },
371
+ getScaleFixedData(worldScaleData, scaleFixed, unscale, abs, _localScaleData) {
372
+ let {scaleX: scaleX, scaleY: scaleY} = worldScaleData;
373
+ if (abs || scaleFixed) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
374
+ if (scaleFixed) {
375
+ if (scaleFixed === true) {
376
+ scaleX = scaleY = unscale ? 1 : 1 / scaleX;
377
+ } else {
378
+ let minScale;
379
+ if (isNumber(scaleFixed)) minScale = scaleFixed; else if (scaleFixed === "zoom-in") minScale = 1;
380
+ if (minScale) {
381
+ if (scaleX > minScale || scaleY > minScale) scaleX = scaleY = unscale ? 1 : 1 / scaleX; else scaleX = scaleY = unscale ? 1 : 1 / minScale;
382
+ }
383
+ }
384
+ }
385
+ tempScaleData$1.scaleX = scaleX;
386
+ tempScaleData$1.scaleY = scaleY;
387
+ return tempScaleData$1;
388
+ },
333
389
  assignScale(scaleData, scale) {
334
390
  if (isNumber(scale)) {
335
391
  scaleData.scaleX = scaleData.scaleY = scale;
@@ -809,8 +865,8 @@ var LeaferUI = function(exports) {
809
865
  if (isObject(originPoints[0])) points = [], originPoints.forEach(p => points.push(p.x, p.y));
810
866
  return points;
811
867
  },
812
- isSame(t, point) {
813
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
868
+ isSame(t, point, quick) {
869
+ return quick ? t.x === point.x && t.y === point.y : float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
814
870
  },
815
871
  reset(t) {
816
872
  P$5.reset(t);
@@ -882,8 +938,8 @@ var LeaferUI = function(exports) {
882
938
  getAtan2(to) {
883
939
  return PointHelper.getAtan2(this, to);
884
940
  }
885
- isSame(point) {
886
- return PointHelper.isSame(this, point);
941
+ isSame(point, quick) {
942
+ return PointHelper.isSame(this, point, quick);
887
943
  }
888
944
  reset() {
889
945
  PointHelper.reset(this);
@@ -1127,9 +1183,9 @@ var LeaferUI = function(exports) {
1127
1183
  }
1128
1184
  if (!onlyBoxSize) to.x += box.x, to.y += box.y;
1129
1185
  },
1130
- getPoint(around, box, to) {
1186
+ getPoint(around, box, to, onlyBoxSize = true) {
1131
1187
  if (!to) to = {};
1132
- AroundHelper.toPoint(around, box, to, true);
1188
+ AroundHelper.toPoint(around, box, to, onlyBoxSize);
1133
1189
  return to;
1134
1190
  }
1135
1191
  };
@@ -1384,6 +1440,9 @@ var LeaferUI = function(exports) {
1384
1440
  y: y + height
1385
1441
  } ];
1386
1442
  },
1443
+ getPoint(t, around, onlyBoxSize = false, to) {
1444
+ return AroundHelper.getPoint(around, t, to, onlyBoxSize);
1445
+ },
1387
1446
  hitRadiusPoint(t, point, pointMatrix) {
1388
1447
  if (pointMatrix) point = PointHelper.tempToInnerRadiusPointOf(point, pointMatrix);
1389
1448
  return point.x >= t.x - point.radiusX && point.x <= t.x + t.width + point.radiusX && (point.y >= t.y - point.radiusY && point.y <= t.y + t.height + point.radiusY);
@@ -1552,6 +1611,9 @@ var LeaferUI = function(exports) {
1552
1611
  getPoints() {
1553
1612
  return BoundsHelper.getPoints(this);
1554
1613
  }
1614
+ getPoint(around, onlyBoxSize, to) {
1615
+ return BoundsHelper.getPoint(this, around, onlyBoxSize, to);
1616
+ }
1555
1617
  hitPoint(point, pointMatrix) {
1556
1618
  return BoundsHelper.hitPoint(this, point, pointMatrix);
1557
1619
  }
@@ -1803,7 +1865,10 @@ var LeaferUI = function(exports) {
1803
1865
  list$1[tag] = UI;
1804
1866
  },
1805
1867
  get(tag, data, x, y, width, height) {
1806
- if (!list$1[tag]) debug$f.error("not register " + tag);
1868
+ if (!list$1[tag]) {
1869
+ debug$f.warn("not register " + tag);
1870
+ return undefined;
1871
+ }
1807
1872
  const ui = new list$1[tag](data);
1808
1873
  if (!isUndefined(x)) {
1809
1874
  ui.x = x;
@@ -1888,42 +1953,6 @@ var LeaferUI = function(exports) {
1888
1953
  this.clear();
1889
1954
  }
1890
1955
  }
1891
- function __decorate(decorators, target, key, desc) {
1892
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1893
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1894
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1895
- }
1896
- function __awaiter(thisArg, _arguments, P, generator) {
1897
- function adopt(value) {
1898
- return value instanceof P ? value : new P(function(resolve) {
1899
- resolve(value);
1900
- });
1901
- }
1902
- return new (P || (P = Promise))(function(resolve, reject) {
1903
- function fulfilled(value) {
1904
- try {
1905
- step(generator.next(value));
1906
- } catch (e) {
1907
- reject(e);
1908
- }
1909
- }
1910
- function rejected(value) {
1911
- try {
1912
- step(generator["throw"](value));
1913
- } catch (e) {
1914
- reject(e);
1915
- }
1916
- }
1917
- function step(result) {
1918
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1919
- }
1920
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1921
- });
1922
- }
1923
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
1924
- var e = new Error(message);
1925
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1926
- };
1927
1956
  function contextAttr(realName) {
1928
1957
  return (target, key) => {
1929
1958
  if (!realName) realName = key;
@@ -3523,10 +3552,10 @@ var LeaferUI = function(exports) {
3523
3552
  const FileHelper = {
3524
3553
  alphaPixelTypes: [ "png", "webp", "svg" ],
3525
3554
  upperCaseTypeMap: {},
3526
- mineType(type) {
3527
- if (!type || type.startsWith("image")) return type;
3555
+ mimeType(type, base = "image") {
3556
+ if (!type || type.startsWith(base)) return type;
3528
3557
  if (type === "jpg") type = "jpeg";
3529
- return "image/" + type;
3558
+ return base + "/" + type;
3530
3559
  },
3531
3560
  fileType(filename) {
3532
3561
  const l = filename.split(".");
@@ -3557,6 +3586,7 @@ var LeaferUI = function(exports) {
3557
3586
  }
3558
3587
  };
3559
3588
  const F = FileHelper;
3589
+ F.mineType = F.mimeType;
3560
3590
  F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3561
3591
  const debug$a = Debug.get("TaskProcessor");
3562
3592
  class TaskItem {
@@ -3796,6 +3826,9 @@ var LeaferUI = function(exports) {
3796
3826
  const debug$9 = Debug.get("Resource");
3797
3827
  const Resource = {
3798
3828
  tasker: new TaskProcessor,
3829
+ queue: new TaskProcessor({
3830
+ parallel: 1
3831
+ }),
3799
3832
  map: {},
3800
3833
  get isComplete() {
3801
3834
  return R.tasker.isComplete;
@@ -3832,6 +3865,12 @@ var LeaferUI = function(exports) {
3832
3865
  R.set(key, value);
3833
3866
  return value;
3834
3867
  },
3868
+ loadFilm(_key, _format) {
3869
+ return undefined;
3870
+ },
3871
+ loadVideo(_key, _format) {
3872
+ return undefined;
3873
+ },
3835
3874
  destroy() {
3836
3875
  R.map = {};
3837
3876
  }
@@ -3840,16 +3879,15 @@ var LeaferUI = function(exports) {
3840
3879
  const ImageManager = {
3841
3880
  maxRecycled: 10,
3842
3881
  recycledList: [],
3843
- patternTasker: new TaskProcessor({
3844
- parallel: 1
3845
- }),
3846
- get(config) {
3882
+ patternTasker: Resource.queue,
3883
+ get(config, type) {
3847
3884
  let image = Resource.get(config.url);
3848
- if (!image) Resource.set(config.url, image = Creator.image(config));
3885
+ if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
3849
3886
  image.use++;
3850
3887
  return image;
3851
3888
  },
3852
3889
  recycle(image) {
3890
+ if (image.parent) image = image.parent;
3853
3891
  image.use--;
3854
3892
  setTimeout(() => {
3855
3893
  if (!image.use) {
@@ -3880,7 +3918,7 @@ var LeaferUI = function(exports) {
3880
3918
  if (config.format) return config.format === format;
3881
3919
  const {url: url} = config;
3882
3920
  if (url.startsWith("data:")) {
3883
- if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
3921
+ if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
3884
3922
  } else {
3885
3923
  if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
3886
3924
  }
@@ -3893,6 +3931,9 @@ var LeaferUI = function(exports) {
3893
3931
  const I$1 = ImageManager;
3894
3932
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3895
3933
  class LeaferImage {
3934
+ get tag() {
3935
+ return "Image";
3936
+ }
3896
3937
  get url() {
3897
3938
  return this.config.url;
3898
3939
  }
@@ -3921,7 +3962,7 @@ var LeaferUI = function(exports) {
3921
3962
  if (!this.loading) {
3922
3963
  this.loading = true;
3923
3964
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
3924
- return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
3965
+ return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
3925
3966
  if (thumbSize) this.setThumbView(img);
3926
3967
  this.setView(img);
3927
3968
  }).catch(e => {
@@ -3995,6 +4036,9 @@ var LeaferUI = function(exports) {
3995
4036
  Platform.image.setPatternTransform(pattern, transform, paint);
3996
4037
  return pattern;
3997
4038
  }
4039
+ render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
4040
+ canvas.drawImage(this.view, x, y, width, height);
4041
+ }
3998
4042
  getLoadUrl(_thumbSize) {
3999
4043
  return this.url;
4000
4044
  }
@@ -4009,8 +4053,10 @@ var LeaferUI = function(exports) {
4009
4053
  return undefined;
4010
4054
  }
4011
4055
  clearLevels(_checkUse) {}
4056
+ destroyFilter() {}
4012
4057
  destroy() {
4013
4058
  this.clearLevels();
4059
+ this.destroyFilter();
4014
4060
  const {view: view} = this;
4015
4061
  if (view && view.close) view.close();
4016
4062
  this.config = {
@@ -4020,6 +4066,16 @@ var LeaferUI = function(exports) {
4020
4066
  this.waitComplete.length = 0;
4021
4067
  }
4022
4068
  }
4069
+ class LeaferFilm extends LeaferImage {
4070
+ get tag() {
4071
+ return "Film";
4072
+ }
4073
+ }
4074
+ class LeaferVideo extends LeaferImage {
4075
+ get tag() {
4076
+ return "Video";
4077
+ }
4078
+ }
4023
4079
  function defineKey(target, key, descriptor, noConfigurable) {
4024
4080
  if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
4025
4081
  Object.defineProperty(target, key, descriptor);
@@ -4171,7 +4227,6 @@ var LeaferUI = function(exports) {
4171
4227
  if (this.__setAttr(key, value)) {
4172
4228
  const data = this.__;
4173
4229
  DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4174
- this.__layout.surfaceChange();
4175
4230
  }
4176
4231
  }
4177
4232
  }));
@@ -4216,7 +4271,6 @@ var LeaferUI = function(exports) {
4216
4271
  return decorateLeafAttr(defaultValue, key => attr({
4217
4272
  set(value) {
4218
4273
  if (this.__setAttr(key, value)) {
4219
- this.__layout.surfaceChange();
4220
4274
  this.waitParent(() => {
4221
4275
  this.parent.__layout.childrenSortChange();
4222
4276
  });
@@ -4250,7 +4304,6 @@ var LeaferUI = function(exports) {
4250
4304
  set(value) {
4251
4305
  if (this.__setAttr(key, value)) {
4252
4306
  this.__layout.hitCanvasChanged = true;
4253
- if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4254
4307
  if (this.leafer) this.leafer.updateCursor();
4255
4308
  }
4256
4309
  }
@@ -4438,6 +4491,10 @@ var LeaferUI = function(exports) {
4438
4491
  if (layout.stateStyleChanged) leaf.updateState();
4439
4492
  if (layout.opacityChanged) updateAllWorldOpacity(leaf);
4440
4493
  leaf.__updateChange();
4494
+ if (layout.surfaceChanged) {
4495
+ if (leaf.__hasComplex) L$1.updateComplex(leaf);
4496
+ layout.surfaceChanged = false;
4497
+ }
4441
4498
  },
4442
4499
  updateAllChange(leaf) {
4443
4500
  updateChange$1(leaf);
@@ -4462,6 +4519,9 @@ var LeaferUI = function(exports) {
4462
4519
  if (!fromWorld) fromWorld = leaf.__nowWorld;
4463
4520
  if (leaf.__worldFlipped || Platform.fullImageShadow) currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform); else currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4464
4521
  },
4522
+ renderComplex(_leaf, _canvas, _options) {},
4523
+ updateComplex(_leaf) {},
4524
+ checkComplex(_leaf) {},
4465
4525
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4466
4526
  const local = isObject(x) ? Object.assign({}, x) : {
4467
4527
  x: x,
@@ -4573,6 +4633,9 @@ var LeaferUI = function(exports) {
4573
4633
  divideParent(matrix$1, relative.scrollWorldTransform);
4574
4634
  return temp ? matrix$1 : Object.assign({}, matrix$1);
4575
4635
  },
4636
+ updateScaleFixedWorld(_t) {},
4637
+ updateOuterBounds(_t) {},
4638
+ cacheId(_t) {},
4576
4639
  drop(t, parent, index, resize) {
4577
4640
  t.setTransform(L$1.getRelativeWorld(t, parent, true), resize);
4578
4641
  parent.add(t, index);
@@ -4619,7 +4682,8 @@ var LeaferUI = function(exports) {
4619
4682
  return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localStrokeBounds;
4620
4683
  },
4621
4684
  localRenderBounds(target) {
4622
- return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localRenderBounds;
4685
+ const {__: __, __layout: __layout} = target;
4686
+ return __.eraser || __.visible === 0 ? null : __layout.localOuterBounds || __layout.localRenderBounds;
4623
4687
  },
4624
4688
  maskLocalBoxBounds(target, index) {
4625
4689
  return checkMask(target, index) && target.__localBoxBounds;
@@ -4628,7 +4692,8 @@ var LeaferUI = function(exports) {
4628
4692
  return checkMask(target, index) && target.__layout.localStrokeBounds;
4629
4693
  },
4630
4694
  maskLocalRenderBounds(target, index) {
4631
- return checkMask(target, index) && target.__layout.localRenderBounds;
4695
+ const {__layout: __layout} = target;
4696
+ return checkMask(target, index) && (__layout.localOuterBounds || __layout.localRenderBounds);
4632
4697
  },
4633
4698
  excludeRenderBounds(child, options) {
4634
4699
  if (options.bounds && !options.bounds.hit(child.__world, options.matrix)) return true;
@@ -5137,7 +5202,6 @@ var LeaferUI = function(exports) {
5137
5202
  }
5138
5203
  opacityChange() {
5139
5204
  this.opacityChanged = true;
5140
- this.surfaceChanged || this.surfaceChange();
5141
5205
  }
5142
5206
  childrenSortChange() {
5143
5207
  if (!this.childrenSortChanged) {
@@ -5552,6 +5616,7 @@ var LeaferUI = function(exports) {
5552
5616
  const {parent: parent, __layout: __layout, __world: __world, __scrollWorld: __scrollWorld, __: __} = this;
5553
5617
  multiplyParent$2(this.__local || __layout, parent ? parent.__scrollWorld || parent.__world : defaultWorld, __world, !!__layout.affectScaleOrRotation, __);
5554
5618
  if (__scrollWorld) translateInner(Object.assign(__scrollWorld, __world), __.scrollX, __.scrollY);
5619
+ if (__layout.scaleFixed) LeafHelper.updateScaleFixedWorld(this);
5555
5620
  },
5556
5621
  __updateLocalMatrix() {
5557
5622
  if (this.__local) {
@@ -5580,6 +5645,7 @@ var LeaferUI = function(exports) {
5580
5645
  __updateWorldBounds() {
5581
5646
  const {__layout: __layout, __world: __world} = this;
5582
5647
  toOuterOf$2(__layout.renderBounds, __world, __world);
5648
+ if (this.__hasComplex) LeafHelper.checkComplex(this);
5583
5649
  if (__layout.resized) {
5584
5650
  if (__layout.resized === "inner") this.__onUpdateSize();
5585
5651
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5629,6 +5695,7 @@ var LeaferUI = function(exports) {
5629
5695
  layout.renderChanged = undefined;
5630
5696
  if (this.parent) this.parent.__layout.renderChange();
5631
5697
  }
5698
+ if (layout.outerScale) LeafHelper.updateOuterBounds(this);
5632
5699
  layout.resized || (layout.resized = "local");
5633
5700
  layout.boundsChanged = undefined;
5634
5701
  },
@@ -5694,7 +5761,7 @@ var LeaferUI = function(exports) {
5694
5761
  const data = this.__;
5695
5762
  if (data.bright && !options.topRendering) return options.topList.add(this);
5696
5763
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5697
- canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5764
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5698
5765
  if (this.__.__single) {
5699
5766
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5700
5767
  const tempCanvas = canvas.getSameCanvas(true, true);
@@ -5746,7 +5813,7 @@ var LeaferUI = function(exports) {
5746
5813
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5747
5814
  const tempCanvas = canvas.getSameCanvas(false, true);
5748
5815
  this.__renderBranch(tempCanvas, options);
5749
- canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5816
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5750
5817
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
5751
5818
  tempCanvas.recycle(nowWorld);
5752
5819
  } else {
@@ -5758,9 +5825,11 @@ var LeaferUI = function(exports) {
5758
5825
  if (this.__hasMask) {
5759
5826
  this.__renderMask(canvas, options);
5760
5827
  } else {
5828
+ let child;
5761
5829
  const {children: children} = this;
5762
5830
  for (let i = 0, len = children.length; i < len; i++) {
5763
- excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
5831
+ child = children[i];
5832
+ excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
5764
5833
  }
5765
5834
  }
5766
5835
  },
@@ -5773,12 +5842,12 @@ var LeaferUI = function(exports) {
5773
5842
  }
5774
5843
  }
5775
5844
  };
5776
- const tempScaleData$1 = {};
5777
5845
  const {LEAF: LEAF, create: create} = IncrementId;
5778
5846
  const {stintSet: stintSet$4} = DataHelper;
5779
5847
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5780
5848
  const {toOuterOf: toOuterOf$1} = BoundsHelper;
5781
5849
  const {copy: copy$2, move: move$2} = PointHelper;
5850
+ const {getScaleFixedData: getScaleFixedData} = MathHelper;
5782
5851
  const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
5783
5852
  exports.Leaf = class Leaf {
5784
5853
  get tag() {
@@ -5936,6 +6005,7 @@ var LeaferUI = function(exports) {
5936
6005
  this.__level = this.parent ? this.parent.__level + 1 : 1;
5937
6006
  if (this.animation) this.__runAnimation("in");
5938
6007
  if (this.__bubbleMap) this.__emitLifeEvent(ChildEvent.MOUNTED);
6008
+ if (leafer.cacheId) LeafHelper.cacheId(this);
5939
6009
  } else {
5940
6010
  this.__emitLifeEvent(ChildEvent.UNMOUNTED);
5941
6011
  }
@@ -6065,13 +6135,8 @@ var LeaferUI = function(exports) {
6065
6135
  if (scaleX < 0) scaleX = -scaleX;
6066
6136
  return scaleX > 1 ? scaleX : 1;
6067
6137
  }
6068
- getRenderScaleData(abs, scaleFixed) {
6069
- let {scaleX: scaleX, scaleY: scaleY} = ImageManager.patternLocked ? this.__world : this.__nowWorld;
6070
- if (abs) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
6071
- if (scaleFixed === true || scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) scaleX = scaleY = 1;
6072
- tempScaleData$1.scaleX = scaleX;
6073
- tempScaleData$1.scaleY = scaleY;
6074
- return tempScaleData$1;
6138
+ getRenderScaleData(abs, scaleFixed, unscale = true) {
6139
+ return getScaleFixedData(ImageManager.patternLocked ? this.__world : this.__nowWorld || this.__world, scaleFixed, unscale, abs);
6075
6140
  }
6076
6141
  getTransform(relative) {
6077
6142
  return this.__layout.getTransform(relative || "local");
@@ -6243,7 +6308,7 @@ var LeaferUI = function(exports) {
6243
6308
  __drawPath(_canvas) {}
6244
6309
  __drawRenderPath(_canvas) {}
6245
6310
  __updatePath() {}
6246
- __updateRenderPath() {}
6311
+ __updateRenderPath(_updateCache) {}
6247
6312
  getMotionPathData() {
6248
6313
  return Plugin.need("path");
6249
6314
  }
@@ -6311,9 +6376,11 @@ var LeaferUI = function(exports) {
6311
6376
  return 0;
6312
6377
  }
6313
6378
  __updateRenderSpread() {
6379
+ let layout;
6314
6380
  const {children: children} = this;
6315
6381
  for (let i = 0, len = children.length; i < len; i++) {
6316
- if (children[i].__layout.renderSpread) return 1;
6382
+ layout = children[i].__layout;
6383
+ if (layout.renderSpread || layout.localOuterBounds) return 1;
6317
6384
  }
6318
6385
  return 0;
6319
6386
  }
@@ -6346,6 +6413,7 @@ var LeaferUI = function(exports) {
6346
6413
  this.add(item, index);
6347
6414
  noIndex || index++;
6348
6415
  }); else child = UICreator.get(child.tag, child);
6416
+ if (!child) return;
6349
6417
  }
6350
6418
  if (child.parent) child.parent.remove(child);
6351
6419
  child.parent = this;
@@ -6567,7 +6635,7 @@ var LeaferUI = function(exports) {
6567
6635
  this.levelMap = null;
6568
6636
  }
6569
6637
  }
6570
- const version = "2.0.1";
6638
+ const version = "2.0.3";
6571
6639
  const debug$5 = Debug.get("LeaferCanvas");
6572
6640
  class LeaferCanvas extends LeaferCanvasBase {
6573
6641
  set zIndex(zIndex) {
@@ -6767,7 +6835,6 @@ var LeaferUI = function(exports) {
6767
6835
  }
6768
6836
  canvasPatch(CanvasRenderingContext2D.prototype);
6769
6837
  canvasPatch(Path2D.prototype);
6770
- const {mineType: mineType, fileType: fileType} = FileHelper;
6771
6838
  Object.assign(Creator, {
6772
6839
  canvas: (options, manager) => new LeaferCanvas(options, manager),
6773
6840
  image: options => new LeaferImage(options)
@@ -6781,29 +6848,27 @@ var LeaferUI = function(exports) {
6781
6848
  return canvas;
6782
6849
  },
6783
6850
  canvasToDataURL: (canvas, type, quality) => {
6784
- const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
6851
+ const imageType = FileHelper.mimeType(type), url = canvas.toDataURL(imageType, quality);
6785
6852
  return imageType === "image/bmp" ? url.replace("image/png;", "image/bmp;") : url;
6786
6853
  },
6787
- canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, mineType(type), quality)),
6854
+ canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, FileHelper.mimeType(type), quality)),
6788
6855
  canvasSaveAs: (canvas, filename, quality) => {
6789
- const url = canvas.toDataURL(mineType(fileType(filename)), quality);
6856
+ const url = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filename)), quality);
6790
6857
  return Platform.origin.download(url, filename);
6791
6858
  },
6792
6859
  download(url, filename) {
6793
- return new Promise(resolve => {
6860
+ return __awaiter(this, void 0, void 0, function*() {
6794
6861
  let el = document.createElement("a");
6795
6862
  el.href = url;
6796
6863
  el.download = filename;
6797
6864
  document.body.appendChild(el);
6798
6865
  el.click();
6799
6866
  document.body.removeChild(el);
6800
- resolve();
6801
6867
  });
6802
6868
  },
6803
- loadImage(src) {
6869
+ loadImage(src, crossOrigin, _leaferImage) {
6804
6870
  return new Promise((resolve, reject) => {
6805
6871
  const img = new Platform.origin.Image;
6806
- const {crossOrigin: crossOrigin} = Platform.image;
6807
6872
  if (crossOrigin) {
6808
6873
  img.setAttribute("crossOrigin", crossOrigin);
6809
6874
  img.crossOrigin = crossOrigin;
@@ -6817,6 +6882,13 @@ var LeaferUI = function(exports) {
6817
6882
  img.src = Platform.image.getRealURL(src);
6818
6883
  });
6819
6884
  },
6885
+ loadContent(url_1) {
6886
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
6887
+ const response = yield fetch(url);
6888
+ if (!response.ok) throw new Error(`${response.status}`);
6889
+ return yield response[responseType]();
6890
+ });
6891
+ },
6820
6892
  Image: Image,
6821
6893
  PointerEvent: PointerEvent,
6822
6894
  DragEvent: DragEvent
@@ -7308,7 +7380,7 @@ var LeaferUI = function(exports) {
7308
7380
  getCellList() {
7309
7381
  return undefined;
7310
7382
  }
7311
- addBlock(block) {
7383
+ addBlock(block, _leafList) {
7312
7384
  if (!this.updateBlocks) this.updateBlocks = [];
7313
7385
  this.updateBlocks.push(block);
7314
7386
  }
@@ -7356,7 +7428,8 @@ var LeaferUI = function(exports) {
7356
7428
  __onLayoutEnd(event) {
7357
7429
  if (event.data) event.data.map(item => {
7358
7430
  let empty;
7359
- if (item.updatedList) item.updatedList.list.some(leaf => {
7431
+ const {updatedList: updatedList} = item;
7432
+ if (updatedList) updatedList.list.some(leaf => {
7360
7433
  empty = !leaf.__world.width || !leaf.__world.height;
7361
7434
  if (empty) {
7362
7435
  if (!leaf.isLeafer) debug$3.tip(leaf.innerName, ": empty");
@@ -7364,7 +7437,7 @@ var LeaferUI = function(exports) {
7364
7437
  }
7365
7438
  return empty;
7366
7439
  });
7367
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
7440
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
7368
7441
  });
7369
7442
  }
7370
7443
  emitRender(type, bounds, options) {
@@ -7564,7 +7637,7 @@ var LeaferUI = function(exports) {
7564
7637
  this.config = {};
7565
7638
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
7566
7639
  this.picker = new Picker(this.target = target, this);
7567
- this.finder = Creator.finder && Creator.finder();
7640
+ this.finder = Creator.finder && Creator.finder(target, this.config);
7568
7641
  }
7569
7642
  getByPoint(hitPoint, hitRadius, options) {
7570
7643
  const {target: target, picker: picker} = this;
@@ -7602,7 +7675,9 @@ var LeaferUI = function(exports) {
7602
7675
  set(value) {
7603
7676
  this.__setAttr(key, value);
7604
7677
  if (value) this.__.__useEffect = true;
7605
- this.__layout.renderChanged || this.__layout.renderChange();
7678
+ const layout = this.__layout;
7679
+ layout.renderChanged || layout.renderChange();
7680
+ layout.surfaceChange();
7606
7681
  }
7607
7682
  }));
7608
7683
  }
@@ -7795,15 +7870,16 @@ var LeaferUI = function(exports) {
7795
7870
  this.__needComputePaint = undefined;
7796
7871
  }
7797
7872
  __getRealStrokeWidth(childStyle) {
7798
- let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
7873
+ let {strokeWidth: strokeWidth, strokeScaleFixed: strokeScaleFixed} = this;
7799
7874
  if (childStyle) {
7800
7875
  if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
7801
- if (!isUndefined(childStyle.strokeWidthFixed)) strokeWidthFixed = childStyle.strokeWidthFixed;
7876
+ if (!isUndefined(childStyle.strokeScaleFixed)) strokeScaleFixed = childStyle.strokeScaleFixed;
7877
+ }
7878
+ if (strokeScaleFixed) {
7879
+ const {scaleX: scaleX} = this.__leaf.getRenderScaleData(true, strokeScaleFixed, false);
7880
+ if (scaleX !== 1) return strokeWidth * scaleX;
7802
7881
  }
7803
- if (strokeWidthFixed) {
7804
- const scale = this.__leaf.getClampRenderScale();
7805
- return scale > 1 ? strokeWidth / scale : strokeWidth;
7806
- } else return strokeWidth;
7882
+ return strokeWidth;
7807
7883
  }
7808
7884
  __setPaint(attrName, value) {
7809
7885
  this.__setInput(attrName, value);
@@ -7926,13 +8002,16 @@ var LeaferUI = function(exports) {
7926
8002
  }
7927
8003
  }
7928
8004
  class ImageData extends RectData {
8005
+ get __urlType() {
8006
+ return "image";
8007
+ }
7929
8008
  setUrl(value) {
7930
8009
  this.__setImageFill(value);
7931
8010
  this._url = value;
7932
8011
  }
7933
8012
  __setImageFill(value) {
7934
8013
  this.fill = value ? {
7935
- type: "image",
8014
+ type: this.__urlType,
7936
8015
  mode: "stretch",
7937
8016
  url: value
7938
8017
  } : undefined;
@@ -7968,7 +8047,7 @@ var LeaferUI = function(exports) {
7968
8047
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7969
8048
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7970
8049
  boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7971
- if (!data.__boxStroke) {
8050
+ if (!data.__boxStroke || data.__useArrow) {
7972
8051
  const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7973
8052
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7974
8053
  spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
@@ -8119,6 +8198,12 @@ var LeaferUI = function(exports) {
8119
8198
  get isFrame() {
8120
8199
  return false;
8121
8200
  }
8201
+ set strokeWidthFixed(value) {
8202
+ this.strokeScaleFixed = value;
8203
+ }
8204
+ get strokeWidthFixed() {
8205
+ return this.strokeScaleFixed;
8206
+ }
8122
8207
  set scale(value) {
8123
8208
  MathHelper.assignScale(this, value);
8124
8209
  }
@@ -8174,6 +8259,9 @@ var LeaferUI = function(exports) {
8174
8259
  getPathString(curve, pathForRender, floatLength) {
8175
8260
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
8176
8261
  }
8262
+ asPath(curve, pathForRender) {
8263
+ this.path = this.getPath(curve, pathForRender);
8264
+ }
8177
8265
  load() {
8178
8266
  this.__.__computePaint();
8179
8267
  }
@@ -8183,16 +8271,18 @@ var LeaferUI = function(exports) {
8183
8271
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
8184
8272
  }
8185
8273
  }
8186
- __updateRenderPath() {
8274
+ __updateRenderPath(updateCache) {
8187
8275
  const data = this.__;
8188
8276
  if (data.path) {
8189
8277
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8190
- if (data.__useArrow) PathArrow.addArrows(this);
8278
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8191
8279
  } else data.__pathForRender && (data.__pathForRender = undefined);
8192
8280
  }
8193
8281
  __drawRenderPath(canvas) {
8282
+ const data = this.__;
8194
8283
  canvas.beginPath();
8195
- this.__drawPathByData(canvas, this.__.__pathForRender);
8284
+ if (data.__useArrow) PathArrow.updateArrow(this);
8285
+ this.__drawPathByData(canvas, data.__pathForRender);
8196
8286
  }
8197
8287
  __drawPath(canvas) {
8198
8288
  canvas.beginPath();
@@ -8241,6 +8331,7 @@ var LeaferUI = function(exports) {
8241
8331
  static setEditOuter(_toolName) {}
8242
8332
  static setEditInner(_editorName) {}
8243
8333
  destroy() {
8334
+ this.__.__willDestroy = true;
8244
8335
  this.fill = this.stroke = null;
8245
8336
  if (this.__animate) this.killAnimate();
8246
8337
  super.destroy();
@@ -8301,7 +8392,7 @@ var LeaferUI = function(exports) {
8301
8392
  __decorate([ strokeType(undefined, true) ], exports.UI.prototype, "stroke", void 0);
8302
8393
  __decorate([ strokeType("inside") ], exports.UI.prototype, "strokeAlign", void 0);
8303
8394
  __decorate([ strokeType(1, true) ], exports.UI.prototype, "strokeWidth", void 0);
8304
- __decorate([ strokeType(false) ], exports.UI.prototype, "strokeWidthFixed", void 0);
8395
+ __decorate([ strokeType(false) ], exports.UI.prototype, "strokeScaleFixed", void 0);
8305
8396
  __decorate([ strokeType("none") ], exports.UI.prototype, "strokeCap", void 0);
8306
8397
  __decorate([ strokeType("miter") ], exports.UI.prototype, "strokeJoin", void 0);
8307
8398
  __decorate([ strokeType() ], exports.UI.prototype, "dashPattern", void 0);
@@ -8348,7 +8439,10 @@ var LeaferUI = function(exports) {
8348
8439
  }
8349
8440
  toJSON(options) {
8350
8441
  const data = super.toJSON(options);
8351
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8442
+ if (!this.childlessJSON) {
8443
+ const children = data.children = [];
8444
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8445
+ }
8352
8446
  return data;
8353
8447
  }
8354
8448
  pick(_hitPoint, _options) {
@@ -8490,12 +8584,12 @@ var LeaferUI = function(exports) {
8490
8584
  this.emitLeafer(LeaferEvent.STOP);
8491
8585
  }
8492
8586
  }
8493
- unlockLayout() {
8587
+ unlockLayout(updateLayout = true) {
8494
8588
  this.layouter.start();
8495
- this.updateLayout();
8589
+ if (updateLayout) this.updateLayout();
8496
8590
  }
8497
- lockLayout() {
8498
- this.updateLayout();
8591
+ lockLayout(updateLayout = true) {
8592
+ if (updateLayout) this.updateLayout();
8499
8593
  this.layouter.stop();
8500
8594
  }
8501
8595
  resize(size) {
@@ -8872,9 +8966,9 @@ var LeaferUI = function(exports) {
8872
8966
  return "Ellipse";
8873
8967
  }
8874
8968
  __updatePath() {
8875
- const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8969
+ const data = this.__, {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = data;
8876
8970
  const rx = width / 2, ry = height / 2;
8877
- const path = this.__.path = [];
8971
+ const path = data.path = [];
8878
8972
  let open;
8879
8973
  if (innerRadius) {
8880
8974
  if (startAngle || endAngle) {
@@ -8896,7 +8990,7 @@ var LeaferUI = function(exports) {
8896
8990
  }
8897
8991
  }
8898
8992
  if (!open) closePath$2(path);
8899
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
8993
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
8900
8994
  }
8901
8995
  };
8902
8996
  __decorate([ dataProcessor(EllipseData) ], exports.Ellipse.prototype, "__", void 0);
@@ -9352,7 +9446,7 @@ var LeaferUI = function(exports) {
9352
9446
  if (this.viewReady) this.renderer.update();
9353
9447
  }
9354
9448
  __render(canvas, options) {
9355
- if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds));
9449
+ if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds, undefined, undefined, true));
9356
9450
  }
9357
9451
  __onResize(event) {
9358
9452
  this.forEach(leafer => leafer.resize(event));
@@ -10074,6 +10168,7 @@ var LeaferUI = function(exports) {
10074
10168
  this.checkPath(data, useDefaultPath);
10075
10169
  this.downTime = Date.now();
10076
10170
  this.emit(exports.PointerEvent.BEFORE_DOWN, data);
10171
+ if (data.path.needUpdate) this.updateDownData(data);
10077
10172
  this.emit(exports.PointerEvent.DOWN, data);
10078
10173
  if (PointerButton.left(data)) {
10079
10174
  this.tapWait();
@@ -10991,8 +11086,8 @@ var LeaferUI = function(exports) {
10991
11086
  canvas.save();
10992
11087
  if (item.transform) canvas.transform(item.transform);
10993
11088
  if (originPaint.scaleFixed) {
10994
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10995
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11089
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
11090
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
10996
11091
  }
10997
11092
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
10998
11093
  fillPathOrText(ui, canvas, renderOptions);
@@ -11247,11 +11342,14 @@ var LeaferUI = function(exports) {
11247
11342
  function getLeafPaint(attrName, paint, ui) {
11248
11343
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11249
11344
  let leafPaint;
11250
- const {boxBounds: boxBounds} = ui.__layout;
11251
- switch (paint.type) {
11345
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
11346
+ switch (type) {
11252
11347
  case "image":
11348
+ case "film":
11349
+ case "video":
11253
11350
  if (!paint.url) return undefined;
11254
11351
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11352
+ if (type !== "image") PaintImage[type](leafPaint);
11255
11353
  break;
11256
11354
 
11257
11355
  case "linear":
@@ -11267,7 +11365,7 @@ var LeaferUI = function(exports) {
11267
11365
  break;
11268
11366
 
11269
11367
  case "solid":
11270
- const {type: type, color: color, opacity: opacity} = paint;
11368
+ const {color: color, opacity: opacity} = paint;
11271
11369
  leafPaint = {
11272
11370
  type: type,
11273
11371
  style: ColorConvert.string(color, opacity)
@@ -11307,7 +11405,7 @@ var LeaferUI = function(exports) {
11307
11405
  const {isSame: isSame} = BoundsHelper;
11308
11406
  function image(ui, attrName, paint, boxBounds, firstUse) {
11309
11407
  let leafPaint, event;
11310
- const image = ImageManager.get(paint);
11408
+ const image = ImageManager.get(paint, paint.type);
11311
11409
  if (cache$1 && paint === cache$1.paint && isSame(boxBounds, cache$1.boxBounds)) {
11312
11410
  leafPaint = cache$1.leafPaint;
11313
11411
  } else {
@@ -11367,8 +11465,8 @@ var LeaferUI = function(exports) {
11367
11465
  return leafPaint;
11368
11466
  }
11369
11467
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11370
- if (attrName === "fill" && !ui.__.__naturalWidth) {
11371
- const data = ui.__;
11468
+ const data = ui.__;
11469
+ if (attrName === "fill" && !data.__naturalWidth) {
11372
11470
  data.__naturalWidth = image.width / data.pixelRatio;
11373
11471
  data.__naturalHeight = image.height / data.pixelRatio;
11374
11472
  if (data.__autoSide) {
@@ -11380,7 +11478,13 @@ var LeaferUI = function(exports) {
11380
11478
  return false;
11381
11479
  }
11382
11480
  }
11383
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
11481
+ if (!leafPaint.data) {
11482
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
11483
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
11484
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
11485
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
11486
+ }
11487
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
11384
11488
  return true;
11385
11489
  }
11386
11490
  function onLoad(ui, event) {
@@ -11412,7 +11516,7 @@ var LeaferUI = function(exports) {
11412
11516
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
11413
11517
  if (paint.mode === "strench") paint.mode = "stretch";
11414
11518
  const {width: width, height: height} = image;
11415
- 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;
11519
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
11416
11520
  const sameBox = box.width === width && box.height === height;
11417
11521
  const data = {
11418
11522
  mode: mode
@@ -11475,8 +11579,6 @@ var LeaferUI = function(exports) {
11475
11579
  data.scaleX = scaleX;
11476
11580
  data.scaleY = scaleY;
11477
11581
  }
11478
- if (opacity && opacity < 1) data.opacity = opacity;
11479
- if (filters) data.filters = filters;
11480
11582
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
11481
11583
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
11482
11584
  type: "x",
@@ -11502,7 +11604,7 @@ var LeaferUI = function(exports) {
11502
11604
  const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
11503
11605
  function stretchMode(data, box, scaleX, scaleY) {
11504
11606
  const transform = get$2(), {x: x, y: y} = box;
11505
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11607
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
11506
11608
  scaleHelper(transform, scaleX, scaleY);
11507
11609
  data.transform = transform;
11508
11610
  }
@@ -11583,10 +11685,10 @@ var LeaferUI = function(exports) {
11583
11685
  }
11584
11686
  }
11585
11687
  function createPattern(paint, ui, canvas, renderOptions) {
11586
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11688
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11587
11689
  if (paint.patternId !== id && !ui.destroyed) {
11588
11690
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11589
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11691
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11590
11692
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11591
11693
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11592
11694
  width *= scaleX;
@@ -11602,7 +11704,7 @@ var LeaferUI = function(exports) {
11602
11704
  if (transform) copy$1(imageMatrix, transform);
11603
11705
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11604
11706
  }
11605
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11707
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11606
11708
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11607
11709
  paint.style = pattern;
11608
11710
  paint.patternId = id;
@@ -11621,15 +11723,15 @@ var LeaferUI = function(exports) {
11621
11723
  return fixScale;
11622
11724
  }
11623
11725
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11624
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11726
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11625
11727
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
11626
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
11728
+ if (!data || paint.patternId === id && !exporting || snapshot) {
11627
11729
  return false;
11628
11730
  } else {
11629
11731
  if (drawImage) {
11630
11732
  if (data.repeat) {
11631
11733
  drawImage = false;
11632
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11734
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11633
11735
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
11634
11736
  }
11635
11737
  }
@@ -11646,20 +11748,21 @@ var LeaferUI = function(exports) {
11646
11748
  }
11647
11749
  }
11648
11750
  }
11649
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11650
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11651
- let {width: width, height: height} = image, clipUI;
11652
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
11751
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
11752
+ const {data: data, image: image, complex: complex} = paint;
11753
+ let {width: width, height: height} = image;
11754
+ if (complex) {
11755
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
11653
11756
  canvas.save();
11654
- clipUI && canvas.clipUI(ui);
11757
+ complex === 2 && canvas.clipUI(ui);
11655
11758
  blendMode && (canvas.blendMode = blendMode);
11656
11759
  opacity && (canvas.opacity *= opacity);
11657
11760
  transform && canvas.transform(transform);
11658
- canvas.drawImage(view, 0, 0, width, height);
11761
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
11659
11762
  canvas.restore();
11660
11763
  } else {
11661
11764
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11662
- canvas.drawImage(view, 0, 0, width, height);
11765
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
11663
11766
  }
11664
11767
  }
11665
11768
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
@@ -11687,6 +11790,7 @@ var LeaferUI = function(exports) {
11687
11790
  if (!recycleMap) recycleMap = {};
11688
11791
  recycleMap[url] = true;
11689
11792
  ImageManager.recyclePaint(paint);
11793
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
11690
11794
  if (image.loading) {
11691
11795
  if (!input) {
11692
11796
  input = data.__input && data.__input[attrName] || [];
@@ -12524,6 +12628,9 @@ var LeaferUI = function(exports) {
12524
12628
  constructor(data) {
12525
12629
  super(data);
12526
12630
  }
12631
+ togglePlay() {
12632
+ this.running ? this.pause() : this.play();
12633
+ }
12527
12634
  play() {
12528
12635
  this.running = true;
12529
12636
  }
@@ -14291,9 +14398,7 @@ var LeaferUI = function(exports) {
14291
14398
  const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = exports.Answer;
14292
14399
  const idCondition = {}, classNameCondition = {}, tagCondition = {};
14293
14400
  class Finder {
14294
- constructor(target) {
14295
- this.innerIdMap = {};
14296
- this.idMap = {};
14401
+ constructor(target, _config) {
14297
14402
  this.methods = {
14298
14403
  id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf),
14299
14404
  1) : 0,
@@ -14303,6 +14408,13 @@ var LeaferUI = function(exports) {
14303
14408
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
14304
14409
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
14305
14410
  };
14411
+ this.idMap = {};
14412
+ this.innerIdMap = {};
14413
+ const app = target && target.app;
14414
+ if (app) {
14415
+ app.idMap ? this.idMap = app.idMap : app.idMap = this.idMap;
14416
+ app.innerIdMap ? this.innerIdMap = app.innerIdMap : app.innerIdMap = this.innerIdMap;
14417
+ }
14306
14418
  if (this.target = target) this.__listenEvents();
14307
14419
  }
14308
14420
  getBy(condition, branch, one, options) {
@@ -14423,8 +14535,13 @@ var LeaferUI = function(exports) {
14423
14535
  return getSelector(this).getBy(condition, this, true, options);
14424
14536
  };
14425
14537
  Plugin.add("find");
14426
- Creator.finder = function(target) {
14427
- return new Finder(target);
14538
+ Creator.finder = function(target, config) {
14539
+ return new Finder(target, config);
14540
+ };
14541
+ LeafHelper.cacheId = function(t) {
14542
+ const {leafer: leafer, id: id} = t;
14543
+ if (id) leafer.app.idMap[id] = t;
14544
+ if (leafer.cacheInnerId) leafer.app.innerIdMap[t.innerId] = t;
14428
14545
  };
14429
14546
  exports.AlignHelper = AlignHelper;
14430
14547
  exports.AnimateEasing = AnimateEasing;
@@ -14489,7 +14606,9 @@ var LeaferUI = function(exports) {
14489
14606
  exports.LeaferCanvasBase = LeaferCanvasBase;
14490
14607
  exports.LeaferData = LeaferData;
14491
14608
  exports.LeaferEvent = LeaferEvent;
14609
+ exports.LeaferFilm = LeaferFilm;
14492
14610
  exports.LeaferImage = LeaferImage;
14611
+ exports.LeaferVideo = LeaferVideo;
14493
14612
  exports.LineData = LineData;
14494
14613
  exports.MathHelper = MathHelper;
14495
14614
  exports.Matrix = Matrix;