Skip to content

Commit f2edc12

Browse files
committed
Persistence PWV Fixes + Refactor
1 parent bf6c2a3 commit f2edc12

14 files changed

Lines changed: 344 additions & 186 deletions

File tree

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
<span class="pywebview-drag-region"></span>
4141
<div id="root"></div>
4242

43-
<script type="module" src="/src/main.tsx"></script>
44-
4543
<script defer>
4644
let checkCount = 0;
4745

@@ -65,5 +63,7 @@
6563
event.preventDefault();
6664
});
6765
</script>
66+
67+
<script type="module" src="/src/main.tsx" defer></script>
6868
</body>
6969
</html>

src/App.tsx

Lines changed: 8 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,26 @@
1-
import { useEffect } from "react";
2-
3-
import { useNodeFactoryContext } from "@utils/nodeFactory";
4-
import { useNodeSystemContext } from "@utils/nodeSystem";
5-
import { useNodeHistoryContext } from "@utils/nodeHistory";
6-
import { usePromptContext } from "@utils/prompt";
7-
import { usePalleteContext } from "@utils/pallete";
8-
import { useVariablesContext } from "@utils/variables";
9-
import { loadProject, saveProject } from "@utils/engineTools";
10-
import {
11-
getBreadcrumb,
12-
getWindowTools,
13-
loadActiveProjectId,
14-
updatePalleteRegistry,
15-
} from "@utils/projectTools";
1+
import { useAppDataContext } from "@utils/appData";
162

173
import { AppWindow } from "@components/window/AppWindow";
184
import { Canvas } from "@components/engine/Canvas";
195
import { Prompt } from "@components/commons/Prompt";
206

217
export default function App() {
22-
const { newNode } = useNodeFactoryContext()!;
23-
24-
const {
25-
nodeSystem,
26-
isEntry,
27-
createEntry,
28-
entries,
29-
overrideNodeSystem,
30-
removeNode,
31-
} = useNodeSystemContext()!;
32-
33-
const {
34-
promptComponent,
35-
promptState,
36-
statesList,
37-
customComponents,
38-
overrideVariables,
39-
} = useVariablesContext()!;
40-
418
const {
42-
activeNode,
43-
openNode,
44-
closeNode,
45-
nodeHistory,
46-
} = useNodeHistoryContext()!;
47-
48-
const {
49-
addSuggestion,
9+
windowTools,
10+
breadcrumb,
5011
generateSuggestions,
51-
} = usePalleteContext()!;
52-
53-
const {
54-
requestPrompt,
55-
} = usePromptContext()!;
56-
57-
const windowTools = getWindowTools(
58-
closeNode,
59-
isEntry,
60-
activeNode,
61-
overrideNodeSystem,
62-
overrideVariables,
63-
openNode,
64-
removeNode,
65-
nodeSystem,
66-
entries,
67-
statesList,
68-
customComponents,
69-
);
70-
71-
const windowExtraTitle = getBreadcrumb(
72-
nodeHistory,
73-
activeNode,
74-
);
75-
76-
useEffect(() => {
77-
(async () => {
78-
const requireLoading = await loadActiveProjectId();
79-
if (!requireLoading) return;
80-
81-
loadProject(
82-
overrideNodeSystem,
83-
overrideVariables,
84-
openNode,
85-
removeNode,
86-
)
87-
})();
88-
}, [
89-
overrideNodeSystem,
90-
overrideVariables,
91-
openNode,
92-
removeNode,
93-
]);
94-
95-
useEffect(() => {
96-
updatePalleteRegistry(
97-
addSuggestion,
98-
openNode,
99-
entries,
100-
createEntry,
101-
requestPrompt,
102-
promptComponent,
103-
promptState,
104-
)
105-
}, [
106-
addSuggestion,
107-
openNode,
108-
entries,
109-
createEntry,
110-
requestPrompt,
111-
promptComponent,
112-
promptState,
113-
]);
114-
115-
useEffect(() => {
116-
saveProject(
117-
nodeSystem,
118-
entries,
119-
{
120-
states: statesList,
121-
customComponents,
122-
},
123-
);
124-
}, [
125-
entries,
126-
nodeSystem,
127-
statesList,
128-
customComponents,
129-
]);
12+
nodes,
13+
} = useAppDataContext()!;
13014

