@leafer-ui/worker 1.2.2 → 1.3.0
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.cjs +23 -323
- package/dist/worker.esm.js +24 -325
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +134 -436
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +134 -437
- package/dist/worker.module.min.js +1 -1
- package/package.json +10 -10
package/dist/worker.js
CHANGED
|
@@ -768,8 +768,8 @@ var LeaferUI = (function (exports) {
|
|
|
768
768
|
t.maxY = y > t.maxY ? y : t.maxY;
|
|
769
769
|
},
|
|
770
770
|
addBounds(t, x, y, width, height) {
|
|
771
|
-
addPoint$
|
|
772
|
-
addPoint$
|
|
771
|
+
addPoint$3(t, x, y);
|
|
772
|
+
addPoint$3(t, x + width, y + height);
|
|
773
773
|
},
|
|
774
774
|
copy(t, pb) {
|
|
775
775
|
t.minX = pb.minX;
|
|
@@ -790,9 +790,9 @@ var LeaferUI = (function (exports) {
|
|
|
790
790
|
setBounds.height = t.maxY - t.minY;
|
|
791
791
|
}
|
|
792
792
|
};
|
|
793
|
-
const { addPoint: addPoint$
|
|
793
|
+
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
794
794
|
|
|
795
|
-
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$
|
|
795
|
+
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
796
796
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
797
797
|
const { float, fourNumber } = MathHelper;
|
|
798
798
|
const { floor, ceil: ceil$2 } = Math;
|
|
@@ -908,17 +908,17 @@ var LeaferUI = (function (exports) {
|
|
|
908
908
|
point.x = t.x;
|
|
909
909
|
point.y = t.y;
|
|
910
910
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
911
|
-
setPoint$
|
|
911
|
+
setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
912
912
|
point.x = t.x + t.width;
|
|
913
913
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
914
|
-
addPoint$
|
|
914
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
915
915
|
point.y = t.y + t.height;
|
|
916
916
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
917
|
-
addPoint$
|
|
917
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
918
918
|
point.x = t.x;
|
|
919
919
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
920
|
-
addPoint$
|
|
921
|
-
toBounds$
|
|
920
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
921
|
+
toBounds$3(tempPointBounds$1, to);
|
|
922
922
|
}
|
|
923
923
|
},
|
|
924
924
|
toInnerOf(t, matrix, to) {
|
|
@@ -1008,8 +1008,8 @@ var LeaferUI = (function (exports) {
|
|
|
1008
1008
|
B.reset(t);
|
|
1009
1009
|
},
|
|
1010
1010
|
setPoints(t, points) {
|
|
1011
|
-
points.forEach((point, index) => index === 0 ? setPoint$
|
|
1012
|
-
toBounds$
|
|
1011
|
+
points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
|
|
1012
|
+
toBounds$3(tempPointBounds$1, t);
|
|
1013
1013
|
},
|
|
1014
1014
|
setPoint(t, point) {
|
|
1015
1015
|
B.set(t, point.x, point.y);
|
|
@@ -1377,7 +1377,7 @@ var LeaferUI = (function (exports) {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
const D$4 = Debug;
|
|
1379
1379
|
|
|
1380
|
-
const debug$
|
|
1380
|
+
const debug$e = Debug.get('RunTime');
|
|
1381
1381
|
const Run = {
|
|
1382
1382
|
currentId: 0,
|
|
1383
1383
|
currentName: '',
|
|
@@ -1395,7 +1395,7 @@ var LeaferUI = (function (exports) {
|
|
|
1395
1395
|
const time = R.idMap[id], name = R.nameMap[id];
|
|
1396
1396
|
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
1397
1397
|
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
1398
|
-
debug$
|
|
1398
|
+
debug$e.log(name, duration, 'ms');
|
|
1399
1399
|
},
|
|
1400
1400
|
endOfName(name, microsecond) {
|
|
1401
1401
|
const id = R.nameToIdMap[name];
|
|
@@ -1405,34 +1405,37 @@ var LeaferUI = (function (exports) {
|
|
|
1405
1405
|
};
|
|
1406
1406
|
const R = Run;
|
|
1407
1407
|
|
|
1408
|
+
const check = [];
|
|
1408
1409
|
const Plugin = {
|
|
1409
1410
|
list: {},
|
|
1410
|
-
add(name) {
|
|
1411
|
+
add(name, ...needPlugins) {
|
|
1411
1412
|
this.list[name] = true;
|
|
1413
|
+
check.push(...needPlugins);
|
|
1412
1414
|
},
|
|
1413
|
-
|
|
1415
|
+
has(name, tip) {
|
|
1414
1416
|
const rs = this.list[name];
|
|
1415
1417
|
if (!rs && tip)
|
|
1416
1418
|
this.need(name);
|
|
1417
1419
|
return rs;
|
|
1418
1420
|
},
|
|
1419
1421
|
need(name) {
|
|
1420
|
-
console.error('need plugin: @leafer-in/' + name);
|
|
1422
|
+
console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1421
1423
|
}
|
|
1422
1424
|
};
|
|
1425
|
+
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1423
1426
|
|
|
1424
|
-
const debug$
|
|
1427
|
+
const debug$d = Debug.get('UICreator');
|
|
1425
1428
|
const UICreator = {
|
|
1426
1429
|
list: {},
|
|
1427
1430
|
register(UI) {
|
|
1428
1431
|
const { __tag: tag } = UI.prototype;
|
|
1429
1432
|
if (list$1[tag])
|
|
1430
|
-
debug$
|
|
1433
|
+
debug$d.repeat(tag);
|
|
1431
1434
|
list$1[tag] = UI;
|
|
1432
1435
|
},
|
|
1433
1436
|
get(tag, data, x, y, width, height) {
|
|
1434
1437
|
if (!list$1[tag])
|
|
1435
|
-
debug$
|
|
1438
|
+
debug$d.error('not register ' + tag);
|
|
1436
1439
|
const ui = new list$1[tag](data);
|
|
1437
1440
|
if (x !== undefined) {
|
|
1438
1441
|
ui.x = x;
|
|
@@ -1448,7 +1451,7 @@ var LeaferUI = (function (exports) {
|
|
|
1448
1451
|
};
|
|
1449
1452
|
const { list: list$1 } = UICreator;
|
|
1450
1453
|
|
|
1451
|
-
const debug$
|
|
1454
|
+
const debug$c = Debug.get('EventCreator');
|
|
1452
1455
|
const EventCreator = {
|
|
1453
1456
|
nameList: {},
|
|
1454
1457
|
register(Event) {
|
|
@@ -1456,7 +1459,7 @@ var LeaferUI = (function (exports) {
|
|
|
1456
1459
|
Object.keys(Event).forEach(key => {
|
|
1457
1460
|
name = Event[key];
|
|
1458
1461
|
if (typeof name === 'string')
|
|
1459
|
-
nameList[name] && debug$
|
|
1462
|
+
nameList[name] && debug$c.repeat(name), nameList[name] = Event;
|
|
1460
1463
|
});
|
|
1461
1464
|
},
|
|
1462
1465
|
changeName(oldName, newName) {
|
|
@@ -2345,7 +2348,7 @@ var LeaferUI = (function (exports) {
|
|
|
2345
2348
|
};
|
|
2346
2349
|
|
|
2347
2350
|
const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
|
|
2348
|
-
const { setPoint: setPoint$
|
|
2351
|
+
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2349
2352
|
const { set, toNumberPoints } = PointHelper;
|
|
2350
2353
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2351
2354
|
const tempPoint$2 = {};
|
|
@@ -2421,8 +2424,8 @@ var LeaferUI = (function (exports) {
|
|
|
2421
2424
|
if (data)
|
|
2422
2425
|
data.push(L$6, x1, y1);
|
|
2423
2426
|
if (setPointBounds) {
|
|
2424
|
-
setPoint$
|
|
2425
|
-
addPoint$
|
|
2427
|
+
setPoint$1(setPointBounds, fromX, fromY);
|
|
2428
|
+
addPoint$1(setPointBounds, x1, y1);
|
|
2426
2429
|
}
|
|
2427
2430
|
if (setStartPoint)
|
|
2428
2431
|
set(setStartPoint, fromX, fromY);
|
|
@@ -2474,7 +2477,7 @@ var LeaferUI = (function (exports) {
|
|
|
2474
2477
|
if (data)
|
|
2475
2478
|
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2476
2479
|
if (setPointBounds)
|
|
2477
|
-
setPoint$
|
|
2480
|
+
setPoint$1(setPointBounds, fromX, fromY);
|
|
2478
2481
|
if (setStartPoint)
|
|
2479
2482
|
set(setStartPoint, fromX, fromY);
|
|
2480
2483
|
for (let i = 0; i < parts; i++) {
|
|
@@ -2536,11 +2539,11 @@ var LeaferUI = (function (exports) {
|
|
|
2536
2539
|
if (0 < t2 && t2 < 1)
|
|
2537
2540
|
tList.push(t2);
|
|
2538
2541
|
}
|
|
2539
|
-
addMode ? addPoint$
|
|
2540
|
-
addPoint$
|
|
2542
|
+
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2543
|
+
addPoint$1(pointBounds, toX, toY);
|
|
2541
2544
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2542
2545
|
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
|
|
2543
|
-
addPoint$
|
|
2546
|
+
addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
|
|
2544
2547
|
}
|
|
2545
2548
|
},
|
|
2546
2549
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2612,7 +2615,7 @@ var LeaferUI = (function (exports) {
|
|
|
2612
2615
|
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2613
2616
|
const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2614
2617
|
const { ellipticalArc } = EllipseHelper;
|
|
2615
|
-
const debug$
|
|
2618
|
+
const debug$b = Debug.get('PathConvert');
|
|
2616
2619
|
const setEndPoint$1 = {};
|
|
2617
2620
|
const PathConvert = {
|
|
2618
2621
|
current: { dot: 0 },
|
|
@@ -2853,7 +2856,7 @@ var LeaferUI = (function (exports) {
|
|
|
2853
2856
|
i += 6;
|
|
2854
2857
|
break;
|
|
2855
2858
|
default:
|
|
2856
|
-
debug$
|
|
2859
|
+
debug$b.error(`command: ${command} [index:${i}]`, old);
|
|
2857
2860
|
return data;
|
|
2858
2861
|
}
|
|
2859
2862
|
lastCommand = command;
|
|
@@ -3078,7 +3081,7 @@ var LeaferUI = (function (exports) {
|
|
|
3078
3081
|
}
|
|
3079
3082
|
|
|
3080
3083
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
3081
|
-
const debug$
|
|
3084
|
+
const debug$a = Debug.get('PathDrawer');
|
|
3082
3085
|
const PathDrawer = {
|
|
3083
3086
|
drawPathByData(drawer, data) {
|
|
3084
3087
|
if (!data)
|
|
@@ -3141,7 +3144,7 @@ var LeaferUI = (function (exports) {
|
|
|
3141
3144
|
i += 6;
|
|
3142
3145
|
break;
|
|
3143
3146
|
default:
|
|
3144
|
-
debug$
|
|
3147
|
+
debug$a.error(`command: ${command} [index:${i}]`, data);
|
|
3145
3148
|
return;
|
|
3146
3149
|
}
|
|
3147
3150
|
}
|
|
@@ -3150,8 +3153,8 @@ var LeaferUI = (function (exports) {
|
|
|
3150
3153
|
|
|
3151
3154
|
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3152
3155
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3153
|
-
const { addPointBounds, copy: copy$8, addPoint
|
|
3154
|
-
const debug$
|
|
3156
|
+
const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3157
|
+
const debug$9 = Debug.get('PathBounds');
|
|
3155
3158
|
let radius, radiusX, radiusY;
|
|
3156
3159
|
const tempPointBounds = {};
|
|
3157
3160
|
const setPointBounds = {};
|
|
@@ -3159,21 +3162,21 @@ var LeaferUI = (function (exports) {
|
|
|
3159
3162
|
const PathBounds = {
|
|
3160
3163
|
toBounds(data, setBounds) {
|
|
3161
3164
|
PathBounds.toTwoPointBounds(data, setPointBounds);
|
|
3162
|
-
toBounds$
|
|
3165
|
+
toBounds$2(setPointBounds, setBounds);
|
|
3163
3166
|
},
|
|
3164
3167
|
toTwoPointBounds(data, setPointBounds) {
|
|
3165
3168
|
if (!data || !data.length)
|
|
3166
|
-
return setPoint
|
|
3169
|
+
return setPoint(setPointBounds, 0, 0);
|
|
3167
3170
|
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3168
3171
|
const len = data.length;
|
|
3169
3172
|
while (i < len) {
|
|
3170
3173
|
command = data[i];
|
|
3171
3174
|
if (i === 0) {
|
|
3172
3175
|
if (command === Z$1 || command === C$1 || command === Q) {
|
|
3173
|
-
setPoint
|
|
3176
|
+
setPoint(setPointBounds, x, y);
|
|
3174
3177
|
}
|
|
3175
3178
|
else {
|
|
3176
|
-
setPoint
|
|
3179
|
+
setPoint(setPointBounds, data[i + 1], data[i + 2]);
|
|
3177
3180
|
}
|
|
3178
3181
|
}
|
|
3179
3182
|
switch (command) {
|
|
@@ -3181,7 +3184,7 @@ var LeaferUI = (function (exports) {
|
|
|
3181
3184
|
case L$2:
|
|
3182
3185
|
x = data[i + 1];
|
|
3183
3186
|
y = data[i + 2];
|
|
3184
|
-
addPoint
|
|
3187
|
+
addPoint(setPointBounds, x, y);
|
|
3185
3188
|
i += 3;
|
|
3186
3189
|
break;
|
|
3187
3190
|
case C$1:
|
|
@@ -3259,7 +3262,7 @@ var LeaferUI = (function (exports) {
|
|
|
3259
3262
|
i += 6;
|
|
3260
3263
|
break;
|
|
3261
3264
|
default:
|
|
3262
|
-
debug$
|
|
3265
|
+
debug$9.error(`command: ${command} [index:${i}]`, data);
|
|
3263
3266
|
return;
|
|
3264
3267
|
}
|
|
3265
3268
|
}
|
|
@@ -3375,7 +3378,7 @@ var LeaferUI = (function (exports) {
|
|
|
3375
3378
|
const F = FileHelper;
|
|
3376
3379
|
F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3377
3380
|
|
|
3378
|
-
const debug$
|
|
3381
|
+
const debug$8 = Debug.get('TaskProcessor');
|
|
3379
3382
|
class TaskItem {
|
|
3380
3383
|
constructor(task) {
|
|
3381
3384
|
this.parallel = true;
|
|
@@ -3390,7 +3393,7 @@ var LeaferUI = (function (exports) {
|
|
|
3390
3393
|
yield this.task();
|
|
3391
3394
|
}
|
|
3392
3395
|
catch (error) {
|
|
3393
|
-
debug$
|
|
3396
|
+
debug$8.error(error);
|
|
3394
3397
|
}
|
|
3395
3398
|
});
|
|
3396
3399
|
}
|
|
@@ -4077,7 +4080,7 @@ var LeaferUI = (function (exports) {
|
|
|
4077
4080
|
defineKey(data, key, property);
|
|
4078
4081
|
}
|
|
4079
4082
|
|
|
4080
|
-
const debug$
|
|
4083
|
+
const debug$7 = new Debug('rewrite');
|
|
4081
4084
|
const list = [];
|
|
4082
4085
|
const excludeNames = ['destroy', 'constructor'];
|
|
4083
4086
|
function rewrite(method) {
|
|
@@ -4094,7 +4097,7 @@ var LeaferUI = (function (exports) {
|
|
|
4094
4097
|
if (list.length) {
|
|
4095
4098
|
list.forEach(item => {
|
|
4096
4099
|
if (error)
|
|
4097
|
-
debug$
|
|
4100
|
+
debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4098
4101
|
item.run();
|
|
4099
4102
|
});
|
|
4100
4103
|
list.length = 0;
|
|
@@ -4811,7 +4814,6 @@ var LeaferUI = (function (exports) {
|
|
|
4811
4814
|
}
|
|
4812
4815
|
}
|
|
4813
4816
|
}
|
|
4814
|
-
LayoutEvent.CHECK_UPDATE = 'layout.check_update';
|
|
4815
4817
|
LayoutEvent.REQUEST = 'layout.request';
|
|
4816
4818
|
LayoutEvent.START = 'layout.start';
|
|
4817
4819
|
LayoutEvent.BEFORE = 'layout.before';
|
|
@@ -5006,13 +5008,13 @@ var LeaferUI = (function (exports) {
|
|
|
5006
5008
|
const LeafEventer = { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroyEventer: destroy };
|
|
5007
5009
|
|
|
5008
5010
|
const { isFinite } = Number;
|
|
5009
|
-
const debug$
|
|
5011
|
+
const debug$6 = Debug.get('setAttr');
|
|
5010
5012
|
const LeafDataProxy = {
|
|
5011
5013
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
5012
5014
|
if (this.leaferIsCreated) {
|
|
5013
5015
|
const oldValue = this.__.__getInput(name);
|
|
5014
5016
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
5015
|
-
debug$
|
|
5017
|
+
debug$6.warn(this.innerName, name, newValue);
|
|
5016
5018
|
newValue = undefined;
|
|
5017
5019
|
}
|
|
5018
5020
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
@@ -5082,7 +5084,7 @@ var LeaferUI = (function (exports) {
|
|
|
5082
5084
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5083
5085
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5084
5086
|
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5085
|
-
const { toBounds: toBounds$
|
|
5087
|
+
const { toBounds: toBounds$1 } = PathBounds;
|
|
5086
5088
|
const LeafBounds = {
|
|
5087
5089
|
__updateWorldBounds() {
|
|
5088
5090
|
toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
|
|
@@ -5164,7 +5166,7 @@ var LeaferUI = (function (exports) {
|
|
|
5164
5166
|
const b = this.__layout.boxBounds;
|
|
5165
5167
|
const data = this.__;
|
|
5166
5168
|
if (data.__pathInputed) {
|
|
5167
|
-
toBounds$
|
|
5169
|
+
toBounds$1(data.path, b);
|
|
5168
5170
|
}
|
|
5169
5171
|
else {
|
|
5170
5172
|
b.x = 0;
|
|
@@ -5712,7 +5714,7 @@ var LeaferUI = (function (exports) {
|
|
|
5712
5714
|
const { setListWithFn } = BoundsHelper;
|
|
5713
5715
|
const { sort } = BranchHelper;
|
|
5714
5716
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5715
|
-
const debug$
|
|
5717
|
+
const debug$5 = new Debug('Branch');
|
|
5716
5718
|
exports.Branch = class Branch extends exports.Leaf {
|
|
5717
5719
|
__updateStrokeSpread() {
|
|
5718
5720
|
const { children } = this;
|
|
@@ -5754,7 +5756,7 @@ var LeaferUI = (function (exports) {
|
|
|
5754
5756
|
}
|
|
5755
5757
|
add(child, index) {
|
|
5756
5758
|
if (child === this || child.destroyed)
|
|
5757
|
-
return debug$
|
|
5759
|
+
return debug$5.warn('add self or destroyed');
|
|
5758
5760
|
const noIndex = index === undefined;
|
|
5759
5761
|
if (!child.__) {
|
|
5760
5762
|
if (child instanceof Array)
|
|
@@ -6008,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6008
6010
|
}
|
|
6009
6011
|
}
|
|
6010
6012
|
|
|
6011
|
-
const version = "1.
|
|
6013
|
+
const version = "1.3.0";
|
|
6012
6014
|
|
|
6013
6015
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6014
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -6076,6 +6078,7 @@ var LeaferUI = (function (exports) {
|
|
|
6076
6078
|
}
|
|
6077
6079
|
Platform.name = 'web';
|
|
6078
6080
|
Platform.isWorker = true;
|
|
6081
|
+
Platform.backgrounder = true;
|
|
6079
6082
|
Platform.requestRender = function (render) { requestAnimationFrame(render); };
|
|
6080
6083
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
6081
6084
|
const { userAgent } = navigator;
|
|
@@ -6282,7 +6285,7 @@ var LeaferUI = (function (exports) {
|
|
|
6282
6285
|
}
|
|
6283
6286
|
|
|
6284
6287
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6285
|
-
const debug$
|
|
6288
|
+
const debug$4 = Debug.get('Layouter');
|
|
6286
6289
|
class Layouter {
|
|
6287
6290
|
constructor(target, userConfig) {
|
|
6288
6291
|
this.totalTimes = 0;
|
|
@@ -6317,7 +6320,7 @@ var LeaferUI = (function (exports) {
|
|
|
6317
6320
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6318
6321
|
}
|
|
6319
6322
|
catch (e) {
|
|
6320
|
-
debug$
|
|
6323
|
+
debug$4.error(e);
|
|
6321
6324
|
}
|
|
6322
6325
|
this.layoutedBlocks = null;
|
|
6323
6326
|
}
|
|
@@ -6331,9 +6334,9 @@ var LeaferUI = (function (exports) {
|
|
|
6331
6334
|
}
|
|
6332
6335
|
layoutOnce() {
|
|
6333
6336
|
if (this.layouting)
|
|
6334
|
-
return debug$
|
|
6337
|
+
return debug$4.warn('layouting');
|
|
6335
6338
|
if (this.times > 3)
|
|
6336
|
-
return debug$
|
|
6339
|
+
return debug$4.warn('layout max times');
|
|
6337
6340
|
this.times++;
|
|
6338
6341
|
this.totalTimes++;
|
|
6339
6342
|
this.layouting = true;
|
|
@@ -6437,7 +6440,7 @@ var LeaferUI = (function (exports) {
|
|
|
6437
6440
|
}
|
|
6438
6441
|
}
|
|
6439
6442
|
|
|
6440
|
-
const debug$
|
|
6443
|
+
const debug$3 = Debug.get('Renderer');
|
|
6441
6444
|
class Renderer {
|
|
6442
6445
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6443
6446
|
constructor(target, canvas, userConfig) {
|
|
@@ -6475,7 +6478,7 @@ var LeaferUI = (function (exports) {
|
|
|
6475
6478
|
const { target } = this;
|
|
6476
6479
|
this.times = 0;
|
|
6477
6480
|
this.totalBounds = new Bounds();
|
|
6478
|
-
debug$
|
|
6481
|
+
debug$3.log(target.innerName, '--->');
|
|
6479
6482
|
try {
|
|
6480
6483
|
if (!target.isApp)
|
|
6481
6484
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6486,9 +6489,9 @@ var LeaferUI = (function (exports) {
|
|
|
6486
6489
|
}
|
|
6487
6490
|
catch (e) {
|
|
6488
6491
|
this.rendering = false;
|
|
6489
|
-
debug$
|
|
6492
|
+
debug$3.error(e);
|
|
6490
6493
|
}
|
|
6491
|
-
debug$
|
|
6494
|
+
debug$3.log('-------------|');
|
|
6492
6495
|
}
|
|
6493
6496
|
renderAgain() {
|
|
6494
6497
|
if (this.rendering) {
|
|
@@ -6500,9 +6503,9 @@ var LeaferUI = (function (exports) {
|
|
|
6500
6503
|
}
|
|
6501
6504
|
renderOnce(callback) {
|
|
6502
6505
|
if (this.rendering)
|
|
6503
|
-
return debug$
|
|
6506
|
+
return debug$3.warn('rendering');
|
|
6504
6507
|
if (this.times > 3)
|
|
6505
|
-
return debug$
|
|
6508
|
+
return debug$3.warn('render max times');
|
|
6506
6509
|
this.times++;
|
|
6507
6510
|
this.totalTimes++;
|
|
6508
6511
|
this.rendering = true;
|
|
@@ -6539,7 +6542,7 @@ var LeaferUI = (function (exports) {
|
|
|
6539
6542
|
partRender() {
|
|
6540
6543
|
const { canvas, updateBlocks: list } = this;
|
|
6541
6544
|
if (!list)
|
|
6542
|
-
return debug$
|
|
6545
|
+
return debug$3.warn('PartRender: need update attr');
|
|
6543
6546
|
this.mergeBlocks();
|
|
6544
6547
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6545
6548
|
this.clipRender(block); });
|
|
@@ -6642,7 +6645,7 @@ var LeaferUI = (function (exports) {
|
|
|
6642
6645
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6643
6646
|
if (empty) {
|
|
6644
6647
|
if (!leaf.isLeafer)
|
|
6645
|
-
debug$
|
|
6648
|
+
debug$3.tip(leaf.innerName, ': empty');
|
|
6646
6649
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6647
6650
|
}
|
|
6648
6651
|
return empty;
|
|
@@ -6808,143 +6811,26 @@ var LeaferUI = (function (exports) {
|
|
|
6808
6811
|
}
|
|
6809
6812
|
}
|
|
6810
6813
|
|
|
6811
|
-
const { Yes, NoAndSkip, YesAndSkip } = exports.Answer;
|
|
6812
|
-
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
6813
6814
|
class Selector {
|
|
6814
6815
|
constructor(target, userConfig) {
|
|
6815
6816
|
this.config = {};
|
|
6816
|
-
this.innerIdMap = {};
|
|
6817
|
-
this.idMap = {};
|
|
6818
|
-
this.methods = {
|
|
6819
|
-
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
6820
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
6821
|
-
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6822
|
-
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
6823
|
-
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
6824
|
-
};
|
|
6825
|
-
this.target = target;
|
|
6826
6817
|
if (userConfig)
|
|
6827
6818
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6828
|
-
this.picker = new Picker(target, this);
|
|
6829
|
-
|
|
6830
|
-
this.__listenEvents();
|
|
6831
|
-
}
|
|
6832
|
-
getBy(condition, branch, one, options) {
|
|
6833
|
-
switch (typeof condition) {
|
|
6834
|
-
case 'number':
|
|
6835
|
-
const leaf = this.getByInnerId(condition, branch);
|
|
6836
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
6837
|
-
case 'string':
|
|
6838
|
-
switch (condition[0]) {
|
|
6839
|
-
case '#':
|
|
6840
|
-
idCondition.id = condition.substring(1), condition = idCondition;
|
|
6841
|
-
break;
|
|
6842
|
-
case '.':
|
|
6843
|
-
classNameCondition.className = condition.substring(1), condition = classNameCondition;
|
|
6844
|
-
break;
|
|
6845
|
-
default:
|
|
6846
|
-
tagCondition.tag = condition, condition = tagCondition;
|
|
6847
|
-
}
|
|
6848
|
-
case 'object':
|
|
6849
|
-
if (condition.id !== undefined) {
|
|
6850
|
-
const leaf = this.getById(condition.id, branch);
|
|
6851
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
6852
|
-
}
|
|
6853
|
-
else if (condition.tag) {
|
|
6854
|
-
const { tag } = condition, isArray = tag instanceof Array;
|
|
6855
|
-
return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
|
|
6856
|
-
}
|
|
6857
|
-
else {
|
|
6858
|
-
return this.getByMethod(this.methods.className, branch, one, condition.className);
|
|
6859
|
-
}
|
|
6860
|
-
case 'function':
|
|
6861
|
-
return this.getByMethod(condition, branch, one, options);
|
|
6862
|
-
}
|
|
6819
|
+
this.picker = new Picker(this.target = target, this);
|
|
6820
|
+
this.finder = Creator.finder && Creator.finder();
|
|
6863
6821
|
}
|
|
6864
6822
|
getByPoint(hitPoint, hitRadius, options) {
|
|
6865
|
-
if (Platform.
|
|
6866
|
-
this.target.
|
|
6823
|
+
if (Platform.backgrounder && this.target)
|
|
6824
|
+
this.target.updateLayout();
|
|
6867
6825
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
6868
6826
|
}
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
if (cache)
|
|
6872
|
-
return cache;
|
|
6873
|
-
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
6874
|
-
return this.findLeaf;
|
|
6875
|
-
}
|
|
6876
|
-
getById(id, branch) {
|
|
6877
|
-
const cache = this.idMap[id];
|
|
6878
|
-
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
6879
|
-
return cache;
|
|
6880
|
-
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
6881
|
-
return this.findLeaf;
|
|
6882
|
-
}
|
|
6883
|
-
getByClassName(className, branch) {
|
|
6884
|
-
return this.getByMethod(this.methods.className, branch, false, className);
|
|
6885
|
-
}
|
|
6886
|
-
getByTag(tag, branch) {
|
|
6887
|
-
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
6888
|
-
}
|
|
6889
|
-
getByMethod(method, branch, one, options) {
|
|
6890
|
-
const list = one ? null : [];
|
|
6891
|
-
this.eachFind(this.toChildren(branch), method, list, options);
|
|
6892
|
-
return list || this.findLeaf;
|
|
6893
|
-
}
|
|
6894
|
-
eachFind(children, method, list, options) {
|
|
6895
|
-
let child, result;
|
|
6896
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
6897
|
-
child = children[i];
|
|
6898
|
-
result = method(child, options);
|
|
6899
|
-
if (result === Yes || result === YesAndSkip) {
|
|
6900
|
-
if (list) {
|
|
6901
|
-
list.push(child);
|
|
6902
|
-
}
|
|
6903
|
-
else {
|
|
6904
|
-
this.findLeaf = child;
|
|
6905
|
-
return;
|
|
6906
|
-
}
|
|
6907
|
-
}
|
|
6908
|
-
if (child.isBranch && result < NoAndSkip)
|
|
6909
|
-
this.eachFind(child.children, method, list, options);
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
toChildren(branch) {
|
|
6913
|
-
this.findLeaf = null;
|
|
6914
|
-
return [branch || this.target];
|
|
6915
|
-
}
|
|
6916
|
-
__onRemoveChild(event) {
|
|
6917
|
-
const { id, innerId } = event.child;
|
|
6918
|
-
if (this.idMap[id])
|
|
6919
|
-
delete this.idMap[id];
|
|
6920
|
-
if (this.innerIdMap[innerId])
|
|
6921
|
-
delete this.innerIdMap[innerId];
|
|
6922
|
-
}
|
|
6923
|
-
__checkIdChange(event) {
|
|
6924
|
-
if (event.attrName === 'id') {
|
|
6925
|
-
const id = event.oldValue;
|
|
6926
|
-
if (this.idMap[id])
|
|
6927
|
-
delete this.idMap[id];
|
|
6928
|
-
}
|
|
6929
|
-
}
|
|
6930
|
-
__listenEvents() {
|
|
6931
|
-
this.__eventIds = [
|
|
6932
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
6933
|
-
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
6934
|
-
];
|
|
6935
|
-
}
|
|
6936
|
-
__removeListenEvents() {
|
|
6937
|
-
this.target.off_(this.__eventIds);
|
|
6938
|
-
this.__eventIds.length = 0;
|
|
6827
|
+
getBy(condition, branch, one, options) {
|
|
6828
|
+
return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
|
|
6939
6829
|
}
|
|
6940
6830
|
destroy() {
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
this.
|
|
6944
|
-
this.findLeaf = null;
|
|
6945
|
-
this.innerIdMap = {};
|
|
6946
|
-
this.idMap = {};
|
|
6947
|
-
}
|
|
6831
|
+
this.picker.destroy();
|
|
6832
|
+
if (this.finder)
|
|
6833
|
+
this.finder.destroy();
|
|
6948
6834
|
}
|
|
6949
6835
|
}
|
|
6950
6836
|
|
|
@@ -7017,7 +6903,7 @@ var LeaferUI = (function (exports) {
|
|
|
7017
6903
|
|
|
7018
6904
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7019
6905
|
const emptyPaint = {};
|
|
7020
|
-
const debug$
|
|
6906
|
+
const debug$2 = Debug.get('UIData');
|
|
7021
6907
|
class UIData extends LeafData {
|
|
7022
6908
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
7023
6909
|
get __strokeWidth() {
|
|
@@ -7054,7 +6940,7 @@ var LeaferUI = (function (exports) {
|
|
|
7054
6940
|
if (value < 0) {
|
|
7055
6941
|
this._width = -value;
|
|
7056
6942
|
this.__leaf.scaleX *= -1;
|
|
7057
|
-
debug$
|
|
6943
|
+
debug$2.warn('width < 0, instead -scaleX ', this);
|
|
7058
6944
|
}
|
|
7059
6945
|
else
|
|
7060
6946
|
this._width = value;
|
|
@@ -7063,7 +6949,7 @@ var LeaferUI = (function (exports) {
|
|
|
7063
6949
|
if (value < 0) {
|
|
7064
6950
|
this._height = -value;
|
|
7065
6951
|
this.__leaf.scaleY *= -1;
|
|
7066
|
-
debug$
|
|
6952
|
+
debug$2.warn('height < 0, instead -scaleY', this);
|
|
7067
6953
|
}
|
|
7068
6954
|
else
|
|
7069
6955
|
this._height = value;
|
|
@@ -7440,25 +7326,27 @@ var LeaferUI = (function (exports) {
|
|
|
7440
7326
|
}
|
|
7441
7327
|
reset(_data) { }
|
|
7442
7328
|
set(data, transition) {
|
|
7443
|
-
if (
|
|
7444
|
-
if (transition
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7329
|
+
if (data) {
|
|
7330
|
+
if (transition) {
|
|
7331
|
+
if (transition === 'temp') {
|
|
7332
|
+
this.lockNormalStyle = true;
|
|
7333
|
+
Object.assign(this, data);
|
|
7334
|
+
this.lockNormalStyle = false;
|
|
7335
|
+
}
|
|
7336
|
+
else
|
|
7337
|
+
this.animate(data, transition);
|
|
7448
7338
|
}
|
|
7449
7339
|
else
|
|
7450
|
-
|
|
7340
|
+
Object.assign(this, data);
|
|
7451
7341
|
}
|
|
7452
|
-
else
|
|
7453
|
-
Object.assign(this, data);
|
|
7454
7342
|
}
|
|
7455
7343
|
get(name) {
|
|
7456
7344
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
7457
7345
|
}
|
|
7458
7346
|
createProxyData() { return undefined; }
|
|
7459
|
-
find(_condition, _options) { return
|
|
7347
|
+
find(_condition, _options) { return Plugin.need('find'); }
|
|
7460
7348
|
findTag(tag) { return this.find({ tag }); }
|
|
7461
|
-
findOne(_condition, _options) { return
|
|
7349
|
+
findOne(_condition, _options) { return Plugin.need('find'); }
|
|
7462
7350
|
findId(id) { return this.findOne({ id }); }
|
|
7463
7351
|
getPath(curve, pathForRender) {
|
|
7464
7352
|
this.__layout.update();
|
|
@@ -7510,9 +7398,9 @@ var LeaferUI = (function (exports) {
|
|
|
7510
7398
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7511
7399
|
return Plugin.need('animate');
|
|
7512
7400
|
}
|
|
7513
|
-
killAnimate(_type) { }
|
|
7514
|
-
export(
|
|
7515
|
-
return
|
|
7401
|
+
killAnimate(_type, _killStyle) { }
|
|
7402
|
+
export(_filename, _options) {
|
|
7403
|
+
return Plugin.need('export');
|
|
7516
7404
|
}
|
|
7517
7405
|
clone(data) {
|
|
7518
7406
|
const json = this.toJSON();
|
|
@@ -7758,16 +7646,18 @@ var LeaferUI = (function (exports) {
|
|
|
7758
7646
|
this.children = [];
|
|
7759
7647
|
}
|
|
7760
7648
|
set(data, transition) {
|
|
7761
|
-
if (data
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7649
|
+
if (data) {
|
|
7650
|
+
if (data.children) {
|
|
7651
|
+
const { children } = data;
|
|
7652
|
+
delete data.children;
|
|
7653
|
+
this.children ? this.clear() : this.__setBranch();
|
|
7654
|
+
super.set(data, transition);
|
|
7655
|
+
children.forEach(child => this.add(child));
|
|
7656
|
+
data.children = children;
|
|
7657
|
+
}
|
|
7658
|
+
else
|
|
7659
|
+
super.set(data, transition);
|
|
7768
7660
|
}
|
|
7769
|
-
else
|
|
7770
|
-
super.set(data, transition);
|
|
7771
7661
|
}
|
|
7772
7662
|
toJSON(options) {
|
|
7773
7663
|
const data = super.toJSON(options);
|
|
@@ -7799,7 +7689,7 @@ var LeaferUI = (function (exports) {
|
|
|
7799
7689
|
], exports.Group);
|
|
7800
7690
|
|
|
7801
7691
|
var Leafer_1;
|
|
7802
|
-
const debug$
|
|
7692
|
+
const debug$1 = Debug.get('Leafer');
|
|
7803
7693
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
7804
7694
|
get __tag() { return 'Leafer'; }
|
|
7805
7695
|
get isApp() { return false; }
|
|
@@ -7964,7 +7854,7 @@ var LeaferUI = (function (exports) {
|
|
|
7964
7854
|
if (this.canvas) {
|
|
7965
7855
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7966
7856
|
if (!newValue)
|
|
7967
|
-
debug$
|
|
7857
|
+
debug$1.warn(attrName + ' is 0');
|
|
7968
7858
|
this.__changeCanvasSize(attrName, newValue);
|
|
7969
7859
|
}
|
|
7970
7860
|
else if (attrName === 'fill') {
|
|
@@ -8105,9 +7995,6 @@ var LeaferUI = (function (exports) {
|
|
|
8105
7995
|
this.canvas && this.canvas.updateClientBounds();
|
|
8106
7996
|
}
|
|
8107
7997
|
receiveEvent(_event) { }
|
|
8108
|
-
__checkUpdateLayout() {
|
|
8109
|
-
this.__layout.update();
|
|
8110
|
-
}
|
|
8111
7998
|
emitLeafer(type) {
|
|
8112
7999
|
this.emitEvent(new LeaferEvent(type, this));
|
|
8113
8000
|
}
|
|
@@ -8118,7 +8005,7 @@ var LeaferUI = (function (exports) {
|
|
|
8118
8005
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
8119
8006
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
8120
8007
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
8121
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this)
|
|
8008
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8122
8009
|
}
|
|
8123
8010
|
__removeListenEvents() {
|
|
8124
8011
|
this.off_(this.__eventIds);
|
|
@@ -8149,7 +8036,7 @@ var LeaferUI = (function (exports) {
|
|
|
8149
8036
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
8150
8037
|
}
|
|
8151
8038
|
catch (e) {
|
|
8152
|
-
debug$
|
|
8039
|
+
debug$1.error(e);
|
|
8153
8040
|
}
|
|
8154
8041
|
}
|
|
8155
8042
|
};
|
|
@@ -8183,7 +8070,7 @@ var LeaferUI = (function (exports) {
|
|
|
8183
8070
|
], exports.Rect);
|
|
8184
8071
|
|
|
8185
8072
|
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8186
|
-
const rect$1 = exports.Rect.prototype, group
|
|
8073
|
+
const rect$1 = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8187
8074
|
const childrenRenderBounds = {};
|
|
8188
8075
|
exports.Box = class Box extends exports.Group {
|
|
8189
8076
|
get __tag() { return 'Box'; }
|
|
@@ -8293,7 +8180,7 @@ var LeaferUI = (function (exports) {
|
|
|
8293
8180
|
rewrite(rect$1.__render)
|
|
8294
8181
|
], exports.Box.prototype, "__renderRect", null);
|
|
8295
8182
|
__decorate([
|
|
8296
|
-
rewrite(group
|
|
8183
|
+
rewrite(group.__render)
|
|
8297
8184
|
], exports.Box.prototype, "__renderGroup", null);
|
|
8298
8185
|
exports.Box = __decorate([
|
|
8299
8186
|
rewriteAble(),
|
|
@@ -8378,7 +8265,7 @@ var LeaferUI = (function (exports) {
|
|
|
8378
8265
|
|
|
8379
8266
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8380
8267
|
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
8381
|
-
const { toBounds
|
|
8268
|
+
const { toBounds } = PathBounds;
|
|
8382
8269
|
exports.Line = class Line extends exports.UI {
|
|
8383
8270
|
get __tag() { return 'Line'; }
|
|
8384
8271
|
get toPoint() {
|
|
@@ -8422,7 +8309,7 @@ var LeaferUI = (function (exports) {
|
|
|
8422
8309
|
}
|
|
8423
8310
|
__updateBoxBounds() {
|
|
8424
8311
|
if (this.points) {
|
|
8425
|
-
toBounds
|
|
8312
|
+
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8426
8313
|
}
|
|
8427
8314
|
else
|
|
8428
8315
|
super.__updateBoxBounds();
|
|
@@ -8774,6 +8661,9 @@ var LeaferUI = (function (exports) {
|
|
|
8774
8661
|
__decorate([
|
|
8775
8662
|
boundsType(0)
|
|
8776
8663
|
], exports.Text.prototype, "paraSpacing", void 0);
|
|
8664
|
+
__decorate([
|
|
8665
|
+
boundsType('x')
|
|
8666
|
+
], exports.Text.prototype, "writingMode", void 0);
|
|
8777
8667
|
__decorate([
|
|
8778
8668
|
boundsType('left')
|
|
8779
8669
|
], exports.Text.prototype, "textAlign", void 0);
|
|
@@ -8960,8 +8850,8 @@ var LeaferUI = (function (exports) {
|
|
|
8960
8850
|
this.children.forEach(leafer => leafer.resize(event));
|
|
8961
8851
|
super.__onResize(event);
|
|
8962
8852
|
}
|
|
8963
|
-
|
|
8964
|
-
this.children.forEach(leafer => leafer.
|
|
8853
|
+
updateLayout() {
|
|
8854
|
+
this.children.forEach(leafer => leafer.updateLayout());
|
|
8965
8855
|
}
|
|
8966
8856
|
__getChildConfig(userConfig) {
|
|
8967
8857
|
let config = Object.assign({}, this.config);
|
|
@@ -9451,7 +9341,7 @@ var LeaferUI = (function (exports) {
|
|
|
9451
9341
|
}
|
|
9452
9342
|
}
|
|
9453
9343
|
|
|
9454
|
-
const debug
|
|
9344
|
+
const debug = Debug.get('emit');
|
|
9455
9345
|
function emit$1(type, data, path, excludePath) {
|
|
9456
9346
|
if (!path && !data.path)
|
|
9457
9347
|
return;
|
|
@@ -9481,7 +9371,7 @@ var LeaferUI = (function (exports) {
|
|
|
9481
9371
|
}
|
|
9482
9372
|
}
|
|
9483
9373
|
catch (e) {
|
|
9484
|
-
debug
|
|
9374
|
+
debug.error(e);
|
|
9485
9375
|
}
|
|
9486
9376
|
}
|
|
9487
9377
|
const allowTypes = ['move', 'zoom', 'rotate', 'key'];
|
|
@@ -10038,8 +9928,8 @@ var LeaferUI = (function (exports) {
|
|
|
10038
9928
|
this.__drawRenderPath(canvas); };
|
|
10039
9929
|
|
|
10040
9930
|
const matrix = new Matrix();
|
|
10041
|
-
const ui$
|
|
10042
|
-
ui$
|
|
9931
|
+
const ui$1 = exports.UI.prototype;
|
|
9932
|
+
ui$1.__updateHitCanvas = function () {
|
|
10043
9933
|
const data = this.__, { hitCanvasManager } = this.leafer;
|
|
10044
9934
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10045
9935
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
@@ -10066,7 +9956,7 @@ var LeaferUI = (function (exports) {
|
|
|
10066
9956
|
this.__drawHitPath(h);
|
|
10067
9957
|
h.setStrokeOptions(data);
|
|
10068
9958
|
};
|
|
10069
|
-
ui$
|
|
9959
|
+
ui$1.__hit = function (inner) {
|
|
10070
9960
|
if (Platform.name === 'miniapp')
|
|
10071
9961
|
this.__drawHitPath(this.__hitCanvas);
|
|
10072
9962
|
const data = this.__;
|
|
@@ -10106,43 +9996,35 @@ var LeaferUI = (function (exports) {
|
|
|
10106
9996
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10107
9997
|
};
|
|
10108
9998
|
|
|
10109
|
-
const ui
|
|
9999
|
+
const ui = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
10110
10000
|
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10111
10001
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10112
|
-
ui
|
|
10002
|
+
ui.__updateHitCanvas.call(this);
|
|
10113
10003
|
else if (this.__hitCanvas)
|
|
10114
10004
|
this.__hitCanvas = null;
|
|
10115
10005
|
};
|
|
10116
10006
|
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10117
|
-
return this.__hitCanvas ? ui
|
|
10007
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10118
10008
|
};
|
|
10119
10009
|
|
|
10120
|
-
const ui = exports.UI.prototype, group = exports.Group.prototype;
|
|
10121
10010
|
function getSelector(ui) {
|
|
10122
10011
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10123
10012
|
}
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
ui.findOne = function (condition, options) {
|
|
10128
|
-
return getSelector(this).getBy(condition, this, true, options);
|
|
10129
|
-
};
|
|
10130
|
-
group.pick = function (hitPoint, options) {
|
|
10131
|
-
this.__layout.update();
|
|
10132
|
-
if (!options)
|
|
10133
|
-
options = {};
|
|
10013
|
+
exports.Group.prototype.pick = function (hitPoint, options) {
|
|
10014
|
+
this.leafer || this.updateLayout();
|
|
10015
|
+
options || (options = emptyData);
|
|
10134
10016
|
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10135
10017
|
};
|
|
10136
10018
|
|
|
10137
|
-
const canvas
|
|
10138
|
-
canvas
|
|
10019
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
10020
|
+
canvas.hitFill = function (point, fillRule) {
|
|
10139
10021
|
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
10140
10022
|
};
|
|
10141
|
-
canvas
|
|
10023
|
+
canvas.hitStroke = function (point, strokeWidth) {
|
|
10142
10024
|
this.strokeWidth = strokeWidth;
|
|
10143
10025
|
return this.context.isPointInStroke(point.x, point.y);
|
|
10144
10026
|
};
|
|
10145
|
-
canvas
|
|
10027
|
+
canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
10146
10028
|
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
10147
10029
|
if (offset)
|
|
10148
10030
|
x -= offset.x, y -= offset.y;
|
|
@@ -11634,197 +11516,12 @@ var LeaferUI = (function (exports) {
|
|
|
11634
11516
|
string
|
|
11635
11517
|
};
|
|
11636
11518
|
|
|
11637
|
-
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
11638
|
-
function getTrimBounds(canvas) {
|
|
11639
|
-
const { width, height } = canvas.view;
|
|
11640
|
-
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
11641
|
-
let x, y, pointBounds, index = 0;
|
|
11642
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
11643
|
-
if (data[i + 3] !== 0) {
|
|
11644
|
-
x = index % width;
|
|
11645
|
-
y = (index - x) / width;
|
|
11646
|
-
pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
|
|
11647
|
-
}
|
|
11648
|
-
index++;
|
|
11649
|
-
}
|
|
11650
|
-
const bounds = new Bounds();
|
|
11651
|
-
toBounds(pointBounds, bounds);
|
|
11652
|
-
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
11653
|
-
}
|
|
11654
|
-
|
|
11655
|
-
const ExportModule = {
|
|
11656
|
-
export(leaf, filename, options) {
|
|
11657
|
-
this.running = true;
|
|
11658
|
-
const fileType = FileHelper.fileType(filename);
|
|
11659
|
-
const isDownload = filename.includes('.');
|
|
11660
|
-
options = FileHelper.getExportOptions(options);
|
|
11661
|
-
return addTask((success) => new Promise((resolve) => {
|
|
11662
|
-
const over = (result) => {
|
|
11663
|
-
success(result);
|
|
11664
|
-
resolve();
|
|
11665
|
-
this.running = false;
|
|
11666
|
-
};
|
|
11667
|
-
const { toURL } = Platform;
|
|
11668
|
-
const { download } = Platform.origin;
|
|
11669
|
-
if (fileType === 'json') {
|
|
11670
|
-
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11671
|
-
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11672
|
-
}
|
|
11673
|
-
if (fileType === 'svg') {
|
|
11674
|
-
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11675
|
-
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11676
|
-
}
|
|
11677
|
-
const { leafer } = leaf;
|
|
11678
|
-
if (leafer) {
|
|
11679
|
-
checkLazy(leaf);
|
|
11680
|
-
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
11681
|
-
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
11682
|
-
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
11683
|
-
const { slice, trim, onCanvas } = options;
|
|
11684
|
-
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
11685
|
-
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
11686
|
-
const screenshot = options.screenshot || leaf.isApp;
|
|
11687
|
-
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
11688
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
11689
|
-
if (screenshot) {
|
|
11690
|
-
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
11691
|
-
}
|
|
11692
|
-
else {
|
|
11693
|
-
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
11694
|
-
scaleX = worldTransform.scaleX;
|
|
11695
|
-
scaleY = worldTransform.scaleY;
|
|
11696
|
-
switch (relative) {
|
|
11697
|
-
case 'inner':
|
|
11698
|
-
matrix.set(worldTransform);
|
|
11699
|
-
break;
|
|
11700
|
-
case 'local':
|
|
11701
|
-
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
11702
|
-
scaleX /= leaf.scaleX;
|
|
11703
|
-
scaleY /= leaf.scaleY;
|
|
11704
|
-
break;
|
|
11705
|
-
case 'world':
|
|
11706
|
-
scaleX = 1;
|
|
11707
|
-
scaleY = 1;
|
|
11708
|
-
break;
|
|
11709
|
-
case 'page':
|
|
11710
|
-
relative = leaf.leafer;
|
|
11711
|
-
default:
|
|
11712
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
11713
|
-
const l = relative.worldTransform;
|
|
11714
|
-
scaleX /= scaleX / l.scaleX;
|
|
11715
|
-
scaleY /= scaleY / l.scaleY;
|
|
11716
|
-
}
|
|
11717
|
-
renderBounds = leaf.getBounds('render', relative);
|
|
11718
|
-
}
|
|
11719
|
-
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
11720
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
11721
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
11722
|
-
if (leaf.isApp) {
|
|
11723
|
-
scaleData.scaleX *= pixelRatio;
|
|
11724
|
-
scaleData.scaleY *= pixelRatio;
|
|
11725
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
11726
|
-
}
|
|
11727
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
11728
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
11729
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
11730
|
-
let sliceLeaf;
|
|
11731
|
-
if (slice) {
|
|
11732
|
-
sliceLeaf = leaf;
|
|
11733
|
-
sliceLeaf.__worldOpacity = 0;
|
|
11734
|
-
leaf = leafer;
|
|
11735
|
-
renderOptions.bounds = canvas.bounds;
|
|
11736
|
-
}
|
|
11737
|
-
canvas.save();
|
|
11738
|
-
if (isFrame && fill !== undefined) {
|
|
11739
|
-
const oldFill = leaf.get('fill');
|
|
11740
|
-
leaf.fill = '';
|
|
11741
|
-
leaf.__render(canvas, renderOptions);
|
|
11742
|
-
leaf.fill = oldFill;
|
|
11743
|
-
}
|
|
11744
|
-
else {
|
|
11745
|
-
leaf.__render(canvas, renderOptions);
|
|
11746
|
-
}
|
|
11747
|
-
canvas.restore();
|
|
11748
|
-
if (sliceLeaf)
|
|
11749
|
-
sliceLeaf.__updateWorldOpacity();
|
|
11750
|
-
if (trim) {
|
|
11751
|
-
trimBounds = getTrimBounds(canvas);
|
|
11752
|
-
const old = canvas, { width, height } = trimBounds;
|
|
11753
|
-
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
11754
|
-
canvas = Creator.canvas(config);
|
|
11755
|
-
canvas.copyWorld(old, trimBounds, config);
|
|
11756
|
-
}
|
|
11757
|
-
if (needFill)
|
|
11758
|
-
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
11759
|
-
if (onCanvas)
|
|
11760
|
-
onCanvas(canvas);
|
|
11761
|
-
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
11762
|
-
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
11763
|
-
}));
|
|
11764
|
-
}
|
|
11765
|
-
else {
|
|
11766
|
-
over({ data: false });
|
|
11767
|
-
}
|
|
11768
|
-
}));
|
|
11769
|
-
}
|
|
11770
|
-
};
|
|
11771
|
-
let tasker;
|
|
11772
|
-
function addTask(task) {
|
|
11773
|
-
if (!tasker)
|
|
11774
|
-
tasker = new TaskProcessor();
|
|
11775
|
-
return new Promise((resolve) => {
|
|
11776
|
-
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
11777
|
-
});
|
|
11778
|
-
}
|
|
11779
|
-
function checkLazy(leaf) {
|
|
11780
|
-
if (leaf.__.__needComputePaint)
|
|
11781
|
-
leaf.__.__computePaint();
|
|
11782
|
-
if (leaf.isBranch)
|
|
11783
|
-
leaf.children.forEach(child => checkLazy(child));
|
|
11784
|
-
}
|
|
11785
|
-
|
|
11786
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
11787
|
-
const debug = Debug.get('@leafer-ui/export');
|
|
11788
|
-
canvas.export = function (filename, options) {
|
|
11789
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
11790
|
-
if (filename.includes('.'))
|
|
11791
|
-
return this.saveAs(filename, quality);
|
|
11792
|
-
else if (blob)
|
|
11793
|
-
return this.toBlob(filename, quality);
|
|
11794
|
-
else
|
|
11795
|
-
return this.toDataURL(filename, quality);
|
|
11796
|
-
};
|
|
11797
|
-
canvas.toBlob = function (type, quality) {
|
|
11798
|
-
return new Promise((resolve) => {
|
|
11799
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
11800
|
-
resolve(blob);
|
|
11801
|
-
}).catch((e) => {
|
|
11802
|
-
debug.error(e);
|
|
11803
|
-
resolve(null);
|
|
11804
|
-
});
|
|
11805
|
-
});
|
|
11806
|
-
};
|
|
11807
|
-
canvas.toDataURL = function (type, quality) {
|
|
11808
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
11809
|
-
};
|
|
11810
|
-
canvas.saveAs = function (filename, quality) {
|
|
11811
|
-
return new Promise((resolve) => {
|
|
11812
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
11813
|
-
resolve(true);
|
|
11814
|
-
}).catch((e) => {
|
|
11815
|
-
debug.error(e);
|
|
11816
|
-
resolve(false);
|
|
11817
|
-
});
|
|
11818
|
-
});
|
|
11819
|
-
};
|
|
11820
|
-
|
|
11821
11519
|
Object.assign(TextConvert, TextConvertModule);
|
|
11822
11520
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
11823
11521
|
Object.assign(Paint, PaintModule);
|
|
11824
11522
|
Object.assign(PaintImage, PaintImageModule);
|
|
11825
11523
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
11826
11524
|
Object.assign(Effect, EffectModule);
|
|
11827
|
-
Object.assign(Export, ExportModule);
|
|
11828
11525
|
|
|
11829
11526
|
Object.assign(Creator, {
|
|
11830
11527
|
interaction: (target, canvas, selector, options) => new InteractionBase(target, canvas, selector, options),
|
|
@@ -11914,6 +11611,7 @@ var LeaferUI = (function (exports) {
|
|
|
11914
11611
|
exports.PathNumberCommandLengthMap = PathNumberCommandLengthMap;
|
|
11915
11612
|
exports.PathNumberCommandMap = PathNumberCommandMap;
|
|
11916
11613
|
exports.PenData = PenData;
|
|
11614
|
+
exports.Picker = Picker;
|
|
11917
11615
|
exports.Platform = Platform;
|
|
11918
11616
|
exports.Plugin = Plugin;
|
|
11919
11617
|
exports.Point = Point;
|