@leafer-game/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.js +59 -53
- package/dist/worker.js.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +59 -53
- 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.js
CHANGED
|
@@ -3638,7 +3638,12 @@ var LeaferUI = (function (exports) {
|
|
|
3638
3638
|
return R.map[key];
|
|
3639
3639
|
},
|
|
3640
3640
|
remove(key) {
|
|
3641
|
-
|
|
3641
|
+
const r = R.map[key];
|
|
3642
|
+
if (r) {
|
|
3643
|
+
if (r.destroy)
|
|
3644
|
+
r.destroy();
|
|
3645
|
+
delete R.map[key];
|
|
3646
|
+
}
|
|
3642
3647
|
},
|
|
3643
3648
|
loadImage(key, format) {
|
|
3644
3649
|
return new Promise((resolve, reject) => {
|
|
@@ -3664,6 +3669,7 @@ var LeaferUI = (function (exports) {
|
|
|
3664
3669
|
const R = Resource;
|
|
3665
3670
|
|
|
3666
3671
|
const ImageManager = {
|
|
3672
|
+
maxRecycled: 100,
|
|
3667
3673
|
recycledList: [],
|
|
3668
3674
|
patternTasker: new TaskProcessor(),
|
|
3669
3675
|
get(config) {
|
|
@@ -3680,13 +3686,8 @@ var LeaferUI = (function (exports) {
|
|
|
3680
3686
|
},
|
|
3681
3687
|
clearRecycled() {
|
|
3682
3688
|
const list = I$1.recycledList;
|
|
3683
|
-
if (list.length >
|
|
3684
|
-
list.forEach(image =>
|
|
3685
|
-
if (!image.use && image.url) {
|
|
3686
|
-
Resource.remove(image.url);
|
|
3687
|
-
image.destroy();
|
|
3688
|
-
}
|
|
3689
|
-
});
|
|
3689
|
+
if (list.length > I$1.maxRecycled) {
|
|
3690
|
+
list.forEach(image => (!image.use && image.url) && Resource.remove(image.url));
|
|
3690
3691
|
list.length = 0;
|
|
3691
3692
|
}
|
|
3692
3693
|
},
|
|
@@ -4072,12 +4073,11 @@ var LeaferUI = (function (exports) {
|
|
|
4072
4073
|
if (defaultValue === undefined) {
|
|
4073
4074
|
property.get = function () { return this[computedKey]; };
|
|
4074
4075
|
}
|
|
4075
|
-
else if (typeof defaultValue === '
|
|
4076
|
-
const { clone } = DataHelper;
|
|
4076
|
+
else if (typeof defaultValue === 'function') {
|
|
4077
4077
|
property.get = function () {
|
|
4078
4078
|
let v = this[computedKey];
|
|
4079
4079
|
if (v === undefined)
|
|
4080
|
-
this[computedKey] = v =
|
|
4080
|
+
this[computedKey] = v = defaultValue(this.__leaf);
|
|
4081
4081
|
return v;
|
|
4082
4082
|
};
|
|
4083
4083
|
}
|
|
@@ -5724,10 +5724,10 @@ var LeaferUI = (function (exports) {
|
|
|
5724
5724
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5725
5725
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5726
5726
|
}
|
|
5727
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5727
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5728
5728
|
if (!fn)
|
|
5729
5729
|
fn = boundsType;
|
|
5730
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5730
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5731
5731
|
}
|
|
5732
5732
|
__emitLifeEvent(type) {
|
|
5733
5733
|
if (this.hasEvent(type))
|
|
@@ -6054,7 +6054,7 @@ var LeaferUI = (function (exports) {
|
|
|
6054
6054
|
}
|
|
6055
6055
|
}
|
|
6056
6056
|
|
|
6057
|
-
const version = "1.
|
|
6057
|
+
const version = "1.5.0";
|
|
6058
6058
|
|
|
6059
6059
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6060
6060
|
get allowBackgroundColor() { return true; }
|
|
@@ -6941,7 +6941,11 @@ var LeaferUI = (function (exports) {
|
|
|
6941
6941
|
setStyleName() { return Plugin.need('state'); },
|
|
6942
6942
|
set() { return Plugin.need('state'); }
|
|
6943
6943
|
};
|
|
6944
|
-
const Transition = {
|
|
6944
|
+
const Transition = {
|
|
6945
|
+
list: {},
|
|
6946
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6947
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6948
|
+
};
|
|
6945
6949
|
|
|
6946
6950
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6947
6951
|
const emptyPaint = {};
|
|
@@ -7365,9 +7369,6 @@ var LeaferUI = (function (exports) {
|
|
|
7365
7369
|
this.__drawPathByBox(pen);
|
|
7366
7370
|
return pen;
|
|
7367
7371
|
}
|
|
7368
|
-
get editConfig() { return undefined; }
|
|
7369
|
-
get editOuter() { return ''; }
|
|
7370
|
-
get editInner() { return ''; }
|
|
7371
7372
|
constructor(data) {
|
|
7372
7373
|
super(data);
|
|
7373
7374
|
}
|
|
@@ -7449,8 +7450,11 @@ var LeaferUI = (function (exports) {
|
|
|
7449
7450
|
export(_filename, _options) {
|
|
7450
7451
|
return Plugin.need('export');
|
|
7451
7452
|
}
|
|
7453
|
+
syncExport(_filename, _options) {
|
|
7454
|
+
return Plugin.need('export');
|
|
7455
|
+
}
|
|
7452
7456
|
clone(data) {
|
|
7453
|
-
const json = this.toJSON();
|
|
7457
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7454
7458
|
if (data)
|
|
7455
7459
|
Object.assign(json, data);
|
|
7456
7460
|
return UI_1.one(json);
|
|
@@ -7749,7 +7753,7 @@ var LeaferUI = (function (exports) {
|
|
|
7749
7753
|
get layoutLocked() { return !this.layouter.running; }
|
|
7750
7754
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7751
7755
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7752
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7756
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7753
7757
|
constructor(userConfig, data) {
|
|
7754
7758
|
super(data);
|
|
7755
7759
|
this.config = {
|
|
@@ -8051,6 +8055,10 @@ var LeaferUI = (function (exports) {
|
|
|
8051
8055
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8052
8056
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8053
8057
|
}
|
|
8058
|
+
getClientPointByWorld(worldPoint) {
|
|
8059
|
+
const { x, y } = this.clientBounds;
|
|
8060
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8061
|
+
}
|
|
8054
8062
|
updateClientBounds() {
|
|
8055
8063
|
this.canvas && this.canvas.updateClientBounds();
|
|
8056
8064
|
}
|
|
@@ -10019,8 +10027,6 @@ var LeaferUI = (function (exports) {
|
|
|
10019
10027
|
h.setStrokeOptions(data);
|
|
10020
10028
|
};
|
|
10021
10029
|
ui$5.__hit = function (inner) {
|
|
10022
|
-
if (Platform.name === 'miniapp')
|
|
10023
|
-
this.__drawHitPath(this.__hitCanvas);
|
|
10024
10030
|
const data = this.__;
|
|
10025
10031
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10026
10032
|
return true;
|
|
@@ -11375,13 +11381,14 @@ var LeaferUI = (function (exports) {
|
|
|
11375
11381
|
}
|
|
11376
11382
|
|
|
11377
11383
|
function layoutText(drawData, style) {
|
|
11378
|
-
const { rows, bounds } = drawData;
|
|
11384
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
11379
11385
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11380
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
11386
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11381
11387
|
let starY = __baseLine;
|
|
11382
11388
|
if (__clipText && realHeight > height) {
|
|
11383
11389
|
realHeight = Math.max(height, __lineHeight);
|
|
11384
|
-
|
|
11390
|
+
if (countRows > 1)
|
|
11391
|
+
drawData.overflow = countRows;
|
|
11385
11392
|
}
|
|
11386
11393
|
else if (height || autoSizeAlign) {
|
|
11387
11394
|
switch (verticalAlign) {
|
|
@@ -11393,7 +11400,7 @@ var LeaferUI = (function (exports) {
|
|
|
11393
11400
|
}
|
|
11394
11401
|
starY += y;
|
|
11395
11402
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11396
|
-
for (let i = 0, len =
|
|
11403
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
11397
11404
|
row = rows[i];
|
|
11398
11405
|
row.x = x;
|
|
11399
11406
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -11462,7 +11469,7 @@ var LeaferUI = (function (exports) {
|
|
|
11462
11469
|
if (i === end && charRight < right) {
|
|
11463
11470
|
break;
|
|
11464
11471
|
}
|
|
11465
|
-
else if (charRight < right && char.char !== ' ') {
|
|
11472
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
11466
11473
|
row.data.splice(i + 1);
|
|
11467
11474
|
row.width -= char.width;
|
|
11468
11475
|
break;
|
|
@@ -12052,17 +12059,17 @@ var LeaferUI = (function (exports) {
|
|
|
12052
12059
|
State.updateStyle = updateStyle;
|
|
12053
12060
|
State.updateEventStyle = updateEventStyle;
|
|
12054
12061
|
const ui$3 = exports.UI.prototype;
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12062
|
+
exports.UI.addAttr('selected', false, stateType, 'selectedStyle');
|
|
12063
|
+
exports.UI.addAttr('disabled', false, stateType, 'disabledStyle');
|
|
12064
|
+
exports.UI.addAttr('states', {}, stateStyleType);
|
|
12065
|
+
exports.UI.addAttr('state', '', stateType);
|
|
12066
|
+
exports.UI.addAttr('normalStyle', undefined, dataType);
|
|
12067
|
+
exports.UI.addAttr('hoverStyle', undefined, stateStyleType);
|
|
12068
|
+
exports.UI.addAttr('pressStyle', undefined, stateStyleType);
|
|
12069
|
+
exports.UI.addAttr('focusStyle', undefined, stateStyleType);
|
|
12070
|
+
exports.UI.addAttr('selectedStyle', undefined, stateStyleType);
|
|
12071
|
+
exports.UI.addAttr('disabledStyle', undefined, stateStyleType);
|
|
12072
|
+
exports.UI.addAttr('button', false, dataType);
|
|
12066
12073
|
ui$3.focus = function (value = true) {
|
|
12067
12074
|
this.waitLeafer(() => {
|
|
12068
12075
|
let { focusData } = this.app.interaction;
|
|
@@ -13027,7 +13034,6 @@ var LeaferUI = (function (exports) {
|
|
|
13027
13034
|
innerShadow: shadow
|
|
13028
13035
|
};
|
|
13029
13036
|
const TransitionModule = {
|
|
13030
|
-
list: TransitionList,
|
|
13031
13037
|
value,
|
|
13032
13038
|
number,
|
|
13033
13039
|
color
|
|
@@ -13072,13 +13078,13 @@ var LeaferUI = (function (exports) {
|
|
|
13072
13078
|
|
|
13073
13079
|
Plugin.add('animate', 'color');
|
|
13074
13080
|
State.canAnimate = true;
|
|
13075
|
-
Object.assign(Transition
|
|
13076
|
-
|
|
13081
|
+
Object.assign(Transition.list, TransitionList);
|
|
13082
|
+
Object.assign(Transition, TransitionModule);
|
|
13077
13083
|
const ui$2 = exports.UI.prototype;
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13084
|
+
exports.UI.addAttr('animation', undefined, animationType);
|
|
13085
|
+
exports.UI.addAttr('animationOut', undefined, dataType);
|
|
13086
|
+
exports.UI.addAttr('transition', true, dataType);
|
|
13087
|
+
exports.UI.addAttr('transitionOut', undefined, dataType);
|
|
13082
13088
|
ui$2.animate = function (keyframe, options, kill, isTemp) {
|
|
13083
13089
|
if (keyframe === undefined)
|
|
13084
13090
|
return this.__animate;
|
|
@@ -13252,7 +13258,7 @@ var LeaferUI = (function (exports) {
|
|
|
13252
13258
|
toX = data[i + 1];
|
|
13253
13259
|
toY = data[i + 2];
|
|
13254
13260
|
distance = segments[index];
|
|
13255
|
-
if (total + distance
|
|
13261
|
+
if (total + distance >= motionDistance || !distanceData.total) {
|
|
13256
13262
|
if (!i)
|
|
13257
13263
|
x = toX, y = toY;
|
|
13258
13264
|
tempFrom.x = x;
|
|
@@ -13271,7 +13277,7 @@ var LeaferUI = (function (exports) {
|
|
|
13271
13277
|
toX = data[i + 5];
|
|
13272
13278
|
toY = data[i + 6];
|
|
13273
13279
|
distance = segments[index];
|
|
13274
|
-
if (total + distance
|
|
13280
|
+
if (total + distance >= motionDistance) {
|
|
13275
13281
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13276
13282
|
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13277
13283
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
@@ -13307,7 +13313,7 @@ var LeaferUI = (function (exports) {
|
|
|
13307
13313
|
toX = data[i + 1];
|
|
13308
13314
|
toY = data[i + 2];
|
|
13309
13315
|
distance = segments[index];
|
|
13310
|
-
if (total + distance
|
|
13316
|
+
if (total + distance >= motionDistance || !distanceData.total) {
|
|
13311
13317
|
if (!i)
|
|
13312
13318
|
x = toX, y = toY;
|
|
13313
13319
|
tempFrom.x = x;
|
|
@@ -13328,7 +13334,7 @@ var LeaferUI = (function (exports) {
|
|
|
13328
13334
|
toX = data[i + 5];
|
|
13329
13335
|
toY = data[i + 6];
|
|
13330
13336
|
distance = segments[index];
|
|
13331
|
-
if (total + distance
|
|
13337
|
+
if (total + distance >= motionDistance) {
|
|
13332
13338
|
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13333
13339
|
HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13334
13340
|
return path;
|
|
@@ -13379,10 +13385,10 @@ var LeaferUI = (function (exports) {
|
|
|
13379
13385
|
const ui$1 = exports.UI.prototype;
|
|
13380
13386
|
const { updateMatrix, updateAllMatrix } = LeafHelper;
|
|
13381
13387
|
const { updateBounds } = BranchHelper;
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13388
|
+
exports.UI.addAttr('motionPath', undefined, motionPathType);
|
|
13389
|
+
exports.UI.addAttr('motionPrecision', 1, motionPathType);
|
|
13390
|
+
exports.UI.addAttr('motion', undefined, motionPathType);
|
|
13391
|
+
exports.UI.addAttr('motionRotation', true, motionPathType);
|
|
13386
13392
|
ui$1.getMotionPathData = function () {
|
|
13387
13393
|
return getMotionPathData(getMotionPath(this));
|
|
13388
13394
|
};
|