@leafer-ui/worker 2.0.1 → 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/worker.cjs CHANGED
@@ -15,6 +15,39 @@ exports.PathNodeHandleType = void 0;
15
15
  PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
16
16
  })(exports.PathNodeHandleType || (exports.PathNodeHandleType = {}));
17
17
 
18
+ function __awaiter(thisArg, _arguments, P, generator) {
19
+ function adopt(value) {
20
+ return value instanceof P ? value : new P(function(resolve) {
21
+ resolve(value);
22
+ });
23
+ }
24
+ return new (P || (P = Promise))(function(resolve, reject) {
25
+ function fulfilled(value) {
26
+ try {
27
+ step(generator.next(value));
28
+ } catch (e) {
29
+ reject(e);
30
+ }
31
+ }
32
+ function rejected(value) {
33
+ try {
34
+ step(generator["throw"](value));
35
+ } catch (e) {
36
+ reject(e);
37
+ }
38
+ }
39
+ function step(result) {
40
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41
+ }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ }
45
+
46
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
47
+ var e = new Error(message);
48
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
49
+ };
50
+
18
51
  class LeaferCanvas extends core.LeaferCanvasBase {
19
52
  get allowBackgroundColor() {
20
53
  return true;
@@ -39,8 +72,6 @@ core.canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
39
72
 
40
73
  core.canvasPatch(Path2D.prototype);
41
74
 
42
- const {mineType: mineType} = core.FileHelper;
43
-
44
75
  Object.assign(core.Creator, {
45
76
  canvas: (options, manager) => new LeaferCanvas(options, manager),
46
77
  image: options => new core.LeaferImage(options)
@@ -51,7 +82,7 @@ function useCanvas(_canvasType, _power) {
51
82
  createCanvas: (width, height) => new OffscreenCanvas(width, height),
52
83
  canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
53
84
  canvas.convertToBlob({
54
- type: mineType(type),
85
+ type: core.FileHelper.mimeType(type),
55
86
  quality: quality
56
87
  }).then(blob => {
57
88
  var reader = new FileReader;
@@ -63,14 +94,14 @@ function useCanvas(_canvasType, _power) {
63
94
  });
64
95
  }),
65
96
  canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
66
- type: mineType(type),
97
+ type: core.FileHelper.mimeType(type),
67
98
  quality: quality
68
99
  }),
69
100
  canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
70
101
  download(_url, _filename) {
71
102
  return undefined;
72
103
  },
73
- loadImage(src) {
104
+ loadImage(src, _crossOrigin, _leaferImage) {
74
105
  return new Promise((resolve, reject) => {
75
106
  let req = new XMLHttpRequest;
76
107
  req.open("GET", core.Platform.image.getRealURL(src), true);
@@ -85,6 +116,13 @@ function useCanvas(_canvasType, _power) {
85
116
  req.onerror = e => reject(e);
86
117
  req.send();
87
118
  });
119
+ },
120
+ loadContent(url_1) {
121
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
122
+ const response = yield fetch(url);
123
+ if (!response.ok) throw new Error(`${response.status}`);
124
+ return yield response[responseType]();
125
+ });
88
126
  }
89
127
  };
90
128
  core.Platform.canvas = core.Creator.canvas();
@@ -584,7 +622,7 @@ class Renderer {
584
622
  getCellList() {
585
623
  return undefined;
586
624
  }
587
- addBlock(block) {
625
+ addBlock(block, _leafList) {
588
626
  if (!this.updateBlocks) this.updateBlocks = [];
589
627
  this.updateBlocks.push(block);
590
628
  }
@@ -632,7 +670,8 @@ class Renderer {
632
670
  __onLayoutEnd(event) {
633
671
  if (event.data) event.data.map(item => {
634
672
  let empty;
635
- if (item.updatedList) item.updatedList.list.some(leaf => {
673
+ const {updatedList: updatedList} = item;
674
+ if (updatedList) updatedList.list.some(leaf => {
636
675
  empty = !leaf.__world.width || !leaf.__world.height;
637
676
  if (empty) {
638
677
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -640,7 +679,7 @@ class Renderer {
640
679
  }
641
680
  return empty;
642
681
  });
643
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
682
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
644
683
  });
645
684
  }
646
685
  emitRender(type, bounds, options) {
@@ -1180,11 +1219,14 @@ function compute(attrName, ui) {
1180
1219
  function getLeafPaint(attrName, paint, ui) {
1181
1220
  if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1182
1221
  let leafPaint;
1183
- const {boxBounds: boxBounds} = ui.__layout;
1184
- switch (paint.type) {
1222
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1223
+ switch (type) {
1185
1224
  case "image":
1225
+ case "film":
1226
+ case "video":
1186
1227
  if (!paint.url) return undefined;
1187
1228
  leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1229
+ if (type !== "image") draw.PaintImage[type](leafPaint);
1188
1230
  break;
1189
1231
 
1190
1232
  case "linear":
@@ -1200,7 +1242,7 @@ function getLeafPaint(attrName, paint, ui) {
1200
1242
  break;
1201
1243
 
1202
1244
  case "solid":
1203
- const {type: type, color: color, opacity: opacity} = paint;
1245
+ const {color: color, opacity: opacity} = paint;
1204
1246
  leafPaint = {
1205
1247
  type: type,
1206
1248
  style: draw.ColorConvert.string(color, opacity)
@@ -1244,7 +1286,7 @@ const {isSame: isSame} = core.BoundsHelper;
1244
1286
 
1245
1287
  function image(ui, attrName, paint, boxBounds, firstUse) {
1246
1288
  let leafPaint, event;
1247
- const image = core.ImageManager.get(paint);
1289
+ const image = core.ImageManager.get(paint, paint.type);
1248
1290
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1249
1291
  leafPaint = cache.leafPaint;
1250
1292
  } else {
@@ -1305,8 +1347,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1305
1347
  }
1306
1348
 
1307
1349
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1308
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1309
- const data = ui.__;
1350
+ const data = ui.__;
1351
+ if (attrName === "fill" && !data.__naturalWidth) {
1310
1352
  data.__naturalWidth = image.width / data.pixelRatio;
1311
1353
  data.__naturalHeight = image.height / data.pixelRatio;
1312
1354
  if (data.__autoSide) {
@@ -1318,7 +1360,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1318
1360
  return false;
1319
1361
  }
1320
1362
  }
1321
- if (!leafPaint.data) draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1363
+ if (!leafPaint.data) {
1364
+ draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1365
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1366
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1367
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1368
+ }
1322
1369
  return true;
1323
1370
  }
1324
1371
 
@@ -1361,7 +1408,7 @@ function getPatternData(paint, box, image) {
1361
1408
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1362
1409
  if (paint.mode === "strench") paint.mode = "stretch";
1363
1410
  const {width: width, height: height} = image;
1364
- 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;
1365
1412
  const sameBox = box.width === width && box.height === height;
1366
1413
  const data = {
1367
1414
  mode: mode
@@ -1424,8 +1471,6 @@ function getPatternData(paint, box, image) {
1424
1471
  data.scaleX = scaleX;
1425
1472
  data.scaleY = scaleY;
1426
1473
  }
1427
- if (opacity && opacity < 1) data.opacity = opacity;
1428
- if (filters) data.filters = filters;
1429
1474
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1430
1475
  if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1431
1476
  type: "x",
@@ -1456,7 +1501,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1456
1501
 
1457
1502
  function stretchMode(data, box, scaleX, scaleY) {
1458
1503
  const transform = get$2(), {x: x, y: y} = box;
1459
- 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;
1460
1505
  scaleHelper(transform, scaleX, scaleY);
1461
1506
  data.transform = transform;
1462
1507
  }
@@ -1528,39 +1573,6 @@ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
1528
1573
  translate(transform, box.x + x, box.y + y);
1529
1574
  }
1530
1575
 
1531
- function __awaiter(thisArg, _arguments, P, generator) {
1532
- function adopt(value) {
1533
- return value instanceof P ? value : new P(function(resolve) {
1534
- resolve(value);
1535
- });
1536
- }
1537
- return new (P || (P = Promise))(function(resolve, reject) {
1538
- function fulfilled(value) {
1539
- try {
1540
- step(generator.next(value));
1541
- } catch (e) {
1542
- reject(e);
1543
- }
1544
- }
1545
- function rejected(value) {
1546
- try {
1547
- step(generator["throw"](value));
1548
- } catch (e) {
1549
- reject(e);
1550
- }
1551
- }
1552
- function step(result) {
1553
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1554
- }
1555
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1556
- });
1557
- }
1558
-
1559
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
1560
- var e = new Error(message);
1561
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1562
- };
1563
-
1564
1576
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1565
1577
 
1566
1578
  const {getFloorScale: getFloorScale} = core.MathHelper, {abs: abs$1} = Math;
@@ -1578,10 +1590,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1578
1590
  }
1579
1591
 
1580
1592
  function createPattern(paint, ui, canvas, renderOptions) {
1581
- let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1593
+ let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1582
1594
  if (paint.patternId !== id && !ui.destroyed) {
1583
1595
  if (!(core.Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1584
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1596
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1585
1597
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1586
1598
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1587
1599
  width *= scaleX;
@@ -1597,7 +1609,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1597
1609
  if (transform) copy$1(imageMatrix, transform);
1598
1610
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1599
1611
  }
1600
- 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, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1601
1613
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1602
1614
  paint.style = pattern;
1603
1615
  paint.patternId = id;
@@ -1618,15 +1630,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1618
1630
  }
1619
1631
 
1620
1632
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1621
- const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1633
+ const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1622
1634
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1623
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1635
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1624
1636
  return false;
1625
1637
  } else {
1626
1638
  if (drawImage) {
1627
1639
  if (data.repeat) {
1628
1640
  drawImage = false;
1629
- } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1641
+ } else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1630
1642
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1631
1643
  }
1632
1644
  }
@@ -1644,20 +1656,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1644
1656
  }
1645
1657
  }
1646
1658
 
1647
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1648
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1649
- let {width: width, height: height} = image, clipUI;
1650
- 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;
1651
1664
  canvas.save();
1652
- clipUI && canvas.clipUI(ui);
1665
+ complex === 2 && canvas.clipUI(ui);
1653
1666
  blendMode && (canvas.blendMode = blendMode);
1654
1667
  opacity && (canvas.opacity *= opacity);
1655
1668
  transform && canvas.transform(transform);
1656
- canvas.drawImage(view, 0, 0, width, height);
1669
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1657
1670
  canvas.restore();
1658
1671
  } else {
1659
1672
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1660
- canvas.drawImage(view, 0, 0, width, height);
1673
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1661
1674
  }
1662
1675
  }
1663
1676
 
@@ -2602,6 +2615,13 @@ Object.assign(core.Creator, {
2602
2615
 
2603
2616
  useCanvas();
2604
2617
 
2618
+ Object.defineProperty(exports, "LeaferFilm", {
2619
+ enumerable: true,
2620
+ get: function() {
2621
+ return core.LeaferFilm;
2622
+ }
2623
+ });
2624
+
2605
2625
  Object.defineProperty(exports, "LeaferImage", {
2606
2626
  enumerable: true,
2607
2627
  get: function() {
@@ -2609,6 +2629,13 @@ Object.defineProperty(exports, "LeaferImage", {
2609
2629
  }
2610
2630
  });
2611
2631
 
2632
+ Object.defineProperty(exports, "LeaferVideo", {
2633
+ enumerable: true,
2634
+ get: function() {
2635
+ return core.LeaferVideo;
2636
+ }
2637
+ });
2638
+
2612
2639
  exports.Layouter = Layouter;
2613
2640
 
2614
2641
  exports.LeaferCanvas = LeaferCanvas;
@@ -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 { HitCanvasManager, InteractionBase } from "@leafer-ui/core";
8
8
 
@@ -19,6 +19,39 @@ var PathNodeHandleType;
19
19
  PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
20
20
  })(PathNodeHandleType || (PathNodeHandleType = {}));
21
21
 
22
+ function __awaiter(thisArg, _arguments, P, generator) {
23
+ function adopt(value) {
24
+ return value instanceof P ? value : new P(function(resolve) {
25
+ resolve(value);
26
+ });
27
+ }
28
+ return new (P || (P = Promise))(function(resolve, reject) {
29
+ function fulfilled(value) {
30
+ try {
31
+ step(generator.next(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ }
36
+ function rejected(value) {
37
+ try {
38
+ step(generator["throw"](value));
39
+ } catch (e) {
40
+ reject(e);
41
+ }
42
+ }
43
+ function step(result) {
44
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
+ }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ }
49
+
50
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
51
+ var e = new Error(message);
52
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
+ };
54
+
22
55
  class LeaferCanvas extends LeaferCanvasBase {
23
56
  get allowBackgroundColor() {
24
57
  return true;
@@ -43,8 +76,6 @@ canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
43
76
 
44
77
  canvasPatch(Path2D.prototype);
45
78
 
46
- const {mineType: mineType} = FileHelper;
47
-
48
79
  Object.assign(Creator, {
49
80
  canvas: (options, manager) => new LeaferCanvas(options, manager),
50
81
  image: options => new LeaferImage(options)
@@ -55,7 +86,7 @@ function useCanvas(_canvasType, _power) {
55
86
  createCanvas: (width, height) => new OffscreenCanvas(width, height),
56
87
  canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
57
88
  canvas.convertToBlob({
58
- type: mineType(type),
89
+ type: FileHelper.mimeType(type),
59
90
  quality: quality
60
91
  }).then(blob => {
61
92
  var reader = new FileReader;
@@ -67,14 +98,14 @@ function useCanvas(_canvasType, _power) {
67
98
  });
68
99
  }),
69
100
  canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
70
- type: mineType(type),
101
+ type: FileHelper.mimeType(type),
71
102
  quality: quality
72
103
  }),
73
104
  canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
74
105
  download(_url, _filename) {
75
106
  return undefined;
76
107
  },
77
- loadImage(src) {
108
+ loadImage(src, _crossOrigin, _leaferImage) {
78
109
  return new Promise((resolve, reject) => {
79
110
  let req = new XMLHttpRequest;
80
111
  req.open("GET", Platform.image.getRealURL(src), true);
@@ -89,6 +120,13 @@ function useCanvas(_canvasType, _power) {
89
120
  req.onerror = e => reject(e);
90
121
  req.send();
91
122
  });
123
+ },
124
+ loadContent(url_1) {
125
+ return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
126
+ const response = yield fetch(url);
127
+ if (!response.ok) throw new Error(`${response.status}`);
128
+ return yield response[responseType]();
129
+ });
92
130
  }
93
131
  };
94
132
  Platform.canvas = Creator.canvas();
@@ -588,7 +626,7 @@ class Renderer {
588
626
  getCellList() {
589
627
  return undefined;
590
628
  }
591
- addBlock(block) {
629
+ addBlock(block, _leafList) {
592
630
  if (!this.updateBlocks) this.updateBlocks = [];
593
631
  this.updateBlocks.push(block);
594
632
  }
@@ -636,7 +674,8 @@ class Renderer {
636
674
  __onLayoutEnd(event) {
637
675
  if (event.data) event.data.map(item => {
638
676
  let empty;
639
- if (item.updatedList) item.updatedList.list.some(leaf => {
677
+ const {updatedList: updatedList} = item;
678
+ if (updatedList) updatedList.list.some(leaf => {
640
679
  empty = !leaf.__world.width || !leaf.__world.height;
641
680
  if (empty) {
642
681
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -644,7 +683,7 @@ class Renderer {
644
683
  }
645
684
  return empty;
646
685
  });
647
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
686
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
648
687
  });
649
688
  }
650
689
  emitRender(type, bounds, options) {
@@ -1184,11 +1223,14 @@ function compute(attrName, ui) {
1184
1223
  function getLeafPaint(attrName, paint, ui) {
1185
1224
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1186
1225
  let leafPaint;
1187
- const {boxBounds: boxBounds} = ui.__layout;
1188
- switch (paint.type) {
1226
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1227
+ switch (type) {
1189
1228
  case "image":
1229
+ case "film":
1230
+ case "video":
1190
1231
  if (!paint.url) return undefined;
1191
1232
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1233
+ if (type !== "image") PaintImage[type](leafPaint);
1192
1234
  break;
1193
1235
 
1194
1236
  case "linear":
@@ -1204,7 +1246,7 @@ function getLeafPaint(attrName, paint, ui) {
1204
1246
  break;
1205
1247
 
1206
1248
  case "solid":
1207
- const {type: type, color: color, opacity: opacity} = paint;
1249
+ const {color: color, opacity: opacity} = paint;
1208
1250
  leafPaint = {
1209
1251
  type: type,
1210
1252
  style: ColorConvert.string(color, opacity)
@@ -1248,7 +1290,7 @@ const {isSame: isSame} = BoundsHelper;
1248
1290
 
1249
1291
  function image(ui, attrName, paint, boxBounds, firstUse) {
1250
1292
  let leafPaint, event;
1251
- const image = ImageManager.get(paint);
1293
+ const image = ImageManager.get(paint, paint.type);
1252
1294
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1253
1295
  leafPaint = cache.leafPaint;
1254
1296
  } else {
@@ -1309,8 +1351,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1309
1351
  }
1310
1352
 
1311
1353
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1312
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1313
- const data = ui.__;
1354
+ const data = ui.__;
1355
+ if (attrName === "fill" && !data.__naturalWidth) {
1314
1356
  data.__naturalWidth = image.width / data.pixelRatio;
1315
1357
  data.__naturalHeight = image.height / data.pixelRatio;
1316
1358
  if (data.__autoSide) {
@@ -1322,7 +1364,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1322
1364
  return false;
1323
1365
  }
1324
1366
  }
1325
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
1367
+ if (!leafPaint.data) {
1368
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
1369
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1370
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1371
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1372
+ }
1326
1373
  return true;
1327
1374
  }
1328
1375
 
@@ -1365,7 +1412,7 @@ function getPatternData(paint, box, image) {
1365
1412
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1366
1413
  if (paint.mode === "strench") paint.mode = "stretch";
1367
1414
  const {width: width, height: height} = image;
1368
- 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;
1415
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1369
1416
  const sameBox = box.width === width && box.height === height;
1370
1417
  const data = {
1371
1418
  mode: mode
@@ -1428,8 +1475,6 @@ function getPatternData(paint, box, image) {
1428
1475
  data.scaleX = scaleX;
1429
1476
  data.scaleY = scaleY;
1430
1477
  }
1431
- if (opacity && opacity < 1) data.opacity = opacity;
1432
- if (filters) data.filters = filters;
1433
1478
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1434
1479
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1435
1480
  type: "x",
@@ -1460,7 +1505,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1460
1505
 
1461
1506
  function stretchMode(data, box, scaleX, scaleY) {
1462
1507
  const transform = get$2(), {x: x, y: y} = box;
1463
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1508
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1464
1509
  scaleHelper(transform, scaleX, scaleY);
1465
1510
  data.transform = transform;
1466
1511
  }
@@ -1532,39 +1577,6 @@ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
1532
1577
  translate(transform, box.x + x, box.y + y);
1533
1578
  }
1534
1579
 
1535
- function __awaiter(thisArg, _arguments, P, generator) {
1536
- function adopt(value) {
1537
- return value instanceof P ? value : new P(function(resolve) {
1538
- resolve(value);
1539
- });
1540
- }
1541
- return new (P || (P = Promise))(function(resolve, reject) {
1542
- function fulfilled(value) {
1543
- try {
1544
- step(generator.next(value));
1545
- } catch (e) {
1546
- reject(e);
1547
- }
1548
- }
1549
- function rejected(value) {
1550
- try {
1551
- step(generator["throw"](value));
1552
- } catch (e) {
1553
- reject(e);
1554
- }
1555
- }
1556
- function step(result) {
1557
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1558
- }
1559
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1560
- });
1561
- }
1562
-
1563
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
1564
- var e = new Error(message);
1565
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1566
- };
1567
-
1568
1580
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1569
1581
 
1570
1582
  const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$1} = Math;
@@ -1582,10 +1594,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1582
1594
  }
1583
1595
 
1584
1596
  function createPattern(paint, ui, canvas, renderOptions) {
1585
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1597
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1586
1598
  if (paint.patternId !== id && !ui.destroyed) {
1587
1599
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1588
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1600
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1589
1601
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1590
1602
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1591
1603
  width *= scaleX;
@@ -1601,7 +1613,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1601
1613
  if (transform) copy$1(imageMatrix, transform);
1602
1614
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1603
1615
  }
1604
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1616
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1605
1617
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1606
1618
  paint.style = pattern;
1607
1619
  paint.patternId = id;
@@ -1622,15 +1634,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1622
1634
  }
1623
1635
 
1624
1636
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1625
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1637
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1626
1638
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1627
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1639
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1628
1640
  return false;
1629
1641
  } else {
1630
1642
  if (drawImage) {
1631
1643
  if (data.repeat) {
1632
1644
  drawImage = false;
1633
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1645
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1634
1646
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1635
1647
  }
1636
1648
  }
@@ -1648,20 +1660,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1648
1660
  }
1649
1661
  }
1650
1662
 
1651
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1652
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1653
- let {width: width, height: height} = image, clipUI;
1654
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1663
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1664
+ const {data: data, image: image, complex: complex} = paint;
1665
+ let {width: width, height: height} = image;
1666
+ if (complex) {
1667
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1655
1668
  canvas.save();
1656
- clipUI && canvas.clipUI(ui);
1669
+ complex === 2 && canvas.clipUI(ui);
1657
1670
  blendMode && (canvas.blendMode = blendMode);
1658
1671
  opacity && (canvas.opacity *= opacity);
1659
1672
  transform && canvas.transform(transform);
1660
- canvas.drawImage(view, 0, 0, width, height);
1673
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1661
1674
  canvas.restore();
1662
1675
  } else {
1663
1676
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1664
- canvas.drawImage(view, 0, 0, width, height);
1677
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1665
1678
  }
1666
1679
  }
1667
1680