@leafer-ui/node 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -74,13 +74,19 @@ class LeaferCanvas extends core.LeaferCanvasBase {
74
74
  }
75
75
  }
76
76
 
77
- const {mineType: mineType, fileType: fileType} = core.FileHelper;
78
-
79
77
  Object.assign(core.Creator, {
80
78
  canvas: (options, manager) => new LeaferCanvas(options, manager),
81
79
  image: options => new core.LeaferImage(options)
82
80
  });
83
81
 
82
+ function loadContent(url_1) {
83
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
84
+ const response = yield fetch(url);
85
+ if (!response.ok) throw new Error(`${response.status}`);
86
+ return yield response[responseType]();
87
+ });
88
+ }
89
+
84
90
  function useCanvas(canvasType, power) {
85
91
  core.Platform.canvasType = canvasType;
86
92
  if (!core.Platform.origin) {
@@ -100,28 +106,30 @@ function useCanvas(canvasType, power) {
100
106
  download(_url, _filename) {
101
107
  return undefined;
102
108
  },
103
- loadImage(src) {
109
+ loadImage(src, _crossOrigin, _leaferImage) {
104
110
  return loadImage(core.Platform.image.getRealURL(src));
105
- }
111
+ },
112
+ loadContent: loadContent
106
113
  };
107
114
  core.Platform.roundRectPatch = true;
108
115
  } else if (canvasType === "napi") {
109
116
  const {Canvas: Canvas, loadImage: loadImage} = power;
110
117
  core.Platform.origin = {
111
118
  createCanvas: (width, height, format) => new Canvas(width, height, format),
112
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
119
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(core.FileHelper.mimeType(type), quality),
113
120
  canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function*() {
114
- return canvas.toBuffer(mineType(type), quality);
121
+ return canvas.toBuffer(core.FileHelper.mimeType(type), quality);
115
122
  }),
116
123
  canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function*() {
117
- return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality));
124
+ return fs.writeFileSync(filename, canvas.toBuffer(core.FileHelper.mimeType(core.FileHelper.fileType(filename)), quality));
118
125
  }),
119
126
  download(_url, _filename) {
120
127
  return undefined;
121
128
  },
122
- loadImage(src) {
129
+ loadImage(src, _crossOrigin, _leaferImage) {
123
130
  return loadImage(core.Platform.image.getRealURL(src));
124
- }
131
+ },
132
+ loadContent: loadContent
125
133
  };
126
134
  }
127
135
  core.Platform.ellipseToCurve = true;
