Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
multiple adjustments and tweaks
ameer2468b9f211c9f496
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsxindex ac1282fdb..7771ee454 100644--- a/apps/desktop/src/routes/editor/Editor.tsx+++ b/apps/desktop/src/routes/editor/Editor.tsx@@ -19,7 +19,6 @@ import { createStore } from "solid-js/store";import { Tooltip } from "@kobalte/core";import { makePersisted } from "@solid-primitives/storage";-import { cx } from "cva";import Cropper, { cropToFloor } from "~/components/Cropper";import { events, type Crop } from "~/utils/tauri";import { ConfigSidebar } from "./ConfigSidebar";@@ -122,7 +121,7 @@ function Inner() {<><Header /><div- class="flex overflow-y-hidden flex-col flex-1 pb-2 gap-2 w-full leading-5 animate-in fade-in"+ class="flex overflow-y-hidden flex-col flex-1 gap-2 pb-2 w-full leading-5 animate-in fade-in"data-tauri-drag-region><div class="flex overflow-hidden flex-col flex-1">diff --git a/apps/desktop/src/routes/editor/ExportDialog.tsx b/apps/desktop/src/routes/editor/ExportDialog.tsxindex b23fa2c02..e2ae7dc08 100644--- a/apps/desktop/src/routes/editor/ExportDialog.tsx+++ b/apps/desktop/src/routes/editor/ExportDialog.tsx@@ -13,12 +13,12 @@ import { createMutation } from "@tanstack/solid-query";import { Channel } from "@tauri-apps/api/core";import { save } from "@tauri-apps/plugin-dialog";import { cx } from "cva";-import { createStore, produce } from "solid-js/store";+import { produce } from "solid-js/store";import Tooltip from "~/components/Tooltip";import { authStore } from "~/store";import { trackEvent } from "~/utils/analytics";import { commands, events, RenderProgress } from "~/utils/tauri";-import { metaUpdateStore, useEditorContext } from "./context";+import { useEditorContext } from "./context";import { RESOLUTION_OPTIONS, ResolutionOption } from "./Header";import {DialogContent,@@ -27,7 +27,6 @@ import {PopperContent,topLeftAnimateClasses,} from "./ui";-import { createProgressBar } from "./utils";export const COMPRESSION_OPTIONS = [{ label: "Studio", value: "studio" },@@ -66,21 +65,21 @@ export const FORMAT_OPTIONS = [type ExportToOption = (typeof EXPORT_TO_OPTIONS)[number]["value"];-type ExportState =- | { type: "idle" }- | { type: "starting" }- | { type: "rendering"; renderedFrames: number; totalFrames: number }- | { type: "saving"; done: boolean };--type CopyState =- | { type: "idle" }- | { type: "starting" }- | { type: "rendering"; renderedFrames: number; totalFrames: number }- | { type: "copying" }- | { type: "copied" };-const ExportDialog = () => {- const { videoId, prettyName, setDialog } = useEditorContext();+ const {+ videoId,+ prettyName,+ setDialog,+ exportState,+ setExportState,+ exportProgress,+ setExportProgress,+ copyState,+ setCopyState,+ uploadState,+ setUploadState,+ metaUpdateStore,+ } = useEditorContext();const [format, setFormat] = createSignal(localStorage.getItem("cap-export-format") || "mp4");@@ -127,29 +126,11 @@ const ExportDialog = () => {commands.getExportEstimates(params.videoId, params.resolution, params.fps));const exportButtonIcon: Record<"file" | "clipboard" | "link", JSX.Element> = {- file: <IconCapFile class="text-gray-500 size-4" />,- clipboard: <IconCapCopy class="text-gray-500 size-4" />,- link: <IconCapLink class="text-gray-500 size-4" />,+ file: <IconCapFile class="text-solid-white size-4" />,+ clipboard: <IconCapCopy class="text-solid-white size-4" />,+ link: <IconCapLink class="text-solid-white size-4" />,};- // States-- const [exportState, setExportState] = createStore<ExportState>({- type: "idle",- });-- const [copyState, setCopyState] = createStore<CopyState>({- type: "idle",- });-- const [uploadState, setUploadState] = createStore<- | { type: "idle" }- | { type: "starting" }- | { type: "rendering"; renderedFrames: number; totalFrames: number }- | { type: "uploading"; progress: number }- | { type: "link-copied" }- >({ type: "idle" });-const copy = createMutation(() => ({mutationFn: async () => {setCopyState({@@ -160,17 +141,26 @@ const ExportDialog = () => {const progress = new Channel<RenderProgress>();progress.onmessage = (msg) => {- if (msg.type === "EstimatedTotalFrames")+ if (msg.type === "EstimatedTotalFrames") {setCopyState({type: "rendering",+ });+ setExportProgress({renderedFrames: 0,totalFrames: msg.total_frames,});- else+ } elsesetCopyState(produce((state) => {- if (msg.type === "FrameRendered" && state.type === "rendering")- state.renderedFrames = msg.current_frame;+ if (+ msg.type === "FrameRendered" &&+ state.type === "rendering"+ ) {+ setExportProgress({+ renderedFrames: msg.current_frame,+ totalFrames: exportProgress()?.totalFrames ?? 0,+ });+ }}));};@@ -187,13 +177,6 @@ const ExportDialog = () => {});- // Show quick progress animation for existing video- setCopyState(- produce((s) => {- if (s.type === "rendering") s.renderedFrames = s.totalFrames;- })- );-await commands.copyVideoToClipboard(outputPath);} catch (error) {console.error("Error in copy media:", error);@@ -205,8 +188,14 @@ const ExportDialog = () => {type: "copied",});setTimeout(() => {+ setExportProgress(null);setDialog((d) => ({ ...d, open: false }));}, 1000);+ setTimeout(() => {+ setCopyState({+ type: "idle",+ });+ }, 1500);},}));@@ -235,19 +224,26 @@ const ExportDialog = () => {const progress = new Channel<RenderProgress>();progress.onmessage = (msg) => {- if (msg.type === "EstimatedTotalFrames")+ if (msg.type === "EstimatedTotalFrames") {setExportState({type: "rendering",+ });+ setExportProgress({renderedFrames: 0,totalFrames: msg.total_frames,});- else+ } else if (msg.type === "FrameRendered") {setExportState(produce((state) => {- if (msg.type === "FrameRendered" && state.type === "rendering")- state.renderedFrames = msg.current_frame;+ if (state.type === "rendering") {+ setExportProgress({+ renderedFrames: msg.current_frame,+ totalFrames: exportProgress()?.totalFrames ?? 0,+ });+ }}));+ }};try {@@ -266,10 +262,7 @@ const ExportDialog = () => {await commands.copyFileToPath(videoPath, path);- setExportState({ type: "saving", done: false });- setTimeout(() => {- setDialog((d) => ({ ...d, open: false }));- }, 1000);+ setExportState({ type: "saving", done: true });} catch (error) {throw error;}@@ -277,7 +270,12 @@ const ExportDialog = () => {onSettled() {setTimeout(() => {exportWithSettings.reset();+ setDialog((d) => ({ ...d, open: false }));+ setExportProgress(null);}, 1000);+ setTimeout(() => {+ setExportState({ type: "idle" });+ }, 1500);},}));@@ -343,17 +341,26 @@ const ExportDialog = () => {const progress = new Channel<RenderProgress>();progress.onmessage = (msg) => {- if (msg.type === "EstimatedTotalFrames")+ if (msg.type === "EstimatedTotalFrames") {setUploadState({type: "rendering",+ });+ setExportProgress({renderedFrames: 0,totalFrames: msg.total_frames,});- else+ } elsesetUploadState(produce((state) => {- if (msg.type === "FrameRendered" && state.type === "rendering")- state.renderedFrames = msg.current_frame;+ if (+ msg.type === "FrameRendered" &&+ state.type === "rendering"+ ) {+ setExportProgress({+ renderedFrames: msg.current_frame,+ totalFrames: exportProgress()?.totalFrames ?? 0,+ });+ }}));};@@ -406,26 +413,11 @@ const ExportDialog = () => {setTimeout(() => {uploadVideo.reset();}, 2000);+ setUploadState({ type: "idle" });+ setExportProgress(null);},}));- createProgressBar(() => {- if (exportWithSettings.isIdle || exportState.type === "idle") return;- if (exportState.type === "starting") return 0;- if (exportState.type === "rendering")- return (exportState.renderedFrames / exportState.totalFrames) * 100;- return 100;- });-- createProgressBar(() => {- if (uploadVideo.isIdle || uploadState.type === "idle") return;- if (uploadState.type === "starting") return 0;- if (uploadState.type === "rendering")- return (uploadState.renderedFrames / uploadState.totalFrames) * 100;- if (uploadState.type === "uploading") return uploadState.progress;- return 100;- });-return (<><Show@@ -757,7 +749,7 @@ const ExportDialog = () => {</Show>{/** Copying to clipboard */}<Show when={copyState.type !== "idle"}>- <CopyingContent copyState={copyState} />+ <CopyingContent /></Show>{/** Exporting to shareable link */}<Show@@ -770,7 +762,7 @@ const ExportDialog = () => {</Show>{/** Exporting to file */}<Show when={exportState.type !== "idle"}>- <ExportingFileContent exportState={exportState} />+ <ExportingFileContent /></Show></div></DialogContent>@@ -779,7 +771,8 @@ const ExportDialog = () => {);};-const CopyingContent = ({ copyState }: { copyState: CopyState }) => {+const CopyingContent = () => {+ const { exportProgress, copyState } = useEditorContext();return (<div class="flex flex-col gap-4 justify-center items-center h-full"><h1 class="text-lg font-medium text-gray-500">@@ -799,8 +792,9 @@ const CopyingContent = ({ copyState }: { copyState: CopyState }) => {width: `${copyState.type === "rendering"? Math.min(- (copyState.renderedFrames / copyState.totalFrames) * 100,- 100+ ((exportProgress()?.renderedFrames ?? 0) /+ (exportProgress()?.totalFrames ?? 0)) *+ 100): 0}%`,@@ -813,7 +807,9 @@ const CopyingContent = ({ copyState }: { copyState: CopyState }) => {><p class="text-xs">{copyState.type === "rendering"- ? `${copyState.renderedFrames}/${copyState.totalFrames} frames`+ ? `${exportProgress()?.renderedFrames}/${+ exportProgress()?.totalFrames+ } frames`: copyState.type === "starting"? "Preparing to render...": ""}@@ -823,11 +819,8 @@ const CopyingContent = ({ copyState }: { copyState: CopyState }) => {);};-const ExportingFileContent = ({- exportState,-}: {- exportState: ExportState;-}) => {+const ExportingFileContent = () => {+ const { exportProgress, exportState } = useEditorContext();return (<div class="flex flex-col gap-4 justify-center items-center h-full"><h1 class="text-lg font-medium text-gray-500">@@ -851,7 +844,8 @@ const ExportingFileContent = ({? 100: exportState.type === "rendering"? Math.min(- (exportState.renderedFrames / exportState.totalFrames) *+ ((exportProgress()?.renderedFrames ?? 0) /+ (exportProgress()?.totalFrames ?? 0)) *100,100)@@ -870,7 +864,9 @@ const ExportingFileContent = ({{exportState.type === "starting"? "Preparing to render...": exportState.type === "rendering"- ? `${exportState.renderedFrames}/${exportState.totalFrames} frames`+ ? `${exportProgress()?.renderedFrames}/${+ exportProgress()?.totalFrames+ } frames`: ""}</p></Show>diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsxindex d6e9f89ab..7e772b5c9 100644--- a/apps/desktop/src/routes/editor/Header.tsx+++ b/apps/desktop/src/routes/editor/Header.tsx@@ -5,7 +5,7 @@ import { remove } from "@tauri-apps/plugin-fs";import { revealItemInDir } from "@tauri-apps/plugin-opener";import { type as ostype } from "@tauri-apps/plugin-os";import { cx } from "cva";-import { createEffect, createSignal, onCleanup, onMount } from "solid-js";+import { ComponentProps, onCleanup, onMount } from "solid-js";import { Button } from "@cap/ui-solid";import CaptionControlsWindows11 from "~/components/titlebar/controls/CaptionControlsWindows11";@@ -36,26 +36,8 @@ export interface ExportEstimates {}export function Header() {- const editorContext = useEditorContext();- const [lastMetaUpdate, setLastMetaUpdate] = createSignal<{- videoId: string;- timestamp: number;- } | null>(null);-- const [selectedFps, setSelectedFps] = createSignal(- Number(localStorage.getItem("cap-export-fps")) || 30- );- const [selectedResolution, setSelectedResolution] =- createSignal<ResolutionOption>(- RESOLUTION_OPTIONS.find(- (opt) => opt.value === localStorage.getItem("cap-export-resolution")- ) || RESOLUTION_OPTIONS[0]- );-- // Save settings when they change- createEffect(() => {- localStorage.setItem("cap-export-resolution", selectedResolution().value);- });+ const { editorInstance, history, setDialog, exportProgress } =+ useEditorContext();let unlistenTitlebar: UnlistenFn | undefined;onMount(async () => {@@ -76,10 +58,10 @@ export function Header() {<EditorButtononClick={async () => {const currentWindow = getCurrentWindow();- if (!editorContext?.editorInstance.path) return;+ if (!editorInstance.path) return;if (!(await ask("Are you sure you want to delete this recording?")))return;- await remove(editorContext?.editorInstance.path, {+ await remove(editorInstance.path, {recursive: true,});await currentWindow.close();@@ -88,15 +70,13 @@ export function Header() {leftIcon={<IconCapTrash class="w-5" />}/><EditorButton- onClick={() =>- revealItemInDir(`${editorContext.editorInstance.path}/`)- }+ onClick={() => revealItemInDir(`${editorInstance.path}/`)}tooltipText="Open recording bundle"leftIcon={<IconLucideFolder class="w-5" />}/><p class="text-sm text-gray-500">- {editorContext.editorInstance.prettyName}+ {editorInstance.prettyName}<span class="text-sm text-gray-400">.cap</span></p>{/* <ErrorBoundary fallback={<></>}>@@ -149,14 +129,14 @@ export function Header() {)}><EditorButton- onClick={() => editorContext.history.undo()}- disabled={!editorContext.history.canUndo()}+ onClick={() => history.undo()}+ disabled={!history.canUndo()}tooltipText="Undo"leftIcon={<IconCapUndo class="w-5" />}/><EditorButton- onClick={() => editorContext.history.redo()}- disabled={!editorContext.history.canRedo()}+ onClick={() => history.redo()}+ disabled={!history.canRedo()}tooltipText="Redo"leftIcon={<IconCapRedo class="w-5" />}/>@@ -167,13 +147,13 @@ export function Header() {class={cx("flex gap-2 justify-center")}onClick={() => {trackEvent("export_button_clicked");- editorContext.setDialog({+ setDialog({type: "export",open: true,});}}>- <IconCapUpload class="size-5" />+ <UploadIcon class="text-gray-50 size-5" />Export</Button>{ostype() === "windows" && <CaptionControlsWindows11 />}@@ -181,3 +161,37 @@ export function Header() {</div>);}++const UploadIcon = (props: ComponentProps<"svg">) => {+ const { exportProgress } = useEditorContext();+ return (+ <svg+ width={20}+ height={20}+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ {/* Bottom part (the base) */}+ <path+ d="M16.6667 10.625V14.1667C16.6667 15.5474 15.5474 16.6667 14.1667 16.6667H5.83333C4.45262 16.6667 3.33333 15.5474 3.33333 14.1667V10.625"+ stroke="currentColor"+ stroke-width={1.66667}+ stroke-linecap="round"+ stroke-linejoin="round"+ class="upload-base"+ />++ {/* Arrow part */}+ <path+ d="M9.99999 3.33333V12.7083M9.99999 3.33333L13.75 7.08333M9.99999 3.33333L6.24999 7.08333"+ stroke="currentColor"+ stroke-width={1.66667}+ stroke-linecap="round"+ stroke-linejoin="round"+ class={cx(exportProgress() !== null ? "bounce" : "")}+ />+ </svg>+ );+};diff --git a/apps/desktop/src/routes/editor/ShareButton.tsx b/apps/desktop/src/routes/editor/ShareButton.tsxindex f8df02395..076591581 100644--- a/apps/desktop/src/routes/editor/ShareButton.tsx+++ b/apps/desktop/src/routes/editor/ShareButton.tsx@@ -8,12 +8,12 @@ import { Channel } from "@tauri-apps/api/core";import { createProgressBar } from "~/routes/editor/utils";import { authStore } from "~/store";import { commands, events, RenderProgress } from "~/utils/tauri";-import { metaUpdateStore, useEditorContext } from "./context";+import { useEditorContext } from "./context";import { RESOLUTION_OPTIONS } from "./Header";import { Dialog, DialogContent } from "./ui";function ShareButton() {- const { videoId } = useEditorContext();+ const { videoId, metaUpdateStore } = useEditorContext();const [recordingMeta, metaActions] = createResource(() =>commands.getRecordingMeta(videoId, "recording"));diff --git a/apps/desktop/src/routes/editor/context.ts b/apps/desktop/src/routes/editor/context.tsindex bec835a0d..9ade5ec8e 100644--- a/apps/desktop/src/routes/editor/context.ts+++ b/apps/desktop/src/routes/editor/context.ts@@ -85,6 +85,57 @@ export const [EditorContextProvider, useEditorContext] = createContextProvider(const [playbackTime, setPlaybackTime] = createSignal<number>(0);const [playing, setPlaying] = createSignal(false);++ //Export states++ const [exportProgress, setExportProgress] = createSignal<{+ totalFrames: number;+ renderedFrames: number;+ } | null>(null);++ type ExportState =+ | { type: "idle" }+ | { type: "starting" }+ | { type: "rendering"}+ | { type: "saving"; done: boolean };++type CopyState =+ | { type: "idle" }+ | { type: "starting" }+ | { type: "rendering"}+ | { type: "copying" }+ | { type: "copied" };++ const [exportState, setExportState] = createStore<ExportState>({+ type: "idle",+ });++ const [copyState, setCopyState] = createStore<CopyState>({+ type: "idle",+ });++ const [uploadState, setUploadState] = createStore<+ | { type: "idle" }+ | { type: "starting" }+ | { type: "rendering" }+ | { type: "uploading"; progress: number }+ | { type: "link-copied" }+ >({ type: "idle" });+++//This is used in ShareButton.tsx to notify the component that the metadata has changed, from ExportDialog.tsx+//When a video is uploaded, the metadata is updated+++ const [lastMetaUpdate, setLastMetaUpdate] = createSignal<{ videoId: string; timestamp: number } | null>(null);++ const metaUpdateStore = {+ notifyUpdate: (videoId: string) => {+ setLastMetaUpdate({ videoId, timestamp: Date.now() });+ },+ getLastUpdate: lastMetaUpdate+ };+createEffect(on(playing, () => {if (!playing())@@ -169,8 +220,19 @@ export const [EditorContextProvider, useEditorContext] = createContextProvider(setProject,selectedTab,backgroundTab,+ exportProgress,+ setExportProgress,+ copyState,+ setCopyState,+ uploadState,+ setUploadState,+ exportState,+ setExportState,setBackgroundTab,setSelectedTab,+ metaUpdateStore,+ lastMetaUpdate,+ setLastMetaUpdate,history: createStoreHistory(project, setProject),playbackTime,setPlaybackTime,@@ -330,16 +392,3 @@ export const [SegmentContextProvider, useSegmentContext] =return props;}, null!);---//This is used in ShareButton.tsx to notify the component that the metadata has changed, from ExportDialog.tsx-//When a video is uploaded, the metadata is updated--const [lastMetaUpdate, setLastMetaUpdate] = createSignal<{ videoId: string; timestamp: number } | null>(null);--export const metaUpdateStore = {- notifyUpdate: (videoId: string) => {- setLastMetaUpdate({ videoId, timestamp: Date.now() });- },- getLastUpdate: lastMetaUpdate-};diff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.cssindex 00315dbe4..0abdc3a72 100644--- a/apps/desktop/src/styles/theme.css+++ b/apps/desktop/src/styles/theme.css@@ -180,22 +180,41 @@0% {stroke-dasharray: 100;stroke-dashoffset: 100;- opacity: 0;}50% {- opacity: 1;}100% {stroke-dashoffset: 0;}}+@keyframes bounce {+ 0%, 100% {+ transform: translateY(-15%);+ animation-timing-function: cubic-bezier(0.8, 0, 1, 1);+ }+ 50% {+ transform: none;+ animation-timing-function: cubic-bezier(0, 0, 0.2, 1);+ }+}++.bounce {+ animation: bounce 1s ease-in-out forwards;+ animation-iteration-count: infinite;+}+.svgpathanimation {stroke-dasharray: 100;stroke-dashoffset: 100;animation: svgpathframes 1s ease-in-out forwards;}+.svgpathanimationrepeat {+ animation: svgpathframes 1s ease-in-out forwards;+ animation-iteration-count: infinite;+}+/* Tabs container with mask-based fade-out effect */.tabs-mask-content {