@leafer-ui/miniapp 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.
@@ -1727,7 +1727,7 @@ const Platform = {
1727
1727
  resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1728
1728
  const realWidth = max$3(floor(width + (xGap || 0)), 1), realHeight = max$3(floor(height + (yGap || 0)), 1);
1729
1729
  let interlaceX, interlaceY, interlaceOffset;
1730
- if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1730
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, interlace.type === "x" ? width : height))) interlace.type === "x" ? interlaceX = true : interlaceY = true;
1731
1731
  const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1732
1732
  const ctx = canvas.getContext("2d");
1733
1733
  if (opacity) ctx.globalAlpha = opacity;
@@ -1897,7 +1897,10 @@ const UICreator = {
1897
1897
  list$1[tag] = UI;
1898
1898
  },
1899
1899
  get(tag, data, x, y, width, height) {
1900
- if (!list$1[tag]) debug$e.error("not register " + tag);
1900
+ if (!list$1[tag]) {
1901
+ debug$e.warn("not register " + tag);
1902
+ return undefined;
1903
+ }
1901
1904
  const ui = new list$1[tag](data);
1902
1905
  if (!isUndefined(x)) {
1903
1906
  ui.x = x;
@@ -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$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$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
  class LeaferCanvas extends LeaferCanvasBase {
6985
7019
  get allowBackgroundColor() {
@@ -7084,8 +7118,6 @@ class LeaferCanvas extends LeaferCanvasBase {
7084
7118
  }
7085
7119
  }
7086
7120
 
7087
- const {mineType: mineType, fileType: fileType} = FileHelper;
7088
-
7089
7121
  Object.assign(Creator, {
7090
7122
  canvas: (options, manager) => new LeaferCanvas(options, manager),
7091
7123
  image: options => new LeaferImage(options)
@@ -7101,12 +7133,12 @@ function useCanvas(_canvasType, app) {
7101
7133
  };
7102
7134
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
7103
7135
  },
7104
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
7136
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
7105
7137
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
7106
7138
  quality: quality
7107
7139
  }),
7108
7140
  canvasSaveAs: (canvas, filePath, quality) => {
7109
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
7141
+ let data = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filePath)), quality);
7110
7142
  data = data.substring(data.indexOf("64,") + 3);
7111
7143
  return Platform.origin.download(data, filePath);
7112
7144
  },
@@ -7140,7 +7172,7 @@ function useCanvas(_canvasType, app) {
7140
7172
  });
7141
7173
  });
7142
7174
  },
