leafer-ui 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,45 @@ var PathNodeHandleType;
7
7
  PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
8
8
  })(PathNodeHandleType || (PathNodeHandleType = {}));
9
9
 
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
+
16
+ function __awaiter(thisArg, _arguments, P, generator) {
17
+ function adopt(value) {
18
+ return value instanceof P ? value : new P(function(resolve) {
19
+ resolve(value);
20
+ });
21
+ }
22
+ return new (P || (P = Promise))(function(resolve, reject) {
23
+ function fulfilled(value) {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ }
30
+ function rejected(value) {
31
+ try {
32
+ step(generator["throw"](value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ }
37
+ function step(result) {
38
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
39
+ }
40
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
41
+ });
42
+ }
43
+
44
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
45
+ var e = new Error(message);
46
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
47
+ };
48
+
10
49
  var Answer;
11
50
 
12
51
  (function(Answer) {
@@ -1727,7 +1766,7 @@ const Platform = {
1727
1766
  resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1728
1767
  const realWidth = max$3(floor(width + (xGap || 0)), 1), realHeight = max$3(floor(height + (yGap || 0)), 1);
1729
1768
  let interlaceX, interlaceY, interlaceOffset;
1730
- if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1769
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1731
1770
  const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1732
1771
  const ctx = canvas.getContext("2d");
1733
1772
  if (opacity) ctx.globalAlpha = opacity;
@@ -1897,7 +1936,10 @@ const UICreator = {
1897
1936
  list$1[tag] = UI;
1898
1937
  },
1899
1938
  get(tag, data, x, y, width, height) {
1900
- if (!list$1[tag]) debug$f.error("not register " + tag);
1939
+ if (!list$1[tag]) {
1940
+ debug$f.warn("not register " + tag);
1941
+ return undefined;
1942
+ }
1901
1943
  const ui = new list$1[tag](data);
1902
1944
  if (!isUndefined(x)) {
1903
1945
  ui.x = x;
@@ -1988,45 +2030,6 @@ class CanvasManager {
1988
2030
  }
1989
2031
  }
1990
2032
 
1991
- function __decorate(decorators, target, key, desc) {
1992
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1993
- 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;
1994
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1995
- }
1996
-
1997
- function __awaiter(thisArg, _arguments, P, generator) {
1998
- function adopt(value) {
1999
- return value instanceof P ? value : new P(function(resolve) {
2000
- resolve(value);
2001
- });
2002
- }
2003
- return new (P || (P = Promise))(function(resolve, reject) {
2004
- function fulfilled(value) {
2005
- try {
2006
- step(generator.next(value));
2007
- } catch (e) {
2008
- reject(e);
2009
- }
2010
- }
2011
- function rejected(value) {
2012
- try {
2013
- step(generator["throw"](value));
2014
- } catch (e) {
2015
- reject(e);
2016
- }
2017
- }
2018
- function step(result) {
2019
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
2020
- }
2021
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2022
- });
2023
- }
2024
-
2025
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
2026
- var e = new Error(message);
2027
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2028
- };
2029
-
2030
2033
  function contextAttr(realName) {
2031
2034
  return (target, key) => {
2032
2035
  if (!realName) realName = key;
@@ -3317,10 +3320,10 @@ const PathCommandDataHelper = {
3317
3320
  data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
3318
3321
  }
3319
3322
  },
3320
- arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3323
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY, fullRadius) {
3321
3324
  if (!isUndefined(lastX)) {
3322
- const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3323
- radius = min$1(radius, min$1(d / 2, d / 2 * abs$3(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3325
+ const r = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / (fullRadius ? 1 : 2);
3326
+ radius = min$1(radius, min$1(r, r * abs$3(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3324
3327
  }
3325
3328
  data.push(U$2, x1, y1, x2, y2, radius);
3326
3329
  },
@@ -3664,7 +3667,7 @@ const PathCorner = {
3664
3667
  let command, lastCommand, commandLen;
3665
3668
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3666
3669
  if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
3667
- const len = data.length;
3670
+ const len = data.length, three = len === 9;
3668
3671
  const smooth = [];
3669
3672
  while (i < len) {
3670
3673
  command = data[i];
@@ -3676,7 +3679,7 @@ const PathCorner = {
3676
3679
  if (data[i] === L$1) {
3677
3680
  secondX = data[i + 1];
3678
3681
  secondY = data[i + 2];
3679
- smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
3682
+ three ? smooth.push(M, startX, startY) : smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
3680
3683
  } else {
3681
3684
  smooth.push(M, startX, startY);
3682
3685
  }
@@ -3688,11 +3691,11 @@ const PathCorner = {
3688
3691
  i += 3;
3689
3692
  switch (data[i]) {
3690
3693
  case L$1:
3691
- arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3694
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY, three);
3692
3695
  break;
3693
3696
 
3694
3697
  case Z:
3695
- arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3698
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
3696
3699
  break;
3697
3700
 
3698
3701
  default:
@@ -3704,7 +3707,7 @@ const PathCorner = {
3704
3707
 
3705
3708
  case Z:
3706
3709
  if (lastCommand !== Z) {
3707
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3710
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY, three);
3708
3711
  smooth.push(Z);
3709
3712
  }
3710
3713
  i += 1;
@@ -3754,10 +3757,10 @@ function canvasPatch(drawer) {
3754
3757
  const FileHelper = {
3755
3758
  alphaPixelTypes: [ "png", "webp", "svg" ],
3756
3759
  upperCaseTypeMap: {},
3757
- mineType(type) {
3758
- if (!type || type.startsWith("image")) return type;
3760
+ mimeType(type, base = "image") {
3761
+ if (!type || type.startsWith(base)) return type;
3759
3762
  if (type === "jpg") type = "jpeg";
3760
- return "image/" + type;
3763
+ return base + "/" + type;
3761
3764
  },
3762
3765
  fileType(filename) {
3763
3766
  const l = filename.split(".");
@@ -3790,6 +3793,8 @@ const FileHelper = {
3790
3793
 
3791
3794
  const F = FileHelper;
3792
3795
 
3796
+ F.mineType = F.mimeType;
3797
+
3793
3798
  F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3794
3799
 
3795
3800
  const debug$a = Debug.get("TaskProcessor");
@@ -4034,6 +4039,9 @@ const debug$9 = Debug.get("Resource");
4034
4039
 
4035
4040
  const Resource = {
4036
4041
  tasker: new TaskProcessor,
4042
+ queue: new TaskProcessor({
4043
+ parallel: 1
4044
+ }),
4037
4045
  map: {},
4038
4046
  get isComplete() {
4039
4047
  return R.tasker.isComplete;
@@ -4070,6 +4078,12 @@ const Resource = {
4070
4078
  R.set(key, value);
4071
4079
  return value;
4072
4080
  },
4081
+ loadFilm(_key, _format) {
4082
+ return undefined;
4083
+ },
4084
+ loadVideo(_key, _format) {
4085
+ return undefined;
4086
+ },
4073
4087
  destroy() {
4074
4088
  R.map = {};
4075
4089
  }
@@ -4080,12 +4094,10 @@ const R = Resource;
4080
4094
  const ImageManager = {
4081
4095
  maxRecycled: 10,
4082
4096
  recycledList: [],
4083
- patternTasker: new TaskProcessor({
4084
- parallel: 1
4085
- }),
4086
- get(config) {
4097
+ patternTasker: Resource.queue,
4098
+ get(config, type) {
4087
4099
  let image = Resource.get(config.url);
4088
- if (!image) Resource.set(config.url, image = Creator.image(config));
4100
+ if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
4089
4101
  image.use++;
4090
4102
  return image;
4091
4103
  },
@@ -4120,7 +4132,7 @@ const ImageManager = {
4120
4132
  if (config.format) return config.format === format;
4121
4133
  const {url: url} = config;
4122
4134
  if (url.startsWith("data:")) {
4123
- if (url.startsWith("data:" + FileHelper.mineType(format))) return true;
4135
+ if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
4124
4136
  } else {
4125
4137
  if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
4126
4138
  }
@@ -4136,6 +4148,9 @@ const I$1 = ImageManager;
4136
4148
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
4137
4149
 
4138
4150
  class LeaferImage {
4151
+ get tag() {
4152
+ return "Image";
4153
+ }
4139
4154
  get url() {
4140
4155
  return this.config.url;
4141
4156
  }
@@ -4164,7 +4179,7 @@ class LeaferImage {
4164
4179
  if (!this.loading) {
4165
4180
  this.loading = true;
4166
4181
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
4167
- return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4182
+ return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4168
4183
  if (thumbSize) this.setThumbView(img);
4169
4184
  this.setView(img);
4170
4185
  }).catch(e => {
@@ -4238,6 +4253,9 @@ class LeaferImage {
4238
4253
  Platform.image.setPatternTransform(pattern, transform, paint);
4239
4254
  return pattern;
4240
4255
  }
4256
+ render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
4257
+ canvas.drawImage(this.view, x, y, width, height);
4258
+ }
4241
4259
  getLoadUrl(_thumbSize) {
4242
4260
  return this.url;
4243
4261
  }
@@ -4264,6 +4282,18 @@ class LeaferImage {
4264
4282
  }
4265
4283
  }
4266
4284
 
4285
+ class LeaferFilm extends LeaferImage {
4286
+ get tag() {
4287
+ return "Film";
4288
+ }
4289
+ }
4290
+
4291
+ class LeaferVideo extends LeaferImage {
4292
+ get tag() {
4293
+ return "Video";
4294
+ }
4295
+ }
4296
+
4267
4297
  function defineKey(target, key, descriptor, noConfigurable) {
4268
4298
  if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
4269
4299
  Object.defineProperty(target, key, descriptor);
@@ -6152,9 +6182,11 @@ const BranchRender = {
6152
6182
  if (this.__hasMask) {
6153
6183
  this.__renderMask(canvas, options);
6154
6184
  } else {
6185
+ let child;
6155
6186
  const {children: children} = this;
6156
6187
  for (let i = 0, len = children.length; i < len; i++) {
6157
- excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
6188
+ child = children[i];
6189
+ excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
6158
6190
  }
6159
6191
  }
6160
6192
  },
@@ -6635,6 +6667,7 @@ let Leaf = class Leaf {
6635
6667
  __drawHitPath(_canvas) {}
6636
6668
  __updateHitCanvas() {}
6637
6669
  __render(_canvas, _options) {}
6670
+ __renderComplex(_canvas, _options) {}
6638
6671
  __drawFast(_canvas, _options) {}
6639
6672
  __draw(_canvas, _options, _originCanvas) {}
6640
6673
  __clip(_canvas, _options) {}
@@ -6754,6 +6787,7 @@ let Branch = class Branch extends Leaf {
6754
6787
  this.add(item, index);
6755
6788
  noIndex || index++;
6756
6789
  }); else child = UICreator.get(child.tag, child);
6790
+ if (!child) return;
6757
6791
  }
6758
6792
  if (child.parent) child.parent.remove(child);
6759
6793
  child.parent = this;
@@ -6979,7 +7013,7 @@ class LeafLevelList {
6979
7013
  }
6980
7014
  }
6981
7015
 
6982
- const version = "2.0.0";
7016
+ const version = "2.0.2";
6983
7017
 
6984
7018
  const debug$5 = Debug.get("LeaferCanvas");
6985
7019
 
@@ -7184,8 +7218,6 @@ canvasPatch(CanvasRenderingContext2D.prototype);
7184
7218
 
7185
7219
  canvasPatch(Path2D.prototype);
7186
7220
 
7187
- const {mineType: mineType, fileType: fileType} = FileHelper;
7188
-
7189
7221
  Object.assign(Creator, {
7190
7222
  canvas: (options, manager) => new LeaferCanvas(options, manager),
7191
7223
  image: options => new LeaferImage(options)
@@ -7200,29 +7232,27 @@ function useCanvas(_canvasType, _power) {
7200
7232
  return canvas;
7201
7233
  },
7202
7234
  canvasToDataURL: (canvas, type, quality) => {
7203
- const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
7235
+ const imageType = FileHelper.mimeType(type), url = canvas.toDataURL(imageType, quality);
7204
7236
  return imageType === "image/bmp" ? url.replace("image/png;", "image/bmp;") : url;
7205
7237
  },
7206
- canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, mineType(type), quality)),
7238
+ canvasToBolb: (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, FileHelper.mimeType(type), quality)),
7207
7239
  canvasSaveAs: (canvas, filename, quality) => {
7208
- const url = canvas.toDataURL(mineType(fileType(filename)), quality);
7240
+ const url = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filename)), quality);
7209
7241
  return Platform.origin.download(url, filename);
7210
7242
  },
7211
7243
  download(url, filename) {
7212
- return new Promise(resolve => {
7244
+ return __awaiter(this, void 0, void 0, function*() {
7213
7245
  let el = document.createElement("a");
7214
7246
  el.href = url;
7215
7247
  el.download = filename;
7216
7248
  document.body.appendChild(el);
7217
7249
  el.click();
7218
7250
  document.body.removeChild(el);
7219
- resolve();
7220
7251
  });
7221
7252
  },
7222
- loadImage(src) {
7253
+ loadImage(src, crossOrigin, _leaferImage) {
7223
7254
  return new Promise((resolve, reject) => {
7224
7255
  const img = new Platform.origin.Image;
7225
- const {crossOrigin: crossOrigin} = Platform.image;
7226
7256
  if (crossOrigin) {
7227
7257
  img.setAttribute("crossOrigin", crossOrigin);
7228
7258
  img.crossOrigin = crossOrigin;
@@ -7236,6 +7266,13 @@ function useCanvas(_canvasType, _power) {
7236
7266
  img.src = Platform.image.getRealURL(src);
7237
7267
  });
7238
7268
  },
7269
+ loadContent(url_1) {
7270
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
7271
+ const response = yield fetch(url);
7272
+ if (!response.ok) throw new Error(`${response.status}`);
7273
+ return yield response[responseType]();
7274
+ });
7275
+ },
7239
7276
  Image: Image,
7240
7277
  PointerEvent: PointerEvent,
7241
7278
  DragEvent: DragEvent
@@ -7747,7 +7784,7 @@ class Renderer {
7747
7784
  getCellList() {
7748
7785
  return undefined;
7749
7786
  }
7750
- addBlock(block) {
7787
+ addBlock(block, _leafList) {
7751
7788
  if (!this.updateBlocks) this.updateBlocks = [];
7752
7789
  this.updateBlocks.push(block);
7753
7790
  }
@@ -7795,7 +7832,8 @@ class Renderer {
7795
7832
  __onLayoutEnd(event) {
7796
7833
  if (event.data) event.data.map(item => {
7797
7834
  let empty;
7798
- if (item.updatedList) item.updatedList.list.some(leaf => {
7835
+ const {updatedList: updatedList} = item;
7836
+ if (updatedList) updatedList.list.some(leaf => {
7799
7837
  empty = !leaf.__world.width || !leaf.__world.height;
7800
7838
  if (empty) {
7801
7839
  if (!leaf.isLeafer) debug$3.tip(leaf.innerName, ": empty");
@@ -7803,7 +7841,7 @@ class Renderer {
7803
7841
  }
7804
7842
  return empty;
7805
7843
  });
7806
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
7844
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
7807
7845
  });
7808
7846
  }
7809
7847
  emitRender(type, bounds, options) {
@@ -8190,16 +8228,16 @@ class UIData extends LeafData {
8190
8228
  return t.fill || t.stroke;
8191
8229
  }
8192
8230
  get __autoWidth() {
8193
- return !this._width;
8231
+ return this._width == null;
8194
8232
  }
8195
8233
  get __autoHeight() {
8196
- return !this._height;
8234
+ return this._height == null;
8197
8235
  }
8198
8236
  get __autoSide() {
8199
- return !this._width || !this._height;
8237
+ return this._width == null || this._height == null;
8200
8238
  }
8201
8239
  get __autoSize() {
8202
- return !this._width && !this._height;
8240
+ return this._width == null && this._height == null;
8203
8241
  }
8204
8242
  setVisible(value) {
8205
8243
  this._visible = value;
@@ -8411,13 +8449,16 @@ class TextData extends UIData {
8411
8449
  }
8412
8450
 
8413
8451
  class ImageData extends RectData {
8452
+ get __urlType() {
8453
+ return "image";
8454
+ }
8414
8455
  setUrl(value) {
8415
8456
  this.__setImageFill(value);
8416
8457
  this._url = value;
8417
8458
  }
8418
8459
  __setImageFill(value) {
8419
8460
  this.fill = value ? {
8420
- type: "image",
8461
+ type: this.__urlType,
8421
8462
  mode: "stretch",
8422
8463
  url: value
8423
8464
  } : undefined;
@@ -8917,7 +8958,10 @@ let Group = class Group extends UI {
8917
8958
  }
8918
8959
  toJSON(options) {
8919
8960
  const data = super.toJSON(options);
8920
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8961
+ if (!this.childlessJSON) {
8962
+ const children = data.children = [];
8963
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8964
+ }
8921
8965
  return data;
8922
8966
  }
8923
8967
  pick(_hitPoint, _options) {
@@ -9066,12 +9110,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9066
9110
  this.emitLeafer(LeaferEvent.STOP);
9067
9111
  }
9068
9112
  }
9069
- unlockLayout() {
9113
+ unlockLayout(updateLayout = true) {
9070
9114
  this.layouter.start();
9071
- this.updateLayout();
9115
+ if (updateLayout) this.updateLayout();
9072
9116
  }
9073
- lockLayout() {
9074
- this.updateLayout();
9117
+ lockLayout(updateLayout = true) {
9118
+ if (updateLayout) this.updateLayout();
9075
9119
  this.layouter.stop();
9076
9120
  }
9077
9121
  resize(size) {
@@ -10864,6 +10908,7 @@ class InteractionBase {
10864
10908
  this.checkPath(data, useDefaultPath);
10865
10909
  this.downTime = Date.now();
10866
10910
  this.emit(PointerEvent$1.BEFORE_DOWN, data);
10911
+ if (data.path.needUpdate) this.updateDownData(data);
10867
10912
  this.emit(PointerEvent$1.DOWN, data);
10868
10913
  if (PointerButton.left(data)) {
10869
10914
  this.tapWait();
@@ -12089,11 +12134,14 @@ function compute(attrName, ui) {
12089
12134
  function getLeafPaint(attrName, paint, ui) {
12090
12135
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
12091
12136
  let leafPaint;
12092
- const {boxBounds: boxBounds} = ui.__layout;
12093
- switch (paint.type) {
12137
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
12138
+ switch (type) {
12094
12139
  case "image":
12140
+ case "film":
12141
+ case "video":
12095
12142
  if (!paint.url) return undefined;
12096
12143
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
12144
+ if (type !== "image") PaintImage[type](leafPaint);
12097
12145
  break;
12098
12146
 
12099
12147
  case "linear":
@@ -12109,7 +12157,7 @@ function getLeafPaint(attrName, paint, ui) {
12109
12157
  break;
12110
12158
 
12111
12159
  case "solid":
12112
- const {type: type, color: color, opacity: opacity} = paint;
12160
+ const {color: color, opacity: opacity} = paint;
12113
12161
  leafPaint = {
12114
12162
  type: type,
12115
12163
  style: ColorConvert.string(color, opacity)
@@ -12153,7 +12201,7 @@ const {isSame: isSame} = BoundsHelper;
12153
12201
 
12154
12202
  function image(ui, attrName, paint, boxBounds, firstUse) {
12155
12203
  let leafPaint, event;
12156
- const image = ImageManager.get(paint);
12204
+ const image = ImageManager.get(paint, paint.type);
12157
12205
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
12158
12206
  leafPaint = cache.leafPaint;
12159
12207
  } else {
@@ -12214,8 +12262,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
12214
12262
  }
12215
12263
 
12216
12264
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
12217
- if (attrName === "fill" && !ui.__.__naturalWidth) {
12218
- const data = ui.__;
12265
+ const data = ui.__;
12266
+ if (attrName === "fill" && !data.__naturalWidth) {
12219
12267
  data.__naturalWidth = image.width / data.pixelRatio;
12220
12268
  data.__naturalHeight = image.height / data.pixelRatio;
12221
12269
  if (data.__autoSide) {
@@ -12227,7 +12275,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
12227
12275
  return false;
12228
12276
  }
12229
12277
  }
12230
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
12278
+ if (!leafPaint.data) {
12279
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
12280
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
12281
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
12282
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
12283
+ }
12231
12284
  return true;
12232
12285
  }
12233
12286
 
@@ -12270,7 +12323,7 @@ function getPatternData(paint, box, image) {
12270
12323
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
12271
12324
  if (paint.mode === "strench") paint.mode = "stretch";
12272
12325
  const {width: width, height: height} = image;
12273
- 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;
12326
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
12274
12327
  const sameBox = box.width === width && box.height === height;
12275
12328
  const data = {
12276
12329
  mode: mode
@@ -12333,8 +12386,6 @@ function getPatternData(paint, box, image) {
12333
12386
  data.scaleX = scaleX;
12334
12387
  data.scaleY = scaleY;
12335
12388
  }
12336
- if (opacity && opacity < 1) data.opacity = opacity;
12337
- if (filters) data.filters = filters;
12338
12389
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
12339
12390
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
12340
12391
  type: "x",
@@ -12365,7 +12416,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
12365
12416
 
12366
12417
  function stretchMode(data, box, scaleX, scaleY) {
12367
12418
  const transform = get$2(), {x: x, y: y} = box;
12368
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
12419
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
12369
12420
  scaleHelper(transform, scaleX, scaleY);
12370
12421
  data.transform = transform;
12371
12422
  }
@@ -12454,10 +12505,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
12454
12505
  }
12455
12506
 
12456
12507
  function createPattern(paint, ui, canvas, renderOptions) {
12457
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
12508
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12458
12509
  if (paint.patternId !== id && !ui.destroyed) {
12459
12510
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
12460
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12511
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12461
12512
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
12462
12513
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
12463
12514
  width *= scaleX;
@@ -12473,7 +12524,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12473
12524
  if (transform) copy$1(imageMatrix, transform);
12474
12525
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
12475
12526
  }
12476
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12527
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12477
12528
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12478
12529
  paint.style = pattern;
12479
12530
  paint.patternId = id;
@@ -12494,15 +12545,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
12494
12545
  }
12495
12546
 
12496
12547
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12497
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
12548
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12498
12549
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
12499
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
12550
+ if (!data || paint.patternId === id && !exporting || snapshot) {
12500
12551
  return false;
12501
12552
  } else {
12502
12553
  if (drawImage) {
12503
12554
  if (data.repeat) {
12504
12555
  drawImage = false;
12505
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12556
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12506
12557
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
12507
12558
  }
12508
12559
  }
@@ -12520,20 +12571,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12520
12571
  }
12521
12572
  }
12522
12573
 
12523
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
12524
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
12525
- let {width: width, height: height} = image, clipUI;
12526
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
12574
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
12575
+ const {data: data, image: image, complex: complex} = paint;
12576
+ let {width: width, height: height} = image;
12577
+ if (complex) {
12578
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
12527
12579
  canvas.save();
12528
- clipUI && canvas.clipUI(ui);
12580
+ complex === 2 && canvas.clipUI(ui);
12529
12581
  blendMode && (canvas.blendMode = blendMode);
12530
12582
  opacity && (canvas.opacity *= opacity);
12531
12583
  transform && canvas.transform(transform);
12532
- canvas.drawImage(view, 0, 0, width, height);
12584
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12533
12585
  canvas.restore();
12534
12586
  } else {
12535
12587
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
12536
- canvas.drawImage(view, 0, 0, width, height);
12588
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12537
12589
  }
12538
12590
  }
12539
12591
 
@@ -13253,7 +13305,7 @@ function layoutText(drawData, style) {
13253
13305
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
13254
13306
  let starY = __baseLine;
13255
13307
  if (__clipText && realHeight > height) {
13256
- realHeight = Math.max(height, __lineHeight);
13308
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
13257
13309
  if (countRows > 1) drawData.overflow = countRows;
13258
13310
  } else if (height || autoSizeAlign) {
13259
13311
  switch (verticalAlign) {
@@ -13310,10 +13362,10 @@ function layoutText(drawData, style) {
13310
13362
  }
13311
13363
 
13312
13364
  function clipText(drawData, style, x, width) {
13313
- if (!width) return;
13314
13365
  const {rows: rows, overflow: overflow} = drawData;
13315
13366
  let {textOverflow: textOverflow} = style;
13316
- rows.splice(overflow);
13367
+ if (overflow) rows.splice(overflow);
13368
+ if (!width) return;
13317
13369
  if (textOverflow && textOverflow !== "show") {
13318
13370
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
13319
13371
  let char, charRight;
@@ -13478,4 +13530,4 @@ Object.assign(Creator, {
13478
13530
 
13479
13531
  useCanvas();
13480
13532
 
13481
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
13533
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };