Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
App progress for exporting video, cleanups
Ilya962e004f949f
diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.jsonindex 8a0d0ad84..fc8192f1b 100644--- a/apps/desktop/src-tauri/capabilities/default.json+++ b/apps/desktop/src-tauri/capabilities/default.json@@ -19,6 +19,7 @@"core:window:allow-start-dragging","core:window:allow-set-position","core:window:allow-set-theme",+ "core:window:allow-set-progress-bar","core:webview:default","core:webview:allow-create-webview-window","core:app:allow-version",diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsxindex e438fbd4b..ce99edb13 100644--- a/apps/desktop/src/App.tsx+++ b/apps/desktop/src/App.tsx@@ -1,25 +1,22 @@import { Router, useCurrentMatches } from "@solidjs/router";import { FileRoutes } from "@solidjs/start/router";import {- createEffect,createResource,- createSignal,ErrorBoundary,onCleanup,onMount,Suspense,} from "solid-js";import { QueryClient, QueryClientProvider } from "@tanstack/solid-query";-import { getCurrentWindow } from "@tauri-apps/api/window";import { message } from "@tauri-apps/plugin-dialog";import "@cap/ui-solid/main.css";import "unfonts.css";import "./styles/theme.css";import { generalSettingsStore } from "./store";-import { commands, type AppTheme } from "./utils/tauri";+import type { AppTheme } from "./utils/tauri";import type { UnlistenFn } from "@tauri-apps/api/event";-import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";+import { getCurrentWebviewWindow, WebviewWindow } from "@tauri-apps/api/webviewWindow";const queryClient = new QueryClient({defaultOptions: {@@ -40,7 +37,8 @@ export default function App() {}function Inner() {- createThemeListener();+ const currentWindow = getCurrentWebviewWindow();+ createThemeListener(currentWindow);return (<ErrorBoundary@@ -64,7 +62,7 @@ function Inner() {if (match.route.info?.AUTO_SHOW_WINDOW === false) return;}- getCurrentWindow().show();+ currentWindow.show();});return <Suspense>{props.children}</Suspense>;@@ -77,8 +75,7 @@ function Inner() {);}-function createThemeListener() {- const currentWindow = getCurrentWebviewWindow();+function createThemeListener(currentWindow: WebviewWindow) {const [theme, themeActions] = createResource<AppTheme | null>(() =>generalSettingsStore.get().then((s) => {const t = s?.theme ?? null;@@ -98,7 +95,6 @@ function createThemeListener() {onCleanup(() => unlisten?.());function update(appTheme: AppTheme | null | undefined) {- console.log(`apptheme: ${appTheme}`);if (appTheme === undefined) return;if (location.pathname === "/camera" ||diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsxindex 97962fcdc..098b07fef 100644--- a/apps/desktop/src/routes/editor/Header.tsx+++ b/apps/desktop/src/routes/editor/Header.tsx@@ -4,6 +4,7 @@ import {Match,Show,Switch,+ createEffect,createResource,onCleanup,onMount,@@ -21,17 +22,41 @@ import {progressState,setProgressState,} from "~/store/progress";+import { events } from "~/utils/tauri";+import Titlebar from "~/components/titlebar/Titlebar";+import { initializeTitlebar, setTitlebar } from "~/utils/titlebar-state";+import type { UnlistenFn } from "@tauri-apps/api/event";+import { getCurrentWindow, ProgressBarStatus } from "@tauri-apps/api/window";export function Header() {- let unlistenTitlebar: UnlistenFn | undefined;+ const currentWindow = getCurrentWindow();+ let unlistenTitlebar: UnlistenFn | undefined;onMount(async () => {unlistenTitlebar = await initializeTitlebar();});-- onCleanup(() => {- unlistenTitlebar?.();+ onCleanup(() => unlistenTitlebar?.());++ createEffect(() => {+ const state = progressState;+ if (state === undefined || state.type === "idle") {+ currentWindow.setProgressBar({ status: ProgressBarStatus.None });+ return;+ }++ let percentage: number | undefined;+ if (state.type === "saving") {+ percentage = state.stage === "rendering" ? Math.min(+ ((state.renderProgress || 0) /+ (state.totalFrames || 1)) *+ 100,+ 100+ ) : Math.min(state.progress || 0, 100);+ }+++ if (percentage) currentWindow.setProgressBar({ progress: percentage });});setTitlebar("border", false);@@ -56,14 +81,14 @@ export function Header() {return (<><Titlebar />- <Dialog.Root open={progressState.type !== "idle"} onOpenChange={() => {}}>+ <Dialog.Root open={progressState.type !== "idle"} onOpenChange={() => { }}><DialogContenttitle={progressState.type === "copying"? "Link Copied": progressState.type === "uploading"- ? "Creating Shareable Link"- : "Exporting Recording"+ ? "Creating Shareable Link"+ : "Exporting Recording"}confirm={<></>}class="bg-gray-600 text-gray-500 dark:text-gray-500"@@ -88,24 +113,23 @@ export function Header() {<divclass="bg-blue-300 h-2.5 rounded-full transition-all duration-200"style={{- width: `${- state.stage === "rendering"+ width: `${state.stage === "rendering"? Math.min(- ((state.renderProgress || 0) /- (state.totalFrames || 1)) *- 100,- 100- )+ ((state.renderProgress || 0) /+ (state.totalFrames || 1)) *+ 100,+ 100+ ): Math.min(state.progress || 0, 100)- }%`,+ }%`,}}/></div><p class="text-xs mt-3 relative z-10">{state.stage === "rendering" &&- state.renderProgress &&- state.totalFrames+ state.renderProgress &&+ state.totalFrames? `${state.message} (${state.renderProgress}/${state.totalFrames} frames)`: state.message}</p>@@ -131,24 +155,23 @@ export function Header() {<divclass="bg-blue-300 h-2.5 rounded-full transition-all duration-200"style={{- width: `${- state.stage === "rendering"+ width: `${state.stage === "rendering"? Math.min(- ((state.renderProgress || 0) /- (state.totalFrames || 1)) *- 100,- 100- )+ ((state.renderProgress || 0) /+ (state.totalFrames || 1)) *+ 100,+ 100+ ): Math.min(state.progress || 0, 100)- }%`,+ }%`,}}/></div><p class="text-xs mt-3 relative z-10">{state.stage === "rendering" &&- state.renderProgress &&- state.totalFrames+ state.renderProgress &&+ state.totalFrames? `${state.message} (${state.renderProgress}/${state.totalFrames} frames)`: state.message}</p>@@ -174,14 +197,13 @@ export function Header() {<divclass="bg-blue-300 h-2.5 rounded-full transition-all duration-200"style={{- width: `${- state.stage === "rendering"+ width: `${state.stage === "rendering"? Math.min(state.renderProgress || 0, 100): Math.min(- (state.uploadProgress || 0) * 100,- 100- )- }%`,+ (state.uploadProgress || 0) * 100,+ 100+ )+ }%`,}}/></div>@@ -189,8 +211,8 @@ export function Header() {<p class="text-xs text-white mt-3 relative z-10">{state.stage === "rendering"? `Rendering - ${Math.round(- state.renderProgress || 0- )}%`+ state.renderProgress || 0+ )}%`: state.message}</p></div>@@ -209,9 +231,6 @@ import { Channel } from "@tauri-apps/api/core";import { save } from "@tauri-apps/plugin-dialog";import { DEFAULT_PROJECT_CONFIG } from "./projectConfig";import { createMutation } from "@tanstack/solid-query";-import Titlebar from "~/components/titlebar/Titlebar";-import { initializeTitlebar, setTitlebar } from "~/utils/titlebar-state";-import { UnlistenFn } from "@tauri-apps/api/event";function ExportButton() {const { videoId, project, prettyName } = useEditorContext();@@ -387,8 +406,8 @@ function ShareButton() {const result = recordingMeta()?.sharing? await commands.uploadExportedVideo(videoId, "Reupload"): await commands.uploadExportedVideo(videoId, {- Initial: { pre_created_video: null },- });+ Initial: { pre_created_video: null },+ });console.log("Upload result:", result);