@leafer-draw/worker 1.0.0-rc.27 → 1.0.0-rc.28
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.esm.js +18 -8
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +39 -14
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +39 -14
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.module.js
CHANGED
|
@@ -11,8 +11,15 @@ const Platform = {
|
|
|
11
11
|
hitCanvasSize: 100,
|
|
12
12
|
maxCacheSize: 2560 * 1600,
|
|
13
13
|
maxPatternSize: 4096 * 2160,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
crossOrigin: 'anonymous',
|
|
15
|
+
getRealURL(url) {
|
|
16
|
+
const { prefix, suffix } = Platform.image;
|
|
17
|
+
if (suffix && !url.startsWith('data:') && !url.startsWith('blob:'))
|
|
18
|
+
url += (url.includes("?") ? "&" : "?") + suffix;
|
|
19
|
+
if (prefix && url[0] === '/')
|
|
20
|
+
url = prefix + url;
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
};
|
|
18
25
|
|
|
@@ -5126,6 +5133,7 @@ let Leaf = class Leaf {
|
|
|
5126
5133
|
get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
|
|
5127
5134
|
get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
|
|
5128
5135
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5136
|
+
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5129
5137
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5130
5138
|
constructor(data) {
|
|
5131
5139
|
this.innerId = create(LEAF);
|
|
@@ -5210,6 +5218,9 @@ let Leaf = class Leaf {
|
|
|
5210
5218
|
findOne(_condition, _options) { return undefined; }
|
|
5211
5219
|
findId(_id) { return undefined; }
|
|
5212
5220
|
focus(_value) { }
|
|
5221
|
+
updateLayout() {
|
|
5222
|
+
this.__layout.update();
|
|
5223
|
+
}
|
|
5213
5224
|
forceUpdate(attrName) {
|
|
5214
5225
|
if (attrName === undefined)
|
|
5215
5226
|
attrName = 'width';
|
|
@@ -5219,8 +5230,8 @@ let Leaf = class Leaf {
|
|
|
5219
5230
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5220
5231
|
this[attrName] = value;
|
|
5221
5232
|
}
|
|
5222
|
-
|
|
5223
|
-
this.
|
|
5233
|
+
forceRender(_bounds) {
|
|
5234
|
+
this.forceUpdate('surface');
|
|
5224
5235
|
}
|
|
5225
5236
|
__updateWorldMatrix() { }
|
|
5226
5237
|
__updateLocalMatrix() { }
|
|
@@ -5801,10 +5812,8 @@ function useCanvas(_canvasType, _power) {
|
|
|
5801
5812
|
download(_url, _filename) { return undefined; },
|
|
5802
5813
|
loadImage(src) {
|
|
5803
5814
|
return new Promise((resolve, reject) => {
|
|
5804
|
-
if (!src.startsWith('data:') && Platform.image.suffix)
|
|
5805
|
-
src += (src.includes("?") ? "&" : "?") + Platform.image.suffix;
|
|
5806
5815
|
let req = new XMLHttpRequest();
|
|
5807
|
-
req.open('GET', src, true);
|
|
5816
|
+
req.open('GET', Platform.image.getRealURL(src), true);
|
|
5808
5817
|
req.responseType = "blob";
|
|
5809
5818
|
req.onload = () => {
|
|
5810
5819
|
createImageBitmap(req.response).then(img => {
|
|
@@ -6937,7 +6946,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
6937
6946
|
__onUpdateSize() {
|
|
6938
6947
|
if (this.__.__input) {
|
|
6939
6948
|
const data = this.__;
|
|
6940
|
-
(data.lazy && this.
|
|
6949
|
+
(data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
|
|
6941
6950
|
}
|
|
6942
6951
|
}
|
|
6943
6952
|
__updateRenderPath() {
|
|
@@ -7495,6 +7504,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7495
7504
|
if (!this.parent)
|
|
7496
7505
|
this.canvas.hittable = newValue;
|
|
7497
7506
|
}
|
|
7507
|
+
else if (attrName === 'zIndex') {
|
|
7508
|
+
this.canvas.zIndex = newValue;
|
|
7509
|
+
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
7510
|
+
}
|
|
7498
7511
|
}
|
|
7499
7512
|
return super.__setAttr(attrName, newValue);
|
|
7500
7513
|
}
|
|
@@ -8113,7 +8126,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8113
8126
|
__drawAfterFill(canvas, _options) {
|
|
8114
8127
|
const origin = this.canvas.view;
|
|
8115
8128
|
const { width, height } = this;
|
|
8116
|
-
if (this.__.cornerRadius) {
|
|
8129
|
+
if (this.__.cornerRadius || this.pathInputed) {
|
|
8117
8130
|
canvas.save();
|
|
8118
8131
|
canvas.clip();
|
|
8119
8132
|
canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
|
|
@@ -8994,7 +9007,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
8994
9007
|
width *= data.scaleX;
|
|
8995
9008
|
height *= data.scaleY;
|
|
8996
9009
|
}
|
|
8997
|
-
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
9010
|
+
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
8998
9011
|
}
|
|
8999
9012
|
else {
|
|
9000
9013
|
allowPaint = false;
|
|
@@ -9506,7 +9519,8 @@ function createRows(drawData, content, style) {
|
|
|
9506
9519
|
if (breakAll) {
|
|
9507
9520
|
if (wordWidth)
|
|
9508
9521
|
addWord();
|
|
9509
|
-
|
|
9522
|
+
if (rowWidth)
|
|
9523
|
+
addRow();
|
|
9510
9524
|
}
|
|
9511
9525
|
else {
|
|
9512
9526
|
if (!afterBreak)
|
|
@@ -9514,10 +9528,12 @@ function createRows(drawData, content, style) {
|
|
|
9514
9528
|
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
9515
9529
|
if (wordWidth)
|
|
9516
9530
|
addWord();
|
|
9517
|
-
|
|
9531
|
+
if (rowWidth)
|
|
9532
|
+
addRow();
|
|
9518
9533
|
}
|
|
9519
9534
|
else {
|
|
9520
|
-
|
|
9535
|
+
if (rowWidth)
|
|
9536
|
+
addRow();
|
|
9521
9537
|
}
|
|
9522
9538
|
}
|
|
9523
9539
|
}
|
|
@@ -9903,6 +9919,7 @@ const ExportModule = {
|
|
|
9903
9919
|
}
|
|
9904
9920
|
const { leafer } = leaf;
|
|
9905
9921
|
if (leafer) {
|
|
9922
|
+
checkLazy(leaf);
|
|
9906
9923
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
9907
9924
|
options = FileHelper.getExportOptions(options);
|
|
9908
9925
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
@@ -9910,6 +9927,8 @@ const ExportModule = {
|
|
|
9910
9927
|
const { slice, trim, onCanvas } = options;
|
|
9911
9928
|
let scale = options.scale || 1;
|
|
9912
9929
|
let pixelRatio = options.pixelRatio || 1;
|
|
9930
|
+
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
9931
|
+
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
9913
9932
|
if (leaf.isApp) {
|
|
9914
9933
|
scale *= pixelRatio;
|
|
9915
9934
|
pixelRatio = leaf.app.pixelRatio;
|
|
@@ -9948,7 +9967,7 @@ const ExportModule = {
|
|
|
9948
9967
|
renderBounds = leaf.getBounds('render', relative);
|
|
9949
9968
|
}
|
|
9950
9969
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
9951
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
9970
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
9952
9971
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
9953
9972
|
if (slice) {
|
|
9954
9973
|
leaf = leafer;
|
|
@@ -9994,6 +10013,12 @@ function addTask(task) {
|
|
|
9994
10013
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
9995
10014
|
});
|
|
9996
10015
|
}
|
|
10016
|
+
function checkLazy(leaf) {
|
|
10017
|
+
if (leaf.__.__needComputePaint)
|
|
10018
|
+
leaf.__.__computePaint();
|
|
10019
|
+
if (leaf.isBranch)
|
|
10020
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
10021
|
+
}
|
|
9997
10022
|
|
|
9998
10023
|
const canvas = LeaferCanvasBase.prototype;
|
|
9999
10024
|
const debug = Debug.get('@leafer-ui/export');
|