Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Add screenshot mode and image icon support
Richie McIlroyf9450c89e32f
diff --git a/apps/desktop/src/components/Mode.tsx b/apps/desktop/src/components/Mode.tsxindex 056fb08e6..7fa7e524b 100644--- a/apps/desktop/src/components/Mode.tsx+++ b/apps/desktop/src/components/Mode.tsx@@ -3,6 +3,7 @@ import { createSignal } from "solid-js";import Tooltip from "~/components/Tooltip";import { useRecordingOptions } from "~/routes/(window-chrome)/OptionsContext";import { commands } from "~/utils/tauri";+import IconCapImageFilled from "~icons/cap/image-filled";const Mode = () => {const { rawOptions, setOptions } = useRecordingOptions();@@ -80,7 +81,7 @@ const Mode = () => {: "bg-gray-3 hover:bg-gray-7"}`}>- <IconCapCamera class="size-3.5 invert dark:invert-0" />+ <IconCapImageFilled class="size-[19px] invert dark:invert-0" /></div></Tooltip>)}@@ -123,7 +124,7 @@ const Mode = () => {: "bg-gray-3 hover:bg-gray-7"}`}>- <IconCapCamera class="size-3.5 invert dark:invert-0" />+ <IconCapImageFilled class="size-[19px] invert dark:invert-0" /></div></>)}diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsxindex f2d55a315..c2e3af0c4 100644--- a/apps/desktop/src/routes/target-select-overlay.tsx+++ b/apps/desktop/src/routes/target-select-overlay.tsx@@ -479,6 +479,7 @@ function Inner() {});createEffect(async () => {+ if (options.mode === "screenshot") return;const bounds = crop();const interacting = isInteracting();@@ -688,6 +689,43 @@ function Inner() {});});+ const [wasInteracting, setWasInteracting] = createSignal(false);+ createEffect(async () => {+ const interacting = isInteracting();+ const was = wasInteracting();+ setWasInteracting(interacting);++ if (was && !interacting) {+ if (options.mode === "screenshot" && isValid()) {+ const target: ScreenCaptureTarget = {+ variant: "area",+ screen: displayId(),+ bounds: {+ position: {+ x: crop().x,+ y: crop().y,+ },+ size: {+ width: crop().width,+ height: crop().height,+ },+ },+ };++ try {+ const path = await invoke<string>("take_screenshot", {+ target,+ });+ // @ts-expect-error+ await commands.showWindow({ ScreenshotEditor: { path } });+ await commands.closeTargetSelectOverlays();+ } catch (e) {+ console.error("Failed to take screenshot", e);+ }+ }+ }+ });+return (<div class="fixed w-screen h-screen bg-black/60"><div@@ -696,25 +734,27 @@ function Inner() {style={controlsStyle()}><div class="flex flex-col items-center">- <RecordingControls- target={{- variant: "area",- screen: displayId(),- bounds: {- position: {- x: crop().x,- y: crop().y,- },- size: {- width: crop().width,- height: crop().height,+ <Show when={options.mode !== "screenshot"}>+ <RecordingControls+ target={{+ variant: "area",+ screen: displayId(),+ bounds: {+ position: {+ x: crop().x,+ y: crop().y,+ },+ size: {+ width: crop().width,+ height: crop().height,+ },},- },- }}- disabled={!isValid()}- showBackground={controllerInside()}- onRecordingStart={() => setOriginalCameraBounds(null)}- />+ }}+ disabled={!isValid()}+ showBackground={controllerInside()}+ onRecordingStart={() => setOriginalCameraBounds(null)}+ />+ </Show><Show when={!isValid()}><div class="flex flex-col gap-1 items-center p-2.5 my-2 rounded-xl border min-w-fit w-fit bg-red-2 shadow-sm border-red-4 text-sm"><p>Minimum size is 150 x 150</p>diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 5d8bf386c..2092cea14 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -134,11 +134,11 @@ async uploadExportedVideo(path: string, mode: UploadMode, channel: TAURI_CHANNELasync uploadScreenshot(screenshotPath: string) : Promise<UploadResult> {return await TAURI_INVOKE("upload_screenshot", { screenshotPath });},-async createScreenshotEditorInstance(path: string) : Promise<SerializedScreenshotEditorInstance> {- return await TAURI_INVOKE("create_screenshot_editor_instance", { path });+async createScreenshotEditorInstance() : Promise<SerializedScreenshotEditorInstance> {+ return await TAURI_INVOKE("create_screenshot_editor_instance");},-async updateScreenshotConfig(config: ProjectConfiguration) : Promise<null> {- return await TAURI_INVOKE("update_screenshot_config", { config });+async updateScreenshotConfig(config: ProjectConfiguration, save: boolean) : Promise<null> {+ return await TAURI_INVOKE("update_screenshot_config", { config, save });},async getRecordingMeta(path: string, fileType: FileType) : Promise<RecordingMetaWithMetadata> {return await TAURI_INVOKE("get_recording_meta", { path, fileType });@@ -481,7 +481,7 @@ export type SceneSegment = { start: number; end: number; mode?: SceneMode }export type ScreenCaptureTarget = { variant: "window"; id: WindowId } | { variant: "display"; id: DisplayId } | { variant: "area"; screen: DisplayId; bounds: LogicalBounds }export type SegmentRecordings = { display: Video; camera: Video | null; mic: Audio | null; system_audio: Audio | null }export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordingsMeta; path: string }-export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string }+export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string; config: ProjectConfiguration | null }export type SetCaptureAreaPending = booleanexport type ShadowConfiguration = { size: number; opacity: number; blur: number }export type SharingMeta = { id: string; link: string }diff --git a/packages/ui-solid/icons/image-filled.svg b/packages/ui-solid/icons/image-filled.svgnew file mode 100644index 000000000..f5329b6bc--- /dev/null+++ b/packages/ui-solid/icons/image-filled.svg@@ -0,0 +1,3 @@+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 2.23858 2.23858 0 5 0H19C21.7614 0 24 2.23858 24 5V19C24 21.7614 21.7614 24 19 24H5C2.23858 24 0 21.7614 0 19V5ZM8.5 11C10.1569 11 11.5 9.65685 11.5 8C11.5 6.34315 10.1569 5 8.5 5C6.84315 5 5.5 6.34315 5.5 8C5.5 9.65685 6.84315 11 8.5 11ZM24 21V14.5L15.5 6L4.5 17L0 21.5V24H24V21Z" fill="white"/>+</svg>diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 7bb78817b..4db5e5ed5 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -74,6 +74,7 @@ declare global {const IconLucideFolder: typeof import('~icons/lucide/folder.jsx')['default']const IconLucideGift: typeof import('~icons/lucide/gift.jsx')['default']const IconLucideHardDrive: typeof import('~icons/lucide/hard-drive.jsx')['default']+ const IconLucideImage: typeof import('~icons/lucide/image.jsx')['default']const IconLucideLayout: typeof import('~icons/lucide/layout.jsx')['default']const IconLucideLoaderCircle: typeof import('~icons/lucide/loader-circle.jsx')['default']const IconLucideMaximize: typeof import('~icons/lucide/maximize.jsx')['default']