@meta2d/core 1.1.0 → 1.1.2
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 -1
- package/src/canvas/canvas.js +120 -33
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +2 -0
- package/src/core.js +64 -42
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.d.ts +2 -0
- package/src/diagrams/iframe.js +46 -5
- package/src/diagrams/iframe.js.map +1 -1
- package/src/dialog/dialog.d.ts +13 -6
- package/src/dialog/dialog.js +7 -5
- package/src/dialog/dialog.js.map +1 -1
- package/src/pen/model.d.ts +3 -1
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +8 -11
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.js +8 -0
- package/src/pen/text.js.map +1 -1
- package/src/store/store.d.ts +1 -1
package/src/core.d.ts
CHANGED
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commonAnchors, commonPens, cube, reset, updateFormData } from './diagrams';
|
|
1
|
+
import { clearIframes, commonAnchors, commonPens, cube, updateIframes, reset, updateFormData } from './diagrams';
|
|
2
2
|
import { Canvas } from './canvas';
|
|
3
3
|
import { calcInView, calcTextDrawRect, calcTextLines, calcTextRect, facePen, formatAttrs, getAllChildren, getFromAnchor, getParent, getToAnchor, getWords, LockState, PenType, renderPenRaw, setElemPosition, connectLine, nearestAnchor, setChildValue, isAncestor, isShowChild, CanvasLayer, validationPlugin, setLifeCycleFunc, getAllFollowers, isInteraction, calcWorldAnchors, isDomShapes, defaultFormat, findOutliersByZScore, } from './pen';
|
|
4
4
|
import { rotatePoint } from './point';
|
|
@@ -685,7 +685,7 @@ export class Meta2d {
|
|
|
685
685
|
else {
|
|
686
686
|
this.fitView(true, 10);
|
|
687
687
|
}
|
|
688
|
-
document.title = data.name + "-" + window.name;
|
|
688
|
+
// document.title = data.name + "-" + window.name;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
doSendDataEvent(value, topics) {
|
|
@@ -862,6 +862,9 @@ export class Meta2d {
|
|
|
862
862
|
async addPen(pen, history, emit = true, abs = false) {
|
|
863
863
|
return await this.canvas.addPen(pen, history, emit, abs);
|
|
864
864
|
}
|
|
865
|
+
addPenSync(pen, history, emit = true, abs = false) {
|
|
866
|
+
return this.canvas.addPenSync(pen, history, emit, abs);
|
|
867
|
+
}
|
|
865
868
|
async addPens(pens, history, abs = false) {
|
|
866
869
|
return await this.canvas.addPens(pens, history, abs);
|
|
867
870
|
}
|
|
@@ -939,6 +942,7 @@ export class Meta2d {
|
|
|
939
942
|
if (data.theme) {
|
|
940
943
|
this.setTheme(data.theme);
|
|
941
944
|
}
|
|
945
|
+
updateIframes(data.pens);
|
|
942
946
|
this.setBackgroundImage(data.bkImage, data);
|
|
943
947
|
Object.assign(this.store.data, data);
|
|
944
948
|
this.store.data.pens = [];
|
|
@@ -1179,33 +1183,36 @@ export class Meta2d {
|
|
|
1179
1183
|
// key: realTime.key,
|
|
1180
1184
|
// });
|
|
1181
1185
|
//JetLinks
|
|
1186
|
+
const Jet = this.store.data.networks?.some((item) => item.protocol === 'ADIIOT');
|
|
1182
1187
|
let productId = realTime.productId || pen.productId;
|
|
1183
1188
|
let deviceId = realTime.deviceId || pen.deviceId;
|
|
1184
1189
|
let propertyId = realTime.propertyId;
|
|
1185
1190
|
let flag = false;
|
|
1186
|
-
if (
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1191
|
+
if (Jet) {
|
|
1192
|
+
if (productId && typeof productId === 'string' && productId.indexOf('${') > -1) {
|
|
1193
|
+
let keys = productId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1194
|
+
if (keys?.length) {
|
|
1195
|
+
productId = this.getDynamicParam(keys[0]) || productId;
|
|
1196
|
+
}
|
|
1197
|
+
flag = true;
|
|
1190
1198
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1199
|
+
if (deviceId && typeof deviceId === 'string' && deviceId.indexOf('${') > -1) {
|
|
1200
|
+
let keys = deviceId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1201
|
+
if (keys?.length) {
|
|
1202
|
+
deviceId = this.getDynamicParam(keys[0]) || deviceId;
|
|
1203
|
+
}
|
|
1204
|
+
flag = true;
|
|
1197
1205
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1206
|
+
if (propertyId && typeof propertyId === 'string' && propertyId.indexOf('${') > -1) {
|
|
1207
|
+
let keys = propertyId.match(/(?<=\$\{).*?(?=\})/g);
|
|
1208
|
+
if (keys?.length) {
|
|
1209
|
+
propertyId = this.getDynamicParam(keys[0]) || propertyId;
|
|
1210
|
+
}
|
|
1211
|
+
flag = true;
|
|
1212
|
+
}
|
|
1213
|
+
if (flag) {
|
|
1214
|
+
realTime.bind && (realTime.bind.id = productId + '#' + deviceId + '#' + propertyId);
|
|
1204
1215
|
}
|
|
1205
|
-
flag = true;
|
|
1206
|
-
}
|
|
1207
|
-
if (flag) {
|
|
1208
|
-
realTime.bind && (realTime.bind.id = productId + '#' + deviceId + '#' + propertyId);
|
|
1209
1216
|
}
|
|
1210
1217
|
if (!this.store.bind[realTime.bind.id]) {
|
|
1211
1218
|
this.store.bind[realTime.bind.id] = [];
|
|
@@ -1214,20 +1221,22 @@ export class Meta2d {
|
|
|
1214
1221
|
id: pen.id,
|
|
1215
1222
|
key: realTime.key,
|
|
1216
1223
|
});
|
|
1217
|
-
if (
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1224
|
+
if (Jet) {
|
|
1225
|
+
if (productId && deviceId && propertyId) {
|
|
1226
|
+
const index = this.jetLinksList.findIndex((item) => item.topic.startsWith(`/${productId}/${deviceId}`));
|
|
1227
|
+
if (index > -1) {
|
|
1228
|
+
const properties = this.jetLinksList[index].properties;
|
|
1229
|
+
if (!properties.includes(realTime.propertyId)) {
|
|
1230
|
+
this.jetLinksList[index].properties.push(realTime.propertyId);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
else {
|
|
1234
|
+
this.jetLinksList.push({
|
|
1235
|
+
topic: `/${productId}/${deviceId}`,
|
|
1236
|
+
deviceId,
|
|
1237
|
+
properties: [realTime.propertyId],
|
|
1238
|
+
});
|
|
1223
1239
|
}
|
|
1224
|
-
}
|
|
1225
|
-
else {
|
|
1226
|
-
this.jetLinksList.push({
|
|
1227
|
-
topic: `/${productId}/${deviceId}`,
|
|
1228
|
-
deviceId,
|
|
1229
|
-
properties: [realTime.propertyId],
|
|
1230
|
-
});
|
|
1231
1240
|
}
|
|
1232
1241
|
}
|
|
1233
1242
|
if (realTime.bind.class === 'iot') {
|
|
@@ -2038,6 +2047,9 @@ export class Meta2d {
|
|
|
2038
2047
|
delete(pens, canDelLocked = false, history = true) {
|
|
2039
2048
|
this.canvas.delete(pens, canDelLocked, history);
|
|
2040
2049
|
}
|
|
2050
|
+
deleteSync(pens, canDelLocked = false, history = true) {
|
|
2051
|
+
this.canvas.deleteSync(pens, canDelLocked, history);
|
|
2052
|
+
}
|
|
2041
2053
|
scale(scale, center = { x: 0, y: 0 }) {
|
|
2042
2054
|
this.canvas.scale(scale, center);
|
|
2043
2055
|
}
|
|
@@ -4347,13 +4359,13 @@ export class Meta2d {
|
|
|
4347
4359
|
let left = fit.leftValue;
|
|
4348
4360
|
let right = fit.rightValue;
|
|
4349
4361
|
if (left) {
|
|
4350
|
-
left = Math.abs(left) < 1 ? left *
|
|
4362
|
+
left = Math.abs(left) < 1 ? left * rect.width : left;
|
|
4351
4363
|
}
|
|
4352
4364
|
else {
|
|
4353
4365
|
left = 0;
|
|
4354
4366
|
}
|
|
4355
4367
|
if (right) {
|
|
4356
|
-
right = Math.abs(right) < 1 ? right *
|
|
4368
|
+
right = Math.abs(right) < 1 ? right * rect.width : right;
|
|
4357
4369
|
}
|
|
4358
4370
|
else {
|
|
4359
4371
|
right = 0;
|
|
@@ -4374,11 +4386,20 @@ export class Meta2d {
|
|
|
4374
4386
|
}
|
|
4375
4387
|
});
|
|
4376
4388
|
}
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4389
|
+
if (Math.abs(fit.leftValue) < 1) {
|
|
4390
|
+
pen.calculative.worldRect.x =
|
|
4391
|
+
rect.x -
|
|
4392
|
+
wGap / 2 +
|
|
4393
|
+
left +
|
|
4394
|
+
(pen.calculative.worldRect.x - rect.x - left) * ratio;
|
|
4395
|
+
}
|
|
4396
|
+
else {
|
|
4397
|
+
pen.calculative.worldRect.x =
|
|
4398
|
+
rect.x -
|
|
4399
|
+
wGap / 2 +
|
|
4400
|
+
left +
|
|
4401
|
+
(pen.calculative.worldRect.x - rect.x) * ratio;
|
|
4402
|
+
}
|
|
4382
4403
|
pen.calculative.worldRect.width *= ratio;
|
|
4383
4404
|
pen.calculative.worldRect.ex =
|
|
4384
4405
|
pen.calculative.worldRect.x + pen.calculative.worldRect.width;
|
|
@@ -6019,6 +6040,7 @@ export class Meta2d {
|
|
|
6019
6040
|
setLifeCycleFunc = setLifeCycleFunc;
|
|
6020
6041
|
destroy(onlyData) {
|
|
6021
6042
|
this.clear(false);
|
|
6043
|
+
clearIframes();
|
|
6022
6044
|
this.stopDataMock();
|
|
6023
6045
|
this.closeSocket();
|
|
6024
6046
|
this.closeNetwork();
|