leafer-ui 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/README.md +13 -5
- package/dist/web.cjs +6 -5
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +6 -5
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +34 -27
- package/dist/web.js.map +1 -1
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +34 -27
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/web.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
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
6057
6057
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -7119,7 +7119,11 @@ const State = {
|
|
|
7119
7119
|
setStyleName() { return Plugin.need('state'); },
|
|
7120
7120
|
set() { return Plugin.need('state'); }
|
|
7121
7121
|
};
|
|
7122
|
-
const Transition = {
|
|
7122
|
+
const Transition = {
|
|
7123
|
+
list: {},
|
|
7124
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
7125
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
7126
|
+
};
|
|
7123
7127
|
|
|
7124
7128
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7125
7129
|
const emptyPaint = {};
|
|
@@ -7543,9 +7547,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7543
7547
|
this.__drawPathByBox(pen);
|
|
7544
7548
|
return pen;
|
|
7545
7549
|
}
|
|
7546
|
-
get editConfig() { return undefined; }
|
|
7547
|
-
get editOuter() { return ''; }
|
|
7548
|
-
get editInner() { return ''; }
|
|
7549
7550
|
constructor(data) {
|
|
7550
7551
|
super(data);
|
|
7551
7552
|
}
|
|
@@ -7627,8 +7628,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7627
7628
|
export(_filename, _options) {
|
|
7628
7629
|
return Plugin.need('export');
|
|
7629
7630
|
}
|
|
7631
|
+
syncExport(_filename, _options) {
|
|
7632
|
+
return Plugin.need('export');
|
|
7633
|
+
}
|
|
7630
7634
|
clone(data) {
|
|
7631
|
-
const json = this.toJSON();
|
|
7635
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7632
7636
|
if (data)
|
|
7633
7637
|
Object.assign(json, data);
|
|
7634
7638
|
return UI_1.one(json);
|
|
@@ -7927,7 +7931,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7927
7931
|
get layoutLocked() { return !this.layouter.running; }
|
|
7928
7932
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7929
7933
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7930
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7934
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7931
7935
|
constructor(userConfig, data) {
|
|
7932
7936
|
super(data);
|
|
7933
7937
|
this.config = {
|
|
@@ -8229,6 +8233,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8229
8233
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8230
8234
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8231
8235
|
}
|
|
8236
|
+
getClientPointByWorld(worldPoint) {
|
|
8237
|
+
const { x, y } = this.clientBounds;
|
|
8238
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8239
|
+
}
|
|
8232
8240
|
updateClientBounds() {
|
|
8233
8241
|
this.canvas && this.canvas.updateClientBounds();
|
|
8234
8242
|
}
|
|
@@ -10197,8 +10205,6 @@ ui$1.__updateHitCanvas = function () {
|
|
|
10197
10205
|
h.setStrokeOptions(data);
|
|
10198
10206
|
};
|
|
10199
10207
|
ui$1.__hit = function (inner) {
|
|
10200
|
-
if (Platform.name === 'miniapp')
|
|
10201
|
-
this.__drawHitPath(this.__hitCanvas);
|
|
10202
10208
|
const data = this.__;
|
|
10203
10209
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10204
10210
|
return true;
|
|
@@ -11862,13 +11868,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
11862
11868
|
}
|
|
11863
11869
|
|
|
11864
11870
|
function layoutText(drawData, style) {
|
|
11865
|
-
const { rows, bounds } = drawData;
|
|
11871
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
11866
11872
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11867
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
11873
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11868
11874
|
let starY = __baseLine;
|
|
11869
11875
|
if (__clipText && realHeight > height) {
|
|
11870
11876
|
realHeight = Math.max(height, __lineHeight);
|
|
11871
|
-
|
|
11877
|
+
if (countRows > 1)
|
|
11878
|
+
drawData.overflow = countRows;
|
|
11872
11879
|
}
|
|
11873
11880
|
else if (height || autoSizeAlign) {
|
|
11874
11881
|
switch (verticalAlign) {
|
|
@@ -11880,7 +11887,7 @@ function layoutText(drawData, style) {
|
|
|
11880
11887
|
}
|
|
11881
11888
|
starY += y;
|
|
11882
11889
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11883
|
-
for (let i = 0, len =
|
|
11890
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
11884
11891
|
row = rows[i];
|
|
11885
11892
|
row.x = x;
|
|
11886
11893
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -11949,7 +11956,7 @@ function clipText(drawData, style, x, width) {
|
|
|
11949
11956
|
if (i === end && charRight < right) {
|
|
11950
11957
|
break;
|
|
11951
11958
|
}
|
|
11952
|
-
else if (charRight < right && char.char !== ' ') {
|
|
11959
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
11953
11960
|
row.data.splice(i + 1);
|
|
11954
11961
|
row.width -= char.width;
|
|
11955
11962
|
break;
|