@meta2d/core 1.0.16 → 1.0.18
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +4 -3
- package/src/canvas/canvas.js +233 -201
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +20 -11
- package/src/core.js +423 -163
- package/src/core.js.map +1 -1
- package/src/diagrams/gif.js +4 -1
- package/src/diagrams/gif.js.map +1 -1
- package/src/pen/model.d.ts +2 -0
- package/src/pen/model.js +3 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +6 -3
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +1 -0
- package/src/store/store.js.map +1 -1
- package/src/utils/file.d.ts +1 -0
- package/src/utils/file.js +8 -0
- package/src/utils/file.js.map +1 -1
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/index.js.map +1 -1
- package/src/utils/object.d.ts +2 -0
- package/src/utils/object.js +21 -0
- package/src/utils/object.js.map +1 -0
package/src/core.js
CHANGED
|
@@ -86,7 +86,7 @@ import { Canvas } from './canvas';
|
|
|
86
86
|
import { calcInView, calcTextDrawRect, calcTextLines, calcTextRect, facePen, formatAttrs, getAllChildren, getFromAnchor, getParent, getToAnchor, getWords, LockState, PenType, renderPenRaw, setElemPosition, connectLine, nearestAnchor, setChildValue, isAncestor, } from './pen';
|
|
87
87
|
import { rotatePoint } from './point';
|
|
88
88
|
import { clearStore, EditType, globalStore, register, registerAnchors, registerCanvasDraw, useStore, } from './store';
|
|
89
|
-
import { formatPadding, s8, valueInArray, valueInRange, } from './utils';
|
|
89
|
+
import { formatPadding, loadCss, s8, valueInArray, valueInRange, } from './utils';
|
|
90
90
|
import { calcCenter, calcRelativeRect, getRect, rectInRect, } from './rect';
|
|
91
91
|
import { deepClone } from './utils/clone';
|
|
92
92
|
import { EventAction } from './event';
|
|
@@ -756,7 +756,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
756
756
|
this.store.patchFlagsBackground = true;
|
|
757
757
|
};
|
|
758
758
|
Meta2d.prototype.setGrid = function (_a) {
|
|
759
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.grid, grid = _c === void 0 ? this.store.data.grid : _c,
|
|
759
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.grid, grid = _c === void 0 ? this.store.data.grid : _c, _e = _b.gridColor, gridColor = _e === void 0 ? this.store.data.gridColor : _e, _f = _b.gridSize, gridSize = _f === void 0 ? this.store.data.gridSize : _f, _g = _b.gridRotate, gridRotate = _g === void 0 ? this.store.data.gridRotate : _g;
|
|
760
760
|
this.store.data.grid = grid;
|
|
761
761
|
this.store.data.gridColor = gridColor;
|
|
762
762
|
this.store.data.gridSize = gridSize;
|
|
@@ -764,13 +764,15 @@ var Meta2d = /** @class */ (function () {
|
|
|
764
764
|
this.store.patchFlagsBackground = true;
|
|
765
765
|
};
|
|
766
766
|
Meta2d.prototype.setRule = function (_a) {
|
|
767
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.rule, rule = _c === void 0 ? this.store.data.rule : _c,
|
|
767
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.rule, rule = _c === void 0 ? this.store.data.rule : _c, _e = _b.ruleColor, ruleColor = _e === void 0 ? this.store.data.ruleColor : _e;
|
|
768
768
|
this.store.data.rule = rule;
|
|
769
769
|
this.store.data.ruleColor = ruleColor;
|
|
770
770
|
this.store.patchFlagsTop = true;
|
|
771
771
|
};
|
|
772
|
-
Meta2d.prototype.open = function (data) {
|
|
773
|
-
var e_1, _a, e_2, _b;
|
|
772
|
+
Meta2d.prototype.open = function (data, render) {
|
|
773
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
774
|
+
var _this = this;
|
|
775
|
+
if (render === void 0) { render = true; }
|
|
774
776
|
this.clear(false);
|
|
775
777
|
if (data) {
|
|
776
778
|
this.setBackgroundImage(data.bkImage);
|
|
@@ -778,8 +780,8 @@ var Meta2d = /** @class */ (function () {
|
|
|
778
780
|
this.store.data.pens = [];
|
|
779
781
|
try {
|
|
780
782
|
// 第一遍赋初值
|
|
781
|
-
for (var
|
|
782
|
-
var pen =
|
|
783
|
+
for (var _e = __values(data.pens), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
784
|
+
var pen = _f.value;
|
|
783
785
|
if (!pen.id) {
|
|
784
786
|
pen.id = s8();
|
|
785
787
|
}
|
|
@@ -790,24 +792,27 @@ var Meta2d = /** @class */ (function () {
|
|
|
790
792
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
791
793
|
finally {
|
|
792
794
|
try {
|
|
793
|
-
if (
|
|
795
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
794
796
|
}
|
|
795
797
|
finally { if (e_1) throw e_1.error; }
|
|
796
798
|
}
|
|
797
799
|
try {
|
|
798
|
-
for (var
|
|
799
|
-
var pen =
|
|
800
|
+
for (var _g = __values(data.pens), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
801
|
+
var pen = _h.value;
|
|
800
802
|
this.canvas.makePen(pen);
|
|
801
803
|
}
|
|
802
804
|
}
|
|
803
805
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
804
806
|
finally {
|
|
805
807
|
try {
|
|
806
|
-
if (
|
|
808
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
807
809
|
}
|
|
808
810
|
finally { if (e_2) throw e_2.error; }
|
|
809
811
|
}
|
|
810
812
|
}
|
|
813
|
+
if (!render) {
|
|
814
|
+
this.canvas.opening = true;
|
|
815
|
+
}
|
|
811
816
|
this.initBindDatas();
|
|
812
817
|
this.render();
|
|
813
818
|
this.listenSocket();
|
|
@@ -815,6 +820,23 @@ var Meta2d = /** @class */ (function () {
|
|
|
815
820
|
this.startAnimate();
|
|
816
821
|
this.startVideo();
|
|
817
822
|
this.doInitJS();
|
|
823
|
+
if (this.store.data.iconUrls) {
|
|
824
|
+
try {
|
|
825
|
+
for (var _j = __values(this.store.data.iconUrls), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
826
|
+
var item = _k.value;
|
|
827
|
+
loadCss(item, function () {
|
|
828
|
+
_this.render();
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
833
|
+
finally {
|
|
834
|
+
try {
|
|
835
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
836
|
+
}
|
|
837
|
+
finally { if (e_3) throw e_3.error; }
|
|
838
|
+
}
|
|
839
|
+
}
|
|
818
840
|
this.store.emitter.emit('opened');
|
|
819
841
|
if (this.canvas.scroll && this.canvas.scroll.isShow) {
|
|
820
842
|
this.canvas.scroll.init();
|
|
@@ -978,21 +1000,21 @@ var Meta2d = /** @class */ (function () {
|
|
|
978
1000
|
* @param render 是否重绘
|
|
979
1001
|
*/
|
|
980
1002
|
Meta2d.prototype.clear = function (render) {
|
|
981
|
-
var
|
|
1003
|
+
var e_4, _a;
|
|
982
1004
|
var _b;
|
|
983
1005
|
if (render === void 0) { render = true; }
|
|
984
1006
|
try {
|
|
985
|
-
for (var _c = __values(this.store.data.pens),
|
|
986
|
-
var pen =
|
|
1007
|
+
for (var _c = __values(this.store.data.pens), _e = _c.next(); !_e.done; _e = _c.next()) {
|
|
1008
|
+
var pen = _e.value;
|
|
987
1009
|
(_b = pen.onDestroy) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
|
|
988
1010
|
}
|
|
989
1011
|
}
|
|
990
|
-
catch (
|
|
1012
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
991
1013
|
finally {
|
|
992
1014
|
try {
|
|
993
|
-
if (
|
|
1015
|
+
if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
|
|
994
1016
|
}
|
|
995
|
-
finally { if (
|
|
1017
|
+
finally { if (e_4) throw e_4.error; }
|
|
996
1018
|
}
|
|
997
1019
|
clearStore(this.store);
|
|
998
1020
|
this.hideInput();
|
|
@@ -1449,7 +1471,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1449
1471
|
var socketFn = void 0;
|
|
1450
1472
|
var socketCbJs = this.store.data.socketCbJs;
|
|
1451
1473
|
if (socketCbJs) {
|
|
1452
|
-
socketFn = new Function('e', '
|
|
1474
|
+
socketFn = new Function('e', 'context', socketCbJs);
|
|
1453
1475
|
}
|
|
1454
1476
|
if (!socketFn) {
|
|
1455
1477
|
return false;
|
|
@@ -1471,7 +1493,10 @@ var Meta2d = /** @class */ (function () {
|
|
|
1471
1493
|
if (this.store.data.websocket) {
|
|
1472
1494
|
this.websocket = new WebSocket(this.store.data.websocket, this.store.data.websocketProtocols);
|
|
1473
1495
|
this.websocket.onmessage = function (e) {
|
|
1474
|
-
_this.socketCallback(e.data
|
|
1496
|
+
_this.socketCallback(e.data, {
|
|
1497
|
+
type: 'websocket',
|
|
1498
|
+
url: _this.store.data.websocket,
|
|
1499
|
+
});
|
|
1475
1500
|
};
|
|
1476
1501
|
this.websocket.onclose = function () {
|
|
1477
1502
|
console.info('Canvas websocket closed and reconneting...');
|
|
@@ -1501,7 +1526,11 @@ var Meta2d = /** @class */ (function () {
|
|
|
1501
1526
|
}
|
|
1502
1527
|
this.mqttClient = mqtt.connect(this.store.data.mqtt, this.store.data.mqttOptions);
|
|
1503
1528
|
this.mqttClient.on('message', function (topic, message) {
|
|
1504
|
-
_this.socketCallback(message.toString(),
|
|
1529
|
+
_this.socketCallback(message.toString(), {
|
|
1530
|
+
topic: topic,
|
|
1531
|
+
type: 'mqtt',
|
|
1532
|
+
url: _this.store.data.mqtt,
|
|
1533
|
+
});
|
|
1505
1534
|
});
|
|
1506
1535
|
if (this.store.data.mqttTopics) {
|
|
1507
1536
|
this.mqttClient.subscribe(this.store.data.mqttTopics.split(','));
|
|
@@ -1532,7 +1561,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1532
1561
|
return [4 /*yield*/, res.text()];
|
|
1533
1562
|
case 2:
|
|
1534
1563
|
data = _a.sent();
|
|
1535
|
-
this.socketCallback(data);
|
|
1564
|
+
this.socketCallback(data, { type: 'http', url: item.http });
|
|
1536
1565
|
_a.label = 3;
|
|
1537
1566
|
case 3: return [2 /*return*/];
|
|
1538
1567
|
}
|
|
@@ -1557,7 +1586,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1557
1586
|
return [4 /*yield*/, res.text()];
|
|
1558
1587
|
case 2:
|
|
1559
1588
|
data = _a.sent();
|
|
1560
|
-
this.socketCallback(data);
|
|
1589
|
+
this.socketCallback(data, { type: 'http', url: http_1 });
|
|
1561
1590
|
_a.label = 3;
|
|
1562
1591
|
case 3: return [2 /*return*/];
|
|
1563
1592
|
}
|
|
@@ -1642,7 +1671,11 @@ var Meta2d = /** @class */ (function () {
|
|
|
1642
1671
|
}
|
|
1643
1672
|
_this.mqttClients[mqttIndex_1] = mqtt.connect(net.url, net.options);
|
|
1644
1673
|
_this.mqttClients[mqttIndex_1].on('message', function (topic, message) {
|
|
1645
|
-
_this.socketCallback(message.toString(),
|
|
1674
|
+
_this.socketCallback(message.toString(), {
|
|
1675
|
+
topic: topic,
|
|
1676
|
+
type: 'mqtt',
|
|
1677
|
+
url: net.url,
|
|
1678
|
+
});
|
|
1646
1679
|
});
|
|
1647
1680
|
if (net.topics) {
|
|
1648
1681
|
_this.mqttClients[mqttIndex_1].subscribe(net.topics.split(','));
|
|
@@ -1652,7 +1685,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1652
1685
|
else if (net.type === 'websocket') {
|
|
1653
1686
|
_this.websockets[websocketIndex_1] = new WebSocket(net.url, net.protocols);
|
|
1654
1687
|
_this.websockets[websocketIndex_1].onmessage = function (e) {
|
|
1655
|
-
_this.socketCallback(e.data);
|
|
1688
|
+
_this.socketCallback(e.data, { type: 'websocket', url: net.url });
|
|
1656
1689
|
};
|
|
1657
1690
|
websocketIndex_1 += 1;
|
|
1658
1691
|
}
|
|
@@ -1663,9 +1696,90 @@ var Meta2d = /** @class */ (function () {
|
|
|
1663
1696
|
this.onNetworkConnect(https_1);
|
|
1664
1697
|
}
|
|
1665
1698
|
};
|
|
1699
|
+
Meta2d.prototype.randomString = function (e) {
|
|
1700
|
+
e = e || 32;
|
|
1701
|
+
var t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678', a = t.length, n = '';
|
|
1702
|
+
for (var i = 0; i < e; i++) {
|
|
1703
|
+
n += t.charAt(Math.floor(Math.random() * a));
|
|
1704
|
+
}
|
|
1705
|
+
return n;
|
|
1706
|
+
};
|
|
1707
|
+
Meta2d.prototype.penMock = function (pen) {
|
|
1708
|
+
var _this = this;
|
|
1709
|
+
var _a;
|
|
1710
|
+
if (pen.realTimes) {
|
|
1711
|
+
var _d_1 = {};
|
|
1712
|
+
pen.realTimes.forEach(function (realTime) {
|
|
1713
|
+
if (!realTime.binds || !realTime.binds.length) {
|
|
1714
|
+
if (realTime.type === 'number') {
|
|
1715
|
+
if (realTime.value && realTime.value.indexOf(',') !== -1) {
|
|
1716
|
+
var arr = realTime.value.split(',');
|
|
1717
|
+
var rai = Math.floor(Math.random() * arr.length);
|
|
1718
|
+
_d_1[realTime.key] = parseFloat(arr[rai]);
|
|
1719
|
+
}
|
|
1720
|
+
else if (realTime.value && realTime.value.indexOf('-') !== -1) {
|
|
1721
|
+
var arr = realTime.value.split('-');
|
|
1722
|
+
var max = parseFloat(arr[1]);
|
|
1723
|
+
var min = parseFloat(arr[0]);
|
|
1724
|
+
_d_1[realTime.key] = Math.random() * (max - min) + min;
|
|
1725
|
+
}
|
|
1726
|
+
else {
|
|
1727
|
+
_d_1[realTime.key] = parseFloat(realTime.value);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
else if (realTime.type === 'bool') {
|
|
1731
|
+
if (typeof realTime.value === 'boolean') {
|
|
1732
|
+
_d_1[realTime.key] = realTime.value;
|
|
1733
|
+
}
|
|
1734
|
+
else if ('true' === realTime.value) {
|
|
1735
|
+
_d_1[realTime.key] = true;
|
|
1736
|
+
}
|
|
1737
|
+
else if ('false' === realTime.value) {
|
|
1738
|
+
_d_1[realTime.key] = false;
|
|
1739
|
+
}
|
|
1740
|
+
else {
|
|
1741
|
+
_d_1[realTime.key] = Math.random() < 0.5;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
else if (realTime.type === 'object' || realTime.type === 'array') {
|
|
1745
|
+
_d_1[realTime.key] = realTime.value;
|
|
1746
|
+
}
|
|
1747
|
+
else {
|
|
1748
|
+
//if (realTime.type === 'string')
|
|
1749
|
+
if (realTime.value &&
|
|
1750
|
+
realTime.value.startsWith('{') &&
|
|
1751
|
+
realTime.value.endsWith('}')) {
|
|
1752
|
+
var str = realTime.value.substring(1, realTime.value.length - 1);
|
|
1753
|
+
var arr = str.split(',');
|
|
1754
|
+
var rai = Math.floor(Math.random() * arr.length);
|
|
1755
|
+
_d_1[realTime.key] = arr[rai];
|
|
1756
|
+
}
|
|
1757
|
+
else if (realTime.value &&
|
|
1758
|
+
realTime.value.startsWith('[') &&
|
|
1759
|
+
realTime.value.endsWith(']')) {
|
|
1760
|
+
var len = parseInt(realTime.value.substring(1, realTime.value.length - 1));
|
|
1761
|
+
_d_1[realTime.key] = _this.randomString(len);
|
|
1762
|
+
}
|
|
1763
|
+
else {
|
|
1764
|
+
_d_1[realTime.key] = realTime.value;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
if (Object.keys(_d_1).length) {
|
|
1770
|
+
this.canvas.updateValue(pen, _d_1);
|
|
1771
|
+
this.store.emitter.emit('valueUpdate', pen);
|
|
1772
|
+
(_a = pen.onValue) === null || _a === void 0 ? void 0 : _a.call(pen, pen);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1666
1776
|
Meta2d.prototype.onNetworkConnect = function (https) {
|
|
1667
1777
|
var _this = this;
|
|
1668
|
-
this.
|
|
1778
|
+
this.updateTimer = setInterval(function () {
|
|
1779
|
+
//模拟数据
|
|
1780
|
+
_this.store.data.pens.forEach(function (pen) {
|
|
1781
|
+
_this.penMock(pen);
|
|
1782
|
+
});
|
|
1669
1783
|
https.forEach(function (item) { return __awaiter(_this, void 0, void 0, function () {
|
|
1670
1784
|
var res, data;
|
|
1671
1785
|
return __generator(this, function (_a) {
|
|
@@ -1683,14 +1797,13 @@ var Meta2d = /** @class */ (function () {
|
|
|
1683
1797
|
return [4 /*yield*/, res.text()];
|
|
1684
1798
|
case 2:
|
|
1685
1799
|
data = _a.sent();
|
|
1686
|
-
this.socketCallback(data);
|
|
1800
|
+
this.socketCallback(data, { type: 'http', url: item.url });
|
|
1687
1801
|
_a.label = 3;
|
|
1688
1802
|
case 3: return [2 /*return*/];
|
|
1689
1803
|
}
|
|
1690
1804
|
});
|
|
1691
1805
|
}); });
|
|
1692
|
-
|
|
1693
|
-
_this.store.data.mockData && _this.store.data.mockData();
|
|
1806
|
+
_this.render();
|
|
1694
1807
|
}, this.store.data.networkInterval || 1000);
|
|
1695
1808
|
};
|
|
1696
1809
|
Meta2d.prototype.closeNetwork = function () {
|
|
@@ -1704,14 +1817,19 @@ var Meta2d = /** @class */ (function () {
|
|
|
1704
1817
|
});
|
|
1705
1818
|
this.mqttClients = undefined;
|
|
1706
1819
|
this.websockets = undefined;
|
|
1707
|
-
clearInterval(this.
|
|
1708
|
-
this.
|
|
1820
|
+
clearInterval(this.updateTimer);
|
|
1821
|
+
this.updateTimer = undefined;
|
|
1709
1822
|
};
|
|
1710
|
-
Meta2d.prototype.socketCallback = function (message,
|
|
1823
|
+
Meta2d.prototype.socketCallback = function (message, context) {
|
|
1711
1824
|
var _this = this;
|
|
1712
|
-
|
|
1713
|
-
this.
|
|
1714
|
-
|
|
1825
|
+
this.store.emitter.emit('socket', { message: message, context: context });
|
|
1826
|
+
if (this.socketFn &&
|
|
1827
|
+
!this.socketFn(message, {
|
|
1828
|
+
meta2d: this,
|
|
1829
|
+
type: context.type,
|
|
1830
|
+
topic: context.topic,
|
|
1831
|
+
url: context.url,
|
|
1832
|
+
})) {
|
|
1715
1833
|
return;
|
|
1716
1834
|
}
|
|
1717
1835
|
var data;
|
|
@@ -1747,7 +1865,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1747
1865
|
// 绑定变量方式更新组件数据
|
|
1748
1866
|
Meta2d.prototype.setDatas = function (datas, _a) {
|
|
1749
1867
|
var _this = this;
|
|
1750
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.render, render = _c === void 0 ? true : _c,
|
|
1868
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.render, render = _c === void 0 ? true : _c, _e = _b.doEvent, doEvent = _e === void 0 ? true : _e, history = _b.history;
|
|
1751
1869
|
// 把{dataId: string; value: any}转成setValue格式数据
|
|
1752
1870
|
var penValues = new Map();
|
|
1753
1871
|
datas.forEach(function (v) {
|
|
@@ -1803,7 +1921,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1803
1921
|
};
|
|
1804
1922
|
Meta2d.prototype.setValue = function (data, _a) {
|
|
1805
1923
|
var _this = this;
|
|
1806
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.render, render = _c === void 0 ? true : _c,
|
|
1924
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.render, render = _c === void 0 ? true : _c, _e = _b.doEvent, doEvent = _e === void 0 ? true : _e, history = _b.history;
|
|
1807
1925
|
var pens = [];
|
|
1808
1926
|
if (data.id) {
|
|
1809
1927
|
if (data.id === this.store.data.id) {
|
|
@@ -2020,12 +2138,33 @@ var Meta2d = /** @class */ (function () {
|
|
|
2020
2138
|
* @param padding 上右下左的内边距
|
|
2021
2139
|
*/
|
|
2022
2140
|
Meta2d.prototype.downloadPng = function (name, padding) {
|
|
2023
|
-
var
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2141
|
+
var e_5, _a;
|
|
2142
|
+
var _this = this;
|
|
2143
|
+
var _b;
|
|
2144
|
+
try {
|
|
2145
|
+
for (var _c = __values(this.store.data.pens), _e = _c.next(); !_e.done; _e = _c.next()) {
|
|
2146
|
+
var pen = _e.value;
|
|
2147
|
+
if (pen.calculative.img) {
|
|
2148
|
+
//重新生成绘制图片
|
|
2149
|
+
(_b = pen.onRenderPenRaw) === null || _b === void 0 ? void 0 : _b.call(pen, pen);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2154
|
+
finally {
|
|
2155
|
+
try {
|
|
2156
|
+
if (_e && !_e.done && (_a = _c.return)) _a.call(_c);
|
|
2157
|
+
}
|
|
2158
|
+
finally { if (e_5) throw e_5.error; }
|
|
2159
|
+
}
|
|
2160
|
+
setTimeout(function () {
|
|
2161
|
+
var a = document.createElement('a');
|
|
2162
|
+
a.setAttribute('download', name || 'le5le.meta2d.png');
|
|
2163
|
+
a.setAttribute('href', _this.toPng(padding, undefined, true));
|
|
2164
|
+
var evt = document.createEvent('MouseEvents');
|
|
2165
|
+
evt.initEvent('click', true, true);
|
|
2166
|
+
a.dispatchEvent(evt);
|
|
2167
|
+
});
|
|
2029
2168
|
};
|
|
2030
2169
|
Meta2d.prototype.getRect = function (pens) {
|
|
2031
2170
|
if (pens === void 0) { pens = this.store.data.pens; }
|
|
@@ -2346,7 +2485,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
2346
2485
|
this.formatPainter();
|
|
2347
2486
|
};
|
|
2348
2487
|
Meta2d.prototype.alignNodes = function (align, pens, rect) {
|
|
2349
|
-
var
|
|
2488
|
+
var e_6, _a;
|
|
2350
2489
|
if (pens === void 0) { pens = this.store.data.pens; }
|
|
2351
2490
|
!rect && (rect = this.getPenRect(this.getRect(pens)));
|
|
2352
2491
|
var initPens = deepClone(pens); // 原 pens ,深拷贝一下
|
|
@@ -2356,12 +2495,12 @@ var Meta2d = /** @class */ (function () {
|
|
|
2356
2495
|
this.alignPen(align, item, rect);
|
|
2357
2496
|
}
|
|
2358
2497
|
}
|
|
2359
|
-
catch (
|
|
2498
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
2360
2499
|
finally {
|
|
2361
2500
|
try {
|
|
2362
2501
|
if (pens_1_1 && !pens_1_1.done && (_a = pens_1.return)) _a.call(pens_1);
|
|
2363
2502
|
}
|
|
2364
|
-
finally { if (
|
|
2503
|
+
finally { if (e_6) throw e_6.error; }
|
|
2365
2504
|
}
|
|
2366
2505
|
this.render();
|
|
2367
2506
|
this.pushHistory({
|
|
@@ -2450,7 +2589,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
2450
2589
|
* @param distance 总的宽 or 高
|
|
2451
2590
|
*/
|
|
2452
2591
|
Meta2d.prototype.spaceBetweenByDirection = function (direction, pens, distance) {
|
|
2453
|
-
var
|
|
2592
|
+
var e_7, _a;
|
|
2454
2593
|
var _this = this;
|
|
2455
2594
|
if (pens === void 0) { pens = this.store.data.pens; }
|
|
2456
2595
|
!distance && (distance = this.getPenRect(this.getRect(pens))[direction]);
|
|
@@ -2484,12 +2623,12 @@ var Meta2d = /** @class */ (function () {
|
|
|
2484
2623
|
this.setValue(__assign({ id: pen.id }, penRect), { render: false, doEvent: false });
|
|
2485
2624
|
}
|
|
2486
2625
|
}
|
|
2487
|
-
catch (
|
|
2626
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
2488
2627
|
finally {
|
|
2489
2628
|
try {
|
|
2490
2629
|
if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
|
|
2491
2630
|
}
|
|
2492
|
-
finally { if (
|
|
2631
|
+
finally { if (e_7) throw e_7.error; }
|
|
2493
2632
|
}
|
|
2494
2633
|
this.render();
|
|
2495
2634
|
this.pushHistory({
|
|
@@ -2603,22 +2742,52 @@ var Meta2d = /** @class */ (function () {
|
|
|
2603
2742
|
};
|
|
2604
2743
|
/**
|
|
2605
2744
|
* 将该画笔置顶,即放到数组最后,最后绘制即在顶部
|
|
2606
|
-
* @param
|
|
2745
|
+
* @param pens pen 置顶的画笔
|
|
2607
2746
|
*/
|
|
2608
|
-
Meta2d.prototype.top = function (
|
|
2747
|
+
Meta2d.prototype.top = function (pens) {
|
|
2748
|
+
var e_8, _a;
|
|
2609
2749
|
var _this = this;
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
var
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2750
|
+
if (!pens)
|
|
2751
|
+
pens = this.store.active;
|
|
2752
|
+
if (!Array.isArray(pens))
|
|
2753
|
+
pens = [pens]; // 兼容
|
|
2754
|
+
var _loop_3 = function (pen) {
|
|
2755
|
+
var _pens = this_1.store.data.pens;
|
|
2756
|
+
// 获取它包含它的子节点
|
|
2757
|
+
var allIds = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_1.store)), false), [pen], false).map(function (p) { return p.id; });
|
|
2758
|
+
var allPens = _pens.filter(function (p) { return allIds.includes(p.id); });
|
|
2759
|
+
allPens.forEach(function (pen) {
|
|
2760
|
+
var index = _pens.findIndex(function (p) { return p.id === pen.id; });
|
|
2761
|
+
if (index > -1) {
|
|
2762
|
+
_pens.push(_pens[index]);
|
|
2763
|
+
_pens.splice(index, 1);
|
|
2764
|
+
_this.initImageCanvas([pen]);
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
//image
|
|
2768
|
+
if (pen.image && pen.name !== 'gif') {
|
|
2769
|
+
this_1.setValue({ id: pen.id, isBottom: false }, { render: false, doEvent: false, history: false });
|
|
2620
2770
|
}
|
|
2621
|
-
|
|
2771
|
+
//dom
|
|
2772
|
+
if (pen.externElement || pen.name === 'gif') {
|
|
2773
|
+
pen.calculative.canvas.maxZindex += 1;
|
|
2774
|
+
this_1.setValue({ id: pen.id, zIndex: pen.calculative.canvas.maxZindex }, { render: false, doEvent: false, history: false });
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
var this_1 = this;
|
|
2778
|
+
try {
|
|
2779
|
+
for (var _b = __values(pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2780
|
+
var pen = _c.value;
|
|
2781
|
+
_loop_3(pen);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
2785
|
+
finally {
|
|
2786
|
+
try {
|
|
2787
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2788
|
+
}
|
|
2789
|
+
finally { if (e_8) throw e_8.error; }
|
|
2790
|
+
}
|
|
2622
2791
|
};
|
|
2623
2792
|
/**
|
|
2624
2793
|
* 若本次改变的画笔存在图片,并且在上层 or 下层,需要擦除上层 or 下层
|
|
@@ -2632,23 +2801,51 @@ var Meta2d = /** @class */ (function () {
|
|
|
2632
2801
|
* 该画笔置底,即放到数组最前,最后绘制即在底部
|
|
2633
2802
|
* @param pens 画笔们,注意 pen 必须在该数组内才有效
|
|
2634
2803
|
*/
|
|
2635
|
-
Meta2d.prototype.bottom = function (
|
|
2636
|
-
var
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2804
|
+
Meta2d.prototype.bottom = function (pens) {
|
|
2805
|
+
var e_9, _a;
|
|
2806
|
+
if (!pens)
|
|
2807
|
+
pens = this.store.active;
|
|
2808
|
+
if (!Array.isArray(pens))
|
|
2809
|
+
pens = [pens]; // 兼容
|
|
2810
|
+
var _loop_4 = function (pen) {
|
|
2811
|
+
var _pens = this_2.store.data.pens;
|
|
2812
|
+
var allIds = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_2.store)), false), [pen], false).map(function (p) { return p.id; });
|
|
2813
|
+
var allPens = _pens.filter(function (p) { return allIds.includes(p.id); });
|
|
2814
|
+
var _loop_5 = function (i) {
|
|
2815
|
+
var pen_1 = allPens[i];
|
|
2816
|
+
var index = _pens.findIndex(function (p) { return p.id === pen_1.id; });
|
|
2817
|
+
if (index > -1) {
|
|
2818
|
+
_pens.unshift(_pens[index]);
|
|
2819
|
+
_pens.splice(index + 1, 1);
|
|
2820
|
+
this_2.initImageCanvas([pen_1]);
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
// 从后往前,保证 allPens 顺序不变
|
|
2824
|
+
for (var i = allPens.length - 1; i >= 0; i--) {
|
|
2825
|
+
_loop_5(i);
|
|
2826
|
+
}
|
|
2827
|
+
//image
|
|
2828
|
+
if (pen.image && pen.name !== 'gif') {
|
|
2829
|
+
this_2.setValue({ id: pen.id, isBottom: true }, { render: false, doEvent: false, history: false });
|
|
2830
|
+
}
|
|
2831
|
+
//dom
|
|
2832
|
+
if (pen.externElement || pen.name === 'gif') {
|
|
2833
|
+
this_2.setValue({ id: pen.id, zIndex: 0 }, { render: false, doEvent: false, history: false });
|
|
2646
2834
|
}
|
|
2647
2835
|
};
|
|
2648
|
-
var
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2836
|
+
var this_2 = this;
|
|
2837
|
+
try {
|
|
2838
|
+
for (var _b = __values(pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2839
|
+
var pen = _c.value;
|
|
2840
|
+
_loop_4(pen);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2844
|
+
finally {
|
|
2845
|
+
try {
|
|
2846
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2847
|
+
}
|
|
2848
|
+
finally { if (e_9) throw e_9.error; }
|
|
2652
2849
|
}
|
|
2653
2850
|
};
|
|
2654
2851
|
/**
|
|
@@ -2657,7 +2854,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
2657
2854
|
* @param pen 画笔
|
|
2658
2855
|
*/
|
|
2659
2856
|
Meta2d.prototype.upByArea = function (pen) {
|
|
2660
|
-
var _a,
|
|
2857
|
+
var _a, e_10, _b;
|
|
2661
2858
|
var _this = this;
|
|
2662
2859
|
var index = this.store.data.pens.findIndex(function (p) { return p.id === pen.id; });
|
|
2663
2860
|
if (index === -1) {
|
|
@@ -2693,111 +2890,174 @@ var Meta2d = /** @class */ (function () {
|
|
|
2693
2890
|
return;
|
|
2694
2891
|
}
|
|
2695
2892
|
(_a = this.store.data.pens).splice.apply(_a, __spreadArray([nextHitIndex + 1, 0], __read(allPens), false));
|
|
2696
|
-
var
|
|
2697
|
-
var index_1 =
|
|
2893
|
+
var _loop_6 = function (pen_2) {
|
|
2894
|
+
var index_1 = this_3.store.data.pens.findIndex(function (p) { return p.id === pen_2.id; });
|
|
2698
2895
|
if (index_1 > -1) {
|
|
2699
|
-
|
|
2896
|
+
this_3.store.data.pens.splice(index_1, 1);
|
|
2700
2897
|
}
|
|
2701
2898
|
};
|
|
2702
|
-
var
|
|
2899
|
+
var this_3 = this;
|
|
2703
2900
|
try {
|
|
2704
2901
|
// 删除靠前的 allPens
|
|
2705
2902
|
for (var allPens_1 = __values(allPens), allPens_1_1 = allPens_1.next(); !allPens_1_1.done; allPens_1_1 = allPens_1.next()) {
|
|
2706
2903
|
var pen_2 = allPens_1_1.value;
|
|
2707
|
-
|
|
2904
|
+
_loop_6(pen_2);
|
|
2708
2905
|
}
|
|
2709
2906
|
}
|
|
2710
|
-
catch (
|
|
2907
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
2711
2908
|
finally {
|
|
2712
2909
|
try {
|
|
2713
2910
|
if (allPens_1_1 && !allPens_1_1.done && (_b = allPens_1.return)) _b.call(allPens_1);
|
|
2714
2911
|
}
|
|
2715
|
-
finally { if (
|
|
2912
|
+
finally { if (e_10) throw e_10.error; }
|
|
2716
2913
|
}
|
|
2717
2914
|
this.initImageCanvas([pen]);
|
|
2718
2915
|
};
|
|
2719
2916
|
/**
|
|
2720
2917
|
* 该画笔上移,即把该画笔在数组中的位置向后移动一个
|
|
2721
|
-
* @param
|
|
2918
|
+
* @param pens 画笔
|
|
2722
2919
|
*/
|
|
2723
|
-
Meta2d.prototype.up = function (
|
|
2724
|
-
var
|
|
2725
|
-
if (
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
var
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2920
|
+
Meta2d.prototype.up = function (pens) {
|
|
2921
|
+
var e_11, _a;
|
|
2922
|
+
if (!pens)
|
|
2923
|
+
pens = this.store.active;
|
|
2924
|
+
if (!Array.isArray(pens))
|
|
2925
|
+
pens = [pens]; // 兼容
|
|
2926
|
+
var _loop_7 = function (pen) {
|
|
2927
|
+
var _pens = this_4.store.data.pens;
|
|
2928
|
+
if (pen.children) {
|
|
2929
|
+
//组合图元
|
|
2930
|
+
var preMovePens = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_4.store)), false), [pen], false);
|
|
2931
|
+
//先保证组合图元的顺序正确。
|
|
2932
|
+
var orderPens = [];
|
|
2933
|
+
var _loop_8 = function (index) {
|
|
2934
|
+
var _pen = _pens[index];
|
|
2935
|
+
if (preMovePens.findIndex(function (p) { return p.id === _pen.id; }) !== -1) {
|
|
2936
|
+
_pen.temIndex = index;
|
|
2937
|
+
orderPens.push(_pen);
|
|
2938
|
+
}
|
|
2939
|
+
};
|
|
2940
|
+
for (var index = 0; index < _pens.length; index++) {
|
|
2941
|
+
_loop_8(index);
|
|
2735
2942
|
}
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2943
|
+
var lastIndex_1 = -1;
|
|
2944
|
+
var offset_1 = 0;
|
|
2945
|
+
orderPens.forEach(function (_pen) {
|
|
2946
|
+
_pen.temIndex -= offset_1;
|
|
2947
|
+
_pens.splice(_pen.temIndex, 1);
|
|
2948
|
+
offset_1 += 1;
|
|
2949
|
+
lastIndex_1 = _pen.temIndex;
|
|
2950
|
+
delete _pen.temIndex;
|
|
2951
|
+
});
|
|
2952
|
+
_pens.splice.apply(_pens, __spreadArray([lastIndex_1 + 1, 0], __read(preMovePens), false));
|
|
2953
|
+
}
|
|
2954
|
+
else {
|
|
2955
|
+
var index = _pens.findIndex(function (p) { return p.id === pen.id; });
|
|
2956
|
+
if (index > -1 && index !== _pens.length - 1) {
|
|
2957
|
+
_pens.splice(index + 2, 0, _pens[index]);
|
|
2958
|
+
_pens.splice(index, 1);
|
|
2959
|
+
this_4.initImageCanvas([pen]);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
//image
|
|
2963
|
+
if (pen.image && pen.name !== 'gif') {
|
|
2964
|
+
this_4.setValue({ id: pen.id, isBottom: false }, { render: false, doEvent: false, history: false });
|
|
2965
|
+
}
|
|
2966
|
+
//dom
|
|
2967
|
+
if (pen.externElement || pen.name === 'gif') {
|
|
2968
|
+
var zIndex = pen.calculative.zIndex === undefined ? 5 : pen.calculative.zIndex + 1;
|
|
2969
|
+
this_4.setValue({ id: pen.id, zIndex: zIndex }, { render: false, doEvent: false, history: false });
|
|
2970
|
+
}
|
|
2971
|
+
};
|
|
2972
|
+
var this_4 = this;
|
|
2973
|
+
try {
|
|
2974
|
+
for (var _b = __values(pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2975
|
+
var pen = _c.value;
|
|
2976
|
+
_loop_7(pen);
|
|
2977
|
+
}
|
|
2750
2978
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
pens.splice(index, 1);
|
|
2756
|
-
this.initImageCanvas([pen]);
|
|
2979
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
2980
|
+
finally {
|
|
2981
|
+
try {
|
|
2982
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2757
2983
|
}
|
|
2984
|
+
finally { if (e_11) throw e_11.error; }
|
|
2758
2985
|
}
|
|
2759
2986
|
};
|
|
2760
2987
|
/**
|
|
2761
2988
|
* 该画笔下移,即把该画笔在该数组中的位置前移一个
|
|
2762
2989
|
* @param pen 画笔
|
|
2763
2990
|
*/
|
|
2764
|
-
Meta2d.prototype.down = function (
|
|
2765
|
-
var
|
|
2766
|
-
if (
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
var
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2991
|
+
Meta2d.prototype.down = function (pens) {
|
|
2992
|
+
var e_12, _a;
|
|
2993
|
+
if (!pens)
|
|
2994
|
+
pens = this.store.active;
|
|
2995
|
+
if (!Array.isArray(pens))
|
|
2996
|
+
pens = [pens]; // 兼容
|
|
2997
|
+
var _loop_9 = function (pen) {
|
|
2998
|
+
var _pens = this_5.store.data.pens;
|
|
2999
|
+
if (pen.children) {
|
|
3000
|
+
//组合图元
|
|
3001
|
+
var preMovePens = __spreadArray(__spreadArray([], __read(getAllChildren(pen, this_5.store)), false), [pen], false);
|
|
3002
|
+
//先保证组合图元的顺序正确。
|
|
3003
|
+
var orderPens = [];
|
|
3004
|
+
var _loop_10 = function (index) {
|
|
3005
|
+
var _pen = _pens[index];
|
|
3006
|
+
if (preMovePens.findIndex(function (p) { return p.id === _pen.id; }) !== -1) {
|
|
3007
|
+
_pen.temIndex = index;
|
|
3008
|
+
orderPens.push(_pen);
|
|
3009
|
+
}
|
|
3010
|
+
};
|
|
3011
|
+
for (var index = 0; index < _pens.length; index++) {
|
|
3012
|
+
_loop_10(index);
|
|
2776
3013
|
}
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
3014
|
+
var firstIndex_1 = -1;
|
|
3015
|
+
var offset_2 = 0;
|
|
3016
|
+
orderPens.forEach(function (_pen, index) {
|
|
3017
|
+
_pen.temIndex -= offset_2;
|
|
3018
|
+
_pens.splice(_pen.temIndex, 1);
|
|
3019
|
+
offset_2 += 1;
|
|
3020
|
+
if (index === 0) {
|
|
3021
|
+
firstIndex_1 = _pen.temIndex;
|
|
3022
|
+
}
|
|
3023
|
+
delete _pen.temIndex;
|
|
3024
|
+
});
|
|
3025
|
+
_pens.splice.apply(_pens, __spreadArray([firstIndex_1 - 1, 0], __read(preMovePens), false));
|
|
3026
|
+
}
|
|
3027
|
+
else {
|
|
3028
|
+
var index = _pens.findIndex(function (p) { return p.id === pen.id; });
|
|
3029
|
+
if (index > -1 && index !== 0) {
|
|
3030
|
+
_pens.splice(index - 1, 0, _pens[index]);
|
|
3031
|
+
_pens.splice(index + 1, 1);
|
|
3032
|
+
this_5.initImageCanvas([pen]);
|
|
2789
3033
|
}
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
3034
|
+
}
|
|
3035
|
+
//image
|
|
3036
|
+
if (pen.image && pen.name !== 'gif') {
|
|
3037
|
+
this_5.setValue({ id: pen.id, isBottom: true }, { render: false, doEvent: false, history: false });
|
|
3038
|
+
}
|
|
3039
|
+
//dom
|
|
3040
|
+
if (pen.externElement || pen.name === 'gif') {
|
|
3041
|
+
var zIndex = pen.calculative.zIndex === undefined ? 3 : pen.calculative.zIndex - 1;
|
|
3042
|
+
if (zIndex < 0) {
|
|
3043
|
+
zIndex = 0;
|
|
3044
|
+
}
|
|
3045
|
+
this_5.setValue({ id: pen.id, zIndex: zIndex }, { render: false, doEvent: false, history: false });
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
3048
|
+
var this_5 = this;
|
|
3049
|
+
try {
|
|
3050
|
+
for (var _b = __values(pens), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3051
|
+
var pen = _c.value;
|
|
3052
|
+
_loop_9(pen);
|
|
3053
|
+
}
|
|
2793
3054
|
}
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
pens.splice(index + 1, 1);
|
|
2799
|
-
this.initImageCanvas([pen]);
|
|
3055
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3056
|
+
finally {
|
|
3057
|
+
try {
|
|
3058
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2800
3059
|
}
|
|
3060
|
+
finally { if (e_12) throw e_12.error; }
|
|
2801
3061
|
}
|
|
2802
3062
|
};
|
|
2803
3063
|
Meta2d.prototype.setLayer = function (pen, toIndex, pens) {
|
|
@@ -2872,9 +3132,9 @@ var Meta2d = /** @class */ (function () {
|
|
|
2872
3132
|
var nextNodes_1 = [];
|
|
2873
3133
|
// 2. 遍历出线的 nextNode
|
|
2874
3134
|
lines.forEach(function (line) {
|
|
2875
|
-
var
|
|
3135
|
+
var e_13, _a;
|
|
2876
3136
|
var lineNextNode = _this.nextNode(line);
|
|
2877
|
-
var
|
|
3137
|
+
var _loop_11 = function (node) {
|
|
2878
3138
|
var have = nextNodes_1.find(function (next) { return next.id === node.id; });
|
|
2879
3139
|
// 3. 不重复的才加进去
|
|
2880
3140
|
!have && nextNodes_1.push(node);
|
|
@@ -2882,15 +3142,15 @@ var Meta2d = /** @class */ (function () {
|
|
|
2882
3142
|
try {
|
|
2883
3143
|
for (var lineNextNode_1 = __values(lineNextNode), lineNextNode_1_1 = lineNextNode_1.next(); !lineNextNode_1_1.done; lineNextNode_1_1 = lineNextNode_1.next()) {
|
|
2884
3144
|
var node = lineNextNode_1_1.value;
|
|
2885
|
-
|
|
3145
|
+
_loop_11(node);
|
|
2886
3146
|
}
|
|
2887
3147
|
}
|
|
2888
|
-
catch (
|
|
3148
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2889
3149
|
finally {
|
|
2890
3150
|
try {
|
|
2891
3151
|
if (lineNextNode_1_1 && !lineNextNode_1_1.done && (_a = lineNextNode_1.return)) _a.call(lineNextNode_1);
|
|
2892
3152
|
}
|
|
2893
|
-
finally { if (
|
|
3153
|
+
finally { if (e_13) throw e_13.error; }
|
|
2894
3154
|
}
|
|
2895
3155
|
});
|
|
2896
3156
|
return nextNodes_1;
|
|
@@ -2913,9 +3173,9 @@ var Meta2d = /** @class */ (function () {
|
|
|
2913
3173
|
var preNodes_1 = [];
|
|
2914
3174
|
// 2. 遍历入线的 preNode
|
|
2915
3175
|
lines.forEach(function (line) {
|
|
2916
|
-
var
|
|
3176
|
+
var e_14, _a;
|
|
2917
3177
|
var linePreNode = _this.previousNode(line);
|
|
2918
|
-
var
|
|
3178
|
+
var _loop_12 = function (node) {
|
|
2919
3179
|
var have = preNodes_1.find(function (pre) { return pre.id === node.id; });
|
|
2920
3180
|
// 3. 不重复的才加进去
|
|
2921
3181
|
!have && preNodes_1.push(node);
|
|
@@ -2923,15 +3183,15 @@ var Meta2d = /** @class */ (function () {
|
|
|
2923
3183
|
try {
|
|
2924
3184
|
for (var linePreNode_1 = __values(linePreNode), linePreNode_1_1 = linePreNode_1.next(); !linePreNode_1_1.done; linePreNode_1_1 = linePreNode_1.next()) {
|
|
2925
3185
|
var node = linePreNode_1_1.value;
|
|
2926
|
-
|
|
3186
|
+
_loop_12(node);
|
|
2927
3187
|
}
|
|
2928
3188
|
}
|
|
2929
|
-
catch (
|
|
3189
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2930
3190
|
finally {
|
|
2931
3191
|
try {
|
|
2932
3192
|
if (linePreNode_1_1 && !linePreNode_1_1.done && (_a = linePreNode_1.return)) _a.call(linePreNode_1);
|
|
2933
3193
|
}
|
|
2934
|
-
finally { if (
|
|
3194
|
+
finally { if (e_14) throw e_14.error; }
|
|
2935
3195
|
}
|
|
2936
3196
|
});
|
|
2937
3197
|
return preNodes_1;
|
|
@@ -3207,7 +3467,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
3207
3467
|
: deepClone(__spreadArray([parent], __read(components), false));
|
|
3208
3468
|
};
|
|
3209
3469
|
Meta2d.prototype.setVisible = function (pen, visible, render) {
|
|
3210
|
-
var
|
|
3470
|
+
var e_15, _a;
|
|
3211
3471
|
if (render === void 0) { render = true; }
|
|
3212
3472
|
this.onSizeUpdate();
|
|
3213
3473
|
this.setValue({ id: pen.id, visible: visible }, { render: false, doEvent: false });
|
|
@@ -3219,12 +3479,12 @@ var Meta2d = /** @class */ (function () {
|
|
|
3219
3479
|
child && this.setVisible(child, visible, false);
|
|
3220
3480
|
}
|
|
3221
3481
|
}
|
|
3222
|
-
catch (
|
|
3482
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
3223
3483
|
finally {
|
|
3224
3484
|
try {
|
|
3225
3485
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3226
3486
|
}
|
|
3227
|
-
finally { if (
|
|
3487
|
+
finally { if (e_15) throw e_15.error; }
|
|
3228
3488
|
}
|
|
3229
3489
|
}
|
|
3230
3490
|
render && this.render();
|