leafer-ui 1.11.2 → 1.12.1
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 +5 -14
- package/dist/web.cjs +25 -16
- package/dist/web.esm.js +25 -16
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +103 -30
- 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 +103 -30
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -4056,16 +4056,27 @@ const ImageManager = {
|
|
|
4056
4056
|
recycle(image) {
|
|
4057
4057
|
image.use--;
|
|
4058
4058
|
setTimeout(() => {
|
|
4059
|
-
if (!image.use)
|
|
4059
|
+
if (!image.use) {
|
|
4060
|
+
if (Platform.image.isLarge(image)) {
|
|
4061
|
+
if (image.url) Resource.remove(image.url);
|
|
4062
|
+
} else {
|
|
4063
|
+
image.clearLevels();
|
|
4064
|
+
I$1.recycledList.push(image);
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4060
4067
|
});
|
|
4061
4068
|
},
|
|
4062
|
-
|
|
4069
|
+
recyclePaint(paint) {
|
|
4070
|
+
I$1.recycle(paint.image);
|
|
4071
|
+
},
|
|
4072
|
+
clearRecycled(force) {
|
|
4063
4073
|
const list = I$1.recycledList;
|
|
4064
|
-
if (list.length > I$1.maxRecycled) {
|
|
4065
|
-
list.forEach(image => !image.use && image.url && Resource.remove(image.url));
|
|
4074
|
+
if (list.length > I$1.maxRecycled || force) {
|
|
4075
|
+
list.forEach(image => (!image.use || force) && image.url && Resource.remove(image.url));
|
|
4066
4076
|
list.length = 0;
|
|
4067
4077
|
}
|
|
4068
4078
|
},
|
|
4079
|
+
clearLevels() {},
|
|
4069
4080
|
hasAlphaPixel(config) {
|
|
4070
4081
|
return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
|
|
4071
4082
|
},
|
|
@@ -4080,7 +4091,7 @@ const ImageManager = {
|
|
|
4080
4091
|
return false;
|
|
4081
4092
|
},
|
|
4082
4093
|
destroy() {
|
|
4083
|
-
|
|
4094
|
+
this.clearRecycled(true);
|
|
4084
4095
|
}
|
|
4085
4096
|
};
|
|
4086
4097
|
|
|
@@ -4183,11 +4194,15 @@ class LeaferImage {
|
|
|
4183
4194
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4184
4195
|
return pattern;
|
|
4185
4196
|
}
|
|
4197
|
+
clearLevels(_checkUse) {}
|
|
4186
4198
|
destroy() {
|
|
4199
|
+
this.clearLevels();
|
|
4200
|
+
const {view: view} = this;
|
|
4201
|
+
if (view && view.close) view.close();
|
|
4187
4202
|
this.config = {
|
|
4188
4203
|
url: ""
|
|
4189
4204
|
};
|
|
4190
|
-
this.cache = null;
|
|
4205
|
+
this.cache = this.view = null;
|
|
4191
4206
|
this.waitComplete.length = 0;
|
|
4192
4207
|
}
|
|
4193
4208
|
}
|
|
@@ -4936,10 +4951,53 @@ const BranchHelper = {
|
|
|
4936
4951
|
if (exclude && exclude === branch) continue;
|
|
4937
4952
|
updateBounds$3(branch);
|
|
4938
4953
|
}
|
|
4954
|
+
},
|
|
4955
|
+
move(branch, x, y) {
|
|
4956
|
+
let w;
|
|
4957
|
+
const {children: children} = branch;
|
|
4958
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
4959
|
+
branch = children[i];
|
|
4960
|
+
w = branch.__world;
|
|
4961
|
+
w.e += x;
|
|
4962
|
+
w.f += y;
|
|
4963
|
+
w.x += x;
|
|
4964
|
+
w.y += y;
|
|
4965
|
+
if (branch.isBranch) move$3(branch, x, y);
|
|
4966
|
+
}
|
|
4967
|
+
},
|
|
4968
|
+
scale(branch, x, y, scaleX, scaleY, a, b) {
|
|
4969
|
+
let w;
|
|
4970
|
+
const {children: children} = branch;
|
|
4971
|
+
const changeScaleX = scaleX - 1;
|
|
4972
|
+
const changeScaleY = scaleY - 1;
|
|
4973
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
4974
|
+
branch = children[i];
|
|
4975
|
+
w = branch.__world;
|
|
4976
|
+
w.a *= scaleX;
|
|
4977
|
+
w.d *= scaleY;
|
|
4978
|
+
if (w.b || w.c) {
|
|
4979
|
+
w.b *= scaleX;
|
|
4980
|
+
w.c *= scaleY;
|
|
4981
|
+
}
|
|
4982
|
+
if (w.e === w.x && w.f === w.y) {
|
|
4983
|
+
w.x = w.e += (w.e - a) * changeScaleX + x;
|
|
4984
|
+
w.y = w.f += (w.f - b) * changeScaleY + y;
|
|
4985
|
+
} else {
|
|
4986
|
+
w.e += (w.e - a) * changeScaleX + x;
|
|
4987
|
+
w.f += (w.f - b) * changeScaleY + y;
|
|
4988
|
+
w.x += (w.x - a) * changeScaleX + x;
|
|
4989
|
+
w.y += (w.y - b) * changeScaleY + y;
|
|
4990
|
+
}
|
|
4991
|
+
w.width *= scaleX;
|
|
4992
|
+
w.height *= scaleY;
|
|
4993
|
+
w.scaleX *= scaleX;
|
|
4994
|
+
w.scaleY *= scaleY;
|
|
4995
|
+
if (branch.isBranch) scale$1(branch, x, y, scaleX, scaleY, a, b);
|
|
4996
|
+
}
|
|
4939
4997
|
}
|
|
4940
4998
|
};
|
|
4941
4999
|
|
|
4942
|
-
const {pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack} = BranchHelper;
|
|
5000
|
+
const {pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack, move: move$3, scale: scale$1} = BranchHelper;
|
|
4943
5001
|
|
|
4944
5002
|
const WaitHelper = {
|
|
4945
5003
|
run(wait) {
|
|
@@ -5966,6 +6024,7 @@ const LeafBounds = {
|
|
|
5966
6024
|
const LeafRender = {
|
|
5967
6025
|
__render(canvas, options) {
|
|
5968
6026
|
if (options.shape) return this.__renderShape(canvas, options);
|
|
6027
|
+
if (options.cellList && !options.cellList.has(this)) return;
|
|
5969
6028
|
if (this.__worldOpacity) {
|
|
5970
6029
|
const data = this.__;
|
|
5971
6030
|
if (data.bright && !options.topRendering) return options.topList.add(this);
|
|
@@ -6502,10 +6561,10 @@ let Leaf = class Leaf {
|
|
|
6502
6561
|
hit(_world, _hitRadius) {
|
|
6503
6562
|
return true;
|
|
6504
6563
|
}
|
|
6505
|
-
__hitWorld(_point) {
|
|
6564
|
+
__hitWorld(_point, _forceHitFill) {
|
|
6506
6565
|
return true;
|
|
6507
6566
|
}
|
|
6508
|
-
__hit(_local) {
|
|
6567
|
+
__hit(_local, _forceHitFill) {
|
|
6509
6568
|
return true;
|
|
6510
6569
|
}
|
|
6511
6570
|
__hitFill(_inner) {
|
|
@@ -6864,7 +6923,7 @@ class LeafLevelList {
|
|
|
6864
6923
|
}
|
|
6865
6924
|
}
|
|
6866
6925
|
|
|
6867
|
-
const version = "1.
|
|
6926
|
+
const version = "1.12.1";
|
|
6868
6927
|
|
|
6869
6928
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6870
6929
|
|
|
@@ -7187,7 +7246,7 @@ class Watcher {
|
|
|
7187
7246
|
return this.hasAdd || this.hasRemove || this.hasVisible;
|
|
7188
7247
|
}
|
|
7189
7248
|
get updatedList() {
|
|
7190
|
-
if (this.hasRemove) {
|
|
7249
|
+
if (this.hasRemove && this.config.usePartLayout) {
|
|
7191
7250
|
const updatedList = new LeafList;
|
|
7192
7251
|
this.__updatedList.list.forEach(item => {
|
|
7193
7252
|
if (item.leafer) updatedList.add(item);
|
|
@@ -7222,16 +7281,18 @@ class Watcher {
|
|
|
7222
7281
|
if (this.running) this.target.emit(RenderEvent.REQUEST);
|
|
7223
7282
|
}
|
|
7224
7283
|
__onAttrChange(event) {
|
|
7225
|
-
this.__updatedList.add(event.target);
|
|
7284
|
+
if (this.config.usePartLayout) this.__updatedList.add(event.target);
|
|
7226
7285
|
this.update();
|
|
7227
7286
|
}
|
|
7228
7287
|
__onChildEvent(event) {
|
|
7229
|
-
if (
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7288
|
+
if (this.config.usePartLayout) {
|
|
7289
|
+
if (event.type === ChildEvent.ADD) {
|
|
7290
|
+
this.hasAdd = true;
|
|
7291
|
+
this.__pushChild(event.child);
|
|
7292
|
+
} else {
|
|
7293
|
+
this.hasRemove = true;
|
|
7294
|
+
this.__updatedList.add(event.parent);
|
|
7295
|
+
}
|
|
7235
7296
|
}
|
|
7236
7297
|
this.update();
|
|
7237
7298
|
}
|
|
@@ -7348,7 +7409,9 @@ const debug$4 = Debug.get("Layouter");
|
|
|
7348
7409
|
class Layouter {
|
|
7349
7410
|
constructor(target, userConfig) {
|
|
7350
7411
|
this.totalTimes = 0;
|
|
7351
|
-
this.config = {
|
|
7412
|
+
this.config = {
|
|
7413
|
+
usePartLayout: true
|
|
7414
|
+
};
|
|
7352
7415
|
this.__levelList = new LeafLevelList;
|
|
7353
7416
|
this.target = target;
|
|
7354
7417
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -7393,7 +7456,7 @@ class Layouter {
|
|
|
7393
7456
|
this.totalTimes++;
|
|
7394
7457
|
this.layouting = true;
|
|
7395
7458
|
this.target.emit(WatchEvent.REQUEST);
|
|
7396
|
-
if (this.totalTimes > 1) {
|
|
7459
|
+
if (this.totalTimes > 1 && this.config.usePartLayout) {
|
|
7397
7460
|
this.partLayout();
|
|
7398
7461
|
} else {
|
|
7399
7462
|
this.fullLayout();
|
|
@@ -7510,7 +7573,7 @@ class Renderer {
|
|
|
7510
7573
|
}
|
|
7511
7574
|
update(change = true) {
|
|
7512
7575
|
if (!this.changed) this.changed = change;
|
|
7513
|
-
this.__requestRender();
|
|
7576
|
+
if (!this.requestTime) this.__requestRender();
|
|
7514
7577
|
}
|
|
7515
7578
|
requestLayout() {
|
|
7516
7579
|
this.target.emit(LayoutEvent.REQUEST);
|
|
@@ -7617,7 +7680,7 @@ class Renderer {
|
|
|
7617
7680
|
Run.end(t);
|
|
7618
7681
|
}
|
|
7619
7682
|
__render(bounds, realBounds) {
|
|
7620
|
-
const {canvas: canvas} = this, includes = bounds.includes(
|
|
7683
|
+
const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
|
|
7621
7684
|
includes: includes
|
|
7622
7685
|
} : {
|
|
7623
7686
|
bounds: bounds,
|
|
@@ -7625,12 +7688,16 @@ class Renderer {
|
|
|
7625
7688
|
};
|
|
7626
7689
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
7627
7690
|
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
|
|
7628
|
-
|
|
7691
|
+
if (this.config.useCellRender) options.cellList = this.getCellList();
|
|
7692
|
+
Platform.render(target, canvas, options);
|
|
7629
7693
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
7630
7694
|
this.renderOptions = options;
|
|
7631
7695
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
7632
7696
|
canvas.updateRender(realBounds);
|
|
7633
7697
|
}
|
|
7698
|
+
getCellList() {
|
|
7699
|
+
return undefined;
|
|
7700
|
+
}
|
|
7634
7701
|
addBlock(block) {
|
|
7635
7702
|
if (!this.updateBlocks) this.updateBlocks = [];
|
|
7636
7703
|
this.updateBlocks.push(block);
|
|
@@ -7845,7 +7912,7 @@ class Picker {
|
|
|
7845
7912
|
hit = child.__.hitRadius ? true : hitRadiusPoint$1(child.__world, point);
|
|
7846
7913
|
if (child.isBranch) {
|
|
7847
7914
|
if (hit || child.__ignoreHitWorld) {
|
|
7848
|
-
if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
|
|
7915
|
+
if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point, true)) continue;
|
|
7849
7916
|
if (child.topChildren) this.eachFind(child.topChildren, false);
|
|
7850
7917
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
7851
7918
|
if (child.isBranchLeaf) this.hitChild(child, point);
|
|
@@ -8287,6 +8354,11 @@ class TextData extends UIData {
|
|
|
8287
8354
|
}
|
|
8288
8355
|
this._boxStyle = value;
|
|
8289
8356
|
}
|
|
8357
|
+
__getInputData(names, options) {
|
|
8358
|
+
const data = super.__getInputData(names, options);
|
|
8359
|
+
if (data.textEditing) delete data.textEditing;
|
|
8360
|
+
return data;
|
|
8361
|
+
}
|
|
8290
8362
|
}
|
|
8291
8363
|
|
|
8292
8364
|
class ImageData extends RectData {
|
|
@@ -11159,7 +11231,7 @@ leaf.hit = function(worldPoint, hitRadius = 0) {
|
|
|
11159
11231
|
}) : this.__hitWorld(worldRadiusPoint);
|
|
11160
11232
|
};
|
|
11161
11233
|
|
|
11162
|
-
leaf.__hitWorld = function(point) {
|
|
11234
|
+
leaf.__hitWorld = function(point, forceHitFill) {
|
|
11163
11235
|
const data = this.__;
|
|
11164
11236
|
if (!data.hitSelf) return false;
|
|
11165
11237
|
const world = this.__world, layout = this.__layout;
|
|
@@ -11177,7 +11249,7 @@ leaf.__hitWorld = function(point) {
|
|
|
11177
11249
|
this.__updateHitCanvas();
|
|
11178
11250
|
if (!layout.boundsChanged) layout.hitCanvasChanged = false;
|
|
11179
11251
|
}
|
|
11180
|
-
return this.__hit(inner);
|
|
11252
|
+
return this.__hit(inner, forceHitFill);
|
|
11181
11253
|
};
|
|
11182
11254
|
|
|
11183
11255
|
leaf.__hitFill = function(inner) {
|
|
@@ -11244,12 +11316,12 @@ ui$1.__updateHitCanvas = function() {
|
|
|
11244
11316
|
h.setStrokeOptions(data);
|
|
11245
11317
|
};
|
|
11246
11318
|
|
|
11247
|
-
ui$1.__hit = function(inner) {
|
|
11319
|
+
ui$1.__hit = function(inner, forceHitFill) {
|
|
11248
11320
|
if (this.__box && this.__box.__hit(inner)) return true;
|
|
11249
11321
|
const data = this.__;
|
|
11250
11322
|
if (data.__isHitPixel && this.__hitPixel(inner)) return true;
|
|
11251
11323
|
const {hitFill: hitFill} = data;
|
|
11252
|
-
const needHitFillPath = (data.fill || data.__isCanvas) && (hitFill === "path" || hitFill === "pixel" && !(data.__isAlphaPixelFill || data.__isCanvas)) || hitFill === "all";
|
|
11324
|
+
const needHitFillPath = (data.fill || data.__isCanvas) && (hitFill === "path" || hitFill === "pixel" && !(data.__isAlphaPixelFill || data.__isCanvas)) || hitFill === "all" || forceHitFill;
|
|
11253
11325
|
if (needHitFillPath && this.__hitFill(inner)) return true;
|
|
11254
11326
|
const {hitStroke: hitStroke, __maxStrokeWidth: strokeWidth} = data;
|
|
11255
11327
|
const needHitStrokePath = data.stroke && (hitStroke === "path" || hitStroke === "pixel" && !data.__isAlphaPixelStroke) || hitStroke === "all";
|
|
@@ -11954,6 +12026,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
11954
12026
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
11955
12027
|
switch (paint.type) {
|
|
11956
12028
|
case "image":
|
|
12029
|
+
if (!paint.url) return undefined;
|
|
11957
12030
|
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
11958
12031
|
break;
|
|
11959
12032
|
|
|
@@ -12358,7 +12431,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
12358
12431
|
if (data.repeat) {
|
|
12359
12432
|
drawImage = false;
|
|
12360
12433
|
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
12361
|
-
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
12434
|
+
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
12362
12435
|
}
|
|
12363
12436
|
}
|
|
12364
12437
|
if (drawImage) {
|
|
@@ -12417,7 +12490,7 @@ function recycleImage(attrName, data) {
|
|
|
12417
12490
|
if (url) {
|
|
12418
12491
|
if (!recycleMap) recycleMap = {};
|
|
12419
12492
|
recycleMap[url] = true;
|
|
12420
|
-
ImageManager.
|
|
12493
|
+
ImageManager.recyclePaint(paint);
|
|
12421
12494
|
if (image.loading) {
|
|
12422
12495
|
if (!input) {
|
|
12423
12496
|
input = data.__input && data.__input[attrName] || [];
|