@leafer-draw/worker 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +13 -197
- package/dist/worker.esm.js +14 -198
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +105 -283
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +105 -283
- package/dist/worker.module.min.js +1 -1
- package/package.json +7 -6
package/dist/worker.module.js
CHANGED
|
@@ -765,8 +765,8 @@ const TwoPointBoundsHelper = {
|
|
|
765
765
|
t.maxY = y > t.maxY ? y : t.maxY;
|
|
766
766
|
},
|
|
767
767
|
addBounds(t, x, y, width, height) {
|
|
768
|
-
addPoint$
|
|
769
|
-
addPoint$
|
|
768
|
+
addPoint$3(t, x, y);
|
|
769
|
+
addPoint$3(t, x + width, y + height);
|
|
770
770
|
},
|
|
771
771
|
copy(t, pb) {
|
|
772
772
|
t.minX = pb.minX;
|
|
@@ -787,9 +787,9 @@ const TwoPointBoundsHelper = {
|
|
|
787
787
|
setBounds.height = t.maxY - t.minY;
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const { addPoint: addPoint$
|
|
790
|
+
const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
|
|
791
791
|
|
|
792
|
-
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$
|
|
792
|
+
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
793
793
|
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
794
794
|
const { float, fourNumber } = MathHelper;
|
|
795
795
|
const { floor, ceil: ceil$2 } = Math;
|
|
@@ -905,17 +905,17 @@ const BoundsHelper = {
|
|
|
905
905
|
point.x = t.x;
|
|
906
906
|
point.y = t.y;
|
|
907
907
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
908
|
-
setPoint$
|
|
908
|
+
setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
909
909
|
point.x = t.x + t.width;
|
|
910
910
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
911
|
-
addPoint$
|
|
911
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
912
912
|
point.y = t.y + t.height;
|
|
913
913
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
914
|
-
addPoint$
|
|
914
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
915
915
|
point.x = t.x;
|
|
916
916
|
toOuterPoint$2(matrix, point, toPoint$5);
|
|
917
|
-
addPoint$
|
|
918
|
-
toBounds$
|
|
917
|
+
addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
|
|
918
|
+
toBounds$3(tempPointBounds$1, to);
|
|
919
919
|
}
|
|
920
920
|
},
|
|
921
921
|
toInnerOf(t, matrix, to) {
|
|
@@ -1005,8 +1005,8 @@ const BoundsHelper = {
|
|
|
1005
1005
|
B.reset(t);
|
|
1006
1006
|
},
|
|
1007
1007
|
setPoints(t, points) {
|
|
1008
|
-
points.forEach((point, index) => index === 0 ? setPoint$
|
|
1009
|
-
toBounds$
|
|
1008
|
+
points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
|
|
1009
|
+
toBounds$3(tempPointBounds$1, t);
|
|
1010
1010
|
},
|
|
1011
1011
|
setPoint(t, point) {
|
|
1012
1012
|
B.set(t, point.x, point.y);
|
|
@@ -1374,7 +1374,7 @@ function getNameList(name) {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
const D$4 = Debug;
|
|
1376
1376
|
|
|
1377
|
-
const debug$
|
|
1377
|
+
const debug$d = Debug.get('RunTime');
|
|
1378
1378
|
const Run = {
|
|
1379
1379
|
currentId: 0,
|
|
1380
1380
|
currentName: '',
|
|
@@ -1392,7 +1392,7 @@ const Run = {
|
|
|
1392
1392
|
const time = R.idMap[id], name = R.nameMap[id];
|
|
1393
1393
|
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
1394
1394
|
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
1395
|
-
debug$
|
|
1395
|
+
debug$d.log(name, duration, 'ms');
|
|
1396
1396
|
},
|
|
1397
1397
|
endOfName(name, microsecond) {
|
|
1398
1398
|
const id = R.nameToIdMap[name];
|
|
@@ -1402,34 +1402,37 @@ const Run = {
|
|
|
1402
1402
|
};
|
|
1403
1403
|
const R = Run;
|
|
1404
1404
|
|
|
1405
|
+
const check = [];
|
|
1405
1406
|
const Plugin = {
|
|
1406
1407
|
list: {},
|
|
1407
|
-
add(name) {
|
|
1408
|
+
add(name, ...needPlugins) {
|
|
1408
1409
|
this.list[name] = true;
|
|
1410
|
+
check.push(...needPlugins);
|
|
1409
1411
|
},
|
|
1410
|
-
|
|
1412
|
+
has(name, tip) {
|
|
1411
1413
|
const rs = this.list[name];
|
|
1412
1414
|
if (!rs && tip)
|
|
1413
1415
|
this.need(name);
|
|
1414
1416
|
return rs;
|
|
1415
1417
|
},
|
|
1416
1418
|
need(name) {
|
|
1417
|
-
console.error('need plugin: @leafer-in/' + name);
|
|
1419
|
+
console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1418
1420
|
}
|
|
1419
1421
|
};
|
|
1422
|
+
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1420
1423
|
|
|
1421
|
-
const debug$
|
|
1424
|
+
const debug$c = Debug.get('UICreator');
|
|
1422
1425
|
const UICreator = {
|
|
1423
1426
|
list: {},
|
|
1424
1427
|
register(UI) {
|
|
1425
1428
|
const { __tag: tag } = UI.prototype;
|
|
1426
1429
|
if (list$1[tag])
|
|
1427
|
-
debug$
|
|
1430
|
+
debug$c.repeat(tag);
|
|
1428
1431
|
list$1[tag] = UI;
|
|
1429
1432
|
},
|
|
1430
1433
|
get(tag, data, x, y, width, height) {
|
|
1431
1434
|
if (!list$1[tag])
|
|
1432
|
-
debug$
|
|
1435
|
+
debug$c.error('not register ' + tag);
|
|
1433
1436
|
const ui = new list$1[tag](data);
|
|
1434
1437
|
if (x !== undefined) {
|
|
1435
1438
|
ui.x = x;
|
|
@@ -1445,7 +1448,7 @@ const UICreator = {
|
|
|
1445
1448
|
};
|
|
1446
1449
|
const { list: list$1 } = UICreator;
|
|
1447
1450
|
|
|
1448
|
-
const debug$
|
|
1451
|
+
const debug$b = Debug.get('EventCreator');
|
|
1449
1452
|
const EventCreator = {
|
|
1450
1453
|
nameList: {},
|
|
1451
1454
|
register(Event) {
|
|
@@ -1453,7 +1456,7 @@ const EventCreator = {
|
|
|
1453
1456
|
Object.keys(Event).forEach(key => {
|
|
1454
1457
|
name = Event[key];
|
|
1455
1458
|
if (typeof name === 'string')
|
|
1456
|
-
nameList[name] && debug$
|
|
1459
|
+
nameList[name] && debug$b.repeat(name), nameList[name] = Event;
|
|
1457
1460
|
});
|
|
1458
1461
|
},
|
|
1459
1462
|
changeName(oldName, newName) {
|
|
@@ -2342,7 +2345,7 @@ const RectHelper = {
|
|
|
2342
2345
|
};
|
|
2343
2346
|
|
|
2344
2347
|
const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
|
|
2345
|
-
const { setPoint: setPoint$
|
|
2348
|
+
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2346
2349
|
const { set, toNumberPoints } = PointHelper;
|
|
2347
2350
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2348
2351
|
const tempPoint$2 = {};
|
|
@@ -2418,8 +2421,8 @@ const BezierHelper = {
|
|
|
2418
2421
|
if (data)
|
|
2419
2422
|
data.push(L$6, x1, y1);
|
|
2420
2423
|
if (setPointBounds) {
|
|
2421
|
-
setPoint$
|
|
2422
|
-
addPoint$
|
|
2424
|
+
setPoint$1(setPointBounds, fromX, fromY);
|
|
2425
|
+
addPoint$1(setPointBounds, x1, y1);
|
|
2423
2426
|
}
|
|
2424
2427
|
if (setStartPoint)
|
|
2425
2428
|
set(setStartPoint, fromX, fromY);
|
|
@@ -2471,7 +2474,7 @@ const BezierHelper = {
|
|
|
2471
2474
|
if (data)
|
|
2472
2475
|
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2473
2476
|
if (setPointBounds)
|
|
2474
|
-
setPoint$
|
|
2477
|
+
setPoint$1(setPointBounds, fromX, fromY);
|
|
2475
2478
|
if (setStartPoint)
|
|
2476
2479
|
set(setStartPoint, fromX, fromY);
|
|
2477
2480
|
for (let i = 0; i < parts; i++) {
|
|
@@ -2533,11 +2536,11 @@ const BezierHelper = {
|
|
|
2533
2536
|
if (0 < t2 && t2 < 1)
|
|
2534
2537
|
tList.push(t2);
|
|
2535
2538
|
}
|
|
2536
|
-
addMode ? addPoint$
|
|
2537
|
-
addPoint$
|
|
2539
|
+
addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
|
|
2540
|
+
addPoint$1(pointBounds, toX, toY);
|
|
2538
2541
|
for (let i = 0, len = tList.length; i < len; i++) {
|
|
2539
2542
|
getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
|
|
2540
|
-
addPoint$
|
|
2543
|
+
addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
|
|
2541
2544
|
}
|
|
2542
2545
|
},
|
|
2543
2546
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
|
|
@@ -2609,7 +2612,7 @@ const EllipseHelper = {
|
|
|
2609
2612
|
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;
|
|
2610
2613
|
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2611
2614
|
const { ellipticalArc } = EllipseHelper;
|
|
2612
|
-
const debug$
|
|
2615
|
+
const debug$a = Debug.get('PathConvert');
|
|
2613
2616
|
const setEndPoint$1 = {};
|
|
2614
2617
|
const PathConvert = {
|
|
2615
2618
|
current: { dot: 0 },
|
|
@@ -2850,7 +2853,7 @@ const PathConvert = {
|
|
|
2850
2853
|
i += 6;
|
|
2851
2854
|
break;
|
|
2852
2855
|
default:
|
|
2853
|
-
debug$
|
|
2856
|
+
debug$a.error(`command: ${command} [index:${i}]`, old);
|
|
2854
2857
|
return data;
|
|
2855
2858
|
}
|
|
2856
2859
|
lastCommand = command;
|
|
@@ -3075,7 +3078,7 @@ class PathCreator {
|
|
|
3075
3078
|
}
|
|
3076
3079
|
|
|
3077
3080
|
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;
|
|
3078
|
-
const debug$
|
|
3081
|
+
const debug$9 = Debug.get('PathDrawer');
|
|
3079
3082
|
const PathDrawer = {
|
|
3080
3083
|
drawPathByData(drawer, data) {
|
|
3081
3084
|
if (!data)
|
|
@@ -3138,7 +3141,7 @@ const PathDrawer = {
|
|
|
3138
3141
|
i += 6;
|
|
3139
3142
|
break;
|
|
3140
3143
|
default:
|
|
3141
|
-
debug$
|
|
3144
|
+
debug$9.error(`command: ${command} [index:${i}]`, data);
|
|
3142
3145
|
return;
|
|
3143
3146
|
}
|
|
3144
3147
|
}
|
|
@@ -3147,8 +3150,8 @@ const PathDrawer = {
|
|
|
3147
3150
|
|
|
3148
3151
|
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;
|
|
3149
3152
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3150
|
-
const { addPointBounds, copy: copy$7, addPoint
|
|
3151
|
-
const debug$
|
|
3153
|
+
const { addPointBounds, copy: copy$7, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
|
|
3154
|
+
const debug$8 = Debug.get('PathBounds');
|
|
3152
3155
|
let radius, radiusX, radiusY;
|
|
3153
3156
|
const tempPointBounds = {};
|
|
3154
3157
|
const setPointBounds = {};
|
|
@@ -3156,21 +3159,21 @@ const setEndPoint = {};
|
|
|
3156
3159
|
const PathBounds = {
|
|
3157
3160
|
toBounds(data, setBounds) {
|
|
3158
3161
|
PathBounds.toTwoPointBounds(data, setPointBounds);
|
|
3159
|
-
toBounds$
|
|
3162
|
+
toBounds$2(setPointBounds, setBounds);
|
|
3160
3163
|
},
|
|
3161
3164
|
toTwoPointBounds(data, setPointBounds) {
|
|
3162
3165
|
if (!data || !data.length)
|
|
3163
|
-
return setPoint
|
|
3166
|
+
return setPoint(setPointBounds, 0, 0);
|
|
3164
3167
|
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3165
3168
|
const len = data.length;
|
|
3166
3169
|
while (i < len) {
|
|
3167
3170
|
command = data[i];
|
|
3168
3171
|
if (i === 0) {
|
|
3169
3172
|
if (command === Z$1 || command === C$1 || command === Q) {
|
|
3170
|
-
setPoint
|
|
3173
|
+
setPoint(setPointBounds, x, y);
|
|
3171
3174
|
}
|
|
3172
3175
|
else {
|
|
3173
|
-
setPoint
|
|
3176
|
+
setPoint(setPointBounds, data[i + 1], data[i + 2]);
|
|
3174
3177
|
}
|
|
3175
3178
|
}
|
|
3176
3179
|
switch (command) {
|
|
@@ -3178,7 +3181,7 @@ const PathBounds = {
|
|
|
3178
3181
|
case L$2:
|
|
3179
3182
|
x = data[i + 1];
|
|
3180
3183
|
y = data[i + 2];
|
|
3181
|
-
addPoint
|
|
3184
|
+
addPoint(setPointBounds, x, y);
|
|
3182
3185
|
i += 3;
|
|
3183
3186
|
break;
|
|
3184
3187
|
case C$1:
|
|
@@ -3256,7 +3259,7 @@ const PathBounds = {
|
|
|
3256
3259
|
i += 6;
|
|
3257
3260
|
break;
|
|
3258
3261
|
default:
|
|
3259
|
-
debug$
|
|
3262
|
+
debug$8.error(`command: ${command} [index:${i}]`, data);
|
|
3260
3263
|
return;
|
|
3261
3264
|
}
|
|
3262
3265
|
}
|
|
@@ -3372,7 +3375,7 @@ const FileHelper = {
|
|
|
3372
3375
|
const F = FileHelper;
|
|
3373
3376
|
F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3374
3377
|
|
|
3375
|
-
const debug$
|
|
3378
|
+
const debug$7 = Debug.get('TaskProcessor');
|
|
3376
3379
|
class TaskItem {
|
|
3377
3380
|
constructor(task) {
|
|
3378
3381
|
this.parallel = true;
|
|
@@ -3387,7 +3390,7 @@ class TaskItem {
|
|
|
3387
3390
|
yield this.task();
|
|
3388
3391
|
}
|
|
3389
3392
|
catch (error) {
|
|
3390
|
-
debug$
|
|
3393
|
+
debug$7.error(error);
|
|
3391
3394
|
}
|
|
3392
3395
|
});
|
|
3393
3396
|
}
|
|
@@ -4074,7 +4077,7 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4074
4077
|
defineKey(data, key, property);
|
|
4075
4078
|
}
|
|
4076
4079
|
|
|
4077
|
-
const debug$
|
|
4080
|
+
const debug$6 = new Debug('rewrite');
|
|
4078
4081
|
const list = [];
|
|
4079
4082
|
const excludeNames = ['destroy', 'constructor'];
|
|
4080
4083
|
function rewrite(method) {
|
|
@@ -4091,7 +4094,7 @@ function doRewrite(error) {
|
|
|
4091
4094
|
if (list.length) {
|
|
4092
4095
|
list.forEach(item => {
|
|
4093
4096
|
if (error)
|
|
4094
|
-
debug$
|
|
4097
|
+
debug$6.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4095
4098
|
item.run();
|
|
4096
4099
|
});
|
|
4097
4100
|
list.length = 0;
|
|
@@ -4808,7 +4811,6 @@ class LayoutEvent extends Event {
|
|
|
4808
4811
|
}
|
|
4809
4812
|
}
|
|
4810
4813
|
}
|
|
4811
|
-
LayoutEvent.CHECK_UPDATE = 'layout.check_update';
|
|
4812
4814
|
LayoutEvent.REQUEST = 'layout.request';
|
|
4813
4815
|
LayoutEvent.START = 'layout.start';
|
|
4814
4816
|
LayoutEvent.BEFORE = 'layout.before';
|
|
@@ -5003,13 +5005,13 @@ const { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroy } =
|
|
|
5003
5005
|
const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
|
|
5004
5006
|
|
|
5005
5007
|
const { isFinite } = Number;
|
|
5006
|
-
const debug$
|
|
5008
|
+
const debug$5 = Debug.get('setAttr');
|
|
5007
5009
|
const LeafDataProxy = {
|
|
5008
5010
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
5009
5011
|
if (this.leaferIsCreated) {
|
|
5010
5012
|
const oldValue = this.__.__getInput(name);
|
|
5011
5013
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
5012
|
-
debug$
|
|
5014
|
+
debug$5.warn(this.innerName, name, newValue);
|
|
5013
5015
|
newValue = undefined;
|
|
5014
5016
|
}
|
|
5015
5017
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
@@ -5079,7 +5081,7 @@ const LeafMatrix = {
|
|
|
5079
5081
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5080
5082
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5081
5083
|
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
|
|
5082
|
-
const { toBounds: toBounds$
|
|
5084
|
+
const { toBounds: toBounds$1 } = PathBounds;
|
|
5083
5085
|
const LeafBounds = {
|
|
5084
5086
|
__updateWorldBounds() {
|
|
5085
5087
|
toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
|
|
@@ -5161,7 +5163,7 @@ const LeafBounds = {
|
|
|
5161
5163
|
const b = this.__layout.boxBounds;
|
|
5162
5164
|
const data = this.__;
|
|
5163
5165
|
if (data.__pathInputed) {
|
|
5164
|
-
toBounds$
|
|
5166
|
+
toBounds$1(data.path, b);
|
|
5165
5167
|
}
|
|
5166
5168
|
else {
|
|
5167
5169
|
b.x = 0;
|
|
@@ -5709,7 +5711,7 @@ Leaf = __decorate([
|
|
|
5709
5711
|
const { setListWithFn } = BoundsHelper;
|
|
5710
5712
|
const { sort } = BranchHelper;
|
|
5711
5713
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5712
|
-
const debug$
|
|
5714
|
+
const debug$4 = new Debug('Branch');
|
|
5713
5715
|
let Branch = class Branch extends Leaf {
|
|
5714
5716
|
__updateStrokeSpread() {
|
|
5715
5717
|
const { children } = this;
|
|
@@ -5751,7 +5753,7 @@ let Branch = class Branch extends Leaf {
|
|
|
5751
5753
|
}
|
|
5752
5754
|
add(child, index) {
|
|
5753
5755
|
if (child === this || child.destroyed)
|
|
5754
|
-
return debug$
|
|
5756
|
+
return debug$4.warn('add self or destroyed');
|
|
5755
5757
|
const noIndex = index === undefined;
|
|
5756
5758
|
if (!child.__) {
|
|
5757
5759
|
if (child instanceof Array)
|
|
@@ -6005,7 +6007,7 @@ class LeafLevelList {
|
|
|
6005
6007
|
}
|
|
6006
6008
|
}
|
|
6007
6009
|
|
|
6008
|
-
const version = "1.
|
|
6010
|
+
const version = "1.3.1";
|
|
6009
6011
|
|
|
6010
6012
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6011
6013
|
get allowBackgroundColor() { return true; }
|
|
@@ -6073,6 +6075,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
6073
6075
|
}
|
|
6074
6076
|
Platform.name = 'web';
|
|
6075
6077
|
Platform.isWorker = true;
|
|
6078
|
+
Platform.backgrounder = true;
|
|
6076
6079
|
Platform.requestRender = function (render) { requestAnimationFrame(render); };
|
|
6077
6080
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
6078
6081
|
const { userAgent } = navigator;
|
|
@@ -6279,7 +6282,7 @@ class LayoutBlockData {
|
|
|
6279
6282
|
}
|
|
6280
6283
|
|
|
6281
6284
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6282
|
-
const debug$
|
|
6285
|
+
const debug$3 = Debug.get('Layouter');
|
|
6283
6286
|
class Layouter {
|
|
6284
6287
|
constructor(target, userConfig) {
|
|
6285
6288
|
this.totalTimes = 0;
|
|
@@ -6314,7 +6317,7 @@ class Layouter {
|
|
|
6314
6317
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6315
6318
|
}
|
|
6316
6319
|
catch (e) {
|
|
6317
|
-
debug$
|
|
6320
|
+
debug$3.error(e);
|
|
6318
6321
|
}
|
|
6319
6322
|
this.layoutedBlocks = null;
|
|
6320
6323
|
}
|
|
@@ -6328,9 +6331,9 @@ class Layouter {
|
|
|
6328
6331
|
}
|
|
6329
6332
|
layoutOnce() {
|
|
6330
6333
|
if (this.layouting)
|
|
6331
|
-
return debug$
|
|
6334
|
+
return debug$3.warn('layouting');
|
|
6332
6335
|
if (this.times > 3)
|
|
6333
|
-
return debug$
|
|
6336
|
+
return debug$3.warn('layout max times');
|
|
6334
6337
|
this.times++;
|
|
6335
6338
|
this.totalTimes++;
|
|
6336
6339
|
this.layouting = true;
|
|
@@ -6434,7 +6437,7 @@ class Layouter {
|
|
|
6434
6437
|
}
|
|
6435
6438
|
}
|
|
6436
6439
|
|
|
6437
|
-
const debug$
|
|
6440
|
+
const debug$2 = Debug.get('Renderer');
|
|
6438
6441
|
class Renderer {
|
|
6439
6442
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6440
6443
|
constructor(target, canvas, userConfig) {
|
|
@@ -6472,7 +6475,7 @@ class Renderer {
|
|
|
6472
6475
|
const { target } = this;
|
|
6473
6476
|
this.times = 0;
|
|
6474
6477
|
this.totalBounds = new Bounds();
|
|
6475
|
-
debug$
|
|
6478
|
+
debug$2.log(target.innerName, '--->');
|
|
6476
6479
|
try {
|
|
6477
6480
|
if (!target.isApp)
|
|
6478
6481
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6483,9 +6486,9 @@ class Renderer {
|
|
|
6483
6486
|
}
|
|
6484
6487
|
catch (e) {
|
|
6485
6488
|
this.rendering = false;
|
|
6486
|
-
debug$
|
|
6489
|
+
debug$2.error(e);
|
|
6487
6490
|
}
|
|
6488
|
-
debug$
|
|
6491
|
+
debug$2.log('-------------|');
|
|
6489
6492
|
}
|
|
6490
6493
|
renderAgain() {
|
|
6491
6494
|
if (this.rendering) {
|
|
@@ -6497,9 +6500,9 @@ class Renderer {
|
|
|
6497
6500
|
}
|
|
6498
6501
|
renderOnce(callback) {
|
|
6499
6502
|
if (this.rendering)
|
|
6500
|
-
return debug$
|
|
6503
|
+
return debug$2.warn('rendering');
|
|
6501
6504
|
if (this.times > 3)
|
|
6502
|
-
return debug$
|
|
6505
|
+
return debug$2.warn('render max times');
|
|
6503
6506
|
this.times++;
|
|
6504
6507
|
this.totalTimes++;
|
|
6505
6508
|
this.rendering = true;
|
|
@@ -6536,7 +6539,7 @@ class Renderer {
|
|
|
6536
6539
|
partRender() {
|
|
6537
6540
|
const { canvas, updateBlocks: list } = this;
|
|
6538
6541
|
if (!list)
|
|
6539
|
-
return debug$
|
|
6542
|
+
return debug$2.warn('PartRender: need update attr');
|
|
6540
6543
|
this.mergeBlocks();
|
|
6541
6544
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6542
6545
|
this.clipRender(block); });
|
|
@@ -6639,7 +6642,7 @@ class Renderer {
|
|
|
6639
6642
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6640
6643
|
if (empty) {
|
|
6641
6644
|
if (!leaf.isLeafer)
|
|
6642
|
-
debug$
|
|
6645
|
+
debug$2.tip(leaf.innerName, ': empty');
|
|
6643
6646
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6644
6647
|
}
|
|
6645
6648
|
return empty;
|
|
@@ -6741,7 +6744,7 @@ const Transition = {
|
|
|
6741
6744
|
|
|
6742
6745
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6743
6746
|
const emptyPaint = {};
|
|
6744
|
-
const debug$
|
|
6747
|
+
const debug$1 = Debug.get('UIData');
|
|
6745
6748
|
class UIData extends LeafData {
|
|
6746
6749
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6747
6750
|
get __strokeWidth() {
|
|
@@ -6778,7 +6781,7 @@ class UIData extends LeafData {
|
|
|
6778
6781
|
if (value < 0) {
|
|
6779
6782
|
this._width = -value;
|
|
6780
6783
|
this.__leaf.scaleX *= -1;
|
|
6781
|
-
debug$
|
|
6784
|
+
debug$1.warn('width < 0, instead -scaleX ', this);
|
|
6782
6785
|
}
|
|
6783
6786
|
else
|
|
6784
6787
|
this._width = value;
|
|
@@ -6787,7 +6790,7 @@ class UIData extends LeafData {
|
|
|
6787
6790
|
if (value < 0) {
|
|
6788
6791
|
this._height = -value;
|
|
6789
6792
|
this.__leaf.scaleY *= -1;
|
|
6790
|
-
debug$
|
|
6793
|
+
debug$1.warn('height < 0, instead -scaleY', this);
|
|
6791
6794
|
}
|
|
6792
6795
|
else
|
|
6793
6796
|
this._height = value;
|
|
@@ -7164,25 +7167,27 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7164
7167
|
}
|
|
7165
7168
|
reset(_data) { }
|
|
7166
7169
|
set(data, transition) {
|
|
7167
|
-
if (
|
|
7168
|
-
if (transition
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7170
|
+
if (data) {
|
|
7171
|
+
if (transition) {
|
|
7172
|
+
if (transition === 'temp') {
|
|
7173
|
+
this.lockNormalStyle = true;
|
|
7174
|
+
Object.assign(this, data);
|
|
7175
|
+
this.lockNormalStyle = false;
|
|
7176
|
+
}
|
|
7177
|
+
else
|
|
7178
|
+
this.animate(data, transition);
|
|
7172
7179
|
}
|
|
7173
7180
|
else
|
|
7174
|
-
|
|
7181
|
+
Object.assign(this, data);
|
|
7175
7182
|
}
|
|
7176
|
-
else
|
|
7177
|
-
Object.assign(this, data);
|
|
7178
7183
|
}
|
|
7179
7184
|
get(name) {
|
|
7180
7185
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
7181
7186
|
}
|
|
7182
7187
|
createProxyData() { return undefined; }
|
|
7183
|
-
find(_condition, _options) { return
|
|
7188
|
+
find(_condition, _options) { return Plugin.need('find'); }
|
|
7184
7189
|
findTag(tag) { return this.find({ tag }); }
|
|
7185
|
-
findOne(_condition, _options) { return
|
|
7190
|
+
findOne(_condition, _options) { return Plugin.need('find'); }
|
|
7186
7191
|
findId(id) { return this.findOne({ id }); }
|
|
7187
7192
|
getPath(curve, pathForRender) {
|
|
7188
7193
|
this.__layout.update();
|
|
@@ -7234,9 +7239,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7234
7239
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7235
7240
|
return Plugin.need('animate');
|
|
7236
7241
|
}
|
|
7237
|
-
killAnimate(_type) { }
|
|
7238
|
-
export(
|
|
7239
|
-
return
|
|
7242
|
+
killAnimate(_type, _killStyle) { }
|
|
7243
|
+
export(_filename, _options) {
|
|
7244
|
+
return Plugin.need('export');
|
|
7240
7245
|
}
|
|
7241
7246
|
clone(data) {
|
|
7242
7247
|
const json = this.toJSON();
|
|
@@ -7482,16 +7487,18 @@ let Group = class Group extends UI {
|
|
|
7482
7487
|
this.children = [];
|
|
7483
7488
|
}
|
|
7484
7489
|
set(data, transition) {
|
|
7485
|
-
if (data
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7490
|
+
if (data) {
|
|
7491
|
+
if (data.children) {
|
|
7492
|
+
const { children } = data;
|
|
7493
|
+
delete data.children;
|
|
7494
|
+
this.children ? this.clear() : this.__setBranch();
|
|
7495
|
+
super.set(data, transition);
|
|
7496
|
+
children.forEach(child => this.add(child));
|
|
7497
|
+
data.children = children;
|
|
7498
|
+
}
|
|
7499
|
+
else
|
|
7500
|
+
super.set(data, transition);
|
|
7492
7501
|
}
|
|
7493
|
-
else
|
|
7494
|
-
super.set(data, transition);
|
|
7495
7502
|
}
|
|
7496
7503
|
toJSON(options) {
|
|
7497
7504
|
const data = super.toJSON(options);
|
|
@@ -7523,7 +7530,7 @@ Group = __decorate([
|
|
|
7523
7530
|
], Group);
|
|
7524
7531
|
|
|
7525
7532
|
var Leafer_1;
|
|
7526
|
-
const debug
|
|
7533
|
+
const debug = Debug.get('Leafer');
|
|
7527
7534
|
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
7528
7535
|
get __tag() { return 'Leafer'; }
|
|
7529
7536
|
get isApp() { return false; }
|
|
@@ -7688,7 +7695,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7688
7695
|
if (this.canvas) {
|
|
7689
7696
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7690
7697
|
if (!newValue)
|
|
7691
|
-
debug
|
|
7698
|
+
debug.warn(attrName + ' is 0');
|
|
7692
7699
|
this.__changeCanvasSize(attrName, newValue);
|
|
7693
7700
|
}
|
|
7694
7701
|
else if (attrName === 'fill') {
|
|
@@ -7829,9 +7836,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7829
7836
|
this.canvas && this.canvas.updateClientBounds();
|
|
7830
7837
|
}
|
|
7831
7838
|
receiveEvent(_event) { }
|
|
7832
|
-
__checkUpdateLayout() {
|
|
7833
|
-
this.__layout.update();
|
|
7834
|
-
}
|
|
7835
7839
|
emitLeafer(type) {
|
|
7836
7840
|
this.emitEvent(new LeaferEvent(type, this));
|
|
7837
7841
|
}
|
|
@@ -7842,7 +7846,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7842
7846
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
7843
7847
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
7844
7848
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
7845
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this)
|
|
7849
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
7846
7850
|
}
|
|
7847
7851
|
__removeListenEvents() {
|
|
7848
7852
|
this.off_(this.__eventIds);
|
|
@@ -7873,7 +7877,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7873
7877
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
7874
7878
|
}
|
|
7875
7879
|
catch (e) {
|
|
7876
|
-
debug
|
|
7880
|
+
debug.error(e);
|
|
7877
7881
|
}
|
|
7878
7882
|
}
|
|
7879
7883
|
};
|
|
@@ -8102,7 +8106,7 @@ Ellipse = __decorate([
|
|
|
8102
8106
|
|
|
8103
8107
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8104
8108
|
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
|
|
8105
|
-
const { toBounds
|
|
8109
|
+
const { toBounds } = PathBounds;
|
|
8106
8110
|
let Line = class Line extends UI {
|
|
8107
8111
|
get __tag() { return 'Line'; }
|
|
8108
8112
|
get toPoint() {
|
|
@@ -8146,7 +8150,7 @@ let Line = class Line extends UI {
|
|
|
8146
8150
|
}
|
|
8147
8151
|
__updateBoxBounds() {
|
|
8148
8152
|
if (this.points) {
|
|
8149
|
-
toBounds
|
|
8153
|
+
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
8150
8154
|
}
|
|
8151
8155
|
else
|
|
8152
8156
|
super.__updateBoxBounds();
|
|
@@ -8498,6 +8502,9 @@ __decorate([
|
|
|
8498
8502
|
__decorate([
|
|
8499
8503
|
boundsType(0)
|
|
8500
8504
|
], Text.prototype, "paraSpacing", void 0);
|
|
8505
|
+
__decorate([
|
|
8506
|
+
boundsType('x')
|
|
8507
|
+
], Text.prototype, "writingMode", void 0);
|
|
8501
8508
|
__decorate([
|
|
8502
8509
|
boundsType('left')
|
|
8503
8510
|
], Text.prototype, "textAlign", void 0);
|
|
@@ -10062,197 +10069,12 @@ const ColorConvertModule = {
|
|
|
10062
10069
|
string
|
|
10063
10070
|
};
|
|
10064
10071
|
|
|
10065
|
-
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
10066
|
-
function getTrimBounds(canvas) {
|
|
10067
|
-
const { width, height } = canvas.view;
|
|
10068
|
-
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
10069
|
-
let x, y, pointBounds, index = 0;
|
|
10070
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
10071
|
-
if (data[i + 3] !== 0) {
|
|
10072
|
-
x = index % width;
|
|
10073
|
-
y = (index - x) / width;
|
|
10074
|
-
pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
|
|
10075
|
-
}
|
|
10076
|
-
index++;
|
|
10077
|
-
}
|
|
10078
|
-
const bounds = new Bounds();
|
|
10079
|
-
toBounds(pointBounds, bounds);
|
|
10080
|
-
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
10081
|
-
}
|
|
10082
|
-
|
|
10083
|
-
const ExportModule = {
|
|
10084
|
-
export(leaf, filename, options) {
|
|
10085
|
-
this.running = true;
|
|
10086
|
-
const fileType = FileHelper.fileType(filename);
|
|
10087
|
-
const isDownload = filename.includes('.');
|
|
10088
|
-
options = FileHelper.getExportOptions(options);
|
|
10089
|
-
return addTask((success) => new Promise((resolve) => {
|
|
10090
|
-
const over = (result) => {
|
|
10091
|
-
success(result);
|
|
10092
|
-
resolve();
|
|
10093
|
-
this.running = false;
|
|
10094
|
-
};
|
|
10095
|
-
const { toURL } = Platform;
|
|
10096
|
-
const { download } = Platform.origin;
|
|
10097
|
-
if (fileType === 'json') {
|
|
10098
|
-
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
10099
|
-
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
10100
|
-
}
|
|
10101
|
-
if (fileType === 'svg') {
|
|
10102
|
-
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
10103
|
-
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
10104
|
-
}
|
|
10105
|
-
const { leafer } = leaf;
|
|
10106
|
-
if (leafer) {
|
|
10107
|
-
checkLazy(leaf);
|
|
10108
|
-
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
10109
|
-
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
10110
|
-
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
10111
|
-
const { slice, trim, onCanvas } = options;
|
|
10112
|
-
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
10113
|
-
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
10114
|
-
const screenshot = options.screenshot || leaf.isApp;
|
|
10115
|
-
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
10116
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
10117
|
-
if (screenshot) {
|
|
10118
|
-
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
10119
|
-
}
|
|
10120
|
-
else {
|
|
10121
|
-
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
10122
|
-
scaleX = worldTransform.scaleX;
|
|
10123
|
-
scaleY = worldTransform.scaleY;
|
|
10124
|
-
switch (relative) {
|
|
10125
|
-
case 'inner':
|
|
10126
|
-
matrix.set(worldTransform);
|
|
10127
|
-
break;
|
|
10128
|
-
case 'local':
|
|
10129
|
-
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
10130
|
-
scaleX /= leaf.scaleX;
|
|
10131
|
-
scaleY /= leaf.scaleY;
|
|
10132
|
-
break;
|
|
10133
|
-
case 'world':
|
|
10134
|
-
scaleX = 1;
|
|
10135
|
-
scaleY = 1;
|
|
10136
|
-
break;
|
|
10137
|
-
case 'page':
|
|
10138
|
-
relative = leaf.leafer;
|
|
10139
|
-
default:
|
|
10140
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
10141
|
-
const l = relative.worldTransform;
|
|
10142
|
-
scaleX /= scaleX / l.scaleX;
|
|
10143
|
-
scaleY /= scaleY / l.scaleY;
|
|
10144
|
-
}
|
|
10145
|
-
renderBounds = leaf.getBounds('render', relative);
|
|
10146
|
-
}
|
|
10147
|
-
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
10148
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
10149
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
10150
|
-
if (leaf.isApp) {
|
|
10151
|
-
scaleData.scaleX *= pixelRatio;
|
|
10152
|
-
scaleData.scaleY *= pixelRatio;
|
|
10153
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
10154
|
-
}
|
|
10155
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
10156
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
10157
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10158
|
-
let sliceLeaf;
|
|
10159
|
-
if (slice) {
|
|
10160
|
-
sliceLeaf = leaf;
|
|
10161
|
-
sliceLeaf.__worldOpacity = 0;
|
|
10162
|
-
leaf = leafer;
|
|
10163
|
-
renderOptions.bounds = canvas.bounds;
|
|
10164
|
-
}
|
|
10165
|
-
canvas.save();
|
|
10166
|
-
if (isFrame && fill !== undefined) {
|
|
10167
|
-
const oldFill = leaf.get('fill');
|
|
10168
|
-
leaf.fill = '';
|
|
10169
|
-
leaf.__render(canvas, renderOptions);
|
|
10170
|
-
leaf.fill = oldFill;
|
|
10171
|
-
}
|
|
10172
|
-
else {
|
|
10173
|
-
leaf.__render(canvas, renderOptions);
|
|
10174
|
-
}
|
|
10175
|
-
canvas.restore();
|
|
10176
|
-
if (sliceLeaf)
|
|
10177
|
-
sliceLeaf.__updateWorldOpacity();
|
|
10178
|
-
if (trim) {
|
|
10179
|
-
trimBounds = getTrimBounds(canvas);
|
|
10180
|
-
const old = canvas, { width, height } = trimBounds;
|
|
10181
|
-
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
10182
|
-
canvas = Creator.canvas(config);
|
|
10183
|
-
canvas.copyWorld(old, trimBounds, config);
|
|
10184
|
-
}
|
|
10185
|
-
if (needFill)
|
|
10186
|
-
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
10187
|
-
if (onCanvas)
|
|
10188
|
-
onCanvas(canvas);
|
|
10189
|
-
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
10190
|
-
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
10191
|
-
}));
|
|
10192
|
-
}
|
|
10193
|
-
else {
|
|
10194
|
-
over({ data: false });
|
|
10195
|
-
}
|
|
10196
|
-
}));
|
|
10197
|
-
}
|
|
10198
|
-
};
|
|
10199
|
-
let tasker;
|
|
10200
|
-
function addTask(task) {
|
|
10201
|
-
if (!tasker)
|
|
10202
|
-
tasker = new TaskProcessor();
|
|
10203
|
-
return new Promise((resolve) => {
|
|
10204
|
-
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
10205
|
-
});
|
|
10206
|
-
}
|
|
10207
|
-
function checkLazy(leaf) {
|
|
10208
|
-
if (leaf.__.__needComputePaint)
|
|
10209
|
-
leaf.__.__computePaint();
|
|
10210
|
-
if (leaf.isBranch)
|
|
10211
|
-
leaf.children.forEach(child => checkLazy(child));
|
|
10212
|
-
}
|
|
10213
|
-
|
|
10214
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
10215
|
-
const debug = Debug.get('@leafer-ui/export');
|
|
10216
|
-
canvas.export = function (filename, options) {
|
|
10217
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
10218
|
-
if (filename.includes('.'))
|
|
10219
|
-
return this.saveAs(filename, quality);
|
|
10220
|
-
else if (blob)
|
|
10221
|
-
return this.toBlob(filename, quality);
|
|
10222
|
-
else
|
|
10223
|
-
return this.toDataURL(filename, quality);
|
|
10224
|
-
};
|
|
10225
|
-
canvas.toBlob = function (type, quality) {
|
|
10226
|
-
return new Promise((resolve) => {
|
|
10227
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
10228
|
-
resolve(blob);
|
|
10229
|
-
}).catch((e) => {
|
|
10230
|
-
debug.error(e);
|
|
10231
|
-
resolve(null);
|
|
10232
|
-
});
|
|
10233
|
-
});
|
|
10234
|
-
};
|
|
10235
|
-
canvas.toDataURL = function (type, quality) {
|
|
10236
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
10237
|
-
};
|
|
10238
|
-
canvas.saveAs = function (filename, quality) {
|
|
10239
|
-
return new Promise((resolve) => {
|
|
10240
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
10241
|
-
resolve(true);
|
|
10242
|
-
}).catch((e) => {
|
|
10243
|
-
debug.error(e);
|
|
10244
|
-
resolve(false);
|
|
10245
|
-
});
|
|
10246
|
-
});
|
|
10247
|
-
};
|
|
10248
|
-
|
|
10249
10072
|
Object.assign(TextConvert, TextConvertModule);
|
|
10250
10073
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
10251
10074
|
Object.assign(Paint, PaintModule);
|
|
10252
10075
|
Object.assign(PaintImage, PaintImageModule);
|
|
10253
10076
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
10254
10077
|
Object.assign(Effect, EffectModule);
|
|
10255
|
-
Object.assign(Export, ExportModule);
|
|
10256
10078
|
|
|
10257
10079
|
useCanvas();
|
|
10258
10080
|
|