@leafer-draw/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 +13 -13
package/dist/node.cjs
CHANGED
|
@@ -18,7 +18,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
18
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -83,8 +83,8 @@ function useCanvas(canvasType, power) {
|
|
|
83
83
|
core.Platform.origin = {
|
|
84
84
|
createCanvas: (width, height, format) => new Canvas(width, height, format),
|
|
85
85
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
86
|
-
canvasToBolb: (canvas, type, quality) => __awaiter(this,
|
|
87
|
-
canvasSaveAs: (canvas, filename, quality) => __awaiter(this,
|
|
86
|
+
canvasToBolb: (canvas, type, quality) => __awaiter(this, undefined, undefined, function* () { return canvas.toBuffer(mineType(type), quality); }),
|
|
87
|
+
canvasSaveAs: (canvas, filename, quality) => __awaiter(this, undefined, undefined, function* () { return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
|
|
88
88
|
download(_url, _filename) { return undefined; },
|
|
89
89
|
loadImage(src) { return loadImage(core.Platform.image.getRealURL(src)); }
|
|
90
90
|
};
|
|
@@ -359,7 +359,7 @@ class Layouter {
|
|
|
359
359
|
}
|
|
360
360
|
partLayout() {
|
|
361
361
|
var _a;
|
|
362
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
362
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
363
363
|
return;
|
|
364
364
|
const t = core.Run.start('PartLayout');
|
|
365
365
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1311,7 +1311,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1311
1311
|
}
|
|
1312
1312
|
else {
|
|
1313
1313
|
if (!paint.patternTask) {
|
|
1314
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1314
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1315
1315
|
paint.patternTask = null;
|
|
1316
1316
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1317
1317
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -1467,7 +1467,7 @@ function shadow(ui, current, shape) {
|
|
|
1467
1467
|
const end = shadow.length - 1;
|
|
1468
1468
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
1469
1469
|
shadow.forEach((item, index) => {
|
|
1470
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
1470
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
|
|
1471
1471
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
1472
1472
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
1473
1473
|
copyBounds = bounds;
|
|
@@ -1543,7 +1543,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1543
1543
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
1544
1544
|
copyBounds = bounds;
|
|
1545
1545
|
}
|
|
1546
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
1546
|
+
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1547
1547
|
if (ui.__worldFlipped) {
|
|
1548
1548
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1549
1549
|
}
|
|
@@ -1901,11 +1901,11 @@ const TextMode = 2;
|
|
|
1901
1901
|
function layoutChar(drawData, style, width, _height) {
|
|
1902
1902
|
const { rows } = drawData;
|
|
1903
1903
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
1904
|
-
let charX, addWordWidth, indentWidth, mode, wordChar;
|
|
1904
|
+
let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
|
|
1905
1905
|
rows.forEach(row => {
|
|
1906
1906
|
if (row.words) {
|
|
1907
|
-
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
1908
|
-
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') &&
|
|
1907
|
+
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
1908
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
|
|
1909
1909
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
1910
1910
|
if (row.isOverflow && !letterSpacing)
|
|
1911
1911
|
row.textMode = true;
|
|
@@ -1917,7 +1917,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1917
1917
|
row.x += indentWidth;
|
|
1918
1918
|
charX = row.x;
|
|
1919
1919
|
row.data = [];
|
|
1920
|
-
row.words.forEach(word => {
|
|
1920
|
+
row.words.forEach((word, index) => {
|
|
1921
1921
|
if (mode === WordMode) {
|
|
1922
1922
|
wordChar = { char: '', x: charX };
|
|
1923
1923
|
charX = toWordChar(word.data, charX, wordChar);
|
|
@@ -1927,7 +1927,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1927
1927
|
else {
|
|
1928
1928
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
1929
1929
|
}
|
|
1930
|
-
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
1930
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
|
|
1931
1931
|
charX += addWordWidth;
|
|
1932
1932
|
row.width += addWordWidth;
|
|
1933
1933
|
}
|
|
@@ -2219,10 +2219,10 @@ const ExportModule = {
|
|
|
2219
2219
|
const { leafer } = leaf;
|
|
2220
2220
|
if (leafer) {
|
|
2221
2221
|
checkLazy(leaf);
|
|
2222
|
-
leafer.waitViewCompleted(() => __awaiter(this,
|
|
2222
|
+
leafer.waitViewCompleted(() => __awaiter(this, undefined, undefined, function* () {
|
|
2223
2223
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2224
2224
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
2225
|
-
const { slice, trim, onCanvas } = options;
|
|
2225
|
+
const { slice, trim, padding, onCanvas } = options;
|
|
2226
2226
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
2227
2227
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2228
2228
|
const screenshot = options.screenshot || leaf.isApp;
|
|
@@ -2296,6 +2296,12 @@ const ExportModule = {
|
|
|
2296
2296
|
canvas = draw.Creator.canvas(config);
|
|
2297
2297
|
canvas.copyWorld(old, trimBounds, config);
|
|
2298
2298
|
}
|
|
2299
|
+
if (padding) {
|
|
2300
|
+
const [top, right, bottom, left] = draw.MathHelper.fourNumber(padding);
|
|
2301
|
+
const old = canvas, { width, height } = old;
|
|
2302
|
+
canvas = draw.Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
|
|
2303
|
+
canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
|
|
2304
|
+
}
|
|
2299
2305
|
if (needFill)
|
|
2300
2306
|
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
2301
2307
|
if (onCanvas)
|
|
@@ -2315,7 +2321,7 @@ function addTask(task) {
|
|
|
2315
2321
|
if (!tasker)
|
|
2316
2322
|
tasker = new draw.TaskProcessor();
|
|
2317
2323
|
return new Promise((resolve) => {
|
|
2318
|
-
tasker.add(() => __awaiter(this,
|
|
2324
|
+
tasker.add(() => __awaiter(this, undefined, undefined, function* () { return yield task(resolve); }), { parallel: false });
|
|
2319
2325
|
});
|
|
2320
2326
|
}
|
|
2321
2327
|
function checkLazy(leaf) {
|
|
@@ -2387,3 +2393,4 @@ Object.keys(draw).forEach(function (k) {
|
|
|
2387
2393
|
get: function () { return draw[k]; }
|
|
2388
2394
|
});
|
|
2389
2395
|
});
|
|
2396
|
+
//# sourceMappingURL=node.cjs.map
|