leafer-game 2.2.11 → 2.3.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/dist/web.js +68 -25
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +72 -26
- 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.js
CHANGED
|
@@ -433,7 +433,7 @@ var LeaferUI = function(exports) {
|
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
const {sin: sin$6, cos: cos$6, acos: acos, sqrt: sqrt$5} = Math;
|
|
436
|
-
const {float: float$
|
|
436
|
+
const {float: float$6} = MathHelper;
|
|
437
437
|
const tempPoint$7 = {};
|
|
438
438
|
function getWorld() {
|
|
439
439
|
return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
|
|
@@ -681,12 +681,12 @@ var LeaferUI = function(exports) {
|
|
|
681
681
|
const cosR = c / scaleY;
|
|
682
682
|
rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
|
|
683
683
|
}
|
|
684
|
-
const cosR = float$
|
|
684
|
+
const cosR = float$6(cos$6(rotation));
|
|
685
685
|
const sinR = sin$6(rotation);
|
|
686
|
-
scaleX = float$
|
|
687
|
-
skewX = cosR ? float$
|
|
688
|
-
skewY = cosR ? float$
|
|
689
|
-
rotation = float$
|
|
686
|
+
scaleX = float$6(scaleX), scaleY = float$6(scaleY);
|
|
687
|
+
skewX = cosR ? float$6((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
|
|
688
|
+
skewY = cosR ? float$6((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
|
|
689
|
+
rotation = float$6(rotation / OneRadian);
|
|
690
690
|
} else {
|
|
691
691
|
scaleX = a;
|
|
692
692
|
scaleY = d;
|
|
@@ -728,7 +728,7 @@ var LeaferUI = function(exports) {
|
|
|
728
728
|
}
|
|
729
729
|
};
|
|
730
730
|
const M$7 = MatrixHelper;
|
|
731
|
-
const {float: float$
|
|
731
|
+
const {float: float$5} = MathHelper;
|
|
732
732
|
const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
|
|
733
733
|
const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$2, round: round$5} = Math;
|
|
734
734
|
const PointHelper = {
|
|
@@ -871,7 +871,7 @@ var LeaferUI = function(exports) {
|
|
|
871
871
|
return points;
|
|
872
872
|
},
|
|
873
873
|
isSame(t, point, quick) {
|
|
874
|
-
return quick ? t.x === point.x && t.y === point.y : float$
|
|
874
|
+
return quick ? t.x === point.x && t.y === point.y : float$5(t.x) === float$5(point.x) && float$5(t.y) === float$5(point.y);
|
|
875
875
|
},
|
|
876
876
|
reset(t) {
|
|
877
877
|
t.x = t.y = 0;
|
|
@@ -1206,7 +1206,7 @@ var LeaferUI = function(exports) {
|
|
|
1206
1206
|
};
|
|
1207
1207
|
const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
|
|
1208
1208
|
const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
1209
|
-
const {float: float$
|
|
1209
|
+
const {float: float$4, fourNumber: fourNumber$1} = MathHelper;
|
|
1210
1210
|
const {floor: floor$2, ceil: ceil$2} = Math;
|
|
1211
1211
|
let right$1, bottom$1, boundsRight, boundsBottom;
|
|
1212
1212
|
const point = {};
|
|
@@ -1375,10 +1375,10 @@ var LeaferUI = function(exports) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
},
|
|
1377
1377
|
float(t, maxLength) {
|
|
1378
|
-
t.x = float$
|
|
1379
|
-
t.y = float$
|
|
1380
|
-
t.width = float$
|
|
1381
|
-
t.height = float$
|
|
1378
|
+
t.x = float$4(t.x, maxLength);
|
|
1379
|
+
t.y = float$4(t.y, maxLength);
|
|
1380
|
+
t.width = float$4(t.width, maxLength);
|
|
1381
|
+
t.height = float$4(t.height, maxLength);
|
|
1382
1382
|
},
|
|
1383
1383
|
add(t, bounds, isPoint) {
|
|
1384
1384
|
right$1 = t.x + t.width;
|
|
@@ -3516,6 +3516,7 @@ var LeaferUI = function(exports) {
|
|
|
3516
3516
|
const {M: M$1, L: L$2, Z: Z$1} = PathCommandMap;
|
|
3517
3517
|
const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
|
|
3518
3518
|
const {arcTo: arcTo} = PathCommandDataHelper;
|
|
3519
|
+
const {float: float$3} = MathHelper;
|
|
3519
3520
|
const PathCorner = {
|
|
3520
3521
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3521
3522
|
let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
|
|
@@ -3556,7 +3557,8 @@ var LeaferUI = function(exports) {
|
|
|
3556
3557
|
break;
|
|
3557
3558
|
|
|
3558
3559
|
case Z$1:
|
|
3559
|
-
|
|
3560
|
+
if (float$3(x) === float$3(startX) && float$3(y) === float$3(startY)) x = lastX,
|
|
3561
|
+
y = lastY; else arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3560
3562
|
break;
|
|
3561
3563
|
|
|
3562
3564
|
default:
|
|
@@ -4718,10 +4720,11 @@ var LeaferUI = function(exports) {
|
|
|
4718
4720
|
hasOffset(t) {
|
|
4719
4721
|
return t.offsetX || t.offsetY;
|
|
4720
4722
|
},
|
|
4721
|
-
hasParent(p, parent) {
|
|
4723
|
+
hasParent(p, parent, minLevel) {
|
|
4722
4724
|
if (!parent) return false;
|
|
4723
4725
|
while (p) {
|
|
4724
4726
|
if (parent === p) return true;
|
|
4727
|
+
if (minLevel && p.__level === minLevel) return;
|
|
4725
4728
|
p = p.parent;
|
|
4726
4729
|
}
|
|
4727
4730
|
},
|
|
@@ -4738,6 +4741,9 @@ var LeaferUI = function(exports) {
|
|
|
4738
4741
|
onAnimate && onAnimate();
|
|
4739
4742
|
}
|
|
4740
4743
|
};
|
|
4744
|
+
function isTrackChanges(leafer) {
|
|
4745
|
+
return leafer && leafer.config.trackChanges;
|
|
4746
|
+
}
|
|
4741
4747
|
const L$1 = LeafHelper;
|
|
4742
4748
|
const {updateAllMatrix: updateAllMatrix$4, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange} = L$1;
|
|
4743
4749
|
function getTempLocal(t, worldPoint) {
|
|
@@ -4785,6 +4791,16 @@ var LeaferUI = function(exports) {
|
|
|
4785
4791
|
sort(a, b) {
|
|
4786
4792
|
return a.__.zIndex === b.__.zIndex ? a.__tempNumber - b.__tempNumber : a.__.zIndex - b.__.zIndex;
|
|
4787
4793
|
},
|
|
4794
|
+
zIndex(branch, child, index) {
|
|
4795
|
+
const {children: children} = branch, before = children[index - 1], after = children[index];
|
|
4796
|
+
if (before && after) {
|
|
4797
|
+
if (child.zIndex < before.zIndex || child.zIndex > after.zIndex) child.zIndex = (before.zIndex + after.zIndex) / 2;
|
|
4798
|
+
} else if (before) {
|
|
4799
|
+
if (child.zIndex < before.zIndex) child.zIndex = before.zIndex + 1;
|
|
4800
|
+
} else if (after) {
|
|
4801
|
+
if (child.zIndex > after.zIndex) child.zIndex = after.zIndex - 1;
|
|
4802
|
+
}
|
|
4803
|
+
},
|
|
4788
4804
|
pushAllChildBranch(branch, leafList) {
|
|
4789
4805
|
branch.__tempNumber = 1;
|
|
4790
4806
|
if (branch.__.__childBranchNumber) {
|
|
@@ -5669,7 +5685,7 @@ var LeaferUI = function(exports) {
|
|
|
5669
5685
|
},
|
|
5670
5686
|
emitPropertyEvent(type, name, oldValue, newValue) {
|
|
5671
5687
|
const {leafer: leafer} = this;
|
|
5672
|
-
if (leafer
|
|
5688
|
+
if (isTrackChanges(leafer) || leafer.zoomLayer === this) {
|
|
5673
5689
|
const event = new PropertyEvent(type, this, name, oldValue, newValue);
|
|
5674
5690
|
this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
|
|
5675
5691
|
leafer.emitEvent(event);
|
|
@@ -6105,7 +6121,6 @@ var LeaferUI = function(exports) {
|
|
|
6105
6121
|
}
|
|
6106
6122
|
}
|
|
6107
6123
|
__bindFrame(frame) {
|
|
6108
|
-
if (this.isFrame && frame !== null) frame = this;
|
|
6109
6124
|
this.frame = frame;
|
|
6110
6125
|
if (this.isBranch) {
|
|
6111
6126
|
const {children: children} = this;
|
|
@@ -6138,6 +6153,7 @@ var LeaferUI = function(exports) {
|
|
|
6138
6153
|
this.__layout.update();
|
|
6139
6154
|
}
|
|
6140
6155
|
forceUpdate(typeOrAttrName) {
|
|
6156
|
+
if (this.__hasComplex) LeafHelper.updateComplex(this);
|
|
6141
6157
|
let quick;
|
|
6142
6158
|
if (!typeOrAttrName || typeOrAttrName === "bounds") doBoundsType(this), quick = true; else if (typeOrAttrName === "surface") doSurfaceType(this),
|
|
6143
6159
|
quick = true; else if (typeOrAttrName === "stroke") doStrokeType(this), quick = true;
|
|
@@ -6410,14 +6426,17 @@ var LeaferUI = function(exports) {
|
|
|
6410
6426
|
}
|
|
6411
6427
|
if (child.parent) child.parent.remove(child);
|
|
6412
6428
|
child.parent = this;
|
|
6413
|
-
noIndex
|
|
6429
|
+
if (noIndex) this.children.push(child); else {
|
|
6430
|
+
BranchHelper.zIndex(this, child, index);
|
|
6431
|
+
this.children.splice(index, 0, child);
|
|
6432
|
+
}
|
|
6414
6433
|
if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
6415
6434
|
const childLayout = child.__layout;
|
|
6416
6435
|
childLayout.boxChanged || childLayout.boxChange();
|
|
6417
6436
|
childLayout.matrixChanged || childLayout.matrixChange();
|
|
6418
6437
|
if (child.__parentChange) child.__parentChange.forEach(item => item(this, child));
|
|
6419
6438
|
if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
|
|
6420
|
-
if (this.
|
|
6439
|
+
if (this.frame) child.__bindFrame(this.frame);
|
|
6421
6440
|
if (this.leafer) {
|
|
6422
6441
|
child.__bindLeafer(this.leafer);
|
|
6423
6442
|
if (this.leafer.created) this.__emitChildEvent(ChildEvent.ADD, child);
|
|
@@ -6477,11 +6496,11 @@ var LeaferUI = function(exports) {
|
|
|
6477
6496
|
if (this.leafer.hitCanvasManager) this.leafer.hitCanvasManager.clear();
|
|
6478
6497
|
}
|
|
6479
6498
|
}
|
|
6480
|
-
if (
|
|
6499
|
+
if (child.frame && !child.isFrame) child.__bindFrame(null);
|
|
6481
6500
|
}
|
|
6482
6501
|
__emitChildEvent(type, child) {
|
|
6483
6502
|
const {leafer: leafer} = this;
|
|
6484
|
-
if (leafer
|
|
6503
|
+
if (isTrackChanges(leafer) || leafer.zoomLayer === this) {
|
|
6485
6504
|
const event = new ChildEvent(type, child, this);
|
|
6486
6505
|
if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
|
|
6487
6506
|
leafer.emitEvent(event);
|
|
@@ -6634,7 +6653,12 @@ var LeaferUI = function(exports) {
|
|
|
6634
6653
|
this.levelMap = null;
|
|
6635
6654
|
}
|
|
6636
6655
|
}
|
|
6637
|
-
const version = "2.
|
|
6656
|
+
const version = "2.3.1";
|
|
6657
|
+
if (typeof globalThis !== "undefined") {
|
|
6658
|
+
const globalLeafer = globalThis.Leafer || (globalThis.Leafer = {});
|
|
6659
|
+
globalLeafer.version = version;
|
|
6660
|
+
globalLeafer.Plugin = Plugin;
|
|
6661
|
+
}
|
|
6638
6662
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6639
6663
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6640
6664
|
set zIndex(zIndex) {
|
|
@@ -7742,6 +7766,16 @@ var LeaferUI = function(exports) {
|
|
|
7742
7766
|
});
|
|
7743
7767
|
};
|
|
7744
7768
|
}
|
|
7769
|
+
function frameType() {
|
|
7770
|
+
return (target, key) => {
|
|
7771
|
+
defineKey(target, key, {
|
|
7772
|
+
set(_value) {},
|
|
7773
|
+
get() {
|
|
7774
|
+
return this;
|
|
7775
|
+
}
|
|
7776
|
+
});
|
|
7777
|
+
};
|
|
7778
|
+
}
|
|
7745
7779
|
function createAttr(defaultValue) {
|
|
7746
7780
|
return (target, key) => {
|
|
7747
7781
|
defineKey(target, key, createDescriptor(key, defaultValue));
|
|
@@ -8994,6 +9028,7 @@ var LeaferUI = function(exports) {
|
|
|
8994
9028
|
return true;
|
|
8995
9029
|
}
|
|
8996
9030
|
};
|
|
9031
|
+
__decorate([ frameType() ], exports.Frame.prototype, "frame", void 0);
|
|
8997
9032
|
__decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
|
|
8998
9033
|
__decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
|
|
8999
9034
|
__decorate([ affectRenderBoundsType("hide") ], exports.Frame.prototype, "overflow", void 0);
|
|
@@ -14111,14 +14146,20 @@ var LeaferUI = function(exports) {
|
|
|
14111
14146
|
const value = from + (to - from) * t;
|
|
14112
14147
|
return roundValue ? round(value) : value;
|
|
14113
14148
|
}
|
|
14114
|
-
function color(
|
|
14115
|
-
from = ColorConvert.object(
|
|
14149
|
+
function color(fromColor, toColor, t) {
|
|
14150
|
+
let from = ColorConvert.object(fromColor), to = ColorConvert.object(toColor);
|
|
14151
|
+
if (!fromColor) from = Object.assign(Object.assign({}, to), {
|
|
14152
|
+
a: 0
|
|
14153
|
+
});
|
|
14154
|
+
if (!toColor) to = Object.assign(Object.assign({}, from), {
|
|
14155
|
+
a: 0
|
|
14156
|
+
});
|
|
14116
14157
|
const rgb = number(from.r, to.r, t, 1) + "," + number(from.g, to.g, t, 1) + "," + number(from.b, to.b, t, 1);
|
|
14117
14158
|
const a = number(from.a, to.a, t);
|
|
14118
14159
|
return a === 1 ? "rgb(" + rgb + ")" : "rgba(" + rgb + "," + a + ")";
|
|
14119
14160
|
}
|
|
14120
14161
|
function paint(from, to, t) {
|
|
14121
|
-
return isString(from) && isString(to) ? color(from, to, t) : to;
|
|
14162
|
+
return (isString(from) || !from) && (isString(to) || !to) ? color(from, to, t) : to;
|
|
14122
14163
|
}
|
|
14123
14164
|
function shadow(from, to, t) {
|
|
14124
14165
|
if (isArray(from) || isArray(to)) return to;
|
|
@@ -14882,6 +14923,7 @@ var LeaferUI = function(exports) {
|
|
|
14882
14923
|
exports.emptyData = emptyData;
|
|
14883
14924
|
exports.eraserType = eraserType;
|
|
14884
14925
|
exports.extraPropertyEventMap = extraPropertyEventMap;
|
|
14926
|
+
exports.frameType = frameType;
|
|
14885
14927
|
exports.getBoundsData = getBoundsData;
|
|
14886
14928
|
exports.getDescriptor = getDescriptor;
|
|
14887
14929
|
exports.getMatrixData = getMatrixData;
|
|
@@ -14895,6 +14937,7 @@ var LeaferUI = function(exports) {
|
|
|
14895
14937
|
exports.isNumber = isNumber;
|
|
14896
14938
|
exports.isObject = isObject;
|
|
14897
14939
|
exports.isString = isString;
|
|
14940
|
+
exports.isTrackChanges = isTrackChanges;
|
|
14898
14941
|
exports.isUndefined = isUndefined;
|
|
14899
14942
|
exports.layoutProcessor = layoutProcessor;
|
|
14900
14943
|
exports.leaferTransformAttrMap = leaferTransformAttrMap;
|