@meta2d/core 1.1.1 → 1.1.3
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 +2 -0
- package/src/canvas/canvas.js +94 -30
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +3 -1
- package/src/core.js +70 -40
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.js +2 -2
- package/src/diagrams/iframe.js.map +1 -1
- package/src/dialog/dialog.d.ts +13 -7
- package/src/dialog/dialog.js +28 -22
- package/src/dialog/dialog.js.map +1 -1
- package/src/pen/model.d.ts +1 -1
- package/src/pen/render.js +2 -2
- package/src/pen/render.js.map +1 -1
- package/src/scroll/scroll.d.ts +1 -1
- package/src/scroll/scroll.js +7 -2
- package/src/scroll/scroll.js.map +1 -1
package/src/core.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare class Meta2d {
|
|
|
74
74
|
private init;
|
|
75
75
|
initEventFns(): void;
|
|
76
76
|
getSendData(data: any[], cpen?: Pen): any;
|
|
77
|
-
convertType(value: string, type: string):
|
|
77
|
+
convertType(value: string, type: string): any;
|
|
78
78
|
getEventData(list: any, pen: Pen): any;
|
|
79
79
|
message(options: MessageOptions): void;
|
|
80
80
|
closeAll(): void;
|
|
@@ -87,6 +87,7 @@ export declare class Meta2d {
|
|
|
87
87
|
* @param emit 是否发送消息
|
|
88
88
|
*/
|
|
89
89
|
addPen(pen: Pen, history?: boolean, emit?: boolean, abs?: boolean): Promise<Pen>;
|
|
90
|
+
addPenSync(pen: Pen, history?: boolean, emit?: boolean, abs?: boolean): Pen;
|
|
90
91
|
addPens(pens: Pen[], history?: boolean, abs?: boolean): Promise<Pen[]>;
|
|
91
92
|
render(patchFlags?: boolean | number): void;
|
|
92
93
|
setBackgroundImage(url: string, data?: any): Promise<void>;
|
|
@@ -214,6 +215,7 @@ export declare class Meta2d {
|
|
|
214
215
|
* @param canDelLocked 是否删除已经锁住的画笔
|
|
215
216
|
*/
|
|
216
217
|
delete(pens?: Pen[], canDelLocked?: boolean, history?: boolean): void;
|
|
218
|
+
deleteSync(pens?: Pen[], canDelLocked?: boolean, history?: boolean): void;
|
|
217
219
|
scale(scale: number, center?: {
|
|
218
220
|
x: number;
|
|
219
221
|
y: number;
|
package/src/core.js
CHANGED
|
@@ -611,6 +611,16 @@ export class Meta2d {
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
+
else if (typeof value === 'object') {
|
|
615
|
+
let bodyStr = JSON.stringify(value);
|
|
616
|
+
let keys = bodyStr.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
617
|
+
if (keys?.length) {
|
|
618
|
+
for (let i = 0; i < keys.length; i++) {
|
|
619
|
+
bodyStr = bodyStr.replace(`\${${keys[i]}}`, this.getDynamicParam(keys[i]));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return JSON.parse(bodyStr);
|
|
623
|
+
}
|
|
614
624
|
return value;
|
|
615
625
|
}
|
|
616
626
|
getEventData(list, pen) {
|
|
@@ -862,6 +872,9 @@ export class Meta2d {
|
|
|
862
872
|
async addPen(pen, history, emit = true, abs = false) {
|
|
863
873
|
return await this.canvas.addPen(pen, history, emit, abs);
|
|
864
874
|
}
|
|
875
|
+
addPenSync(pen, history, emit = true, abs = false) {
|
|
876
|
+
return this.canvas.addPenSync(pen, history, emit, abs);
|
|
877
|
+
}
|
|
865
878
|
async addPens(pens, history, abs = false) {
|
|
866
879
|
return await this.canvas.addPens(pens, history, abs);
|
|
867
880
|
}
|
|
@@ -1180,33 +1193,36 @@ export class Meta2d {
|
|
|
1180
1193
|
// key: realTime.key,
|
|
1181
1194
|
// });
|
|
1182
1195
|
//JetLinks
|
|
1196
|
+
const Jet = this.store.data.networks?.some((item) => item.protocol === 'ADIIOT');
|
|
1183
1197
|
let productId = realTime.productId || pen.productId;
|
|
1184
1198
|
let deviceId = realTime.deviceId || pen.deviceId;
|
|
1185
1199
|
let propertyId = realTime.propertyId;
|
|
1186
1200
|
let flag = false;
|
|
1187
|
-
if (
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1201
|
+
if (Jet) {
|
|
1202
|
+
if (productId && typeof productId === 'string' && productId.indexOf('${') > -1) {
|
|
1203
|
+
let keys = productId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1204
|
+
if (keys?.length) {
|
|
1205
|
+
productId = this.getDynamicParam(keys[0]) || productId;
|
|
1206
|
+
}
|
|
1207
|
+
flag = true;
|
|
1191
1208
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1209
|
+
if (deviceId && typeof deviceId === 'string' && deviceId.indexOf('${') > -1) {
|
|
1210
|
+
let keys = deviceId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1211
|
+
if (keys?.length) {
|
|
1212
|
+
deviceId = this.getDynamicParam(keys[0]) || deviceId;
|
|
1213
|
+
}
|
|
1214
|
+
flag = true;
|
|
1198
1215
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1216
|
+
if (propertyId && typeof propertyId === 'string' && propertyId.indexOf('${') > -1) {
|
|
1217
|
+
let keys = propertyId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1218
|
+
if (keys?.length) {
|
|
1219
|
+
propertyId = this.getDynamicParam(keys[0]) || propertyId;
|
|
1220
|
+
}
|
|
1221
|
+
flag = true;
|
|
1222
|
+
}
|
|
1223
|
+
if (flag) {
|
|
1224
|
+
realTime.bind && (realTime.bind.id = productId + '#' + deviceId + '#' + propertyId);
|
|
1205
1225
|
}
|
|
1206
|
-
flag = true;
|
|
1207
|
-
}
|
|
1208
|
-
if (flag) {
|
|
1209
|
-
realTime.bind && (realTime.bind.id = productId + '#' + deviceId + '#' + propertyId);
|
|
1210
1226
|
}
|
|
1211
1227
|
if (!this.store.bind[realTime.bind.id]) {
|
|
1212
1228
|
this.store.bind[realTime.bind.id] = [];
|
|
@@ -1215,20 +1231,22 @@ export class Meta2d {
|
|
|
1215
1231
|
id: pen.id,
|
|
1216
1232
|
key: realTime.key,
|
|
1217
1233
|
});
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1234
|
+
if (Jet) {
|
|
1235
|
+
if (productId && deviceId && propertyId) {
|
|
1236
|
+
const index = this.jetLinksList.findIndex((item) => item.topic.startsWith(`/${productId}/${deviceId}`));
|
|
1237
|
+
if (index > -1) {
|
|
1238
|
+
const properties = this.jetLinksList[index].properties;
|
|
1239
|
+
if (!properties.includes(realTime.propertyId)) {
|
|
1240
|
+
this.jetLinksList[index].properties.push(realTime.propertyId);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
this.jetLinksList.push({
|
|
1245
|
+
topic: `/${productId}/${deviceId}`,
|
|
1246
|
+
deviceId,
|
|
1247
|
+
properties: [realTime.propertyId],
|
|
1248
|
+
});
|
|
1224
1249
|
}
|
|
1225
|
-
}
|
|
1226
|
-
else {
|
|
1227
|
-
this.jetLinksList.push({
|
|
1228
|
-
topic: `/${productId}/${deviceId}`,
|
|
1229
|
-
deviceId,
|
|
1230
|
-
properties: [realTime.propertyId],
|
|
1231
|
-
});
|
|
1232
1250
|
}
|
|
1233
1251
|
}
|
|
1234
1252
|
if (realTime.bind.class === 'iot') {
|
|
@@ -2039,6 +2057,9 @@ export class Meta2d {
|
|
|
2039
2057
|
delete(pens, canDelLocked = false, history = true) {
|
|
2040
2058
|
this.canvas.delete(pens, canDelLocked, history);
|
|
2041
2059
|
}
|
|
2060
|
+
deleteSync(pens, canDelLocked = false, history = true) {
|
|
2061
|
+
this.canvas.deleteSync(pens, canDelLocked, history);
|
|
2062
|
+
}
|
|
2042
2063
|
scale(scale, center = { x: 0, y: 0 }) {
|
|
2043
2064
|
this.canvas.scale(scale, center);
|
|
2044
2065
|
}
|
|
@@ -4348,13 +4369,13 @@ export class Meta2d {
|
|
|
4348
4369
|
let left = fit.leftValue;
|
|
4349
4370
|
let right = fit.rightValue;
|
|
4350
4371
|
if (left) {
|
|
4351
|
-
left = Math.abs(left) < 1 ? left *
|
|
4372
|
+
left = Math.abs(left) < 1 ? left * rect.width : left;
|
|
4352
4373
|
}
|
|
4353
4374
|
else {
|
|
4354
4375
|
left = 0;
|
|
4355
4376
|
}
|
|
4356
4377
|
if (right) {
|
|
4357
|
-
right = Math.abs(right) < 1 ? right *
|
|
4378
|
+
right = Math.abs(right) < 1 ? right * rect.width : right;
|
|
4358
4379
|
}
|
|
4359
4380
|
else {
|
|
4360
4381
|
right = 0;
|
|
@@ -4375,11 +4396,20 @@ export class Meta2d {
|
|
|
4375
4396
|
}
|
|
4376
4397
|
});
|
|
4377
4398
|
}
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4399
|
+
if (Math.abs(fit.leftValue) < 1) {
|
|
4400
|
+
pen.calculative.worldRect.x =
|
|
4401
|
+
rect.x -
|
|
4402
|
+
wGap / 2 +
|
|
4403
|
+
left +
|
|
4404
|
+
(pen.calculative.worldRect.x - rect.x - left) * ratio;
|
|
4405
|
+
}
|
|
4406
|
+
else {
|
|
4407
|
+
pen.calculative.worldRect.x =
|
|
4408
|
+
rect.x -
|
|
4409
|
+
wGap / 2 +
|
|
4410
|
+
left +
|
|
4411
|
+
(pen.calculative.worldRect.x - rect.x) * ratio;
|
|
4412
|
+
}
|
|
4383
4413
|
pen.calculative.worldRect.width *= ratio;
|
|
4384
4414
|
pen.calculative.worldRect.ex =
|
|
4385
4415
|
pen.calculative.worldRect.x + pen.calculative.worldRect.width;
|