@meta2d/core 1.0.70 → 1.0.71
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/core.js +54 -90
- package/src/core.js.map +1 -1
- package/src/pen/render.js +28 -4
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +15 -6
- package/src/pen/text.js.map +1 -1
- package/src/store/store.d.ts +1 -1
- package/src/utils/jetLinks.d.ts +8 -0
- package/src/utils/jetLinks.js +116 -0
- package/src/utils/jetLinks.js.map +1 -0
- package/src/utils/url.js +3 -0
- package/src/utils/url.js.map +1 -1
package/package.json
CHANGED
package/src/core.js
CHANGED
|
@@ -16,6 +16,7 @@ import { getter } from './utils/object';
|
|
|
16
16
|
import { getCookie, getMeta2dData, queryURLParams } from './utils/url';
|
|
17
17
|
import { HotkeyType } from './data';
|
|
18
18
|
import { Message, messageList } from './message';
|
|
19
|
+
import { closeJetLinks, connectJetLinks, getSendData, sendJetLinksData } from './utils/jetLinks';
|
|
19
20
|
import { le5leTheme } from './theme';
|
|
20
21
|
export class Meta2d {
|
|
21
22
|
store;
|
|
@@ -368,6 +369,16 @@ export class Meta2d {
|
|
|
368
369
|
});
|
|
369
370
|
}
|
|
370
371
|
}
|
|
372
|
+
Object.keys(e.extend).forEach((key) => {
|
|
373
|
+
if (!['x', 'y', 'width', 'height'].includes(key)) {
|
|
374
|
+
if (url.indexOf('?') !== -1) {
|
|
375
|
+
url += `&${key}=${e.extend[key]}`;
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
url += `?${key}=${e.extend[key]}`;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
});
|
|
371
382
|
const data = this.getEventData(e.list, pen);
|
|
372
383
|
this.canvas.dialog.show(e.value, url, e.extend, data);
|
|
373
384
|
}
|
|
@@ -375,51 +386,10 @@ export class Meta2d {
|
|
|
375
386
|
this.events[EventAction.SendData] = (pen, e) => {
|
|
376
387
|
if (e.list?.length) {
|
|
377
388
|
// if (e.targetType === 'id') {
|
|
378
|
-
if (e.network && e.network.protocol === '
|
|
379
|
-
const list =
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
list[index] = {
|
|
383
|
-
deviceId: _pen.deviceId,
|
|
384
|
-
productId: _pen.productId,
|
|
385
|
-
properties: {},
|
|
386
|
-
};
|
|
387
|
-
for (let key in item.value) {
|
|
388
|
-
if (item.value[key] === undefined || item.value[key] === '') {
|
|
389
|
-
//找到绑定了这个设备属性的图元属性
|
|
390
|
-
const realTime = _pen.realTimes?.find((item) => item.propertyId === key);
|
|
391
|
-
if (realTime) {
|
|
392
|
-
list[index].properties[key] = _pen[realTime.key];
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
else if (typeof item.value[key] === 'string' &&
|
|
396
|
-
item.value[key]?.indexOf('${') > -1) {
|
|
397
|
-
let keys = item.value[key].match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
398
|
-
if (keys?.length) {
|
|
399
|
-
list[index].properties[key] =
|
|
400
|
-
_pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
list[index].properties[key] = item.value[key];
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
if (this.jetLinksClient && list.length) {
|
|
409
|
-
list.forEach((item) => {
|
|
410
|
-
this.jetLinksClient.send(JSON.stringify({
|
|
411
|
-
type: 'sub',
|
|
412
|
-
topic: `/device-message-sender/${item.productId}/${item.deviceId}`,
|
|
413
|
-
parameter: {
|
|
414
|
-
messageType: 'WRITE_PROPERTY',
|
|
415
|
-
properties: item.properties,
|
|
416
|
-
headers: {
|
|
417
|
-
async: false,
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
id: item.productId + '/' + item.deviceId + '-' + s8(),
|
|
421
|
-
}));
|
|
422
|
-
});
|
|
389
|
+
if (e.network && e.network.protocol === 'ADIIOT') {
|
|
390
|
+
const list = getSendData(this, pen, e);
|
|
391
|
+
if (list.length) {
|
|
392
|
+
sendJetLinksData(this, list);
|
|
423
393
|
}
|
|
424
394
|
return;
|
|
425
395
|
}
|
|
@@ -952,6 +922,42 @@ export class Meta2d {
|
|
|
952
922
|
this.store.data.pens.forEach((pen) => {
|
|
953
923
|
pen.realTimes?.forEach((realTime) => {
|
|
954
924
|
if (realTime.bind && realTime.bind.id) {
|
|
925
|
+
// if (!this.store.bind[realTime.bind.id]) {
|
|
926
|
+
// this.store.bind[realTime.bind.id] = [];
|
|
927
|
+
// }
|
|
928
|
+
// this.store.bind[realTime.bind.id].push({
|
|
929
|
+
// id: pen.id,
|
|
930
|
+
// key: realTime.key,
|
|
931
|
+
// });
|
|
932
|
+
//JetLinks
|
|
933
|
+
let productId = realTime.productId || pen.productId;
|
|
934
|
+
let deviceId = realTime.deviceId || pen.deviceId;
|
|
935
|
+
let propertyId = realTime.propertyId;
|
|
936
|
+
let flag = false;
|
|
937
|
+
if (productId && productId.indexOf('${') > -1) {
|
|
938
|
+
let keys = productId.match(/(?<=\$\{).*?(?=\})/g);
|
|
939
|
+
if (keys?.length) {
|
|
940
|
+
productId = this.getDynamicParam(keys[0]) || productId;
|
|
941
|
+
}
|
|
942
|
+
flag = true;
|
|
943
|
+
}
|
|
944
|
+
if (deviceId && deviceId.indexOf('${') > -1) {
|
|
945
|
+
let keys = deviceId.match(/(?<=\$\{).*?(?=\})/g);
|
|
946
|
+
if (keys?.length) {
|
|
947
|
+
deviceId = this.getDynamicParam(keys[0]) || deviceId;
|
|
948
|
+
}
|
|
949
|
+
flag = true;
|
|
950
|
+
}
|
|
951
|
+
if (propertyId && propertyId.indexOf('${') > -1) {
|
|
952
|
+
let keys = propertyId.match(/(?<=\$\{).*?(?=\})/g);
|
|
953
|
+
if (keys?.length) {
|
|
954
|
+
propertyId = this.getDynamicParam(keys[0]) || propertyId;
|
|
955
|
+
}
|
|
956
|
+
flag = true;
|
|
957
|
+
}
|
|
958
|
+
if (flag) {
|
|
959
|
+
realTime.bind && (realTime.bind.id = productId + '#' + deviceId + '#' + propertyId);
|
|
960
|
+
}
|
|
955
961
|
if (!this.store.bind[realTime.bind.id]) {
|
|
956
962
|
this.store.bind[realTime.bind.id] = [];
|
|
957
963
|
}
|
|
@@ -959,10 +965,6 @@ export class Meta2d {
|
|
|
959
965
|
id: pen.id,
|
|
960
966
|
key: realTime.key,
|
|
961
967
|
});
|
|
962
|
-
//JetLinks
|
|
963
|
-
const productId = realTime.productId || pen.productId;
|
|
964
|
-
const deviceId = realTime.deviceId || pen.deviceId;
|
|
965
|
-
const propertyId = realTime.propertyId;
|
|
966
968
|
if (productId && deviceId && propertyId) {
|
|
967
969
|
const index = this.jetLinksList.findIndex((item) => item.topic.startsWith(`/${productId}/${deviceId}`));
|
|
968
970
|
if (index > -1) {
|
|
@@ -2041,47 +2043,8 @@ export class Meta2d {
|
|
|
2041
2043
|
sqlIndex += 1;
|
|
2042
2044
|
}
|
|
2043
2045
|
}
|
|
2044
|
-
else if (net.protocol === '
|
|
2045
|
-
|
|
2046
|
-
this.jetLinksClient = new WebSocket(`${net.url}/${localStorage.getItem('X-Access-Token') ||
|
|
2047
|
-
getCookie('X-Access-Token') ||
|
|
2048
|
-
new URLSearchParams(location.search).get('X-Access-Token') ||
|
|
2049
|
-
''}`
|
|
2050
|
-
// 'ws://8.134.86.52:29000/api/messaging/961d8b395298d3ec3a021df70d6b6ca4'
|
|
2051
|
-
);
|
|
2052
|
-
//消息接收
|
|
2053
|
-
this.jetLinksClient.onmessage = (e) => {
|
|
2054
|
-
const mess = JSON.parse(e.data);
|
|
2055
|
-
if (mess.payload &&
|
|
2056
|
-
mess.payload.success &&
|
|
2057
|
-
mess.payload?.properties) {
|
|
2058
|
-
const data = [];
|
|
2059
|
-
for (let key in mess.payload.properties) {
|
|
2060
|
-
if (!key.startsWith('_')) {
|
|
2061
|
-
data.push({
|
|
2062
|
-
id: `${mess.payload.headers.productId}#${mess.payload.deviceId}#${key}`,
|
|
2063
|
-
value: mess.payload.properties[key],
|
|
2064
|
-
});
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
this.setDatas(data, { history: false });
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
this.jetLinksClient.onopen = () => {
|
|
2071
|
-
this.jetLinksList.forEach((item) => {
|
|
2072
|
-
this.jetLinksClient.send(JSON.stringify({
|
|
2073
|
-
type: 'sub',
|
|
2074
|
-
topic: `/device${item.topic}/message/property/report`,
|
|
2075
|
-
parameter: {
|
|
2076
|
-
deviceId: item.deviceId,
|
|
2077
|
-
properties: item.properties,
|
|
2078
|
-
history: 1,
|
|
2079
|
-
},
|
|
2080
|
-
id: item.topic + '-' + s8(),
|
|
2081
|
-
}));
|
|
2082
|
-
});
|
|
2083
|
-
};
|
|
2084
|
-
}
|
|
2046
|
+
else if (net.protocol === 'ADIIOT') {
|
|
2047
|
+
connectJetLinks(this, net);
|
|
2085
2048
|
}
|
|
2086
2049
|
});
|
|
2087
2050
|
}
|
|
@@ -2473,6 +2436,7 @@ export class Meta2d {
|
|
|
2473
2436
|
clearInterval(_sqlTimer);
|
|
2474
2437
|
_sqlTimer = undefined;
|
|
2475
2438
|
});
|
|
2439
|
+
closeJetLinks(this);
|
|
2476
2440
|
}
|
|
2477
2441
|
socketCallback(message, context) {
|
|
2478
2442
|
this.store.emitter.emit('socket', { message, context });
|