@meta2d/core 1.0.44 → 1.0.46
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.js +9 -7
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +2 -1
- package/src/core.js +88 -21
- package/src/core.js.map +1 -1
- package/src/diagrams/video.js +3 -0
- package/src/diagrams/video.js.map +1 -1
- package/src/options.d.ts +1 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/render.js +4 -1
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +3 -3
- package/src/pen/text.js.map +1 -1
package/src/core.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class Meta2d {
|
|
|
27
27
|
type?: string;
|
|
28
28
|
topic?: string;
|
|
29
29
|
url?: string;
|
|
30
|
-
}) => boolean;
|
|
30
|
+
}) => boolean | string;
|
|
31
31
|
events: Record<number, (pen: Pen, e: Event) => void>;
|
|
32
32
|
map: ViewMap;
|
|
33
33
|
mapTimer: any;
|
|
@@ -158,6 +158,7 @@ export declare class Meta2d {
|
|
|
158
158
|
*/
|
|
159
159
|
combine(pens?: Pen[], showChild?: number): void;
|
|
160
160
|
uncombine(pen?: Pen): void;
|
|
161
|
+
appendChild(pens?: Pen[]): void;
|
|
161
162
|
isCombine(pen: Pen): boolean;
|
|
162
163
|
active(pens: Pen[], emit?: boolean): void;
|
|
163
164
|
inactive(): void;
|
package/src/core.js
CHANGED
|
@@ -187,9 +187,27 @@ var Meta2d = /** @class */ (function () {
|
|
|
187
187
|
}
|
|
188
188
|
if (_this.store.messageEvents[eventName]) {
|
|
189
189
|
_this.store.messageEvents[eventName].forEach(function (item) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
var flag = false;
|
|
191
|
+
if (item.event.conditions && item.event.conditions.length) {
|
|
192
|
+
if (item.event.conditionType === 'and') {
|
|
193
|
+
flag = item.event.conditions.every(function (condition) {
|
|
194
|
+
return _this.judgeCondition(item.pen, condition.key, condition);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else if (item.event.conditionType === 'or') {
|
|
198
|
+
flag = item.event.conditions.some(function (condition) {
|
|
199
|
+
return _this.judgeCondition(item.pen, condition.key, condition);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
flag = true;
|
|
205
|
+
}
|
|
206
|
+
if (flag) {
|
|
207
|
+
item.event.actions.forEach(function (action) {
|
|
208
|
+
_this.events[action.action](item.pen, action);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
193
211
|
});
|
|
194
212
|
}
|
|
195
213
|
};
|
|
@@ -553,7 +571,9 @@ var Meta2d = /** @class */ (function () {
|
|
|
553
571
|
var pens = e.params ? _this.find(e.params) : _this.find(pen.id);
|
|
554
572
|
pens.forEach(function (pen) {
|
|
555
573
|
if (value.hasOwnProperty('visible')) {
|
|
556
|
-
|
|
574
|
+
if (pen.visible !== value.visible) {
|
|
575
|
+
_this.setVisible(pen, value.visible);
|
|
576
|
+
}
|
|
557
577
|
}
|
|
558
578
|
_this.setValue(__assign({ id: pen.id }, value), { render: false, doEvent: false });
|
|
559
579
|
});
|
|
@@ -589,6 +609,17 @@ var Meta2d = /** @class */ (function () {
|
|
|
589
609
|
};
|
|
590
610
|
this.events[EventAction.StopAnimate] = function (pen, e) {
|
|
591
611
|
if (!e.value || typeof e.value === 'string') {
|
|
612
|
+
if (e.value) {
|
|
613
|
+
var _pen = _this.findOne(e.value);
|
|
614
|
+
if (!_this.store.animates.has(_pen)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
if (!_this.store.animates.has(pen)) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
592
623
|
_this.stopAnimate(e.value || [pen]);
|
|
593
624
|
return;
|
|
594
625
|
}
|
|
@@ -1425,6 +1456,9 @@ var Meta2d = /** @class */ (function () {
|
|
|
1425
1456
|
else {
|
|
1426
1457
|
pens = idOrTagOrPens;
|
|
1427
1458
|
}
|
|
1459
|
+
if (!pens.length) {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1428
1462
|
pens.forEach(function (pen) {
|
|
1429
1463
|
var _a, _b;
|
|
1430
1464
|
if (pen.calculative.pause) {
|
|
@@ -1477,8 +1511,9 @@ var Meta2d = /** @class */ (function () {
|
|
|
1477
1511
|
}
|
|
1478
1512
|
}
|
|
1479
1513
|
});
|
|
1480
|
-
this.canvas.canvasImage.init();
|
|
1481
|
-
this.canvas.canvasImageBottom.init();
|
|
1514
|
+
// this.canvas.canvasImage.init();
|
|
1515
|
+
// this.canvas.canvasImageBottom.init();
|
|
1516
|
+
this.initImageCanvas(pens);
|
|
1482
1517
|
this.canvas.animate();
|
|
1483
1518
|
};
|
|
1484
1519
|
Meta2d.prototype.pauseAnimate = function (idOrTagOrPens) {
|
|
@@ -1738,6 +1773,28 @@ var Meta2d = /** @class */ (function () {
|
|
|
1738
1773
|
}
|
|
1739
1774
|
this.inactive();
|
|
1740
1775
|
};
|
|
1776
|
+
Meta2d.prototype.appendChild = function (pens) {
|
|
1777
|
+
if (pens === void 0) { pens = this.store.active; }
|
|
1778
|
+
if (!pens) {
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
if (pens.length < 2) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
var pIdx = pens.findIndex(function (pen) { return pen.name === 'combine' && pen.showChild !== undefined; });
|
|
1785
|
+
if (pIdx !== -1) {
|
|
1786
|
+
var parent_1 = pens[pIdx];
|
|
1787
|
+
this.pushChildren(parent_1, __spreadArray(__spreadArray([], __read(pens.slice(0, pIdx)), false), __read(pens.slice(pIdx + 1)), false));
|
|
1788
|
+
pens.forEach(function (pen) {
|
|
1789
|
+
calcInView(pen, true);
|
|
1790
|
+
});
|
|
1791
|
+
this.initImageCanvas(pens);
|
|
1792
|
+
this.render();
|
|
1793
|
+
}
|
|
1794
|
+
else {
|
|
1795
|
+
console.warn('Invalid operation!');
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1741
1798
|
Meta2d.prototype.isCombine = function (pen) {
|
|
1742
1799
|
if (pen.name === 'combine') {
|
|
1743
1800
|
return true;
|
|
@@ -2275,7 +2332,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
2275
2332
|
// https.forEach(async (_item) => {
|
|
2276
2333
|
// this.requestHttp(_item);
|
|
2277
2334
|
// });
|
|
2278
|
-
|
|
2335
|
+
_this.render();
|
|
2279
2336
|
}, this.store.data.networkInterval || 1000);
|
|
2280
2337
|
}
|
|
2281
2338
|
https.forEach(function (_item, index) {
|
|
@@ -2297,17 +2354,21 @@ var Meta2d = /** @class */ (function () {
|
|
|
2297
2354
|
if (!req.url) return [3 /*break*/, 3];
|
|
2298
2355
|
if (typeof req.headers === 'object') {
|
|
2299
2356
|
for (i in req.headers) {
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2357
|
+
if (typeof req.headers[i] === 'string') {
|
|
2358
|
+
keys = req.headers[i].match(/(?<=\$\{).*?(?=\})/g);
|
|
2359
|
+
if (keys) {
|
|
2360
|
+
req.headers[i] = req.headers[i].replace("${" + keys[0] + "}", this.getDynamicParam(keys[0]));
|
|
2361
|
+
}
|
|
2303
2362
|
}
|
|
2304
2363
|
}
|
|
2305
2364
|
}
|
|
2306
2365
|
if (typeof req.body === 'object') {
|
|
2307
2366
|
for (i in req.body) {
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2367
|
+
if (typeof req.body[i] === 'string') {
|
|
2368
|
+
keys = req.body[i].match(/(?<=\$\{).*?(?=\})/g);
|
|
2369
|
+
if (keys) {
|
|
2370
|
+
req.body[i] = req.body[i].replace("${" + keys[0] + "}", this.getDynamicParam(keys[0]));
|
|
2371
|
+
}
|
|
2311
2372
|
}
|
|
2312
2373
|
}
|
|
2313
2374
|
}
|
|
@@ -2351,22 +2412,28 @@ var Meta2d = /** @class */ (function () {
|
|
|
2351
2412
|
Meta2d.prototype.socketCallback = function (message, context) {
|
|
2352
2413
|
var _this = this;
|
|
2353
2414
|
this.store.emitter.emit('socket', { message: message, context: context });
|
|
2354
|
-
|
|
2355
|
-
|
|
2415
|
+
var _message = message;
|
|
2416
|
+
if (this.socketFn) {
|
|
2417
|
+
_message = this.socketFn(message, {
|
|
2356
2418
|
meta2d: this,
|
|
2357
2419
|
type: context.type,
|
|
2358
2420
|
topic: context.topic,
|
|
2359
2421
|
url: context.url,
|
|
2360
|
-
})
|
|
2361
|
-
|
|
2422
|
+
});
|
|
2423
|
+
if (!_message) {
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
if (_message === true) {
|
|
2428
|
+
_message = message;
|
|
2362
2429
|
}
|
|
2363
2430
|
var data;
|
|
2364
|
-
if (
|
|
2365
|
-
data =
|
|
2431
|
+
if (_message.constructor === Object || _message.constructor === Array) {
|
|
2432
|
+
data = _message;
|
|
2366
2433
|
}
|
|
2367
|
-
else if (typeof
|
|
2434
|
+
else if (typeof _message === 'string') {
|
|
2368
2435
|
try {
|
|
2369
|
-
data = JSON.parse(
|
|
2436
|
+
data = JSON.parse(_message);
|
|
2370
2437
|
}
|
|
2371
2438
|
catch (error) {
|
|
2372
2439
|
console.warn('Invalid socket data:', data, error);
|