@leafer/core 1.0.4 → 1.0.6
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/lib/core.cjs +58 -15
- package/lib/core.esm.js +58 -15
- package/lib/core.esm.min.js +1 -1
- package/lib/core.min.cjs +1 -1
- package/package.json +17 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/core.cjs
CHANGED
|
@@ -554,6 +554,12 @@ const PointHelper = {
|
|
|
554
554
|
to.y = t.y + sin$2(r) * distance;
|
|
555
555
|
return to;
|
|
556
556
|
},
|
|
557
|
+
toNumberPoints(originPoints) {
|
|
558
|
+
let points = originPoints;
|
|
559
|
+
if (typeof originPoints[0] === 'object')
|
|
560
|
+
points = [], originPoints.forEach(p => points.push(p.x, p.y));
|
|
561
|
+
return points;
|
|
562
|
+
},
|
|
557
563
|
reset(t) {
|
|
558
564
|
P$5.reset(t);
|
|
559
565
|
}
|
|
@@ -1544,7 +1550,10 @@ const { assign } = DataHelper;
|
|
|
1544
1550
|
|
|
1545
1551
|
class LeafData {
|
|
1546
1552
|
get __useNaturalRatio() { return true; }
|
|
1547
|
-
get __isLinePath() {
|
|
1553
|
+
get __isLinePath() {
|
|
1554
|
+
const { path } = this;
|
|
1555
|
+
return path && path.length === 6 && path[0] === 1;
|
|
1556
|
+
}
|
|
1548
1557
|
get __blendMode() {
|
|
1549
1558
|
if (this.eraser && this.eraser !== 'path')
|
|
1550
1559
|
return 'destination-out';
|
|
@@ -2307,11 +2316,12 @@ const RectHelper = {
|
|
|
2307
2316
|
|
|
2308
2317
|
const { sin: sin$1, cos: cos$1, atan2: atan2$1, ceil, abs: abs$1, PI, sqrt: sqrt$1, pow } = Math;
|
|
2309
2318
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2310
|
-
const { set } = PointHelper;
|
|
2319
|
+
const { set, toNumberPoints } = PointHelper;
|
|
2311
2320
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2312
2321
|
const tempPoint$1 = {};
|
|
2313
2322
|
const BezierHelper = {
|
|
2314
|
-
points(data,
|
|
2323
|
+
points(data, originPoints, curve, close) {
|
|
2324
|
+
let points = toNumberPoints(originPoints);
|
|
2315
2325
|
data.push(M$5, points[0], points[1]);
|
|
2316
2326
|
if (curve && points.length > 5) {
|
|
2317
2327
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
@@ -2820,6 +2830,27 @@ const PathConvert = {
|
|
|
2820
2830
|
}
|
|
2821
2831
|
return data;
|
|
2822
2832
|
},
|
|
2833
|
+
objectToCanvasData(list) {
|
|
2834
|
+
const data = [];
|
|
2835
|
+
list.forEach(item => {
|
|
2836
|
+
switch (item.name) {
|
|
2837
|
+
case 'M':
|
|
2838
|
+
data.push(M$4, item.x, item.y);
|
|
2839
|
+
break;
|
|
2840
|
+
case 'L':
|
|
2841
|
+
data.push(L$5, item.x, item.y);
|
|
2842
|
+
break;
|
|
2843
|
+
case 'C':
|
|
2844
|
+
data.push(C$4, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
|
|
2845
|
+
break;
|
|
2846
|
+
case 'Q':
|
|
2847
|
+
data.push(Q$3, item.x1, item.y1, item.x, item.y);
|
|
2848
|
+
break;
|
|
2849
|
+
case 'Z': data.push(Z$4);
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
return data;
|
|
2853
|
+
},
|
|
2823
2854
|
copyData(data, old, index, count) {
|
|
2824
2855
|
for (let i = index, end = index + count; i < end; i++) {
|
|
2825
2856
|
data.push(old[i]);
|
|
@@ -4757,6 +4788,7 @@ class RenderEvent extends Event {
|
|
|
4757
4788
|
}
|
|
4758
4789
|
}
|
|
4759
4790
|
RenderEvent.REQUEST = 'render.request';
|
|
4791
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4760
4792
|
RenderEvent.START = 'render.start';
|
|
4761
4793
|
RenderEvent.BEFORE = 'render.before';
|
|
4762
4794
|
RenderEvent.RENDER = 'render';
|
|
@@ -4932,7 +4964,7 @@ const { isFinite } = Number;
|
|
|
4932
4964
|
const debug = Debug.get('setAttr');
|
|
4933
4965
|
const LeafDataProxy = {
|
|
4934
4966
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4935
|
-
if (this.
|
|
4967
|
+
if (this.leaferIsCreated) {
|
|
4936
4968
|
const oldValue = this.__.__getInput(name);
|
|
4937
4969
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4938
4970
|
debug.warn(this.innerName, name, newValue);
|
|
@@ -5087,7 +5119,7 @@ const LeafBounds = {
|
|
|
5087
5119
|
const b = this.__layout.boxBounds;
|
|
5088
5120
|
const data = this.__;
|
|
5089
5121
|
if (data.__pathInputed) {
|
|
5090
|
-
toBounds(data.
|
|
5122
|
+
toBounds(data.path, b);
|
|
5091
5123
|
}
|
|
5092
5124
|
else {
|
|
5093
5125
|
b.x = 0;
|
|
@@ -5099,7 +5131,7 @@ const LeafBounds = {
|
|
|
5099
5131
|
__updateAutoLayout() {
|
|
5100
5132
|
this.__layout.matrixChanged = true;
|
|
5101
5133
|
if (this.isBranch) {
|
|
5102
|
-
if (this.
|
|
5134
|
+
if (this.leaferIsReady)
|
|
5103
5135
|
this.leafer.layouter.addExtra(this);
|
|
5104
5136
|
if (this.__.flow) {
|
|
5105
5137
|
if (this.__layout.boxChanged)
|
|
@@ -5160,7 +5192,7 @@ const LeafRender = {
|
|
|
5160
5192
|
if (this.__worldOpacity) {
|
|
5161
5193
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5162
5194
|
this.__drawRenderPath(canvas);
|
|
5163
|
-
this.
|
|
5195
|
+
this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
|
|
5164
5196
|
}
|
|
5165
5197
|
},
|
|
5166
5198
|
__updateWorldOpacity() {
|
|
@@ -5234,6 +5266,8 @@ exports.Leaf = class Leaf {
|
|
|
5234
5266
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5235
5267
|
get __DataProcessor() { return LeafData; }
|
|
5236
5268
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5269
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5270
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5237
5271
|
get isLeafer() { return false; }
|
|
5238
5272
|
get isBranch() { return false; }
|
|
5239
5273
|
get isBranchLeaf() { return false; }
|
|
@@ -5675,10 +5709,17 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5675
5709
|
add(child, index) {
|
|
5676
5710
|
if (child === this)
|
|
5677
5711
|
return;
|
|
5712
|
+
const noIndex = index === undefined;
|
|
5713
|
+
if (!child.__) {
|
|
5714
|
+
if (child instanceof Array)
|
|
5715
|
+
return child.forEach(item => { this.add(item, index); noIndex || index++; });
|
|
5716
|
+
else
|
|
5717
|
+
child = UICreator.get(child.tag, child);
|
|
5718
|
+
}
|
|
5678
5719
|
if (child.parent)
|
|
5679
5720
|
child.parent.remove(child);
|
|
5680
5721
|
child.parent = this;
|
|
5681
|
-
|
|
5722
|
+
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5682
5723
|
if (child.isBranch)
|
|
5683
5724
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5684
5725
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
@@ -5692,15 +5733,17 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5692
5733
|
}
|
|
5693
5734
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5694
5735
|
}
|
|
5695
|
-
addMany(...children) {
|
|
5696
|
-
children.forEach(child => this.add(child));
|
|
5697
|
-
}
|
|
5736
|
+
addMany(...children) { this.add(children); }
|
|
5698
5737
|
remove(child, destroy) {
|
|
5699
5738
|
if (child) {
|
|
5700
|
-
if (child.
|
|
5701
|
-
|
|
5739
|
+
if (child.__) {
|
|
5740
|
+
if (child.animationOut)
|
|
5741
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5742
|
+
else
|
|
5743
|
+
this.__remove(child, destroy);
|
|
5744
|
+
}
|
|
5702
5745
|
else
|
|
5703
|
-
this.
|
|
5746
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5704
5747
|
}
|
|
5705
5748
|
else if (child === undefined) {
|
|
5706
5749
|
super.remove(null, destroy);
|
|
@@ -5918,7 +5961,7 @@ class LeafLevelList {
|
|
|
5918
5961
|
}
|
|
5919
5962
|
}
|
|
5920
5963
|
|
|
5921
|
-
const version = "1.0.
|
|
5964
|
+
const version = "1.0.6";
|
|
5922
5965
|
|
|
5923
5966
|
exports.AlignHelper = AlignHelper;
|
|
5924
5967
|
exports.AroundHelper = AroundHelper;
|
package/lib/core.esm.js
CHANGED
|
@@ -552,6 +552,12 @@ const PointHelper = {
|
|
|
552
552
|
to.y = t.y + sin$2(r) * distance;
|
|
553
553
|
return to;
|
|
554
554
|
},
|
|
555
|
+
toNumberPoints(originPoints) {
|
|
556
|
+
let points = originPoints;
|
|
557
|
+
if (typeof originPoints[0] === 'object')
|
|
558
|
+
points = [], originPoints.forEach(p => points.push(p.x, p.y));
|
|
559
|
+
return points;
|
|
560
|
+
},
|
|
555
561
|
reset(t) {
|
|
556
562
|
P$5.reset(t);
|
|
557
563
|
}
|
|
@@ -1542,7 +1548,10 @@ const { assign } = DataHelper;
|
|
|
1542
1548
|
|
|
1543
1549
|
class LeafData {
|
|
1544
1550
|
get __useNaturalRatio() { return true; }
|
|
1545
|
-
get __isLinePath() {
|
|
1551
|
+
get __isLinePath() {
|
|
1552
|
+
const { path } = this;
|
|
1553
|
+
return path && path.length === 6 && path[0] === 1;
|
|
1554
|
+
}
|
|
1546
1555
|
get __blendMode() {
|
|
1547
1556
|
if (this.eraser && this.eraser !== 'path')
|
|
1548
1557
|
return 'destination-out';
|
|
@@ -2305,11 +2314,12 @@ const RectHelper = {
|
|
|
2305
2314
|
|
|
2306
2315
|
const { sin: sin$1, cos: cos$1, atan2: atan2$1, ceil, abs: abs$1, PI, sqrt: sqrt$1, pow } = Math;
|
|
2307
2316
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2308
|
-
const { set } = PointHelper;
|
|
2317
|
+
const { set, toNumberPoints } = PointHelper;
|
|
2309
2318
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2310
2319
|
const tempPoint$1 = {};
|
|
2311
2320
|
const BezierHelper = {
|
|
2312
|
-
points(data,
|
|
2321
|
+
points(data, originPoints, curve, close) {
|
|
2322
|
+
let points = toNumberPoints(originPoints);
|
|
2313
2323
|
data.push(M$5, points[0], points[1]);
|
|
2314
2324
|
if (curve && points.length > 5) {
|
|
2315
2325
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
@@ -2818,6 +2828,27 @@ const PathConvert = {
|
|
|
2818
2828
|
}
|
|
2819
2829
|
return data;
|
|
2820
2830
|
},
|
|
2831
|
+
objectToCanvasData(list) {
|
|
2832
|
+
const data = [];
|
|
2833
|
+
list.forEach(item => {
|
|
2834
|
+
switch (item.name) {
|
|
2835
|
+
case 'M':
|
|
2836
|
+
data.push(M$4, item.x, item.y);
|
|
2837
|
+
break;
|
|
2838
|
+
case 'L':
|
|
2839
|
+
data.push(L$5, item.x, item.y);
|
|
2840
|
+
break;
|
|
2841
|
+
case 'C':
|
|
2842
|
+
data.push(C$4, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
|
|
2843
|
+
break;
|
|
2844
|
+
case 'Q':
|
|
2845
|
+
data.push(Q$3, item.x1, item.y1, item.x, item.y);
|
|
2846
|
+
break;
|
|
2847
|
+
case 'Z': data.push(Z$4);
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
return data;
|
|
2851
|
+
},
|
|
2821
2852
|
copyData(data, old, index, count) {
|
|
2822
2853
|
for (let i = index, end = index + count; i < end; i++) {
|
|
2823
2854
|
data.push(old[i]);
|
|
@@ -4755,6 +4786,7 @@ class RenderEvent extends Event {
|
|
|
4755
4786
|
}
|
|
4756
4787
|
}
|
|
4757
4788
|
RenderEvent.REQUEST = 'render.request';
|
|
4789
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4758
4790
|
RenderEvent.START = 'render.start';
|
|
4759
4791
|
RenderEvent.BEFORE = 'render.before';
|
|
4760
4792
|
RenderEvent.RENDER = 'render';
|
|
@@ -4930,7 +4962,7 @@ const { isFinite } = Number;
|
|
|
4930
4962
|
const debug = Debug.get('setAttr');
|
|
4931
4963
|
const LeafDataProxy = {
|
|
4932
4964
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4933
|
-
if (this.
|
|
4965
|
+
if (this.leaferIsCreated) {
|
|
4934
4966
|
const oldValue = this.__.__getInput(name);
|
|
4935
4967
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4936
4968
|
debug.warn(this.innerName, name, newValue);
|
|
@@ -5085,7 +5117,7 @@ const LeafBounds = {
|
|
|
5085
5117
|
const b = this.__layout.boxBounds;
|
|
5086
5118
|
const data = this.__;
|
|
5087
5119
|
if (data.__pathInputed) {
|
|
5088
|
-
toBounds(data.
|
|
5120
|
+
toBounds(data.path, b);
|
|
5089
5121
|
}
|
|
5090
5122
|
else {
|
|
5091
5123
|
b.x = 0;
|
|
@@ -5097,7 +5129,7 @@ const LeafBounds = {
|
|
|
5097
5129
|
__updateAutoLayout() {
|
|
5098
5130
|
this.__layout.matrixChanged = true;
|
|
5099
5131
|
if (this.isBranch) {
|
|
5100
|
-
if (this.
|
|
5132
|
+
if (this.leaferIsReady)
|
|
5101
5133
|
this.leafer.layouter.addExtra(this);
|
|
5102
5134
|
if (this.__.flow) {
|
|
5103
5135
|
if (this.__layout.boxChanged)
|
|
@@ -5158,7 +5190,7 @@ const LeafRender = {
|
|
|
5158
5190
|
if (this.__worldOpacity) {
|
|
5159
5191
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5160
5192
|
this.__drawRenderPath(canvas);
|
|
5161
|
-
this.
|
|
5193
|
+
this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
|
|
5162
5194
|
}
|
|
5163
5195
|
},
|
|
5164
5196
|
__updateWorldOpacity() {
|
|
@@ -5232,6 +5264,8 @@ let Leaf = class Leaf {
|
|
|
5232
5264
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5233
5265
|
get __DataProcessor() { return LeafData; }
|
|
5234
5266
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5267
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5268
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5235
5269
|
get isLeafer() { return false; }
|
|
5236
5270
|
get isBranch() { return false; }
|
|
5237
5271
|
get isBranchLeaf() { return false; }
|
|
@@ -5673,10 +5707,17 @@ let Branch = class Branch extends Leaf {
|
|
|
5673
5707
|
add(child, index) {
|
|
5674
5708
|
if (child === this)
|
|
5675
5709
|
return;
|
|
5710
|
+
const noIndex = index === undefined;
|
|
5711
|
+
if (!child.__) {
|
|
5712
|
+
if (child instanceof Array)
|
|
5713
|
+
return child.forEach(item => { this.add(item, index); noIndex || index++; });
|
|
5714
|
+
else
|
|
5715
|
+
child = UICreator.get(child.tag, child);
|
|
5716
|
+
}
|
|
5676
5717
|
if (child.parent)
|
|
5677
5718
|
child.parent.remove(child);
|
|
5678
5719
|
child.parent = this;
|
|
5679
|
-
|
|
5720
|
+
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5680
5721
|
if (child.isBranch)
|
|
5681
5722
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5682
5723
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
@@ -5690,15 +5731,17 @@ let Branch = class Branch extends Leaf {
|
|
|
5690
5731
|
}
|
|
5691
5732
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5692
5733
|
}
|
|
5693
|
-
addMany(...children) {
|
|
5694
|
-
children.forEach(child => this.add(child));
|
|
5695
|
-
}
|
|
5734
|
+
addMany(...children) { this.add(children); }
|
|
5696
5735
|
remove(child, destroy) {
|
|
5697
5736
|
if (child) {
|
|
5698
|
-
if (child.
|
|
5699
|
-
|
|
5737
|
+
if (child.__) {
|
|
5738
|
+
if (child.animationOut)
|
|
5739
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5740
|
+
else
|
|
5741
|
+
this.__remove(child, destroy);
|
|
5742
|
+
}
|
|
5700
5743
|
else
|
|
5701
|
-
this.
|
|
5744
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5702
5745
|
}
|
|
5703
5746
|
else if (child === undefined) {
|
|
5704
5747
|
super.remove(null, destroy);
|
|
@@ -5916,6 +5959,6 @@ class LeafLevelList {
|
|
|
5916
5959
|
}
|
|
5917
5960
|
}
|
|
5918
5961
|
|
|
5919
|
-
const version = "1.0.
|
|
5962
|
+
const version = "1.0.6";
|
|
5920
5963
|
|
|
5921
5964
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule, version, visibleType };
|