@linkdlab/funcnodes_react_flow 0.1.0 → 0.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/dist/frontend/datarenderer/images.d.ts +11 -0
- package/dist/frontend/datarenderer/images.js +13 -0
- package/dist/frontend/datarenderer/images.js.map +1 -0
- package/dist/frontend/datarenderer/index.d.ts +16 -0
- package/dist/frontend/datarenderer/index.js +26 -0
- package/dist/frontend/datarenderer/index.js.map +1 -0
- package/dist/frontend/datarenderer/plotly.d.ts +14 -0
- package/dist/frontend/datarenderer/plotly.js +53 -0
- package/dist/frontend/datarenderer/plotly.js.map +1 -0
- package/dist/frontend/dialog.d.ts +17 -0
- package/dist/frontend/dialog.js +26 -0
- package/dist/frontend/dialog.js.map +1 -0
- package/dist/frontend/edge.d.ts +5 -0
- package/dist/frontend/edge.js +40 -0
- package/dist/frontend/edge.js.map +1 -0
- package/dist/frontend/funcnodesreactflow/index.d.ts +6 -0
- package/dist/frontend/funcnodesreactflow/index.js +94 -0
- package/dist/frontend/funcnodesreactflow/index.js.map +1 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.d.ts +5 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.js +149 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.js.map +1 -0
- package/dist/frontend/header/index.d.ts +4 -0
- package/dist/frontend/header/index.js +227 -0
- package/dist/frontend/header/index.js.map +1 -0
- package/{src/frontend/index.tsx → dist/frontend/index.d.ts} +0 -1
- package/dist/frontend/index.js +4 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/lib.d.ts +10 -0
- package/dist/frontend/lib.js +107 -0
- package/dist/frontend/lib.js.map +1 -0
- package/{src/frontend/node/index.tsx → dist/frontend/node/index.d.ts} +0 -1
- package/dist/frontend/node/index.js +3 -0
- package/dist/frontend/node/index.js.map +1 -0
- package/dist/frontend/node/io/default_input_renderer.d.ts +11 -0
- package/dist/frontend/node/io/default_input_renderer.js +235 -0
- package/dist/frontend/node/io/default_input_renderer.js.map +1 -0
- package/dist/frontend/node/io/default_output_render.d.ts +6 -0
- package/dist/frontend/node/io/default_output_render.js +23 -0
- package/dist/frontend/node/io/default_output_render.js.map +1 -0
- package/dist/frontend/node/io/handle_renderer.d.ts +6 -0
- package/dist/frontend/node/io/handle_renderer.js +70 -0
- package/dist/frontend/node/io/handle_renderer.js.map +1 -0
- package/{src/frontend/node/io/index.tsx → dist/frontend/node/io/index.d.ts} +0 -1
- package/dist/frontend/node/io/index.js +4 -0
- package/dist/frontend/node/io/index.js.map +1 -0
- package/dist/frontend/node/io/io.d.ts +16 -0
- package/dist/frontend/node/io/io.js +98 -0
- package/dist/frontend/node/io/io.js.map +1 -0
- package/dist/frontend/node/io/nodeinput.d.ts +6 -0
- package/dist/frontend/node/io/nodeinput.js +74 -0
- package/dist/frontend/node/io/nodeinput.js.map +1 -0
- package/dist/frontend/node/io/nodeoutput.d.ts +6 -0
- package/dist/frontend/node/io/nodeoutput.js +19 -0
- package/dist/frontend/node/io/nodeoutput.js.map +1 -0
- package/dist/frontend/node/node.d.ts +20 -0
- package/dist/frontend/node/node.js +118 -0
- package/dist/frontend/node/node.js.map +1 -0
- package/dist/frontend/utils/colorpicker.d.ts +19 -0
- package/dist/frontend/utils/colorpicker.js +209 -0
- package/dist/frontend/utils/colorpicker.js.map +1 -0
- package/dist/frontend/utils/jsondata.d.ts +6 -0
- package/dist/frontend/utils/jsondata.js +8 -0
- package/dist/frontend/utils/jsondata.js.map +1 -0
- package/dist/frontend/utils/table.d.ts +11 -0
- package/dist/frontend/utils/table.js +108 -0
- package/dist/frontend/utils/table.js.map +1 -0
- package/dist/funcnodes/funcnodesworker.d.ts +72 -0
- package/dist/funcnodes/funcnodesworker.js +532 -0
- package/dist/funcnodes/funcnodesworker.js.map +1 -0
- package/dist/funcnodes/index.js +5 -0
- package/dist/funcnodes/index.js.map +1 -0
- package/dist/funcnodes/websocketworker.d.ts +27 -0
- package/dist/funcnodes/websocketworker.js +224 -0
- package/dist/funcnodes/websocketworker.js.map +1 -0
- package/dist/funcnodes/workermanager.d.ts +32 -0
- package/dist/funcnodes/workermanager.js +241 -0
- package/dist/funcnodes/workermanager.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/states/edge.d.ts +7 -0
- package/dist/states/edge.js +6 -0
- package/dist/states/edge.js.map +1 -0
- package/dist/states/edge.t.d.ts +16 -0
- package/dist/states/edge.t.js +2 -0
- package/dist/states/edge.t.js.map +1 -0
- package/dist/states/fnrfzst.d.ts +10 -0
- package/dist/states/fnrfzst.js +378 -0
- package/dist/states/fnrfzst.js.map +1 -0
- package/dist/states/fnrfzst.t.d.ts +100 -0
- package/dist/states/fnrfzst.t.js +2 -0
- package/dist/states/fnrfzst.t.js.map +1 -0
- package/dist/states/index.d.ts +7 -0
- package/dist/states/index.js +6 -0
- package/dist/states/index.js.map +1 -0
- package/dist/states/lib.d.ts +3 -0
- package/dist/states/lib.js +14 -0
- package/dist/states/lib.js.map +1 -0
- package/dist/states/lib.t.d.ts +24 -0
- package/dist/states/lib.t.js +2 -0
- package/dist/states/lib.t.js.map +1 -0
- package/dist/states/node.d.ts +4 -0
- package/dist/states/node.js +43 -0
- package/dist/states/node.js.map +1 -0
- package/dist/states/node.t.d.ts +73 -0
- package/dist/states/node.t.js +2 -0
- package/dist/states/node.t.js.map +1 -0
- package/dist/states/nodeio.t.d.ts +67 -0
- package/dist/states/nodeio.t.js +2 -0
- package/dist/states/nodeio.t.js.map +1 -0
- package/dist/states/nodespace.d.ts +3 -0
- package/dist/states/nodespace.js +77 -0
- package/dist/states/nodespace.js.map +1 -0
- package/dist/states/nodespace.t.d.ts +16 -0
- package/dist/states/nodespace.t.js +2 -0
- package/dist/states/nodespace.t.js.map +1 -0
- package/dist/states/reactflow.d.ts +8 -0
- package/dist/states/reactflow.js +33 -0
- package/dist/states/reactflow.js.map +1 -0
- package/dist/states/reactflow.t.d.ts +11 -0
- package/dist/states/reactflow.t.js +2 -0
- package/dist/states/reactflow.t.js.map +1 -0
- package/dist/types/rendering.t.d.ts +10 -0
- package/dist/types/rendering.t.js +2 -0
- package/dist/types/rendering.t.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/objects.d.ts +19 -0
- package/dist/utils/objects.js +118 -0
- package/dist/utils/objects.js.map +1 -0
- package/package.json +52 -21
- package/package copy.json +0 -63
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/public/worker_manager +0 -1
- package/src/App.css +0 -38
- package/src/App.test.tsx +0 -9
- package/src/App.tsx +0 -22
- package/src/frontend/datarenderer/images.tsx +0 -28
- package/src/frontend/datarenderer/index.tsx +0 -53
- package/src/frontend/datarenderer/plotly.tsx +0 -82
- package/src/frontend/dialog.scss +0 -88
- package/src/frontend/dialog.tsx +0 -70
- package/src/frontend/edge.scss +0 -15
- package/src/frontend/edge.tsx +0 -31
- package/src/frontend/funcnodesreactflow.scss +0 -63
- package/src/frontend/funcnodesreactflow.tsx +0 -283
- package/src/frontend/header/header.scss +0 -48
- package/src/frontend/header/index.tsx +0 -268
- package/src/frontend/layout/htmlelements.scss +0 -63
- package/src/frontend/lib.scss +0 -157
- package/src/frontend/lib.tsx +0 -198
- package/src/frontend/node/io/default_input_renderer.tsx +0 -327
- package/src/frontend/node/io/default_output_render.tsx +0 -26
- package/src/frontend/node/io/handle_renderer.tsx +0 -89
- package/src/frontend/node/io/io.scss +0 -91
- package/src/frontend/node/io/io.tsx +0 -114
- package/src/frontend/node/io/nodeinput.tsx +0 -125
- package/src/frontend/node/io/nodeoutput.tsx +0 -37
- package/src/frontend/node/node.scss +0 -265
- package/src/frontend/node/node.tsx +0 -208
- package/src/frontend/nodecontextmenu.scss +0 -18
- package/src/frontend/utils/colorpicker.scss +0 -37
- package/src/frontend/utils/colorpicker.tsx +0 -342
- package/src/frontend/utils/jsondata.tsx +0 -19
- package/src/frontend/utils/table.scss +0 -22
- package/src/frontend/utils/table.tsx +0 -159
- package/src/funcnodes/funcnodesworker.ts +0 -455
- package/src/funcnodes/websocketworker.ts +0 -153
- package/src/funcnodes/workermanager.ts +0 -229
- package/src/index.css +0 -13
- package/src/index.tsx +0 -19
- package/src/logo.svg +0 -1
- package/src/react-app-env.d.ts +0 -1
- package/src/reportWebVitals.ts +0 -15
- package/src/setupTests.ts +0 -5
- package/src/state/edge.ts +0 -35
- package/src/state/fnrfzst.ts +0 -440
- package/src/state/index.ts +0 -139
- package/src/state/lib.ts +0 -26
- package/src/state/node.ts +0 -118
- package/src/state/nodespace.ts +0 -151
- package/src/state/reactflow.ts +0 -65
- package/src/types/lib.d.ts +0 -16
- package/src/types/node.d.ts +0 -29
- package/src/types/nodeio.d.ts +0 -82
- package/src/types/worker.d.ts +0 -56
- package/tsconfig.json +0 -20
- /package/{src/funcnodes/index.ts → dist/funcnodes/index.d.ts} +0 -0
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import FuncNodesWorker, { WorkerProps } from "./funcnodesworker";
|
|
2
|
-
import { FuncNodesReactFlowZustandInterface } from "../state";
|
|
3
|
-
|
|
4
|
-
interface WebSocketWorkerProps extends WorkerProps {
|
|
5
|
-
url: string;
|
|
6
|
-
}
|
|
7
|
-
class WebSocketWorker extends FuncNodesWorker {
|
|
8
|
-
private _url: string;
|
|
9
|
-
private _websocket: WebSocket | null = null;
|
|
10
|
-
private reconnectAttempts: number = 0;
|
|
11
|
-
private maxReconnectAttempts: number = 999;
|
|
12
|
-
private initialTimeout: number = 200; // Initial reconnect delay in ms
|
|
13
|
-
private maxTimeout: number = 5000; // Maximum reconnect delay
|
|
14
|
-
private _reconnect: boolean = true;
|
|
15
|
-
constructor(data: WebSocketWorkerProps) {
|
|
16
|
-
super(data);
|
|
17
|
-
this._url = data.url;
|
|
18
|
-
this.connect();
|
|
19
|
-
this._zustand.auto_progress();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private connect(): void {
|
|
23
|
-
console.log("Connecting to websocket");
|
|
24
|
-
this.is_open = false;
|
|
25
|
-
this._websocket = new WebSocket(this._url);
|
|
26
|
-
|
|
27
|
-
this._websocket.onopen = () => {
|
|
28
|
-
this.onopen();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
this._websocket.onclose = () => {
|
|
32
|
-
this.onclose();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
this._websocket.onerror = () => {
|
|
36
|
-
this.on_ws_error();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
this._websocket.onmessage = (event) => {
|
|
40
|
-
this.onmessage(event.data);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private calculateReconnectTimeout(): number {
|
|
45
|
-
// Increase timeout exponentially, capped at maxTimeout
|
|
46
|
-
let timeout = Math.min(
|
|
47
|
-
this.initialTimeout * Math.pow(2, this.reconnectAttempts),
|
|
48
|
-
this.maxTimeout
|
|
49
|
-
);
|
|
50
|
-
return timeout;
|
|
51
|
-
}
|
|
52
|
-
private auto_reconnect(): void {
|
|
53
|
-
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
54
|
-
let timeout = this.calculateReconnectTimeout();
|
|
55
|
-
console.log(`Attempting to reconnect in ${timeout} ms`);
|
|
56
|
-
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
if (this._websocket) {
|
|
59
|
-
if (this._websocket.readyState === WebSocket.OPEN) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
this.reconnectAttempts++;
|
|
64
|
-
this.connect();
|
|
65
|
-
}, timeout);
|
|
66
|
-
} else {
|
|
67
|
-
console.warn("Maximum reconnect attempts reached. Giving up.");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async onmessage(data: string) {
|
|
72
|
-
await this.recieve(JSON.parse(data));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
onopen() {
|
|
76
|
-
console.log("Websocket opened");
|
|
77
|
-
this.is_open = true;
|
|
78
|
-
this._zustand.auto_progress();
|
|
79
|
-
this.reconnectAttempts = 0;
|
|
80
|
-
this.fullsync();
|
|
81
|
-
}
|
|
82
|
-
onclose() {
|
|
83
|
-
console.log("Websocket closed", this);
|
|
84
|
-
super.onclose();
|
|
85
|
-
if (this._reconnect) {
|
|
86
|
-
console.log("Websocket closed,reconnecting");
|
|
87
|
-
this.auto_reconnect(); // Attempt to reconnect
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
on_ws_error() {
|
|
92
|
-
console.warn("Websocket error");
|
|
93
|
-
if (this._websocket) {
|
|
94
|
-
this._websocket.close(); // Ensure the connection is closed before attempting to reconnect
|
|
95
|
-
} else {
|
|
96
|
-
this.auto_reconnect();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async send(data: any) {
|
|
101
|
-
if (!this._websocket || this._websocket.readyState !== WebSocket.OPEN) {
|
|
102
|
-
throw new Error("Websocket not connected");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this._websocket.send(JSON.stringify(data));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async stop() {
|
|
109
|
-
await super.stop();
|
|
110
|
-
this._reconnect = false;
|
|
111
|
-
// this.close();
|
|
112
|
-
}
|
|
113
|
-
close() {
|
|
114
|
-
if (this._websocket) this._websocket.close();
|
|
115
|
-
}
|
|
116
|
-
disconnect() {
|
|
117
|
-
super.disconnect();
|
|
118
|
-
this._reconnect = false;
|
|
119
|
-
this.close();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async reconnect() {
|
|
123
|
-
await super.reconnect();
|
|
124
|
-
this._reconnect = true;
|
|
125
|
-
if (this._websocket) {
|
|
126
|
-
console.log("Reconnecting", this._websocket.readyState);
|
|
127
|
-
if (
|
|
128
|
-
this._websocket.readyState === WebSocket.OPEN ||
|
|
129
|
-
this._websocket.readyState === WebSocket.CONNECTING
|
|
130
|
-
) {
|
|
131
|
-
if (this._websocket.readyState === WebSocket.CONNECTING) {
|
|
132
|
-
//await to ensure the websocket is connected, with a timeout of 2 seconds
|
|
133
|
-
await new Promise((resolve, reject) => {
|
|
134
|
-
let timeout = setTimeout(() => {
|
|
135
|
-
reject("Timeout");
|
|
136
|
-
}, 2000);
|
|
137
|
-
this._websocket?.addEventListener("open", () => {
|
|
138
|
-
clearTimeout(timeout);
|
|
139
|
-
resolve(null);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if (this._websocket.readyState === WebSocket.OPEN) {
|
|
144
|
-
this.fullsync();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
this.connect();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default WebSocketWorker;
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { FuncNodesReactFlowZustandInterface, WorkersState } from "../state";
|
|
2
|
-
import FuncNodesWorker from "./funcnodesworker";
|
|
3
|
-
import WebSocketWorker from "./websocketworker";
|
|
4
|
-
|
|
5
|
-
class WorkerManager {
|
|
6
|
-
private wsuri: string;
|
|
7
|
-
private workers: any;
|
|
8
|
-
private ws: WebSocket | null = null;
|
|
9
|
-
private reconnectAttempts: number = 0;
|
|
10
|
-
private maxReconnectAttempts: number = 999;
|
|
11
|
-
private initialTimeout: number = 200; // Initial reconnect delay in ms
|
|
12
|
-
private maxTimeout: number = 2000; // Maximum reconnect delay
|
|
13
|
-
private zustand: FuncNodesReactFlowZustandInterface;
|
|
14
|
-
private connectionTimeout?: NodeJS.Timeout;
|
|
15
|
-
on_setWorker: (worker: FuncNodesWorker | undefined) => void;
|
|
16
|
-
constructor(wsuri: string, zustand: FuncNodesReactFlowZustandInterface) {
|
|
17
|
-
this.wsuri = wsuri;
|
|
18
|
-
this.zustand = zustand;
|
|
19
|
-
this.workers = {};
|
|
20
|
-
this.on_setWorker = (worker: FuncNodesWorker | undefined) => {
|
|
21
|
-
console.log("WorkerManager: on_setWorker", worker);
|
|
22
|
-
this.zustand.worker = worker;
|
|
23
|
-
};
|
|
24
|
-
this.connect();
|
|
25
|
-
}
|
|
26
|
-
private connect(): void {
|
|
27
|
-
this.zustand.set_progress({
|
|
28
|
-
progress: 0,
|
|
29
|
-
message: "connecting to worker manager",
|
|
30
|
-
status: "info",
|
|
31
|
-
blocking: true,
|
|
32
|
-
});
|
|
33
|
-
console.log("Connecting to websocket");
|
|
34
|
-
this.ws = new WebSocket(this.wsuri);
|
|
35
|
-
|
|
36
|
-
this.ws.onopen = () => {
|
|
37
|
-
this.onopen();
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this.ws.onclose = () => {
|
|
41
|
-
this.onclose();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
this.ws.onerror = () => {
|
|
45
|
-
this.on_ws_error();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
this.ws.onmessage = (event) => {
|
|
49
|
-
this.onmessage(event.data);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
this.connectionTimeout = setTimeout(() => {
|
|
53
|
-
if (this.ws?.readyState !== WebSocket.OPEN) {
|
|
54
|
-
this.on_ws_error();
|
|
55
|
-
}
|
|
56
|
-
}, 5000);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
on_ws_error() {
|
|
60
|
-
console.warn("Websocket error");
|
|
61
|
-
if (this.ws) {
|
|
62
|
-
this.ws.close(); // Ensure the connection is closed before attempting to reconnect
|
|
63
|
-
} else {
|
|
64
|
-
this.reconnect();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
onopen() {
|
|
69
|
-
if (this.connectionTimeout) {
|
|
70
|
-
clearTimeout(this.connectionTimeout);
|
|
71
|
-
this.connectionTimeout = undefined;
|
|
72
|
-
}
|
|
73
|
-
this.zustand.auto_progress();
|
|
74
|
-
console.log("WorkerManager: onopen");
|
|
75
|
-
if (this.ws) {
|
|
76
|
-
this.ws.send("worker_status");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Get active worker from window storage
|
|
80
|
-
const active_worker = window.localStorage.getItem(
|
|
81
|
-
"funcnodes__active_worker"
|
|
82
|
-
);
|
|
83
|
-
if (active_worker) {
|
|
84
|
-
this.set_active(active_worker);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
onmessage(event: string) {
|
|
88
|
-
let msg = JSON.parse(event);
|
|
89
|
-
if (msg.type === "worker_status") {
|
|
90
|
-
console.debug("WorkerManager: worker_status", msg);
|
|
91
|
-
const new_state: WorkersState = {};
|
|
92
|
-
for (let worker of msg.active) {
|
|
93
|
-
worker.active = true;
|
|
94
|
-
new_state[worker.uuid] = worker;
|
|
95
|
-
}
|
|
96
|
-
for (let worker of msg.inactive) {
|
|
97
|
-
worker.active = false;
|
|
98
|
-
new_state[worker.uuid] = worker;
|
|
99
|
-
}
|
|
100
|
-
this.zustand.workers.setState(new_state);
|
|
101
|
-
return;
|
|
102
|
-
} else if (msg.type === "set_worker") {
|
|
103
|
-
if (msg.data.type === "WSWorker") {
|
|
104
|
-
let url =
|
|
105
|
-
"ws" +
|
|
106
|
-
(msg.data.ssl ? "s" : "") +
|
|
107
|
-
"://" +
|
|
108
|
-
msg.data.host +
|
|
109
|
-
":" +
|
|
110
|
-
msg.data.port;
|
|
111
|
-
this.setWorker(
|
|
112
|
-
this.workers[msg.data.uuid] ||
|
|
113
|
-
new WebSocketWorker({
|
|
114
|
-
url,
|
|
115
|
-
zustand: this.zustand,
|
|
116
|
-
uuid: msg.data.uuid,
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
} else {
|
|
120
|
-
console.error("WorkerManager: unknown worker type", msg);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
//store active worker in window storage
|
|
124
|
-
|
|
125
|
-
return;
|
|
126
|
-
} else if (msg.type === "progress") {
|
|
127
|
-
this.zustand.set_progress(msg as ProgressStateMessage);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
console.error("WorkerManager: unknown message", msg);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
setWorker(worker: FuncNodesWorker | undefined) {
|
|
134
|
-
for (let w in this.workers) {
|
|
135
|
-
if (w !== worker?.uuid) {
|
|
136
|
-
this.workers[w].disconnect();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (worker !== undefined) {
|
|
140
|
-
this.workers[worker.uuid] = worker;
|
|
141
|
-
worker.reconnect();
|
|
142
|
-
}
|
|
143
|
-
window.localStorage.setItem("funcnodes__active_worker", worker?.uuid || "");
|
|
144
|
-
if (this.zustand.worker !== undefined) {
|
|
145
|
-
this.zustand.clear_all();
|
|
146
|
-
}
|
|
147
|
-
this.zustand.worker = worker;
|
|
148
|
-
this.on_setWorker(worker);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async restart_worker(workerid: string) {
|
|
152
|
-
this.ws?.send(JSON.stringify({ type: "restart_worker", workerid }));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private calculateReconnectTimeout(): number {
|
|
156
|
-
// Increase timeout exponentially, capped at maxTimeout
|
|
157
|
-
let timeout = Math.min(
|
|
158
|
-
this.initialTimeout * Math.pow(2, this.reconnectAttempts),
|
|
159
|
-
this.maxTimeout
|
|
160
|
-
);
|
|
161
|
-
return timeout;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private reconnect(): void {
|
|
165
|
-
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
166
|
-
let timeout = this.calculateReconnectTimeout();
|
|
167
|
-
console.log(`Attempting to reconnect in ${timeout} ms`);
|
|
168
|
-
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
if (this.ws) {
|
|
171
|
-
if (this.ws.readyState === WebSocket.OPEN) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
this.reconnectAttempts++;
|
|
176
|
-
this.connect();
|
|
177
|
-
}, timeout);
|
|
178
|
-
} else {
|
|
179
|
-
console.warn("Maximum reconnect attempts reached. Giving up.");
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
onclose() {
|
|
184
|
-
console.log("WorkerManager: onclose");
|
|
185
|
-
this.reconnect(); // Attempt to reconnect
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
set_active(workerid: string) {
|
|
189
|
-
if (!this.ws) return;
|
|
190
|
-
this.ws.send(JSON.stringify({ type: "set_active", workerid }));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
new_worker({
|
|
194
|
-
name,
|
|
195
|
-
reference,
|
|
196
|
-
copyLib,
|
|
197
|
-
copyNS,
|
|
198
|
-
}: {
|
|
199
|
-
name?: string;
|
|
200
|
-
reference?: string;
|
|
201
|
-
copyLib?: boolean;
|
|
202
|
-
copyNS?: boolean;
|
|
203
|
-
}) {
|
|
204
|
-
if (!name) name = undefined;
|
|
205
|
-
if (!copyLib) copyLib = false;
|
|
206
|
-
if (!copyNS) copyNS = false;
|
|
207
|
-
if (!reference) {
|
|
208
|
-
reference = undefined;
|
|
209
|
-
copyLib = false;
|
|
210
|
-
copyNS = false;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (this.ws) {
|
|
214
|
-
this.ws.send(
|
|
215
|
-
JSON.stringify({
|
|
216
|
-
type: "new_worker",
|
|
217
|
-
kwargs: {
|
|
218
|
-
name,
|
|
219
|
-
reference,
|
|
220
|
-
copyLib,
|
|
221
|
-
copyNS,
|
|
222
|
-
},
|
|
223
|
-
})
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export default WorkerManager;
|
package/src/index.css
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import App from './App';
|
|
5
|
-
import reportWebVitals from './reportWebVitals';
|
|
6
|
-
|
|
7
|
-
const root = ReactDOM.createRoot(
|
|
8
|
-
document.getElementById('root') as HTMLElement
|
|
9
|
-
);
|
|
10
|
-
root.render(
|
|
11
|
-
<React.StrictMode>
|
|
12
|
-
<App />
|
|
13
|
-
</React.StrictMode>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
// If you want to start measuring performance in your app, pass a function
|
|
17
|
-
// to log results (for example: reportWebVitals(console.log))
|
|
18
|
-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
19
|
-
reportWebVitals();
|
package/src/logo.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
package/src/react-app-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="react-scripts" />
|
package/src/reportWebVitals.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReportHandler } from 'web-vitals';
|
|
2
|
-
|
|
3
|
-
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
-
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
-
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
-
getCLS(onPerfEntry);
|
|
7
|
-
getFID(onPerfEntry);
|
|
8
|
-
getFCP(onPerfEntry);
|
|
9
|
-
getLCP(onPerfEntry);
|
|
10
|
-
getTTFB(onPerfEntry);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default reportWebVitals;
|
package/src/setupTests.ts
DELETED
package/src/state/edge.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
interface BaseEdgeAction {
|
|
2
|
-
type: string;
|
|
3
|
-
src_nid: string;
|
|
4
|
-
src_ioid: string;
|
|
5
|
-
trg_nid: string;
|
|
6
|
-
trg_ioid: string;
|
|
7
|
-
from_remote: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface EdgeActionAdd extends BaseEdgeAction {
|
|
11
|
-
type: "add";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface EdgeActionDelete extends BaseEdgeAction {
|
|
15
|
-
type: "delete";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type EdgeAction = EdgeActionAdd | EdgeActionDelete;
|
|
19
|
-
|
|
20
|
-
const generate_edge_id = ({
|
|
21
|
-
src_nid,
|
|
22
|
-
src_ioid,
|
|
23
|
-
trg_nid,
|
|
24
|
-
trg_ioid,
|
|
25
|
-
}: {
|
|
26
|
-
src_nid: string;
|
|
27
|
-
src_ioid: string;
|
|
28
|
-
trg_nid: string;
|
|
29
|
-
trg_ioid: string;
|
|
30
|
-
}) => {
|
|
31
|
-
return [`${src_nid}:${src_ioid}`, `${trg_nid}:${trg_ioid}`].sort().join("--");
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { generate_edge_id };
|
|
35
|
-
export type { EdgeAction, EdgeActionAdd, EdgeActionDelete };
|