@leafer-ui/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 -27
- 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 -27
- 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 +10 -10
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$1.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$1.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; }
|
|
@@ -6938,7 +6938,11 @@ const State = {
|
|
|
6938
6938
|
setStyleName() { return Plugin.need('state'); },
|
|
6939
6939
|
set() { return Plugin.need('state'); }
|
|
6940
6940
|
};
|
|
6941
|
-
const Transition = {
|
|
6941
|
+
const Transition = {
|
|
6942
|
+
list: {},
|
|
6943
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6944
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6945
|
+
};
|
|
6942
6946
|
|
|
6943
6947
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6944
6948
|
const emptyPaint = {};
|
|
@@ -7362,9 +7366,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7362
7366
|
this.__drawPathByBox(pen);
|
|
7363
7367
|
return pen;
|
|
7364
7368
|
}
|
|
7365
|
-
get editConfig() { return undefined; }
|
|
7366
|
-
get editOuter() { return ''; }
|
|
7367
|
-
get editInner() { return ''; }
|
|
7368
7369
|
constructor(data) {
|
|
7369
7370
|
super(data);
|
|
7370
7371
|
}
|
|
@@ -7446,8 +7447,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7446
7447
|
export(_filename, _options) {
|
|
7447
7448
|
return Plugin.need('export');
|
|
7448
7449
|
}
|
|
7450
|
+
syncExport(_filename, _options) {
|
|
7451
|
+
return Plugin.need('export');
|
|
7452
|
+
}
|
|
7449
7453
|
clone(data) {
|
|
7450
|
-
const json = this.toJSON();
|
|
7454
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7451
7455
|
if (data)
|
|
7452
7456
|
Object.assign(json, data);
|
|
7453
7457
|
return UI_1.one(json);
|
|
@@ -7746,7 +7750,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7746
7750
|
get layoutLocked() { return !this.layouter.running; }
|
|
7747
7751
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7748
7752
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7749
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7753
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7750
7754
|
constructor(userConfig, data) {
|
|
7751
7755
|
super(data);
|
|
7752
7756
|
this.config = {
|
|
@@ -8048,6 +8052,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8048
8052
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8049
8053
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8050
8054
|
}
|
|
8055
|
+
getClientPointByWorld(worldPoint) {
|
|
8056
|
+
const { x, y } = this.clientBounds;
|
|
8057
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8058
|
+
}
|
|
8051
8059
|
updateClientBounds() {
|
|
8052
8060
|
this.canvas && this.canvas.updateClientBounds();
|
|
8053
8061
|
}
|
|
@@ -10016,8 +10024,6 @@ ui$1.__updateHitCanvas = function () {
|
|
|
10016
10024
|
h.setStrokeOptions(data);
|
|
10017
10025
|
};
|
|
10018
10026
|
ui$1.__hit = function (inner) {
|
|
10019
|
-
if (Platform.name === 'miniapp')
|
|
10020
|
-
this.__drawHitPath(this.__hitCanvas);
|
|
10021
10027
|
const data = this.__;
|
|
10022
10028
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10023
10029
|
return true;
|
|
@@ -11372,13 +11378,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
11372
11378
|
}
|
|
11373
11379
|
|
|
11374
11380
|
function layoutText(drawData, style) {
|
|
11375
|
-
const { rows, bounds } = drawData;
|
|
11381
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
11376
11382
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11377
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
11383
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11378
11384
|
let starY = __baseLine;
|
|
11379
11385
|
if (__clipText && realHeight > height) {
|
|
11380
11386
|
realHeight = Math.max(height, __lineHeight);
|
|
11381
|
-
|
|
11387
|
+
if (countRows > 1)
|
|
11388
|
+
drawData.overflow = countRows;
|
|
11382
11389
|
}
|
|
11383
11390
|
else if (height || autoSizeAlign) {
|
|
11384
11391
|
switch (verticalAlign) {
|
|
@@ -11390,7 +11397,7 @@ function layoutText(drawData, style) {
|
|
|
11390
11397
|
}
|
|
11391
11398
|
starY += y;
|
|
11392
11399
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11393
|
-
for (let i = 0, len =
|
|
11400
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
11394
11401
|
row = rows[i];
|
|
11395
11402
|
row.x = x;
|
|
11396
11403
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -11459,7 +11466,7 @@ function clipText(drawData, style, x, width) {
|
|
|
11459
11466
|
if (i === end && charRight < right) {
|
|
11460
11467
|
break;
|
|
11461
11468
|
}
|
|
11462
|
-
else if (charRight < right && char.char !== ' ') {
|
|
11469
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
11463
11470
|
row.data.splice(i + 1);
|
|
11464
11471
|
row.width -= char.width;
|
|
11465
11472
|
break;
|