Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Load in custom backgrounds + misc fixes
Richie McIlroy104fc135495e
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.ymlindex 945cb8e3f..590b64f9b 100644--- a/.github/workflows/publish.yml+++ b/.github/workflows/publish.yml@@ -137,6 +137,7 @@ jobs:- name: Create .env file in rootrun: |echo "appVersion=${{ needs.draft.outputs.version }}" >> .env+ echo "VITE_ENVIRONMENT=production" >> .envecho "CAP_DESKTOP_SENTRY_URL=https://6a3b6a09e6ae976c2ad6fff710e88748@o4506859771527168.ingest.us.sentry.io/4508330917101568" >> .envecho "NEXT_PUBLIC_WEB_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}" >> .envecho 'NEXTAUTH_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .envdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-dark.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-dark.jpgnew file mode 100644index 000000000..b5aed00cbBinary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-dark.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-light.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-light.jpgnew file mode 100644index 000000000..bec1265e7Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sequoia-light.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-clouds.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-clouds.jpgnew file mode 100644index 000000000..7a46b3231Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-clouds.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-dark.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-dark.jpgnew file mode 100644index 000000000..d0987dbbbBinary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-dark.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-evening.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-evening.jpgnew file mode 100644index 000000000..e164bfdf4Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-evening.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-fromabove.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-fromabove.jpgnew file mode 100644index 000000000..ae6f7f4cfBinary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-fromabove.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-horizon.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-horizon.jpgnew file mode 100644index 000000000..d3fcb1a43Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-horizon.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-light.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-light.jpgnew file mode 100644index 000000000..ee07156b2Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-light.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-river.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-river.jpgnew file mode 100644index 000000000..ec9791cbfBinary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/sonoma-river.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-dark.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-dark.jpgnew file mode 100644index 000000000..d8e5b6dd6Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-dark.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-semi-dark.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-semi-dark.jpgnew file mode 100644index 000000000..47d50679aBinary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura-semi-dark.jpg differdiff --git a/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura.jpg b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura.jpgnew file mode 100644index 000000000..869d525d0Binary files /dev/null and b/apps/desktop/src-tauri/assets/backgrounds/macOS/ventura.jpg differdiff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.jsonindex 30b0f2804..8a3d29a50 100644--- a/apps/desktop/src-tauri/capabilities/default.json+++ b/apps/desktop/src-tauri/capabilities/default.json@@ -5,15 +5,19 @@"windows": ["*"],"permissions": ["fs:default",+ "fs:allow-resource-read",+ "fs:allow-resource-read-recursive","fs:write-all","fs:read-all","fs:allow-appdata-read","fs:allow-appdata-write",+ "fs:allow-picture-read-recursive",{"identifier": "fs:scope","allow": [{ "path": "$APPDATA/**" },- { "path": "$HOME/**" }+ { "path": "$HOME/**" },+ { "path": "$RESOURCE/**" }]},"core:path:allow-resolve-directory",diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 8dd9f757f..e0a0c0aa9 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -1938,6 +1938,25 @@ fn configure_logging(folder: &PathBuf) -> tracing_appender::non_blocking::Worker_guard}+#[tauri::command]+#[specta::specta]+async fn get_wallpaper_path(app: AppHandle, filename: String) -> Result<String, String> {+ let resource_path = app+ .path()+ .resource_dir()+ .map_err(|_| "Failed to get resource dir".to_string())?+ .join("assets")+ .join("backgrounds")+ .join("macOS")+ .join(filename);++ if resource_path.exists() {+ Ok(resource_path.to_string_lossy().to_string())+ } else {+ Err(format!("Resource not found: {:?}", resource_path))+ }+}+#[cfg_attr(mobile, tauri::mobile_entry_point)]pub async fn run() {let tauri_context = tauri::generate_context!();@@ -2004,7 +2023,8 @@ pub async fn run() {global_message_dialog,show_window,write_clipboard_string,- platform::perform_haptic_feedback+ platform::perform_haptic_feedback,+ get_wallpaper_path]).events(tauri_specta::collect_events![RecordingOptionsChanged,diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.jsonindex b9dfb808a..7ee606d10 100644--- a/apps/desktop/src-tauri/tauri.conf.json+++ b/apps/desktop/src-tauri/tauri.conf.json@@ -13,10 +13,10 @@"app": {"macOSPrivateApi": true,"security": {- "csp": null,+ "csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost","assetProtocol": {"enable": true,- "scope": ["$APPDATA/**"]+ "scope": ["$APPDATA/**", "**/*.jpg", "$RESOURCE/**", "$HOME/**"]}}},@@ -52,6 +52,9 @@"icons/macos/icon.icns","icons/icon.ico"],+ "resources": [+ "assets/backgrounds/macOS/*"+ ],"macOS": {"dmg": {"background": "assets/dmg-background.png",diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsxindex b54fe57d0..14ed4c456 100644--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx@@ -53,7 +53,7 @@ import {const getAuth = cache(async () => {const value = await authStore.get();- const local = import.meta.env.VITE_LOCAL_MODE === "true";+ const local = import.meta.env.VITE_ENVIRONMENT === "development";const res = await apiClient.desktop.getUserPlan({headers: await protectedHeaders(),diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex 4d1a0cd89..8ef4fdf9a 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -11,13 +11,19 @@ import {createSignal,For,Show,+ onMount,} from "solid-js";import { Dynamic } from "solid-js/web";import { createWritableMemo } from "@solid-primitives/memo";import { createEventListenerMap } from "@solid-primitives/event-listener";import { produce } from "solid-js/store";import { writeFile, BaseDirectory } from "@tauri-apps/plugin-fs";-import { appDataDir } from "@tauri-apps/api/path";+import {+ appDataDir,+ appLocalDataDir,+ join,+ resolveResource,+} from "@tauri-apps/api/path";import { convertFileSrc } from "@tauri-apps/api/core";import {@@ -63,24 +69,20 @@ const CURSOR_ANIMATION_STYLES: Record<CursorAnimationStyle, string> = {fast: "Fast & Responsive",} as const;-const WALLPAPERS = [- {- id: "wall1",- url: "https://images.unsplash.com/photo-1542332213-9b5a5a3fad35?w=1920",- },- {- id: "wall2",- url: "https://images.unsplash.com/photo-1542810104-c5f07c7357ff?w=1920",- },- {- id: "wall3",- url: "https://images.unsplash.com/photo-1445368794737-0cf251429ca0?w=1920",- },- {- id: "wall4",- url: "https://images.unsplash.com/photo-1737365506116-ef7eba797492?w=1920",- },-];+const WALLPAPER_NAMES = [+ "sequoia-dark",+ "sequoia-light",+ "sonoma-clouds",+ "sonoma-dark",+ "sonoma-evening",+ "sonoma-fromabove",+ "sonoma-horizon",+ "sonoma-light",+ "sonoma-river",+ "ventura-dark",+ "ventura-semi-dark",+ "ventura",+] as const;export function ConfigSidebar() {const {@@ -93,6 +95,55 @@ export function ConfigSidebar() {setState,} = useEditorContext();+ const [wallpapers] = createResource(async () => {+ return Promise.all(+ WALLPAPER_NAMES.map(async (id) => {+ try {+ // Get the validated path from Rust+ const path = await commands.getWallpaperPath(`${id}.jpg`);++ // Convert to proper URL+ const url = convertFileSrc(path);++ return {+ id,+ url,+ };+ } catch (err) {+ return {+ id,+ url: null,+ };+ }+ })+ );+ });++ // Validate background source path on mount+ onMount(() => {+ if (+ project.background.source.type === "wallpaper" ||+ project.background.source.type === "image"+ ) {+ const path = project.background.source.path;+ if (path) {+ if (project.background.source.type === "image") {+ // Use async IIFE to check file existence+ (async () => {+ try {+ await fetch(convertFileSrc(path), { method: "HEAD" });+ } catch {+ setProject("background", "source", {+ type: "image",+ path: null,+ });+ }+ })();+ }+ }+ }+ });+const backgrounds: {[K in BackgroundSource["type"]]: Extract<BackgroundSource, { type: K }>;} = {@@ -249,51 +300,63 @@ export function ConfigSidebar() {<KTabs.Content value="wallpaper"><KRadioGroupvalue={- project.background.source.type === "image"- ? project.background.source.path ?? undefined+ project.background.source.type === "wallpaper"+ ? wallpapers()?.find((w) =>+ (+ project.background.source as { path?: string }+ ).path?.includes(w.id)+ )?.url ?? undefined: undefined}onChange={async (photoUrl) => {try {- const response = await fetch(photoUrl);- const blob = await response.blob();- const fileName = `wallpaper-${Date.now()}.jpg`;- const arrayBuffer = await blob.arrayBuffer();- const uint8Array = new Uint8Array(arrayBuffer);-- const fullPath = `${await appDataDir()}/${fileName}`;+ const wallpaper = wallpapers()?.find(+ (w) => w.url === photoUrl+ );+ if (!wallpaper) return;- await writeFile(fileName, uint8Array, {- baseDir: BaseDirectory.AppData,- });+ // Get the raw path without any URL prefixes+ const rawPath = decodeURIComponent(+ photoUrl.replace("file://", "")+ );setProject("background", "source", {- type: "image",- path: fullPath,- });+ type: "wallpaper",+ path: rawPath,+ } as const);} catch (err) {- console.error("Failed to save wallpaper:", err);+ console.error("Failed to set wallpaper:", err);+ toast.error("Failed to set wallpaper");}}}- class="grid grid-cols-2 gap-2 h-auto"+ class="grid grid-cols-7 gap-2 h-auto">- <For each={WALLPAPERS}>- {(photo) => (- <KRadioGroup.Item- value={photo.url}- class="col-span-1 aspect-video relative group"- >- <KRadioGroup.ItemInput class="peer" />- <KRadioGroup.ItemControl class="cursor-pointer w-full h-full overflow-hidden rounded-lg border border-gray-200 ui-checked:border-blue-300 peer-focus-visible:border-2 peer-focus-visible:border-blue-300">- <img- src={photo.url}- alt="Wallpaper option"- class="w-full h-full object-cover"- />- </KRadioGroup.ItemControl>- </KRadioGroup.Item>- )}- </For>+ <Show+ when={!wallpapers.loading}+ fallback={+ <div class="col-span-7 flex items-center justify-center h-32 text-gray-400">+ Loading wallpapers...+ </div>+ }+ >+ <For each={wallpapers()?.filter((p) => p.url !== null)}>+ {(photo) => (+ <KRadioGroup.Item+ value={photo.url!}+ class="aspect-square relative group"+ >+ <KRadioGroup.ItemInput class="peer" />+ <KRadioGroup.ItemControl class="cursor-pointer w-full h-full overflow-hidden rounded-lg border border-gray-200 ui-checked:border-blue-300 ui-checked:ring-2 ui-checked:ring-blue-300 peer-focus-visible:border-2 peer-focus-visible:border-blue-300">+ <img+ src={photo.url!}+ alt="Wallpaper option"+ class="w-full h-full object-cover"+ />+ </KRadioGroup.ItemControl>+ </KRadioGroup.Item>+ )}+ </For>+ </Show></KRadioGroup></KTabs.Content><KTabs.Content value="image">@@ -454,10 +517,7 @@ export function ConfigSidebar() {createRoot((dispose) =>createEventListenerMap(window, {- mouseup: () => {- resumeHistory();- dispose();- },+ mouseup: () => dispose(),mousemove: (moveEvent) => {const rawNewAngle =Math.round(diff --git a/apps/desktop/src/utils/analytics.ts b/apps/desktop/src/utils/analytics.tsindex 01ee56465..966b96e60 100644--- a/apps/desktop/src/utils/analytics.ts+++ b/apps/desktop/src/utils/analytics.ts@@ -4,17 +4,19 @@ import posthog from "posthog-js";const key = import.meta.env.VITE_POSTHOG_KEY as string;const host = import.meta.env.VITE_POSTHOG_HOST as string;-console.log(key, host);--posthog.init(key, { api_host: host });+if (key && host) {+ posthog.init(key, { api_host: host });+}export function initAnonymousUser() {+ if (!key || !host) return;const anonymousId = localStorage.getItem("anonymous_id") ?? uuid();localStorage.setItem("anonymous_id", anonymousId);posthog.identify(anonymousId);}export function identifyUser(userId: string, properties?: Record<string, any>) {+ if (!key || !host) return;const currentId = posthog.get_distinct_id();if (currentId && currentId !== userId) {posthog.alias(userId);@@ -26,5 +28,6 @@ export function identifyUser(userId: string, properties?: Record<string, any>) {}export function trackEvent(eventName: string, properties?: Record<string, any>) {+ if (!key || !host) return;posthog.capture(eventName, properties);}\ No newline at end of filediff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 38d187140..cd4eeb7c2 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -166,6 +166,9 @@ async writeClipboardString(text: string) : Promise<null> {},async performHapticFeedback(pattern: HapticPattern | null, time: HapticPerformanceTime | null) : Promise<null> {return await TAURI_INVOKE("perform_haptic_feedback", { pattern, time });+},+async getWallpaperPath(filename: string) : Promise<string> {+ return await TAURI_INVOKE("get_wallpaper_path", { filename });}}diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex eb8fbe21a..320ef7cc5 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -86,12 +86,21 @@ impl From<BackgroundSource> for Background {],angle: angle as f32,},- BackgroundSource::Image { path } => Background::Image {- path: path.clone().unwrap(),- },- BackgroundSource::Wallpaper { path } => Background::Image {- path: path.clone().unwrap(),- },+ BackgroundSource::Image { path } | BackgroundSource::Wallpaper { path } => {+ if let Some(path) = path {+ if !path.is_empty() {+ let clean_path = path+ .replace("asset://localhost/", "/")+ .replace("asset://", "")+ .replace("localhost//", "/");++ if std::path::Path::new(&clean_path).exists() {+ return Background::Image { path: clean_path };+ }+ }+ }+ Background::Color([1.0, 1.0, 1.0, 1.0])+ }}}}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 92503f19d..796658426 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -122,8 +122,8 @@ importers:specifier: 2.0.1version: 2.0.1'@tauri-apps/plugin-fs':- specifier: 2.0.3- version: 2.0.3+ specifier: 2.2.0+ version: 2.2.0'@tauri-apps/plugin-http':specifier: ^2.0.1version: 2.0.1@@ -4632,8 +4632,8 @@ packages:'@tauri-apps/[email protected]':resolution: {integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==}- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-3Xv9cg5krj/2gSo1HFn9GbKUE0keh+DMx7O+hQeSzg1T4yGY5Fv/+yBISmrPa2j9thi3qcjgPj8PnMH4rbl/Dw==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-+08mApuONKI8/sCNEZ6AR8vf5vI9DXD4YfrQ9NQmhRxYKMLVhRW164vdW5BSLmMpuevftpQ2FVoL9EFkfG9Z+g==}'@tauri-apps/[email protected]':resolution: {integrity: sha512-j6IA3pVBybSCwPpsihpX4z8bs6PluuGtr06ahL/xy4D8HunNBTmRmadJrFOQi0gOAbaig4MkQ15nzNLBLy8R1A==}@@ -15415,7 +15415,7 @@ snapshots:dependencies:'@tauri-apps/api': 2.1.1- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':dependencies:'@tauri-apps/api': 2.1.1@@ -17961,7 +17961,7 @@ snapshots:doctrine: 2.1.0eslint: 8.57.1eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.12.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])+ eslint-module-utils: 2.12.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected]))([email protected])hasown: 2.0.2is-core-module: 2.15.1is-glob: 4.0.3