@leafer-ui/node 1.3.2 → 1.4.0
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 +22 -15
- package/dist/node.cjs.map +1 -0
- package/dist/node.esm.js +22 -15
- package/dist/node.esm.js.map +1 -0
- package/dist/node.esm.min.js +2 -1
- package/dist/node.esm.min.js.map +1 -0
- package/dist/node.min.cjs +2 -1
- package/dist/node.min.cjs.map +1 -0
- package/package.json +16 -16
package/dist/node.cjs
CHANGED
|
@@ -19,7 +19,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
19
19
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
20
|
PERFORMANCE OF THIS SOFTWARE.
|
|
21
21
|
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
22
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -84,8 +84,8 @@ function useCanvas(canvasType, power) {
|
|
|
84
84
|
core.Platform.origin = {
|
|
85
85
|
createCanvas: (width, height, format) => new Canvas(width, height, format),
|
|
86
86
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
87
|
-
canvasToBolb: (canvas, type, quality) => __awaiter(this,
|
|
88
|
-
canvasSaveAs: (canvas, filename, quality) => __awaiter(this,
|
|
87
|
+
canvasToBolb: (canvas, type, quality) => __awaiter(this, undefined, undefined, function* () { return canvas.toBuffer(mineType(type), quality); }),
|
|
88
|
+
canvasSaveAs: (canvas, filename, quality) => __awaiter(this, undefined, undefined, function* () { return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
|
|
89
89
|
download(_url, _filename) { return undefined; },
|
|
90
90
|
loadImage(src) { return loadImage(core.Platform.image.getRealURL(src)); }
|
|
91
91
|
};
|
|
@@ -360,7 +360,7 @@ class Layouter {
|
|
|
360
360
|
}
|
|
361
361
|
partLayout() {
|
|
362
362
|
var _a;
|
|
363
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
363
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
364
364
|
return;
|
|
365
365
|
const t = core.Run.start('PartLayout');
|
|
366
366
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1468,7 +1468,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
else {
|
|
1470
1470
|
if (!paint.patternTask) {
|
|
1471
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1471
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1472
1472
|
paint.patternTask = null;
|
|
1473
1473
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1474
1474
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -1624,7 +1624,7 @@ function shadow(ui, current, shape) {
|
|
|
1624
1624
|
const end = shadow.length - 1;
|
|
1625
1625
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
1626
1626
|
shadow.forEach((item, index) => {
|
|
1627
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
1627
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
|
|
1628
1628
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
1629
1629
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
1630
1630
|
copyBounds = bounds;
|
|
@@ -1700,7 +1700,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1700
1700
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
1701
1701
|
copyBounds = bounds;
|
|
1702
1702
|
}
|
|
1703
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
1703
|
+
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1704
1704
|
if (ui.__worldFlipped) {
|
|
1705
1705
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1706
1706
|
}
|
|
@@ -2058,11 +2058,11 @@ const TextMode = 2;
|
|
|
2058
2058
|
function layoutChar(drawData, style, width, _height) {
|
|
2059
2059
|
const { rows } = drawData;
|
|
2060
2060
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
2061
|
-
let charX, addWordWidth, indentWidth, mode, wordChar;
|
|
2061
|
+
let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
|
|
2062
2062
|
rows.forEach(row => {
|
|
2063
2063
|
if (row.words) {
|
|
2064
|
-
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2065
|
-
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') &&
|
|
2064
|
+
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
2065
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
|
|
2066
2066
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2067
2067
|
if (row.isOverflow && !letterSpacing)
|
|
2068
2068
|
row.textMode = true;
|
|
@@ -2074,7 +2074,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2074
2074
|
row.x += indentWidth;
|
|
2075
2075
|
charX = row.x;
|
|
2076
2076
|
row.data = [];
|
|
2077
|
-
row.words.forEach(word => {
|
|
2077
|
+
row.words.forEach((word, index) => {
|
|
2078
2078
|
if (mode === WordMode) {
|
|
2079
2079
|
wordChar = { char: '', x: charX };
|
|
2080
2080
|
charX = toWordChar(word.data, charX, wordChar);
|
|
@@ -2084,7 +2084,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2084
2084
|
else {
|
|
2085
2085
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2086
2086
|
}
|
|
2087
|
-
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2087
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
|
|
2088
2088
|
charX += addWordWidth;
|
|
2089
2089
|
row.width += addWordWidth;
|
|
2090
2090
|
}
|
|
@@ -2376,10 +2376,10 @@ const ExportModule = {
|
|
|
2376
2376
|
const { leafer } = leaf;
|
|
2377
2377
|
if (leafer) {
|
|
2378
2378
|
checkLazy(leaf);
|
|
2379
|
-
leafer.waitViewCompleted(() => __awaiter(this,
|
|
2379
|
+
leafer.waitViewCompleted(() => __awaiter(this, undefined, undefined, function* () {
|
|
2380
2380
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2381
2381
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
2382
|
-
const { slice, trim, onCanvas } = options;
|
|
2382
|
+
const { slice, trim, padding, onCanvas } = options;
|
|
2383
2383
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
2384
2384
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2385
2385
|
const screenshot = options.screenshot || leaf.isApp;
|
|
@@ -2453,6 +2453,12 @@ const ExportModule = {
|
|
|
2453
2453
|
canvas = draw.Creator.canvas(config);
|
|
2454
2454
|
canvas.copyWorld(old, trimBounds, config);
|
|
2455
2455
|
}
|
|
2456
|
+
if (padding) {
|
|
2457
|
+
const [top, right, bottom, left] = draw.MathHelper.fourNumber(padding);
|
|
2458
|
+
const old = canvas, { width, height } = old;
|
|
2459
|
+
canvas = draw.Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
|
|
2460
|
+
canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
|
|
2461
|
+
}
|
|
2456
2462
|
if (needFill)
|
|
2457
2463
|
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
2458
2464
|
if (onCanvas)
|
|
@@ -2472,7 +2478,7 @@ function addTask(task) {
|
|
|
2472
2478
|
if (!tasker)
|
|
2473
2479
|
tasker = new draw.TaskProcessor();
|
|
2474
2480
|
return new Promise((resolve) => {
|
|
2475
|
-
tasker.add(() => __awaiter(this,
|
|
2481
|
+
tasker.add(() => __awaiter(this, undefined, undefined, function* () { return yield task(resolve); }), { parallel: false });
|
|
2476
2482
|
});
|
|
2477
2483
|
}
|
|
2478
2484
|
function checkLazy(leaf) {
|
|
@@ -2552,3 +2558,4 @@ Object.keys(core$1).forEach(function (k) {
|
|
|
2552
2558
|
get: function () { return core$1[k]; }
|
|
2553
2559
|
});
|
|
2554
2560
|
});
|
|
2561
|
+
//# sourceMappingURL=node.cjs.map
|