Skip to content

Commit 492a6cb

Browse files
committed
Run Project
1 parent dca4531 commit 492a6cb

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/defs/PyWebview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface PyWebview {
1111
load_project_id: () => Promise<string | null>;
1212
backup_project: (content: string) => Promise<boolean>;
1313
restore_project: () => Promise<string>;
14+
run_project: () => Promise<void>;
1415
}
1516
}
1617

src/utils/desktopTools.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ const setupDesktopTools = () => {
111111
return getApi()!.restore_project();
112112
}
113113

114+
const runProject = async (): Promise<void> => {
115+
if (!isDesktop()) return;
116+
await waitForPWV();
117+
return getApi()!.run_project();
118+
}
119+
114120
return {
115121
isDesktop,
116122
closeWindow,
@@ -119,7 +125,8 @@ const setupDesktopTools = () => {
119125
loadFile,
120126
loadProjectId,
121127
backupProject,
122-
getRestoredProject
128+
getRestoredProject,
129+
runProject,
123130
}
124131
};
125132

@@ -132,5 +139,6 @@ export const {
132139
loadProjectId,
133140
backupProject,
134141
getRestoredProject,
142+
runProject,
135143
} = setupDesktopTools();
136144

src/utils/projectTools.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { RefObject } from "react";
33
import type { NodeSystem, Variable } from "@defs/Node";
44
import type { Suggestion } from "@defs/UI";
55

6-
import { loadProjectId } from "@utils/desktopTools";
6+
import { isDesktop, loadProjectId, runProject } from "@utils/desktopTools";
77
import { loadData, wipeData } from "@utils/persistentTools";
88
import { generateId } from "@utils/generatorTools";
99
import { downloadScript } from "@utils/compilerTools";
@@ -85,6 +85,13 @@ const setupProjectTools = () => {
8585
icon: "Rocket",
8686
action: () => downloadScript(nodeSystem, entries),
8787
},
88+
...(isDesktop() ? [
89+
{
90+
name: "Run Project",
91+
icon: "CirclePlay",
92+
action: () => runProject(),
93+
}
94+
] : []),
8895
];
8996
};
9097

0 commit comments

Comments
 (0)