@meta2d/core 1.1.20 → 1.1.22
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 +87 -15
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +3 -3
- package/src/core.js +65 -18
- package/src/core.js.map +1 -1
- package/src/diagrams/htmlDom.d.ts +12 -0
- package/src/diagrams/htmlDom.js +66 -0
- package/src/diagrams/htmlDom.js.map +1 -0
- package/src/diagrams/index.d.ts +3 -0
- package/src/diagrams/index.js +3 -0
- package/src/diagrams/index.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 +157 -65
- package/src/pen/render.js.map +1 -1
- package/src/point/point.d.ts +3 -0
- package/src/point/point.js.map +1 -1
- package/src/store/store.d.ts +2 -0
- package/src/store/store.js.map +1 -1
package/src/core.d.ts
CHANGED
|
@@ -270,10 +270,10 @@ export declare class Meta2d {
|
|
|
270
270
|
iotAggregatePublish(item: any): void;
|
|
271
271
|
closeIot(): void;
|
|
272
272
|
connectSqls(): void;
|
|
273
|
-
connectSSE(net: Network): void
|
|
273
|
+
connectSSE(net: Network): Promise<void>;
|
|
274
274
|
closeSSE(): void;
|
|
275
|
-
connectNetMqtt(net: Network): void
|
|
276
|
-
connectNetWebSocket(net: Network): void
|
|
275
|
+
connectNetMqtt(net: Network): Promise<void>;
|
|
276
|
+
connectNetWebSocket(net: Network): Promise<void>;
|
|
277
277
|
getMqttUrl(): Promise<{
|
|
278
278
|
username: any;
|
|
279
279
|
password: any;
|
package/src/core.js
CHANGED
|
@@ -695,6 +695,8 @@ export class Meta2d {
|
|
|
695
695
|
//图纸更新
|
|
696
696
|
const data = await getMeta2dData(this.store, id);
|
|
697
697
|
if (data) {
|
|
698
|
+
data.locked = 1;
|
|
699
|
+
data.fits?.length && (globalThis.meta2dData = JSON.stringify(data));
|
|
698
700
|
this.canvas.opening = true;
|
|
699
701
|
this.open(data);
|
|
700
702
|
this.lock(1);
|
|
@@ -1694,6 +1696,9 @@ export class Meta2d {
|
|
|
1694
1696
|
}
|
|
1695
1697
|
if (index !== -1 && index !== undefined) {
|
|
1696
1698
|
const animate = deepClone(pen.animations[index]);
|
|
1699
|
+
if (!animate.animateCycle) {
|
|
1700
|
+
animate.animateCycle = 0;
|
|
1701
|
+
}
|
|
1697
1702
|
animate.animateName = animate.name;
|
|
1698
1703
|
delete animate.name;
|
|
1699
1704
|
animate.currentAnimation = index;
|
|
@@ -2681,10 +2686,19 @@ export class Meta2d {
|
|
|
2681
2686
|
});
|
|
2682
2687
|
}
|
|
2683
2688
|
}
|
|
2684
|
-
connectSSE(net) {
|
|
2689
|
+
async connectSSE(net) {
|
|
2685
2690
|
if (net.enable === false) {
|
|
2686
2691
|
return;
|
|
2687
2692
|
}
|
|
2693
|
+
if (net.preJs) {
|
|
2694
|
+
if (!net.preFn) {
|
|
2695
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
2696
|
+
net.preFn = new AsyncFunction('network', net.preJs);
|
|
2697
|
+
}
|
|
2698
|
+
if (net.preFn) {
|
|
2699
|
+
net = await net.preFn(net);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2688
2702
|
this.eventSources[net.index] = new EventSource(net.url, { withCredentials: net.withCredentials });
|
|
2689
2703
|
this.eventSources[net.index].onmessage = (e) => {
|
|
2690
2704
|
this.socketCallback(e.data, { type: 'SSE', url: net.url, name: net.name, net });
|
|
@@ -2702,10 +2716,19 @@ export class Meta2d {
|
|
|
2702
2716
|
}
|
|
2703
2717
|
});
|
|
2704
2718
|
}
|
|
2705
|
-
connectNetMqtt(net) {
|
|
2719
|
+
async connectNetMqtt(net) {
|
|
2706
2720
|
if (net.enable === false) {
|
|
2707
2721
|
return;
|
|
2708
2722
|
}
|
|
2723
|
+
if (net.preJs) {
|
|
2724
|
+
if (!net.preFn) {
|
|
2725
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
2726
|
+
net.preFn = new AsyncFunction('network', net.preJs);
|
|
2727
|
+
}
|
|
2728
|
+
if (net.preFn) {
|
|
2729
|
+
net = await net.preFn(net);
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2709
2732
|
if (net.options.clientId && !net.options.customClientId) {
|
|
2710
2733
|
net.options.clientId = s8();
|
|
2711
2734
|
}
|
|
@@ -2806,7 +2829,7 @@ export class Meta2d {
|
|
|
2806
2829
|
}
|
|
2807
2830
|
});
|
|
2808
2831
|
}
|
|
2809
|
-
connectNetWebSocket(net) {
|
|
2832
|
+
async connectNetWebSocket(net) {
|
|
2810
2833
|
if (this.websockets[net.index]) {
|
|
2811
2834
|
this.websockets[net.index].onclose = undefined;
|
|
2812
2835
|
this.websockets[net.index]?.close();
|
|
@@ -2815,6 +2838,15 @@ export class Meta2d {
|
|
|
2815
2838
|
if (net.enable === false) {
|
|
2816
2839
|
return;
|
|
2817
2840
|
}
|
|
2841
|
+
if (net.preJs) {
|
|
2842
|
+
if (!net.preFn) {
|
|
2843
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
2844
|
+
net.preFn = new AsyncFunction('network', net.preJs);
|
|
2845
|
+
}
|
|
2846
|
+
if (net.preFn) {
|
|
2847
|
+
net = await net.preFn(net);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2818
2850
|
let url = net.url;
|
|
2819
2851
|
if (url.indexOf('${') > -1) {
|
|
2820
2852
|
let keys = url.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
@@ -3144,6 +3176,9 @@ export class Meta2d {
|
|
|
3144
3176
|
}
|
|
3145
3177
|
}
|
|
3146
3178
|
penNetwork(pen) {
|
|
3179
|
+
if (!pen.apiUrl) {
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3147
3182
|
const penNetwork = {
|
|
3148
3183
|
url: pen.apiUrl,
|
|
3149
3184
|
method: pen.apiMethod,
|
|
@@ -3239,6 +3274,16 @@ export class Meta2d {
|
|
|
3239
3274
|
}
|
|
3240
3275
|
async requestHttp(_req) {
|
|
3241
3276
|
let req = deepClone(_req);
|
|
3277
|
+
const net = this.store.data.networks?.filter((item) => item.protocol === 'http')[req.index];
|
|
3278
|
+
if (net?.preJs) {
|
|
3279
|
+
if (!net.preFn) {
|
|
3280
|
+
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
3281
|
+
net.preFn = new AsyncFunction('network', net.preJs);
|
|
3282
|
+
}
|
|
3283
|
+
if (net.preFn) {
|
|
3284
|
+
req = await net.preFn(req);
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3242
3287
|
if (req.url) {
|
|
3243
3288
|
if (req.url.indexOf('${') > -1) {
|
|
3244
3289
|
let keys = req.url.match(/\$\{([^}]+)\}/g)?.map(m => m.slice(2, -1));
|
|
@@ -3298,7 +3343,6 @@ export class Meta2d {
|
|
|
3298
3343
|
});
|
|
3299
3344
|
if (res.ok) {
|
|
3300
3345
|
const data = await res.text();
|
|
3301
|
-
const net = this.store.data.networks.filter(item => item.protocol === 'http')[req.index];
|
|
3302
3346
|
this.socketCallback(data, { type: 'http', method: req.method, url: req.url, name: req.name, net });
|
|
3303
3347
|
}
|
|
3304
3348
|
else {
|
|
@@ -3874,11 +3918,9 @@ export class Meta2d {
|
|
|
3874
3918
|
}
|
|
3875
3919
|
event.actions.forEach((action) => {
|
|
3876
3920
|
if (action.timeout) {
|
|
3877
|
-
|
|
3921
|
+
setTimeout(() => {
|
|
3878
3922
|
if (this.events[action.action]) {
|
|
3879
3923
|
this.events[action.action](pen, action);
|
|
3880
|
-
clearTimeout(timer);
|
|
3881
|
-
timer = null;
|
|
3882
3924
|
}
|
|
3883
3925
|
}, action.timeout);
|
|
3884
3926
|
}
|
|
@@ -3924,11 +3966,9 @@ export class Meta2d {
|
|
|
3924
3966
|
if (indexArr.includes(index)) {
|
|
3925
3967
|
trigger.actions?.forEach((event) => {
|
|
3926
3968
|
if (event.timeout) {
|
|
3927
|
-
|
|
3969
|
+
setTimeout(() => {
|
|
3928
3970
|
if (this.events[event.action]) {
|
|
3929
3971
|
this.events[event.action](pen, event);
|
|
3930
|
-
clearTimeout(timer);
|
|
3931
|
-
timer = null;
|
|
3932
3972
|
}
|
|
3933
3973
|
}, event.timeout);
|
|
3934
3974
|
}
|
|
@@ -3967,11 +4007,9 @@ export class Meta2d {
|
|
|
3967
4007
|
if (indexArr.includes(index)) {
|
|
3968
4008
|
trigger.actions?.forEach((event) => {
|
|
3969
4009
|
if (event.timeout) {
|
|
3970
|
-
|
|
4010
|
+
setTimeout(() => {
|
|
3971
4011
|
if (this.events[event.action]) {
|
|
3972
4012
|
this.events[event.action](pen, event);
|
|
3973
|
-
clearTimeout(timer);
|
|
3974
|
-
timer = null;
|
|
3975
4013
|
}
|
|
3976
4014
|
}, event.timeout);
|
|
3977
4015
|
}
|
|
@@ -4006,11 +4044,9 @@ export class Meta2d {
|
|
|
4006
4044
|
if (flag) {
|
|
4007
4045
|
state.actions?.forEach((event) => {
|
|
4008
4046
|
if (event.timeout) {
|
|
4009
|
-
|
|
4047
|
+
setTimeout(() => {
|
|
4010
4048
|
if (this.events[event.action]) {
|
|
4011
4049
|
this.events[event.action](pen, event);
|
|
4012
|
-
clearTimeout(timer);
|
|
4013
|
-
timer = null;
|
|
4014
4050
|
}
|
|
4015
4051
|
}, event.timeout);
|
|
4016
4052
|
}
|
|
@@ -4049,7 +4085,14 @@ export class Meta2d {
|
|
|
4049
4085
|
}
|
|
4050
4086
|
if (flag) {
|
|
4051
4087
|
item.event.actions.forEach((action) => {
|
|
4052
|
-
|
|
4088
|
+
if (action.timeout) {
|
|
4089
|
+
setTimeout(() => {
|
|
4090
|
+
this.events[action.action](item.pen, action, data);
|
|
4091
|
+
}, action.timeout);
|
|
4092
|
+
}
|
|
4093
|
+
else {
|
|
4094
|
+
this.events[action.action](item.pen, action, data);
|
|
4095
|
+
}
|
|
4053
4096
|
});
|
|
4054
4097
|
}
|
|
4055
4098
|
});
|
|
@@ -5653,7 +5696,11 @@ export class Meta2d {
|
|
|
5653
5696
|
}
|
|
5654
5697
|
this.setValue({ id: pen.id, canvasLayer: layer }, { render: false, doEvent: false, history: false });
|
|
5655
5698
|
}
|
|
5656
|
-
else if (pen.
|
|
5699
|
+
else if (pen.name.endsWith('Dom') ||
|
|
5700
|
+
isDomShapes.includes(pen.name) ||
|
|
5701
|
+
this.store.options.domShapes.includes(pen.name) ||
|
|
5702
|
+
pen.externElement ||
|
|
5703
|
+
pen.name === 'gif') {
|
|
5657
5704
|
let zIndex = 0;
|
|
5658
5705
|
// let zIndex = pen.calculative.zIndex === undefined ? 5 : pen.calculative.zIndex + 1;
|
|
5659
5706
|
if (type === 'top') {
|