@leafer-draw/worker 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/worker.js +58 -22
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +62 -23
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +7 -7
package/dist/worker.js
CHANGED
|
@@ -433,7 +433,7 @@ var LeaferUI = function(exports) {
|
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
|
|
436
|
-
const {float: float$
|
|
436
|
+
const {float: float$3} = MathHelper;
|
|
437
437
|
const tempPoint$4 = {};
|
|
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$3(cos$5(rotation));
|
|
685
685
|
const sinR = sin$5(rotation);
|
|
686
|
-
scaleX = float$
|
|
687
|
-
skewX = cosR ? float$
|
|
688
|
-
skewY = cosR ? float$
|
|
689
|
-
rotation = float$
|
|
686
|
+
scaleX = float$3(scaleX), scaleY = float$3(scaleY);
|
|
687
|
+
skewX = cosR ? float$3((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
|
|
688
|
+
skewY = cosR ? float$3((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
|
|
689
|
+
rotation = float$3(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$6 = MatrixHelper;
|
|
731
|
-
const {float: float$
|
|
731
|
+
const {float: float$2} = MathHelper;
|
|
732
732
|
const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
|
|
733
733
|
const {sin: sin$4, cos: cos$4, abs: abs$5, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2} = 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$2(t.x) === float$2(point.x) && float$2(t.y) === float$2(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, fourNumber: fourNumber} = MathHelper;
|
|
1209
|
+
const {float: float$1, fourNumber: fourNumber} = MathHelper;
|
|
1210
1210
|
const {floor: floor$1, ceil: ceil$1} = 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(t.x, maxLength);
|
|
1379
|
-
t.y = float(t.y, maxLength);
|
|
1380
|
-
t.width = float(t.width, maxLength);
|
|
1381
|
-
t.height = float(t.height, maxLength);
|
|
1378
|
+
t.x = float$1(t.x, maxLength);
|
|
1379
|
+
t.y = float$1(t.y, maxLength);
|
|
1380
|
+
t.width = float$1(t.width, maxLength);
|
|
1381
|
+
t.height = float$1(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, L: L$1, Z: Z} = PathCommandMap;
|
|
3517
3517
|
const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
|
|
3518
3518
|
const {arcTo: arcTo} = PathCommandDataHelper;
|
|
3519
|
+
const {float: float} = MathHelper;
|
|
3519
3520
|
const PathCorner = {
|
|
3520
3521
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3521
3522
|
let command, lastCommand, commandLen, startXIndex, startYIndex, smoothLen;
|
|
@@ -3556,7 +3557,7 @@ var LeaferUI = function(exports) {
|
|
|
3556
3557
|
break;
|
|
3557
3558
|
|
|
3558
3559
|
case Z:
|
|
3559
|
-
arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3560
|
+
if (float(x) === float(startX) && float(y) === float(startY)) x = lastX, y = lastY; else arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY, three);
|
|
3560
3561
|
break;
|
|
3561
3562
|
|
|
3562
3563
|
default:
|
|
@@ -4718,10 +4719,11 @@ var LeaferUI = function(exports) {
|
|
|
4718
4719
|
hasOffset(t) {
|
|
4719
4720
|
return t.offsetX || t.offsetY;
|
|
4720
4721
|
},
|
|
4721
|
-
hasParent(p, parent) {
|
|
4722
|
+
hasParent(p, parent, minLevel) {
|
|
4722
4723
|
if (!parent) return false;
|
|
4723
4724
|
while (p) {
|
|
4724
4725
|
if (parent === p) return true;
|
|
4726
|
+
if (minLevel && p.__level === minLevel) return;
|
|
4725
4727
|
p = p.parent;
|
|
4726
4728
|
}
|
|
4727
4729
|
},
|
|
@@ -4738,6 +4740,9 @@ var LeaferUI = function(exports) {
|
|
|
4738
4740
|
onAnimate && onAnimate();
|
|
4739
4741
|
}
|
|
4740
4742
|
};
|
|
4743
|
+
function isTrackChanges(leafer) {
|
|
4744
|
+
return leafer && leafer.config.trackChanges;
|
|
4745
|
+
}
|
|
4741
4746
|
const L = LeafHelper;
|
|
4742
4747
|
const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$1, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange} = L;
|
|
4743
4748
|
function getTempLocal(t, worldPoint) {
|
|
@@ -4785,6 +4790,16 @@ var LeaferUI = function(exports) {
|
|
|
4785
4790
|
sort(a, b) {
|
|
4786
4791
|
return a.__.zIndex === b.__.zIndex ? a.__tempNumber - b.__tempNumber : a.__.zIndex - b.__.zIndex;
|
|
4787
4792
|
},
|
|
4793
|
+
zIndex(branch, child, index) {
|
|
4794
|
+
const {children: children} = branch, before = children[index - 1], after = children[index];
|
|
4795
|
+
if (before && after) {
|
|
4796
|
+
if (child.zIndex < before.zIndex || child.zIndex > after.zIndex) child.zIndex = (before.zIndex + after.zIndex) / 2;
|
|
4797
|
+
} else if (before) {
|
|
4798
|
+
if (child.zIndex < before.zIndex) child.zIndex = before.zIndex + 1;
|
|
4799
|
+
} else if (after) {
|
|
4800
|
+
if (child.zIndex > after.zIndex) child.zIndex = after.zIndex - 1;
|
|
4801
|
+
}
|
|
4802
|
+
},
|
|
4788
4803
|
pushAllChildBranch(branch, leafList) {
|
|
4789
4804
|
branch.__tempNumber = 1;
|
|
4790
4805
|
if (branch.__.__childBranchNumber) {
|
|
@@ -5669,7 +5684,7 @@ var LeaferUI = function(exports) {
|
|
|
5669
5684
|
},
|
|
5670
5685
|
emitPropertyEvent(type, name, oldValue, newValue) {
|
|
5671
5686
|
const {leafer: leafer} = this;
|
|
5672
|
-
if (leafer
|
|
5687
|
+
if (isTrackChanges(leafer) || leafer.zoomLayer === this) {
|
|
5673
5688
|
const event = new PropertyEvent(type, this, name, oldValue, newValue);
|
|
5674
5689
|
this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
|
|
5675
5690
|
leafer.emitEvent(event);
|
|
@@ -6105,7 +6120,6 @@ var LeaferUI = function(exports) {
|
|
|
6105
6120
|
}
|
|
6106
6121
|
}
|
|
6107
6122
|
__bindFrame(frame) {
|
|
6108
|
-
if (this.isFrame && frame !== null) frame = this;
|
|
6109
6123
|
this.frame = frame;
|
|
6110
6124
|
if (this.isBranch) {
|
|
6111
6125
|
const {children: children} = this;
|
|
@@ -6138,6 +6152,7 @@ var LeaferUI = function(exports) {
|
|
|
6138
6152
|
this.__layout.update();
|
|
6139
6153
|
}
|
|
6140
6154
|
forceUpdate(typeOrAttrName) {
|
|
6155
|
+
if (this.__hasComplex) LeafHelper.updateComplex(this);
|
|
6141
6156
|
let quick;
|
|
6142
6157
|
if (!typeOrAttrName || typeOrAttrName === "bounds") doBoundsType(this), quick = true; else if (typeOrAttrName === "surface") doSurfaceType(this),
|
|
6143
6158
|
quick = true; else if (typeOrAttrName === "stroke") doStrokeType(this), quick = true;
|
|
@@ -6410,14 +6425,17 @@ var LeaferUI = function(exports) {
|
|
|
6410
6425
|
}
|
|
6411
6426
|
if (child.parent) child.parent.remove(child);
|
|
6412
6427
|
child.parent = this;
|
|
6413
|
-
noIndex
|
|
6428
|
+
if (noIndex) this.children.push(child); else {
|
|
6429
|
+
BranchHelper.zIndex(this, child, index);
|
|
6430
|
+
this.children.splice(index, 0, child);
|
|
6431
|
+
}
|
|
6414
6432
|
if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
6415
6433
|
const childLayout = child.__layout;
|
|
6416
6434
|
childLayout.boxChanged || childLayout.boxChange();
|
|
6417
6435
|
childLayout.matrixChanged || childLayout.matrixChange();
|
|
6418
6436
|
if (child.__parentChange) child.__parentChange.forEach(item => item(this, child));
|
|
6419
6437
|
if (child.__bubbleMap) child.__emitLifeEvent(ChildEvent.ADD);
|
|
6420
|
-
if (this.
|
|
6438
|
+
if (this.frame) child.__bindFrame(this.frame);
|
|
6421
6439
|
if (this.leafer) {
|
|
6422
6440
|
child.__bindLeafer(this.leafer);
|
|
6423
6441
|
if (this.leafer.created) this.__emitChildEvent(ChildEvent.ADD, child);
|
|
@@ -6477,11 +6495,11 @@ var LeaferUI = function(exports) {
|
|
|
6477
6495
|
if (this.leafer.hitCanvasManager) this.leafer.hitCanvasManager.clear();
|
|
6478
6496
|
}
|
|
6479
6497
|
}
|
|
6480
|
-
if (
|
|
6498
|
+
if (child.frame && !child.isFrame) child.__bindFrame(null);
|
|
6481
6499
|
}
|
|
6482
6500
|
__emitChildEvent(type, child) {
|
|
6483
6501
|
const {leafer: leafer} = this;
|
|
6484
|
-
if (leafer
|
|
6502
|
+
if (isTrackChanges(leafer) || leafer.zoomLayer === this) {
|
|
6485
6503
|
const event = new ChildEvent(type, child, this);
|
|
6486
6504
|
if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
|
|
6487
6505
|
leafer.emitEvent(event);
|
|
@@ -6634,7 +6652,12 @@ var LeaferUI = function(exports) {
|
|
|
6634
6652
|
this.levelMap = null;
|
|
6635
6653
|
}
|
|
6636
6654
|
}
|
|
6637
|
-
const version = "2.
|
|
6655
|
+
const version = "2.3.1";
|
|
6656
|
+
if (typeof globalThis !== "undefined") {
|
|
6657
|
+
const globalLeafer = globalThis.Leafer || (globalThis.Leafer = {});
|
|
6658
|
+
globalLeafer.version = version;
|
|
6659
|
+
globalLeafer.Plugin = Plugin;
|
|
6660
|
+
}
|
|
6638
6661
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6639
6662
|
get allowBackgroundColor() {
|
|
6640
6663
|
return true;
|
|
@@ -7338,6 +7361,16 @@ var LeaferUI = function(exports) {
|
|
|
7338
7361
|
});
|
|
7339
7362
|
};
|
|
7340
7363
|
}
|
|
7364
|
+
function frameType() {
|
|
7365
|
+
return (target, key) => {
|
|
7366
|
+
defineKey(target, key, {
|
|
7367
|
+
set(_value) {},
|
|
7368
|
+
get() {
|
|
7369
|
+
return this;
|
|
7370
|
+
}
|
|
7371
|
+
});
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7341
7374
|
function createAttr(defaultValue) {
|
|
7342
7375
|
return (target, key) => {
|
|
7343
7376
|
defineKey(target, key, createDescriptor(key, defaultValue));
|
|
@@ -8590,6 +8623,7 @@ var LeaferUI = function(exports) {
|
|
|
8590
8623
|
return true;
|
|
8591
8624
|
}
|
|
8592
8625
|
};
|
|
8626
|
+
__decorate([ frameType() ], exports.Frame.prototype, "frame", void 0);
|
|
8593
8627
|
__decorate([ dataProcessor(FrameData) ], exports.Frame.prototype, "__", void 0);
|
|
8594
8628
|
__decorate([ surfaceType("#FFFFFF") ], exports.Frame.prototype, "fill", void 0);
|
|
8595
8629
|
__decorate([ affectRenderBoundsType("hide") ], exports.Frame.prototype, "overflow", void 0);
|
|
@@ -10709,6 +10743,7 @@ var LeaferUI = function(exports) {
|
|
|
10709
10743
|
exports.emptyData = emptyData;
|
|
10710
10744
|
exports.eraserType = eraserType;
|
|
10711
10745
|
exports.extraPropertyEventMap = extraPropertyEventMap;
|
|
10746
|
+
exports.frameType = frameType;
|
|
10712
10747
|
exports.getBoundsData = getBoundsData;
|
|
10713
10748
|
exports.getDescriptor = getDescriptor;
|
|
10714
10749
|
exports.getMatrixData = getMatrixData;
|
|
@@ -10722,6 +10757,7 @@ var LeaferUI = function(exports) {
|
|
|
10722
10757
|
exports.isNumber = isNumber;
|
|
10723
10758
|
exports.isObject = isObject;
|
|
10724
10759
|
exports.isString = isString;
|
|
10760
|
+
exports.isTrackChanges = isTrackChanges;
|
|
10725
10761
|
exports.isUndefined = isUndefined;
|
|
10726
10762
|
exports.layoutProcessor = layoutProcessor;
|
|
10727
10763
|
exports.leaferTransformAttrMap = leaferTransformAttrMap;
|