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