@linkdlab/funcnodes_react_flow 0.1.0 → 0.1.1
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/{public → app/public}/index.html +3 -3
- package/{src → app/src}/App.tsx +1 -1
- package/{src → app/src}/index.tsx +6 -6
- package/app/tsconfig.app.json +10 -0
- package/app/webpack.config.js +143 -0
- package/{src → module/src}/frontend/datarenderer/index.tsx +1 -0
- package/{src → module/src}/frontend/dialog.tsx +1 -0
- package/{src → module/src}/frontend/edge.tsx +1 -0
- package/{src/frontend → module/src/frontend/funcnodesreactflow}/funcnodesreactflow.scss +1 -1
- package/module/src/frontend/funcnodesreactflow/index.tsx +68 -0
- package/{src/frontend/funcnodesreactflow.tsx → module/src/frontend/funcnodesreactflow/react_flow_layer.tsx} +65 -136
- package/{src → module/src}/frontend/header/index.tsx +2 -1
- package/{src → module/src}/frontend/index.tsx +1 -1
- package/{src → module/src}/frontend/lib.tsx +2 -1
- package/{src → module/src}/frontend/node/io/default_input_renderer.tsx +3 -1
- package/{src → module/src}/frontend/node/io/default_output_render.tsx +3 -4
- package/{src → module/src}/frontend/node/io/handle_renderer.tsx +6 -1
- package/{src → module/src}/frontend/node/io/io.tsx +1 -0
- package/{src → module/src}/frontend/node/io/nodeinput.tsx +3 -1
- package/{src → module/src}/frontend/node/io/nodeoutput.tsx +7 -1
- package/{src → module/src}/frontend/node/node.tsx +3 -2
- package/{src → module/src}/frontend/utils/table.tsx +3 -2
- package/{src → module/src}/funcnodes/funcnodesworker.ts +6 -5
- package/{src → module/src}/funcnodes/websocketworker.ts +0 -1
- package/{src → module/src}/funcnodes/workermanager.ts +6 -2
- package/module/src/index.tsx +4 -0
- package/{src/state/edge.ts → module/src/states/edge.t.ts} +0 -15
- package/module/src/states/edge.ts +15 -0
- package/module/src/states/fnrfzst.t.ts +117 -0
- package/{src/state → module/src/states}/fnrfzst.ts +19 -44
- package/module/src/states/index.ts +7 -0
- package/module/src/states/lib.t.ts +30 -0
- package/module/src/states/lib.ts +16 -0
- package/{src/state/node.ts → module/src/states/node.t.ts} +24 -44
- package/module/src/states/node.ts +46 -0
- package/{src/types/nodeio.d.ts → module/src/states/nodeio.t.ts} +21 -0
- package/module/src/states/nodespace.t.ts +57 -0
- package/{src/state → module/src/states}/nodespace.ts +4 -65
- package/module/src/states/reactflow.t.ts +27 -0
- package/{src/state → module/src/states}/reactflow.ts +2 -18
- package/module/src/types/funcnodesreactflow.d.ts +1 -0
- package/module/src/types/rendering.t.ts +13 -0
- package/module/src/utils/index.ts +4 -0
- package/{src/state/index.ts → module/src/utils/objects.ts} +0 -8
- package/module/tsconfig.module.json +15 -0
- package/module/webpack.config.js +140 -0
- package/package.json +27 -5
- package/tsconfig.json +1 -3
- package/package copy.json +0 -63
- package/src/frontend/nodecontextmenu.scss +0 -18
- package/src/logo.svg +0 -1
- package/src/state/lib.ts +0 -26
- package/src/types/lib.d.ts +0 -16
- package/src/types/node.d.ts +0 -29
- package/src/types/worker.d.ts +0 -56
- /package/{public → app/public}/favicon.ico +0 -0
- /package/{public → app/public}/logo192.png +0 -0
- /package/{public → app/public}/logo512.png +0 -0
- /package/{public → app/public}/manifest.json +0 -0
- /package/{public → app/public}/robots.txt +0 -0
- /package/{public → app/public}/worker_manager +0 -0
- /package/{src → app/src}/App.css +0 -0
- /package/{src → app/src}/App.test.tsx +0 -0
- /package/{src → app/src}/index.css +0 -0
- /package/{src → app/src}/react-app-env.d.ts +0 -0
- /package/{src → app/src}/reportWebVitals.ts +0 -0
- /package/{src → app/src}/setupTests.ts +0 -0
- /package/{src → module/src}/frontend/datarenderer/images.tsx +0 -0
- /package/{src → module/src}/frontend/datarenderer/plotly.tsx +0 -0
- /package/{src → module/src}/frontend/dialog.scss +0 -0
- /package/{src → module/src}/frontend/edge.scss +0 -0
- /package/{src → module/src}/frontend/header/header.scss +0 -0
- /package/{src → module/src}/frontend/layout/htmlelements.scss +0 -0
- /package/{src → module/src}/frontend/lib.scss +0 -0
- /package/{src → module/src}/frontend/node/index.tsx +0 -0
- /package/{src → module/src}/frontend/node/io/index.tsx +0 -0
- /package/{src → module/src}/frontend/node/io/io.scss +0 -0
- /package/{src → module/src}/frontend/node/node.scss +0 -0
- /package/{src → module/src}/frontend/utils/colorpicker.scss +0 -0
- /package/{src → module/src}/frontend/utils/colorpicker.tsx +0 -0
- /package/{src → module/src}/frontend/utils/jsondata.tsx +0 -0
- /package/{src → module/src}/frontend/utils/table.scss +0 -0
- /package/{src → module/src}/funcnodes/index.ts +0 -0
|
@@ -7,20 +7,21 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from "react";
|
|
9
9
|
|
|
10
|
-
import { NodeStore } from "../../
|
|
10
|
+
import { NodeStore, NodeType } from "../../states/node.t";
|
|
11
11
|
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
|
12
12
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
13
13
|
import ExpandIcon from "@mui/icons-material/Expand";
|
|
14
14
|
import LanIcon from "@mui/icons-material/Lan";
|
|
15
15
|
import PlayCircleFilledIcon from "@mui/icons-material/PlayCircleFilled";
|
|
16
16
|
import "./node.scss";
|
|
17
|
-
import { FuncNodesReactFlowZustandInterface } from "../../
|
|
17
|
+
import { FuncNodesReactFlowZustandInterface } from "../../states/fnrfzst.t";
|
|
18
18
|
import { FuncNodesContext } from "..";
|
|
19
19
|
import get_rendertype from "../datarenderer";
|
|
20
20
|
import CustomColorPicker, { HSLColorPicker } from "../utils/colorpicker";
|
|
21
21
|
import { NodeInput, NodeOutput } from "./io";
|
|
22
22
|
import { PreviewHandleDataRendererForIo } from "./io/handle_renderer";
|
|
23
23
|
import CustomDialog from "../dialog";
|
|
24
|
+
import { IOType } from "../../states/nodeio.t";
|
|
24
25
|
interface NodeHeaderProps {
|
|
25
26
|
node_data: NodeType;
|
|
26
27
|
}
|
|
@@ -9,6 +9,7 @@ import TableSortLabel from "@mui/material/TableSortLabel";
|
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
10
|
|
|
11
11
|
import "./table.scss";
|
|
12
|
+
import React from "react";
|
|
12
13
|
|
|
13
14
|
interface TableData {
|
|
14
15
|
columns: string[];
|
|
@@ -67,7 +68,7 @@ const transform_table_data = (data: TableData): TransFormedTableData => {
|
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
const SortableTable = ({ tabledata }: { tabledata: TableData }) => {
|
|
71
72
|
// State to manage the sorted column and direction
|
|
72
73
|
const transformed_table_data: TransFormedTableData = useMemo(
|
|
73
74
|
() => transform_table_data(tabledata),
|
|
@@ -154,6 +155,6 @@ function SortableTable({ tabledata }: { tabledata: TableData }) {
|
|
|
154
155
|
</Table>
|
|
155
156
|
</TableContainer>
|
|
156
157
|
);
|
|
157
|
-
}
|
|
158
|
+
};
|
|
158
159
|
|
|
159
160
|
export { SortableTable };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
2
|
import {
|
|
3
|
+
FullState,
|
|
3
4
|
FuncNodesReactFlowZustandInterface,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../
|
|
7
|
-
import { NodeActionUpdate } from "../
|
|
8
|
-
import {
|
|
5
|
+
JSONMessage,
|
|
6
|
+
NodeSpaceEvent,
|
|
7
|
+
} from "../states/fnrfzst.t";
|
|
8
|
+
import { NodeActionUpdate, NodeType, PartialNodeType } from "../states/node.t"; // Import the missing type
|
|
9
|
+
import { deep_merge } from "../utils";
|
|
9
10
|
type CmdMessage = {
|
|
10
11
|
type: string;
|
|
11
12
|
cmd: string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FuncNodesReactFlowZustandInterface,
|
|
3
|
+
ProgressStateMessage,
|
|
4
|
+
WorkersState,
|
|
5
|
+
} from "../states/fnrfzst.t";
|
|
2
6
|
import FuncNodesWorker from "./funcnodesworker";
|
|
3
7
|
import WebSocketWorker from "./websocketworker";
|
|
4
8
|
|
|
@@ -30,7 +34,7 @@ class WorkerManager {
|
|
|
30
34
|
status: "info",
|
|
31
35
|
blocking: true,
|
|
32
36
|
});
|
|
33
|
-
console.log("Connecting to websocket");
|
|
37
|
+
console.log("Connecting to websocket:", this.wsuri);
|
|
34
38
|
this.ws = new WebSocket(this.wsuri);
|
|
35
39
|
|
|
36
40
|
this.ws.onopen = () => {
|
|
@@ -17,19 +17,4 @@ interface EdgeActionDelete extends BaseEdgeAction {
|
|
|
17
17
|
|
|
18
18
|
type EdgeAction = EdgeActionAdd | EdgeActionDelete;
|
|
19
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
20
|
export type { EdgeAction, EdgeActionAdd, EdgeActionDelete };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const generate_edge_id = ({
|
|
2
|
+
src_nid,
|
|
3
|
+
src_ioid,
|
|
4
|
+
trg_nid,
|
|
5
|
+
trg_ioid,
|
|
6
|
+
}: {
|
|
7
|
+
src_nid: string;
|
|
8
|
+
src_ioid: string;
|
|
9
|
+
trg_nid: string;
|
|
10
|
+
trg_ioid: string;
|
|
11
|
+
}) => {
|
|
12
|
+
return [`${src_nid}:${src_ioid}`, `${trg_nid}:${trg_ioid}`].sort().join("--");
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { generate_edge_id };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { StoreApi, UseBoundStore } from "zustand";
|
|
2
|
+
import { FuncNodesWorker, WorkerManager } from "../funcnodes";
|
|
3
|
+
import { LibType, LibZustandInterface } from "./lib.t";
|
|
4
|
+
import { NodeSpaceZustandInterface } from "./nodespace.t";
|
|
5
|
+
import { NodeAction, NodeType } from "./node.t";
|
|
6
|
+
import { RFStore } from "./reactflow.t";
|
|
7
|
+
import { EdgeAction } from "./edge.t";
|
|
8
|
+
import { useReactFlow } from "reactflow";
|
|
9
|
+
|
|
10
|
+
interface RenderOptions {
|
|
11
|
+
typemap?: { [key: string]: string };
|
|
12
|
+
inputconverter?: { [key: string]: string };
|
|
13
|
+
}
|
|
14
|
+
interface NodeViewState {
|
|
15
|
+
pos: [number, number];
|
|
16
|
+
size: [number, number];
|
|
17
|
+
collapsed: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ViewState {
|
|
20
|
+
nodes: { [key: string]: NodeViewState };
|
|
21
|
+
renderoptions?: RenderOptions;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface FullNodeSpaceJSON {
|
|
25
|
+
nodes: NodeType[];
|
|
26
|
+
edges: [string, string, string, string][];
|
|
27
|
+
prop: { [key: string]: any };
|
|
28
|
+
lib: LibType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface FullState {
|
|
32
|
+
backend: FullNodeSpaceJSON;
|
|
33
|
+
view: ViewState;
|
|
34
|
+
worker: { [key: string]: string[] };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ProgressState {
|
|
38
|
+
message: string;
|
|
39
|
+
status: string;
|
|
40
|
+
progress: number;
|
|
41
|
+
blocking: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface ProgressStateMessage extends ProgressState {
|
|
45
|
+
type: "progress";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ResultMessage {
|
|
49
|
+
type: "result";
|
|
50
|
+
id?: string;
|
|
51
|
+
result: any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface ErrorMessage {
|
|
55
|
+
type: "error";
|
|
56
|
+
error: string;
|
|
57
|
+
tb: string[];
|
|
58
|
+
id?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface NodeSpaceEvent {
|
|
62
|
+
type: "nsevent";
|
|
63
|
+
event: string;
|
|
64
|
+
data: { [key: string]: any };
|
|
65
|
+
}
|
|
66
|
+
type JSONMessage =
|
|
67
|
+
| ProgressStateMessage
|
|
68
|
+
| ResultMessage
|
|
69
|
+
| ErrorMessage
|
|
70
|
+
| NodeSpaceEvent;
|
|
71
|
+
|
|
72
|
+
interface WorkerRepresentation {
|
|
73
|
+
uuid: string;
|
|
74
|
+
host: string;
|
|
75
|
+
port: number;
|
|
76
|
+
ssl: boolean;
|
|
77
|
+
active: boolean;
|
|
78
|
+
name: string | null;
|
|
79
|
+
}
|
|
80
|
+
interface WorkersState {
|
|
81
|
+
[key: string]: WorkerRepresentation;
|
|
82
|
+
}
|
|
83
|
+
interface FuncNodesReactFlowZustandInterface {
|
|
84
|
+
lib: LibZustandInterface;
|
|
85
|
+
workermanager: WorkerManager | undefined;
|
|
86
|
+
workers: UseBoundStore<StoreApi<WorkersState>>;
|
|
87
|
+
worker: FuncNodesWorker | undefined;
|
|
88
|
+
nodespace: NodeSpaceZustandInterface;
|
|
89
|
+
useReactFlowStore: RFStore;
|
|
90
|
+
render_options: UseBoundStore<StoreApi<RenderOptions>>;
|
|
91
|
+
progress_state: UseBoundStore<StoreApi<ProgressState>>;
|
|
92
|
+
update_render_options: (options: RenderOptions) => void;
|
|
93
|
+
rf_instance?: ReturnType<typeof useReactFlow>;
|
|
94
|
+
on_node_action: (action: NodeAction) => void;
|
|
95
|
+
on_edge_action: (edge: EdgeAction) => void;
|
|
96
|
+
set_progress: (progress: ProgressState) => void;
|
|
97
|
+
auto_progress: () => void;
|
|
98
|
+
reactflowRef: HTMLDivElement | null;
|
|
99
|
+
clear_all: () => void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type {
|
|
103
|
+
FuncNodesReactFlowZustandInterface,
|
|
104
|
+
WorkersState,
|
|
105
|
+
WorkerRepresentation,
|
|
106
|
+
JSONMessage,
|
|
107
|
+
FullState,
|
|
108
|
+
FullNodeSpaceJSON,
|
|
109
|
+
ViewState,
|
|
110
|
+
RenderOptions,
|
|
111
|
+
ProgressState,
|
|
112
|
+
ProgressStateMessage,
|
|
113
|
+
ResultMessage,
|
|
114
|
+
ErrorMessage,
|
|
115
|
+
NodeSpaceEvent,
|
|
116
|
+
NodeViewState,
|
|
117
|
+
};
|
|
@@ -1,52 +1,28 @@
|
|
|
1
|
-
import LibZustand
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import reactflowstore, { RFStore } from "./reactflow";
|
|
1
|
+
import LibZustand from "./lib";
|
|
2
|
+
import NodeSpaceZustand from "./nodespace";
|
|
3
|
+
import { createNodeStore } from "./node";
|
|
4
|
+
import { PartialIOType } from "./nodeio.t";
|
|
5
|
+
import reactflowstore from "./reactflow";
|
|
7
6
|
import {
|
|
8
7
|
Node as RFNode,
|
|
9
8
|
NodeChange,
|
|
10
|
-
useReactFlow,
|
|
11
9
|
EdgeChange,
|
|
12
10
|
Edge as RFEdge,
|
|
13
11
|
Connection as RFConnection,
|
|
14
12
|
} from "reactflow";
|
|
15
|
-
import { NodeAction } from "./node";
|
|
16
|
-
import { deep_merge } from "
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
13
|
+
import { NodeAction, NodeStore } from "./node.t";
|
|
14
|
+
import { deep_merge } from "../utils";
|
|
15
|
+
import { generate_edge_id } from "./edge";
|
|
16
|
+
import { EdgeAction } from "./edge.t";
|
|
17
|
+
import { create } from "zustand";
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
interface WorkersState {
|
|
30
|
-
[key: string]: WorkerRepresentation;
|
|
31
|
-
}
|
|
32
|
-
interface FuncNodesReactFlowZustandInterface {
|
|
33
|
-
lib: LibZustandInterface;
|
|
34
|
-
workermanager: WorkerManager | undefined;
|
|
35
|
-
workers: UseBoundStore<StoreApi<WorkersState>>;
|
|
36
|
-
worker: FuncNodesWorker | undefined;
|
|
37
|
-
nodespace: NodeSpaceZustandInterface;
|
|
38
|
-
useReactFlowStore: RFStore;
|
|
39
|
-
render_options: UseBoundStore<StoreApi<RenderOptions>>;
|
|
40
|
-
progress_state: UseBoundStore<StoreApi<ProgressState>>;
|
|
41
|
-
update_render_options: (options: RenderOptions) => void;
|
|
42
|
-
rf_instance?: ReturnType<typeof useReactFlow>;
|
|
43
|
-
on_node_action: (action: NodeAction) => void;
|
|
44
|
-
on_edge_action: (edge: EdgeAction) => void;
|
|
45
|
-
set_progress: (progress: ProgressState) => void;
|
|
46
|
-
auto_progress: () => void;
|
|
47
|
-
reactflowRef: HTMLDivElement | null;
|
|
48
|
-
clear_all: () => void;
|
|
49
|
-
}
|
|
19
|
+
import type {
|
|
20
|
+
FuncNodesReactFlowZustandInterface,
|
|
21
|
+
ProgressState,
|
|
22
|
+
RenderOptions,
|
|
23
|
+
WorkersState,
|
|
24
|
+
} from "./fnrfzst.t";
|
|
25
|
+
import type { NodeType } from "./node.t";
|
|
50
26
|
|
|
51
27
|
const _fill_node_frontend = (
|
|
52
28
|
node: NodeType,
|
|
@@ -194,7 +170,7 @@ const FuncNodesReactFlowZustand = (): FuncNodesReactFlowZustandInterface => {
|
|
|
194
170
|
if (action.node.io) {
|
|
195
171
|
for (const io in action.node.io) {
|
|
196
172
|
// if fullvalue is in the update data, set to fullvalue otherwise set to undefined
|
|
197
|
-
new_obj.io[io].fullvalue = action.node.io[io]
|
|
173
|
+
new_obj.io[io].fullvalue = action.node.io[io]?.fullvalue;
|
|
198
174
|
}
|
|
199
175
|
}
|
|
200
176
|
|
|
@@ -436,5 +412,4 @@ const FuncNodesReactFlowZustand = (): FuncNodesReactFlowZustandInterface => {
|
|
|
436
412
|
};
|
|
437
413
|
|
|
438
414
|
export default FuncNodesReactFlowZustand;
|
|
439
|
-
export { LibZustand, NodeSpaceZustand };
|
|
440
|
-
export type { FuncNodesReactFlowZustandInterface, WorkersState };
|
|
415
|
+
export { LibZustand, NodeSpaceZustand, assert_reactflow_node };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import LibZustand from "./lib";
|
|
2
|
+
import NodeSpaceZustand from "./nodespace";
|
|
3
|
+
import { FuncNodesReactFlowZustandInterface, WorkersState } from "./fnrfzst.t";
|
|
4
|
+
import FuncNodesReactFlowZustand from "./fnrfzst";
|
|
5
|
+
export default FuncNodesReactFlowZustand;
|
|
6
|
+
export { LibZustand, NodeSpaceZustand };
|
|
7
|
+
export type { FuncNodesReactFlowZustandInterface, WorkersState };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useStore, create, UseBoundStore, StoreApi } from "zustand";
|
|
2
|
+
|
|
3
|
+
type LibNode = {
|
|
4
|
+
node_id: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
node_name?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Shelf = {
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
nodes: LibNode[];
|
|
13
|
+
subshelves: Shelf[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type LibType = {
|
|
17
|
+
shelves: Shelf[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface LibState {
|
|
21
|
+
state: LibType;
|
|
22
|
+
set: (state: LibType) => void;
|
|
23
|
+
get: () => LibType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LibZustandInterface {
|
|
27
|
+
libstate: UseBoundStore<StoreApi<LibState>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type { LibZustandInterface, LibState, LibType, Shelf, LibNode };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { LibType, LibZustandInterface, LibState } from "./lib.t";
|
|
3
|
+
|
|
4
|
+
const LibZustand = (): LibZustandInterface => {
|
|
5
|
+
return {
|
|
6
|
+
libstate: create<LibState>((set, get) => ({
|
|
7
|
+
state: {
|
|
8
|
+
shelves: [],
|
|
9
|
+
},
|
|
10
|
+
set: (state: LibType) => set({ state: state }),
|
|
11
|
+
get: () => get().state,
|
|
12
|
+
})),
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default LibZustand;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useStore, create, UseBoundStore, StoreApi } from "zustand";
|
|
2
|
-
import { DeepPartial, deep_merge } from "
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { DeepPartial, deep_merge } from "../utils";
|
|
3
|
+
import { IOType } from "./nodeio.t";
|
|
4
|
+
import { DataRenderOptions } from "../types/rendering.t";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Interface for the NodeActionAdd.
|
|
@@ -64,48 +64,27 @@ type NodeAction =
|
|
|
64
64
|
|
|
65
65
|
type NodeStore = UseBoundStore<StoreApi<NodeType>>;
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
frontend: {
|
|
71
|
-
pos: [0, 0],
|
|
72
|
-
size: [200, 100],
|
|
73
|
-
collapsed: false,
|
|
74
|
-
},
|
|
75
|
-
io: {},
|
|
76
|
-
name: "dummy",
|
|
77
|
-
in_trigger: false,
|
|
78
|
-
io_order: [],
|
|
79
|
-
};
|
|
80
|
-
const assert_full_node = (node: PartialNodeType): NodeType => {
|
|
81
|
-
if (!node.id) {
|
|
82
|
-
throw new Error("Node must have an id");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const { new_obj } = deep_merge(dummy_node, node);
|
|
86
|
-
return new_obj;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const createNodeStore = (node: NodeType): NodeStore => {
|
|
90
|
-
// check if node is Object
|
|
67
|
+
interface NodeRenderOptions {
|
|
68
|
+
data?: DataRenderOptions;
|
|
69
|
+
}
|
|
91
70
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
71
|
+
interface NodeType {
|
|
72
|
+
id: string;
|
|
73
|
+
node_name: string;
|
|
74
|
+
io: { [key: string]: IOType };
|
|
75
|
+
frontend: {
|
|
76
|
+
pos: [number, number];
|
|
77
|
+
size: [number, number];
|
|
78
|
+
collapsed: boolean;
|
|
79
|
+
};
|
|
80
|
+
name: string;
|
|
81
|
+
in_trigger: boolean;
|
|
82
|
+
error?: string;
|
|
83
|
+
render_options?: NodeRenderOptions;
|
|
84
|
+
io_order: string[];
|
|
85
|
+
}
|
|
105
86
|
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
export { createNodeStore, assert_full_node };
|
|
87
|
+
type PartialNodeType = DeepPartial<NodeType>;
|
|
109
88
|
|
|
110
89
|
export type {
|
|
111
90
|
NodeStore,
|
|
@@ -114,5 +93,6 @@ export type {
|
|
|
114
93
|
NodeActionDelete,
|
|
115
94
|
NodeActionAdd,
|
|
116
95
|
NodeActionError,
|
|
117
|
-
|
|
96
|
+
PartialNodeType,
|
|
97
|
+
NodeType,
|
|
118
98
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useStore, create, UseBoundStore, StoreApi } from "zustand";
|
|
2
|
+
import { deep_merge } from "../utils";
|
|
3
|
+
import { NodeType, PartialNodeType, NodeStore } from "./node.t";
|
|
4
|
+
import { IOType } from "./nodeio.t";
|
|
5
|
+
const dummy_node: NodeType = {
|
|
6
|
+
id: "dummy",
|
|
7
|
+
node_name: "dummy",
|
|
8
|
+
frontend: {
|
|
9
|
+
pos: [0, 0],
|
|
10
|
+
size: [200, 100],
|
|
11
|
+
collapsed: false,
|
|
12
|
+
},
|
|
13
|
+
io: {},
|
|
14
|
+
name: "dummy",
|
|
15
|
+
in_trigger: false,
|
|
16
|
+
io_order: [],
|
|
17
|
+
};
|
|
18
|
+
const assert_full_node = (node: PartialNodeType): NodeType => {
|
|
19
|
+
if (!node.id) {
|
|
20
|
+
throw new Error("Node must have an id");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { new_obj } = deep_merge(dummy_node, node);
|
|
24
|
+
return new_obj;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const createNodeStore = (node: NodeType): NodeStore => {
|
|
28
|
+
// check if node is Object
|
|
29
|
+
|
|
30
|
+
if (node.io === undefined) {
|
|
31
|
+
node.io = {};
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(node.io)) {
|
|
34
|
+
node.io_order = node.io.map((io) => io.id);
|
|
35
|
+
const new_io: { [key: string]: IOType } = {};
|
|
36
|
+
for (const io of node.io) {
|
|
37
|
+
new_io[io.id] = io;
|
|
38
|
+
}
|
|
39
|
+
node.io = new_io;
|
|
40
|
+
} else {
|
|
41
|
+
node.io_order = Object.keys(node.io);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return create<NodeType>((set, get) => node);
|
|
45
|
+
};
|
|
46
|
+
export { createNodeStore, assert_full_node };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BaseRenderOptions } from "../types/rendering.t";
|
|
2
|
+
import { DeepPartial } from "../utils";
|
|
1
3
|
interface AllOf {
|
|
2
4
|
allOf: SerializedType[];
|
|
3
5
|
}
|
|
@@ -80,3 +82,22 @@ type InputRendererType = ({
|
|
|
80
82
|
io,
|
|
81
83
|
inputconverter,
|
|
82
84
|
}: InputRendererProps) => JSX.Element;
|
|
85
|
+
|
|
86
|
+
type PartialIOType = DeepPartial<IOType>;
|
|
87
|
+
|
|
88
|
+
export type {
|
|
89
|
+
AllOf,
|
|
90
|
+
AnyOf,
|
|
91
|
+
ArrayOf,
|
|
92
|
+
DictOf,
|
|
93
|
+
EnumOf,
|
|
94
|
+
TypeOf,
|
|
95
|
+
SerializedType,
|
|
96
|
+
IORenderOptions,
|
|
97
|
+
IOValueOptions,
|
|
98
|
+
IOType,
|
|
99
|
+
OutputRendererType,
|
|
100
|
+
InputRendererProps,
|
|
101
|
+
InputRendererType,
|
|
102
|
+
PartialIOType,
|
|
103
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { NodeStore } from "./node.t";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the NodeSpaceZustand state management.
|
|
5
|
+
* This interface is used to define the shape of the state and the actions that can be performed on it.
|
|
6
|
+
*/
|
|
7
|
+
interface NodeSpaceZustandInterface {
|
|
8
|
+
// A Map object that holds NodeStore objects. The key is a string (node id), and the value is a NodeStore.
|
|
9
|
+
nodesstates: Map<string, NodeStore>;
|
|
10
|
+
|
|
11
|
+
get_node: (nid: string, raise?: boolean) => NodeStore | undefined;
|
|
12
|
+
|
|
13
|
+
// A function to add a new node to the nodesstates Map. It takes a NodeType object as a parameter.
|
|
14
|
+
// add_node: ({
|
|
15
|
+
// node,
|
|
16
|
+
// from_remote,
|
|
17
|
+
// }: {
|
|
18
|
+
// node: NodeType;
|
|
19
|
+
// from_remote: boolean;
|
|
20
|
+
// }) => void;
|
|
21
|
+
|
|
22
|
+
// // A function to update an existing node in the nodesstates Map.
|
|
23
|
+
// // It takes a node id (string) and a PartialNodeType object (which contains the properties to be updated) as parameters.
|
|
24
|
+
// update_node: ({
|
|
25
|
+
// nid,
|
|
26
|
+
// node,
|
|
27
|
+
// from_remote,
|
|
28
|
+
// }: {
|
|
29
|
+
// nid: string;
|
|
30
|
+
// node: PartialNodeType;
|
|
31
|
+
// from_remote: boolean;
|
|
32
|
+
// }) => void;
|
|
33
|
+
|
|
34
|
+
// set_value: ({
|
|
35
|
+
// node,
|
|
36
|
+
// io,
|
|
37
|
+
// value,
|
|
38
|
+
// set_default,
|
|
39
|
+
// }: {
|
|
40
|
+
// node: string;
|
|
41
|
+
// io: string;
|
|
42
|
+
// value: any;
|
|
43
|
+
// set_default?: boolean | undefined;
|
|
44
|
+
// }) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Interface for the NodeSpaceZustandProps.
|
|
49
|
+
* This interface is used to define the properties that can be passed to the NodeSpaceZustand component.
|
|
50
|
+
*/
|
|
51
|
+
interface NodeSpaceZustandProps {
|
|
52
|
+
// Optional callback function that is invoked when a node action occurs.
|
|
53
|
+
// The function takes a NodeAction object as a parameter.
|
|
54
|
+
// on_node_action?: (action: NodeAction) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type { NodeSpaceZustandProps, NodeSpaceZustandInterface };
|