@leafer-ui/worker 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/worker.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$4, 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$2(t.x) === float$2(point.x) && float$2(t.y) === float$2(point.y);
868
+ isSame(t, point, quick) {
869
+ return quick ? t.x === point.x && t.y === point.y : float$2(t.x) === float$2(point.x) && float$2(t.y) === float$2(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$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.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.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
  class LeaferCanvas extends LeaferCanvasBase {
6572
6640
  get allowBackgroundColor() {
6573
6641
  return true;
@@ -6589,7 +6657,6 @@ var LeaferUI = function(exports) {
6589
6657
  }
6590
6658
  canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
6591
6659
  canvasPatch(Path2D.prototype);
6592
- const {mineType: mineType} = FileHelper;
6593
6660
  Object.assign(Creator, {
6594
6661
  canvas: (options, manager) => new LeaferCanvas(options, manager),
6595
6662
  image: options => new LeaferImage(options)
@@ -6599,7 +6666,7 @@ var LeaferUI = function(exports) {
6599
6666
  createCanvas: (width, height) => new OffscreenCanvas(width, height),
6600
6667
  canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
6601
6668
  canvas.convertToBlob({
6602
- type: mineType(type),
6669
+ type: FileHelper.mimeType(type),
6603
6670
  quality: quality
6604
6671
  }).then(blob => {
6605
6672
  var reader = new FileReader;
@@ -6611,14 +6678,14 @@ var LeaferUI = function(exports) {
6611
6678
  });
6612
6679
  }),
6613
6680
  canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
6614
- type: mineType(type),
6681
+ type: FileHelper.mimeType(type),
6615
6682
  quality: quality
6616
6683
  }),
6617
6684
  canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
6618
6685
  download(_url, _filename) {
6619
6686
  return undefined;
6620
6687
  },
6621
- loadImage(src) {
6688
+ loadImage(src, _crossOrigin, _leaferImage) {
6622
6689
  return new Promise((resolve, reject) => {
6623
6690
  let req = new XMLHttpRequest;
6624
6691
  req.open("GET", Platform.image.getRealURL(src), true);
@@ -6633,6 +6700,13 @@ var LeaferUI = function(exports) {
6633
6700
  req.onerror = e => reject(e);
6634
6701
  req.send();
6635
6702
  });
6703
+ },
6704
+ loadContent(url_1) {
6705
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
6706
+ const response = yield fetch(url);
6707
+ if (!response.ok) throw new Error(`${response.status}`);
6708
+ return yield response[responseType]();
6709
+ });
6636
6710
  }
6637
6711
  };
6638
6712
  Platform.canvas = Creator.canvas();
@@ -7111,7 +7185,7 @@ var LeaferUI = function(exports) {
7111
7185
  getCellList() {
7112
7186
  return undefined;
7113
7187
  }
7114
- addBlock(block) {
7188
+ addBlock(block, _leafList) {
7115
7189
  if (!this.updateBlocks) this.updateBlocks = [];
7116
7190
  this.updateBlocks.push(block);
7117
7191
  }
@@ -7159,7 +7233,8 @@ var LeaferUI = function(exports) {
7159
7233
  __onLayoutEnd(event) {
7160
7234
  if (event.data) event.data.map(item => {
7161
7235
  let empty;
7162
- if (item.updatedList) item.updatedList.list.some(leaf => {
7236
+ const {updatedList: updatedList} = item;
7237
+ if (updatedList) updatedList.list.some(leaf => {
7163
7238
  empty = !leaf.__world.width || !leaf.__world.height;
7164
7239
  if (empty) {
7165
7240
  if (!leaf.isLeafer) debug$3.tip(leaf.innerName, ": empty");
@@ -7167,7 +7242,7 @@ var LeaferUI = function(exports) {
7167
7242
  }
7168
7243
  return empty;
7169
7244
  });
7170
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
7245
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
7171
7246
  });
7172
7247
  }
7173
7248
  emitRender(type, bounds, options) {
@@ -7367,7 +7442,7 @@ var LeaferUI = function(exports) {
7367
7442
  this.config = {};
7368
7443
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
7369
7444
  this.picker = new Picker(this.target = target, this);
7370
- this.finder = Creator.finder && Creator.finder();
7445
+ this.finder = Creator.finder && Creator.finder(target, this.config);
7371
7446
  }
7372
7447
  getByPoint(hitPoint, hitRadius, options) {
7373
7448
  const {target: target, picker: picker} = this;
@@ -7405,7 +7480,9 @@ var LeaferUI = function(exports) {
7405
7480
  set(value) {
7406
7481
  this.__setAttr(key, value);
7407
7482
  if (value) this.__.__useEffect = true;
7408
- this.__layout.renderChanged || this.__layout.renderChange();
7483
+ const layout = this.__layout;
7484
+ layout.renderChanged || layout.renderChange();
7485
+ layout.surfaceChange();
7409
7486
  }
7410
7487
  }));
7411
7488
  }
@@ -7598,15 +7675,16 @@ var LeaferUI = function(exports) {
7598
7675
  this.__needComputePaint = undefined;
7599
7676
  }
7600
7677
  __getRealStrokeWidth(childStyle) {
7601
- let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
7678
+ let {strokeWidth: strokeWidth, strokeScaleFixed: strokeScaleFixed} = this;
7602
7679
  if (childStyle) {
7603
7680
  if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
7604
- 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;
7605
7686
  }
7606
- if (strokeWidthFixed) {
7607
- const scale = this.__leaf.getClampRenderScale();
7608
- return scale > 1 ? strokeWidth / scale : strokeWidth;
7609
- } else return strokeWidth;
7687
+ return strokeWidth;
7610
7688
  }
7611
7689
  __setPaint(attrName, value) {
7612
7690
  this.__setInput(attrName, value);
@@ -7729,13 +7807,16 @@ var LeaferUI = function(exports) {
7729
7807
  }
7730
7808
  }
7731
7809
  class ImageData extends RectData {
7810
+ get __urlType() {
7811
+ return "image";
7812
+ }
7732
7813
  setUrl(value) {
7733
7814
  this.__setImageFill(value);
7734
7815
  this._url = value;
7735
7816
  }
7736
7817
  __setImageFill(value) {
7737
7818
  this.fill = value ? {
7738
- type: "image",
7819
+ type: this.__urlType,
7739
7820
  mode: "stretch",
7740
7821
  url: value
7741
7822
  } : undefined;
@@ -7771,7 +7852,7 @@ var LeaferUI = function(exports) {
7771
7852
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
7772
7853
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
7773
7854
  boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
7774
- if (!data.__boxStroke) {
7855
+ if (!data.__boxStroke || data.__useArrow) {
7775
7856
  const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
7776
7857
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
7777
7858
  spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
@@ -7922,6 +8003,12 @@ var LeaferUI = function(exports) {
7922
8003
  get isFrame() {
7923
8004
  return false;
7924
8005
  }
8006
+ set strokeWidthFixed(value) {
8007
+ this.strokeScaleFixed = value;
8008
+ }
8009
+ get strokeWidthFixed() {
8010
+ return this.strokeScaleFixed;
8011
+ }
7925
8012
  set scale(value) {
7926
8013
  MathHelper.assignScale(this, value);
7927
8014
  }
@@ -7977,6 +8064,9 @@ var LeaferUI = function(exports) {
7977
8064
  getPathString(curve, pathForRender, floatLength) {
7978
8065
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
7979
8066
  }
8067
+ asPath(curve, pathForRender) {
8068
+ this.path = this.getPath(curve, pathForRender);
8069
+ }
7980
8070
  load() {
7981
8071
  this.__.__computePaint();
7982
8072
  }
@@ -7986,16 +8076,18 @@ var LeaferUI = function(exports) {
7986
8076
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
7987
8077
  }
7988
8078
  }
7989
- __updateRenderPath() {
8079
+ __updateRenderPath(updateCache) {
7990
8080
  const data = this.__;
7991
8081
  if (data.path) {
7992
8082
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7993
- if (data.__useArrow) PathArrow.addArrows(this);
8083
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache);
7994
8084
  } else data.__pathForRender && (data.__pathForRender = undefined);
7995
8085
  }
7996
8086
  __drawRenderPath(canvas) {
8087
+ const data = this.__;
7997
8088
  canvas.beginPath();
7998
- this.__drawPathByData(canvas, this.__.__pathForRender);
8089
+ if (data.__useArrow) PathArrow.updateArrow(this);
8090
+ this.__drawPathByData(canvas, data.__pathForRender);
7999
8091
  }
8000
8092
  __drawPath(canvas) {
8001
8093
  canvas.beginPath();
@@ -8044,6 +8136,7 @@ var LeaferUI = function(exports) {
8044
8136
  static setEditOuter(_toolName) {}
8045
8137
  static setEditInner(_editorName) {}
8046
8138
  destroy() {
8139
+ this.__.__willDestroy = true;
8047
8140
  this.fill = this.stroke = null;
8048
8141
  if (this.__animate) this.killAnimate();
8049
8142
  super.destroy();
@@ -8104,7 +8197,7 @@ var LeaferUI = function(exports) {
8104
8197
  __decorate([ strokeType(undefined, true) ], exports.UI.prototype, "stroke", void 0);
8105
8198
  __decorate([ strokeType("inside") ], exports.UI.prototype, "strokeAlign", void 0);
8106
8199
  __decorate([ strokeType(1, true) ], exports.UI.prototype, "strokeWidth", void 0);
8107
- __decorate([ strokeType(false) ], exports.UI.prototype, "strokeWidthFixed", void 0);
8200
+ __decorate([ strokeType(false) ], exports.UI.prototype, "strokeScaleFixed", void 0);
8108
8201
  __decorate([ strokeType("none") ], exports.UI.prototype, "strokeCap", void 0);
8109
8202
  __decorate([ strokeType("miter") ], exports.UI.prototype, "strokeJoin", void 0);
8110
8203
  __decorate([ strokeType() ], exports.UI.prototype, "dashPattern", void 0);
@@ -8151,7 +8244,10 @@ var LeaferUI = function(exports) {
8151
8244
  }
8152
8245
  toJSON(options) {
8153
8246
  const data = super.toJSON(options);
8154
- 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
+ }
8155
8251
  return data;
8156
8252
  }
8157
8253
  pick(_hitPoint, _options) {
@@ -8293,12 +8389,12 @@ var LeaferUI = function(exports) {
8293
8389
  this.emitLeafer(LeaferEvent.STOP);
8294
8390
  }
8295
8391
  }
8296
- unlockLayout() {
8392
+ unlockLayout(updateLayout = true) {
8297
8393
  this.layouter.start();
8298
- this.updateLayout();
8394
+ if (updateLayout) this.updateLayout();
8299
8395
  }
8300
- lockLayout() {
8301
- this.updateLayout();
8396
+ lockLayout(updateLayout = true) {
8397
+ if (updateLayout) this.updateLayout();
8302
8398
  this.layouter.stop();
8303
8399
  }
8304
8400
  resize(size) {
@@ -8675,9 +8771,9 @@ var LeaferUI = function(exports) {
8675
8771
  return "Ellipse";
8676
8772
  }
8677
8773
  __updatePath() {
8678
- 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;
8679
8775
  const rx = width / 2, ry = height / 2;
8680
- const path = this.__.path = [];
8776
+ const path = data.path = [];
8681
8777
  let open;
8682
8778
  if (innerRadius) {
8683
8779
  if (startAngle || endAngle) {
@@ -8699,7 +8795,7 @@ var LeaferUI = function(exports) {
8699
8795
  }
8700
8796
  }
8701
8797
  if (!open) closePath$2(path);
8702
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
8798
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
8703
8799
  }
8704
8800
  };
8705
8801
  __decorate([ dataProcessor(EllipseData) ], exports.Ellipse.prototype, "__", void 0);
@@ -9155,7 +9251,7 @@ var LeaferUI = function(exports) {
9155
9251
  if (this.viewReady) this.renderer.update();
9156
9252
  }
9157
9253
  __render(canvas, options) {
9158
- if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds));
9254
+ if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds, undefined, undefined, true));
9159
9255
  }
9160
9256
  __onResize(event) {
9161
9257
  this.forEach(leafer => leafer.resize(event));
@@ -9877,6 +9973,7 @@ var LeaferUI = function(exports) {
9877
9973
  this.checkPath(data, useDefaultPath);
9878
9974
  this.downTime = Date.now();
9879
9975
  this.emit(exports.PointerEvent.BEFORE_DOWN, data);
9976
+ if (data.path.needUpdate) this.updateDownData(data);
9880
9977
  this.emit(exports.PointerEvent.DOWN, data);
9881
9978
  if (PointerButton.left(data)) {
9882
9979
  this.tapWait();
@@ -10470,8 +10567,8 @@ var LeaferUI = function(exports) {
10470
10567
  canvas.save();
10471
10568
  if (item.transform) canvas.transform(item.transform);
10472
10569
  if (originPaint.scaleFixed) {
10473
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10474
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10570
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
10571
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
10475
10572
  }
10476
10573
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
10477
10574
  fillPathOrText(ui, canvas, renderOptions);
@@ -10726,11 +10823,14 @@ var LeaferUI = function(exports) {
10726
10823
  function getLeafPaint(attrName, paint, ui) {
10727
10824
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
10728
10825
  let leafPaint;
10729
- const {boxBounds: boxBounds} = ui.__layout;
10730
- switch (paint.type) {
10826
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
10827
+ switch (type) {
10731
10828
  case "image":
10829
+ case "film":
10830
+ case "video":
10732
10831
  if (!paint.url) return undefined;
10733
10832
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10833
+ if (type !== "image") PaintImage[type](leafPaint);
10734
10834
  break;
10735
10835
 
10736
10836
  case "linear":
@@ -10746,7 +10846,7 @@ var LeaferUI = function(exports) {
10746
10846
  break;
10747
10847
 
10748
10848
  case "solid":
10749
- const {type: type, color: color, opacity: opacity} = paint;
10849
+ const {color: color, opacity: opacity} = paint;
10750
10850
  leafPaint = {
10751
10851
  type: type,
10752
10852
  style: ColorConvert.string(color, opacity)
@@ -10786,7 +10886,7 @@ var LeaferUI = function(exports) {
10786
10886
  const {isSame: isSame} = BoundsHelper;
10787
10887
  function image(ui, attrName, paint, boxBounds, firstUse) {
10788
10888
  let leafPaint, event;
10789
- const image = ImageManager.get(paint);
10889
+ const image = ImageManager.get(paint, paint.type);
10790
10890
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
10791
10891
  leafPaint = cache.leafPaint;
10792
10892
  } else {
@@ -10846,8 +10946,8 @@ var LeaferUI = function(exports) {
10846
10946
  return leafPaint;
10847
10947
  }
10848
10948
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10849
- if (attrName === "fill" && !ui.__.__naturalWidth) {
10850
- const data = ui.__;
10949
+ const data = ui.__;
10950
+ if (attrName === "fill" && !data.__naturalWidth) {
10851
10951
  data.__naturalWidth = image.width / data.pixelRatio;
10852
10952
  data.__naturalHeight = image.height / data.pixelRatio;
10853
10953
  if (data.__autoSide) {
@@ -10859,7 +10959,13 @@ var LeaferUI = function(exports) {
10859
10959
  return false;
10860
10960
  }
10861
10961
  }
10862
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
10962
+ if (!leafPaint.data) {
10963
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
10964
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
10965
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
10966
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
10967
+ }
10968
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
10863
10969
  return true;
10864
10970
  }
10865
10971
  function onLoad(ui, event) {
@@ -10891,7 +10997,7 @@ var LeaferUI = function(exports) {
10891
10997
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
10892
10998
  if (paint.mode === "strench") paint.mode = "stretch";
10893
10999
  const {width: width, height: height} = image;
10894
- 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;
11000
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
10895
11001
  const sameBox = box.width === width && box.height === height;
10896
11002
  const data = {
10897
11003
  mode: mode
@@ -10954,8 +11060,6 @@ var LeaferUI = function(exports) {
10954
11060
  data.scaleX = scaleX;
10955
11061
  data.scaleY = scaleY;
10956
11062
  }
10957
- if (opacity && opacity < 1) data.opacity = opacity;
10958
- if (filters) data.filters = filters;
10959
11063
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
10960
11064
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
10961
11065
  type: "x",
@@ -10981,7 +11085,7 @@ var LeaferUI = function(exports) {
10981
11085
  const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
10982
11086
  function stretchMode(data, box, scaleX, scaleY) {
10983
11087
  const transform = get$2(), {x: x, y: y} = box;
10984
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
11088
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
10985
11089
  scaleHelper(transform, scaleX, scaleY);
10986
11090
  data.transform = transform;
10987
11091
  }
@@ -11062,10 +11166,10 @@ var LeaferUI = function(exports) {
11062
11166
  }
11063
11167
  }
11064
11168
  function createPattern(paint, ui, canvas, renderOptions) {
11065
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
11169
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11066
11170
  if (paint.patternId !== id && !ui.destroyed) {
11067
11171
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11068
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11172
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11069
11173
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11070
11174
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11071
11175
  width *= scaleX;
@@ -11081,7 +11185,7 @@ var LeaferUI = function(exports) {
11081
11185
  if (transform) copy$1(imageMatrix, transform);
11082
11186
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11083
11187
  }
11084
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11188
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11085
11189
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11086
11190
  paint.style = pattern;
11087
11191
  paint.patternId = id;
@@ -11100,15 +11204,15 @@ var LeaferUI = function(exports) {
11100
11204
  return fixScale;
11101
11205
  }
11102
11206
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11103
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
11207
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11104
11208
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
11105
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
11209
+ if (!data || paint.patternId === id && !exporting || snapshot) {
11106
11210
  return false;
11107
11211
  } else {
11108
11212
  if (drawImage) {
11109
11213
  if (data.repeat) {
11110
11214
  drawImage = false;
11111
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11215
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11112
11216
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
11113
11217
  }
11114
11218
  }
@@ -11125,20 +11229,21 @@ var LeaferUI = function(exports) {
11125
11229
  }
11126
11230
  }
11127
11231
  }
11128
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
11129
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
11130
- let {width: width, height: height} = image, clipUI;
11131
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
11232
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
11233
+ const {data: data, image: image, complex: complex} = paint;
11234
+ let {width: width, height: height} = image;
11235
+ if (complex) {
11236
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
11132
11237
  canvas.save();
11133
- clipUI && canvas.clipUI(ui);
11238
+ complex === 2 && canvas.clipUI(ui);
11134
11239
  blendMode && (canvas.blendMode = blendMode);
11135
11240
  opacity && (canvas.opacity *= opacity);
11136
11241
  transform && canvas.transform(transform);
11137
- canvas.drawImage(view, 0, 0, width, height);
11242
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
11138
11243
  canvas.restore();
11139
11244
  } else {
11140
11245
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
11141
- canvas.drawImage(view, 0, 0, width, height);
11246
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
11142
11247
  }
11143
11248
  }
11144
11249
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
@@ -11166,6 +11271,7 @@ var LeaferUI = function(exports) {
11166
11271
  if (!recycleMap) recycleMap = {};
11167
11272
  recycleMap[url] = true;
11168
11273
  ImageManager.recyclePaint(paint);
11274
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
11169
11275
  if (image.loading) {
11170
11276
  if (!input) {
11171
11277
  input = data.__input && data.__input[attrName] || [];
@@ -12037,7 +12143,9 @@ var LeaferUI = function(exports) {
12037
12143
  exports.LeaferCanvasBase = LeaferCanvasBase;
12038
12144
  exports.LeaferData = LeaferData;
12039
12145
  exports.LeaferEvent = LeaferEvent;
12146
+ exports.LeaferFilm = LeaferFilm;
12040
12147
  exports.LeaferImage = LeaferImage;
12148
+ exports.LeaferVideo = LeaferVideo;
12041
12149
  exports.LineData = LineData;
12042
12150
  exports.MathHelper = MathHelper;
12043
12151
  exports.Matrix = Matrix;