@leafer/core 1.6.2 → 1.6.3
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 +221 -132
- package/lib/core.esm.js +221 -133
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +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
|
@@ -25,8 +25,6 @@ const Platform = {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const Creator = {};
|
|
29
|
-
|
|
30
28
|
const IncrementId = {
|
|
31
29
|
RUNTIME: 'runtime',
|
|
32
30
|
LEAF: 'leaf',
|
|
@@ -466,8 +464,10 @@ const PointHelper = {
|
|
|
466
464
|
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
467
465
|
},
|
|
468
466
|
move(t, x, y) {
|
|
469
|
-
|
|
470
|
-
|
|
467
|
+
if (typeof x === 'object')
|
|
468
|
+
t.x += x.x, t.y += x.y;
|
|
469
|
+
else
|
|
470
|
+
t.x += x, t.y += y;
|
|
471
471
|
},
|
|
472
472
|
scale(t, scaleX, scaleY = scaleX) {
|
|
473
473
|
if (t.x)
|
|
@@ -803,15 +803,87 @@ const TwoPointBoundsHelper = {
|
|
|
803
803
|
};
|
|
804
804
|
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
805
805
|
|
|
806
|
+
exports.Direction4 = void 0;
|
|
807
|
+
(function (Direction4) {
|
|
808
|
+
Direction4[Direction4["top"] = 0] = "top";
|
|
809
|
+
Direction4[Direction4["right"] = 1] = "right";
|
|
810
|
+
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
811
|
+
Direction4[Direction4["left"] = 3] = "left";
|
|
812
|
+
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
813
|
+
exports.Direction9 = void 0;
|
|
814
|
+
(function (Direction9) {
|
|
815
|
+
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
816
|
+
Direction9[Direction9["top"] = 1] = "top";
|
|
817
|
+
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
818
|
+
Direction9[Direction9["right"] = 3] = "right";
|
|
819
|
+
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
820
|
+
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
821
|
+
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
822
|
+
Direction9[Direction9["left"] = 7] = "left";
|
|
823
|
+
Direction9[Direction9["center"] = 8] = "center";
|
|
824
|
+
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
825
|
+
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
826
|
+
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
827
|
+
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
828
|
+
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
829
|
+
|
|
830
|
+
const directionData = [
|
|
831
|
+
{ x: 0, y: 0 },
|
|
832
|
+
{ x: 0.5, y: 0 },
|
|
833
|
+
{ x: 1, y: 0 },
|
|
834
|
+
{ x: 1, y: 0.5 },
|
|
835
|
+
{ x: 1, y: 1 },
|
|
836
|
+
{ x: 0.5, y: 1 },
|
|
837
|
+
{ x: 0, y: 1 },
|
|
838
|
+
{ x: 0, y: 0.5 },
|
|
839
|
+
{ x: 0.5, y: 0.5 }
|
|
840
|
+
];
|
|
841
|
+
directionData.forEach(item => item.type = 'percent');
|
|
842
|
+
const AroundHelper = {
|
|
843
|
+
directionData,
|
|
844
|
+
tempPoint: {},
|
|
845
|
+
get,
|
|
846
|
+
toPoint(around, box, to, onlyBoxSize, content, onlyContentSize) {
|
|
847
|
+
const point = get(around);
|
|
848
|
+
to.x = point.x;
|
|
849
|
+
to.y = point.y;
|
|
850
|
+
if (point.type === 'percent') {
|
|
851
|
+
to.x *= box.width;
|
|
852
|
+
to.y *= box.height;
|
|
853
|
+
if (content) {
|
|
854
|
+
if (!onlyContentSize)
|
|
855
|
+
to.x -= content.x, to.y -= content.y;
|
|
856
|
+
if (point.x)
|
|
857
|
+
to.x -= (point.x === 1) ? content.width : (point.x === 0.5 ? point.x * content.width : 0);
|
|
858
|
+
if (point.y)
|
|
859
|
+
to.y -= (point.y === 1) ? content.height : (point.y === 0.5 ? point.y * content.height : 0);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
if (!onlyBoxSize)
|
|
863
|
+
to.x += box.x, to.y += box.y;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
function get(around) {
|
|
867
|
+
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const { toPoint: toPoint$2 } = AroundHelper;
|
|
871
|
+
const AlignHelper = {
|
|
872
|
+
toPoint(align, content, box, to, onlyBoxSize, onlyContentSize) {
|
|
873
|
+
toPoint$2(align, box, to, onlyBoxSize, content, onlyContentSize);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
|
|
806
877
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
807
878
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
808
879
|
const { float, fourNumber } = MathHelper;
|
|
809
880
|
const { floor, ceil: ceil$1 } = Math;
|
|
810
881
|
let right, bottom, boundsRight, boundsBottom;
|
|
811
882
|
const point = {};
|
|
812
|
-
const toPoint$
|
|
883
|
+
const toPoint$1 = {};
|
|
884
|
+
const tempBounds$1 = {};
|
|
813
885
|
const BoundsHelper = {
|
|
814
|
-
tempBounds:
|
|
886
|
+
tempBounds: tempBounds$1,
|
|
815
887
|
set(t, x = 0, y = 0, width = 0, height = 0) {
|
|
816
888
|
t.x = x;
|
|
817
889
|
t.y = y;
|
|
@@ -874,8 +946,8 @@ const BoundsHelper = {
|
|
|
874
946
|
}
|
|
875
947
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
876
948
|
},
|
|
877
|
-
scale(t, scaleX, scaleY = scaleX) {
|
|
878
|
-
PointHelper.scale(t, scaleX, scaleY);
|
|
949
|
+
scale(t, scaleX, scaleY = scaleX, onlySize) {
|
|
950
|
+
onlySize || PointHelper.scale(t, scaleX, scaleY);
|
|
879
951
|
t.width *= scaleX;
|
|
880
952
|
t.height *= scaleY;
|
|
881
953
|
},
|
|
@@ -885,9 +957,9 @@ const BoundsHelper = {
|
|
|
885
957
|
t.height *= scaleY;
|
|
886
958
|
},
|
|
887
959
|
tempToOuterOf(t, matrix) {
|
|
888
|
-
B.copy(
|
|
889
|
-
B.toOuterOf(
|
|
890
|
-
return
|
|
960
|
+
B.copy(tempBounds$1, t);
|
|
961
|
+
B.toOuterOf(tempBounds$1, matrix);
|
|
962
|
+
return tempBounds$1;
|
|
891
963
|
},
|
|
892
964
|
getOuterOf(t, matrix) {
|
|
893
965
|
t = Object.assign({}, t);
|
|
@@ -918,17 +990,17 @@ const BoundsHelper = {
|
|
|
918
990
|
else {
|
|
919
991
|
point.x = t.x;
|
|
920
992
|
point.y = t.y;
|
|
921
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
922
|
-
setPoint$2(tempPointBounds$1, toPoint$
|
|
993
|
+
toOuterPoint$2(matrix, point, toPoint$1);
|
|
994
|
+
setPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
923
995
|
point.x = t.x + t.width;
|
|
924
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
925
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
996
|
+
toOuterPoint$2(matrix, point, toPoint$1);
|
|
997
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
926
998
|
point.y = t.y + t.height;
|
|
927
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
928
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
999
|
+
toOuterPoint$2(matrix, point, toPoint$1);
|
|
1000
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
929
1001
|
point.x = t.x;
|
|
930
|
-
toOuterPoint$2(matrix, point, toPoint$
|
|
931
|
-
addPoint$2(tempPointBounds$1, toPoint$
|
|
1002
|
+
toOuterPoint$2(matrix, point, toPoint$1);
|
|
1003
|
+
addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
|
|
932
1004
|
toBounds$2(tempPointBounds$1, to);
|
|
933
1005
|
}
|
|
934
1006
|
},
|
|
@@ -938,9 +1010,21 @@ const BoundsHelper = {
|
|
|
938
1010
|
B.scale(to, 1 / matrix.a, 1 / matrix.d);
|
|
939
1011
|
},
|
|
940
1012
|
getFitMatrix(t, put, baseScale = 1) {
|
|
941
|
-
const scale = Math.min(baseScale,
|
|
1013
|
+
const scale = Math.min(baseScale, B.getFitScale(t, put));
|
|
942
1014
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
943
1015
|
},
|
|
1016
|
+
getFitScale(t, put, isCoverMode) {
|
|
1017
|
+
const sw = t.width / put.width, sh = t.height / put.height;
|
|
1018
|
+
return isCoverMode ? Math.max(sw, sh) : Math.min(sw, sh);
|
|
1019
|
+
},
|
|
1020
|
+
put(t, put, align = 'center', putScale = 1, changeSize = true, to) {
|
|
1021
|
+
to || (to = put);
|
|
1022
|
+
if (typeof putScale === 'string')
|
|
1023
|
+
putScale = B.getFitScale(t, put, putScale === 'cover');
|
|
1024
|
+
tempBounds$1.width = changeSize ? put.width *= putScale : put.width * putScale;
|
|
1025
|
+
tempBounds$1.height = changeSize ? put.height *= putScale : put.height * putScale;
|
|
1026
|
+
AlignHelper.toPoint(align, tempBounds$1, t, to, true, true);
|
|
1027
|
+
},
|
|
944
1028
|
getSpread(t, spread, side) {
|
|
945
1029
|
const n = {};
|
|
946
1030
|
B.copyAndSpread(n, t, spread, false, side);
|
|
@@ -1114,8 +1198,8 @@ class Bounds {
|
|
|
1114
1198
|
BoundsHelper.move(this, x, y);
|
|
1115
1199
|
return this;
|
|
1116
1200
|
}
|
|
1117
|
-
scale(scaleX, scaleY) {
|
|
1118
|
-
BoundsHelper.scale(this, scaleX, scaleY);
|
|
1201
|
+
scale(scaleX, scaleY, onlySize) {
|
|
1202
|
+
BoundsHelper.scale(this, scaleX, scaleY, onlySize);
|
|
1119
1203
|
return this;
|
|
1120
1204
|
}
|
|
1121
1205
|
scaleOf(origin, scaleX, scaleY) {
|
|
@@ -1133,6 +1217,9 @@ class Bounds {
|
|
|
1133
1217
|
getFitMatrix(put, baseScale) {
|
|
1134
1218
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1135
1219
|
}
|
|
1220
|
+
put(put, align, putScale) {
|
|
1221
|
+
BoundsHelper.put(this, put, align, putScale);
|
|
1222
|
+
}
|
|
1136
1223
|
spread(fourNumber, side) {
|
|
1137
1224
|
BoundsHelper.spread(this, fourNumber, side);
|
|
1138
1225
|
return this;
|
|
@@ -1241,79 +1328,6 @@ class AutoBounds {
|
|
|
1241
1328
|
}
|
|
1242
1329
|
}
|
|
1243
1330
|
|
|
1244
|
-
exports.Direction4 = void 0;
|
|
1245
|
-
(function (Direction4) {
|
|
1246
|
-
Direction4[Direction4["top"] = 0] = "top";
|
|
1247
|
-
Direction4[Direction4["right"] = 1] = "right";
|
|
1248
|
-
Direction4[Direction4["bottom"] = 2] = "bottom";
|
|
1249
|
-
Direction4[Direction4["left"] = 3] = "left";
|
|
1250
|
-
})(exports.Direction4 || (exports.Direction4 = {}));
|
|
1251
|
-
exports.Direction9 = void 0;
|
|
1252
|
-
(function (Direction9) {
|
|
1253
|
-
Direction9[Direction9["topLeft"] = 0] = "topLeft";
|
|
1254
|
-
Direction9[Direction9["top"] = 1] = "top";
|
|
1255
|
-
Direction9[Direction9["topRight"] = 2] = "topRight";
|
|
1256
|
-
Direction9[Direction9["right"] = 3] = "right";
|
|
1257
|
-
Direction9[Direction9["bottomRight"] = 4] = "bottomRight";
|
|
1258
|
-
Direction9[Direction9["bottom"] = 5] = "bottom";
|
|
1259
|
-
Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
|
|
1260
|
-
Direction9[Direction9["left"] = 7] = "left";
|
|
1261
|
-
Direction9[Direction9["center"] = 8] = "center";
|
|
1262
|
-
Direction9[Direction9["top-left"] = 0] = "top-left";
|
|
1263
|
-
Direction9[Direction9["top-right"] = 2] = "top-right";
|
|
1264
|
-
Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
|
|
1265
|
-
Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
|
|
1266
|
-
})(exports.Direction9 || (exports.Direction9 = {}));
|
|
1267
|
-
|
|
1268
|
-
const directionData = [
|
|
1269
|
-
{ x: 0, y: 0 },
|
|
1270
|
-
{ x: 0.5, y: 0 },
|
|
1271
|
-
{ x: 1, y: 0 },
|
|
1272
|
-
{ x: 1, y: 0.5 },
|
|
1273
|
-
{ x: 1, y: 1 },
|
|
1274
|
-
{ x: 0.5, y: 1 },
|
|
1275
|
-
{ x: 0, y: 1 },
|
|
1276
|
-
{ x: 0, y: 0.5 },
|
|
1277
|
-
{ x: 0.5, y: 0.5 }
|
|
1278
|
-
];
|
|
1279
|
-
directionData.forEach(item => item.type = 'percent');
|
|
1280
|
-
const AroundHelper = {
|
|
1281
|
-
directionData,
|
|
1282
|
-
tempPoint: {},
|
|
1283
|
-
get,
|
|
1284
|
-
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1285
|
-
const point = get(around);
|
|
1286
|
-
to.x = point.x;
|
|
1287
|
-
to.y = point.y;
|
|
1288
|
-
if (point.type === 'percent') {
|
|
1289
|
-
to.x *= bounds.width;
|
|
1290
|
-
to.y *= bounds.height;
|
|
1291
|
-
if (pointBounds) {
|
|
1292
|
-
to.x -= pointBounds.x;
|
|
1293
|
-
to.y -= pointBounds.y;
|
|
1294
|
-
if (point.x)
|
|
1295
|
-
to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
|
|
1296
|
-
if (point.y)
|
|
1297
|
-
to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
if (!onlySize) {
|
|
1301
|
-
to.x += bounds.x;
|
|
1302
|
-
to.y += bounds.y;
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
};
|
|
1306
|
-
function get(around) {
|
|
1307
|
-
return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
const { toPoint: toPoint$1 } = AroundHelper;
|
|
1311
|
-
const AlignHelper = {
|
|
1312
|
-
toPoint(align, contentBounds, bounds, to, onlySize) {
|
|
1313
|
-
toPoint$1(align, bounds, to, onlySize, contentBounds);
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
|
|
1317
1331
|
const StringNumberMap = {
|
|
1318
1332
|
'0': 1,
|
|
1319
1333
|
'1': 1,
|
|
@@ -1444,11 +1458,17 @@ const Plugin = {
|
|
|
1444
1458
|
return rs;
|
|
1445
1459
|
},
|
|
1446
1460
|
need(name) {
|
|
1447
|
-
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1461
|
+
console.error('please install and import plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1448
1462
|
}
|
|
1449
1463
|
};
|
|
1450
1464
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1451
1465
|
|
|
1466
|
+
const Creator = {
|
|
1467
|
+
editor(_options) {
|
|
1468
|
+
return Plugin.need('editor');
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
|
|
1452
1472
|
const debug$9 = Debug.get('UICreator');
|
|
1453
1473
|
const UICreator = {
|
|
1454
1474
|
list: {},
|
|
@@ -1586,6 +1606,10 @@ const DataHelper = {
|
|
|
1586
1606
|
for (let i = 0, len = list.length; i < len; i++)
|
|
1587
1607
|
map[list[i]] = true;
|
|
1588
1608
|
return map;
|
|
1609
|
+
},
|
|
1610
|
+
stintSet(data, attrName, value) {
|
|
1611
|
+
value || (value = undefined);
|
|
1612
|
+
data[attrName] !== value && (data[attrName] = value);
|
|
1589
1613
|
}
|
|
1590
1614
|
};
|
|
1591
1615
|
const { assign } = DataHelper;
|
|
@@ -2409,6 +2433,8 @@ const BezierHelper = {
|
|
|
2409
2433
|
cY = points[i + 3];
|
|
2410
2434
|
ba = sqrt$1(pow(bX - aX, 2) + pow(bY - aY, 2));
|
|
2411
2435
|
cb = sqrt$1(pow(cX - bX, 2) + pow(cY - bY, 2));
|
|
2436
|
+
if (!ba && !cb)
|
|
2437
|
+
continue;
|
|
2412
2438
|
d = ba + cb;
|
|
2413
2439
|
ba = (t * ba) / d;
|
|
2414
2440
|
cb = (t * cb) / d;
|
|
@@ -3388,7 +3414,7 @@ function canvasPatch(drawer) {
|
|
|
3388
3414
|
}
|
|
3389
3415
|
|
|
3390
3416
|
const FileHelper = {
|
|
3391
|
-
|
|
3417
|
+
alphaPixelTypes: ['png', 'webp', 'svg'],
|
|
3392
3418
|
upperCaseTypeMap: {},
|
|
3393
3419
|
mineType(type) {
|
|
3394
3420
|
if (!type || type.startsWith('image'))
|
|
@@ -3415,7 +3441,7 @@ const FileHelper = {
|
|
|
3415
3441
|
}
|
|
3416
3442
|
};
|
|
3417
3443
|
const F = FileHelper;
|
|
3418
|
-
F.
|
|
3444
|
+
F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3419
3445
|
|
|
3420
3446
|
const debug$4 = Debug.get('TaskProcessor');
|
|
3421
3447
|
class TaskItem {
|
|
@@ -3732,8 +3758,8 @@ const ImageManager = {
|
|
|
3732
3758
|
list.length = 0;
|
|
3733
3759
|
}
|
|
3734
3760
|
},
|
|
3735
|
-
|
|
3736
|
-
return FileHelper.
|
|
3761
|
+
hasAlphaPixel(config) {
|
|
3762
|
+
return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
|
|
3737
3763
|
},
|
|
3738
3764
|
isFormat(format, config) {
|
|
3739
3765
|
if (config.format === format)
|
|
@@ -3771,7 +3797,7 @@ class LeaferImage {
|
|
|
3771
3797
|
this.setView(view.config ? view.view : view);
|
|
3772
3798
|
}
|
|
3773
3799
|
ImageManager.isFormat('svg', config) && (this.isSVG = true);
|
|
3774
|
-
ImageManager.
|
|
3800
|
+
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
3775
3801
|
}
|
|
3776
3802
|
load(onSuccess, onError) {
|
|
3777
3803
|
if (!this.loading) {
|
|
@@ -4459,7 +4485,7 @@ const LeafBoundsHelper = {
|
|
|
4459
4485
|
}
|
|
4460
4486
|
};
|
|
4461
4487
|
|
|
4462
|
-
const { updateBounds: updateBounds$
|
|
4488
|
+
const { updateBounds: updateBounds$2 } = LeafHelper;
|
|
4463
4489
|
const BranchHelper = {
|
|
4464
4490
|
sort(a, b) {
|
|
4465
4491
|
return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
|
|
@@ -4521,11 +4547,11 @@ const BranchHelper = {
|
|
|
4521
4547
|
branch = branchStack[i];
|
|
4522
4548
|
children = branch.children;
|
|
4523
4549
|
for (let j = 0, len = children.length; j < len; j++) {
|
|
4524
|
-
updateBounds$
|
|
4550
|
+
updateBounds$2(children[j]);
|
|
4525
4551
|
}
|
|
4526
4552
|
if (exclude && exclude === branch)
|
|
4527
4553
|
continue;
|
|
4528
|
-
updateBounds$
|
|
4554
|
+
updateBounds$2(branch);
|
|
4529
4555
|
}
|
|
4530
4556
|
}
|
|
4531
4557
|
};
|
|
@@ -4543,7 +4569,7 @@ const WaitHelper = {
|
|
|
4543
4569
|
}
|
|
4544
4570
|
};
|
|
4545
4571
|
|
|
4546
|
-
const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
|
|
4572
|
+
const { getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$1 } = LeafHelper;
|
|
4547
4573
|
const { toOuterOf: toOuterOf$2, getPoints, copy: copy$2 } = BoundsHelper;
|
|
4548
4574
|
const localContent = '_localContentBounds';
|
|
4549
4575
|
const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
|
|
@@ -4587,7 +4613,9 @@ class LeafLayout {
|
|
|
4587
4613
|
this._localRenderBounds = local;
|
|
4588
4614
|
}
|
|
4589
4615
|
update() {
|
|
4590
|
-
const { leafer } =
|
|
4616
|
+
const { leaf } = this, { leafer } = leaf;
|
|
4617
|
+
if (leaf.isApp)
|
|
4618
|
+
return updateBounds$1(leaf);
|
|
4591
4619
|
if (leafer) {
|
|
4592
4620
|
if (leafer.ready)
|
|
4593
4621
|
leafer.watcher.changed && leafer.layouter.layout();
|
|
@@ -4595,7 +4623,7 @@ class LeafLayout {
|
|
|
4595
4623
|
leafer.start();
|
|
4596
4624
|
}
|
|
4597
4625
|
else {
|
|
4598
|
-
let root =
|
|
4626
|
+
let root = leaf;
|
|
4599
4627
|
while (root.parent && !root.parent.leafer) {
|
|
4600
4628
|
root = root.parent;
|
|
4601
4629
|
}
|
|
@@ -4817,7 +4845,7 @@ class LeafLayout {
|
|
|
4817
4845
|
}
|
|
4818
4846
|
childrenSortChange() {
|
|
4819
4847
|
if (!this.childrenSortChanged) {
|
|
4820
|
-
this.childrenSortChanged = true;
|
|
4848
|
+
this.childrenSortChanged = this.affectChildrenSort = true;
|
|
4821
4849
|
this.leaf.forceUpdate('surface');
|
|
4822
4850
|
}
|
|
4823
4851
|
}
|
|
@@ -4884,6 +4912,40 @@ ImageEvent.LOAD = 'image.load';
|
|
|
4884
4912
|
ImageEvent.LOADED = 'image.loaded';
|
|
4885
4913
|
ImageEvent.ERROR = 'image.error';
|
|
4886
4914
|
|
|
4915
|
+
class BoundsEvent extends Event {
|
|
4916
|
+
static checkHas(leaf, type, mode) {
|
|
4917
|
+
if (mode === 'on') {
|
|
4918
|
+
type === WORLD ? leaf.__hasWorldEvent = true : leaf.__hasLocalEvent = true;
|
|
4919
|
+
}
|
|
4920
|
+
else {
|
|
4921
|
+
leaf.__hasLocalEvent = leaf.hasEvent(RESIZE) || leaf.hasEvent(INNER) || leaf.hasEvent(LOCAL);
|
|
4922
|
+
leaf.__hasWorldEvent = leaf.hasEvent(WORLD);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
static emitLocal(leaf) {
|
|
4926
|
+
if (leaf.leaferIsReady) {
|
|
4927
|
+
const { resized } = leaf.__layout;
|
|
4928
|
+
if (resized !== 'local') {
|
|
4929
|
+
leaf.emit(RESIZE, leaf);
|
|
4930
|
+
if (resized === 'inner')
|
|
4931
|
+
leaf.emit(INNER, leaf);
|
|
4932
|
+
}
|
|
4933
|
+
leaf.emit(LOCAL, leaf);
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
static emitWorld(leaf) {
|
|
4937
|
+
if (leaf.leaferIsReady)
|
|
4938
|
+
leaf.emit(WORLD, this);
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
BoundsEvent.RESIZE = 'bounds.resize';
|
|
4942
|
+
BoundsEvent.INNER = 'bounds.inner';
|
|
4943
|
+
BoundsEvent.LOCAL = 'bounds.local';
|
|
4944
|
+
BoundsEvent.WORLD = 'bounds.world';
|
|
4945
|
+
const { RESIZE, INNER, LOCAL, WORLD } = BoundsEvent;
|
|
4946
|
+
const boundsEventMap = {};
|
|
4947
|
+
[RESIZE, INNER, LOCAL, WORLD].forEach(key => boundsEventMap[key] = 1);
|
|
4948
|
+
|
|
4887
4949
|
class ResizeEvent extends Event {
|
|
4888
4950
|
get bigger() {
|
|
4889
4951
|
if (!this.old)
|
|
@@ -4980,9 +5042,12 @@ class Eventer {
|
|
|
4980
5042
|
set event(map) { this.on(map); }
|
|
4981
5043
|
on(type, listener, options) {
|
|
4982
5044
|
if (!listener) {
|
|
4983
|
-
let event
|
|
4984
|
-
|
|
4985
|
-
|
|
5045
|
+
let event;
|
|
5046
|
+
if (type instanceof Array)
|
|
5047
|
+
type.forEach(item => this.on(item[0], item[1], item[2]));
|
|
5048
|
+
else
|
|
5049
|
+
for (let key in type)
|
|
5050
|
+
(event = type[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4986
5051
|
return;
|
|
4987
5052
|
}
|
|
4988
5053
|
let capture, once;
|
|
@@ -5012,6 +5077,8 @@ class Eventer {
|
|
|
5012
5077
|
else {
|
|
5013
5078
|
map[type] = [item];
|
|
5014
5079
|
}
|
|
5080
|
+
if (boundsEventMap[type])
|
|
5081
|
+
BoundsEvent.checkHas(this, type, 'on');
|
|
5015
5082
|
}
|
|
5016
5083
|
});
|
|
5017
5084
|
}
|
|
@@ -5033,6 +5100,8 @@ class Eventer {
|
|
|
5033
5100
|
events.splice(index, 1);
|
|
5034
5101
|
if (!events.length)
|
|
5035
5102
|
delete map[type];
|
|
5103
|
+
if (boundsEventMap[type])
|
|
5104
|
+
BoundsEvent.checkHas(this, type, 'off');
|
|
5036
5105
|
}
|
|
5037
5106
|
}
|
|
5038
5107
|
});
|
|
@@ -5052,19 +5121,31 @@ class Eventer {
|
|
|
5052
5121
|
}
|
|
5053
5122
|
}
|
|
5054
5123
|
on_(type, listener, bind, options) {
|
|
5055
|
-
if (
|
|
5056
|
-
|
|
5057
|
-
|
|
5124
|
+
if (!listener)
|
|
5125
|
+
(type instanceof Array) && type.forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]));
|
|
5126
|
+
else
|
|
5127
|
+
this.on(type, bind ? listener = listener.bind(bind) : listener, options);
|
|
5058
5128
|
return { type, current: this, listener, options };
|
|
5059
5129
|
}
|
|
5060
5130
|
off_(id) {
|
|
5061
5131
|
if (!id)
|
|
5062
5132
|
return;
|
|
5063
5133
|
const list = id instanceof Array ? id : [id];
|
|
5064
|
-
list.forEach(item =>
|
|
5134
|
+
list.forEach(item => {
|
|
5135
|
+
if (!item.listener)
|
|
5136
|
+
(item.type instanceof Array) && item.type.forEach(v => item.current.off(v[0], v[1], v[3]));
|
|
5137
|
+
else
|
|
5138
|
+
item.current.off(item.type, item.listener, item.options);
|
|
5139
|
+
});
|
|
5065
5140
|
list.length = 0;
|
|
5066
5141
|
}
|
|
5067
|
-
once(type, listener, capture) {
|
|
5142
|
+
once(type, listener, captureOrBind, capture) {
|
|
5143
|
+
if (!listener)
|
|
5144
|
+
return (type instanceof Array) && type.forEach(item => this.once(item[0], item[1], item[2], item[3]));
|
|
5145
|
+
if (typeof captureOrBind === 'object')
|
|
5146
|
+
listener = listener.bind(captureOrBind);
|
|
5147
|
+
else
|
|
5148
|
+
capture = captureOrBind;
|
|
5068
5149
|
this.on(type, listener, { once: true, capture });
|
|
5069
5150
|
}
|
|
5070
5151
|
emit(type, event, capture) {
|
|
@@ -5185,9 +5266,9 @@ const LeafMatrix = {
|
|
|
5185
5266
|
if (this.__local) {
|
|
5186
5267
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5187
5268
|
if (layout.affectScaleOrRotation) {
|
|
5188
|
-
if (layout.scaleChanged || layout.rotationChanged) {
|
|
5269
|
+
if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
|
|
5189
5270
|
setLayout(local, data, null, null, layout.affectRotation);
|
|
5190
|
-
layout.scaleChanged = layout.rotationChanged =
|
|
5271
|
+
layout.scaleChanged = layout.rotationChanged = undefined;
|
|
5191
5272
|
}
|
|
5192
5273
|
}
|
|
5193
5274
|
local.e = data.x + data.offsetX;
|
|
@@ -5197,7 +5278,7 @@ const LeafMatrix = {
|
|
|
5197
5278
|
translateInner(local, -tempPoint.x, -tempPoint.y, !data.around);
|
|
5198
5279
|
}
|
|
5199
5280
|
}
|
|
5200
|
-
this.__layout.matrixChanged =
|
|
5281
|
+
this.__layout.matrixChanged = undefined;
|
|
5201
5282
|
}
|
|
5202
5283
|
};
|
|
5203
5284
|
|
|
@@ -5207,11 +5288,17 @@ const { toOuterOf: toOuterOf$1, copyAndSpread, copy: copy$1 } = BoundsHelper;
|
|
|
5207
5288
|
const { toBounds } = PathBounds;
|
|
5208
5289
|
const LeafBounds = {
|
|
5209
5290
|
__updateWorldBounds() {
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5291
|
+
const layout = this.__layout;
|
|
5292
|
+
toOuterOf$1(layout.renderBounds, this.__world, this.__world);
|
|
5293
|
+
if (layout.resized) {
|
|
5294
|
+
if (layout.resized === 'inner')
|
|
5295
|
+
this.__onUpdateSize();
|
|
5296
|
+
if (this.__hasLocalEvent)
|
|
5297
|
+
BoundsEvent.emitLocal(this);
|
|
5298
|
+
layout.resized = undefined;
|
|
5214
5299
|
}
|
|
5300
|
+
if (this.__hasWorldEvent)
|
|
5301
|
+
BoundsEvent.emitWorld(this);
|
|
5215
5302
|
},
|
|
5216
5303
|
__updateLocalBounds() {
|
|
5217
5304
|
const layout = this.__layout;
|
|
@@ -5220,12 +5307,12 @@ const LeafBounds = {
|
|
|
5220
5307
|
this.__updatePath();
|
|
5221
5308
|
this.__updateRenderPath();
|
|
5222
5309
|
this.__updateBoxBounds();
|
|
5223
|
-
layout.resized =
|
|
5310
|
+
layout.resized = 'inner';
|
|
5224
5311
|
}
|
|
5225
5312
|
if (layout.localBoxChanged) {
|
|
5226
5313
|
if (this.__local)
|
|
5227
5314
|
this.__updateLocalBoxBounds();
|
|
5228
|
-
layout.localBoxChanged =
|
|
5315
|
+
layout.localBoxChanged = undefined;
|
|
5229
5316
|
if (layout.strokeSpread)
|
|
5230
5317
|
layout.strokeChanged = true;
|
|
5231
5318
|
if (layout.renderSpread)
|
|
@@ -5233,7 +5320,7 @@ const LeafBounds = {
|
|
|
5233
5320
|
if (this.parent)
|
|
5234
5321
|
this.parent.__layout.boxChange();
|
|
5235
5322
|
}
|
|
5236
|
-
layout.boxChanged =
|
|
5323
|
+
layout.boxChanged = undefined;
|
|
5237
5324
|
if (layout.strokeChanged) {
|
|
5238
5325
|
layout.strokeSpread = this.__updateStrokeSpread();
|
|
5239
5326
|
if (layout.strokeSpread) {
|
|
@@ -5245,12 +5332,12 @@ const LeafBounds = {
|
|
|
5245
5332
|
else {
|
|
5246
5333
|
layout.spreadStrokeCancel();
|
|
5247
5334
|
}
|
|
5248
|
-
layout.strokeChanged =
|
|
5335
|
+
layout.strokeChanged = undefined;
|
|
5249
5336
|
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
|
|
5250
5337
|
layout.renderChanged = true;
|
|
5251
5338
|
if (this.parent)
|
|
5252
5339
|
this.parent.__layout.strokeChange();
|
|
5253
|
-
layout.resized =
|
|
5340
|
+
layout.resized = 'inner';
|
|
5254
5341
|
}
|
|
5255
5342
|
if (layout.renderChanged) {
|
|
5256
5343
|
layout.renderSpread = this.__updateRenderSpread();
|
|
@@ -5263,11 +5350,12 @@ const LeafBounds = {
|
|
|
5263
5350
|
else {
|
|
5264
5351
|
layout.spreadRenderCancel();
|
|
5265
5352
|
}
|
|
5266
|
-
layout.renderChanged =
|
|
5353
|
+
layout.renderChanged = undefined;
|
|
5267
5354
|
if (this.parent)
|
|
5268
5355
|
this.parent.__layout.renderChange();
|
|
5269
5356
|
}
|
|
5270
|
-
layout.
|
|
5357
|
+
layout.resized || (layout.resized = 'local');
|
|
5358
|
+
layout.boundsChanged = undefined;
|
|
5271
5359
|
},
|
|
5272
5360
|
__updateLocalBoxBounds() {
|
|
5273
5361
|
if (this.__hasMotionPath)
|
|
@@ -5807,7 +5895,7 @@ exports.Leaf = class Leaf {
|
|
|
5807
5895
|
off(_type, _listener, _options) { }
|
|
5808
5896
|
on_(_type, _listener, _bind, _options) { return undefined; }
|
|
5809
5897
|
off_(_id) { }
|
|
5810
|
-
once(_type, _listener, _capture) { }
|
|
5898
|
+
once(_type, _listener, _captureOrBind, _capture) { }
|
|
5811
5899
|
emit(_type, _event, _capture) { }
|
|
5812
5900
|
emitEvent(_event, _capture) { }
|
|
5813
5901
|
hasEvent(_type, _capture) { return false; }
|
|
@@ -6144,13 +6232,14 @@ class LeafLevelList {
|
|
|
6144
6232
|
}
|
|
6145
6233
|
}
|
|
6146
6234
|
|
|
6147
|
-
const version = "1.6.
|
|
6235
|
+
const version = "1.6.3";
|
|
6148
6236
|
|
|
6149
6237
|
exports.AlignHelper = AlignHelper;
|
|
6150
6238
|
exports.AroundHelper = AroundHelper;
|
|
6151
6239
|
exports.AutoBounds = AutoBounds;
|
|
6152
6240
|
exports.BezierHelper = BezierHelper;
|
|
6153
6241
|
exports.Bounds = Bounds;
|
|
6242
|
+
exports.BoundsEvent = BoundsEvent;
|
|
6154
6243
|
exports.BoundsHelper = BoundsHelper;
|
|
6155
6244
|
exports.BranchHelper = BranchHelper;
|
|
6156
6245
|
exports.BranchRender = BranchRender;
|