Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

prefer throwing over typesafe errors

Brendan Allanf97c8607504a
diff --git a/apps/desktop/src-tauri/icons/dmg-background.png b/apps/desktop/src-tauri/icons/dmg-background.png
new file mode 100644
index 000000000..662fbecac
Binary files /dev/null and b/apps/desktop/src-tauri/icons/dmg-background.png differ
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 9dfc7af3d..a8ce7f0c7 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -380,7 +380,7 @@ async fn start_recording(app: AppHandle, state: MutableState<'_, App>) -> Result
Ok(recording) => state.set_current_recording(recording),
Err(error) => {
eprintln!("{error}");
- return Err("Failed to set up recording".into());
+ return Err(format!("Failed to set up recording: {error}"));
}
};
@@ -2470,6 +2470,7 @@ pub async fn run() {
AuthenticationInvalid,
audio_meter::AudioInputLevelChange
])
+ .error_handling(tauri_specta::ErrorHandlingMode::Throw)
.typ::<ProjectConfiguration>()
.typ::<AuthStore>()
.typ::<hotkeys::HotkeysStore>()
diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json
index 880268dec..5939f031e 100644
--- a/apps/desktop/src-tauri/tauri.conf.json
+++ b/apps/desktop/src-tauri/tauri.conf.json
@@ -6,7 +6,7 @@
"build": {
"beforeDevCommand": "node scripts/prepareSidecars.js && pnpm localdev",
"devUrl": "http://localhost:3001",
- "beforeBuildCommand": "node scripts/prepareSidecars.js && pnpm build",
+ "beforeBuildCommand": "node scripts/prepareSidecars.js && pnpm turbo build --filter @cap/desktop",
"frontendDist": "../.output/public"
},
"app": {
@@ -40,6 +40,11 @@
"icons/icon.icns",
"icons/icon.ico"
],
- "externalBin": ["../../../target/binaries/ffmpeg"]
+ "externalBin": ["../../../target/binaries/ffmpeg"],
+ "macOS": {
+ "dmg": {
+ "background": "./src-tauri/icons/dmg-background.png"
+ }
+ }
}
}
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index ed128d0c7..d1c83df82 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -84,6 +84,9 @@ export default function () {
await commands.stopRecording();
}
},
+ onError: (e) => {
+ alert("An error occurred, here are the details:\n" + e.toString());
+ },
}));
createAsync(() => getAuth());
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx b/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx
index 01794b9dd..46232eafc 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx
@@ -16,32 +16,28 @@ export default function Recordings() {
const fetchRecordings = createQuery(() => ({
queryKey: ["recordings"],
queryFn: async () => {
- try {
- const result = await commands.listRecordings();
- if (result.status === "ok") {
- const recordings = await Promise.all(
- result.data.map(async (file) => {
- const [id, path, meta] = file;
- const thumbnailPath = `${path}/screenshots/display.jpg`;
+ const result = await commands
+ .listRecordings()
+ .then(
+ () =>
+ Promise.resolve([]) as ReturnType<typeof commands.listRecordings>
+ );
- return {
- id,
- path,
- prettyName: meta.pretty_name,
- isNew: false,
- thumbnailPath,
- };
- })
- );
- return recordings;
- } else {
- console.error("Failed to list recordings:", result.error);
- return [];
- }
- } catch (error) {
- console.error("Error fetching recordings:", error);
- return [];
- }
+ const recordings = await Promise.all(
+ result.map(async (file) => {
+ const [id, path, meta] = file;
+ const thumbnailPath = `${path}/screenshots/display.jpg`;
+
+ return {
+ id,
+ path,
+ prettyName: meta.pretty_name,
+ isNew: false,
+ thumbnailPath,
+ };
+ })
+ );
+ return recordings;
},
}));
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx b/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx
index e21f104dd..92d42feaf 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx
@@ -16,25 +16,26 @@ export default function Screenshots() {
const fetchScreenshots = createQuery(() => ({
queryKey: ["screenshots"],
queryFn: async () => {
- const result = await commands.listScreenshots();
- if (result.status === "ok") {
- const screenshots = await Promise.all(
- result.data.map(async (file) => {
- const [id, pngPath, meta] = file;
-
- return {
- id,
- path: pngPath,
- prettyName: meta.pretty_name,
- isNew: false,
- thumbnailPath: pngPath,
- };
- })
+ const result = await commands
+ .listScreenshots()
+ .catch(
+ () =>
+ Promise.resolve([]) as ReturnType<typeof commands.listScreenshots>
);
- return screenshots;
- } else {
- return [];
- }
+ const screenshots = await Promise.all(
+ result.map(async (file) => {
+ const [id, pngPath, meta] = file;
+
+ return {
+ id,
+ path: pngPath,
+ prettyName: meta.pretty_name,
+ isNew: false,
+ thumbnailPath: pngPath,
+ };
+ })
+ );
+ return screenshots;
},
}));
diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
index 65f1f8ca0..c4e4cfbc2 100644
--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
@@ -68,7 +68,7 @@ export default function Page() {
const checkUpgradeStatus = async () => {
const result = await commands.checkUpgradedAndUpdate();
- if (result.status === "ok" && result.data === true) {
+ if (result) {
setUpgradeComplete(true);
}
};
diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsx
index 5fdf572ba..a253ee332 100644
--- a/apps/desktop/src/routes/editor/Header.tsx
+++ b/apps/desktop/src/routes/editor/Header.tsx
@@ -40,9 +40,7 @@ export function Header() {
)}
>
<div class="flex flex-row items-center gap-[0.5rem] text-[0.875rem]"></div>
- <div
- class="flex flex-row gap-2 font-medium items-center"
- >
+ <div class="flex flex-row gap-2 font-medium items-center">
<ShareButton />
<ExportButton />
</div>
@@ -170,14 +168,13 @@ function ShareButton() {
const uploadVideo = createMutation(() => ({
mutationFn: async () => {
- const res = await commands.uploadRenderedVideo(
+ await commands.uploadRenderedVideo(
videoId,
project
? project
: presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG,
null
);
- if (res.status !== "ok") throw new Error(res.error);
},
onSuccess: () => metaActions.refetch(),
}));
diff --git a/apps/desktop/src/routes/editor/editorInstanceContext.ts b/apps/desktop/src/routes/editor/editorInstanceContext.ts
index d423ed6cc..d0e39e7f6 100644
--- a/apps/desktop/src/routes/editor/editorInstanceContext.ts
+++ b/apps/desktop/src/routes/editor/editorInstanceContext.ts
@@ -18,10 +18,9 @@ export const [EditorInstanceContextProvider, useEditorInstanceContext] =
const [editorInstance] = createResource(async () => {
const instance = await commands.createEditorInstance(props.videoId);
- if (instance.status !== "ok") throw new Error("Failed to start editor");
const [ws, isConnected] = createImageDataWS(
- instance.data.framesSocketUrl,
+ instance.framesSocketUrl,
setLatestFrame
);
@@ -33,7 +32,7 @@ export const [EditorInstanceContextProvider, useEditorInstanceContext] =
}
});
- return instance.data;
+ return instance;
});
return {
diff --git a/apps/desktop/src/routes/prev-recordings.tsx b/apps/desktop/src/routes/prev-recordings.tsx
index 24a2ca354..631415f81 100644
--- a/apps/desktop/src/routes/prev-recordings.tsx
+++ b/apps/desktop/src/routes/prev-recordings.tsx
@@ -82,9 +82,12 @@ export default function () {
const allMedia = createMemo(() => [...recordings, ...screenshots]);
return (
- <div class="w-screen h-[100vh] bg-transparent relative" style={{
- "scrollbar-color": "auto transparent"
- }}>
+ <div
+ class="w-screen h-[100vh] bg-transparent relative"
+ style={{
+ "scrollbar-color": "auto transparent",
+ }}
+ >
<div class="w-full relative left-0 bottom-0 flex flex-col-reverse pl-[40px] pb-[80px] gap-4 h-full overflow-y-auto">
<div class="pt-12 w-full flex flex-col gap-4">
<TransitionGroup
@@ -99,7 +102,7 @@ export default function () {
const [ref, setRef] = createSignal<HTMLElement | null>(null);
const normalizedPath = media.path.replace(/\\/g, "/");
const mediaId = normalizedPath.split("/").pop()?.split(".")[0]!;
-
+
const type = media.type ?? "recording";
const fileId =
type === "recording"
@@ -123,16 +126,12 @@ export default function () {
const copyMedia = createMutation(() => ({
mutationFn: async () => {
if (isRecording) {
- const res = await commands.copyRenderedVideoToClipboard(
+ await commands.copyRenderedVideoToClipboard(
mediaId,
presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG
);
- if (res.status !== "ok") throw new Error(res.error);
} else {
- const res = await commands.copyScreenshotToClipboard(
- media.path
- );
- if (res.status !== "ok") throw new Error(res.error);
+ await commands.copyScreenshotToClipboard(media.path);
}
},
}));
@@ -156,49 +155,28 @@ export default function () {
? suggestedName
: `${suggestedName}${extension}`;
- const savePathResult = await commands.saveFileDialog(
+ const savePath = await commands.saveFileDialog(
fullFileName,
fileType
);
- if (
- savePathResult.status !== "ok" ||
- !savePathResult.data
- ) {
+ if (!savePath) {
return false;
}
- const savePath = savePathResult.data;
-
if (isRecording) {
const renderedPath = await commands.getRenderedVideo(
mediaId,
presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG
);
- if (renderedPath.status !== "ok" || !renderedPath.data) {
+ if (!renderedPath) {
throw new Error("Failed to get rendered video path");
}
- const copyResult = await commands.copyFileToPath(
- renderedPath.data,
- savePath
- );
- if (copyResult.status !== "ok") {
- throw new Error(
- `Failed to copy file: ${copyResult.error}`
- );
- }
+ await commands.copyFileToPath(renderedPath, savePath);
} else {
- const copyResult = await commands.copyFileToPath(
- media.path,
- savePath
- );
- if (copyResult.status !== "ok") {
- throw new Error(
- `Failed to copy file: ${copyResult.error}`
- );
- }
+ await commands.copyFileToPath(media.path, savePath);
}
return true;
@@ -206,7 +184,7 @@ export default function () {
}));
const uploadMedia = createMutation(() => ({
mutationFn: async () => {
- let res: Result<UploadResult, string>;
+ let res: UploadResult;
if (isRecording) {
res = await commands.uploadRenderedVideo(
mediaId,
@@ -217,11 +195,7 @@ export default function () {
res = await commands.uploadScreenshot(media.path);
}
- if (res.status === "error") {
- throw new Error(res.error);
- }
-
- switch (res.data) {
+ switch (res) {
case "NotAuthenticated":
throw new Error("Not authenticated");
case "PlanCheckFailed":
@@ -239,17 +213,14 @@ export default function () {
const [metadata] = createResource(async () => {
if (isRecording) {
- const result = await commands.getVideoMetadata(
- media.path,
- null
- );
-
- if (result.status !== "ok") {
- console.error(`Failed to get metadata: ${result.status}`);
- return;
- }
-
- const [duration, size] = result.data;
+ const result = await commands
+ .getVideoMetadata(media.path, null)
+ .catch((e) => {
+ console.error(`Failed to get metadata: ${e}`);
+ });
+ if (!result) return;
+
+ const [duration, size] = result;
console.log(
`Metadata for ${media.path}: duration=${duration}, size=${size}`
);
diff --git a/apps/desktop/src/utils/queries.ts b/apps/desktop/src/utils/queries.ts
index 9d8b0f60c..ce4ae1e38 100644
--- a/apps/desktop/src/utils/queries.ts
+++ b/apps/desktop/src/utils/queries.ts
@@ -22,18 +22,12 @@ export const listScreens = queryOptions({
const getOptions = queryOptions({
queryKey: ["recordingOptions"] as const,
- queryFn: async () => {
- const o = await commands.getRecordingOptions();
- if (o.status === "ok") return o.data;
- },
+ queryFn: () => commands.getRecordingOptions(),
});
const getCurrentRecording = queryOptions({
queryKey: ["currentRecording"] as const,
- queryFn: async () => {
- const o = await commands.getCurrentRecording();
- if (o.status === "ok") return o.data[0];
- },
+ queryFn: () => commands.getCurrentRecording().then((d) => d[0]),
});
const listVideoDevices = queryOptions({
@@ -57,9 +51,8 @@ export function createVideoDevicesQuery() {
export const listAudioDevices = queryOptions({
queryKey: ["audioDevices"] as const,
queryFn: async () => {
- const r = await commands.listAudioDevices();
- if (r.status === "ok")
- return r.data.map((name) => ({ name, deviceId: name }));
+ const devices = await commands.listAudioDevices();
+ return devices.map((name) => ({ name, deviceId: name }));
},
reconcile: "name",
refetchInterval: 1000,
@@ -99,9 +92,7 @@ export function createOptionsQuery() {
const options = createQuery(() => ({
...getOptions,
select: (data) => {
- if (data && state) {
- return { ...data, ...state };
- }
+ return { ...data, ...state };
},
}));
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 79d85bd97..577a59c21 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -5,61 +5,26 @@
export const commands = {
-async getRecordingOptions() : Promise<Result<RecordingOptions, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_recording_options") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async getRecordingOptions() : Promise<RecordingOptions> {
+ return await TAURI_INVOKE("get_recording_options");
},
-async setRecordingOptions(options: RecordingOptions) : Promise<Result<null, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("set_recording_options", { options }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async setRecordingOptions(options: RecordingOptions) : Promise<null> {
+ return await TAURI_INVOKE("set_recording_options", { options });
},
-async startRecording() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("start_recording") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async startRecording() : Promise<null> {
+ return await TAURI_INVOKE("start_recording");
},
-async stopRecording() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("stop_recording") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async stopRecording() : Promise<null> {
+ return await TAURI_INVOKE("stop_recording");
},
-async pauseRecording() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("pause_recording") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async pauseRecording() : Promise<null> {
+ return await TAURI_INVOKE("pause_recording");
},
-async resumeRecording() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("resume_recording") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async resumeRecording() : Promise<null> {
+ return await TAURI_INVOKE("resume_recording");
},
-async takeScreenshot() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("take_screenshot") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async takeScreenshot() : Promise<null> {
+ return await TAURI_INVOKE("take_screenshot");
},
async listCameras() : Promise<string[]> {
return await TAURI_INVOKE("list_cameras");
@@ -70,13 +35,8 @@ async listCaptureWindows() : Promise<CaptureWindow[]> {
async listCaptureScreens() : Promise<CaptureScreen[]> {
return await TAURI_INVOKE("list_capture_screens");
},
-async listAudioDevices() : Promise<Result<string[], null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("list_audio_devices") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async listAudioDevices() : Promise<string[]> {
+ return await TAURI_INVOKE("list_audio_devices");
},
async showPreviousRecordingsWindow() : Promise<void> {
await TAURI_INVOKE("show_previous_recordings_window");
@@ -84,91 +44,41 @@ async showPreviousRecordingsWindow() : Promise<void> {
async closePreviousRecordingsWindow() : Promise<void> {
await TAURI_INVOKE("close_previous_recordings_window");
},
-async setFakeWindowBounds(name: string, bounds: Bounds) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("set_fake_window_bounds", { name, bounds }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async setFakeWindowBounds(name: string, bounds: Bounds) : Promise<null> {
+ return await TAURI_INVOKE("set_fake_window_bounds", { name, bounds });
},
-async removeFakeWindow(name: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("remove_fake_window", { name }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async removeFakeWindow(name: string) : Promise<null> {
+ return await TAURI_INVOKE("remove_fake_window", { name });
},
async focusCapturesPanel() : Promise<void> {
await TAURI_INVOKE("focus_captures_panel");
},
-async getCurrentRecording() : Promise<Result<JsonValue<InProgressRecording | null>, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_current_recording") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async getCurrentRecording() : Promise<JsonValue<InProgressRecording | null>> {
+ return await TAURI_INVOKE("get_current_recording");
},
async renderToFile(outputPath: string, videoId: string, project: ProjectConfiguration, progressChannel: TAURI_CHANNEL<RenderProgress>) : Promise<void> {
await TAURI_INVOKE("render_to_file", { outputPath, videoId, project, progressChannel });
},
-async getRenderedVideo(videoId: string, project: ProjectConfiguration) : Promise<Result<string, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_rendered_video", { videoId, project }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async getRenderedVideo(videoId: string, project: ProjectConfiguration) : Promise<string> {
+ return await TAURI_INVOKE("get_rendered_video", { videoId, project });
},
-async copyFileToPath(src: string, dst: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("copy_file_to_path", { src, dst }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async copyFileToPath(src: string, dst: string) : Promise<null> {
+ return await TAURI_INVOKE("copy_file_to_path", { src, dst });
},
-async copyRenderedVideoToClipboard(videoId: string, project: ProjectConfiguration) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("copy_rendered_video_to_clipboard", { videoId, project }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async copyRenderedVideoToClipboard(videoId: string, project: ProjectConfiguration) : Promise<null> {
+ return await TAURI_INVOKE("copy_rendered_video_to_clipboard", { videoId, project });
},
-async copyScreenshotToClipboard(path: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("copy_screenshot_to_clipboard", { path }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async copyScreenshotToClipboard(path: string) : Promise<null> {
+ return await TAURI_INVOKE("copy_screenshot_to_clipboard", { path });
},
-async openFilePath(path: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("open_file_path", { path }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async openFilePath(path: string) : Promise<null> {
+ return await TAURI_INVOKE("open_file_path", { path });
},
-async getVideoMetadata(videoId: string, videoType: VideoType | null) : Promise<Result<[number, number], string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_video_metadata", { videoId, videoType }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async getVideoMetadata(videoId: string, videoType: VideoType | null) : Promise<[number, number]> {
+ return await TAURI_INVOKE("get_video_metadata", { videoId, videoType });
},
-async createEditorInstance(videoId: string) : Promise<Result<SerializedEditorInstance, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("create_editor_instance", { videoId }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async createEditorInstance(videoId: string) : Promise<SerializedEditorInstance> {
+ return await TAURI_INVOKE("create_editor_instance", { videoId });
},
async startPlayback(videoId: string) : Promise<void> {
await TAURI_INVOKE("start_playback", { videoId });
@@ -200,21 +110,11 @@ async doPermissionsCheck(initialCheck: boolean) : Promise<OSPermissionsCheck> {
async requestPermission(permission: OSPermission) : Promise<void> {
await TAURI_INVOKE("request_permission", { permission });
},
-async uploadRenderedVideo(videoId: string, project: ProjectConfiguration, preCreatedVideo: PreCreatedVideo | null) : Promise<Result<UploadResult, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("upload_rendered_video", { videoId, project, preCreatedVideo }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async uploadRenderedVideo(videoId: string, project: ProjectConfiguration, preCreatedVideo: PreCreatedVideo | null) : Promise<UploadResult> {
+ return await TAURI_INVOKE("upload_rendered_video", { videoId, project, preCreatedVideo });
},
-async uploadScreenshot(screenshotPath: string) : Promise<Result<UploadResult, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("upload_screenshot", { screenshotPath }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async uploadScreenshot(screenshotPath: string) : Promise<UploadResult> {
+ return await TAURI_INVOKE("upload_screenshot", { screenshotPath });
},
async getRecordingMeta(id: string, fileType: string) : Promise<RecordingMeta> {
return await TAURI_INVOKE("get_recording_meta", { id, fileType });
@@ -225,77 +125,32 @@ async openUpgradeWindow() : Promise<void> {
async openSettingsWindow(page: string) : Promise<void> {
await TAURI_INVOKE("open_settings_window", { page });
},
-async saveFileDialog(fileName: string, fileType: string) : Promise<Result<string | null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("save_file_dialog", { fileName, fileType }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async saveFileDialog(fileName: string, fileType: string) : Promise<string | null> {
+ return await TAURI_INVOKE("save_file_dialog", { fileName, fileType });
},
-async listRecordings() : Promise<Result<([string, string, RecordingMeta])[], string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("list_recordings") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async listRecordings() : Promise<([string, string, RecordingMeta])[]> {
+ return await TAURI_INVOKE("list_recordings");
},
-async listScreenshots() : Promise<Result<([string, string, RecordingMeta])[], string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("list_screenshots") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async listScreenshots() : Promise<([string, string, RecordingMeta])[]> {
+ return await TAURI_INVOKE("list_screenshots");
},
-async checkUpgradedAndUpdate() : Promise<Result<boolean, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("check_upgraded_and_update") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async checkUpgradedAndUpdate() : Promise<boolean> {
+ return await TAURI_INVOKE("check_upgraded_and_update");
},
-async openExternalLink(url: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("open_external_link", { url }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async openExternalLink(url: string) : Promise<null> {
+ return await TAURI_INVOKE("open_external_link", { url });
},
-async setHotkey(action: HotkeyAction, hotkey: Hotkey | null) : Promise<Result<null, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("set_hotkey", { action, hotkey }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async setHotkey(action: HotkeyAction, hotkey: Hotkey | null) : Promise<null> {
+ return await TAURI_INVOKE("set_hotkey", { action, hotkey });
},
-async deleteAuthOpenSignin() : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("delete_auth_open_signin") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async deleteAuthOpenSignin() : Promise<null> {
+ return await TAURI_INVOKE("delete_auth_open_signin");
},
-async resetCameraPermissions() : Promise<Result<null, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("reset_camera_permissions") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async resetCameraPermissions() : Promise<null> {
+ return await TAURI_INVOKE("reset_camera_permissions");
},
-async resetMicrophonePermissions() : Promise<Result<null, null>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("reset_microphone_permissions") };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async resetMicrophonePermissions() : Promise<null> {
+ return await TAURI_INVOKE("reset_microphone_permissions");
},
async isCameraWindowOpen() : Promise<boolean> {
return await TAURI_INVOKE("is_camera_window_open");
@@ -303,13 +158,8 @@ async isCameraWindowOpen() : Promise<boolean> {
async seekTo(videoId: string, frameNumber: number) : Promise<void> {
await TAURI_INVOKE("seek_to", { videoId, frameNumber });
},
-async sendFeedbackRequest(feedback: string) : Promise<Result<null, string>> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("send_feedback_request", { feedback }) };
-} catch (e) {
- if(e instanceof Error) throw e;
- else return { status: "error", error: e as any };
-}
+async sendFeedbackRequest(feedback: string) : Promise<null> {
+ return await TAURI_INVOKE("send_feedback_request", { feedback });
},
async positionTrafficLights(controlsInset: [number, number] | null) : Promise<void> {
await TAURI_INVOKE("position_traffic_lights", { controlsInset });