7143
- loadImage(src) {
7175
+ loadImage(src, _crossOrigin, _leaferImage) {
7144
7176
  return new Promise((resolve, reject) => {
7145
7177
  const img = Platform.canvas.view.createImage();
7146
7178
  img.onload = () => {
@@ -7152,6 +7184,14 @@ function useCanvas(_canvasType, app) {
7152
7184
  img.src = Platform.image.getRealURL(src);
7153
7185
  });
7154
7186
  },
7187
+ loadContent(url, responseType = "text") {
7188
+ return new Promise((resolve, reject) => app.request({
7189
+ url: url,
7190
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
7191
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
7192
+ fail: reject
7193
+ }));
7194
+ },
7155
7195
  noRepeat: "repeat-x"
7156
7196
  };
7157
7197
  Platform.miniapp = {
@@ -7703,7 +7743,7 @@ class Renderer {
7703
7743
  getCellList() {
7704
7744
  return undefined;
7705
7745
  }
7706
- addBlock(block) {
7746
+ addBlock(block, _leafList) {
7707
7747
  if (!this.updateBlocks) this.updateBlocks = [];
7708
7748
  this.updateBlocks.push(block);
7709
7749
  }
@@ -7751,7 +7791,8 @@ class Renderer {
7751
7791
  __onLayoutEnd(event) {
7752
7792
  if (event.data) event.data.map(item => {
7753
7793
  let empty;
7754
- if (item.updatedList) item.updatedList.list.some(leaf => {
7794
+ const {updatedList: updatedList} = item;
7795
+ if (updatedList) updatedList.list.some(leaf => {
7755
7796
  empty = !leaf.__world.width || !leaf.__world.height;
7756
7797
  if (empty) {
7757
7798
  if (!leaf.isLeafer) debug$3.tip(leaf.innerName, ": empty");
@@ -7759,7 +7800,7 @@ class Renderer {
7759
7800
  }
7760
7801
  return empty;
7761
7802
  });
7762
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
7803
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
7763
7804
  });
7764
7805
  }
7765
7806
  emitRender(type, bounds, options) {
@@ -8146,16 +8187,16 @@ class UIData extends LeafData {
8146
8187
  return t.fill || t.stroke;
8147
8188
  }
8148
8189
  get __autoWidth() {
8149
- return !this._width;
8190
+ return this._width == null;
8150
8191
  }
8151
8192
  get __autoHeight() {
8152
- return !this._height;
8193
+ return this._height == null;
8153
8194
  }
8154
8195
  get __autoSide() {
8155
- return !this._width || !this._height;
8196
+ return this._width == null || this._height == null;
8156
8197
  }
8157
8198
  get __autoSize() {
8158
- return !this._width && !this._height;
8199
+ return this._width == null && this._height == null;
8159
8200
  }
8160
8201
  setVisible(value) {
8161
8202
  this._visible = value;
@@ -8367,13 +8408,16 @@ class TextData extends UIData {
8367
8408
  }
8368
8409
 
8369
8410
  class ImageData extends RectData {
8411
+ get __urlType() {
8412
+ return "image";
8413
+ }
8370
8414
  setUrl(value) {
8371
8415
  this.__setImageFill(value);
8372
8416
  this._url = value;
8373
8417
  }
8374
8418
  __setImageFill(value) {
8375
8419
  this.fill = value ? {
8376
- type: "image",
8420
+ type: this.__urlType,
8377
8421
  mode: "stretch",
8378
8422
  url: value
8379
8423
  } : undefined;
@@ -8873,7 +8917,10 @@ let Group = class Group extends UI {
8873
8917
  }
8874
8918
  toJSON(options) {
8875
8919
  const data = super.toJSON(options);
8876
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options));
8920
+ if (!this.childlessJSON) {
8921
+ const children = data.children = [];
8922
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
8923
+ }
8877
8924
  return data;
8878
8925
  }
8879
8926
  pick(_hitPoint, _options) {
@@ -9022,12 +9069,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
9022
9069
  this.emitLeafer(LeaferEvent.STOP);
9023
9070
  }
9024
9071
  }
9025
- unlockLayout() {
9072
+ unlockLayout(updateLayout = true) {
9026
9073
  this.layouter.start();
9027
- this.updateLayout();
9074
+ if (updateLayout) this.updateLayout();
9028
9075
  }
9029
- lockLayout() {
9030
- this.updateLayout();
9076
+ lockLayout(updateLayout = true) {
9077
+ if (updateLayout) this.updateLayout();
9031
9078
  this.layouter.stop();
9032
9079
  }
9033
9080
  resize(size) {
@@ -10820,6 +10867,7 @@ class InteractionBase {
10820
10867
  this.checkPath(data, useDefaultPath);
10821
10868
  this.downTime = Date.now();
10822
10869
  this.emit(PointerEvent.BEFORE_DOWN, data);
10870
+ if (data.path.needUpdate) this.updateDownData(data);
10823
10871
  this.emit(PointerEvent.DOWN, data);
10824
10872
  if (PointerButton.left(data)) {
10825
10873
  this.tapWait();
@@ -11829,11 +11877,14 @@ function compute(attrName, ui) {
11829
11877
  function getLeafPaint(attrName, paint, ui) {
11830
11878
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11831
11879
  let leafPaint;
11832
- const {boxBounds: boxBounds} = ui.__layout;
11833
- switch (paint.type) {
11880
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
11881
+ switch (type) {
11834
11882
  case "image":
11883
+ case "film":
11884
+ case "video":
11835
11885
  if (!paint.url) return undefined;
11836
11886
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11887
+ if (type !== "image") PaintImage[type](leafPaint);
11837
11888
  break;
11838
11889
 
11839
11890
  case "linear":
@@ -11849,7 +11900,7 @@ function getLeafPaint(attrName, paint, ui) {
11849
11900
  break;
11850
11901
 
11851
11902
  case "solid":
11852
- const {type: type, color: color, opacity: opacity} = paint;
11903
+ const {color: color, opacity: opacity} = paint;
11853
11904
  leafPaint = {
11854
11905
  type: type,
11855
11906
  style: ColorConvert.string(color, opacity)
@@ -11893,7 +11944,7 @@ const {isSame: isSame} = BoundsHelper;
11893
11944
 
11894
11945
  function image(ui, attrName, paint, boxBounds, firstUse) {
11895
11946
  let leafPaint, event;
11896
- const image = ImageManager.get(paint);
11947
+ const image = ImageManager.get(paint, paint.type);
11897
11948
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
11898
11949
  leafPaint = cache.leafPaint;
11899
11950
  } else {
@@ -11954,8 +12005,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11954
12005
  }
11955
12006
 
11956
12007
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
11957
- if (attrName === "fill" && !ui.__.__naturalWidth) {
11958
- const data = ui.__;
12008
+ const data = ui.__;
12009
+ if (attrName === "fill" && !data.__naturalWidth) {
11959
12010
  data.__naturalWidth = image.width / data.pixelRatio;
11960
12011
  data.__naturalHeight = image.height / data.pixelRatio;
11961
12012
  if (data.__autoSide) {
@@ -11967,7 +12018,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
11967
12018
  return false;
11968
12019
  }
11969
12020
  }
11970
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
12021
+ if (!leafPaint.data) {
12022
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
12023
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
12024
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
12025
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
12026
+ }
11971
12027
  return true;
11972
12028
  }
11973
12029
 
@@ -12010,7 +12066,7 @@ function getPatternData(paint, box, image) {
12010
12066
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
12011
12067
  if (paint.mode === "strench") paint.mode = "stretch";
12012
12068
  const {width: width, height: height} = image;
12013
- 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;
12069
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
12014
12070
  const sameBox = box.width === width && box.height === height;
12015
12071
  const data = {
12016
12072
  mode: mode
@@ -12073,8 +12129,6 @@ function getPatternData(paint, box, image) {
12073
12129
  data.scaleX = scaleX;
12074
12130
  data.scaleY = scaleY;
12075
12131
  }
12076
- if (opacity && opacity < 1) data.opacity = opacity;
12077
- if (filters) data.filters = filters;
12078
12132
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
12079
12133
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
12080
12134
  type: "x",
@@ -12105,7 +12159,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
12105
12159
 
12106
12160
  function stretchMode(data, box, scaleX, scaleY) {
12107
12161
  const transform = get$2(), {x: x, y: y} = box;
12108
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
12162
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
12109
12163
  scaleHelper(transform, scaleX, scaleY);
12110
12164
  data.transform = transform;
12111
12165
  }
@@ -12194,10 +12248,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
12194
12248
  }
12195
12249
 
12196
12250
  function createPattern(paint, ui, canvas, renderOptions) {
12197
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
12251
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12198
12252
  if (paint.patternId !== id && !ui.destroyed) {
12199
12253
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
12200
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12254
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12201
12255
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
12202
12256
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
12203
12257
  width *= scaleX;
@@ -12213,7 +12267,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12213
12267
  if (transform) copy$1(imageMatrix, transform);
12214
12268
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
12215
12269
  }
12216
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12270
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12217
12271
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12218
12272
  paint.style = pattern;
12219
12273
  paint.patternId = id;
@@ -12234,15 +12288,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
12234
12288
  }
12235
12289
 
12236
12290
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12237
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
12291
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12238
12292
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
12239
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
12293
+ if (!data || paint.patternId === id && !exporting || snapshot) {
12240
12294
  return false;
12241
12295
  } else {
12242
12296
  if (drawImage) {
12243
12297
  if (data.repeat) {
12244
12298
  drawImage = false;
12245
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12299
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12246
12300
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
12247
12301
  }
12248
12302
  }
@@ -12260,20 +12314,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12260
12314
  }
12261
12315
  }
12262
12316
 
12263
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
12264
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
12265
- let {width: width, height: height} = image, clipUI;
12266
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
12317
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
12318
+ const {data: data, image: image, complex: complex} = paint;
12319
+ let {width: width, height: height} = image;
12320
+ if (complex) {
12321
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
12267
12322
  canvas.save();
12268
- clipUI && canvas.clipUI(ui);
12323
+ complex === 2 && canvas.clipUI(ui);
12269
12324
  blendMode && (canvas.blendMode = blendMode);
12270
12325
  opacity && (canvas.opacity *= opacity);
12271
12326
  transform && canvas.transform(transform);
12272
- canvas.drawImage(view, 0, 0, width, height);
12327
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12273
12328
  canvas.restore();
12274
12329
  } else {
12275
12330
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
12276
- canvas.drawImage(view, 0, 0, width, height);
12331
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
12277
12332
  }
12278
12333
  }
12279
12334
 
@@ -12993,7 +13048,7 @@ function layoutText(drawData, style) {
12993
13048
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
12994
13049
  let starY = __baseLine;
12995
13050
  if (__clipText && realHeight > height) {
12996
- realHeight = Math.max(height, __lineHeight);
13051
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
12997
13052
  if (countRows > 1) drawData.overflow = countRows;
12998
13053
  } else if (height || autoSizeAlign) {
12999
13054
  switch (verticalAlign) {
@@ -13050,10 +13105,10 @@ function layoutText(drawData, style) {
13050
13105
  }
13051
13106
 
13052
13107
  function clipText(drawData, style, x, width) {
13053
- if (!width) return;
13054
13108
  const {rows: rows, overflow: overflow} = drawData;
13055
13109
  let {textOverflow: textOverflow} = style;
13056
- rows.splice(overflow);
13110
+ if (overflow) rows.splice(overflow);
13111
+ if (!width) return;
13057
13112
  if (textOverflow && textOverflow !== "show") {
13058
13113
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
13059
13114
  let char, charRight;
@@ -13224,4 +13279,4 @@ try {
13224
13279
  if (wx) useCanvas("miniapp", wx);
13225
13280
  } catch (_a) {}
13226
13281
 
13227
- 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, 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 };
13282
+ 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, 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 };