leafer-draw 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$2(floor(width + (xGap || 0)), 1), realHeight = max$2(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$e.error("not register " + tag);
1939
+ if (!list$1[tag]) {
1940
+ debug$e.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(radius, min(d / 2, d / 2 * abs$2(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(radius, min(r, r * abs$2(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$9 = Debug.get("TaskProcessor");
@@ -4034,6 +4039,9 @@ const debug$8 = 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 = 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$4 = 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$2.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) {
@@ -7990,16 +8028,16 @@ class UIData extends LeafData {
7990
8028
  return t.fill || t.stroke;
7991
8029
  }
7992
8030
  get __autoWidth() {
7993
- return !this._width;
8031
+ return this._width == null;
7994
8032
  }
7995
8033
  get __autoHeight() {
7996
- return !this._height;
8034
+ return this._height == null;
7997
8035
  }
7998
8036
  get __autoSide() {
7999
- return !this._width || !this._height;
8037
+ return this._width == null || this._height == null;
8000
8038
  }
8001
8039
  get __autoSize() {
8002
- return !this._width && !this._height;
8040
+ return this._width == null && this._height == null;
8003
8041
  }
8004
8042
  setVisible(value) {
8005
8043
  this._visible = value;
@@ -8211,13 +8249,16 @@ class TextData extends UIData {
8211
8249
  }
8212
8250
 
8213
8251
  class ImageData extends RectData {
8252
+ get __urlType() {
8253
+ return "image";
8254
+ }
8214
8255
  setUrl(value) {
8215
8256
  this.__setImageFill(value);
8216
8257
  this._url = value;
8217
8258
  }
8218
8259
  __setImageFill(value) {
8219
8260
  this.fill = value ? {
8220
- type: "image",
8261
+ type: this.__urlType,
8221
8262
  mode: "stretch",
8222
8263
  url: value
8223
8264
  } : undefined;
@@ -8717,7 +8758,10 @@ let Group = class Group extends UI {
8717
8758
  }
8718
8759
  toJSON(options) {
8719
8760
  const data = super.toJSON(options);
8720
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8761
+ if (!this.childlessJSON) {
8762
+ const children = data.children = [];
8763
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8764
+ }
8721
8765
  return data;
8722
8766
  }
8723
8767
  pick(_hitPoint, _options) {
@@ -8866,12 +8910,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8866
8910
  this.emitLeafer(LeaferEvent.STOP);
8867
8911
  }
8868
8912
  }
8869
- unlockLayout() {
8913
+ unlockLayout(updateLayout = true) {
8870
8914
  this.layouter.start();
8871
- this.updateLayout();
8915
+ if (updateLayout) this.updateLayout();
8872
8916
  }
8873
- lockLayout() {
8874
- this.updateLayout();
8917
+ lockLayout(updateLayout = true) {
8918
+ if (updateLayout) this.updateLayout();
8875
8919
  this.layouter.stop();
8876
8920
  }
8877
8921
  resize(size) {
@@ -10054,11 +10098,14 @@ function compute(attrName, ui) {
10054
10098
  function getLeafPaint(attrName, paint, ui) {
10055
10099
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
10056
10100
  let leafPaint;
10057
- const {boxBounds: boxBounds} = ui.__layout;
10058
- switch (paint.type) {
10101
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
10102
+ switch (type) {
10059
10103
  case "image":
10104
+ case "film":
10105
+ case "video":
10060
10106
  if (!paint.url) return undefined;
10061
10107
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10108
+ if (type !== "image") PaintImage[type](leafPaint);
10062
10109
  break;
10063
10110
 
10064
10111
  case "linear":
@@ -10074,7 +10121,7 @@ function getLeafPaint(attrName, paint, ui) {
10074
10121
  break;
10075
10122
 
10076
10123
  case "solid":
10077
- const {type: type, color: color, opacity: opacity} = paint;
10124
+ const {color: color, opacity: opacity} = paint;
10078
10125
  leafPaint = {
10079
10126
  type: type,
10080
10127
  style: ColorConvert.string(color, opacity)
@@ -10118,7 +10165,7 @@ const {isSame: isSame} = BoundsHelper;
10118
10165
 
10119
10166
  function image(ui, attrName, paint, boxBounds, firstUse) {
10120
10167
  let leafPaint, event;
10121
- const image = ImageManager.get(paint);
10168
+ const image = ImageManager.get(paint, paint.type);
10122
10169
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
10123
10170
  leafPaint = cache.leafPaint;
10124
10171
  } else {
@@ -10179,8 +10226,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10179
10226
  }
10180
10227
 
10181
10228
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
10182
- if (attrName === "fill" && !ui.__.__naturalWidth) {
10183
- const data = ui.__;
10229
+ const data = ui.__;
10230
+ if (attrName === "fill" && !data.__naturalWidth) {
10184
10231
  data.__naturalWidth = image.width / data.pixelRatio;
10185
10232
  data.__naturalHeight = image.height / data.pixelRatio;
10186
10233
  if (data.__autoSide) {
@@ -10192,7 +10239,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10192
10239
  return false;
10193
10240
  }
10194
10241
  }
10195
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
10242
+ if (!leafPaint.data) {
10243
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
10244
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
10245
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
10246
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
10247
+ }
10196
10248
  return true;
10197
10249
  }
10198
10250
 
@@ -10235,7 +10287,7 @@ function getPatternData(paint, box, image) {
10235
10287
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
10236
10288
  if (paint.mode === "strench") paint.mode = "stretch";
10237
10289
  const {width: width, height: height} = image;
10238
- 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;
10290
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
10239
10291
  const sameBox = box.width === width && box.height === height;
10240
10292
  const data = {
10241
10293
  mode: mode
@@ -10298,8 +10350,6 @@ function getPatternData(paint, box, image) {
10298
10350
  data.scaleX = scaleX;
10299
10351
  data.scaleY = scaleY;
10300
10352
  }
10301
- if (opacity && opacity < 1) data.opacity = opacity;
10302
- if (filters) data.filters = filters;
10303
10353
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
10304
10354
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
10305
10355
  type: "x",
@@ -10330,7 +10380,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
10330
10380
 
10331
10381
  function stretchMode(data, box, scaleX, scaleY) {
10332
10382
  const transform = get$2(), {x: x, y: y} = box;
10333
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
10383
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
10334
10384
  scaleHelper(transform, scaleX, scaleY);
10335
10385
  data.transform = transform;
10336
10386
  }
@@ -10419,10 +10469,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
10419
10469
  }
10420
10470
 
10421
10471
  function createPattern(paint, ui, canvas, renderOptions) {
10422
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
10472
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
10423
10473
  if (paint.patternId !== id && !ui.destroyed) {
10424
10474
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
10425
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
10475
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
10426
10476
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
10427
10477
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
10428
10478
  width *= scaleX;
@@ -10438,7 +10488,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
10438
10488
  if (transform) copy$1(imageMatrix, transform);
10439
10489
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
10440
10490
  }
10441
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
10491
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
10442
10492
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
10443
10493
  paint.style = pattern;
10444
10494
  paint.patternId = id;
@@ -10459,15 +10509,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
10459
10509
  }
10460
10510
 
10461
10511
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10462
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10512
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
10463
10513
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
10464
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
10514
+ if (!data || paint.patternId === id && !exporting || snapshot) {
10465
10515
  return false;
10466
10516
  } else {
10467
10517
  if (drawImage) {
10468
10518
  if (data.repeat) {
10469
10519
  drawImage = false;
10470
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10520
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10471
10521
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
10472
10522
  }
10473
10523
  }
@@ -10485,20 +10535,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10485
10535
  }
10486
10536
  }
10487
10537
 
10488
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10489
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10490
- let {width: width, height: height} = image, clipUI;
10491
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
10538
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
10539
+ const {data: data, image: image, complex: complex} = paint;
10540
+ let {width: width, height: height} = image;
10541
+ if (complex) {
10542
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
10492
10543
  canvas.save();
10493
- clipUI && canvas.clipUI(ui);
10544
+ complex === 2 && canvas.clipUI(ui);
10494
10545
  blendMode && (canvas.blendMode = blendMode);
10495
10546
  opacity && (canvas.opacity *= opacity);
10496
10547
  transform && canvas.transform(transform);
10497
- canvas.drawImage(view, 0, 0, width, height);
10548
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
10498
10549
  canvas.restore();
10499
10550
  } else {
10500
10551
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
10501
- canvas.drawImage(view, 0, 0, width, height);
10552
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
10502
10553
  }
10503
10554
  }
10504
10555
 
@@ -11218,7 +11269,7 @@ function layoutText(drawData, style) {
11218
11269
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11219
11270
  let starY = __baseLine;
11220
11271
  if (__clipText && realHeight > height) {
11221
- realHeight = Math.max(height, __lineHeight);
11272
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
11222
11273
  if (countRows > 1) drawData.overflow = countRows;
11223
11274
  } else if (height || autoSizeAlign) {
11224
11275
  switch (verticalAlign) {
@@ -11275,10 +11326,10 @@ function layoutText(drawData, style) {
11275
11326
  }
11276
11327
 
11277
11328
  function clipText(drawData, style, x, width) {
11278
- if (!width) return;
11279
11329
  const {rows: rows, overflow: overflow} = drawData;
11280
11330
  let {textOverflow: textOverflow} = style;
11281
- rows.splice(overflow);
11331
+ if (overflow) rows.splice(overflow);
11332
+ if (!width) return;
11282
11333
  if (textOverflow && textOverflow !== "show") {
11283
11334
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
11284
11335
  let char, charRight;
@@ -11437,4 +11488,4 @@ Object.assign(Effect, EffectModule);
11437
11488
 
11438
11489
  useCanvas();
11439
11490
 
11440
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, 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, MyImage, 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, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, 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$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
11491
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, 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, MyImage, 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, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, 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$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };