@leafer-draw/worker 1.2.1 → 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 +13 -197
- package/dist/worker.esm.js +14 -198
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +133 -302
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +133 -302
- package/dist/worker.module.min.js +1 -1
- package/package.json +7 -6
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$d = 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$d.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$c = 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$c.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$c.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$b = 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$b.repeat(name), nameList[name] = Event;
|
|
1460
1463
|
});
|
|
1461
1464
|
},
|
|
1462
1465
|
changeName(oldName, newName) {
|
|
@@ -2050,11 +2053,11 @@ var LeaferUI = (function (exports) {
|
|
|
2050
2053
|
toBlob(_type, _quality) { return undefined; }
|
|
2051
2054
|
toDataURL(_type, _quality) { return undefined; }
|
|
2052
2055
|
saveAs(_filename, _quality) { return undefined; }
|
|
2053
|
-
resize(size) {
|
|
2056
|
+
resize(size, safeResize = true) {
|
|
2054
2057
|
if (this.isSameSize(size))
|
|
2055
2058
|
return;
|
|
2056
2059
|
let takeCanvas;
|
|
2057
|
-
if (this.context && !this.unreal && this.width) {
|
|
2060
|
+
if (this.context && !this.unreal && safeResize && this.width) {
|
|
2058
2061
|
takeCanvas = this.getSameCanvas();
|
|
2059
2062
|
takeCanvas.copyWorld(this);
|
|
2060
2063
|
}
|
|
@@ -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$2, 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$a = 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$a.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$9 = 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$9.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$7, addPoint
|
|
3154
|
-
const debug$
|
|
3156
|
+
const { addPointBounds, copy: copy$7, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3157
|
+
const debug$8 = 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$8.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$7 = 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$7.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$6 = 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$6.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4098
4101
|
item.run();
|
|
4099
4102
|
});
|
|
4100
4103
|
list.length = 0;
|
|
@@ -4256,18 +4259,21 @@ var LeaferUI = (function (exports) {
|
|
|
4256
4259
|
L.setTransform(t, matrix, resize);
|
|
4257
4260
|
},
|
|
4258
4261
|
setTransform(t, transform, resize) {
|
|
4259
|
-
const
|
|
4262
|
+
const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
|
|
4263
|
+
const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
|
|
4260
4264
|
if (resize) {
|
|
4261
|
-
const scaleX = layout.scaleX / t.scaleX;
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
+
const scaleX = layout.scaleX / t.scaleX, scaleY = layout.scaleY / t.scaleY;
|
|
4266
|
+
delete layout.scaleX, delete layout.scaleY;
|
|
4267
|
+
if (originPoint) {
|
|
4268
|
+
BoundsHelper.scale(t.boxBounds, Math.abs(scaleX), Math.abs(scaleY));
|
|
4269
|
+
const changedPoint = L.getInnerOrigin(t, data.origin);
|
|
4270
|
+
PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
|
|
4271
|
+
}
|
|
4265
4272
|
t.set(layout);
|
|
4266
|
-
t.scaleResize(scaleX, scaleY,
|
|
4273
|
+
t.scaleResize(scaleX, scaleY, false);
|
|
4267
4274
|
}
|
|
4268
|
-
else
|
|
4275
|
+
else
|
|
4269
4276
|
t.set(layout);
|
|
4270
|
-
}
|
|
4271
4277
|
},
|
|
4272
4278
|
getFlipTransform(t, axis) {
|
|
4273
4279
|
const m = getMatrixData();
|
|
@@ -4808,7 +4814,6 @@ var LeaferUI = (function (exports) {
|
|
|
4808
4814
|
}
|
|
4809
4815
|
}
|
|
4810
4816
|
}
|
|
4811
|
-
LayoutEvent.CHECK_UPDATE = 'layout.check_update';
|
|
4812
4817
|
LayoutEvent.REQUEST = 'layout.request';
|
|
4813
4818
|
LayoutEvent.START = 'layout.start';
|
|
4814
4819
|
LayoutEvent.BEFORE = 'layout.before';
|
|
@@ -4950,14 +4955,15 @@ var LeaferUI = (function (exports) {
|
|
|
4950
4955
|
if (list) {
|
|
4951
4956
|
let item;
|
|
4952
4957
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
4953
|
-
item = list[i]
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
+
if (item = list[i]) {
|
|
4959
|
+
item.listener(event);
|
|
4960
|
+
if (item.once) {
|
|
4961
|
+
this.off(type, item.listener, capture);
|
|
4962
|
+
i--, len--;
|
|
4963
|
+
}
|
|
4964
|
+
if (event && event.isStopNow)
|
|
4965
|
+
break;
|
|
4958
4966
|
}
|
|
4959
|
-
if (event && event.isStopNow)
|
|
4960
|
-
break;
|
|
4961
4967
|
}
|
|
4962
4968
|
}
|
|
4963
4969
|
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
@@ -5002,13 +5008,13 @@ var LeaferUI = (function (exports) {
|
|
|
5002
5008
|
const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
|
|
5003
5009
|
|
|
5004
5010
|
const { isFinite } = Number;
|
|
5005
|
-
const debug$
|
|
5011
|
+
const debug$5 = Debug.get('setAttr');
|
|
5006
5012
|
const LeafDataProxy = {
|
|
5007
5013
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
5008
5014
|
if (this.leaferIsCreated) {
|
|
5009
5015
|
const oldValue = this.__.__getInput(name);
|
|
5010
5016
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
5011
|
-
debug$
|
|
5017
|
+
debug$5.warn(this.innerName, name, newValue);
|
|
5012
5018
|
newValue = undefined;
|
|
5013
5019
|
}
|
|
5014
5020
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
@@ -5078,7 +5084,7 @@ var LeaferUI = (function (exports) {
|
|
|
5078
5084
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5079
5085
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5080
5086
|
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
|
|
5081
|
-
const { toBounds: toBounds$
|
|
5087
|
+
const { toBounds: toBounds$1 } = PathBounds;
|
|
5082
5088
|
const LeafBounds = {
|
|
5083
5089
|
__updateWorldBounds() {
|
|
5084
5090
|
toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
|
|
@@ -5160,7 +5166,7 @@ var LeaferUI = (function (exports) {
|
|
|
5160
5166
|
const b = this.__layout.boxBounds;
|
|
5161
5167
|
const data = this.__;
|
|
5162
5168
|
if (data.__pathInputed) {
|
|
5163
|
-
toBounds$
|
|
5169
|
+
toBounds$1(data.path, b);
|
|
5164
5170
|
}
|
|
5165
5171
|
else {
|
|
5166
5172
|
b.x = 0;
|
|
@@ -5708,7 +5714,7 @@ var LeaferUI = (function (exports) {
|
|
|
5708
5714
|
const { setListWithFn } = BoundsHelper;
|
|
5709
5715
|
const { sort } = BranchHelper;
|
|
5710
5716
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5711
|
-
const debug$
|
|
5717
|
+
const debug$4 = new Debug('Branch');
|
|
5712
5718
|
exports.Branch = class Branch extends exports.Leaf {
|
|
5713
5719
|
__updateStrokeSpread() {
|
|
5714
5720
|
const { children } = this;
|
|
@@ -5750,7 +5756,7 @@ var LeaferUI = (function (exports) {
|
|
|
5750
5756
|
}
|
|
5751
5757
|
add(child, index) {
|
|
5752
5758
|
if (child === this || child.destroyed)
|
|
5753
|
-
return debug$
|
|
5759
|
+
return debug$4.warn('add self or destroyed');
|
|
5754
5760
|
const noIndex = index === undefined;
|
|
5755
5761
|
if (!child.__) {
|
|
5756
5762
|
if (child instanceof Array)
|
|
@@ -6004,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6004
6010
|
}
|
|
6005
6011
|
}
|
|
6006
6012
|
|
|
6007
|
-
const version = "1.
|
|
6013
|
+
const version = "1.3.0";
|
|
6008
6014
|
|
|
6009
6015
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6010
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -6072,6 +6078,7 @@ var LeaferUI = (function (exports) {
|
|
|
6072
6078
|
}
|
|
6073
6079
|
Platform.name = 'web';
|
|
6074
6080
|
Platform.isWorker = true;
|
|
6081
|
+
Platform.backgrounder = true;
|
|
6075
6082
|
Platform.requestRender = function (render) { requestAnimationFrame(render); };
|
|
6076
6083
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
6077
6084
|
const { userAgent } = navigator;
|
|
@@ -6278,7 +6285,7 @@ var LeaferUI = (function (exports) {
|
|
|
6278
6285
|
}
|
|
6279
6286
|
|
|
6280
6287
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6281
|
-
const debug$
|
|
6288
|
+
const debug$3 = Debug.get('Layouter');
|
|
6282
6289
|
class Layouter {
|
|
6283
6290
|
constructor(target, userConfig) {
|
|
6284
6291
|
this.totalTimes = 0;
|
|
@@ -6313,7 +6320,7 @@ var LeaferUI = (function (exports) {
|
|
|
6313
6320
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6314
6321
|
}
|
|
6315
6322
|
catch (e) {
|
|
6316
|
-
debug$
|
|
6323
|
+
debug$3.error(e);
|
|
6317
6324
|
}
|
|
6318
6325
|
this.layoutedBlocks = null;
|
|
6319
6326
|
}
|
|
@@ -6327,9 +6334,9 @@ var LeaferUI = (function (exports) {
|
|
|
6327
6334
|
}
|
|
6328
6335
|
layoutOnce() {
|
|
6329
6336
|
if (this.layouting)
|
|
6330
|
-
return debug$
|
|
6337
|
+
return debug$3.warn('layouting');
|
|
6331
6338
|
if (this.times > 3)
|
|
6332
|
-
return debug$
|
|
6339
|
+
return debug$3.warn('layout max times');
|
|
6333
6340
|
this.times++;
|
|
6334
6341
|
this.totalTimes++;
|
|
6335
6342
|
this.layouting = true;
|
|
@@ -6433,7 +6440,7 @@ var LeaferUI = (function (exports) {
|
|
|
6433
6440
|
}
|
|
6434
6441
|
}
|
|
6435
6442
|
|
|
6436
|
-
const debug$
|
|
6443
|
+
const debug$2 = Debug.get('Renderer');
|
|
6437
6444
|
class Renderer {
|
|
6438
6445
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6439
6446
|
constructor(target, canvas, userConfig) {
|
|
@@ -6471,7 +6478,7 @@ var LeaferUI = (function (exports) {
|
|
|
6471
6478
|
const { target } = this;
|
|
6472
6479
|
this.times = 0;
|
|
6473
6480
|
this.totalBounds = new Bounds();
|
|
6474
|
-
debug$
|
|
6481
|
+
debug$2.log(target.innerName, '--->');
|
|
6475
6482
|
try {
|
|
6476
6483
|
if (!target.isApp)
|
|
6477
6484
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6482,9 +6489,9 @@ var LeaferUI = (function (exports) {
|
|
|
6482
6489
|
}
|
|
6483
6490
|
catch (e) {
|
|
6484
6491
|
this.rendering = false;
|
|
6485
|
-
debug$
|
|
6492
|
+
debug$2.error(e);
|
|
6486
6493
|
}
|
|
6487
|
-
debug$
|
|
6494
|
+
debug$2.log('-------------|');
|
|
6488
6495
|
}
|
|
6489
6496
|
renderAgain() {
|
|
6490
6497
|
if (this.rendering) {
|
|
@@ -6496,9 +6503,9 @@ var LeaferUI = (function (exports) {
|
|
|
6496
6503
|
}
|
|
6497
6504
|
renderOnce(callback) {
|
|
6498
6505
|
if (this.rendering)
|
|
6499
|
-
return debug$
|
|
6506
|
+
return debug$2.warn('rendering');
|
|
6500
6507
|
if (this.times > 3)
|
|
6501
|
-
return debug$
|
|
6508
|
+
return debug$2.warn('render max times');
|
|
6502
6509
|
this.times++;
|
|
6503
6510
|
this.totalTimes++;
|
|
6504
6511
|
this.rendering = true;
|
|
@@ -6535,7 +6542,7 @@ var LeaferUI = (function (exports) {
|
|
|
6535
6542
|
partRender() {
|
|
6536
6543
|
const { canvas, updateBlocks: list } = this;
|
|
6537
6544
|
if (!list)
|
|
6538
|
-
return debug$
|
|
6545
|
+
return debug$2.warn('PartRender: need update attr');
|
|
6539
6546
|
this.mergeBlocks();
|
|
6540
6547
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6541
6548
|
this.clipRender(block); });
|
|
@@ -6638,7 +6645,7 @@ var LeaferUI = (function (exports) {
|
|
|
6638
6645
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6639
6646
|
if (empty) {
|
|
6640
6647
|
if (!leaf.isLeafer)
|
|
6641
|
-
debug$
|
|
6648
|
+
debug$2.tip(leaf.innerName, ': empty');
|
|
6642
6649
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6643
6650
|
}
|
|
6644
6651
|
return empty;
|
|
@@ -6740,7 +6747,7 @@ var LeaferUI = (function (exports) {
|
|
|
6740
6747
|
|
|
6741
6748
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6742
6749
|
const emptyPaint = {};
|
|
6743
|
-
const debug$
|
|
6750
|
+
const debug$1 = Debug.get('UIData');
|
|
6744
6751
|
class UIData extends LeafData {
|
|
6745
6752
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6746
6753
|
get __strokeWidth() {
|
|
@@ -6777,7 +6784,7 @@ var LeaferUI = (function (exports) {
|
|
|
6777
6784
|
if (value < 0) {
|
|
6778
6785
|
this._width = -value;
|
|
6779
6786
|
this.__leaf.scaleX *= -1;
|
|
6780
|
-
debug$
|
|
6787
|
+
debug$1.warn('width < 0, instead -scaleX ', this);
|
|
6781
6788
|
}
|
|
6782
6789
|
else
|
|
6783
6790
|
this._width = value;
|
|
@@ -6786,7 +6793,7 @@ var LeaferUI = (function (exports) {
|
|
|
6786
6793
|
if (value < 0) {
|
|
6787
6794
|
this._height = -value;
|
|
6788
6795
|
this.__leaf.scaleY *= -1;
|
|
6789
|
-
debug$
|
|
6796
|
+
debug$1.warn('height < 0, instead -scaleY', this);
|
|
6790
6797
|
}
|
|
6791
6798
|
else
|
|
6792
6799
|
this._height = value;
|
|
@@ -7163,25 +7170,27 @@ var LeaferUI = (function (exports) {
|
|
|
7163
7170
|
}
|
|
7164
7171
|
reset(_data) { }
|
|
7165
7172
|
set(data, transition) {
|
|
7166
|
-
if (
|
|
7167
|
-
if (transition
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7173
|
+
if (data) {
|
|
7174
|
+
if (transition) {
|
|
7175
|
+
if (transition === 'temp') {
|
|
7176
|
+
this.lockNormalStyle = true;
|
|
7177
|
+
Object.assign(this, data);
|
|
7178
|
+
this.lockNormalStyle = false;
|
|
7179
|
+
}
|
|
7180
|
+
else
|
|
7181
|
+
this.animate(data, transition);
|
|
7171
7182
|
}
|
|
7172
7183
|
else
|
|
7173
|
-
|
|
7184
|
+
Object.assign(this, data);
|
|
7174
7185
|
}
|
|
7175
|
-
else
|
|
7176
|
-
Object.assign(this, data);
|
|
7177
7186
|
}
|
|
7178
7187
|
get(name) {
|
|
7179
7188
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
7180
7189
|
}
|
|
7181
7190
|
createProxyData() { return undefined; }
|
|
7182
|
-
find(_condition, _options) { return
|
|
7191
|
+
find(_condition, _options) { return Plugin.need('find'); }
|
|
7183
7192
|
findTag(tag) { return this.find({ tag }); }
|
|
7184
|
-
findOne(_condition, _options) { return
|
|
7193
|
+
findOne(_condition, _options) { return Plugin.need('find'); }
|
|
7185
7194
|
findId(id) { return this.findOne({ id }); }
|
|
7186
7195
|
getPath(curve, pathForRender) {
|
|
7187
7196
|
this.__layout.update();
|
|
@@ -7233,9 +7242,9 @@ var LeaferUI = (function (exports) {
|
|
|
7233
7242
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7234
7243
|
return Plugin.need('animate');
|
|
7235
7244
|
}
|
|
7236
|
-
killAnimate(_type) { }
|
|
7237
|
-
export(
|
|
7238
|
-
return
|
|
7245
|
+
killAnimate(_type, _killStyle) { }
|
|
7246
|
+
export(_filename, _options) {
|
|
7247
|
+
return Plugin.need('export');
|
|
7239
7248
|
}
|
|
7240
7249
|
clone(data) {
|
|
7241
7250
|
const json = this.toJSON();
|
|
@@ -7481,16 +7490,18 @@ var LeaferUI = (function (exports) {
|
|
|
7481
7490
|
this.children = [];
|
|
7482
7491
|
}
|
|
7483
7492
|
set(data, transition) {
|
|
7484
|
-
if (data
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7493
|
+
if (data) {
|
|
7494
|
+
if (data.children) {
|
|
7495
|
+
const { children } = data;
|
|
7496
|
+
delete data.children;
|
|
7497
|
+
this.children ? this.clear() : this.__setBranch();
|
|
7498
|
+
super.set(data, transition);
|
|
7499
|
+
children.forEach(child => this.add(child));
|
|
7500
|
+
data.children = children;
|
|
7501
|
+
}
|
|
7502
|
+
else
|
|
7503
|
+
super.set(data, transition);
|
|
7491
7504
|
}
|
|
7492
|
-
else
|
|
7493
|
-
super.set(data, transition);
|
|
7494
7505
|
}
|
|
7495
7506
|
toJSON(options) {
|
|
7496
7507
|
const data = super.toJSON(options);
|
|
@@ -7522,7 +7533,7 @@ var LeaferUI = (function (exports) {
|
|
|
7522
7533
|
], exports.Group);
|
|
7523
7534
|
|
|
7524
7535
|
var Leafer_1;
|
|
7525
|
-
const debug
|
|
7536
|
+
const debug = Debug.get('Leafer');
|
|
7526
7537
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
7527
7538
|
get __tag() { return 'Leafer'; }
|
|
7528
7539
|
get isApp() { return false; }
|
|
@@ -7687,7 +7698,7 @@ var LeaferUI = (function (exports) {
|
|
|
7687
7698
|
if (this.canvas) {
|
|
7688
7699
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7689
7700
|
if (!newValue)
|
|
7690
|
-
debug
|
|
7701
|
+
debug.warn(attrName + ' is 0');
|
|
7691
7702
|
this.__changeCanvasSize(attrName, newValue);
|
|
7692
7703
|
}
|
|
7693
7704
|
else if (attrName === 'fill') {
|
|
@@ -7753,6 +7764,8 @@ var LeaferUI = (function (exports) {
|
|
|
7753
7764
|
this.requestRender();
|
|
7754
7765
|
}
|
|
7755
7766
|
}
|
|
7767
|
+
else
|
|
7768
|
+
this.requestRender();
|
|
7756
7769
|
}
|
|
7757
7770
|
__checkViewCompleted(emit = true) {
|
|
7758
7771
|
this.nextRender(() => {
|
|
@@ -7826,9 +7839,6 @@ var LeaferUI = (function (exports) {
|
|
|
7826
7839
|
this.canvas && this.canvas.updateClientBounds();
|
|
7827
7840
|
}
|
|
7828
7841
|
receiveEvent(_event) { }
|
|
7829
|
-
__checkUpdateLayout() {
|
|
7830
|
-
this.__layout.update();
|
|
7831
|
-
}
|
|
7832
7842
|
emitLeafer(type) {
|
|
7833
7843
|
this.emitEvent(new LeaferEvent(type, this));
|
|
7834
7844
|
}
|
|
@@ -7839,7 +7849,7 @@ var LeaferUI = (function (exports) {
|
|
|
7839
7849
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
7840
7850
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
7841
7851
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
7842
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this)
|
|
7852
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
7843
7853
|
}
|
|
7844
7854
|
__removeListenEvents() {
|
|
7845
7855
|
this.off_(this.__eventIds);
|
|
@@ -7870,7 +7880,7 @@ var LeaferUI = (function (exports) {
|
|
|
7870
7880
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
7871
7881
|
}
|
|
7872
7882
|
catch (e) {
|
|
7873
|
-
debug
|
|
7883
|
+
debug.error(e);
|
|
7874
7884
|
}
|
|
7875
7885
|
}
|
|
7876
7886
|
};
|
|
@@ -8099,7 +8109,7 @@ var LeaferUI = (function (exports) {
|
|
|
8099
8109
|
|
|
8100
8110
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8101
8111
|
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
8102
|
-
const { toBounds
|
|
8112
|
+
const { toBounds } = PathBounds;
|
|
8103
8113
|
exports.Line = class Line extends exports.UI {
|
|
8104
8114
|
get __tag() { return 'Line'; }
|
|
8105
8115
|
get toPoint() {
|
|
@@ -8143,7 +8153,7 @@ var LeaferUI = (function (exports) {
|
|
|
8143
8153
|
}
|
|
8144
8154
|
__updateBoxBounds() {
|
|
8145
8155
|
if (this.points) {
|
|
8146
|
-
toBounds
|
|
8156
|
+
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8147
8157
|
}
|
|
8148
8158
|
else
|
|
8149
8159
|
super.__updateBoxBounds();
|
|
@@ -8318,10 +8328,10 @@ var LeaferUI = (function (exports) {
|
|
|
8318
8328
|
__updateSize() {
|
|
8319
8329
|
const { canvas } = this;
|
|
8320
8330
|
if (canvas) {
|
|
8321
|
-
const { smooth } = this.__;
|
|
8331
|
+
const { smooth, safeResize } = this.__;
|
|
8332
|
+
canvas.resize(this.__, safeResize);
|
|
8322
8333
|
if (canvas.smooth !== smooth)
|
|
8323
8334
|
canvas.smooth = smooth;
|
|
8324
|
-
canvas.resize(this.__);
|
|
8325
8335
|
}
|
|
8326
8336
|
}
|
|
8327
8337
|
destroy() {
|
|
@@ -8347,6 +8357,9 @@ var LeaferUI = (function (exports) {
|
|
|
8347
8357
|
__decorate([
|
|
8348
8358
|
resizeType(true)
|
|
8349
8359
|
], exports.Canvas.prototype, "smooth", void 0);
|
|
8360
|
+
__decorate([
|
|
8361
|
+
dataType(false)
|
|
8362
|
+
], exports.Canvas.prototype, "safeResize", void 0);
|
|
8350
8363
|
__decorate([
|
|
8351
8364
|
resizeType()
|
|
8352
8365
|
], exports.Canvas.prototype, "contextSettings", void 0);
|
|
@@ -8492,6 +8505,9 @@ var LeaferUI = (function (exports) {
|
|
|
8492
8505
|
__decorate([
|
|
8493
8506
|
boundsType(0)
|
|
8494
8507
|
], exports.Text.prototype, "paraSpacing", void 0);
|
|
8508
|
+
__decorate([
|
|
8509
|
+
boundsType('x')
|
|
8510
|
+
], exports.Text.prototype, "writingMode", void 0);
|
|
8495
8511
|
__decorate([
|
|
8496
8512
|
boundsType('left')
|
|
8497
8513
|
], exports.Text.prototype, "textAlign", void 0);
|
|
@@ -10056,197 +10072,12 @@ var LeaferUI = (function (exports) {
|
|
|
10056
10072
|
string
|
|
10057
10073
|
};
|
|
10058
10074
|
|
|
10059
|
-
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
10060
|
-
function getTrimBounds(canvas) {
|
|
10061
|
-
const { width, height } = canvas.view;
|
|
10062
|
-
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
10063
|
-
let x, y, pointBounds, index = 0;
|
|
10064
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
10065
|
-
if (data[i + 3] !== 0) {
|
|
10066
|
-
x = index % width;
|
|
10067
|
-
y = (index - x) / width;
|
|
10068
|
-
pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
|
|
10069
|
-
}
|
|
10070
|
-
index++;
|
|
10071
|
-
}
|
|
10072
|
-
const bounds = new Bounds();
|
|
10073
|
-
toBounds(pointBounds, bounds);
|
|
10074
|
-
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
10075
|
-
}
|
|
10076
|
-
|
|
10077
|
-
const ExportModule = {
|
|
10078
|
-
export(leaf, filename, options) {
|
|
10079
|
-
this.running = true;
|
|
10080
|
-
const fileType = FileHelper.fileType(filename);
|
|
10081
|
-
const isDownload = filename.includes('.');
|
|
10082
|
-
options = FileHelper.getExportOptions(options);
|
|
10083
|
-
return addTask((success) => new Promise((resolve) => {
|
|
10084
|
-
const over = (result) => {
|
|
10085
|
-
success(result);
|
|
10086
|
-
resolve();
|
|
10087
|
-
this.running = false;
|
|
10088
|
-
};
|
|
10089
|
-
const { toURL } = Platform;
|
|
10090
|
-
const { download } = Platform.origin;
|
|
10091
|
-
if (fileType === 'json') {
|
|
10092
|
-
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10093
|
-
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
10094
|
-
}
|
|
10095
|
-
if (fileType === 'svg') {
|
|
10096
|
-
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10097
|
-
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
10098
|
-
}
|
|
10099
|
-
const { leafer } = leaf;
|
|
10100
|
-
if (leafer) {
|
|
10101
|
-
checkLazy(leaf);
|
|
10102
|
-
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
10103
|
-
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
10104
|
-
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
10105
|
-
const { slice, trim, onCanvas } = options;
|
|
10106
|
-
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
10107
|
-
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
10108
|
-
const screenshot = options.screenshot || leaf.isApp;
|
|
10109
|
-
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
10110
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
10111
|
-
if (screenshot) {
|
|
10112
|
-
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
10113
|
-
}
|
|
10114
|
-
else {
|
|
10115
|
-
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
10116
|
-
scaleX = worldTransform.scaleX;
|
|
10117
|
-
scaleY = worldTransform.scaleY;
|
|
10118
|
-
switch (relative) {
|
|
10119
|
-
case 'inner':
|
|
10120
|
-
matrix.set(worldTransform);
|
|
10121
|
-
break;
|
|
10122
|
-
case 'local':
|
|
10123
|
-
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
10124
|
-
scaleX /= leaf.scaleX;
|
|
10125
|
-
scaleY /= leaf.scaleY;
|
|
10126
|
-
break;
|
|
10127
|
-
case 'world':
|
|
10128
|
-
scaleX = 1;
|
|
10129
|
-
scaleY = 1;
|
|
10130
|
-
break;
|
|
10131
|
-
case 'page':
|
|
10132
|
-
relative = leaf.leafer;
|
|
10133
|
-
default:
|
|
10134
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
10135
|
-
const l = relative.worldTransform;
|
|
10136
|
-
scaleX /= scaleX / l.scaleX;
|
|
10137
|
-
scaleY /= scaleY / l.scaleY;
|
|
10138
|
-
}
|
|
10139
|
-
renderBounds = leaf.getBounds('render', relative);
|
|
10140
|
-
}
|
|
10141
|
-
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10142
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10143
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
10144
|
-
if (leaf.isApp) {
|
|
10145
|
-
scaleData.scaleX *= pixelRatio;
|
|
10146
|
-
scaleData.scaleY *= pixelRatio;
|
|
10147
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
10148
|
-
}
|
|
10149
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10150
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10151
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10152
|
-
let sliceLeaf;
|
|
10153
|
-
if (slice) {
|
|
10154
|
-
sliceLeaf = leaf;
|
|
10155
|
-
sliceLeaf.__worldOpacity = 0;
|
|
10156
|
-
leaf = leafer;
|
|
10157
|
-
renderOptions.bounds = canvas.bounds;
|
|
10158
|
-
}
|
|
10159
|
-
canvas.save();
|
|
10160
|
-
if (isFrame && fill !== undefined) {
|
|
10161
|
-
const oldFill = leaf.get('fill');
|
|
10162
|
-
leaf.fill = '';
|
|
10163
|
-
leaf.__render(canvas, renderOptions);
|
|
10164
|
-
leaf.fill = oldFill;
|
|
10165
|
-
}
|
|
10166
|
-
else {
|
|
10167
|
-
leaf.__render(canvas, renderOptions);
|
|
10168
|
-
}
|
|
10169
|
-
canvas.restore();
|
|
10170
|
-
if (sliceLeaf)
|
|
10171
|
-
sliceLeaf.__updateWorldOpacity();
|
|
10172
|
-
if (trim) {
|
|
10173
|
-
trimBounds = getTrimBounds(canvas);
|
|
10174
|
-
const old = canvas, { width, height } = trimBounds;
|
|
10175
|
-
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
10176
|
-
canvas = Creator.canvas(config);
|
|
10177
|
-
canvas.copyWorld(old, trimBounds, config);
|
|
10178
|
-
}
|
|
10179
|
-
if (needFill)
|
|
10180
|
-
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
10181
|
-
if (onCanvas)
|
|
10182
|
-
onCanvas(canvas);
|
|
10183
|
-
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
10184
|
-
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
10185
|
-
}));
|
|
10186
|
-
}
|
|
10187
|
-
else {
|
|
10188
|
-
over({ data: false });
|
|
10189
|
-
}
|
|
10190
|
-
}));
|
|
10191
|
-
}
|
|
10192
|
-
};
|
|
10193
|
-
let tasker;
|
|
10194
|
-
function addTask(task) {
|
|
10195
|
-
if (!tasker)
|
|
10196
|
-
tasker = new TaskProcessor();
|
|
10197
|
-
return new Promise((resolve) => {
|
|
10198
|
-
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
10199
|
-
});
|
|
10200
|
-
}
|
|
10201
|
-
function checkLazy(leaf) {
|
|
10202
|
-
if (leaf.__.__needComputePaint)
|
|
10203
|
-
leaf.__.__computePaint();
|
|
10204
|
-
if (leaf.isBranch)
|
|
10205
|
-
leaf.children.forEach(child => checkLazy(child));
|
|
10206
|
-
}
|
|
10207
|
-
|
|
10208
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
10209
|
-
const debug = Debug.get('@leafer-ui/export');
|
|
10210
|
-
canvas.export = function (filename, options) {
|
|
10211
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
10212
|
-
if (filename.includes('.'))
|
|
10213
|
-
return this.saveAs(filename, quality);
|
|
10214
|
-
else if (blob)
|
|
10215
|
-
return this.toBlob(filename, quality);
|
|
10216
|
-
else
|
|
10217
|
-
return this.toDataURL(filename, quality);
|
|
10218
|
-
};
|
|
10219
|
-
canvas.toBlob = function (type, quality) {
|
|
10220
|
-
return new Promise((resolve) => {
|
|
10221
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
10222
|
-
resolve(blob);
|
|
10223
|
-
}).catch((e) => {
|
|
10224
|
-
debug.error(e);
|
|
10225
|
-
resolve(null);
|
|
10226
|
-
});
|
|
10227
|
-
});
|
|
10228
|
-
};
|
|
10229
|
-
canvas.toDataURL = function (type, quality) {
|
|
10230
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
10231
|
-
};
|
|
10232
|
-
canvas.saveAs = function (filename, quality) {
|
|
10233
|
-
return new Promise((resolve) => {
|
|
10234
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
10235
|
-
resolve(true);
|
|
10236
|
-
}).catch((e) => {
|
|
10237
|
-
debug.error(e);
|
|
10238
|
-
resolve(false);
|
|
10239
|
-
});
|
|
10240
|
-
});
|
|
10241
|
-
};
|
|
10242
|
-
|
|
10243
10075
|
Object.assign(TextConvert, TextConvertModule);
|
|
10244
10076
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
10245
10077
|
Object.assign(Paint, PaintModule);
|
|
10246
10078
|
Object.assign(PaintImage, PaintImageModule);
|
|
10247
10079
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
10248
10080
|
Object.assign(Effect, EffectModule);
|
|
10249
|
-
Object.assign(Export, ExportModule);
|
|
10250
10081
|
|
|
10251
10082
|
useCanvas();
|
|
10252
10083
|
|