13115
return (<>
13216
<AppWindow
13317
tools={windowTools}
134-
extraTitle={windowExtraTitle}
18+
breadcrumb={breadcrumb}
13519
generateSuggestions={generateSuggestions}
13620
>
137-
<Canvas
138-
nodes={[
139-
...nodeSystem[activeNode]?.nodes || [],
140-
newNode
141-
]}
142-
/>
21+
<Canvas nodes={nodes} />
14322
<Prompt />
14423
</AppWindow>
14524
</>);
14625
}
26+

src/components/engine/Node/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,7 @@
137137
width: 100%;
138138
}
139139

140+
.node-base-input input::placeholder {
141+
color: #ffffff66;
142+
}
143+

src/components/window/AppBar/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
import type { Suggestion, ToolButtonData } from "@defs/UI";
2+
13
import { isDesktop } from "@utils/desktopTools";
24

35
import { WindowActions } from "@components/window/WindowActions";
4-
import { ToolBar, type ToolButtonData } from "@components/window/ToolBar";
5-
import { Pallete, type Suggestion } from "@components/window/Pallete";
6+
import { ToolBar } from "@components/window/ToolBar";
7+
import { Pallete } from "@components/window/Pallete";
68

79
import "./style.css";
810

911
export function AppBar({
1012
tools=[],
11-
extraTitle = "",
13+
breadcrumb = "",
1214
generateSuggestions = () => [],
1315
}: {
1416
tools?: ToolButtonData[];
15-
extraTitle?: string;
17+
breadcrumb?: string;
1618
generateSuggestions?: (query: string) => Suggestion[];
1719
}) {
1820
const title: string = "GraphScript Engine";
@@ -35,7 +37,7 @@ export function AppBar({
3537

3638
<div className="root-app-extra-title">
3739
<span>
38-
{extraTitle}
40+
{breadcrumb}
3941
</span>
4042
</div>
4143
</div>

src/components/window/AppWindow/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import type { ReactNode } from "react";
2+
3+
import type { Suggestion, ToolButtonData } from "@defs/UI";
4+
25
import { isDesktop } from "@utils/desktopTools";
36

47
import { AppBar } from "@components/window/AppBar";
5-
import type { ToolButtonData } from "@components/window/ToolBar";
6-
import type { Suggestion } from "@components/window/Pallete";
78

89
import "./style.css";
910

1011
export function AppWindow({
1112
children,
1213
tools = [],
13-
extraTitle = "",
14+
breadcrumb = "",
1415
generateSuggestions = () => [],
1516
}: {
1617
children?: ReactNode;
1718
tools?: ToolButtonData[];
18-
extraTitle?: string;
19+
breadcrumb?: string;
1920
generateSuggestions?: (query: string) => Suggestion[];
2021
}) {
2122
return (<>
@@ -24,7 +25,7 @@ export function AppWindow({
2425
}`}>
2526
<AppBar
2627
tools={tools}
27-
extraTitle={extraTitle}
28+
breadcrumb={breadcrumb}
2829
generateSuggestions={generateSuggestions}
2930
/>
3031

src/components/window/Pallete/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { useEffect, useState } from "react";
22

3+
import type { Suggestion } from "@defs/UI";
4+
35
import { Input } from "@components/commons/Input";
46
import { DynamicIcon } from "@components/commons/DynamicIcon";
57

68
import "./style.css";
79

8-
export type Suggestion = {
9-
name: string;
10-
icon: string;
11-
action: () => void;
12-
}
13-
1410
export function Pallete({
1511
generateSuggestions,
1612
}: {

src/components/window/ToolBar/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1+
import type { ToolButtonData } from "@defs/UI";
2+
13
import { DynamicIcon } from "@components/commons/DynamicIcon";
24

35
import "./style.css";
46

5-
export type ToolButtonData = {
6-
name: string;
7-
icon: string;
8-
action: () => void;
9-
disabled?: boolean;
10-
};
11-
127
export function ToolBar({ tools }: {
138
tools: ToolButtonData[];
149
}) {

src/defs/UI.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type ToolButtonData = {
2+
name: string;
3+
icon: string;
4+
action: () => void;
5+
disabled?: boolean;
6+
};
7+
8+
export type Suggestion = {
9+
name: string;
10+
icon: string;
11+
action: () => void;
12+
}
13+

0 commit comments

Comments
 (0)