@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.
package/dist/miniapp.cjs CHANGED
@@ -118,8 +118,6 @@ class LeaferCanvas extends core.LeaferCanvasBase {
118
118
  }
119
119
  }
120
120
 
121
- const {mineType: mineType, fileType: fileType} = core.FileHelper;
122
-
123
121
  Object.assign(core.Creator, {
124
122
  canvas: (options, manager) => new LeaferCanvas(options, manager),
125
123
  image: options => new core.LeaferImage(options)
@@ -135,12 +133,12 @@ function useCanvas(_canvasType, app) {
135
133
  };
136
134
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
137
135
  },
138
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
136
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(core.FileHelper.mimeType(type), quality),
139
137
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
140
138
  quality: quality
141
139
  }),
142
140
  canvasSaveAs: (canvas, filePath, quality) => {
143
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
141
+ let data = canvas.toDataURL(core.FileHelper.mimeType(core.FileHelper.fileType(filePath)), quality);
144
142
  data = data.substring(data.indexOf("64,") + 3);
145
143
  return core.Platform.origin.download(data, filePath);
146
144
  },
@@ -174,7 +172,7 @@ function useCanvas(_canvasType, app) {
174
172
  });
175
173
  });
176
174
  },
177
- loadImage(src) {
175
+ loadImage(src, _crossOrigin, _leaferImage) {
178
176
  return new Promise((resolve, reject) => {
179
177
  const img = core.Platform.canvas.view.createImage();
180
178
  img.onload = () => {
@@ -186,6 +184,14 @@ function useCanvas(_canvasType, app) {
186
184
  img.src = core.Platform.image.getRealURL(src);
187
185
  });
188
186
  },
187
+ loadContent(url, responseType = "text") {
188
+ return new Promise((resolve, reject) => app.request({
189
+ url: url,
190
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
191
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
192
+ fail: reject
193
+ }));
194
+ },
189
195
  noRepeat: "repeat-x"
190
196
  };
191
197
  core.Platform.miniapp = {
@@ -737,7 +743,7 @@ class Renderer {
737
743
  getCellList() {
738
744
  return undefined;
739
745
  }
740
- addBlock(block) {
746
+ addBlock(block, _leafList) {
741
747
  if (!this.updateBlocks) this.updateBlocks = [];
742
748
  this.updateBlocks.push(block);
743
749
  }
@@ -785,7 +791,8 @@ class Renderer {
785
791
  __onLayoutEnd(event) {
786
792
  if (event.data) event.data.map(item => {
787
793
  let empty;
788
- if (item.updatedList) item.updatedList.list.some(leaf => {
794
+ const {updatedList: updatedList} = item;
795
+ if (updatedList) updatedList.list.some(leaf => {
789
796
  empty = !leaf.__world.width || !leaf.__world.height;
790
797
  if (empty) {
791
798
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -793,7 +800,7 @@ class Renderer {
793
800
  }
794
801
  return empty;
795
802
  });
796
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
803
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
797
804
  });
798
805
  }
799
806
  emitRender(type, bounds, options) {
@@ -1445,11 +1452,14 @@ function compute(attrName, ui) {
1445
1452
  function getLeafPaint(attrName, paint, ui) {
1446
1453
  if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1447
1454
  let leafPaint;
1448
- const {boxBounds: boxBounds} = ui.__layout;
1449
- switch (paint.type) {
1455
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1456
+ switch (type) {
1450
1457
  case "image":
1458
+ case "film":
1459
+ case "video":
1451
1460
  if (!paint.url) return undefined;
1452
1461
  leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1462
+ if (type !== "image") draw.PaintImage[type](leafPaint);
1453
1463
  break;
1454
1464
 
1455
1465
  case "linear":
@@ -1465,7 +1475,7 @@ function getLeafPaint(attrName, paint, ui) {
1465
1475
  break;
1466
1476
 
1467
1477
  case "solid":
1468
- const {type: type, color: color, opacity: opacity} = paint;
1478
+ const {color: color, opacity: opacity} = paint;
1469
1479
  leafPaint = {
1470
1480
  type: type,
1471
1481
  style: draw.ColorConvert.string(color, opacity)
@@ -1509,7 +1519,7 @@ const {isSame: isSame} = core.BoundsHelper;
1509
1519
 
1510
1520
  function image(ui, attrName, paint, boxBounds, firstUse) {
1511
1521
  let leafPaint, event;
1512
- const image = core.ImageManager.get(paint);
1522
+ const image = core.ImageManager.get(paint, paint.type);
1513
1523
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1514
1524
  leafPaint = cache.leafPaint;
1515
1525
  } else {
@@ -1570,8 +1580,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1570
1580
  }
1571
1581
 
1572
1582
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1573
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1574
- const data = ui.__;
1583
+ const data = ui.__;
1584
+ if (attrName === "fill" && !data.__naturalWidth) {
1575
1585
  data.__naturalWidth = image.width / data.pixelRatio;
1576
1586
  data.__naturalHeight = image.height / data.pixelRatio;
1577
1587
  if (data.__autoSide) {
@@ -1583,7 +1593,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1583
1593
  return false;
1584
1594
  }
1585
1595
  }
1586
- if (!leafPaint.data) draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1596
+ if (!leafPaint.data) {
1597
+ draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1598
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1599
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1600
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1601
+ }
1587
1602
  return true;
1588
1603
  }
1589
1604
 
@@ -1626,7 +1641,7 @@ function getPatternData(paint, box, image) {
1626
1641
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1627
1642
  if (paint.mode === "strench") paint.mode = "stretch";
1628
1643
  const {width: width, height: height} = image;
1629
- 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;
1644
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1630
1645
  const sameBox = box.width === width && box.height === height;
1631
1646
  const data = {
1632
1647
  mode: mode
@@ -1689,8 +1704,6 @@ function getPatternData(paint, box, image) {
1689
1704
  data.scaleX = scaleX;
1690
1705
  data.scaleY = scaleY;
1691
1706
  }
1692
- if (opacity && opacity < 1) data.opacity = opacity;
1693
- if (filters) data.filters = filters;
1694
1707
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1695
1708
  if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1696
1709
  type: "x",
@@ -1721,7 +1734,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1721
1734
 
1722
1735
  function stretchMode(data, box, scaleX, scaleY) {
1723
1736
  const transform = get$2(), {x: x, y: y} = box;
1724
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1737
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1725
1738
  scaleHelper(transform, scaleX, scaleY);
1726
1739
  data.transform = transform;
1727
1740
  }
@@ -1843,10 +1856,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1843
1856
  }
1844
1857
 
1845
1858
  function createPattern(paint, ui, canvas, renderOptions) {
1846
- let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1859
+ let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1847
1860
  if (paint.patternId !== id && !ui.destroyed) {
1848
1861
  if (!(core.Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1849
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1862
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1850
1863
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1851
1864
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1852
1865
  width *= scaleX;
@@ -1862,7 +1875,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1862
1875
  if (transform) copy$1(imageMatrix, transform);
1863
1876
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1864
1877
  }
1865
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1878
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1866
1879
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1867
1880
  paint.style = pattern;
1868
1881
  paint.patternId = id;
@@ -1883,15 +1896,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1883
1896
  }
1884
1897
 
1885
1898
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1886
- const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1899
+ const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1887
1900
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1888
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1901
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1889
1902
  return false;
1890
1903
  } else {
1891
1904
  if (drawImage) {
1892
1905
  if (data.repeat) {
1893
1906
  drawImage = false;
1894
- } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1907
+ } else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1895
1908
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1896
1909
  }
1897
1910
  }
@@ -1909,20 +1922,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1909
1922
  }
1910
1923
  }
1911
1924
 
1912
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1913
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1914
- let {width: width, height: height} = image, clipUI;
1915
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1925
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1926
+ const {data: data, image: image, complex: complex} = paint;
1927
+ let {width: width, height: height} = image;
1928
+ if (complex) {
1929
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1916
1930
  canvas.save();
1917
- clipUI && canvas.clipUI(ui);
1931
+ complex === 2 && canvas.clipUI(ui);
1918
1932
  blendMode && (canvas.blendMode = blendMode);
1919
1933
  opacity && (canvas.opacity *= opacity);
1920
1934
  transform && canvas.transform(transform);
1921
- canvas.drawImage(view, 0, 0, width, height);
1935
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1922
1936
  canvas.restore();
1923
1937
  } else {
1924
1938
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1925
- canvas.drawImage(view, 0, 0, width, height);
1939
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1926
1940
  }
1927
1941
  }
1928
1942
 
@@ -2642,7 +2656,7 @@ function layoutText(drawData, style) {
2642
2656
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2643
2657
  let starY = __baseLine;
2644
2658
  if (__clipText && realHeight > height) {
2645
- realHeight = Math.max(height, __lineHeight);
2659
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2646
2660
  if (countRows > 1) drawData.overflow = countRows;
2647
2661
  } else if (height || autoSizeAlign) {
2648
2662
  switch (verticalAlign) {
@@ -2699,10 +2713,10 @@ function layoutText(drawData, style) {
2699
2713
  }
2700
2714
 
2701
2715
  function clipText(drawData, style, x, width) {
2702
- if (!width) return;
2703
2716
  const {rows: rows, overflow: overflow} = drawData;
2704
2717
  let {textOverflow: textOverflow} = style;
2705
- rows.splice(overflow);
2718
+ if (overflow) rows.splice(overflow);
2719
+ if (!width) return;
2706
2720
  if (textOverflow && textOverflow !== "show") {
2707
2721
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2708
2722
  let char, charRight;
@@ -2873,6 +2887,13 @@ try {
2873
2887
  if (wx) useCanvas("miniapp", wx);
2874
2888
  } catch (_a) {}
2875
2889
 
2890
+ Object.defineProperty(exports, "LeaferFilm", {
2891
+ enumerable: true,
2892
+ get: function() {
2893
+ return core.LeaferFilm;
2894
+ }
2895
+ });
2896
+
2876
2897
  Object.defineProperty(exports, "LeaferImage", {
2877
2898
  enumerable: true,
2878
2899
  get: function() {
@@ -2880,6 +2901,13 @@ Object.defineProperty(exports, "LeaferImage", {
2880
2901
  }
2881
2902
  });
2882
2903
 
2904
+ Object.defineProperty(exports, "LeaferVideo", {
2905
+ enumerable: true,
2906
+ get: function() {
2907
+ return core.LeaferVideo;
2908
+ }
2909
+ });
2910
+
2883
2911
  exports.Interaction = Interaction;
2884
2912
 
2885
2913
  exports.Layouter = Layouter;
@@ -1,8 +1,8 @@
1
- import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, ImageEvent, MatrixHelper, MathHelper, AlignHelper, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
1
+ import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, ImageEvent, MatrixHelper, MathHelper, AlignHelper, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
5
- export { LeaferImage } from "@leafer/core";
5
+ export { LeaferFilm, LeaferImage, LeaferVideo } from "@leafer/core";
6
6
 
7
7
  import { InteractionHelper, InteractionBase, isUndefined as isUndefined$1, HitCanvasManager } from "@leafer-ui/core";
8
8
 
@@ -122,8 +122,6 @@ class LeaferCanvas extends LeaferCanvasBase {
122
122
  }
123
123
  }
124
124
 
125
- const {mineType: mineType, fileType: fileType} = FileHelper;
126
-
127
125
  Object.assign(Creator, {
128
126
  canvas: (options, manager) => new LeaferCanvas(options, manager),
129
127
  image: options => new LeaferImage(options)
@@ -139,12 +137,12 @@ function useCanvas(_canvasType, app) {
139
137
  };
140
138
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
141
139
  },
142
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
140
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
143
141
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
144
142
  quality: quality
145
143
  }),
146
144
  canvasSaveAs: (canvas, filePath, quality) => {
147
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
145
+ let data = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filePath)), quality);
148
146
  data = data.substring(data.indexOf("64,") + 3);
149
147
  return Platform.origin.download(data, filePath);
150
148
  },
@@ -178,7 +176,7 @@ function useCanvas(_canvasType, app) {
178
176
  });
179
177
  });
180
178
  },
181
- loadImage(src) {
179
+ loadImage(src, _crossOrigin, _leaferImage) {
182
180
  return new Promise((resolve, reject) => {
183
181
  const img = Platform.canvas.view.createImage();
184
182
  img.onload = () => {
@@ -190,6 +188,14 @@ function useCanvas(_canvasType, app) {
190
188
  img.src = Platform.image.getRealURL(src);
191
189
  });
192
190
  },
191
+ loadContent(url, responseType = "text") {
192
+ return new Promise((resolve, reject) => app.request({
193
+ url: url,
194
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
195
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
196
+ fail: reject
197
+ }));
198
+ },
193
199
  noRepeat: "repeat-x"
194
200
  };
195
201
  Platform.miniapp = {
@@ -741,7 +747,7 @@ class Renderer {
741
747
  getCellList() {
742
748
  return undefined;
743
749
  }
744
- addBlock(block) {
750
+ addBlock(block, _leafList) {
745
751
  if (!this.updateBlocks) this.updateBlocks = [];
746
752
  this.updateBlocks.push(block);
747
753
  }
@@ -789,7 +795,8 @@ class Renderer {
789
795
  __onLayoutEnd(event) {
790
796
  if (event.data) event.data.map(item => {
791
797
  let empty;
792
- if (item.updatedList) item.updatedList.list.some(leaf => {
798
+ const {updatedList: updatedList} = item;
799
+ if (updatedList) updatedList.list.some(leaf => {
793
800
  empty = !leaf.__world.width || !leaf.__world.height;
794
801
  if (empty) {
795
802
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -797,7 +804,7 @@ class Renderer {
797
804
  }
798
805
  return empty;
799
806
  });
800
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
807
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
801
808
  });
802
809
  }
803
810
  emitRender(type, bounds, options) {
@@ -1449,11 +1456,14 @@ function compute(attrName, ui) {
1449
1456
  function getLeafPaint(attrName, paint, ui) {
1450
1457
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1451
1458
  let leafPaint;
1452
- const {boxBounds: boxBounds} = ui.__layout;
1453
- switch (paint.type) {
1459
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1460
+ switch (type) {
1454
1461
  case "image":
1462
+ case "film":
1463
+ case "video":
1455
1464
  if (!paint.url) return undefined;
1456
1465
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1466
+ if (type !== "image") PaintImage[type](leafPaint);
1457
1467
  break;
1458
1468
 
1459
1469
  case "linear":
@@ -1469,7 +1479,7 @@ function getLeafPaint(attrName, paint, ui) {
1469
1479
  break;
1470
1480
 
1471
1481
  case "solid":
1472
- const {type: type, color: color, opacity: opacity} = paint;
1482
+ const {color: color, opacity: opacity} = paint;
1473
1483
  leafPaint = {
1474
1484
  type: type,
1475
1485
  style: ColorConvert.string(color, opacity)
@@ -1513,7 +1523,7 @@ const {isSame: isSame} = BoundsHelper;
1513
1523
 
1514
1524
  function image(ui, attrName, paint, boxBounds, firstUse) {
1515
1525
  let leafPaint, event;
1516
- const image = ImageManager.get(paint);
1526
+ const image = ImageManager.get(paint, paint.type);
1517
1527
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1518
1528
  leafPaint = cache.leafPaint;
1519
1529
  } else {
@@ -1574,8 +1584,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1574
1584
  }
1575
1585
 
1576
1586
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1577
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1578
- const data = ui.__;
1587
+ const data = ui.__;
1588
+ if (attrName === "fill" && !data.__naturalWidth) {
1579
1589
  data.__naturalWidth = image.width / data.pixelRatio;
1580
1590
  data.__naturalHeight = image.height / data.pixelRatio;
1581
1591
  if (data.__autoSide) {
@@ -1587,7 +1597,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1587
1597
  return false;
1588
1598
  }
1589
1599
  }
1590
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
1600
+ if (!leafPaint.data) {
1601
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
1602
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1603
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1604
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1605
+ }
1591
1606
  return true;
1592
1607
  }
1593
1608
 
@@ -1630,7 +1645,7 @@ function getPatternData(paint, box, image) {
1630
1645
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1631
1646
  if (paint.mode === "strench") paint.mode = "stretch";
1632
1647
  const {width: width, height: height} = image;
1633
- 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;
1648
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1634
1649
  const sameBox = box.width === width && box.height === height;
1635
1650
  const data = {
1636
1651
  mode: mode
@@ -1693,8 +1708,6 @@ function getPatternData(paint, box, image) {
1693
1708
  data.scaleX = scaleX;
1694
1709
  data.scaleY = scaleY;
1695
1710
  }
1696
- if (opacity && opacity < 1) data.opacity = opacity;
1697
- if (filters) data.filters = filters;
1698
1711
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1699
1712
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1700
1713
  type: "x",
@@ -1725,7 +1738,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1725
1738
 
1726
1739
  function stretchMode(data, box, scaleX, scaleY) {
1727
1740
  const transform = get$2(), {x: x, y: y} = box;
1728
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1741
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1729
1742
  scaleHelper(transform, scaleX, scaleY);
1730
1743
  data.transform = transform;
1731
1744
  }
@@ -1847,10 +1860,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1847
1860
  }
1848
1861
 
1849
1862
  function createPattern(paint, ui, canvas, renderOptions) {
1850
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1863
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1851
1864
  if (paint.patternId !== id && !ui.destroyed) {
1852
1865
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1853
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1866
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1854
1867
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1855
1868
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1856
1869
  width *= scaleX;
@@ -1866,7 +1879,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1866
1879
  if (transform) copy$1(imageMatrix, transform);
1867
1880
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1868
1881
  }
1869
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1882
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1870
1883
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1871
1884
  paint.style = pattern;
1872
1885
  paint.patternId = id;
@@ -1887,15 +1900,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1887
1900
  }
1888
1901
 
1889
1902
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1890
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1903
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1891
1904
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1892
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1905
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1893
1906
  return false;
1894
1907
  } else {
1895
1908
  if (drawImage) {
1896
1909
  if (data.repeat) {
1897
1910
  drawImage = false;
1898
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1911
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1899
1912
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1900
1913
  }
1901
1914
  }
@@ -1913,20 +1926,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1913
1926
  }
1914
1927
  }
1915
1928
 
1916
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1917
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1918
- let {width: width, height: height} = image, clipUI;
1919
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1929
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1930
+ const {data: data, image: image, complex: complex} = paint;
1931
+ let {width: width, height: height} = image;
1932
+ if (complex) {
1933
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1920
1934
  canvas.save();
1921
- clipUI && canvas.clipUI(ui);
1935
+ complex === 2 && canvas.clipUI(ui);
1922
1936
  blendMode && (canvas.blendMode = blendMode);
1923
1937
  opacity && (canvas.opacity *= opacity);
1924
1938
  transform && canvas.transform(transform);
1925
- canvas.drawImage(view, 0, 0, width, height);
1939
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1926
1940
  canvas.restore();
1927
1941
  } else {
1928
1942
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1929
- canvas.drawImage(view, 0, 0, width, height);
1943
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1930
1944
  }
1931
1945
  }
1932
1946
 
@@ -2646,7 +2660,7 @@ function layoutText(drawData, style) {
2646
2660
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2647
2661
  let starY = __baseLine;
2648
2662
  if (__clipText && realHeight > height) {
2649
- realHeight = Math.max(height, __lineHeight);
2663
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2650
2664
  if (countRows > 1) drawData.overflow = countRows;
2651
2665
  } else if (height || autoSizeAlign) {
2652
2666
  switch (verticalAlign) {
@@ -2703,10 +2717,10 @@ function layoutText(drawData, style) {
2703
2717
  }
2704
2718
 
2705
2719
  function clipText(drawData, style, x, width) {
2706
- if (!width) return;
2707
2720
  const {rows: rows, overflow: overflow} = drawData;
2708
2721
  let {textOverflow: textOverflow} = style;
2709
- rows.splice(overflow);
2722
+ if (overflow) rows.splice(overflow);
2723
+ if (!width) return;
2710
2724
  if (textOverflow && textOverflow !== "show") {
2711
2725
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2712
2726
  let char, charRight;