@@ -609,7 +617,7 @@ class Renderer {
609
617
  getCellList() {
610
618
  return undefined;
611
619
  }
612
- addBlock(block) {
620
+ addBlock(block, _leafList) {
613
621
  if (!this.updateBlocks) this.updateBlocks = [];
614
622
  this.updateBlocks.push(block);
615
623
  }
@@ -657,7 +665,8 @@ class Renderer {
657
665
  __onLayoutEnd(event) {
658
666
  if (event.data) event.data.map(item => {
659
667
  let empty;
660
- if (item.updatedList) item.updatedList.list.some(leaf => {
668
+ const {updatedList: updatedList} = item;
669
+ if (updatedList) updatedList.list.some(leaf => {
661
670
  empty = !leaf.__world.width || !leaf.__world.height;
662
671
  if (empty) {
663
672
  if (!leaf.isLeafer) debug$1.tip(leaf.innerName, ": empty");
@@ -665,7 +674,7 @@ class Renderer {
665
674
  }
666
675
  return empty;
667
676
  });
668
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
677
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
669
678
  });
670
679
  }
671
680
  emitRender(type, bounds, options) {
@@ -871,7 +880,7 @@ class Selector {
871
880
  this.config = {};
872
881
  if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
873
882
  this.picker = new Picker(this.target = target, this);
874
- this.finder = core.Creator.finder && core.Creator.finder();
883
+ this.finder = core.Creator.finder && core.Creator.finder(target, this.config);
875
884
  }
876
885
  getByPoint(hitPoint, hitRadius, options) {
877
886
  const {target: target, picker: picker} = this;
@@ -930,8 +939,8 @@ function fills(fills, ui, canvas, renderOptions) {
930
939
  canvas.save();
931
940
  if (item.transform) canvas.transform(item.transform);
932
941
  if (originPaint.scaleFixed) {
933
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
934
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
942
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
943
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
935
944
  }
936
945
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
937
946
  fillPathOrText(ui, canvas, renderOptions);
@@ -1205,11 +1214,14 @@ function compute(attrName, ui) {
1205
1214
  function getLeafPaint(attrName, paint, ui) {
1206
1215
  if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1207
1216
  let leafPaint;
1208
- const {boxBounds: boxBounds} = ui.__layout;
1209
- switch (paint.type) {
1217
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1218
+ switch (type) {
1210
1219
  case "image":
1220
+ case "film":
1221
+ case "video":
1211
1222
  if (!paint.url) return undefined;
1212
1223
  leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1224
+ if (type !== "image") draw.PaintImage[type](leafPaint);
1213
1225
  break;
1214
1226
 
1215
1227
  case "linear":
@@ -1225,7 +1237,7 @@ function getLeafPaint(attrName, paint, ui) {
1225
1237
  break;
1226
1238
 
1227
1239
  case "solid":
1228
- const {type: type, color: color, opacity: opacity} = paint;
1240
+ const {color: color, opacity: opacity} = paint;
1229
1241
  leafPaint = {
1230
1242
  type: type,
1231
1243
  style: draw.ColorConvert.string(color, opacity)
@@ -1269,7 +1281,7 @@ const {isSame: isSame} = core.BoundsHelper;
1269
1281
 
1270
1282
  function image(ui, attrName, paint, boxBounds, firstUse) {
1271
1283
  let leafPaint, event;
1272
- const image = core.ImageManager.get(paint);
1284
+ const image = core.ImageManager.get(paint, paint.type);
1273
1285
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1274
1286
  leafPaint = cache.leafPaint;
1275
1287
  } else {
@@ -1330,8 +1342,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1330
1342
  }
1331
1343
 
1332
1344
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1333
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1334
- const data = ui.__;
1345
+ const data = ui.__;
1346
+ if (attrName === "fill" && !data.__naturalWidth) {
1335
1347
  data.__naturalWidth = image.width / data.pixelRatio;
1336
1348
  data.__naturalHeight = image.height / data.pixelRatio;
1337
1349
  if (data.__autoSide) {
@@ -1343,7 +1355,13 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1343
1355
  return false;
1344
1356
  }
1345
1357
  }
1346
- if (!leafPaint.data) draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1358
+ if (!leafPaint.data) {
1359
+ draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1360
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1361
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1362
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1363
+ }
1364
+ if (paint.filter) draw.PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1347
1365
  return true;
1348
1366
  }
1349
1367
 
@@ -1386,7 +1404,7 @@ function getPatternData(paint, box, image) {
1386
1404
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1387
1405
  if (paint.mode === "strench") paint.mode = "stretch";
1388
1406
  const {width: width, height: height} = image;
1389
- 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;
1407
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1390
1408
  const sameBox = box.width === width && box.height === height;
1391
1409
  const data = {
1392
1410
  mode: mode
@@ -1449,8 +1467,6 @@ function getPatternData(paint, box, image) {
1449
1467
  data.scaleX = scaleX;
1450
1468
  data.scaleY = scaleY;
1451
1469
  }
1452
- if (opacity && opacity < 1) data.opacity = opacity;
1453
- if (filters) data.filters = filters;
1454
1470
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1455
1471
  if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1456
1472
  type: "x",
@@ -1481,7 +1497,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1481
1497
 
1482
1498
  function stretchMode(data, box, scaleX, scaleY) {
1483
1499
  const transform = get$2(), {x: x, y: y} = box;
1484
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1500
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1485
1501
  scaleHelper(transform, scaleX, scaleY);
1486
1502
  data.transform = transform;
1487
1503
  }
@@ -1570,10 +1586,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1570
1586
  }
1571
1587
 
1572
1588
  function createPattern(paint, ui, canvas, renderOptions) {
1573
- let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1589
+ let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1574
1590
  if (paint.patternId !== id && !ui.destroyed) {
1575
1591
  if (!(core.Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1576
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1592
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1577
1593
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1578
1594
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1579
1595
  width *= scaleX;
@@ -1589,7 +1605,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1589
1605
  if (transform) copy$1(imageMatrix, transform);
1590
1606
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1591
1607
  }
1592
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1608
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1593
1609
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1594
1610
  paint.style = pattern;
1595
1611
  paint.patternId = id;
@@ -1610,15 +1626,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1610
1626
  }
1611
1627
 
1612
1628
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1613
- const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1629
+ const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1614
1630
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1615
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1631
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1616
1632
  return false;
1617
1633
  } else {
1618
1634
  if (drawImage) {
1619
1635
  if (data.repeat) {
1620
1636
  drawImage = false;
1621
- } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1637
+ } else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1622
1638
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1623
1639
  }
1624
1640
  }
@@ -1636,20 +1652,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1636
1652
  }
1637
1653
  }
1638
1654
 
1639
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1640
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1641
- let {width: width, height: height} = image, clipUI;
1642
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1655
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1656
+ const {data: data, image: image, complex: complex} = paint;
1657
+ let {width: width, height: height} = image;
1658
+ if (complex) {
1659
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1643
1660
  canvas.save();
1644
- clipUI && canvas.clipUI(ui);
1661
+ complex === 2 && canvas.clipUI(ui);
1645
1662
  blendMode && (canvas.blendMode = blendMode);
1646
1663
  opacity && (canvas.opacity *= opacity);
1647
1664
  transform && canvas.transform(transform);
1648
- canvas.drawImage(view, 0, 0, width, height);
1665
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1649
1666
  canvas.restore();
1650
1667
  } else {
1651
1668
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1652
- canvas.drawImage(view, 0, 0, width, height);
1669
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1653
1670
  }
1654
1671
  }
1655
1672
 
@@ -1679,6 +1696,7 @@ function recycleImage(attrName, data) {
1679
1696
  if (!recycleMap) recycleMap = {};
1680
1697
  recycleMap[url] = true;
1681
1698
  core.ImageManager.recyclePaint(paint);
1699
+ if (data.__willDestroy && image.parent) draw.PaintImage.recycleFilter(image, data.__leaf);
1682
1700
  if (image.loading) {
1683
1701
  if (!input) {
1684
1702
  input = data.__input && data.__input[attrName] || [];
@@ -2849,6 +2867,13 @@ Object.assign(core.Creator, {
2849
2867
  hitCanvasManager: () => new core$1.HitCanvasManager
2850
2868
  });
2851
2869
 
2870
+ Object.defineProperty(exports, "LeaferFilm", {
2871
+ enumerable: true,
2872
+ get: function() {
2873
+ return core.LeaferFilm;
2874
+ }
2875
+ });
2876
+
2852
2877
  Object.defineProperty(exports, "LeaferImage", {
2853
2878
  enumerable: true,
2854
2879
  get: function() {
@@ -2856,6 +2881,13 @@ Object.defineProperty(exports, "LeaferImage", {
2856
2881
  }
2857
2882
  });
2858
2883
 
2884
+ Object.defineProperty(exports, "LeaferVideo", {
2885
+ enumerable: true,
2886
+ get: function() {
2887
+ return core.LeaferVideo;
2888
+ }
2889
+ });
2890
+
2859
2891
  exports.Layouter = Layouter;
2860
2892
 
2861
2893
  exports.LeaferCanvas = LeaferCanvas;
package/dist/node.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, isNumber, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, PointHelper, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, ImageEvent, MatrixHelper, MathHelper, AlignHelper, isNumber, 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 { writeFileSync } from "fs";
8
8
 
@@ -78,13 +78,19 @@ class LeaferCanvas extends LeaferCanvasBase {
78
78
  }
79
79
  }
80
80
 
81
- const {mineType: mineType, fileType: fileType} = FileHelper;
82
-
83
81
  Object.assign(Creator, {
84
82
  canvas: (options, manager) => new LeaferCanvas(options, manager),
85
83
  image: options => new LeaferImage(options)
86
84
  });
87
85
 
86
+ function loadContent(url_1) {
87
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
88
+ const response = yield fetch(url);
89
+ if (!response.ok) throw new Error(`${response.status}`);
90
+ return yield response[responseType]();
91
+ });
92
+ }
93
+
88
94
  function useCanvas(canvasType, power) {
89
95
  Platform.canvasType = canvasType;
90
96
  if (!Platform.origin) {
@@ -104,28 +110,30 @@ function useCanvas(canvasType, power) {
104
110
  download(_url, _filename) {
105
111
  return undefined;
106
112
  },
107
- loadImage(src) {
113
+ loadImage(src, _crossOrigin, _leaferImage) {
108
114
  return loadImage(Platform.image.getRealURL(src));
109
- }
115
+ },
116
+ loadContent: loadContent
110
117
  };
111
118
  Platform.roundRectPatch = true;
112
119
  } else if (canvasType === "napi") {
113
120
  const {Canvas: Canvas, loadImage: loadImage} = power;
114
121
  Platform.origin = {
115
122
  createCanvas: (width, height, format) => new Canvas(width, height, format),
116
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
123
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
117
124
  canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function*() {
118
- return canvas.toBuffer(mineType(type), quality);
125
+ return canvas.toBuffer(FileHelper.mimeType(type), quality);
119
126
  }),
120
127
  canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function*() {
121
- return writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality));
128
+ return writeFileSync(filename, canvas.toBuffer(FileHelper.mimeType(FileHelper.fileType(filename)), quality));
122
129
  }),
123
130
  download(_url, _filename) {
124
131
  return undefined;
125
132
  },
126
- loadImage(src) {
133
+ loadImage(src, _crossOrigin, _leaferImage) {
127
134
  return loadImage(Platform.image.getRealURL(src));
128
- }
135
+ },
136
+ loadContent: loadContent
129
137
  };
130
138
  }
131
139
  Platform.ellipseToCurve = true;
@@ -613,7 +621,7 @@ class Renderer {
613
621
  getCellList() {
614
622
  return undefined;
615
623
  }
616
- addBlock(block) {
624
+ addBlock(block, _leafList) {
617
625
  if (!this.updateBlocks) this.updateBlocks = [];
618
626
  this.updateBlocks.push(block);
619
627
  }
@@ -661,7 +669,8 @@ class Renderer {
661
669
  __onLayoutEnd(event) {
662
670
  if (event.data) event.data.map(item => {
663
671
  let empty;
664
- if (item.updatedList) item.updatedList.list.some(leaf => {
672
+ const {updatedList: updatedList} = item;
673
+ if (updatedList) updatedList.list.some(leaf => {
665
674
  empty = !leaf.__world.width || !leaf.__world.height;
666
675
  if (empty) {
667
676
  if (!leaf.isLeafer) debug$1.tip(leaf.innerName, ": empty");
@@ -669,7 +678,7 @@ class Renderer {
669
678
  }
670
679
  return empty;
671
680
  });
672
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
681
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
673
682
  });
674
683
  }
675
684
  emitRender(type, bounds, options) {
@@ -875,7 +884,7 @@ class Selector {
875
884
  this.config = {};
876
885
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
877
886
  this.picker = new Picker(this.target = target, this);
878
- this.finder = Creator.finder && Creator.finder();
887
+ this.finder = Creator.finder && Creator.finder(target, this.config);
879
888
  }
880
889
  getByPoint(hitPoint, hitRadius, options) {
881
890
  const {target: target, picker: picker} = this;
@@ -934,8 +943,8 @@ function fills(fills, ui, canvas, renderOptions) {
934
943
  canvas.save();
935
944
  if (item.transform) canvas.transform(item.transform);
936
945
  if (originPaint.scaleFixed) {
937
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
938
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
946
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
947
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
939
948
  }
940
949
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
941
950
  fillPathOrText(ui, canvas, renderOptions);
@@ -1209,11 +1218,14 @@ function compute(attrName, ui) {
1209
1218
  function getLeafPaint(attrName, paint, ui) {
1210
1219
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1211
1220
  let leafPaint;
1212
- const {boxBounds: boxBounds} = ui.__layout;
1213
- switch (paint.type) {
1221
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1222
+ switch (type) {
1214
1223
  case "image":
1224
+ case "film":
1225
+ case "video":
1215
1226
  if (!paint.url) return undefined;
1216
1227
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1228
+ if (type !== "image") PaintImage[type](leafPaint);
1217
1229
  break;
1218
1230
 
1219
1231
  case "linear":
@@ -1229,7 +1241,7 @@ function getLeafPaint(attrName, paint, ui) {
1229
1241
  break;
1230
1242
 
1231
1243
  case "solid":
1232
- const {type: type, color: color, opacity: opacity} = paint;
1244
+ const {color: color, opacity: opacity} = paint;
1233
1245
  leafPaint = {
1234
1246
  type: type,
1235
1247
  style: ColorConvert.string(color, opacity)
@@ -1273,7 +1285,7 @@ const {isSame: isSame} = BoundsHelper;
1273
1285
 
1274
1286
  function image(ui, attrName, paint, boxBounds, firstUse) {
1275
1287
  let leafPaint, event;
1276
- const image = ImageManager.get(paint);
1288
+ const image = ImageManager.get(paint, paint.type);
1277
1289
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1278
1290
  leafPaint = cache.leafPaint;
1279
1291
  } else {
@@ -1334,8 +1346,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1334
1346
  }
1335
1347
 
1336
1348
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1337
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1338
- const data = ui.__;
1349
+ const data = ui.__;
1350
+ if (attrName === "fill" && !data.__naturalWidth) {
1339
1351
  data.__naturalWidth = image.width / data.pixelRatio;
1340
1352
  data.__naturalHeight = image.height / data.pixelRatio;
1341
1353
  if (data.__autoSide) {
@@ -1347,7 +1359,13 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1347
1359
  return false;
1348
1360
  }
1349
1361
  }
1350
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
1362
+ if (!leafPaint.data) {
1363
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
1364
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1365
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1366
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1367
+ }
1368
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1351
1369
  return true;
1352
1370
  }
1353
1371
 
@@ -1390,7 +1408,7 @@ function getPatternData(paint, box, image) {
1390
1408
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1391
1409
  if (paint.mode === "strench") paint.mode = "stretch";
1392
1410
  const {width: width, height: height} = image;
1393
- 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;
1411
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1394
1412
  const sameBox = box.width === width && box.height === height;
1395
1413
  const data = {
1396
1414
  mode: mode
@@ -1453,8 +1471,6 @@ function getPatternData(paint, box, image) {
1453
1471
  data.scaleX = scaleX;
1454
1472
  data.scaleY = scaleY;
1455
1473
  }
1456
- if (opacity && opacity < 1) data.opacity = opacity;
1457
- if (filters) data.filters = filters;
1458
1474
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1459
1475
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1460
1476
  type: "x",
@@ -1485,7 +1501,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1485
1501
 
1486
1502
  function stretchMode(data, box, scaleX, scaleY) {
1487
1503
  const transform = get$2(), {x: x, y: y} = box;
1488
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1504
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1489
1505
  scaleHelper(transform, scaleX, scaleY);
1490
1506
  data.transform = transform;
1491
1507
  }
@@ -1574,10 +1590,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1574
1590
  }
1575
1591
 
1576
1592
  function createPattern(paint, ui, canvas, renderOptions) {
1577
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1593
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1578
1594
  if (paint.patternId !== id && !ui.destroyed) {
1579
1595
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1580
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1596
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1581
1597
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1582
1598
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1583
1599
  width *= scaleX;
@@ -1593,7 +1609,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1593
1609
  if (transform) copy$1(imageMatrix, transform);
1594
1610
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1595
1611
  }
1596
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1612
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1597
1613
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1598
1614
  paint.style = pattern;
1599
1615
  paint.patternId = id;
@@ -1614,15 +1630,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1614
1630
  }
1615
1631
 
1616
1632
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1617
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1633
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1618
1634
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1619
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1635
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1620
1636
  return false;
1621
1637
  } else {
1622
1638
  if (drawImage) {
1623
1639
  if (data.repeat) {
1624
1640
  drawImage = false;
1625
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1641
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1626
1642
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1627
1643
  }
1628
1644
  }
@@ -1640,20 +1656,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1640
1656
  }
1641
1657
  }
1642
1658
 
1643
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1644
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1645
- let {width: width, height: height} = image, clipUI;
1646
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1659
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1660
+ const {data: data, image: image, complex: complex} = paint;
1661
+ let {width: width, height: height} = image;
1662
+ if (complex) {
1663
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1647
1664
  canvas.save();
1648
- clipUI && canvas.clipUI(ui);
1665
+ complex === 2 && canvas.clipUI(ui);
1649
1666
  blendMode && (canvas.blendMode = blendMode);
1650
1667
  opacity && (canvas.opacity *= opacity);
1651
1668
  transform && canvas.transform(transform);
1652
- canvas.drawImage(view, 0, 0, width, height);
1669
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1653
1670
  canvas.restore();
1654
1671
  } else {
1655
1672
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1656
- canvas.drawImage(view, 0, 0, width, height);
1673
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1657
1674
  }
1658
1675
  }
1659
1676
 
@@ -1683,6 +1700,7 @@ function recycleImage(attrName, data) {
1683
1700
  if (!recycleMap) recycleMap = {};
1684
1701
  recycleMap[url] = true;
1685
1702
  ImageManager.recyclePaint(paint);
1703
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
1686
1704
  if (image.loading) {
1687
1705
  if (!input) {
1688
1706
  input = data.__input && data.__input[attrName] || [];