@leafer-ui/node 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/node.cjs +66 -36
- package/dist/node.esm.js +54 -38
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -12
- package/src/index.ts +2 -2
- package/types/index.d.ts +1 -8
- package/src/core.ts +0 -73
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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) {
|
|
@@ -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 (
|
|
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 {
|
|
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
|
-
|
|
1334
|
-
|
|
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,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
1343
1355
|
return false;
|
|
1344
1356
|
}
|
|
1345
1357
|
}
|
|
1346
|
-
if (!leafPaint.data)
|
|
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
|
+
}
|
|
1347
1364
|
return true;
|
|
1348
1365
|
}
|
|
1349
1366
|
|
|
@@ -1386,7 +1403,7 @@ function getPatternData(paint, box, image) {
|
|
|
1386
1403
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
1387
1404
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
1388
1405
|
const {width: width, height: height} = image;
|
|
1389
|
-
const {
|
|
1406
|
+
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
1407
|
const sameBox = box.width === width && box.height === height;
|
|
1391
1408
|
const data = {
|
|
1392
1409
|
mode: mode
|
|
@@ -1449,8 +1466,6 @@ function getPatternData(paint, box, image) {
|
|
|
1449
1466
|
data.scaleX = scaleX;
|
|
1450
1467
|
data.scaleY = scaleY;
|
|
1451
1468
|
}
|
|
1452
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
1453
|
-
if (filters) data.filters = filters;
|
|
1454
1469
|
if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
1455
1470
|
if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
|
|
1456
1471
|
type: "x",
|
|
@@ -1481,7 +1496,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
|
|
|
1481
1496
|
|
|
1482
1497
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
1483
1498
|
const transform = get$2(), {x: x, y: y} = box;
|
|
1484
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
1499
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
1485
1500
|
scaleHelper(transform, scaleX, scaleY);
|
|
1486
1501
|
data.transform = transform;
|
|
1487
1502
|
}
|
|
@@ -1570,10 +1585,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
|
1570
1585
|
}
|
|
1571
1586
|
|
|
1572
1587
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
1573
|
-
let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
1588
|
+
let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
1574
1589
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1575
1590
|
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);
|
|
1591
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
1577
1592
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
1578
1593
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
1579
1594
|
width *= scaleX;
|
|
@@ -1589,7 +1604,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
1589
1604
|
if (transform) copy$1(imageMatrix, transform);
|
|
1590
1605
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1591
1606
|
}
|
|
1592
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
1607
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
1593
1608
|
const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
1594
1609
|
paint.style = pattern;
|
|
1595
1610
|
paint.patternId = id;
|
|
@@ -1610,15 +1625,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
1610
1625
|
}
|
|
1611
1626
|
|
|
1612
1627
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
1613
|
-
const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
1628
|
+
const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
1614
1629
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
1615
|
-
if (!data || paint.patternId ===
|
|
1630
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
1616
1631
|
return false;
|
|
1617
1632
|
} else {
|
|
1618
1633
|
if (drawImage) {
|
|
1619
1634
|
if (data.repeat) {
|
|
1620
1635
|
drawImage = false;
|
|
1621
|
-
} else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
|
|
1636
|
+
} else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
|
|
1622
1637
|
drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
1623
1638
|
}
|
|
1624
1639
|
}
|
|
@@ -1636,20 +1651,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
1636
1651
|
}
|
|
1637
1652
|
}
|
|
1638
1653
|
|
|
1639
|
-
function drawImage(paint,
|
|
1640
|
-
const {data: data, image: image
|
|
1641
|
-
let {width: width, height: height} = image
|
|
1642
|
-
if (
|
|
1654
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
1655
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
1656
|
+
let {width: width, height: height} = image;
|
|
1657
|
+
if (complex) {
|
|
1658
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
1643
1659
|
canvas.save();
|
|
1644
|
-
|
|
1660
|
+
complex === 2 && canvas.clipUI(ui);
|
|
1645
1661
|
blendMode && (canvas.blendMode = blendMode);
|
|
1646
1662
|
opacity && (canvas.opacity *= opacity);
|
|
1647
1663
|
transform && canvas.transform(transform);
|
|
1648
|
-
|
|
1664
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
1649
1665
|
canvas.restore();
|
|
1650
1666
|
} else {
|
|
1651
1667
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
1652
|
-
|
|
1668
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
1653
1669
|
}
|
|
1654
1670
|
}
|
|
1655
1671
|
|
|
@@ -2849,6 +2865,13 @@ Object.assign(core.Creator, {
|
|
|
2849
2865
|
hitCanvasManager: () => new core$1.HitCanvasManager
|
|
2850
2866
|
});
|
|
2851
2867
|
|
|
2868
|
+
Object.defineProperty(exports, "LeaferFilm", {
|
|
2869
|
+
enumerable: true,
|
|
2870
|
+
get: function() {
|
|
2871
|
+
return core.LeaferFilm;
|
|
2872
|
+
}
|
|
2873
|
+
});
|
|
2874
|
+
|
|
2852
2875
|
Object.defineProperty(exports, "LeaferImage", {
|
|
2853
2876
|
enumerable: true,
|
|
2854
2877
|
get: function() {
|
|
@@ -2856,6 +2879,13 @@ Object.defineProperty(exports, "LeaferImage", {
|
|
|
2856
2879
|
}
|
|
2857
2880
|
});
|
|
2858
2881
|
|
|
2882
|
+
Object.defineProperty(exports, "LeaferVideo", {
|
|
2883
|
+
enumerable: true,
|
|
2884
|
+
get: function() {
|
|
2885
|
+
return core.LeaferVideo;
|
|
2886
|
+
}
|
|
2887
|
+
});
|
|
2888
|
+
|
|
2859
2889
|
exports.Layouter = Layouter;
|
|
2860
2890
|
|
|
2861
2891
|
exports.LeaferCanvas = LeaferCanvas;
|
package/dist/node.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch,
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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) {
|
|
@@ -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 (
|
|
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 {
|
|
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
|
-
|
|
1338
|
-
|
|
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,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
1347
1359
|
return false;
|
|
1348
1360
|
}
|
|
1349
1361
|
}
|
|
1350
|
-
if (!leafPaint.data)
|
|
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
|
+
}
|
|
1351
1368
|
return true;
|
|
1352
1369
|
}
|
|
1353
1370
|
|
|
@@ -1390,7 +1407,7 @@ function getPatternData(paint, box, image) {
|
|
|
1390
1407
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
1391
1408
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
1392
1409
|
const {width: width, height: height} = image;
|
|
1393
|
-
const {
|
|
1410
|
+
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
1411
|
const sameBox = box.width === width && box.height === height;
|
|
1395
1412
|
const data = {
|
|
1396
1413
|
mode: mode
|
|
@@ -1453,8 +1470,6 @@ function getPatternData(paint, box, image) {
|
|
|
1453
1470
|
data.scaleX = scaleX;
|
|
1454
1471
|
data.scaleY = scaleY;
|
|
1455
1472
|
}
|
|
1456
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
1457
|
-
if (filters) data.filters = filters;
|
|
1458
1473
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
1459
1474
|
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
1460
1475
|
type: "x",
|
|
@@ -1485,7 +1500,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
|
|
|
1485
1500
|
|
|
1486
1501
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
1487
1502
|
const transform = get$2(), {x: x, y: y} = box;
|
|
1488
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
1503
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
1489
1504
|
scaleHelper(transform, scaleX, scaleY);
|
|
1490
1505
|
data.transform = transform;
|
|
1491
1506
|
}
|
|
@@ -1574,10 +1589,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
|
1574
1589
|
}
|
|
1575
1590
|
|
|
1576
1591
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
1577
|
-
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
1592
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
1578
1593
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1579
1594
|
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);
|
|
1595
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
1581
1596
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
1582
1597
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
1583
1598
|
width *= scaleX;
|
|
@@ -1593,7 +1608,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
1593
1608
|
if (transform) copy$1(imageMatrix, transform);
|
|
1594
1609
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1595
1610
|
}
|
|
1596
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
1611
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
1597
1612
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
1598
1613
|
paint.style = pattern;
|
|
1599
1614
|
paint.patternId = id;
|
|
@@ -1614,15 +1629,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
1614
1629
|
}
|
|
1615
1630
|
|
|
1616
1631
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
1617
|
-
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
1632
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
1618
1633
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
1619
|
-
if (!data || paint.patternId ===
|
|
1634
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
1620
1635
|
return false;
|
|
1621
1636
|
} else {
|
|
1622
1637
|
if (drawImage) {
|
|
1623
1638
|
if (data.repeat) {
|
|
1624
1639
|
drawImage = false;
|
|
1625
|
-
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
1640
|
+
} else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
1626
1641
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
1627
1642
|
}
|
|
1628
1643
|
}
|
|
@@ -1640,20 +1655,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
1640
1655
|
}
|
|
1641
1656
|
}
|
|
1642
1657
|
|
|
1643
|
-
function drawImage(paint,
|
|
1644
|
-
const {data: data, image: image
|
|
1645
|
-
let {width: width, height: height} = image
|
|
1646
|
-
if (
|
|
1658
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
1659
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
1660
|
+
let {width: width, height: height} = image;
|
|
1661
|
+
if (complex) {
|
|
1662
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
1647
1663
|
canvas.save();
|
|
1648
|
-
|
|
1664
|
+
complex === 2 && canvas.clipUI(ui);
|
|
1649
1665
|
blendMode && (canvas.blendMode = blendMode);
|
|
1650
1666
|
opacity && (canvas.opacity *= opacity);
|
|
1651
1667
|
transform && canvas.transform(transform);
|
|
1652
|
-
|
|
1668
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
1653
1669
|
canvas.restore();
|
|
1654
1670
|
} else {
|
|
1655
1671
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
1656
|
-
|
|
1672
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
1657
1673
|
}
|
|
1658
1674
|
}
|
|
1659
1675
|
|