@leafer-draw/worker 1.4.1 → 1.5.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/worker.cjs +6 -5
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.esm.js +6 -5
- package/dist/worker.esm.js.map +1 -1
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +34 -25
- package/dist/worker.js.map +1 -1
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +34 -25
- package/dist/worker.module.js.map +1 -1
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +7 -7
package/dist/worker.module.js
CHANGED
|
@@ -3635,7 +3635,12 @@ const Resource = {
|
|
|
3635
3635
|
return R.map[key];
|
|
3636
3636
|
},
|
|
3637
3637
|
remove(key) {
|
|
3638
|
-
|
|
3638
|
+
const r = R.map[key];
|
|
3639
|
+
if (r) {
|
|
3640
|
+
if (r.destroy)
|
|
3641
|
+
r.destroy();
|
|
3642
|
+
delete R.map[key];
|
|
3643
|
+
}
|
|
3639
3644
|
},
|
|
3640
3645
|
loadImage(key, format) {
|
|
3641
3646
|
return new Promise((resolve, reject) => {
|
|
@@ -3661,6 +3666,7 @@ const Resource = {
|
|
|
3661
3666
|
const R = Resource;
|
|
3662
3667
|
|
|
3663
3668
|
const ImageManager = {
|
|
3669
|
+
maxRecycled: 100,
|
|
3664
3670
|
recycledList: [],
|
|
3665
3671
|
patternTasker: new TaskProcessor(),
|
|
3666
3672
|
get(config) {
|
|
@@ -3677,13 +3683,8 @@ const ImageManager = {
|
|
|
3677
3683
|
},
|
|
3678
3684
|
clearRecycled() {
|
|
3679
3685
|
const list = I.recycledList;
|
|
3680
|
-
if (list.length >
|
|
3681
|
-
list.forEach(image =>
|
|
3682
|
-
if (!image.use && image.url) {
|
|
3683
|
-
Resource.remove(image.url);
|
|
3684
|
-
image.destroy();
|
|
3685
|
-
}
|
|
3686
|
-
});
|
|
3686
|
+
if (list.length > I.maxRecycled) {
|
|
3687
|
+
list.forEach(image => (!image.use && image.url) && Resource.remove(image.url));
|
|
3687
3688
|
list.length = 0;
|
|
3688
3689
|
}
|
|
3689
3690
|
},
|
|
@@ -4069,12 +4070,11 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4069
4070
|
if (defaultValue === undefined) {
|
|
4070
4071
|
property.get = function () { return this[computedKey]; };
|
|
4071
4072
|
}
|
|
4072
|
-
else if (typeof defaultValue === '
|
|
4073
|
-
const { clone } = DataHelper;
|
|
4073
|
+
else if (typeof defaultValue === 'function') {
|
|
4074
4074
|
property.get = function () {
|
|
4075
4075
|
let v = this[computedKey];
|
|
4076
4076
|
if (v === undefined)
|
|
4077
|
-
this[computedKey] = v =
|
|
4077
|
+
this[computedKey] = v = defaultValue(this.__leaf);
|
|
4078
4078
|
return v;
|
|
4079
4079
|
};
|
|
4080
4080
|
}
|
|
@@ -5721,10 +5721,10 @@ let Leaf = class Leaf {
|
|
|
5721
5721
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5722
5722
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5723
5723
|
}
|
|
5724
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5724
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5725
5725
|
if (!fn)
|
|
5726
5726
|
fn = boundsType;
|
|
5727
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5727
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5728
5728
|
}
|
|
5729
5729
|
__emitLifeEvent(type) {
|
|
5730
5730
|
if (this.hasEvent(type))
|
|
@@ -6051,7 +6051,7 @@ class LeafLevelList {
|
|
|
6051
6051
|
}
|
|
6052
6052
|
}
|
|
6053
6053
|
|
|
6054
|
-
const version = "1.
|
|
6054
|
+
const version = "1.5.0";
|
|
6055
6055
|
|
|
6056
6056
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6057
6057
|
get allowBackgroundColor() { return true; }
|
|
@@ -6781,7 +6781,11 @@ const State = {
|
|
|
6781
6781
|
setStyleName() { return Plugin.need('state'); },
|
|
6782
6782
|
set() { return Plugin.need('state'); }
|
|
6783
6783
|
};
|
|
6784
|
-
const Transition = {
|
|
6784
|
+
const Transition = {
|
|
6785
|
+
list: {},
|
|
6786
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6787
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6788
|
+
};
|
|
6785
6789
|
|
|
6786
6790
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6787
6791
|
const emptyPaint = {};
|
|
@@ -7205,9 +7209,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7205
7209
|
this.__drawPathByBox(pen);
|
|
7206
7210
|
return pen;
|
|
7207
7211
|
}
|
|
7208
|
-
get editConfig() { return undefined; }
|
|
7209
|
-
get editOuter() { return ''; }
|
|
7210
|
-
get editInner() { return ''; }
|
|
7211
7212
|
constructor(data) {
|
|
7212
7213
|
super(data);
|
|
7213
7214
|
}
|
|
@@ -7289,8 +7290,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7289
7290
|
export(_filename, _options) {
|
|
7290
7291
|
return Plugin.need('export');
|
|
7291
7292
|
}
|
|
7293
|
+
syncExport(_filename, _options) {
|
|
7294
|
+
return Plugin.need('export');
|
|
7295
|
+
}
|
|
7292
7296
|
clone(data) {
|
|
7293
|
-
const json = this.toJSON();
|
|
7297
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7294
7298
|
if (data)
|
|
7295
7299
|
Object.assign(json, data);
|
|
7296
7300
|
return UI_1.one(json);
|
|
@@ -7589,7 +7593,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7589
7593
|
get layoutLocked() { return !this.layouter.running; }
|
|
7590
7594
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7591
7595
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7592
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7596
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7593
7597
|
constructor(userConfig, data) {
|
|
7594
7598
|
super(data);
|
|
7595
7599
|
this.config = {
|
|
@@ -7891,6 +7895,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7891
7895
|
getPagePointByClient(clientPoint, updateClient) {
|
|
7892
7896
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7893
7897
|
}
|
|
7898
|
+
getClientPointByWorld(worldPoint) {
|
|
7899
|
+
const { x, y } = this.clientBounds;
|
|
7900
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
7901
|
+
}
|
|
7894
7902
|
updateClientBounds() {
|
|
7895
7903
|
this.canvas && this.canvas.updateClientBounds();
|
|
7896
7904
|
}
|
|
@@ -9926,13 +9934,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
9926
9934
|
}
|
|
9927
9935
|
|
|
9928
9936
|
function layoutText(drawData, style) {
|
|
9929
|
-
const { rows, bounds } = drawData;
|
|
9937
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
9930
9938
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
9931
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
9939
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
9932
9940
|
let starY = __baseLine;
|
|
9933
9941
|
if (__clipText && realHeight > height) {
|
|
9934
9942
|
realHeight = Math.max(height, __lineHeight);
|
|
9935
|
-
|
|
9943
|
+
if (countRows > 1)
|
|
9944
|
+
drawData.overflow = countRows;
|
|
9936
9945
|
}
|
|
9937
9946
|
else if (height || autoSizeAlign) {
|
|
9938
9947
|
switch (verticalAlign) {
|
|
@@ -9944,7 +9953,7 @@ function layoutText(drawData, style) {
|
|
|
9944
9953
|
}
|
|
9945
9954
|
starY += y;
|
|
9946
9955
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
9947
|
-
for (let i = 0, len =
|
|
9956
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
9948
9957
|
row = rows[i];
|
|
9949
9958
|
row.x = x;
|
|
9950
9959
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -10013,7 +10022,7 @@ function clipText(drawData, style, x, width) {
|
|
|
10013
10022
|
if (i === end && charRight < right) {
|
|
10014
10023
|
break;
|
|
10015
10024
|
}
|
|
10016
|
-
else if (charRight < right && char.char !== ' ') {
|
|
10025
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
10017
10026
|
row.data.splice(i + 1);
|
|
10018
10027
|
row.width -= char.width;
|
|
10019
10028
|
break;
|