Skip to content

Commit 9cc7df5

Browse files
committed
Start on operationview
1 parent 3cab229 commit 9cc7df5

File tree

11 files changed

+114
-589
lines changed

11 files changed

+114
-589
lines changed

src-tauri/Cargo.lock

Lines changed: 8 additions & 390 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tauri-plugin-fs = { version = "2", features= ["watch"] }
1919
tauri-plugin-dialog = "2"
2020
tauri-plugin-store = "2"
2121
tauri-plugin-opener = "2"
22-
idevice = { version = "0.1.35", features = ["full"] }
22+
idevice = { version = "0.1.35", features = ["usbmuxd", "afc", "installation_proxy"] }
2323
futures = "0.3.31"
2424
keyring = "2"
2525
icloud_auth = {path = "./apple-private-apis/icloud-auth" }

src-tauri/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use sideloader::apple_commands::{
2121
use tauri::Emitter;
2222
use templates::create_template;
2323

24-
use sdk::install_sdk;
24+
use sdk::install_sdk_operation;
2525
use swift::{
2626
build_swift, clean_swift, deploy_swift, get_swiftly_toolchains, get_toolchain_info,
2727
has_darwin_sdk, validate_toolchain,
@@ -53,7 +53,7 @@ fn main() {
5353
get_swiftly_toolchains,
5454
validate_toolchain,
5555
get_toolchain_info,
56-
install_sdk,
56+
install_sdk_operation,
5757
has_darwin_sdk,
5858
])
5959
.run(tauri::generate_context!())

src-tauri/src/packer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src-tauri/src/sdk.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::swift::{swift_bin, validate_toolchain};
1313
const DARWIN_TOOLS_VERSION: &str = "1.0.1";
1414

1515
#[tauri::command]
16-
pub async fn install_sdk(
16+
pub async fn install_sdk_operation(
1717
app: AppHandle,
1818
xcode_path: String,
1919
toolchain_path: String,
@@ -30,7 +30,7 @@ pub async fn install_sdk(
3030
"{main_err} (additionally, failed to clean up temp dir: {cleanup_err})"
3131
)),
3232
(Err(main_err), _) => Err(main_err),
33-
(Ok(val), Err(cleanup_err)) => Err(format!(
33+
(Ok(_), Err(cleanup_err)) => Err(format!(
3434
"Install succeeded, but failed to clean up temp dir: {cleanup_err}"
3535
)),
3636
(Ok(val), Ok(_)) => Ok(val),
@@ -229,7 +229,6 @@ async fn install_toolset(output_path: &PathBuf) -> Result<(), String> {
229229
archive
230230
.unpack(&toolset_dir)
231231
.map_err(|e| format!("Failed to extract toolset: {}", e))?;
232-
let toolset_bin = toolset_dir.join("bin");
233232
Ok(())
234233
}
235234

src/components/OperationView.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {
2+
Button,
3+
Input,
4+
Modal,
5+
ModalClose,
6+
ModalDialog,
7+
Typography,
8+
} from "@mui/joy";
9+
import { listen } from "@tauri-apps/api/event";
10+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
11+
import { invoke } from "@tauri-apps/api/core";
12+
import { Operation } from "../utilities/operations";
13+
14+
interface OperationViewProps {
15+
operation_info: { operation: Operation; params: { [key: string]: any } };
16+
}
17+
18+
export default ({ operation_info }: OperationViewProps) => {
19+
const operation = operation_info.operation;
20+
const params = operation_info.params;
21+
const id = useMemo<string>(() => operation.id + "_operation", [operation]);
22+
const [open, setOpen] = useState(true);
23+
24+
const listenerAdded = useRef(false);
25+
const unlisten = useRef<() => void>(() => {});
26+
27+
useEffect(() => {
28+
if (!listenerAdded.current) {
29+
(async () => {
30+
const unlistenFn = await listen(id, (event) => {});
31+
unlisten.current = unlistenFn;
32+
})();
33+
listenerAdded.current = true;
34+
}
35+
return () => {
36+
unlisten.current();
37+
};
38+
}, []);
39+
40+
const startOperation = useCallback(async () => {
41+
invoke(id);
42+
}, []);
43+
44+
return (
45+
<Modal
46+
open={open}
47+
onClose={() => {
48+
setOpen(false);
49+
}}
50+
>
51+
<ModalDialog>
52+
<ModalClose />
53+
<Typography level="h3">Can I put my balls in your jaws?</Typography>
54+
</ModalDialog>
55+
</Modal>
56+
);
57+
};

src/components/RunCommand.css

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/components/RunCommand.tsx

Lines changed: 0 additions & 181 deletions
This file was deleted.

src/components/SDKMenu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useToast } from "react-toast-plus";
55
import { invoke } from "@tauri-apps/api/core";
66
import { useCallback, useEffect } from "react";
77
import { openUrl } from "@tauri-apps/plugin-opener";
8+
import OperationView from "./OperationView";
9+
import { installSdkOperation } from "../utilities/operations";
810

911
export default () => {
1012
const { selectedToolchain, hasDarwinSDK, checkSDK } = useIDE();

src/utilities/IDEContext.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from "@mui/joy";
2424
import { useCommandRunner } from "./Command";
2525
import { useStore } from "./StoreContext";
26+
import { Operation } from "./operations";
2627

2728
export interface IDEContextType {
2829
initialized: boolean;
@@ -38,6 +39,10 @@ export interface IDEContextType {
3839
scanToolchains: () => Promise<void>;
3940
checkSDK: () => Promise<void>;
4041
locateToolchain: () => Promise<void>;
42+
startOperation: <T>(
43+
operation: Operation,
44+
params: { [key: string]: any }
45+
) => Promise<T>;
4146
setSelectedToolchain: (
4247
value: Toolchain | ((oldValue: Toolchain | null) => Toolchain | null) | null
4348
) => void;
@@ -155,7 +160,9 @@ export const IDEProvider: React.FC<{
155160
})
156161
);
157162
initPromises.push(
158-
invoke("has_darwin_sdk").then((response) => {
163+
invoke("has_darwin_sdk", {
164+
toolchainPath: selectedToolchain?.path ?? "",
165+
}).then((response) => {
159166
setHasDarwinSDK(response as boolean);
160167
})
161168
);
@@ -165,10 +172,8 @@ export const IDEProvider: React.FC<{
165172
setInitialized(true);
166173
})
167174
.catch((error) => {
168-
console.error("Error initializing IDE context:", error);
169-
alert(
170-
"An error occurred while initializing the IDE context. Please check the console for details."
171-
);
175+
console.error("Error initializing IDE context: ", error);
176+
alert("An error occurred while initializing the IDE context: " + error);
172177
});
173178
}, []);
174179

@@ -267,6 +272,8 @@ export const IDEProvider: React.FC<{
267272

268273
const { cancelCommand } = useCommandRunner();
269274

275+
const startOperation = useCallback;
276+
270277
const contextValue = useMemo(
271278
() => ({
272279
isWindows,

0 commit comments

Comments
 (0)