leafer-draw 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$3, pow: pow$1, max: max$3, floor: floor$2, PI: PI$3} = 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$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
868
+ isSame(t, point, quick) {
869
+ return quick ? t.x === point.x && t.y === point.y : float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(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$e.error("not register " + tag);
1868
+ if (!list$1[tag]) {
1869
+ debug$e.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$9 = Debug.get("TaskProcessor");
3562
3592
  class TaskItem {
@@ -3796,6 +3826,9 @@ var LeaferUI = function(exports) {
3796
3826
  const debug$8 = 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 = 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.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, relative.scrollWorldTransform);
4574
4634
  return temp ? matrix : Object.assign({}, matrix);
4575
4635
  },
4636
+ updateScaleFixedWorld(_t) {},
4637
+ updateOuterBounds(_t) {},
4638
+ cacheId(_t) {},
4576
4639
  drop(t, parent, index, resize) {
4577
4640
  t.setTransform(L.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$4 = 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$2.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) {
@@ -7407,7 +7480,9 @@ var LeaferUI = function(exports) {
7407
7480
  set(value) {
7408
7481
  this.__setAttr(key, value);
7409
7482
  if (value) this.__.__useEffect = true;
7410
- this.__layout.renderChanged || this.__layout.renderChange();
7483
+ const layout = this.__layout;
7484
+ layout.renderChanged || layout.renderChange();
7485
+ layout.surfaceChange();
7411
7486
  }
7412
7487
  }));
7413
7488
  }
@@ -7600,15 +7675,16 @@ var LeaferUI = function(exports) {
7600
7675
  this.__needComputePaint = undefined;
7601
7676
  }
7602
7677
  __getRealStrokeWidth(childStyle) {
7603
- let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
7678
+ let {strokeWidth: strokeWidth, strokeScaleFixed: strokeScaleFixed} = this;
7604
7679
  if (childStyle) {
7605
7680
  if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
7606
- if (!isUndefined(childStyle.strokeWidthFixed)) strokeWidthFixed = childStyle.strokeWidthFixed;
7681
+ if (!isUndefined(childStyle.strokeScaleFixed)) strokeScaleFixed = childStyle.strokeScaleFixed;
7682
+ }
7683
+ if (strokeScaleFixed) {
7684
+ const {scaleX: scaleX} = this.__leaf.getRenderScaleData(true, strokeScaleFixed, false);
7685
+ if (scaleX !== 1) return strokeWidth * scaleX;
7607
7686
  }
7608
- if (strokeWidthFixed) {
7609
- const scale = this.__leaf.getClampRenderScale();
7610
- return scale > 1 ? strokeWidth / scale : strokeWidth;
7611
- } else return strokeWidth;
7687
+ return strokeWidth;
7612
7688
  }
7613
7689
  __setPaint(attrName, value) {
7614
7690
  this.__setInput(attrName, value);
@@ -7731,13 +7807,16 @@ var LeaferUI = function(exports) {
7731
7807
  }
7732
7808
  }
7733
7809
  class ImageData extends RectData {
7810
+ get __urlType() {
7811
+ return "image";
7812
+ }
7734
7813
  setUrl(value) {
7735
7814
  this.__setImageFill(value);
7736
7815
  this._url = value;
7737
7816
  }
7738
7817
  __setImageFill(value) {
7739
7818
  this.fill = value ? {
7740
- type: "image",
7819
+ type: this.__urlType,
7741
7820
  mode: "stretch",
7742
7821
  url: value
7743
7822
  } : undefined;
@@ -7773,7 +7852,7 @@ var LeaferUI = function(exports) {
7773
7852
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7774
7853
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7775
7854
  boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7776
- if (!data.__boxStroke) {
7855
+ if (!data.__boxStroke || data.__useArrow) {
7777
7856
  const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7778
7857
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7779
7858
  spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
@@ -7924,6 +8003,12 @@ var LeaferUI = function(exports) {
7924
8003
  get isFrame() {
7925
8004
  return false;
7926
8005
  }
8006
+ set strokeWidthFixed(value) {
8007
+ this.strokeScaleFixed = value;
8008
+ }
8009
+ get strokeWidthFixed() {
8010
+ return this.strokeScaleFixed;
8011
+ }
7927
8012
  set scale(value) {
7928
8013
  MathHelper.assignScale(this, value);
7929
8014
  }
@@ -7979,6 +8064,9 @@ var LeaferUI = function(exports) {
7979
8064
  getPathString(curve, pathForRender, floatLength) {
7980
8065
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
7981
8066
  }
8067
+ asPath(curve, pathForRender) {
8068
+ this.path = this.getPath(curve, pathForRender);
8069
+ }
7982
8070
  load() {
7983
8071
  this.__.__computePaint();
7984
8072
  }
@@ -7988,16 +8076,18 @@ var LeaferUI = function(exports) {
7988
8076
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
7989
8077
  }
7990
8078
  }
7991
- __updateRenderPath() {
8079
+ __updateRenderPath(updateCache) {
7992
8080
  const data = this.__;
7993
8081
  if (data.path) {
7994
8082
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7995
- if (data.__useArrow) PathArrow.addArrows(this);
8083
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache);
7996
8084
  } else data.__pathForRender && (data.__pathForRender = undefined);
7997
8085
  }
7998
8086
  __drawRenderPath(canvas) {
8087
+ const data = this.__;
7999
8088
  canvas.beginPath();
8000
- this.__drawPathByData(canvas, this.__.__pathForRender);
8089
+ if (data.__useArrow) PathArrow.updateArrow(this);
8090
+ this.__drawPathByData(canvas, data.__pathForRender);
8001
8091
  }
8002
8092
  __drawPath(canvas) {
8003
8093
  canvas.beginPath();
@@ -8046,6 +8136,7 @@ var LeaferUI = function(exports) {
8046
8136
  static setEditOuter(_toolName) {}
8047
8137
  static setEditInner(_editorName) {}
8048
8138
  destroy() {
8139
+ this.__.__willDestroy = true;
8049
8140
  this.fill = this.stroke = null;
8050
8141
  if (this.__animate) this.killAnimate();
8051
8142
  super.destroy();
@@ -8106,7 +8197,7 @@ var LeaferUI = function(exports) {
8106
8197
  __decorate([ strokeType(undefined, true) ], exports.UI.prototype, "stroke", void 0);
8107
8198
  __decorate([ strokeType("inside") ], exports.UI.prototype, "strokeAlign", void 0);
8108
8199
  __decorate([ strokeType(1, true) ], exports.UI.prototype, "strokeWidth", void 0);
8109
- __decorate([ strokeType(false) ], exports.UI.prototype, "strokeWidthFixed", void 0);
8200
+ __decorate([ strokeType(false) ], exports.UI.prototype, "strokeScaleFixed", void 0);
8110
8201
  __decorate([ strokeType("none") ], exports.UI.prototype, "strokeCap", void 0);
8111
8202
  __decorate([ strokeType("miter") ], exports.UI.prototype, "strokeJoin", void 0);
8112
8203
  __decorate([ strokeType() ], exports.UI.prototype, "dashPattern", void 0);
@@ -8153,7 +8244,10 @@ var LeaferUI = function(exports) {
8153
8244
  }
8154
8245
  toJSON(options) {
8155
8246
  const data = super.toJSON(options);
8156
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8247
+ if (!this.childlessJSON) {
8248
+ const children = data.children = [];
8249
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8250
+ }
8157
8251
  return data;
8158
8252
  }
8159
8253
  pick(_hitPoint, _options) {
@@ -8295,12 +8389,12 @@ var LeaferUI = function(exports) {
8295
8389
  this.emitLeafer(LeaferEvent.STOP);
8296
8390
  }
8297
8391
  }
8298
- unlockLayout() {
8392
+ unlockLayout(updateLayout = true) {
8299
8393
  this.layouter.start();
8300
- this.updateLayout();
8394
+ if (updateLayout) this.updateLayout();
8301
8395
  }
8302
- lockLayout() {
8303
- this.updateLayout();
8396
+ lockLayout(updateLayout = true) {
8397
+ if (updateLayout) this.updateLayout();
8304
8398
  this.layouter.stop();
8305
8399
  }
8306
8400
  resize(size) {
@@ -8677,9 +8771,9 @@ var LeaferUI = function(exports) {
8677
8771
  return "Ellipse";
8678
8772
  }
8679
8773
  __updatePath() {
8680
- const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8774
+ const data = this.__, {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = data;
8681
8775
  const rx = width / 2, ry = height / 2;
8682
- const path = this.__.path = [];
8776
+ const path = data.path = [];
8683
8777
  let open;
8684
8778
  if (innerRadius) {
8685
8779
  if (startAngle || endAngle) {
@@ -8701,7 +8795,7 @@ var LeaferUI = function(exports) {
8701
8795
  }
8702
8796
  }
8703
8797
  if (!open) closePath$2(path);
8704
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
8798
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
8705
8799
  }
8706
8800
  };
8707
8801
  __decorate([ dataProcessor(EllipseData) ], exports.Ellipse.prototype, "__", void 0);
@@ -9091,8 +9185,8 @@ var LeaferUI = function(exports) {
9091
9185
  canvas.save();
9092
9186
  if (item.transform) canvas.transform(item.transform);
9093
9187
  if (originPaint.scaleFixed) {
9094
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
9095
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9188
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
9189
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
9096
9190
  }
9097
9191
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
9098
9192
  fillPathOrText(ui, canvas, renderOptions);
@@ -9347,11 +9441,14 @@ var LeaferUI = function(exports) {
9347
9441
  function getLeafPaint(attrName, paint, ui) {
9348
9442
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
9349
9443
  let leafPaint;
9350
- const {boxBounds: boxBounds} = ui.__layout;
9351
- switch (paint.type) {
9444
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
9445
+ switch (type) {
9352
9446
  case "image":
9447
+ case "film":
9448
+ case "video":
9353
9449
  if (!paint.url) return undefined;
9354
9450
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9451
+ if (type !== "image") PaintImage[type](leafPaint);
9355
9452
  break;
9356
9453
 
9357
9454
  case "linear":
@@ -9367,7 +9464,7 @@ var LeaferUI = function(exports) {
9367
9464
  break;
9368
9465
 
9369
9466
  case "solid":
9370
- const {type: type, color: color, opacity: opacity} = paint;
9467
+ const {color: color, opacity: opacity} = paint;
9371
9468
  leafPaint = {
9372
9469
  type: type,
9373
9470
  style: ColorConvert.string(color, opacity)
@@ -9407,7 +9504,7 @@ var LeaferUI = function(exports) {
9407
9504
  const {isSame: isSame} = BoundsHelper;
9408
9505
  function image(ui, attrName, paint, boxBounds, firstUse) {
9409
9506
  let leafPaint, event;
9410
- const image = ImageManager.get(paint);
9507
+ const image = ImageManager.get(paint, paint.type);
9411
9508
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
9412
9509
  leafPaint = cache.leafPaint;
9413
9510
  } else {
@@ -9467,8 +9564,8 @@ var LeaferUI = function(exports) {
9467
9564
  return leafPaint;
9468
9565
  }
9469
9566
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
9470
- if (attrName === "fill" && !ui.__.__naturalWidth) {
9471
- const data = ui.__;
9567
+ const data = ui.__;
9568
+ if (attrName === "fill" && !data.__naturalWidth) {
9472
9569
  data.__naturalWidth = image.width / data.pixelRatio;
9473
9570
  data.__naturalHeight = image.height / data.pixelRatio;
9474
9571
  if (data.__autoSide) {
@@ -9480,7 +9577,13 @@ var LeaferUI = function(exports) {
9480
9577
  return false;
9481
9578
  }
9482
9579
  }
9483
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
9580
+ if (!leafPaint.data) {
9581
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
9582
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
9583
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
9584
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
9585
+ }
9586
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
9484
9587
  return true;
9485
9588
  }
9486
9589
  function onLoad(ui, event) {
@@ -9512,7 +9615,7 @@ var LeaferUI = function(exports) {
9512
9615
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
9513
9616
  if (paint.mode === "strench") paint.mode = "stretch";
9514
9617
  const {width: width, height: height} = image;
9515
- 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;
9618
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
9516
9619
  const sameBox = box.width === width && box.height === height;
9517
9620
  const data = {
9518
9621
  mode: mode
@@ -9575,8 +9678,6 @@ var LeaferUI = function(exports) {
9575
9678
  data.scaleX = scaleX;
9576
9679
  data.scaleY = scaleY;
9577
9680
  }
9578
- if (opacity && opacity < 1) data.opacity = opacity;
9579
- if (filters) data.filters = filters;
9580
9681
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
9581
9682
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
9582
9683
  type: "x",
@@ -9602,7 +9703,7 @@ var LeaferUI = function(exports) {
9602
9703
  const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
9603
9704
  function stretchMode(data, box, scaleX, scaleY) {
9604
9705
  const transform = get$2(), {x: x, y: y} = box;
9605
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
9706
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
9606
9707
  scaleHelper(transform, scaleX, scaleY);
9607
9708
  data.transform = transform;
9608
9709
  }
@@ -9683,10 +9784,10 @@ var LeaferUI = function(exports) {
9683
9784
  }
9684
9785
  }
9685
9786
  function createPattern(paint, ui, canvas, renderOptions) {
9686
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
9787
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
9687
9788
  if (paint.patternId !== id && !ui.destroyed) {
9688
9789
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
9689
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
9790
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
9690
9791
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
9691
9792
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
9692
9793
  width *= scaleX;
@@ -9702,7 +9803,7 @@ var LeaferUI = function(exports) {
9702
9803
  if (transform) copy$1(imageMatrix, transform);
9703
9804
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9704
9805
  }
9705
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
9806
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
9706
9807
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
9707
9808
  paint.style = pattern;
9708
9809
  paint.patternId = id;
@@ -9721,15 +9822,15 @@ var LeaferUI = function(exports) {
9721
9822
  return fixScale;
9722
9823
  }
9723
9824
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
9724
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
9825
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
9725
9826
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
9726
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
9827
+ if (!data || paint.patternId === id && !exporting || snapshot) {
9727
9828
  return false;
9728
9829
  } else {
9729
9830
  if (drawImage) {
9730
9831
  if (data.repeat) {
9731
9832
  drawImage = false;
9732
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
9833
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
9733
9834
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
9734
9835
  }
9735
9836
  }
@@ -9746,20 +9847,21 @@ var LeaferUI = function(exports) {
9746
9847
  }
9747
9848
  }
9748
9849
  }
9749
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
9750
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
9751
- let {width: width, height: height} = image, clipUI;
9752
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
9850
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
9851
+ const {data: data, image: image, complex: complex} = paint;
9852
+ let {width: width, height: height} = image;
9853
+ if (complex) {
9854
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
9753
9855
  canvas.save();
9754
- clipUI && canvas.clipUI(ui);
9856
+ complex === 2 && canvas.clipUI(ui);
9755
9857
  blendMode && (canvas.blendMode = blendMode);
9756
9858
  opacity && (canvas.opacity *= opacity);
9757
9859
  transform && canvas.transform(transform);
9758
- canvas.drawImage(view, 0, 0, width, height);
9860
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
9759
9861
  canvas.restore();
9760
9862
  } else {
9761
9863
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
9762
- canvas.drawImage(view, 0, 0, width, height);
9864
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
9763
9865
  }
9764
9866
  }
9765
9867
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
@@ -9787,6 +9889,7 @@ var LeaferUI = function(exports) {
9787
9889
  if (!recycleMap) recycleMap = {};
9788
9890
  recycleMap[url] = true;
9789
9891
  ImageManager.recyclePaint(paint);
9892
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
9790
9893
  if (image.loading) {
9791
9894
  if (!input) {
9792
9895
  input = data.__input && data.__input[attrName] || [];
@@ -10646,7 +10749,9 @@ var LeaferUI = function(exports) {
10646
10749
  exports.LeaferCanvasBase = LeaferCanvasBase;
10647
10750
  exports.LeaferData = LeaferData;
10648
10751
  exports.LeaferEvent = LeaferEvent;
10752
+ exports.LeaferFilm = LeaferFilm;
10649
10753
  exports.LeaferImage = LeaferImage;
10754
+ exports.LeaferVideo = LeaferVideo;
10650
10755
  exports.LineData = LineData;
10651
10756
  exports.MathHelper = MathHelper;
10652
10757
  exports.Matrix = Matrix;