Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip

ameer24689f7b03c97be5
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index a8bba6f43..ac1282fdb 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -19,8 +19,9 @@ 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 { type Crop, events } from "~/utils/tauri";
+import { events, type Crop } from "~/utils/tauri";
import { ConfigSidebar } from "./ConfigSidebar";
import {
EditorContextProvider,
@@ -30,6 +31,7 @@ import {
useEditorContext,
useEditorInstanceContext,
} from "./context";
+import ExportDialog from "./ExportDialog";
import { Header } from "./Header";
import { Player } from "./Player";
import { Timeline } from "./Timeline";
@@ -41,7 +43,6 @@ import {
Subfield,
Toggle,
} from "./ui";
-import { cx } from "cva";
export function Editor() {
const [params] = useSearchParams<{ id: string }>();
@@ -147,6 +148,11 @@ function Dialogs() {
if ("type" in d && d.type === "crop") return "lg";
return "sm";
})()}
+ contentClass={(() => {
+ const d = dialog();
+ if ("type" in d && d.type === "export") return "max-w-[740px]";
+ return "";
+ })()}
open={dialog().open}
onOpenChange={(o) => {
if (!o) setDialog((d) => ({ ...d, open: false }));
@@ -160,6 +166,9 @@ function Dialogs() {
>
{(dialog) => (
<Switch>
+ <Match when={dialog().type === "export"}>
+ {(_) => <ExportDialog />}
+ </Match>
<Match when={dialog().type === "createPreset"}>
{(_) => {
const [form, setForm] = createStore({
diff --git a/apps/desktop/src/routes/editor/ExportButton.tsx b/apps/desktop/src/routes/editor/ExportButton.tsx
deleted file mode 100644
index c1385d291..000000000
--- a/apps/desktop/src/routes/editor/ExportButton.tsx
+++ /dev/null
@@ -1,368 +0,0 @@
-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="lightdark"
- class={cx("flex gap-2 justify-center")}
- 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/ExportDialog.tsx b/apps/desktop/src/routes/editor/ExportDialog.tsx
new file mode 100644
index 000000000..218950436
--- /dev/null
+++ b/apps/desktop/src/routes/editor/ExportDialog.tsx
@@ -0,0 +1,872 @@
+import { Button } from "@cap/ui-solid";
+import {
+ createEffect,
+ createResource,
+ createSignal,
+ For,
+ JSX,
+ Show,
+} from "solid-js";
+
+import { Select as KSelect } from "@kobalte/core/select";
+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 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 { RESOLUTION_OPTIONS, ResolutionOption } from "./Header";
+import {
+ DialogContent,
+ MenuItem,
+ MenuItemList,
+ PopperContent,
+ topLeftAnimateClasses,
+} from "./ui";
+import { createProgressBar } from "./utils";
+
+export const COMPRESSION_OPTIONS = [
+ { label: "Studio", value: "studio" },
+ { label: "Social Media", value: "social" },
+ { label: "Web", value: "web" },
+ { label: "Web (Low)", value: "web_low" },
+] as const;
+
+export const FPS_OPTIONS = [
+ { label: "30 FPS", value: 30 },
+ { label: "60 FPS", value: 60 },
+] satisfies Array<{ label: string; value: number }>;
+
+export const EXPORT_TO_OPTIONS = [
+ {
+ label: "File",
+ value: "file",
+ icon: <IconCapFile class="text-gray-500 size-4" />,
+ },
+ {
+ label: "Clipboard",
+ value: "clipboard",
+ icon: <IconCapCopy class="text-gray-500 size-4" />,
+ },
+ {
+ label: "Shareable link",
+ value: "link",
+ icon: <IconCapLink class="text-gray-500 size-4" />,
+ },
+] as const;
+
+export const FORMAT_OPTIONS = [
+ { label: "MP4", value: "mp4" },
+ { label: "GIF", value: "gif", disabled: true },
+] as { label: string; value: string; disabled?: boolean }[];
+
+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 [format, setFormat] = createSignal(
+ localStorage.getItem("cap-export-format") || "mp4"
+ );
+ const [copyPressed, setCopyPressed] = createSignal(false);
+
+ const [selectedFps, setSelectedFps] = createSignal(
+ Number(localStorage.getItem("cap-export-fps") || 30)
+ );
+ const [exportTo, setExportTo] = createSignal<ExportToOption>(
+ (localStorage.getItem("cap-export-to") as ExportToOption) || "file"
+ );
+ const [selectedResolution, setSelectedResolution] =
+ createSignal<ResolutionOption>(
+ RESOLUTION_OPTIONS.find(
+ (opt) => opt.value === localStorage.getItem("cap-export-resolution")
+ ) || RESOLUTION_OPTIONS[0]
+ );
+ const [compression, setCompression] = createSignal(
+ localStorage.getItem("cap-export-compression") || "social"
+ );
+ const [uploadComplete, setUploadComplete] = createSignal(false);
+
+ createEffect(() => {
+ localStorage.setItem("cap-export-format", format());
+ localStorage.setItem("cap-export-to", exportTo());
+ localStorage.setItem("cap-export-fps", selectedFps().toString());
+ localStorage.setItem("cap-export-resolution", selectedResolution().value);
+ localStorage.setItem("cap-export-compression", compression());
+ });
+
+ const selectedStyle =
+ "ring-1 ring-offset-2 ring-offset-gray-200 bg-gray-300 ring-gray-500";
+
+ const [exportEstimates] = createResource(
+ () => ({
+ videoId,
+ resolution: {
+ x: selectedResolution().width,
+ y: selectedResolution().height,
+ },
+ fps: selectedFps(),
+ }),
+ (params) =>
+ 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" />,
+ };
+
+ const [exportState, setExportState] = createStore<ExportState>({
+ type: "idle",
+ });
+
+ const [copyState, setCopyState] = createStore<CopyState>({
+ type: "idle",
+ });
+
+ const copy = createMutation(() => ({
+ mutationFn: async () => {
+ setCopyState({
+ type: "starting",
+ });
+
+ try {
+ const progress = new Channel<RenderProgress>();
+
+ progress.onmessage = (msg) => {
+ if (msg.type === "EstimatedTotalFrames")
+ setCopyState({
+ type: "rendering",
+ renderedFrames: 0,
+ totalFrames: msg.total_frames,
+ });
+ else
+ setCopyState(
+ produce((state) => {
+ if (msg.type === "FrameRendered" && state.type === "rendering")
+ state.renderedFrames = msg.current_frame;
+ })
+ );
+ };
+
+ // First try to get existing rendered video
+ const outputPath = await commands.exportVideo(
+ videoId,
+ progress,
+ false,
+ selectedFps(),
+ {
+ x: selectedResolution().width,
+ y: selectedResolution().height,
+ }
+ );
+
+ // 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);
+ throw error;
+ }
+ },
+ onSuccess() {
+ setCopyState({
+ type: "copied",
+ });
+ setTimeout(() => {
+ setCopyState({ type: "idle" });
+ }, 2000);
+ },
+ }));
+
+ const [recordingMeta, metaActions] = createResource(() =>
+ commands.getRecordingMeta(videoId, "recording")
+ );
+
+ const exportWithSettings = createMutation(() => ({
+ mutationFn: async () => {
+ setExportState({ type: "idle" });
+
+ const path = await save({
+ filters: [{ name: "mp4 filter", extensions: ["mp4"] }],
+ defaultPath: `~/Desktop/${prettyName()}.mp4`,
+ });
+ if (!path) return;
+
+ trackEvent("export_started", {
+ resolution: selectedResolution().value,
+ fps: 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,
+ selectedFps(),
+ {
+ x: selectedResolution().width,
+ y: 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();
+ setDialog((d) => ({ ...d, open: false }));
+ }, 1000);
+ },
+ }));
+
+ 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;
+ });
+
+ const [uploadState, setUploadState] = createStore<
+ | { type: "idle" }
+ | { type: "starting" }
+ | { type: "rendering"; renderedFrames: number; totalFrames: number }
+ | { type: "uploading"; progress: number }
+ | { type: "link-copied" }
+ >({ type: "idle" });
+
+ 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: selectedResolution().value,
+ fps: 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, selectedFps(), {
+ x: selectedResolution().width,
+ y: selectedResolution().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();
+ setUploadComplete(true);
+ metaUpdateStore.notifyUpdate(videoId);
+ },
+ onError: (error) => {
+ commands.globalMessageDialog(
+ error instanceof Error ? error.message : "Failed to upload recording"
+ );
+ },
+ onSettled() {
+ setTimeout(() => {
+ uploadVideo.reset();
+ }, 2000);
+ },
+ }));
+
+ 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
+ when={
+ exportState.type === "idle" &&
+ uploadState.type === "idle" &&
+ copyState.type === "idle"
+ }
+ >
+ <DialogContent
+ title="Export"
+ confirm={
+ <Button
+ class="flex gap-2 items-center"
+ variant="primary"
+ onClick={() => {
+ if (exportTo() === "file") {
+ exportWithSettings.mutate();
+ } else if (exportTo() === "link") {
+ uploadVideo.mutate();
+ } else {
+ copy.mutate();
+ }
+ }}
+ >
+ {exportButtonIcon[exportTo()]} Export to {exportTo()}
+ </Button>
+ }
+ leftFooterContent={
+ <div>
+ <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 class="flex flex-wrap gap-3">
+ {/* Format */}
+ <div class="p-4 bg-gray-100 rounded-xl">
+ <div class="flex flex-col gap-3">
+ <h3 class="text-gray-500">Format</h3>
+ <div class="flex flex-row gap-2">
+ <For each={FORMAT_OPTIONS}>
+ {(option) =>
+ option.disabled ? (
+ <Tooltip content={"Coming soon"}>
+ <Button
+ variant="secondary"
+ onClick={() => setFormat(option.value)}
+ disabled={option.disabled}
+ class={cx(
+ format() === option.value && selectedStyle
+ )}
+ >
+ {option.label}
+ </Button>
+ </Tooltip>
+ ) : (
+ <Button
+ variant="secondary"
+ onClick={() => setFormat(option.value)}
+ autofocus={false}
+ class={cx(format() === option.value && selectedStyle)}
+ >
+ {option.label}
+ </Button>
+ )
+ }
+ </For>
+ </div>
+ </div>
+ </div>
+ {/* Frame rate */}
+ <div class="overflow-hidden relative p-4 bg-gray-100 rounded-xl">
+ <div class="flex flex-col gap-3">
+ <h3 class="text-gray-500">Frame rate</h3>
+ <KSelect
+ options={FPS_OPTIONS}
+ optionValue="value"
+ optionTextValue="label"
+ placeholder="Select FPS"
+ value={FPS_OPTIONS.find((opt) => opt.value === selectedFps())}
+ onChange={(option) => {
+ const fps = option?.value ?? 30;
+ trackEvent("export_fps_changed", {
+ fps: fps,
+ });
+ 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 gap-2 items-center px-3 w-full h-10 bg-gray-200 rounded-xl transition-colors disabled:text-gray-400">
+ <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>
+ </div>
+ {/* Export to */}
+ <div class="flex-1 p-4 bg-gray-100 rounded-xl">
+ <div class="flex flex-col gap-3">
+ <h3 class="text-gray-500">Export to</h3>
+ <div class="flex gap-2">
+ <For each={EXPORT_TO_OPTIONS}>
+ {(option) => (
+ <Button
+ onClick={() => setExportTo(option.value)}
+ class={cx(
+ "flex gap-2 items-center",
+ exportTo() === option.value && selectedStyle
+ )}
+ variant="secondary"
+ >
+ {option.icon}
+ {option.label}
+ </Button>
+ )}
+ </For>
+ </div>
+ </div>
+ </div>
+ {/* Compression */}
+ <div class="p-4 bg-gray-100 rounded-xl">
+ <div class="flex flex-col gap-3">
+ <h3 class="text-gray-400">Compression (Coming Soon)</h3>
+ <div class="flex gap-2">
+ <For each={COMPRESSION_OPTIONS}>
+ {(option) => (
+ <Button
+ onClick={() => setCompression(option.value)}
+ variant="secondary"
+ disabled
+ >
+ {option.label}
+ </Button>
+ )}
+ </For>
+ </div>
+ </div>
+ </div>
+ {/* Resolution */}
+ <div class="flex-1 p-4 bg-gray-100 rounded-xl">
+ <div class="flex flex-col gap-3">
+ <h3 class="text-gray-500">Resolution</h3>
+ <div class="flex gap-2">
+ <For each={RESOLUTION_OPTIONS}>
+ {(option) => (
+ <Button
+ class={cx(
+ "flex-1",
+ selectedResolution().value === option.value &&
+ selectedStyle
+ )}
+ variant="secondary"
+ onClick={() => setSelectedResolution(option)}
+ >
+ {option.label}
+ </Button>
+ )}
+ </For>
+ </div>
+ </div>
+ </div>
+ </div>
+ </DialogContent>
+ </Show>
+ <Show
+ when={
+ exportState.type !== "idle" ||
+ uploadState.type !== "idle" ||
+ copyState.type !== "idle"
+ }
+ >
+ <DialogContent
+ title={"Export"}
+ confirm={
+ <Show when={uploadComplete()}>
+ <div class="relative">
+ <a
+ href={recordingMeta()?.sharing?.link}
+ target="_blank"
+ rel="noreferrer"
+ class="block"
+ >
+ <Button
+ variant="lightdark"
+ class="flex gap-2 justify-center items-center"
+ >
+ <p>Open Link</p>
+ <div class="size-6" />{" "}
+ {/* Placeholder for the copy button */}
+ </Button>
+ </a>
+ {/* Absolutely positioned copy button that sits on top */}
+ <Tooltip
+ childClass="absolute right-4 top-1/2 transform -translate-y-1/2"
+ content="Copy link"
+ >
+ <div
+ onClick={() => {
+ setCopyPressed(true);
+ setTimeout(() => {
+ setCopyPressed(false);
+ }, 2000);
+ navigator.clipboard.writeText(
+ recordingMeta()?.sharing?.link!
+ );
+ }}
+ class="flex justify-center items-center rounded-lg transition-colors duration-300 cursor-pointer bg-gray-450 group hover:bg-gray-400 size-6"
+ >
+ {!copyPressed() ? (
+ <IconCapCopy class="size-2.5 text-gray-50 group-hover:text-gray-500 transition-colors duration-300" />
+ ) : (
+ <IconLucideCheck class="size-2.5 svgpathanimation text-gray-50 group-hover:text-gray-500 transition-colors duration-300" />
+ )}
+ </div>
+ </Tooltip>
+ </div>
+ </Show>
+ }
+ close={
+ <Show when={uploadComplete()}>
+ <Button
+ onClick={() => {
+ setUploadComplete(false);
+ setUploadState({ type: "idle" });
+ }}
+ variant="secondary"
+ class="flex gap-2 justify-center h-[44px] items-center"
+ >
+ Back
+ </Button>
+ </Show>
+ }
+ class="text-gray-500 bg-gray-600 dark:text-gray-500"
+ >
+ <div class="relative z-10 px-5 py-4 mx-auto space-y-6 w-full text-center">
+ {/** Upload success */}
+ <Show when={uploadComplete()}>
+ <UploadingSuccessContent />
+ </Show>
+ {/** Copying to clipboard */}
+ <Show when={copyState.type !== "idle"}>
+ <CopyingContent copyState={copyState} />
+ </Show>
+ {/** Exporting to shareable link */}
+ <Show when={uploadState.type !== "idle" && uploadVideo.isPending}>
+ <UploadingCapContent />
+ </Show>
+ {/** Exporting to file */}
+ <Show when={exportState.type !== "idle"}>
+ <ExportingFileContent exportState={exportState} />
+ </Show>
+ </div>
+ </DialogContent>
+ </Show>
+ </>
+ );
+};
+
+const CopyingContent = ({ copyState }: { copyState: CopyState }) => {
+ return (
+ <div class="flex justify-center items-center h-full">
+ <h1 class="text-lg font-medium text-gray-500">
+ {copyState.type === "rendering"
+ ? "Rendering video..."
+ : copyState.type === "starting"
+ ? "Copying to clipboard..."
+ : "Copied to clipboard"}
+ </h1>
+ <Show when={copyState.type === "rendering"}>
+ <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: `${
+ copyState.type === "rendering"
+ ? Math.min(
+ (copyState.renderedFrames / copyState.totalFrames) * 100,
+ 100
+ )
+ : 0
+ }%`,
+ }}
+ />
+ </div>
+ </Show>
+ <p class="mt-2 text-xs text-gray-500">
+ {copyState.type === "rendering"
+ ? `${Math.floor(
+ (copyState.renderedFrames / copyState.totalFrames) * 100
+ )}%`
+ : ""}
+ </p>
+ </div>
+ );
+};
+
+const ExportingFileContent = ({
+ exportState,
+}: {
+ exportState: ExportState;
+}) => {
+ return (
+ <>
+ <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>
+ </>
+ );
+};
+
+const UploadingSuccessContent = () => {
+ return (
+ <div class="flex flex-col gap-5 justify-center items-center">
+ <div class="flex flex-col gap-1 items-center">
+ <h1 class="mx-auto text-lg font-medium text-center text-gray-500">
+ Upload Complete
+ </h1>
+ <p class="text-sm text-gray-400">
+ Your Cap has been uploaded successfully
+ </p>
+ </div>
+ </div>
+ );
+};
+
+const UploadingCapContent = () => {
+ return (
+ <div class="flex gap-2 justify-center items-center">
+ <IconLucideLoaderCircle class="animate-spin size-7" />
+ <h1 class="text-lg font-medium text-center text-gray-500">
+ Uploading Cap
+ </h1>
+ </div>
+ );
+};
+
+export default ExportDialog;
diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsx
index 3f158d347..d6e9f89ab 100644
--- a/apps/desktop/src/routes/editor/Header.tsx
+++ b/apps/desktop/src/routes/editor/Header.tsx
@@ -7,13 +7,14 @@ import { type as ostype } from "@tauri-apps/plugin-os";
import { cx } from "cva";
import { createEffect, createSignal, onCleanup, onMount } from "solid-js";
+import { Button } from "@cap/ui-solid";
+import CaptionControlsWindows11 from "~/components/titlebar/controls/CaptionControlsWindows11";
+import { trackEvent } from "~/utils/analytics";
import { initializeTitlebar } from "~/utils/titlebar-state";
import { useEditorContext } from "./context";
-import ExportButton from "./ExportButton";
import PresetsDropdown from "./PresetsDropdown";
import ShareButton from "./ShareButton";
import { EditorButton } from "./ui";
-import CaptionControlsWindows11 from "~/components/titlebar/controls/CaptionControlsWindows11";
export type ResolutionOption = {
label: string;
@@ -36,6 +37,10 @@ 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
@@ -49,7 +54,6 @@ export function Header() {
// Save settings when they change
createEffect(() => {
- localStorage.setItem("cap-export-fps", selectedFps().toString());
localStorage.setItem("cap-export-resolution", selectedResolution().value);
});
@@ -62,11 +66,11 @@ export function Header() {
return (
<div
data-tauri-drag-region
- class="relative w-full h-14 flex flex-row items-center"
+ class="flex relative flex-row items-center w-full h-14"
>
<div
data-tauri-drag-region
- class={cx("flex-1 h-full flex flex-row items-center gap-2 px-4")}
+ class={cx("flex flex-row flex-1 gap-2 items-center px-4 h-full")}
>
{ostype() === "macos" && <div class="h-full w-[4rem]" />}
<EditorButton
@@ -132,7 +136,7 @@ export function Header() {
<div
data-tauri-drag-region
- class="px-4 border-x border-black-transparent-10 flex flex-col justify-center"
+ class="flex flex-col justify-center px-4 border-x border-black-transparent-10"
>
<PresetsDropdown />
</div>
@@ -157,16 +161,21 @@ export function Header() {
leftIcon={<IconCapRedo class="w-5" />}
/>
<div data-tauri-drag-region class="flex-1 h-full" />
- <ShareButton
- selectedResolution={selectedResolution}
- selectedFps={selectedFps}
- />
- <ExportButton
- selectedResolution={selectedResolution()}
- selectedFps={selectedFps()}
- setSelectedFps={setSelectedFps}
- setSelectedResolution={setSelectedResolution}
- />
+ <ShareButton />
+ <Button
+ variant="lightdark"
+ class={cx("flex gap-2 justify-center")}
+ onClick={() => {
+ trackEvent("export_button_clicked");
+ editorContext.setDialog({
+ type: "export",
+ open: true,
+ });
+ }}
+ >
+ <IconCapUpload class="size-5" />
+ Export
+ </Button>
{ostype() === "windows" && <CaptionControlsWindows11 />}
</div>
</div>
diff --git a/apps/desktop/src/routes/editor/ShareButton.tsx b/apps/desktop/src/routes/editor/ShareButton.tsx
index 875ab8f7f..f8df02395 100644
--- a/apps/desktop/src/routes/editor/ShareButton.tsx
+++ b/apps/desktop/src/routes/editor/ShareButton.tsx
@@ -1,27 +1,28 @@
import { Button } from "@cap/ui-solid";
import { createMutation } from "@tanstack/solid-query";
-import { createResource, createSignal, Show } from "solid-js";
+import { createEffect, createResource, createSignal, Show } from "solid-js";
import { createStore, produce } from "solid-js/store";
import Tooltip from "~/components/Tooltip";
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 { metaUpdateStore, useEditorContext } from "./context";
+import { RESOLUTION_OPTIONS } from "./Header";
import { Dialog, DialogContent } from "./ui";
-function ShareButton(props: {
- selectedResolution: () => ResolutionOption;
- selectedFps: () => number;
-}) {
- const { videoId, project } = useEditorContext();
+function ShareButton() {
+ const { videoId } = useEditorContext();
const [recordingMeta, metaActions] = createResource(() =>
commands.getRecordingMeta(videoId, "recording")
);
const [copyPressed, setCopyPressed] = createSignal(false);
+ const selectedFps = Number(localStorage.getItem("cap-export-fps")) || 30;
+ const selectedResolution =
+ RESOLUTION_OPTIONS.find(
+ (opt) => opt.value === localStorage.getItem("cap-export-resolution")
+ ) || RESOLUTION_OPTIONS[0];
const uploadVideo = createMutation(() => ({
mutationFn: async () => {
@@ -36,12 +37,6 @@ function ShareButton(props: {
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");
@@ -100,18 +95,10 @@ function ShareButton(props: {
);
};
- await commands.exportVideo(
- videoId,
- progress,
- true,
- props.selectedFps(),
- {
- x: props.selectedResolution()?.width || RESOLUTION_OPTIONS[0].width,
- y:
- props.selectedResolution()?.height ||
- RESOLUTION_OPTIONS[0].height,
- }
- );
+ await commands.exportVideo(videoId, progress, true, selectedFps, {
+ x: selectedResolution.width,
+ y: selectedResolution.height,
+ });
setUploadState({ type: "uploading", progress: 0 });
@@ -175,31 +162,17 @@ function ShareButton(props: {
return 100;
});
+ // Watch for metadata updates
+ createEffect(() => {
+ const update = metaUpdateStore.getLastUpdate();
+ if (update && update.videoId === videoId) {
+ metaActions.refetch();
+ }
+ });
+
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 !py-2"
- >
- {!uploadVideo.isPending ? (
- <>
- <IconCapLink class="size-5" />
- <span>Shareable Link</span>
- </>
- ) : (
- <>
- <IconLucideLoaderCircle class="size-[1rem] animate-spin" />
- <span>Uploading Cap</span>
- </>
- )}
- </Button>
- }
- >
+ <Show when={recordingMeta.latest?.sharing}>
{(sharing) => {
const url = () => new URL(sharing().link);
const copyLink = () => {
@@ -218,7 +191,7 @@ function ShareButton(props: {
>
<Button
disabled={uploadVideo.isPending}
- onClick={(e) => uploadVideo.mutate()}
+ onClick={() => uploadVideo.mutate()}
variant="primary"
class="flex justify-center items-center size-[41px] !px-0 !py-0 space-x-1 rounded-xl"
>
@@ -244,9 +217,8 @@ function ShareButton(props: {
</a>
{/** Copy button */}
<Tooltip content="Copy link">
- <Button
- variant="secondary"
- class="flex justify-center items-center size-[22px] text-gray-500 !px-0 !py-0 rounded-[5px] dark:bg-black-transparent-10 dark:hover:bg-black-transparent-40 bg-gray-200 hover:bg-gray-300"
+ <div
+ class="flex justify-center items-center rounded-lg size-[22px] text-gray-500 !px-0 !py-0 dark:bg-black-transparent-10 dark:hover:bg-black-transparent-40 bg-gray-200 hover:bg-gray-300"
onClick={copyLink}
>
{!copyPressed() ? (
@@ -254,7 +226,7 @@ function ShareButton(props: {
) : (
<IconLucideCheck class="size-2.5 svgpathanimation" />
)}
- </Button>
+ </div>
</Tooltip>
</div>
</Tooltip>
diff --git a/apps/desktop/src/routes/editor/context.ts b/apps/desktop/src/routes/editor/context.ts
index 8b6a96f87..1d66134fe 100644
--- a/apps/desktop/src/routes/editor/context.ts
+++ b/apps/desktop/src/routes/editor/context.ts
@@ -28,7 +28,8 @@ export type CurrentDialog =
| { type: "createPreset" }
| { type: "renamePreset"; presetIndex: number }
| { type: "deletePreset"; presetIndex: number }
- | { type: "crop"; position: XY<number>; size: XY<number> };
+ | { type: "crop"; position: XY<number>; size: XY<number> }
+ | { type: "export" };
export type DialogState = { open: false } | ({ open: boolean } & CurrentDialog);
@@ -328,3 +329,17 @@ export const [SegmentContextProvider, useSegmentContext] =
createContextProvider((props: { width: Accessor<number> }) => {
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/routes/editor/ui.tsx b/apps/desktop/src/routes/editor/ui.tsx
index 5b8fcad49..2646e248d 100644
--- a/apps/desktop/src/routes/editor/ui.tsx
+++ b/apps/desktop/src/routes/editor/ui.tsx
@@ -180,6 +180,7 @@ export const Dialog = {
props: ComponentProps<typeof KDialog> & {
hideOverlay?: boolean;
size?: "sm" | "lg";
+ contentClass?: string;
}
) {
return (
@@ -191,6 +192,7 @@ export const Dialog = {
<div class="flex fixed inset-0 z-50 justify-center items-center">
<KDialog.Content
class={cx(
+ props.contentClass,
"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",
(props.size ?? "sm") === "sm" ? "max-w-96" : "max-w-3xl"
)}
@@ -216,17 +218,26 @@ export const Dialog = {
);
return <Button {...props} />;
},
- Footer(props: ComponentProps<"div"> & { close?: JSX.Element }) {
+ Footer(
+ props: ComponentProps<"div"> & {
+ close?: JSX.Element;
+ leftFooterContent?: JSX.Element;
+ }
+ ) {
return (
<div
class={cx(
- "h-[4rem] px-[1rem] gap-[0.75rem] flex flex-row items-center justify-end",
+ "h-[4rem] px-[1rem] gap-3 flex flex-row items-center",
+ props.leftFooterContent ? "justify-between" : "justify-end",
props.class
)}
{...props}
>
- {props.close ?? <Dialog.CloseButton />}
- {props.children}
+ {props.leftFooterContent}
+ <div class="flex flex-row gap-3 items-center">
+ {props.close ?? <Dialog.CloseButton />}
+ {props.children}
+ </div>
</div>
);
},
@@ -246,6 +257,7 @@ export function DialogContent(
confirm: JSX.Element;
class?: string;
close?: JSX.Element;
+ leftFooterContent?: JSX.Element;
}>
) {
return (
@@ -256,7 +268,12 @@ export function DialogContent(
</KDialog.Title>
</Dialog.Header>
<Dialog.Content class={props.class}>{props.children}</Dialog.Content>
- <Dialog.Footer close={props.close}>{props.confirm}</Dialog.Footer>
+ <Dialog.Footer
+ close={props.close}
+ leftFooterContent={props.leftFooterContent}
+ >
+ {props.confirm}
+ </Dialog.Footer>
</>
);
}
diff --git a/packages/ui-solid/icons/file.svg b/packages/ui-solid/icons/file.svg
new file mode 100644
index 000000000..ed9848675
--- /dev/null
+++ b/packages/ui-solid/icons/file.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-file"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg>
\ No newline at end of file
diff --git a/packages/ui-solid/icons/move-left.svg b/packages/ui-solid/icons/move-left.svg
new file mode 100644
index 000000000..6fc9e50d2
--- /dev/null
+++ b/packages/ui-solid/icons/move-left.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-move-left-icon lucide-move-left"><path d="M6 8L2 12L6 16"/><path d="M2 12H22"/></svg>
\ No newline at end of file
diff --git a/packages/ui-solid/icons/move-right.svg b/packages/ui-solid/icons/move-right.svg
new file mode 100644
index 000000000..3cfe9e50b
--- /dev/null
+++ b/packages/ui-solid/icons/move-right.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-move-right-icon lucide-move-right"><path d="M18 8L22 12L18 16"/><path d="M2 12H22"/></svg>
\ No newline at end of file
diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.ts
index 4fe420c8a..01fe6f87f 100644
--- a/packages/ui-solid/src/auto-imports.d.ts
+++ b/packages/ui-solid/src/auto-imports.d.ts
@@ -13,6 +13,7 @@ declare global {
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 IconCapCheck: typeof import('~icons/cap/check.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']
@@ -42,6 +43,8 @@ declare global {
const IconCapMessageBubble: typeof import('~icons/cap/message-bubble.jsx')['default']
const IconCapMicrophone: typeof import('~icons/cap/microphone.jsx')['default']
const IconCapMoreVertical: typeof import('~icons/cap/more-vertical.jsx')['default']
+ const IconCapMoveLeft: typeof import('~icons/cap/move-left.jsx')['default']
+ const IconCapMoveRight: typeof import('~icons/cap/move-right.jsx')['default']
const IconCapNext: typeof import('~icons/cap/next.jsx')['default']
const IconCapPadding: typeof import('~icons/cap/padding.jsx')['default']
const IconCapPause: typeof import('~icons/cap/pause.jsx')['default']
@@ -55,6 +58,7 @@ declare global {
const IconCapScissors: typeof import('~icons/cap/scissors.jsx')['default']
const IconCapSettings: typeof import('~icons/cap/settings.jsx')['default']
const IconCapShadow: typeof import('~icons/cap/shadow.jsx')['default']
+ const IconCapSize: typeof import('~icons/cap/size.jsx')['default']
const IconCapSquare: typeof import('~icons/cap/square.jsx')['default']
const IconCapStop: typeof import('~icons/cap/stop.jsx')['default']
const IconCapStopCircle: typeof import('~icons/cap/stop-circle.jsx')['default']