Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
editor redesign wip
ameer2468d033bf7162c0
diff --git a/apps/desktop/src/components/titlebar/Titlebar.tsx b/apps/desktop/src/components/titlebar/Titlebar.tsxindex 173f6c93e..8b5b213f6 100644--- a/apps/desktop/src/components/titlebar/Titlebar.tsx+++ b/apps/desktop/src/components/titlebar/Titlebar.tsx@@ -1,9 +1,9 @@// Credits: tauri-controls-import { type ComponentProps, Match, splitProps, Switch } from "solid-js";import { type } from "@tauri-apps/plugin-os";-import CaptionControlsWindows11 from "./controls/CaptionControlsWindows11";-import titlebarState from "~/utils/titlebar-state";import { cx } from "cva";+import { type ComponentProps, Match, splitProps, Switch } from "solid-js";+import titlebarState from "~/utils/titlebar-state";+import CaptionControlsWindows11 from "./controls/CaptionControlsWindows11";export default function Titlebar() {function left() {@@ -14,9 +14,13 @@ export default function Titlebar() {return (<headerclass={cx(- "flex flex-row items-center select-none space-x-1 shrink-0 border-gray-200",- titlebarState.transparent ? "bg-transparent" : "bg-gray-50",- titlebarState.border ? "border-b" : ""+ "flex flex-row items-center select-none space-x-1 shrink-0 border-gray-50",+ titlebarState.backgroundColor+ ? titlebarState.backgroundColor+ : titlebarState.transparent+ ? "bg-transparent"+ : "bg-gray-50",+ titlebarState.border ? "border-b border-b-gray-200" : "")}style={{height: titlebarState.height,@@ -51,7 +55,7 @@ function WindowControls(props: ComponentProps<"div">) {/></Match><Match when={ostype === "macos"}>- <div data-tauri-drag-region class="flex h-full w-20" />+ <div data-tauri-drag-region class="flex w-20 h-full" /></Match></Switch>);diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsxindex 655429b86..4de051536 100644--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx@@ -1,4 +1,5 @@import { Button } from "@cap/ui-solid";+import { Tooltip } from "@kobalte/core";import { Select as KSelect, SelectRootProps } from "@kobalte/core/select";import { useNavigate } from "@solidjs/router";import {@@ -7,35 +8,34 @@ import {useQueryClient,} from "@tanstack/solid-query";import { getVersion } from "@tauri-apps/api/app";-import { availableMonitors, getCurrentWindow } from "@tauri-apps/api/window";-import { LogicalSize } from "@tauri-apps/api/window";+import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window";import { cx } from "cva";import {- type JSX,- Show,- type ValidComponent,createEffect,createMemo,createResource,createSignal,- onMount,- onCleanup,ErrorBoundary,+ type JSX,+ onCleanup,+ onMount,+ Show,Suspense,+ type ValidComponent,} from "solid-js";import { createStore } from "solid-js/store";-import { Tooltip } from "@kobalte/core";import { trackEvent } from "~/utils/analytics";+import Mode from "~/components/Mode";import {createCurrentRecordingQuery,+ createLicenseQuery,createOptionsQuery,- listWindows,- listAudioDevices,- getPermissions,createVideoDevicesQuery,+ getPermissions,+ listAudioDevices,listScreens,- createLicenseQuery,+ listWindows,} from "~/utils/queries";import {type CaptureScreen,@@ -50,7 +50,6 @@ import {topLeftAnimateClasses,topRightAnimateClasses,} from "../editor/ui";-import Mode from "~/components/Mode";export default function () {const { options, setOptions } = createOptionsQuery();@@ -146,7 +145,7 @@ export default function () {"items",<divdir={ostype() === "windows" ? "rtl" : "rtl"}- class="flex mx-2 items-center gap-1"+ class="flex gap-1 items-center mx-2"><Tooltip.Root openDelay={0}><Tooltip.Trigger>@@ -157,11 +156,11 @@ export default function () {}class="flex items-center justify-center w-5 h-5 -ml-[1.5px]">- <IconCapSettings class="size-5 text-gray-400 hover:text-gray-500" />+ <IconCapSettings class="text-gray-400 size-5 hover:text-gray-500" /></button></Tooltip.Trigger><Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">Settings<Tooltip.Arrow class="fill-gray-500" /></Tooltip.Content>@@ -174,13 +173,13 @@ export default function () {onClick={() =>commands.showWindow({ Settings: { page: "recordings" } })}- class="flex items-center justify-center w-5 h-5"+ class="flex justify-center items-center w-5 h-5">- <IconLucideSquarePlay class="size-5 text-gray-400 hover:text-gray-500" />+ <IconLucideSquarePlay class="text-gray-400 size-5 hover:text-gray-500" /></button></Tooltip.Trigger><Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">Previous Recordings<Tooltip.Arrow class="fill-gray-500" /></Tooltip.Content>@@ -193,9 +192,9 @@ export default function () {<buttontype="button"onClick={() => commands.showWindow("Upgrade")}- class="relative flex items-center justify-center w-5 h-5"+ class="flex relative justify-center items-center w-5 h-5">- <IconLucideGift class="size-5 text-gray-400 hover:text-gray-500" />+ <IconLucideGift class="text-gray-400 size-5 hover:text-gray-500" /><divstyle={{ "background-color": "#FF4747" }}class="block z-10 absolute top-0 right-0 size-1.5 rounded-full animate-bounce"@@ -209,9 +208,9 @@ export default function () {onClick={() => {new WebviewWindow("debug", { url: "/debug" });}}- class="flex items-center justify-center w-5 h-5"+ class="flex justify-center items-center w-5 h-5">- <IconLucideBug class="size-5 text-gray-400 hover:text-gray-500" />+ <IconLucideBug class="text-gray-400 size-5 hover:text-gray-500" /></button>)}</div>@@ -221,13 +220,13 @@ export default function () {});return (- <div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-[--gray-50] h-full text-[--text-primary]">+ <div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-gray-50 h-full text-[--text-primary]">{initialize()}<div class="flex items-center justify-between pb-[0.25rem]"><div class="flex items-center space-x-1"><div class="*:w-[92px] *:h-auto text-[--text-primary] ">- <IconCapLogoFullDark class="dark:block hidden" />- <IconCapLogoFull class="dark:hidden block" />+ <IconCapLogoFullDark class="hidden dark:block" />+ <IconCapLogoFull class="block dark:hidden" /></div><ErrorBoundary fallback={<></>}><Suspense>@@ -257,13 +256,13 @@ export default function () {<TargetSelects options={options.data} setOptions={setOptions} /><CameraSelect options={options.data} setOptions={setOptions} /><MicrophoneSelect options={options.data} setOptions={setOptions} />- <div class="w-full flex items-center space-x-1">+ <div class="flex items-center space-x-1 w-full"><Buttondisabled={toggleRecording.isPending}variant={isRecording() ? "destructive" : "primary"}size="md"onClick={() => toggleRecording.mutate()}- class="flex-grow flex items-center justify-center"+ class="flex flex-grow justify-center items-center">{isRecording() ? ("Stop Recording"@@ -320,20 +319,18 @@ function useRequestPermission() {return requestPermission;}-import * as dialog from "@tauri-apps/plugin-dialog";-import * as updater from "@tauri-apps/plugin-updater";import { makePersisted } from "@solid-primitives/storage";-import { setTitlebar } from "~/utils/titlebar-state";-import { type as ostype } from "@tauri-apps/plugin-os";-import { apiClient, protectedHeaders } from "~/utils/web-api";-import { Transition } from "solid-transition-group";+import { UnlistenFn } from "@tauri-apps/api/event";import {getCurrentWebviewWindow,WebviewWindow,} from "@tauri-apps/api/webviewWindow";-import { Webview } from "@tauri-apps/api/webview";-import { UnlistenFn } from "@tauri-apps/api/event";-import { isDev } from "solid-js/web";+import * as dialog from "@tauri-apps/plugin-dialog";+import { type as ostype } from "@tauri-apps/plugin-os";+import * as updater from "@tauri-apps/plugin-updater";+import { Transition } from "solid-transition-group";+import { setTitlebar } from "~/utils/titlebar-state";+import { apiClient } from "~/utils/web-api";let hasChecked = false;function createUpdateCheck() {@@ -498,7 +495,7 @@ function TargetSelects(props: {return (<div><Tooltip.Root openDelay={500}>- <Tooltip.Trigger class="fixed flex flex-row items-center w-8 h-8">+ <Tooltip.Trigger class="flex fixed flex-row items-center w-8 h-8"><TransitiononEnter={(el, done) => {if (shouldAnimateAreaSelect)@@ -577,7 +574,7 @@ function TargetSelects(props: {</Transition></Tooltip.Trigger><Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">{isTargetCaptureArea()? "Remove selection": areaSelection.pending@@ -606,7 +603,7 @@ function TargetSelects(props: {: undefined,}}>- <div class="bg-gray-100 flex-1" />+ <div class="flex-1 bg-gray-100" /></div><TargetSelect<CaptureScreen>options={screens.data ?? []}@@ -653,7 +650,7 @@ function TargetSelects(props: {optionsEmptyText="No windows found"selected={props.options?.captureTarget.variant === "window"}itemComponent={(props) => (- <div class="flex-1 flex flex-col overflow-x-hidden">+ <div class="flex overflow-x-hidden flex-col flex-1"><div class="w-full truncate">{props.item.rawValue?.name}</div><div class="w-full text-xs">{props.item.rawValue?.owner_name}@@ -762,7 +759,7 @@ function CameraSelect(props: {class={topLeftAnimateClasses}><MenuItemList<typeof KSelect.Listbox>- class="max-h-32 overflow-y-auto"+ class="overflow-y-auto max-h-32"as={KSelect.Listbox}/></PopperContent>@@ -928,7 +925,7 @@ function MicrophoneSelect(props: {class={topLeftAnimateClasses}><MenuItemList<typeof KSelect.Listbox>- class="max-h-36 overflow-y-auto"+ class="overflow-y-auto max-h-36"as={KSelect.Listbox}/></PopperContent>@@ -1013,8 +1010,8 @@ function TargetSelect<T extends { id: number; name: string }>(props: {{(value) => value.selectedOption()?.name}</KSelect.Value>{props.options.length > 1 && (- <KSelect.Icon class="ui-expanded:-rotate-180 transition-transform">- <IconCapChevronDown class="size-4 shrink-0 transform transition-transform" />+ <KSelect.Icon class="transition-transform ui-expanded:-rotate-180">+ <IconCapChevronDown class="transition-transform transform size-4 shrink-0" /></KSelect.Icon>)}</KSelect.Trigger>@@ -1137,9 +1134,9 @@ function ChangelogButton() {<buttontype="button"onClick={handleChangelogClick}- class="relative flex items-center justify-center w-5 h-5"+ class="flex relative justify-center items-center w-5 h-5">- <IconLucideBell class="size-5 text-gray-400 hover:text-gray-500" />+ <IconLucideBell class="text-gray-400 size-5 hover:text-gray-500" />{changelogState.hasUpdate && (<divstyle={{ "background-color": "#FF4747" }}@@ -1149,7 +1146,7 @@ function ChangelogButton() {</button></Tooltip.Trigger><Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">Changelog<Tooltip.Arrow class="fill-gray-500" /></Tooltip.Content>diff --git a/apps/desktop/src/routes/(window-chrome)/settings.tsx b/apps/desktop/src/routes/(window-chrome)/settings.tsxindex afd96e182..75d4bc62a 100644--- a/apps/desktop/src/routes/(window-chrome)/settings.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings.tsx@@ -1,8 +1,8 @@-import { A, type RouteSectionProps } from "@solidjs/router";-import { createResource, For, Show, Suspense, onMount } from "solid-js";import { Button } from "@cap/ui-solid";+import { A, type RouteSectionProps } from "@solidjs/router";import { getVersion } from "@tauri-apps/api/app";import "@total-typescript/ts-reset/filter-boolean";+import { createResource, For, Show, Suspense } from "solid-js";import toast from "solid-toast";import { authStore } from "~/store";@@ -55,7 +55,7 @@ export default function Settings(props: RouteSectionProps) {return (<div class="flex-1 flex flex-row divide-x divide-[--gray-200] text-[0.875rem] leading-[1.25rem] overflow-y-hidden">- <div class="h-full flex flex-col">+ <div class="flex flex-col h-full bg-gray-100"><ul class="min-w-[12rem] h-full p-[0.625rem] space-y-1 text-[--text-primary]"><Foreach={@@ -116,19 +116,19 @@ export default function Settings(props: RouteSectionProps) {{item.type === "button" ? (<buttononClick={item.onClick}- class="w-full rounded-lg h-[2rem] px-[0.375rem] flex flex-row items-center gap-[0.375rem] transition-colors border hover:bg-gray-100 border-transparent"+ class="w-full rounded-lg h-[2rem] px-2 flex flex-row items-center gap-[0.375rem] transition-colors border hover:bg-gray-100 border-transparent">- <item.icon class="size-[1.25rem]" />+ <item.icon class="size-4" /><span>{item.name}</span></button>) : (<Ahref={item.href}- activeClass="bg-blue-50 border-blue-200 text-blue-700"+ activeClass="bg-gray-200"inactiveClass="hover:bg-gray-100 border-transparent"- class="rounded-lg h-[2rem] px-[0.375rem] flex flex-row items-center gap-[0.375rem] transition-colors border"+ class="rounded-lg h-[2rem] px-2 flex flex-row items-center gap-[0.375rem] transition-colors border">- <item.icon class="size-[1.25rem]" />+ <item.icon class="size-4" /><span>{item.name}</span></A>)}@@ -138,14 +138,14 @@ export default function Settings(props: RouteSectionProps) {</ul><div class="p-[0.625rem]"><Show when={version()}>- {(v) => <p class="text-xs text-gray-400 mb-1">v{v()}</p>}+ {(v) => <p class="mb-1 text-xs text-gray-400">v{v()}</p>}</Show><Button onClick={handleAuth} variant="secondary" class="w-full">{auth.data ? "Sign Out" : "Sign In"}</Button></div></div>- <div class="flex-1 bg-gray-50 overflow-y-hidden animate-in">+ <div class="overflow-y-hidden flex-1 bg-gray-50 animate-in"><Suspense>{props.children}</Suspense></div></div>diff --git a/apps/desktop/src/routes/editor/AspectRatioSelect.tsx b/apps/desktop/src/routes/editor/AspectRatioSelect.tsxnew file mode 100644index 000000000..d93487fba--- /dev/null+++ b/apps/desktop/src/routes/editor/AspectRatioSelect.tsx@@ -0,0 +1,94 @@+import { Select as KSelect } from "@kobalte/core/select";+import { Show } from "solid-js";++import { type AspectRatio } from "~/utils/tauri";+import { useEditorContext } from "./context";+import { ASPECT_RATIOS } from "./projectConfig";+import {+ EditorButton,+ MenuItem,+ MenuItemList,+ PopperContent,+ topLeftAnimateClasses,+} from "./ui";++function AspectRatioSelect() {+ const { project, setProject } = useEditorContext();+ return (+ <KSelect<AspectRatio | "auto">+ value={project.aspectRatio ?? "auto"}+ onChange={(v) => {+ if (v === null) return;+ setProject("aspectRatio", v === "auto" ? null : v);+ }}+ defaultValue="auto"+ options={+ ["auto", "wide", "vertical", "square", "classic", "tall"] as const+ }+ multiple={false}+ itemComponent={(props) => {+ const item = () =>+ props.item.rawValue === "auto"+ ? null+ : ASPECT_RATIOS[props.item.rawValue];++ return (+ <MenuItem<typeof KSelect.Item> as={KSelect.Item} item={props.item}>+ <KSelect.ItemLabel class="flex-1">+ {props.item.rawValue === "auto"+ ? "Auto"+ : ASPECT_RATIOS[props.item.rawValue].name}+ <Show when={item()}>+ {(item) => (+ <span class="text-gray-400">+ {"⋅"}+ {item().ratio[0]}:{item().ratio[1]}+ </span>+ )}+ </Show>+ </KSelect.ItemLabel>+ <KSelect.ItemIndicator class="ml-auto">+ <IconCapCircleCheck />+ </KSelect.ItemIndicator>+ </MenuItem>+ );+ }}+ placement="top-start"+ >+ <EditorButton<typeof KSelect.Trigger>+ as={KSelect.Trigger}+ class="w-28"+ leftIcon={<IconCapLayout />}+ rightIcon={+ <KSelect.Icon>+ <IconCapChevronDown />+ </KSelect.Icon>+ }+ rightIconEnd={true}+ >+ <KSelect.Value<AspectRatio | "auto">>+ {(state) => {+ const text = () => {+ const option = state.selectedOption();+ return option === "auto" ? "Auto" : ASPECT_RATIOS[option].name;+ };+ return <>{text()}</>;+ }}+ </KSelect.Value>+ </EditorButton>+ <KSelect.Portal>+ <PopperContent<typeof KSelect.Content>+ as={KSelect.Content}+ class={topLeftAnimateClasses}+ >+ <MenuItemList<typeof KSelect.Listbox>+ as={KSelect.Listbox}+ class="w-[12.5rem]"+ />+ </PopperContent>+ </KSelect.Portal>+ </KSelect>+ );+}++export default AspectRatioSelect;diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsxindex 952225b6b..fa8329e98 100644--- a/apps/desktop/src/routes/editor/Editor.tsx+++ b/apps/desktop/src/routes/editor/Editor.tsx@@ -2,6 +2,8 @@ import { Button } from "@cap/ui-solid";import { trackDeep } from "@solid-primitives/deep";import { throttle } from "@solid-primitives/scheduled";import { useSearchParams } from "@solidjs/router";+import { createMutation } from "@tanstack/solid-query";+import { convertFileSrc } from "@tauri-apps/api/core";import {Match,Show,@@ -14,10 +16,13 @@ import {untrack,} from "solid-js";import { createStore } from "solid-js/store";-import { createMutation } from "@tanstack/solid-query";-import { convertFileSrc } from "@tauri-apps/api/core";-import { type Crop, events, commands } from "~/utils/tauri";+import { Tooltip } from "@kobalte/core";+import { makePersisted } from "@solid-primitives/storage";+import Cropper, { cropToFloor } from "~/components/Cropper";+import { type Crop, events } from "~/utils/tauri";+import { setTitlebar } from "~/utils/titlebar-state";+import { ConfigSidebar } from "./ConfigSidebar";import {EditorContextProvider,EditorInstanceContextProvider,@@ -26,6 +31,9 @@ import {useEditorContext,useEditorInstanceContext,} from "./context";+import { Header } from "./Header";+import { Player } from "./Player";+import { Timeline } from "./Timeline";import {Dialog,DialogContent,@@ -34,13 +42,6 @@ import {Subfield,Toggle,} from "./ui";-import { Header } from "./Header";-import { Player } from "./Player";-import { ConfigSidebar } from "./ConfigSidebar";-import { Timeline } from "./Timeline";-import Cropper, { cropToFloor } from "~/components/Cropper";-import { makePersisted } from "@solid-primitives/storage";-import { Tooltip } from "@kobalte/core";export function Editor() {const [params] = useSearchParams<{ id: string }>();@@ -116,15 +117,17 @@ function Inner() {));+ setTitlebar("backgroundColor", "bg-gray-50");+return (- <div class="w-screen h-screen flex flex-col">+ <div class="flex flex-col w-screen h-screen"><Header /><div- class="p-5 pt-0 flex-1 w-full overflow-y-hidden flex flex-col gap-4 bg-gray-50 leading-5 animate-in fade-in"+ class="flex overflow-y-hidden flex-col flex-1 gap-4 p-5 w-full leading-5 bg-gray-50 backdrop-blur-md animate-in fade-in"data-tauri-drag-region>- <div class="rounded-2xl overflow-hidden shadow border flex-1 flex flex-col divide-y bg-white">- <div class="flex flex-row flex-1 divide-x overflow-y-hidden">+ <div class="flex overflow-hidden flex-col flex-1 bg-white rounded-2xl border divide-y shadow">+ <div class="flex overflow-y-hidden flex-row flex-1 divide-x"><Player /><ConfigSidebar /></div>@@ -345,7 +348,7 @@ function Dialogs() {<div class="flex flex-row items-center space-x-[0.5rem] text-gray-400"><Tooltip.Root openDelay={500}><Tooltip.Trigger- class="fixed flex flex-row items-center w-8 h-8"+ class="flex fixed flex-row items-center w-8 h-8"tabIndex={-1}><button@@ -363,7 +366,7 @@ function Dialogs() {</button></Tooltip.Trigger><Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">Rule of Thirds<Tooltip.Arrow class="fill-gray-500" /></Tooltip.Content>@@ -389,7 +392,7 @@ function Dialogs() {</Dialog.Header><Dialog.Content><div class="flex flex-row justify-center">- <div class="divide-black-transparent-10 overflow-hidden rounded">+ <div class="overflow-hidden rounded divide-black-transparent-10"><Croppervalue={crop}onCropChange={setCrop}diff --git a/apps/desktop/src/routes/editor/ExportButton.tsx b/apps/desktop/src/routes/editor/ExportButton.tsxnew file mode 100644index 000000000..859b5de7a--- /dev/null+++ b/apps/desktop/src/routes/editor/ExportButton.tsx@@ -0,0 +1,372 @@+import { Button } from "@cap/ui-solid";+import { Select as KSelect } from "@kobalte/core/select";+import { createMutation } from "@tanstack/solid-query";+import { save } from "@tauri-apps/plugin-dialog";+import { cx } from "cva";+import { createResource, createSignal, Setter, Show } from "solid-js";+import { createStore, produce } from "solid-js/store";++import { Channel } from "@tauri-apps/api/core";+import { createProgressBar } from "~/routes/editor/utils";+import { trackEvent } from "~/utils/analytics";+import { commands, RenderProgress } from "~/utils/tauri";+import { useEditorContext } from "./context";+import { RESOLUTION_OPTIONS, ResolutionOption } from "./Header";+import {+ Dialog,+ DialogContent,+ MenuItem,+ MenuItemList,+ PopperContent,+ topLeftAnimateClasses,+} from "./ui";++const FPS_OPTIONS = [+ { label: "30 FPS", value: 30 },+ { label: "60 FPS", value: 60 },+] satisfies Array<{ label: string; value: number }>;++function ExportButton(props: {+ selectedFps: number;+ selectedResolution: ResolutionOption;+ setSelectedResolution: Setter<ResolutionOption>;+ setSelectedFps: Setter<number>;+}) {+ const { videoId, project, prettyName } = useEditorContext();+ const [showExportOptions, setShowExportOptions] = createSignal(false);++ const [exportEstimates] = createResource(+ () => ({+ videoId,+ resolution: {+ x: props.selectedResolution.width,+ y: props.selectedResolution.height,+ },+ fps: props.selectedFps,+ }),+ (params) =>+ commands.getExportEstimates(params.videoId, params.resolution, params.fps)+ );++ const exportWithSettings = createMutation(() => ({+ mutationFn: async () => {+ setExportState({ type: "idle" });++ setShowExportOptions(false);++ const path = await save({+ filters: [{ name: "mp4 filter", extensions: ["mp4"] }],+ defaultPath: `~/Desktop/${prettyName()}.mp4`,+ });+ if (!path) return;++ trackEvent("export_started", {+ resolution: props.selectedResolution.value,+ fps: props.selectedFps,+ path: path,+ });++ setExportState({ type: "starting" });++ const progress = new Channel<RenderProgress>();++ progress.onmessage = (msg) => {+ if (msg.type === "EstimatedTotalFrames")+ setExportState({+ type: "rendering",+ renderedFrames: 0,+ totalFrames: msg.total_frames,+ });+ else+ setExportState(+ produce((state) => {+ if (msg.type === "FrameRendered" && state.type === "rendering")+ state.renderedFrames = msg.current_frame;+ })+ );+ };++ try {+ const videoPath = await commands.exportVideo(+ videoId,+ progress,+ true,+ props.selectedFps,+ {+ x: props.selectedResolution.width,+ y: props.selectedResolution.height,+ }+ );++ setExportState({ type: "saving", done: false });++ await commands.copyFileToPath(videoPath, path);++ setExportState({ type: "saving", done: false });+ } catch (error) {+ throw error;+ }+ },+ onSettled() {+ setTimeout(() => {+ exportWithSettings.reset();+ }, 2000);+ },+ }));++ const [exportState, setExportState] = createStore<+ | { type: "idle" }+ | { type: "starting" }+ | { type: "rendering"; renderedFrames: number; totalFrames: number }+ | { type: "saving"; done: boolean }+ >({ type: "idle" });++ 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;+ });++ return (+ <div class="relative">+ <Button+ variant="white"+ class={cx(+ "flex gap-2 justify-center",+ showExportOptions() &&+ "shadow-[inset_0_0_4px_2px_rgba(0,0,0,0.25)] dark:shadow-[inset_0_0_4px_2px_rgba(0,0,0,0.7)]"+ )}+ onClick={() => {+ trackEvent("export_button_clicked");+ setShowExportOptions(!showExportOptions());+ }}+ >+ <IconCapUpload class="size-5" />+ Export+ </Button>+ <Show when={showExportOptions()}>+ <div class="absolute right-0 top-full mt-2 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-40 p-4 min-w-[240px]">+ <div class="space-y-4">+ <div>+ <label class="block mb-1 text-sm font-medium text-gray-500 dark:text-gray-400">+ Resolution+ </label>+ <KSelect<ResolutionOption>+ options={RESOLUTION_OPTIONS}+ optionValue="value"+ optionTextValue="label"+ placeholder="Select Resolution"+ value={props.selectedResolution}+ onChange={(value) => {+ if (value) {+ trackEvent("export_resolution_changed", {+ resolution: value.value,+ width: value.width,+ height: value.height,+ });+ props.setSelectedResolution(value);+ }+ }}+ itemComponent={(props) => (+ <MenuItem<typeof KSelect.Item>+ as={KSelect.Item}+ item={props.item}+ >+ <KSelect.ItemLabel class="flex-1">+ {props.item.rawValue.label}+ </KSelect.ItemLabel>+ </MenuItem>+ )}+ >+ <KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">+ <KSelect.Value<ResolutionOption> class="flex-1 text-sm text-left truncate text-[--gray-500]">+ {(state) => <span>{state.selectedOption()?.label}</span>}+ </KSelect.Value>+ <KSelect.Icon>+ <IconCapChevronDown class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]" />+ </KSelect.Icon>+ </KSelect.Trigger>+ <KSelect.Portal>+ <PopperContent<typeof KSelect.Content>+ as={KSelect.Content}+ class={cx(topLeftAnimateClasses, "z-50")}+ >+ <MenuItemList<typeof KSelect.Listbox>+ class="overflow-y-auto max-h-32"+ as={KSelect.Listbox}+ />+ </PopperContent>+ </KSelect.Portal>+ </KSelect>+ </div>+ <div>+ <label class="block mb-1 text-sm font-medium text-gray-500 dark:text-gray-400">+ FPS+ </label>+ <KSelect+ options={FPS_OPTIONS}+ optionValue="value"+ optionTextValue="label"+ placeholder="Select FPS"+ value={FPS_OPTIONS.find(+ (opt) => opt.value === props.selectedFps+ )}+ onChange={(option) => {+ const fps = option?.value ?? 30;+ trackEvent("export_fps_changed", {+ fps: fps,+ });+ props.setSelectedFps(fps);+ }}+ itemComponent={(props) => (+ <MenuItem<typeof KSelect.Item>+ as={KSelect.Item}+ item={props.item}+ >+ <KSelect.ItemLabel class="flex-1">+ {props.item.rawValue.label}+ </KSelect.ItemLabel>+ </MenuItem>+ )}+ >+ <KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">+ <KSelect.Value<+ (typeof FPS_OPTIONS)[number]+ > class="flex-1 text-sm text-left truncate text-[--gray-500]">+ {(state) => <span>{state.selectedOption()?.label}</span>}+ </KSelect.Value>+ <KSelect.Icon>+ <IconCapChevronDown class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]" />+ </KSelect.Icon>+ </KSelect.Trigger>+ <KSelect.Portal>+ <PopperContent<typeof KSelect.Content>+ as={KSelect.Content}+ class={cx(topLeftAnimateClasses, "z-50")}+ >+ <MenuItemList<typeof KSelect.Listbox>+ class="overflow-y-auto max-h-32"+ as={KSelect.Listbox}+ />+ </PopperContent>+ </KSelect.Portal>+ </KSelect>+ </div>+ <Button+ variant="primary"+ class="justify-center w-full"+ onClick={() => exportWithSettings.mutate()}+ >+ Export Video+ </Button>+ <Show when={exportEstimates.latest}>+ {(est) => (+ <div+ class={cx(+ "flex overflow-hidden z-40 justify-between items-center max-w-full text-xs font-medium transition-all pointer-events-none"+ )}+ >+ <p class="flex gap-4 items-center">+ <span class="flex items-center text-[--gray-500]">+ <IconCapCamera class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />+ {(() => {+ const totalSeconds = Math.round(est().duration_seconds);+ const hours = Math.floor(totalSeconds / 3600);+ const minutes = Math.floor((totalSeconds % 3600) / 60);+ const seconds = totalSeconds % 60;++ if (hours > 0) {+ return `${hours}:${minutes+ .toString()+ .padStart(2, "0")}:${seconds+ .toString()+ .padStart(2, "0")}`;+ }+ return `${minutes}:${seconds+ .toString()+ .padStart(2, "0")}`;+ })()}+ </span>+ <span class="flex items-center text-[--gray-500]">+ <IconLucideHardDrive class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />+ {est().estimated_size_mb.toFixed(2)} MB+ </span>+ <span class="flex items-center text-[--gray-500]">+ <IconLucideClock class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />+ {(() => {+ const totalSeconds = Math.round(+ est().estimated_time_seconds+ );+ const hours = Math.floor(totalSeconds / 3600);+ const minutes = Math.floor((totalSeconds % 3600) / 60);+ const seconds = totalSeconds % 60;++ if (hours > 0) {+ return `~${hours}:${minutes+ .toString()+ .padStart(2, "0")}:${seconds+ .toString()+ .padStart(2, "0")}`;+ }+ return `~${minutes}:${seconds+ .toString()+ .padStart(2, "0")}`;+ })()}+ </span>+ </p>+ </div>+ )}+ </Show>+ </div>+ </div>+ </Show>+ <Dialog.Root+ open={!exportWithSettings.isIdle && exportState.type !== "idle"}+ onOpenChange={(o) => {+ // cancellation doesn't work yet+ // if (!o) exportWithSettings.reset();+ }}+ >+ <DialogContent+ title="Exporting Recording"+ confirm={<></>}+ close={<></>}+ class="text-gray-500 bg-gray-600 dark:text-gray-500"+ >+ <div class="w-[80%] text-center mx-auto relative z-10 space-y-6 py-4">+ <div class="w-full bg-gray-200 rounded-full h-2.5 mb-2">+ <div+ class="bg-blue-300 h-2.5 rounded-full"+ style={{+ width: `${+ exportState.type === "saving"+ ? 100+ : exportState.type === "rendering"+ ? Math.min(+ (exportState.renderedFrames /+ exportState.totalFrames) *+ 100,+ 100+ )+ : 0+ }%`,+ }}+ />+ </div>+ <p class="relative z-10 mt-3 text-xs">+ {exportState.type == "idle" || exportState.type === "starting"+ ? "Preparing to render..."+ : exportState.type === "rendering"+ ? `Rendering video (${exportState.renderedFrames}/${exportState.totalFrames} frames)`+ : "Exported successfully!"}+ </p>+ </div>+ </DialogContent>+ </Dialog.Root>+ </div>+ );+}++export default ExportButton;diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsxindex 7cf0ecd66..537dbaac2 100644--- a/apps/desktop/src/routes/editor/Header.tsx+++ b/apps/desktop/src/routes/editor/Header.tsx@@ -1,69 +1,166 @@-import { Button } from "@cap/ui-solid";+import type { UnlistenFn } from "@tauri-apps/api/event";+import { type as ostype } from "@tauri-apps/plugin-os";import { cx } from "cva";import {- Setter,- Show,batch,createEffect,- createResource,createSignal,+ JSX,onCleanup,onMount,- ErrorBoundary,- Suspense,} from "solid-js";-import { type as ostype } from "@tauri-apps/plugin-os";-import { Tooltip } from "@kobalte/core";-import { Select as KSelect } from "@kobalte/core/select";-import { createMutation } from "@tanstack/solid-query";-import { save } from "@tauri-apps/plugin-dialog";-import type { UnlistenFn } from "@tauri-apps/api/event";-import { getCurrentWindow, ProgressBarStatus } from "@tauri-apps/api/window";-import { createStore, produce } from "solid-js/store";-import { commands, events, RenderProgress } from "~/utils/tauri";-import { useEditorContext } from "./context";-import { authStore } from "~/store";-import { trackEvent } from "~/utils/analytics";-import {- Dialog,- DialogContent,- MenuItem,- MenuItemList,- PopperContent,- topLeftAnimateClasses,-} from "./ui";import Titlebar from "~/components/titlebar/Titlebar";-import { initializeTitlebar, setTitlebar } from "~/utils/titlebar-state";-import { Channel } from "@tauri-apps/api/core";import { createLicenseQuery } from "~/utils/queries";+import { initializeTitlebar, setTitlebar } from "~/utils/titlebar-state";+import AspectRatioSelect from "./AspectRatioSelect";+import { useEditorContext } from "./context";+import ExportButton from "./ExportButton";+import PresetsDropdown from "./PresetsDropdown";+import ShareButton from "./ShareButton";+import { EditorButton } from "./ui";-type ResolutionOption = {+export type ResolutionOption = {label: string;value: string;width: number;height: number;};-const RESOLUTION_OPTIONS: ResolutionOption[] = [+export const RESOLUTION_OPTIONS: ResolutionOption[] = [{ label: "720p", value: "720p", width: 1280, height: 720 },{ label: "1080p", value: "1080p", width: 1920, height: 1080 },{ label: "4K", value: "4k", width: 3840, height: 2160 },];-const FPS_OPTIONS = [- { label: "30 FPS", value: 30 },- { label: "60 FPS", value: 60 },-] satisfies Array<{ label: string; value: number }>;-export interface ExportEstimates {duration_seconds: number;estimated_time_seconds: number;estimated_size_mb: number;}+// Menu configuration for the header+const Menu = {+ left: [+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => (+ <EditorButton+ tooltipText="Captions"+ leftIcon={<IconCapCaptions class="w-5" />}+ comingSoon+ />+ ),+ },+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => (+ <EditorButton+ tooltipText="Performance"+ leftIcon={<IconCapGauge class="w-[18px]" />}+ comingSoon+ />+ ),+ },+ ],+ center: [+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => <PresetsDropdown />,+ },+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => {+ const { editorInstance, setDialog, project } = props.editorContext;+ return (+ <EditorButton+ onClick={() => {+ const display = editorInstance.recordings.segments[0].display;+ setDialog({+ open: true,+ type: "crop",+ position: {+ ...(project.background.crop?.position ?? { x: 0, y: 0 }),+ },+ size: {+ ...(project.background.crop?.size ?? {+ x: display.width,+ y: display.height,+ }),+ },+ });+ }}+ leftIcon={<IconCapCrop class="w-5 text-gray-500" />}+ >+ Crop+ </EditorButton>+ );+ },+ },+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => <AspectRatioSelect />,+ },+ ],+ right: [+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => {+ const { history } = props.editorContext;+ return (+ <EditorButton+ onClick={() => history.undo()}+ disabled={!history.canUndo()}+ tooltipText="Undo"+ leftIcon={<IconCapUndo class="w-5" />}+ />+ );+ },+ },+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => {+ const { history } = props.editorContext;+ return (+ <EditorButton+ onClick={() => history.redo()}+ disabled={!history.canRedo()}+ tooltipText="Redo"+ leftIcon={<IconCapRedo class="w-5" />}+ />+ );+ },+ },+ {+ button: (props: {+ editorContext?: ReturnType<typeof useEditorContext>;+ }) => (+ <EditorButton+ tooltipText="Delete recording"+ leftIcon={<IconCapTrash class="w-5" />}+ />+ ),+ },+ ],+} satisfies Record<+ "left" | "center" | "right",+ {+ button: (props: {+ editorContext: ReturnType<typeof useEditorContext>;+ }) => JSX.Element;+ }[]+>;+export function Header() {const license = createLicenseQuery();+ const editorContext = useEditorContext();const [selectedFps, setSelectedFps] = createSignal(Number(localStorage.getItem("cap-export-fps")) || 30@@ -88,8 +185,8 @@ export function Header() {onCleanup(() => unlistenTitlebar?.());batch(() => {- setTitlebar("border", false);- setTitlebar("height", "4rem");+ setTitlebar("height", "60px");+ setTitlebar("border", true);setTitlebar("transparent", false);setTitlebar("items",@@ -100,7 +197,7 @@ export function Header() {ostype() === "windows" ? "pl-[4.3rem]" : "pl-[1.25rem]")}>- <div class="flex flex-row gap-2 font-medium items-center">+ <div class="flex relative z-20 flex-row gap-2 items-center font-medium"><ShareButtonselectedResolution={selectedResolution}selectedFps={selectedFps}@@ -117,660 +214,58 @@ export function Header() {});return (- <div class="relative">- <div class="absolute left-[6rem] top-[1.25rem] z-10">- <ErrorBoundary fallback={<></>}>- <Suspense>- <span- onClick={async () => {- if (license.data?.type !== "pro") {- await commands.showWindow("Upgrade");- }- }}- class={`text-[0.8rem] ${- license.data?.type === "pro"- ? "bg-[--blue-400] text-gray-50 dark:text-gray-500"- : "bg-gray-200 cursor-pointer hover:bg-gray-300"- } rounded-[0.55rem] px-2 py-1`}- >- {license.data?.type === "commercial"- ? "Commercial License"- : license.data?.type === "pro"- ? "Pro"- : "Personal License"}- </span>- </Suspense>- </ErrorBoundary>- </div>- <Titlebar />- </div>- );-}--function ExportButton(props: {- selectedFps: number;- selectedResolution: ResolutionOption;- setSelectedResolution: Setter<ResolutionOption>;- setSelectedFps: Setter<number>;-}) {- const { videoId, project, prettyName } = useEditorContext();- const [showExportOptions, setShowExportOptions] = createSignal(false);-- const [exportEstimates] = createResource(- () => ({- videoId,- resolution: {- x: props.selectedResolution.width,- y: props.selectedResolution.height,- },- fps: props.selectedFps,- }),- (params) =>- commands.getExportEstimates(params.videoId, params.resolution, params.fps)- );-- const exportWithSettings = createMutation(() => ({- mutationFn: async () => {- setExportState({ type: "idle" });-- setShowExportOptions(false);-- const path = await save({- filters: [{ name: "mp4 filter", extensions: ["mp4"] }],- defaultPath: `~/Desktop/${prettyName()}.mp4`,- });- if (!path) return;-- trackEvent("export_started", {- resolution: props.selectedResolution.value,- fps: props.selectedFps,- path: path,- });-- setExportState({ type: "starting" });-- const progress = new Channel<RenderProgress>();-- progress.onmessage = (msg) => {- if (msg.type === "EstimatedTotalFrames")- setExportState({- type: "rendering",- renderedFrames: 0,- totalFrames: msg.total_frames,- });- else- setExportState(- produce((state) => {- if (msg.type === "FrameRendered" && state.type === "rendering")- state.renderedFrames = msg.current_frame;- })- );- };-- try {- const videoPath = await commands.exportVideo(- videoId,- progress,- true,- props.selectedFps,- {- x: props.selectedResolution.width,- y: props.selectedResolution.height,- }- );-- setExportState({ type: "saving", done: false });-- await commands.copyFileToPath(videoPath, path);-- setExportState({ type: "saving", done: false });- } catch (error) {- throw error;- }- },- onSettled() {- setTimeout(() => {- exportWithSettings.reset();- }, 2000);- },- }));-- const [exportState, setExportState] = createStore<- | { type: "idle" }- | { type: "starting" }- | { type: "rendering"; renderedFrames: number; totalFrames: number }- | { type: "saving"; done: boolean }- >({ type: "idle" });-- 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;- });-- return (- <div class="relative">- <Button- variant="primary"- onClick={() => {- trackEvent("export_button_clicked");- setShowExportOptions(!showExportOptions());- }}+ <div data-tauri-drag-region class="relative w-full">+ <div+ data-tauri-drag-region+ class="absolute flex gap-4 h-full w-full items-start left-[5.5rem] z-10">- Export- </Button>- <Show when={showExportOptions()}>- <div class="absolute right-0 top-full mt-2 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-40 p-4 min-w-[240px]">- <div class="space-y-4">- <div>- <label class="block text-sm font-medium mb-1 text-gray-500 dark:text-gray-400">- Resolution- </label>- <KSelect<ResolutionOption>- options={RESOLUTION_OPTIONS}- optionValue="value"- optionTextValue="label"- placeholder="Select Resolution"- value={props.selectedResolution}- onChange={(value) => {- if (value) {- trackEvent("export_resolution_changed", {- resolution: value.value,- width: value.width,- height: value.height,- });- props.setSelectedResolution(value);+ <div class="flex gap-4 items-center h-full">+ <p class="text-sm text-gray-500">+ Recording<span class="opacity-50">.cap</span>+ </p>+ {/* <ErrorBoundary fallback={<></>}>+ <Suspense>+ <span+ onClick={async () => {+ if (license.data?.type !== "pro") {+ await commands.showWindow("Upgrade");}}}- itemComponent={(props) => (- <MenuItem<typeof KSelect.Item>- as={KSelect.Item}- item={props.item}- >- <KSelect.ItemLabel class="flex-1">- {props.item.rawValue.label}- </KSelect.ItemLabel>- </MenuItem>- )}- >- <KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">- <KSelect.Value<ResolutionOption> class="flex-1 text-sm text-left truncate text-[--gray-500]">- {(state) => <span>{state.selectedOption()?.label}</span>}- </KSelect.Value>- <KSelect.Icon>- <IconCapChevronDown class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]" />- </KSelect.Icon>- </KSelect.Trigger>- <KSelect.Portal>- <PopperContent<typeof KSelect.Content>- as={KSelect.Content}- class={cx(topLeftAnimateClasses, "z-50")}- >- <MenuItemList<typeof KSelect.Listbox>- class="max-h-32 overflow-y-auto"- as={KSelect.Listbox}- />- </PopperContent>- </KSelect.Portal>- </KSelect>- </div>- <div>- <label class="block text-sm font-medium mb-1 text-gray-500 dark:text-gray-400">- FPS- </label>- <KSelect- options={FPS_OPTIONS}- optionValue="value"- optionTextValue="label"- placeholder="Select FPS"- value={FPS_OPTIONS.find(- (opt) => opt.value === props.selectedFps- )}- onChange={(option) => {- const fps = option?.value ?? 30;- trackEvent("export_fps_changed", {- fps: fps,- });- props.setSelectedFps(fps);- }}- itemComponent={(props) => (- <MenuItem<typeof KSelect.Item>- as={KSelect.Item}- item={props.item}- >- <KSelect.ItemLabel class="flex-1">- {props.item.rawValue.label}- </KSelect.ItemLabel>- </MenuItem>- )}+ class={`text-[0.8rem] ${+ license.data?.type === "pro"+ ? "bg-[--blue-400] text-gray-50 dark:text-gray-500"+ : "bg-gray-200 cursor-pointer hover:bg-gray-300"+ } rounded-[0.55rem] px-2 py-1`}>- <KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">- <KSelect.Value<- (typeof FPS_OPTIONS)[number]- > class="flex-1 text-sm text-left truncate text-[--gray-500]">- {(state) => <span>{state.selectedOption()?.label}</span>}- </KSelect.Value>- <KSelect.Icon>- <IconCapChevronDown class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]" />- </KSelect.Icon>- </KSelect.Trigger>- <KSelect.Portal>- <PopperContent<typeof KSelect.Content>- as={KSelect.Content}- class={cx(topLeftAnimateClasses, "z-50")}- >- <MenuItemList<typeof KSelect.Listbox>- class="max-h-32 overflow-y-auto"- as={KSelect.Listbox}- />- </PopperContent>- </KSelect.Portal>- </KSelect>- </div>- <Button- variant="primary"- class="w-full justify-center"- onClick={() => exportWithSettings.mutate()}- >- Export Video- </Button>- <Show when={exportEstimates.latest}>- {(est) => (- <div- class={cx(- "font-medium z-40 flex justify-between items-center pointer-events-none transition-all max-w-full overflow-hidden text-xs"- )}- >- <p class="flex items-center gap-4">- <span class="flex items-center text-[--gray-500]">- <IconCapCamera class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />- {(() => {- const totalSeconds = Math.round(est().duration_seconds);- const hours = Math.floor(totalSeconds / 3600);- const minutes = Math.floor((totalSeconds % 3600) / 60);- const seconds = totalSeconds % 60;-- if (hours > 0) {- return `${hours}:${minutes- .toString()- .padStart(2, "0")}:${seconds- .toString()- .padStart(2, "0")}`;- }- return `${minutes}:${seconds- .toString()- .padStart(2, "0")}`;- })()}- </span>- <span class="flex items-center text-[--gray-500]">- <IconLucideHardDrive class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />- {est().estimated_size_mb.toFixed(2)} MB- </span>- <span class="flex items-center text-[--gray-500]">- <IconLucideClock class="w-[14px] h-[14px] mr-1.5 text-[--gray-500]" />- {(() => {- const totalSeconds = Math.round(- est().estimated_time_seconds- );- const hours = Math.floor(totalSeconds / 3600);- const minutes = Math.floor((totalSeconds % 3600) / 60);- const seconds = totalSeconds % 60;-- if (hours > 0) {- return `~${hours}:${minutes- .toString()- .padStart(2, "0")}:${seconds- .toString()- .padStart(2, "0")}`;- }- return `~${minutes}:${seconds- .toString()- .padStart(2, "0")}`;- })()}- </span>- </p>- </div>- )}- </Show>- </div>+ {license.data?.type === "commercial"+ ? "Commercial License"+ : license.data?.type === "pro"+ ? "Pro"+ : "Personal License"}+ </span>+ </Suspense>+ </ErrorBoundary> */}</div>- </Show>- <Dialog.Root- open={!exportWithSettings.isIdle && exportState.type !== "idle"}- onOpenChange={(o) => {- // cancellation doesn't work yet- // if (!o) exportWithSettings.reset();- }}+ </div>+ <div+ data-tauri-drag-region+ class="flex absolute inset-x-0 z-10 items-center mx-auto h-full w-fit">- <DialogContent- title="Exporting Recording"- confirm={<></>}- close={<></>}- class="bg-gray-600 text-gray-500 dark:text-gray-500"- >- <div class="w-[80%] text-center mx-auto relative z-10 space-y-6 py-4">- <div class="w-full bg-gray-200 rounded-full h-2.5 mb-2">- <div- class="bg-blue-300 h-2.5 rounded-full"- style={{- width: `${- exportState.type === "saving"- ? 100- : exportState.type === "rendering"- ? Math.min(- (exportState.renderedFrames /- exportState.totalFrames) *- 100,- 100- )- : 0- }%`,- }}- />- </div>- <p class="text-xs mt-3 relative z-10">- {exportState.type == "idle" || exportState.type === "starting"- ? "Preparing to render..."- : exportState.type === "rendering"- ? `Rendering video (${exportState.renderedFrames}/${exportState.totalFrames} frames)`- : "Exported successfully!"}- </p>- </div>- </DialogContent>- </Dialog.Root>- </div>- );-}--function ShareButton(props: {- selectedResolution: () => ResolutionOption;- selectedFps: () => number;-}) {- const { videoId, project } = useEditorContext();- const [recordingMeta, metaActions] = createResource(() =>- commands.getRecordingMeta(videoId, "recording")- );-- const uploadVideo = createMutation(() => ({- mutationFn: async () => {- setUploadState({ type: "idle" });-- console.log("Starting upload process...");-- // Check authentication first- const existingAuth = await authStore.get();- if (!existingAuth) {- await commands.showWindow("SignIn");- throw new Error("You need to sign in to share recordings");- }-- trackEvent("create_shareable_link_clicked", {- resolution: props.selectedResolution().value,- fps: props.selectedFps(),- has_existing_auth: !!existingAuth,- });-- const meta = recordingMeta();- if (!meta) {- console.error("No recording metadata available");- throw new Error("Recording metadata not available");- }-- const metadata = await commands.getVideoMetadata(videoId, null);- const plan = await commands.checkUpgradedAndUpdate();- const canShare = {- allowed: plan || metadata.duration < 300,- reason: !plan && metadata.duration >= 300 ? "upgrade_required" : null,- };-- if (!canShare.allowed) {- if (canShare.reason === "upgrade_required") {- await commands.showWindow("Upgrade");- throw new Error(- "Upgrade required to share recordings longer than 5 minutes"- );- }- }-- const unlisten = await events.uploadProgress.listen((event) => {- console.log("Upload progress event:", event.payload);- setUploadState(- produce((state) => {- if (state.type !== "uploading") return;-- state.progress = Math.round(event.payload.progress * 100);- })- );- });-- try {- setUploadState({ type: "starting" });-- // Setup progress listener before starting upload-- console.log("Starting actual upload...");-- const progress = new Channel<RenderProgress>();-- progress.onmessage = (msg) => {- if (msg.type === "EstimatedTotalFrames")- setUploadState({- type: "rendering",- renderedFrames: 0,- totalFrames: msg.total_frames,- });- else- setUploadState(- produce((state) => {- if (msg.type === "FrameRendered" && state.type === "rendering")- state.renderedFrames = msg.current_frame;- })- );- };-- await commands.exportVideo(- videoId,- progress,- true,- props.selectedFps(),- {- x: props.selectedResolution()?.width || RESOLUTION_OPTIONS[0].width,- y:- props.selectedResolution()?.height ||- RESOLUTION_OPTIONS[0].height,- }- );-- setUploadState({ type: "uploading", progress: 0 });-- // Now proceed with upload- const result = recordingMeta()?.sharing- ? await commands.uploadExportedVideo(videoId, "Reupload")- : await commands.uploadExportedVideo(videoId, {- Initial: { pre_created_video: null },- });-- if (result === "NotAuthenticated") {- await commands.showWindow("SignIn");- throw new Error("You need to sign in to share recordings");- } else if (result === "PlanCheckFailed")- throw new Error("Failed to verify your subscription status");- else if (result === "UpgradeRequired")- throw new Error("This feature requires an upgraded plan");-- setUploadState({ type: "link-copied" });-- return result;- } catch (error) {- console.error("Upload error:", error);- throw error instanceof Error- ? error- : new Error("Failed to upload recording");- } finally {- unlisten();- }- },- onSuccess: () => {- metaActions.refetch();- },- onError: (error) => {- commands.globalMessageDialog(- error instanceof Error ? error.message : "Failed to upload recording"- );- },- onSettled() {- setTimeout(() => {- setUploadState({ type: "idle" });- uploadVideo.reset();- }, 2000);- },- }));-- const [uploadState, setUploadState] = createStore<- | { type: "idle" }- | { type: "starting" }- | { type: "rendering"; renderedFrames: number; totalFrames: number }- | { type: "uploading"; progress: number }- | { type: "link-copied" }- >({ type: "idle" });-- 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 (- <div class="relative">- <Show- when={recordingMeta.latest?.sharing}- fallback={- <Button- disabled={uploadVideo.isPending}- onClick={(e) => uploadVideo.mutate()}- variant="primary"- class="flex items-center space-x-1"- >- {uploadVideo.isPending ? (- <>- <span>Uploading Cap</span>- <IconLucideLoaderCircle class="size-[1rem] animate-spin" />- </>- ) : (- "Create Shareable Link"+ {Object.values(Menu).map((section) => (+ <div+ class={cx(+ "flex gap-4 items-center px-4 h-full",+ section === Menu.center &&+ "border-r border-l border-r-gray-200 border-l-gray-200")}- </Button>- }- >- {(sharing) => {- const url = () => new URL(sharing().link);-- return (- <div class="flex flex-row items-center gap-2">- <Tooltip.Root openDelay={0} closeDelay={0}>- <Tooltip.Trigger>- <Button- disabled={uploadVideo.isPending}- onClick={(e) => uploadVideo.mutate()}- variant="secondary"- class="flex items-center space-x-1"- >- {uploadVideo.isPending ? (- <IconLucideLoaderCircle class="size-[1rem] animate-spin" />- ) : (- <IconLucideRotateCcw class="size-[1rem]" />- )}- </Button>- </Tooltip.Trigger>- <Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">- {uploadVideo.isPending- ? "Reuploading video"- : "Reupload video"}- <Tooltip.Arrow class="fill-gray-500" />- </Tooltip.Content>- </Tooltip.Portal>- </Tooltip.Root>- <a- class="rounded-full h-[2rem] px-[1rem] flex flex-row items-center gap-[0.375rem] bg-gray-200 hover:bg-gray-300 transition-colors duration-100"- href={sharing().link}- target="_blank"- rel="noreferrer"- >- <span class="text-[0.875rem] text-gray-500">- {url().host}- {url().pathname}- </span>- </a>- </div>- );- }}- </Show>- <Dialog.Root open={!uploadVideo.isIdle}>- <DialogContent- title={- uploadState.type === "uploading"- ? "Creating Shareable Link"- : uploadState.type === "link-copied"- ? "Link Copied"- : "Exporting Recording"- }- confirm={<></>}- close={<></>}- class="bg-gray-600 text-gray-500 dark:text-gray-500"- >- <div class="w-[80%] text-center mx-auto relative z-10 space-y-6 py-4">- <div class="w-full bg-gray-200 rounded-full h-2.5 mb-2">- <div- class="bg-blue-300 h-2.5 rounded-full"- style={{- width: `${- uploadState.type === "uploading"- ? uploadState.progress- : uploadState.type === "link-copied"- ? 100- : uploadState.type === "rendering"- ? Math.min(- (uploadState.renderedFrames /- uploadState.totalFrames) *- 100,- 100- )- : 0- }%`,- }}- />- </div>-- <p class="text-xs text-white mt-3 relative z-10">- {uploadState.type == "idle" || uploadState.type === "starting"- ? "Preparing to render..."- : uploadState.type === "rendering"- ? `Rendering video (${uploadState.renderedFrames}/${uploadState.totalFrames} frames)`- : uploadState.type === "uploading"- ? `Uploading - ${Math.floor(uploadState.progress)}%`- : "Link copied to clipboard!"}- </p>+ >+ {section.map((item) => (+ <>{item.button({ editorContext })}</>+ ))}</div>- </DialogContent>- </Dialog.Root>+ ))}+ </div>+ <Titlebar /></div>);}--function createProgressBar(progress: () => number | undefined) {- const currentWindow = getCurrentWindow();-- createEffect(() => {- const p = progress();- console.log({ p });- if (p === undefined)- currentWindow.setProgressBar({ status: ProgressBarStatus.None });- else currentWindow.setProgressBar({ progress: Math.round(p) });- });-}diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsxindex 03e6b148f..81e5ae93d 100644--- a/apps/desktop/src/routes/editor/Player.tsx+++ b/apps/desktop/src/routes/editor/Player.tsx@@ -1,24 +1,15 @@import { DropdownMenu as KDropdownMenu } from "@kobalte/core/dropdown-menu";import { Select as KSelect } from "@kobalte/core/select";import { ToggleButton as KToggleButton } from "@kobalte/core/toggle-button";-import { createEventListener } from "@solid-primitives/event-listener";import { createElementBounds } from "@solid-primitives/bounds";+import { createEventListener } from "@solid-primitives/event-listener";import { cx } from "cva";-import {- For,- Show,- Suspense,- createEffect,- createResource,- createSignal,- on,-} from "solid-js";+import { For, Show, Suspense, createEffect, createSignal } from "solid-js";import { reconcile } from "solid-js/store";import { type AspectRatio, commands } from "~/utils/tauri";import { FPS, OUTPUT_SIZE, useEditorContext } from "./context";import { ASPECT_RATIOS } from "./projectConfig";-import { authStore } from "~/store";import {ComingSoonTooltip,DropdownItem,@@ -129,51 +120,8 @@ export function Player() {});return (- <div class="flex flex-col divide-y flex-1">- <div class="flex flex-row justify-between font-medium p-[0.75rem] text-[0.875rem] z-10 bg-gray-50">- <div class="flex flex-row items-center gap-[0.5rem]">- <AspectRatioSelect />- <EditorButton- leftIcon={<IconCapCrop />}- onClick={() => {- const display = editorInstance.recordings.segments[0].display;- setDialog({- open: true,- type: "crop",- position: {- ...(project.background.crop?.position ?? { x: 0, y: 0 }),- },- size: {- ...(project.background.crop?.size ?? {- x: display.width,- y: display.height,- }),- },- });- }}- >- Crop- </EditorButton>- <PresetsDropdown />- </div>- <div class="flex flex-row place-items-center gap-2">- <EditorButton- disabled={!history.canUndo()}- leftIcon={<IconCapUndo />}- onClick={() => history.undo()}- >- Undo- </EditorButton>- <EditorButton- disabled={!history.canRedo()}- leftIcon={<IconCapRedo />}- onClick={() => history.redo()}- >- Redo- </EditorButton>- </div>- </div>- <div ref={setCanvasContainerRef} class="bg-gray-100 flex-1 relative">+ <div class="flex flex-col flex-1 divide-y">+ <div ref={setCanvasContainerRef} class="relative flex-1 bg-gray-50"><Show when={latestFrame()}>{(currentFrame) => {const padding = 16;@@ -224,7 +172,7 @@ export function Player() {width: `${size().width}px`,height: `${size().height}px`,}}- class="bg-blue-50 absolute rounded"+ class="absolute bg-blue-50 rounded"ref={canvasRef}id="canvas"width={currentFrame().width}@@ -235,7 +183,7 @@ export function Player() {</Show></div><div class="flex flex-row items-center p-[0.75rem] gap-[0.5rem] z-10 bg-gray-50 justify-between">- <div class="flex-1 flex items-center">+ <div class="flex flex-1 items-center"><div class="flex-1" /><Time seconds={Math.max(previewTime() ?? playbackTime(), 0)} /></div>@@ -253,7 +201,7 @@ export function Player() {<buttontype="button"onClick={handlePlayPauseClick}- class="hover:text-black transition-colors"+ class="transition-colors hover:text-black">{!playing() || isAtEnd() ? (<IconCapPlayCircle class="size-[1.5rem]" />@@ -272,7 +220,7 @@ export function Player() {<IconCapFrameLast class="size-[1.2rem]" /></button></div>- <div class="flex-1 flex flex-row justify-end items-center gap-2">+ <div class="flex flex-row flex-1 gap-2 justify-end items-center"><Time seconds={totalDuration()} /><div class="flex-1" />{window.FLAGS.split ? (@@ -403,12 +351,12 @@ function PresetsDropdown() {><MenuItemList<typeof KDropdownMenu.Group>as={KDropdownMenu.Group}- class="flex-1 overflow-y-auto scrollbar-none"+ class="overflow-y-auto flex-1 scrollbar-none"><Foreach={presets.query.data?.presets ?? []}fallback={- <div class="w-full text-sm text-gray-400 text-center py-1">+ <div class="py-1 w-full text-sm text-center text-gray-400">No Presets</div>}@@ -449,7 +397,7 @@ function PresetsDropdown() {<MenuItemList<typeof KDropdownMenu.SubContent>as={KDropdownMenu.SubContent}class={cx(- "animate-in fade-in slide-in-from-left-1 w-44",+ "w-44 animate-in fade-in slide-in-from-left-1",dropdownContainerClasses)}>diff --git a/apps/desktop/src/routes/editor/PresetsDropdown.tsx b/apps/desktop/src/routes/editor/PresetsDropdown.tsxnew file mode 100644index 000000000..6a3a0b0bd--- /dev/null+++ b/apps/desktop/src/routes/editor/PresetsDropdown.tsx@@ -0,0 +1,146 @@+import { DropdownMenu as KDropdownMenu } from "@kobalte/core/dropdown-menu";+import { cx } from "cva";+import { For, Show, Suspense, createSignal } from "solid-js";+import { reconcile } from "solid-js/store";++import { useEditorContext } from "./context";+import {+ DropdownItem,+ EditorButton,+ MenuItem,+ MenuItemList,+ PopperContent,+ dropdownContainerClasses,+ topLeftAnimateClasses,+} from "./ui";++function PresetsDropdown() {+ const { setDialog, presets, setProject } = useEditorContext();++ return (+ <KDropdownMenu gutter={8}>+ <EditorButton<typeof KDropdownMenu.Trigger>+ as={KDropdownMenu.Trigger}+ leftIcon={<IconCapPresets />}+ >+ Presets+ </EditorButton>+ <KDropdownMenu.Portal>+ <Suspense>+ <PopperContent<typeof KDropdownMenu.Content>+ as={KDropdownMenu.Content}+ class={cx("w-72 max-h-56", topLeftAnimateClasses)}+ >+ <MenuItemList<typeof KDropdownMenu.Group>+ as={KDropdownMenu.Group}+ class="overflow-y-auto flex-1 scrollbar-none"+ >+ <For+ each={presets.query.data?.presets ?? []}+ fallback={+ <div class="py-1 w-full text-sm text-center text-gray-400">+ No Presets+ </div>+ }+ >+ {(preset, i) => {+ const [showSettings, setShowSettings] = createSignal(false);++ return (+ <KDropdownMenu.Sub gutter={16}>+ <MenuItem<typeof KDropdownMenu.SubTrigger>+ as={KDropdownMenu.SubTrigger}+ onFocusIn={() => setShowSettings(false)}+ onClick={() => setShowSettings(false)}+ >+ <span class="mr-auto">{preset.name}</span>+ <Show when={presets.query.data?.default === i()}>+ <span class="px-[0.375rem] h-[1.25rem] rounded-full bg-gray-100 text-gray-400 text-[0.75rem]">+ Default+ </span>+ </Show>+ <button+ type="button"+ class="text-gray-400 hover:text-[currentColor]"+ onClick={(e) => {+ e.stopPropagation();+ setShowSettings((s) => !s);+ }}+ onPointerUp={(e) => {+ e.stopPropagation();+ e.preventDefault();+ }}+ >+ <IconCapSettings />+ </button>+ </MenuItem>+ <KDropdownMenu.Portal>+ {showSettings() && (+ <MenuItemList<typeof KDropdownMenu.SubContent>+ as={KDropdownMenu.SubContent}+ class={cx(+ "w-44 animate-in fade-in slide-in-from-left-1",+ dropdownContainerClasses+ )}+ >+ <DropdownItem+ onSelect={() =>+ setProject(reconcile(preset.config))+ }+ >+ Apply+ </DropdownItem>+ <DropdownItem+ onSelect={() => presets.setDefault(i())}+ >+ Set as default+ </DropdownItem>+ <DropdownItem+ onSelect={() =>+ setDialog({+ type: "renamePreset",+ presetIndex: i(),+ open: true,+ })+ }+ >+ Rename+ </DropdownItem>+ <DropdownItem+ onClick={() =>+ setDialog({+ type: "deletePreset",+ presetIndex: i(),+ open: true,+ })+ }+ >+ Delete+ </DropdownItem>+ </MenuItemList>+ )}+ </KDropdownMenu.Portal>+ </KDropdownMenu.Sub>+ );+ }}+ </For>+ </MenuItemList>+ <MenuItemList<typeof KDropdownMenu.Group>+ as={KDropdownMenu.Group}+ class="border-t shrink-0"+ >+ <DropdownItem+ onSelect={() => setDialog({ type: "createPreset", open: true })}+ >+ <span>Create new preset</span>+ <IconCapCirclePlus class="ml-auto" />+ </DropdownItem>+ </MenuItemList>+ </PopperContent>+ </Suspense>+ </KDropdownMenu.Portal>+ </KDropdownMenu>+ );+}++export default PresetsDropdown;diff --git a/apps/desktop/src/routes/editor/ShareButton.tsx b/apps/desktop/src/routes/editor/ShareButton.tsxnew file mode 100644index 000000000..eafd094c9--- /dev/null+++ b/apps/desktop/src/routes/editor/ShareButton.tsx@@ -0,0 +1,296 @@+import { Button } from "@cap/ui-solid";+import { Tooltip } from "@kobalte/core";+import { createMutation } from "@tanstack/solid-query";+import { createResource, Show } from "solid-js";+import { createStore, produce } from "solid-js/store";++import { Channel } from "@tauri-apps/api/core";+import { createProgressBar } from "~/routes/editor/utils";+import { authStore } from "~/store";+import { trackEvent } from "~/utils/analytics";+import { commands, events, RenderProgress } from "~/utils/tauri";+import { useEditorContext } from "./context";+import { RESOLUTION_OPTIONS, ResolutionOption } from "./Header";+import { Dialog, DialogContent } from "./ui";++function ShareButton(props: {+ selectedResolution: () => ResolutionOption;+ selectedFps: () => number;+}) {+ const { videoId, project } = useEditorContext();+ const [recordingMeta, metaActions] = createResource(() =>+ commands.getRecordingMeta(videoId, "recording")+ );++ const uploadVideo = createMutation(() => ({+ mutationFn: async () => {+ setUploadState({ type: "idle" });++ console.log("Starting upload process...");++ // Check authentication first+ const existingAuth = await authStore.get();+ if (!existingAuth) {+ await commands.showWindow("SignIn");+ throw new Error("You need to sign in to share recordings");+ }++ trackEvent("create_shareable_link_clicked", {+ resolution: props.selectedResolution().value,+ fps: props.selectedFps(),+ has_existing_auth: !!existingAuth,+ });++ const meta = recordingMeta();+ if (!meta) {+ console.error("No recording metadata available");+ throw new Error("Recording metadata not available");+ }++ const metadata = await commands.getVideoMetadata(videoId, null);+ const plan = await commands.checkUpgradedAndUpdate();+ const canShare = {+ allowed: plan || metadata.duration < 300,+ reason: !plan && metadata.duration >= 300 ? "upgrade_required" : null,+ };++ if (!canShare.allowed) {+ if (canShare.reason === "upgrade_required") {+ await commands.showWindow("Upgrade");+ throw new Error(+ "Upgrade required to share recordings longer than 5 minutes"+ );+ }+ }++ const unlisten = await events.uploadProgress.listen((event) => {+ console.log("Upload progress event:", event.payload);+ setUploadState(+ produce((state) => {+ if (state.type !== "uploading") return;++ state.progress = Math.round(event.payload.progress * 100);+ })+ );+ });++ try {+ setUploadState({ type: "starting" });++ // Setup progress listener before starting upload++ console.log("Starting actual upload...");++ const progress = new Channel<RenderProgress>();++ progress.onmessage = (msg) => {+ if (msg.type === "EstimatedTotalFrames")+ setUploadState({+ type: "rendering",+ renderedFrames: 0,+ totalFrames: msg.total_frames,+ });+ else+ setUploadState(+ produce((state) => {+ if (msg.type === "FrameRendered" && state.type === "rendering")+ state.renderedFrames = msg.current_frame;+ })+ );+ };++ await commands.exportVideo(+ videoId,+ progress,+ true,+ props.selectedFps(),+ {+ x: props.selectedResolution()?.width || RESOLUTION_OPTIONS[0].width,+ y:+ props.selectedResolution()?.height ||+ RESOLUTION_OPTIONS[0].height,+ }+ );++ setUploadState({ type: "uploading", progress: 0 });++ // Now proceed with upload+ const result = recordingMeta()?.sharing+ ? await commands.uploadExportedVideo(videoId, "Reupload")+ : await commands.uploadExportedVideo(videoId, {+ Initial: { pre_created_video: null },+ });++ if (result === "NotAuthenticated") {+ await commands.showWindow("SignIn");+ throw new Error("You need to sign in to share recordings");+ } else if (result === "PlanCheckFailed")+ throw new Error("Failed to verify your subscription status");+ else if (result === "UpgradeRequired")+ throw new Error("This feature requires an upgraded plan");++ setUploadState({ type: "link-copied" });++ return result;+ } catch (error) {+ console.error("Upload error:", error);+ throw error instanceof Error+ ? error+ : new Error("Failed to upload recording");+ } finally {+ unlisten();+ }+ },+ onSuccess: () => {+ metaActions.refetch();+ },+ onError: (error) => {+ commands.globalMessageDialog(+ error instanceof Error ? error.message : "Failed to upload recording"+ );+ },+ onSettled() {+ setTimeout(() => {+ setUploadState({ type: "idle" });+ uploadVideo.reset();+ }, 2000);+ },+ }));++ const [uploadState, setUploadState] = createStore<+ | { type: "idle" }+ | { type: "starting" }+ | { type: "rendering"; renderedFrames: number; totalFrames: number }+ | { type: "uploading"; progress: number }+ | { type: "link-copied" }+ >({ type: "idle" });++ 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 (+ <div class="relative">+ <Show+ when={recordingMeta.latest?.sharing}+ fallback={+ <Button+ disabled={uploadVideo.isPending}+ onClick={(e) => uploadVideo.mutate()}+ variant="primary"+ class="flex gap-2 items-center"+ >+ <IconCapLink class="size-5" />+ {uploadVideo.isPending ? (+ <>+ <span>Uploading Cap</span>+ <IconLucideLoaderCircle class="size-[1rem] animate-spin" />+ </>+ ) : (+ "Shareable Link"+ )}+ </Button>+ }+ >+ {(sharing) => {+ const url = () => new URL(sharing().link);++ return (+ <div class="flex flex-row gap-2 items-center">+ <Tooltip.Root openDelay={0} closeDelay={0}>+ <Tooltip.Trigger>+ <Button+ disabled={uploadVideo.isPending}+ onClick={(e) => uploadVideo.mutate()}+ variant="secondary"+ class="flex items-center space-x-1"+ >+ {uploadVideo.isPending ? (+ <IconLucideLoaderCircle class="size-[1rem] animate-spin" />+ ) : (+ <IconLucideRotateCcw class="size-[1rem]" />+ )}+ </Button>+ </Tooltip.Trigger>+ <Tooltip.Portal>+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg duration-100 animate-in fade-in">+ {uploadVideo.isPending+ ? "Reuploading video"+ : "Reupload video"}+ <Tooltip.Arrow class="fill-gray-500" />+ </Tooltip.Content>+ </Tooltip.Portal>+ </Tooltip.Root>+ <a+ class="rounded-full h-[2rem] px-[1rem] flex flex-row items-center gap-[0.375rem] bg-gray-200 hover:bg-gray-300 transition-colors duration-100"+ href={sharing().link}+ target="_blank"+ rel="noreferrer"+ >+ <span class="text-[0.875rem] text-gray-500">+ {url().host}+ {url().pathname}+ </span>+ </a>+ </div>+ );+ }}+ </Show>+ <Dialog.Root open={!uploadVideo.isIdle}>+ <DialogContent+ title={+ uploadState.type === "uploading"+ ? "Creating Shareable Link"+ : uploadState.type === "link-copied"+ ? "Link Copied"+ : "Exporting Recording"+ }+ confirm={<></>}+ close={<></>}+ class="text-gray-500 bg-gray-600 dark:text-gray-500"+ >+ <div class="w-[80%] text-center mx-auto relative z-10 space-y-6 py-4">+ <div class="w-full bg-gray-200 rounded-full h-2.5 mb-2">+ <div+ class="bg-blue-300 h-2.5 rounded-full"+ style={{+ width: `${+ uploadState.type === "uploading"+ ? uploadState.progress+ : uploadState.type === "link-copied"+ ? 100+ : uploadState.type === "rendering"+ ? Math.min(+ (uploadState.renderedFrames /+ uploadState.totalFrames) *+ 100,+ 100+ )+ : 0+ }%`,+ }}+ />+ </div>++ <p class="relative z-10 mt-3 text-xs text-white">+ {uploadState.type == "idle" || uploadState.type === "starting"+ ? "Preparing to render..."+ : uploadState.type === "rendering"+ ? `Rendering video (${uploadState.renderedFrames}/${uploadState.totalFrames} frames)`+ : uploadState.type === "uploading"+ ? `Uploading - ${Math.floor(uploadState.progress)}%`+ : "Link copied to clipboard!"}+ </p>+ </div>+ </DialogContent>+ </Dialog.Root>+ </div>+ );+}++export default ShareButton;diff --git a/apps/desktop/src/routes/editor/ui.tsx b/apps/desktop/src/routes/editor/ui.tsxindex 0bd9229f1..34eb1fd40 100644--- a/apps/desktop/src/routes/editor/ui.tsx+++ b/apps/desktop/src/routes/editor/ui.tsx@@ -7,13 +7,14 @@ import { Switch as KSwitch } from "@kobalte/core/switch";import { Tooltip as KTooltip } from "@kobalte/core/tooltip";import { cva, cx, type VariantProps } from "cva";import {+ mergeProps,+ splitProps,type ComponentProps,type JSX,type ParentProps,type ValidComponent,- mergeProps,- splitProps,} from "solid-js";+import Tooltip from "~/components/Tooltip";import { useEditorContext } from "./context";import { TextInput } from "./TextInput";@@ -45,7 +46,7 @@ export function Subfield(><span>{props.name}- {props.required && <span class="text-blue-500 ml-px">*</span>}+ {props.required && <span class="ml-px text-blue-500">*</span>}</span>{props.children}</div>@@ -84,7 +85,7 @@ export function Slider(props: ComponentProps<typeof KSlider>) {}}><KSlider.Track class="h-[0.5rem] relative mx-1">- <KSlider.Fill class="absolute bg-blue-100 ui-disabled:bg-gray-300 h-full rounded-full -ml-2" />+ <KSlider.Fill class="absolute -ml-2 h-full bg-blue-100 rounded-full ui-disabled:bg-gray-300" /><KSlider.Thumbclass={cx("size-[1.25rem] bg-blue-300 -top-1.5 rounded-full outline-none outline-2 outline-offset-2 focus-visible:outline-blue-300 ui-disabled:bg-gray-400"@@ -120,7 +121,7 @@ export const Dialog = {{!props.hideOverlay && (<KDialog.Overlay class="fixed inset-0 z-50 bg-[#000]/80 ui-expanded:animate-in ui-expanded:fade-in ui-closed:animate-out ui-closed:fade-out" />)}- <div class="fixed inset-0 z-50 flex items-center justify-center">+ <div class="flex fixed inset-0 z-50 justify-center items-center"><KDialog.Contentclass={cx("z-50 divide-y text-sm rounded-[1.25rem] overflow-hidden border border-gray-200 bg-gray-50 min-w-[22rem] ui-expanded:animate-in ui-expanded:fade-in ui-expanded:zoom-in-95 origin-top ui-closed:animate-out ui-closed:fade-out ui-closed:zoom-out-95",@@ -204,7 +205,7 @@ export function MenuItem<T extends ValidComponent = "button">(class={cx(props.class,"flex flex-row shrink-0 items-center gap-[0.375rem] px-[0.675rem] py-[0.375rem] rounded-[0.5rem] outline-none text-nowrap overflow-hidden text-ellipsis w-full max-w-full",- "text-[0.875rem] text-gray-400 disabled:text-gray-400 ui-highlighted:bg-gray-100 ui-highlighted:text-gray-500"+ "text-[0.875rem] text-gray-400 disabled:text-gray-400 ui-highlighted:bg-gray-200 ui-highlighted:text-gray-500")}/>);@@ -243,16 +244,16 @@ export function MenuItemList<T extends ValidComponent = "div">(const editorButtonStyles = cva(["group flex flex-row items-center px-[0.375rem] gap-[0.375rem] h-[2rem] rounded-[0.5rem] text-[0.875rem]",- "focus-visible:outline outline-2 outline-offset-2 transition-colors duration-100",- "disabled:bg-gray-100 disabled:text-gray-400",+ "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 transition-colors duration-100",+ "disabled:opacity-50 disabled:text-gray-400",],{variants: {variant: {primary:- "text-gray-500 enabled:hover:ui-not-pressed:bg-gray-100 ui-expanded:bg-gray-100 outline-blue-300",+ "text-gray-500 enabled:hover:ui-not-pressed:bg-gray-200 ui-expanded:bg-gray-200 outline-blue-300 focus:bg-gray-200",danger:- "text-gray-500 enabled:hover:ui-not-pressed:bg-gray-100 ui-expanded:bg-red-300 ui-pressed:bg-red-300 ui-expanded:text-gray-50 ui-pressed:text-gray-50 outline-red-300",+ "text-gray-500 enabled:hover:ui-not-pressed:bg-gray-200 ui-expanded:bg-red-300 ui-pressed:bg-red-300 ui-expanded:text-gray-50 ui-pressed:text-gray-50 outline-red-300",},},defaultVariants: { variant: "primary" },@@ -263,9 +264,9 @@ const editorButtonLeftIconStyles = cva("transition-colors duration-100", {variants: {variant: {primary:- "text-gray-400 enabled:group-hover:not-ui-group-disabled:text-gray-500 ui-group-expanded:text-gray-500",+ "text-gray-500 enabled:group-hover:not-ui-group-disabled:text-gray-500 ui-group-expanded:text-gray-500",danger:- "text-gray-400 enabled:group-hover:text-gray-500 ui-group-expanded:text-gray-50 ui-group-pressed:text-gray-50",+ "text-gray-500 enabled:group-hover:text-gray-500 ui-group-expanded:text-gray-50 ui-group-pressed:text-gray-50",},},defaultVariants: { variant: "primary" },@@ -273,8 +274,12 @@ const editorButtonLeftIconStyles = cva("transition-colors duration-100", {type EditorButtonProps<T extends ValidComponent = "button"> =PolymorphicProps<T> & {+ children?: JSX.Element | string;leftIcon?: JSX.Element;rightIcon?: JSX.Element;+ tooltipText?: string;+ comingSoon?: boolean;+ rightIconEnd?: boolean;} & VariantProps<typeof editorButtonStyles>;export function EditorButton<T extends ValidComponent = "button">(@@ -282,22 +287,60 @@ export function EditorButton<T extends ValidComponent = "button">() {const [local, cvaProps, others] = splitProps(mergeProps({ variant: "primary" }, props) as unknown as EditorButtonProps,- ["children", "leftIcon", "rightIcon"],+ [+ "children",+ "leftIcon",+ "rightIcon",+ "tooltipText",+ "comingSoon",+ "rightIconEnd",+ ],["class", "variant"]);- return (- <Polymorphic- as="button"- {...others}- class={editorButtonStyles({ ...cvaProps, class: cvaProps.class })}- >+ const buttonContent = (+ <><span class={editorButtonLeftIconStyles({ variant: cvaProps.variant })}>{local.leftIcon}</span>- <span>{local.children}</span>- <span class="text-gray-400">{local.rightIcon}</span>- </Polymorphic>+ {local.children && <span>{local.children}</span>}+ {local.rightIcon && (+ <span class={local.rightIconEnd ? "ml-auto" : ""}>+ {local.rightIcon}+ </span>+ )}+ </>+ );++ return (+ <>+ {local.tooltipText || local.comingSoon ? (+ <Tooltip content={local.comingSoon ? "Coming soon" : local.tooltipText}>+ <Polymorphic+ as="button"+ {...others}+ class={cx(+ editorButtonStyles({ ...cvaProps, class: cvaProps.class }),+ local.rightIconEnd && "justify-between"+ )}+ disabled={local.comingSoon}+ >+ {buttonContent}+ </Polymorphic>+ </Tooltip>+ ) : (+ <Polymorphic+ as="button"+ {...others}+ class={cx(+ editorButtonStyles({ ...cvaProps, class: cvaProps.class }),+ local.rightIconEnd && "justify-between"+ )}+ >+ {buttonContent}+ </Polymorphic>+ )}+ </>);}diff --git a/apps/desktop/src/routes/editor/utils.ts b/apps/desktop/src/routes/editor/utils.tsindex aef7c011e..7fd6d14bd 100644--- a/apps/desktop/src/routes/editor/utils.ts+++ b/apps/desktop/src/routes/editor/utils.ts@@ -11,3 +11,18 @@ export function formatTime(secs: number, fps?: number) {return str;}++import { getCurrentWindow, ProgressBarStatus } from "@tauri-apps/api/window";+import { createEffect } from "solid-js";++export function createProgressBar(progress: () => number | undefined) {+ const currentWindow = getCurrentWindow();++ createEffect(() => {+ const p = progress();+ console.log({ p });+ if (p === undefined)+ currentWindow.setProgressBar({ status: ProgressBarStatus.None });+ else currentWindow.setProgressBar({ progress: Math.round(p) });+ });+ }\ No newline at end of filediff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.cssindex c218342dd..7402f0bd5 100644--- a/apps/desktop/src/styles/theme.css+++ b/apps/desktop/src/styles/theme.css@@ -7,6 +7,7 @@--gray-200: #e7eaf0;--gray-300: #c9cedb;--gray-400: #8991a3;+ --gray-450: #F3F3F3;--gray-500: #12161f;--text-primary: rgba(18, 22, 31, 0.95); /* Section titles, headings */@@ -30,6 +31,7 @@--blue-200: #85adff;--blue-300: #4785ff;--blue-400: #3f75e0;+ --blue-500: rgb(54, 102, 197);--blue-transparent-10: rgba(34, 64, 122, 0.1);--blue-transparent-20: rgba(34, 64, 122, 0.2);@@ -43,16 +45,18 @@--red-transparent-20: rgba(255, 71, 102, 0.2);--shadow-s: 0px 8px 16px 0px rgba(18, 22, 31, 0.04);+}/* Dark theme variables */:root.dark {/* Main background colors */- --gray-50: #1e1e1e; /* Main background */- --gray-100: #242424; /* Secondary background */- --gray-200: #2a2a2a; /* Borders and dividers */+ --gray-50: #161616; /* Main background */+ --gray-100: #191919; /* Secondary background */+ --gray-200: #232323; /* Borders and dividers */--gray-300: #3a3a3a; /* Subtle highlights */--gray-400: #9d9d9d; /* Secondary text - descriptions */+ --gray-450: #F3F3F3;--gray-500: #ffffff; /* Primary text - titles/headings (back to white) *//* Add new variables for text hierarchy */diff --git a/apps/desktop/src/utils/titlebar-state.ts b/apps/desktop/src/utils/titlebar-state.tsindex 4f76aefe5..a4e2c4962 100644--- a/apps/desktop/src/utils/titlebar-state.ts+++ b/apps/desktop/src/utils/titlebar-state.ts@@ -1,8 +1,8 @@-import { createStore } from "solid-js/store";-import type { JSX } from "solid-js";+import type { UnlistenFn } from "@tauri-apps/api/event";import { getCurrentWindow } from "@tauri-apps/api/window";import { type as ostype } from "@tauri-apps/plugin-os";-import type { UnlistenFn } from "@tauri-apps/api/event";+import type { JSX } from "solid-js";+import { createStore } from "solid-js/store";export interface TitlebarState {height: string;@@ -14,6 +14,7 @@ export interface TitlebarState {minimizable: boolean;closable: boolean;border: boolean;+ backgroundColor: string | null;transparent: boolean;}@@ -27,6 +28,7 @@ const [state, setState] = createStore<TitlebarState>({minimizable: true,closable: true,border: true,+ backgroundColor: null,transparent: false,});@@ -54,5 +56,5 @@ async function initializeTitlebar(): Promise<UnlistenFn | undefined> {});}-export { setState as setTitlebar, initializeTitlebar };+export { initializeTitlebar, setState as setTitlebar };export default state;diff --git a/packages/ui-solid/icons/captions.svg b/packages/ui-solid/icons/captions.svgnew file mode 100644index 000000000..16b2c91d2--- /dev/null+++ b/packages/ui-solid/icons/captions.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-captions"><rect width="18" height="14" x="3" y="5" rx="2" ry="2"/><path d="M7 15h4M15 15h2M7 11h2M13 11h4"/></svg>\ No newline at end of filediff --git a/packages/ui-solid/icons/gauge.svg b/packages/ui-solid/icons/gauge.svgnew file mode 100644index 000000000..e958ac9dc--- /dev/null+++ b/packages/ui-solid/icons/gauge.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-gauge"><path d="M15.6 2.7a10 10 0 1 0 5.7 5.7"/><circle cx="12" cy="12" r="2"/><path d="M13.4 10.6 19 5"/></svg>\ No newline at end of filediff --git a/packages/ui-solid/icons/link.svg b/packages/ui-solid/icons/link.svgnew file mode 100644index 000000000..9d699e586--- /dev/null+++ b/packages/ui-solid/icons/link.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>\ No newline at end of filediff --git a/packages/ui-solid/src/Button.tsx b/packages/ui-solid/src/Button.tsxindex 4b6e656b8..b23766e25 100644--- a/packages/ui-solid/src/Button.tsx+++ b/packages/ui-solid/src/Button.tsx@@ -2,7 +2,7 @@ import { cva, type VariantProps } from "cva";import type { ComponentProps } from "solid-js";const styles = cva(- "rounded-full outline-offset-2 outline-2 focus-visible:outline",+ "rounded-xl outline-offset-2 outline-2 focus-visible:outline transition-all duration-200",{defaultVariants: {variant: "primary",@@ -11,18 +11,18 @@ const styles = cva(variants: {variant: {primary:- "bg-blue-300 text-gray-50 dark:text-gray-500 hover:bg-blue-400 disabled:bg-blue-200 outline-blue-300",+ "bg-blue-300 text-gray-50 hover:-translate-y-px shadow-[0_0_0_0_rgba(54,102,197,1)] hover:shadow-[0_3px_0_0_rgba(54,102,197,1)] dark:hover:shadow-[0_3px_0_0_rgba(71,133,255,0.50)] dark:text-gray-500 disabled:bg-blue-200 outline-blue-300",secondary:- "bg-gray-200 text-gray-500 hover:bg-gray-300 disabled:bg-gray-200 disabled:text-gray-400 outline-blue-300",+ "bg-gray-200 hover:-translate-y-px shadow-[0_0_0_0_rgba(0,0,0,0.20)] hover:shadow-[0_3px_0_0_rgba(0,0,0,0.20)] dark:shadow-[0_0_0_0_rgba(255,255,255,0.20)] hover:dark:shadow-[0_3px_0_0_rgba(255,255,255,0.10)] text-gray-500 disabled:bg-gray-200 disabled:text-gray-400 outline-blue-300",destructive:"bg-red-300 text-gray-50 dark:text-gray-500 hover:bg-red-400 disabled:bg-red-200 outline-red-300",white:- "bg-gray-50 dark:bg-gray-500 text-gray-500 dark:text-gray-50 hover:bg-gray-100 disabled:bg-gray-50 disabled:text-gray-400 outline-blue-300",+ "bg-gray-100 dark:bg-gray-500 hover:-translate-y-px shadow-[0_0_0_0_rgba(255,255,255,0.50)] dark:hover:shadow-[0_3px_0_0_rgba(255,255,255,0.50)] hover:shadow-[0_3px_0_0_rgba(0,0,0,0.10)] text-gray-500 dark:disabled:bg-gray-300 dark:disabled:text-gray-400 dark:text-gray-50 disabled:bg-gray-400 disabled:text-gray-400 outline-blue-300",},size: {xs: "font-[400] text-[0.75rem] px-[0.5rem] h-[1.25rem] ",sm: "font-[400] text-[0.875rem] px-[0.75rem] h-[1.75rem]",- md: "font-[400] text-[0.875rem] px-[1rem] h-[2rem]",+ md: "font-[400] text-sm px-4 py-2.5",lg: "font-[400] text-[0.875rem] px-[1rem] h-[2.25rem]",},},diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex e3a4ff7af..3cb20517d 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -8,8 +8,10 @@ export {}declare global {const IconCapArrows: typeof import('~icons/cap/arrows.jsx')['default']const IconCapAudioOn: typeof import('~icons/cap/audio-on.jsx')['default']+ const IconCapAuto: typeof import('~icons/cap/auto.jsx')['default']const IconCapBlur: typeof import('~icons/cap/blur.jsx')['default']const IconCapCamera: typeof import('~icons/cap/camera.jsx')['default']+ const IconCapCaptions: typeof import('~icons/cap/captions.jsx')['default']const IconCapChevronDown: typeof import('~icons/cap/chevron-down.jsx')['default']const IconCapCircleCheck: typeof import('~icons/cap/circle-check.jsx')['default']const IconCapCirclePlus: typeof import('~icons/cap/circle-plus.jsx')['default']@@ -25,12 +27,14 @@ declare global {const IconCapFilmCut: typeof import('~icons/cap/film-cut.jsx')['default']const IconCapFrameFirst: typeof import('~icons/cap/frame-first.jsx')['default']const IconCapFrameLast: typeof import('~icons/cap/frame-last.jsx')['default']+ const IconCapGauge: typeof import('~icons/cap/gauge.jsx')['default']const IconCapHotkeys: typeof import('~icons/cap/hotkeys.jsx')['default']const IconCapImage: typeof import('~icons/cap/image.jsx')['default']const IconCapInfo: typeof import('~icons/cap/info.jsx')['default']const IconCapInset: typeof import('~icons/cap/inset.jsx')['default']const IconCapInstant: typeof import('~icons/cap/instant.jsx')['default']const IconCapLayout: typeof import('~icons/cap/layout.jsx')['default']+ const IconCapLink: typeof import('~icons/cap/link.jsx')['default']const IconCapLogo: typeof import('~icons/cap/logo.jsx')['default']const IconCapLogoFull: typeof import('~icons/cap/logo-full.jsx')['default']const IconCapLogoFullDark: typeof import('~icons/cap/logo-full-dark.jsx')['default']diff --git a/packages/ui-solid/tailwind.config.js b/packages/ui-solid/tailwind.config.jsindex e36e5bbbe..7c63e7c6a 100644--- a/packages/ui-solid/tailwind.config.js+++ b/packages/ui-solid/tailwind.config.js@@ -14,6 +14,7 @@ module.exports = {200: "var(--gray-200)",300: "var(--gray-300)",400: "var(--gray-400)",+ 450: "var(--gray-450)",500: "var(--gray-500)",},"black-transparent": {