Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
always use project-configuration.json instead of taking project config from frontend (#324)
Brendan Allan3865cd1a5ecb
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rsindex 5a93e44b8..2397a3bb8 100644--- a/apps/desktop/src-tauri/src/export.rs+++ b/apps/desktop/src-tauri/src/export.rs@@ -12,7 +12,6 @@ use tauri::AppHandle;pub async fn export_video(app: AppHandle,video_id: String,- project: ProjectConfiguration,progress: tauri::ipc::Channel<RenderProgress>,force: bool,fps: u32,@@ -62,7 +61,7 @@ pub async fn export_video(.ok();// Create a modified project configuration that accounts for different video lengths- let mut modified_project = project.clone();+ let mut modified_project = editor_instance.project_config.1.borrow().clone();if let Some(timeline) = &mut modified_project.timeline {// Ensure timeline duration matches the longest videofor segment in timeline.segments.iter_mut() {diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex a69ed9a17..5c808fc91 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -13,6 +13,7 @@ mod audio_meter;mod editor_window;mod export;mod fake_window;+mod presets;mod tray;mod upload;mod web_api;@@ -41,6 +42,7 @@ use mp4::Mp4Reader;// use display::{list_capture_windows, Bounds, CaptureTarget, FPS};use notifications::NotificationType;use png::{ColorType, Encoder};+use presets::PresetsStore;use relative_path::RelativePathBuf;use scap::capturer::Capturer;use scap::frame::Frame;@@ -2002,6 +2004,7 @@ pub async fn run() {.error_handling(tauri_specta::ErrorHandlingMode::Throw).typ::<ProjectConfiguration>().typ::<AuthStore>()+ .typ::<presets::PresetsStore>().typ::<hotkeys::HotkeysStore>().typ::<general_settings::GeneralSettingsStore>().typ::<cap_flags::Flags>();diff --git a/apps/desktop/src-tauri/src/presets.rs b/apps/desktop/src-tauri/src/presets.rsnew file mode 100644index 000000000..8f868b258--- /dev/null+++ b/apps/desktop/src-tauri/src/presets.rs@@ -0,0 +1,66 @@+use cap_project::{ProjectConfiguration, TimelineConfiguration};+use serde::{Deserialize, Serialize};+use serde_json::json;+use specta::Type;+use tauri::{AppHandle, Wry};+use tauri_plugin_store::StoreExt;++#[derive(Serialize, Deserialize, Type, Debug, Default)]+#[serde(rename_all = "camelCase")]+pub struct PresetsStore {+ presets: Vec<Preset>,+ default: Option<u32>,+}++#[derive(Serialize, Deserialize, Type, Debug, Clone)]+#[serde(rename_all = "camelCase")]+pub struct Preset {+ name: String,+ pub config: ProjectConfiguration,+}++impl PresetsStore {+ fn get(app: &AppHandle<Wry>) -> Result<Option<Self>, String> {+ match app.get_store("store").map(|s| s.get("presets")) {+ Some(Some(store)) => {+ // Handle potential deserialization errors gracefully+ match serde_json::from_value(store) {+ Ok(settings) => Ok(Some(settings)),+ Err(_) => Err("Failed to deserialize presets store".to_string()),+ }+ }+ _ => Ok(None),+ }+ }++ pub fn get_default_preset(app: &AppHandle<Wry>) -> Result<Option<Preset>, String> {+ let Some(this) = Self::get(app)? else {+ return Ok(None);+ };++ let Some(default_i) = this.default else {+ return Ok(None);+ };++ Ok(this.presets.get(default_i as usize).cloned())+ }++ pub fn update(app: &AppHandle, update: impl FnOnce(&mut Self)) -> Result<(), String> {+ let Some(store) = app.get_store("store") else {+ return Err("Store not found".to_string());+ };++ let mut settings = Self::get(app)?.unwrap_or_default();+ update(&mut settings);+ store.set("presets", json!(settings));+ store.save().map_err(|e| e.to_string())+ }+}++impl Preset {+ fn resolve(&self, timeline: TimelineConfiguration) -> ProjectConfiguration {+ let mut ret = self.config.clone();+ ret.timeline = Some(timeline);+ ret+ }+}diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex b2cb690ab..e856c936f 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -7,6 +7,7 @@ use crate::{export::export_video,general_settings::GeneralSettingsStore,notifications, open_editor, open_external_link,+ presets::PresetsStore,upload::get_s3_config,upload_exported_video, web_api,windows::{CapWindowId, ShowCapWindow},@@ -235,7 +236,11 @@ async fn handle_recording_finished(let recordings = ProjectRecordings::new(&completed_recording.meta);- let config = project_config_from_recording(&completed_recording, &recordings);+ let config = project_config_from_recording(+ &completed_recording,+ &recordings,+ PresetsStore::get_default_preset(&app)?.map(|p| p.config),+ );config.write(&completed_recording.recording_dir)@@ -277,7 +282,6 @@ async fn handle_recording_finished(export_video(app.clone(),completed_recording.id.clone(),- config,tauri::ipc::Channel::new(|_| Ok(())),true,completed_recording.meta.content.max_fps(),@@ -387,6 +391,7 @@ fn generate_zoom_segments_from_clicks(fn project_config_from_recording(completed_recording: &CompletedRecording,recordings: &ProjectRecordings,+ default_config: Option<ProjectConfiguration>,) -> ProjectConfiguration {ProjectConfiguration {timeline: Some(TimelineConfiguration {@@ -403,6 +408,6 @@ fn project_config_from_recording(.collect(),zoom_segments: generate_zoom_segments_from_clicks(&completed_recording, &recordings),}),- ..Default::default()+ ..default_config.unwrap_or_default()}}diff --git a/apps/desktop/src/routes/(window-chrome)/licensing.tsx b/apps/desktop/src/routes/(window-chrome)/licensing.tsxindex 76c867b9a..18a77a7eb 100644--- a/apps/desktop/src/routes/(window-chrome)/licensing.tsx+++ b/apps/desktop/src/routes/(window-chrome)/licensing.tsx@@ -274,7 +274,7 @@ function CommercialLicensePurchase() {await generalSettingsStore.set({commercialLicense: {activatedOn: Date.now(),- expiryDate: value.expiryDate,+ expiryDate: value.expiryDate ?? null,refresh: value.refresh,licenseKey: value.licenseKey,},diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsxindex 589b823b8..f4e98ff2e 100644--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx@@ -1,4 +1,4 @@-import { createSignal, onCleanup, onMount } from "solid-js";+import { createSignal, onCleanup, onMount, Show } from "solid-js";import { Button } from "@cap/ui-solid";import { getCurrentWindow } from "@tauri-apps/api/window";import * as shell from "@tauri-apps/plugin-shell";@@ -172,28 +172,24 @@ const signInAction = action(async (planType: "yearly" | "monthly") => {}});-export default function Page() {- const proFeatures = [- "Commercial License Included",- "Unlimited cloud storage & Shareable links",- "Connect custom S3 storage bucket",- "Advanced teams features",- "Unlimited views",- "Password protected videos",- "Advanced analytics",- "Priority support",- ];+const proFeatures = [+ "Commercial License Included",+ "Unlimited cloud storage & Shareable links",+ "Connect custom S3 storage bucket",+ "Advanced teams features",+ "Unlimited views",+ "Password protected videos",+ "Advanced analytics",+ "Priority support",+];+export default function Page() {const [isAnnual, setIsAnnual] = createSignal(true);const [isCommercialAnnual, setIsCommercialAnnual] = createSignal(true);const [upgradeComplete, setUpgradeComplete] = createSignal(false);const [loading, setLoading] = createSignal(false);- const [isAuthenticated, setIsAuthenticated] = createSignal(true);- const [licenseKey, setLicenseKey] = createSignal("");const signIn = useAction(signInAction);- const submission = useSubmission(signInAction);const license = createLicenseQuery();- const navigate = useNavigate();const resetLicense = createMutation(() => ({mutationFn: async () => {@@ -232,16 +228,6 @@ export default function Page() {},}));- const togglePricing = () => {- console.log("Toggling pricing plan");- setIsAnnual(!isAnnual());- };-- const toggleCommercialPricing = () => {- console.log("Toggling commercial pricing plan");- setIsCommercialAnnual(!isCommercialAnnual());- };-const openCheckoutInExternalBrowser = async () => {console.log("Opening checkout in external browser");setLoading(true);@@ -301,38 +287,6 @@ export default function Page() {},}));- const activateLicenseKey = createMutation(() => ({- mutationFn: async (vars: { licenseKey: string }) => {- const generalSettings = await generalSettingsStore.get();- if (!generalSettings?.instanceId) {- throw new Error("No instance ID found");- }- const resp = await licenseApiClient.activateCommercialLicense({- headers: {- licensekey: vars.licenseKey,- instanceid: generalSettings.instanceId,- },- body: { reset: false },- });-- if (resp.status === 200)- return { ...resp.body, licenseKey: vars.licenseKey };- if (typeof resp.body === "object" && resp.body && "message" in resp.body)- throw resp.body.message;- throw new Error((resp.body as any).toString());- },- onSuccess: async (value) => {- await generalSettingsStore.set({- commercialLicense: {- activatedOn: Date.now(),- expiryDate: value.expiryDate,- refresh: value.refresh,- licenseKey: value.licenseKey,- },- });- },- }));-onMount(async () => {console.log("Component mounted");const unsubscribeDeepLink = await onOpenUrl(async (urls) => {@@ -482,21 +436,25 @@ export default function Page() {</pre></div>- <div class="space-y-2">- <label class="text-sm font-medium text-[--text-primary]">- Expiration Date- </label>- <div class="w-full p-3 bg-gray-50 dark:bg-[--gray-800] rounded-lg border border-gray-200 dark:border-[--gray-700] text-sm text-[--text-secondary]">- {new Date(license.data.expiryDate).toLocaleDateString(- undefined,- {- year: "numeric",- month: "long",- day: "numeric",- }- )}- </div>- </div>+ <Show when={license.data.expiryDate}>+ {(expiryDate) => (+ <div class="space-y-2">+ <label class="text-sm font-medium text-[--text-primary]">+ Expiration Date+ </label>+ <div class="w-full p-3 bg-gray-50 dark:bg-[--gray-800] rounded-lg border border-gray-200 dark:border-[--gray-700] text-sm text-[--text-secondary]">+ {new Date(expiryDate()).toLocaleDateString(+ undefined,+ {+ year: "numeric",+ month: "long",+ day: "numeric",+ }+ )}+ </div>+ </div>+ )}+ </Show><div class="pt-4 border-t border-gray-200 dark:border-[--gray-700]"><Button@@ -575,7 +533,7 @@ export default function Page() {}value={!isCommercialAnnual() ? "on" : "off"}class="peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-[--gray-400] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"- onClick={toggleCommercialPricing}+ onClick={() => setIsCommercialAnnual((v) => !v)}><spandata-state={@@ -601,31 +559,8 @@ export default function Page() {: "Purchase License"}</button></div>- <div class="px-6 pt-0">- <p class="text-[--text-primary] text-sm mb-2">- Already have a license key?- </p>- <div class="h-[76px]">- <Input- placeholder="Enter license key"- value={licenseKey()}- onInput={(e) => setLicenseKey(e.currentTarget.value)}- />- <Button- class="mt-2 w-full relative"- disabled={activateLicenseKey.isPending}- onClick={() =>- activateLicenseKey.mutate({- licenseKey: licenseKey(),- })- }- >- <div class="w-full flex justify-center">- Activate License- </div>- </Button>- </div>- </div>+ <LicenseKeyActivation />+<div class="flex items-center px-6 pt-0 pb-6"><div class="space-y-6"><div>@@ -692,7 +627,7 @@ export default function Page() {data-state={isAnnual() ? "unchecked" : "checked"}value={isAnnual() ? "on" : "off"}class="peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent dark:bg-[#3F75E0] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 bg-[--blue-400]"- onClick={togglePricing}+ onClick={() => setIsAnnual((v) => !v)}><spandata-state={isAnnual() ? "unchecked" : "checked"}@@ -742,3 +677,65 @@ export default function Page() {</div>);}++function LicenseKeyActivation() {+ const [licenseKey, setLicenseKey] = createSignal("");++ const activateLicenseKey = createMutation(() => ({+ mutationFn: async (vars: { licenseKey: string }) => {+ const generalSettings = await generalSettingsStore.get();+ if (!generalSettings?.instanceId) {+ throw new Error("No instance ID found");+ }+ const resp = await licenseApiClient.activateCommercialLicense({+ headers: {+ licensekey: vars.licenseKey,+ instanceid: generalSettings.instanceId,+ },+ body: { reset: false },+ });++ if (resp.status === 200)+ return { ...resp.body, licenseKey: vars.licenseKey };+ if (typeof resp.body === "object" && resp.body && "message" in resp.body)+ throw resp.body.message;+ throw new Error((resp.body as any).toString());+ },+ onSuccess: async (value) => {+ await generalSettingsStore.set({+ commercialLicense: {+ activatedOn: Date.now(),+ expiryDate: value.expiryDate ?? null,+ refresh: value.refresh,+ licenseKey: value.licenseKey,+ },+ });+ },+ }));++ return (+ <div class="px-6 pt-0">+ <p class="text-[--text-primary] text-sm mb-2">+ Already have a license key?+ </p>+ <div class="h-[76px]">+ <Input+ placeholder="Enter license key"+ value={licenseKey()}+ onInput={(e) => setLicenseKey(e.currentTarget.value)}+ />+ <Button+ class="mt-2 w-full relative"+ disabled={activateLicenseKey.isPending}+ onClick={() =>+ activateLicenseKey.mutate({+ licenseKey: licenseKey(),+ })+ }+ >+ <div class="w-full flex justify-center">Activate License</div>+ </Button>+ </div>+ </div>+ );+}diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex 7eef74110..aa1e2aafb 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -41,11 +41,7 @@ import {Toggle,Slider,} from "./ui";-import {- DEFAULT_GRADIENT_FROM,- DEFAULT_GRADIENT_TO,- DEFAULT_PROJECT_CONFIG,-} from "./projectConfig";+import { DEFAULT_GRADIENT_FROM, DEFAULT_GRADIENT_TO } from "./projectConfig";import { generalSettingsStore } from "~/store";import { type as ostype } from "@tauri-apps/plugin-os";import toast from "solid-toast";@@ -806,7 +802,7 @@ export function ConfigSidebar() {<Field name="Shadow" icon={<IconCapShadow />}><div class="space-y-3"><Slider- value={[project.background.shadow]}+ value={[project.background.shadow!]}onChange={(v) => {batch(() => {setProject("background", "shadow", v[0]);@@ -978,16 +974,10 @@ export function ConfigSidebar() {<Fieldname="Size During Zoom"icon={<IconCapEnlarge />}- value={`${- project.camera.zoom_size ??- DEFAULT_PROJECT_CONFIG.camera.zoom_size- }%`}+ value={`${project.camera.zoom_size}%`}><Slider- value={[- project.camera.zoom_size ??- DEFAULT_PROJECT_CONFIG.camera.zoom_size,- ]}+ value={[project.camera.zoom_size!]}onChange={(v) => setProject("camera", "zoom_size", v[0])}minValue={10}maxValue={60}@@ -996,10 +986,7 @@ export function ConfigSidebar() {</Field><Field name="Rounded Corners" icon={<IconCapCorners />}><Slider- value={[- project.camera.rounding ??- DEFAULT_PROJECT_CONFIG.camera.rounding,- ]}+ value={[project.camera.rounding!]}onChange={(v) => setProject("camera", "rounding", v[0])}minValue={0}maxValue={100}@@ -1009,7 +996,7 @@ export function ConfigSidebar() {<Field name="Shadow" icon={<IconCapShadow />}><div class="space-y-3"><Slider- value={[project.camera.shadow]}+ value={[project.camera.shadow!]}onChange={(v) => setProject("camera", "shadow", v[0])}minValue={0}maxValue={100}diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsxindex 563aaf25a..952225b6b 100644--- a/apps/desktop/src/routes/editor/Editor.tsx+++ b/apps/desktop/src/routes/editor/Editor.tsx@@ -53,10 +53,12 @@ export function Editor() {when={(() => {const ctx = useEditorInstanceContext();const editorInstance = ctx.editorInstance();- const presets = ctx.presets.query();- if (!editorInstance || !presets) return;- return { editorInstance, presets };+ if (!editorInstance) return;++ return {+ editorInstance,+ };})()}>{(values) => (@@ -209,7 +211,7 @@ function Dialogs() {>{(dialog) => {const [name, setName] = createSignal(- presets.query()?.presets[dialog().presetIndex].name!+ presets.query.data?.presets[dialog().presetIndex].name!);const renamePreset = createMutation(() => ({diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsxindex 162cfe62c..7cf0ecd66 100644--- a/apps/desktop/src/routes/editor/Header.tsx+++ b/apps/desktop/src/routes/editor/Header.tsx@@ -210,7 +210,6 @@ function ExportButton(props: {try {const videoPath = await commands.exportVideo(videoId,- project,progress,true,props.selectedFps,@@ -573,7 +572,6 @@ function ShareButton(props: {await commands.exportVideo(videoId,- project,progress,true,props.selectedFps(),diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsxindex a5f632d3d..1d97d020d 100644--- a/apps/desktop/src/routes/editor/Player.tsx+++ b/apps/desktop/src/routes/editor/Player.tsx@@ -401,7 +401,7 @@ function PresetsDropdown() {class="flex-1 overflow-y-auto scrollbar-none"><For- each={presets.query()?.presets ?? []}+ each={presets.query.data?.presets ?? []}fallback={<div class="w-full text-sm text-gray-400 text-center py-1">No Presets@@ -419,7 +419,7 @@ function PresetsDropdown() {onClick={() => setShowSettings(false)}><span class="mr-auto">{preset.name}</span>- <Show when={presets.query()?.default === i()}>+ <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>diff --git a/apps/desktop/src/routes/editor/context.ts b/apps/desktop/src/routes/editor/context.tsindex 551b3899e..d7c3e78a5 100644--- a/apps/desktop/src/routes/editor/context.ts+++ b/apps/desktop/src/routes/editor/context.ts@@ -15,15 +15,14 @@ import {import { createStore, reconcile, unwrap } from "solid-js/store";import { createElementBounds, NullableBounds } from "@solid-primitives/bounds";-import type { PresetsStore } from "../../store";import {+ PresetsStore,type ProjectConfiguration,type SerializedEditorInstance,type XY,commands,events,} from "~/utils/tauri";-import { DEFAULT_PROJECT_CONFIG } from "./projectConfig";import { createImageDataWS, createLazySignal } from "~/utils/socket";import { createPresets } from "~/utils/createPresets";@@ -45,22 +44,10 @@ export const OUTPUT_SIZE = {export const MAX_ZOOM_IN = 3;export const [EditorContextProvider, useEditorContext] = createContextProvider(- (props: {- editorInstance: SerializedEditorInstance;- presets: PresetsStore;- }) => {+ (props: { editorInstance: SerializedEditorInstance }) => {const editorInstanceContext = useEditorInstanceContext();const [project, setProject] = createStore<ProjectConfiguration>(- props.editorInstance.savedProjectConfig ??- (() => {- const config =- props.presets.presets[props.presets.default ?? 0]?.config;- if (!config) return;- // @ts-ignore- config.timeline = undefined;- return config;- })() ??- DEFAULT_PROJECT_CONFIG+ props.editorInstance.savedProjectConfig);createEffect(diff --git a/apps/desktop/src/routes/editor/projectConfig.ts b/apps/desktop/src/routes/editor/projectConfig.tsindex 5bcd035bf..11e50db95 100644--- a/apps/desktop/src/routes/editor/projectConfig.ts+++ b/apps/desktop/src/routes/editor/projectConfig.ts@@ -1,44 +1,10 @@-import type { AspectRatio, ProjectConfiguration } from "~/utils/tauri";+import type { AspectRatio } from "~/utils/tauri";export type RGBColor = [number, number, number];export const DEFAULT_GRADIENT_FROM = [71, 133, 255] satisfies RGBColor;export const DEFAULT_GRADIENT_TO = [255, 71, 102] satisfies RGBColor;-export const DEFAULT_PROJECT_CONFIG = {- aspectRatio: null,- background: {- source: {- type: "wallpaper",- path: "sequoia-dark",- },- blur: 0,- padding: 0,- rounding: 0,- inset: 0,- crop: null,- shadow: 50,- },- camera: {- hide: false,- mirror: false,- position: { x: "right", y: "bottom" },- rounding: 100,- shadow: 50,- size: 30,- zoom_size: 60,- },- audio: { mute: false, improve: false },- cursor: {- hideWhenIdle: false,- size: 0,- type: "pointer",- animationStyle: "regular" as const,- },- hotkeys: { show: false },- motionBlur: 0.2,-} satisfies ProjectConfiguration;-export const ASPECT_RATIOS = {wide: { name: "Wide", ratio: [16, 9] },vertical: { name: "Vertical", ratio: [9, 16] },diff --git a/apps/desktop/src/routes/recordings-overlay.tsx b/apps/desktop/src/routes/recordings-overlay.tsxindex 516c79b96..592d87322 100644--- a/apps/desktop/src/routes/recordings-overlay.tsx+++ b/apps/desktop/src/routes/recordings-overlay.tsx@@ -26,7 +26,6 @@ import { createStore, produce, SetStoreFunction } from "solid-js/store";import IconLucideClock from "~icons/lucide/clock";import { commands, events, RenderProgress, UploadResult } from "~/utils/tauri";-import { DEFAULT_PROJECT_CONFIG } from "./editor/projectConfig";import { createPresets } from "~/utils/createPresets";import { FPS, OUTPUT_SIZE } from "./editor/context";import { authStore } from "~/store";@@ -587,7 +586,6 @@ function createRecordingMutations(// First try to get existing rendered videoconst outputPath = await commands.exportVideo(mediaId,- presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG,progress,false,FPS,@@ -680,7 +678,6 @@ function createRecordingMutations(// Always force re-render when savingconst outputPath = await commands.exportVideo(mediaId,- presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG,progress,true, // Force re-renderFPS,@@ -772,7 +769,6 @@ function createRecordingMutations(// First try to get existing rendered videoawait commands.exportVideo(mediaId,- presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG,progress,false,FPS,diff --git a/apps/desktop/src/store.ts b/apps/desktop/src/store.tsindex cb8261de3..f4d81d340 100644--- a/apps/desktop/src/store.ts+++ b/apps/desktop/src/store.ts@@ -4,7 +4,7 @@ import { onCleanup } from "solid-js";import {type AuthStore,- type ProjectConfiguration,+ type PresetsStore,type HotkeysStore,type GeneralSettingsStore,} from "~/utils/tauri";@@ -18,14 +18,6 @@ const store = () => {return _store;};-export type PresetsStore = {- presets: Array<{- name: string;- config: Omit<ProjectConfiguration, "timeline">;- }>;- default?: number;-};-function declareStore<T extends object>(name: string) {const get = () => store().then((s) => s.get<T>(name));const listen = (fn: (data?: T | undefined) => void) =>diff --git a/apps/desktop/src/utils/createPresets.ts b/apps/desktop/src/utils/createPresets.tsindex de78411a7..0fc009e64 100644--- a/apps/desktop/src/utils/createPresets.ts+++ b/apps/desktop/src/utils/createPresets.ts@@ -1,8 +1,5 @@-import { createResource, onCleanup } from "solid-js";--import type { ProjectConfiguration } from "~/utils/tauri";-import { presetsStore, type PresetsStore } from "~/store";-import { DEFAULT_PROJECT_CONFIG } from "~/routes/editor/projectConfig";+import type { PresetsStore, ProjectConfiguration } from "~/utils/tauri";+import { presetsStore } from "~/store";export type CreatePreset = {name: string;@@ -11,20 +8,13 @@ export type CreatePreset = {};export function createPresets() {- const [query, queryActions] = createResource(async () => {- return (await presetsStore.get()) ?? ({ presets: [] } as PresetsStore);- });-- const [cleanup] = createResource(() =>- presetsStore.listen((data) => {- if (data) queryActions.mutate(data);- })- );- onCleanup(() => cleanup()?.());+ const query = presetsStore.createQuery();async function updatePresets(fn: (prev: PresetsStore) => PresetsStore) {- const p = query();- if (!p) throw new Error("Presets not loaded");+ if (query.isLoading) throw new Error("Presets not loaded");++ let p = query.data;+ if (!p) await presetsStore.set((p = { presets: [], default: null }));const newValue = fn(p);@@ -55,19 +45,6 @@ export function createPresets() {: prev.default,};}),- getDefaultConfig: () => {- const p = query();- if (!p) return DEFAULT_PROJECT_CONFIG;-- const config = p.presets[p.default ?? 0]?.config;- if (!config) return DEFAULT_PROJECT_CONFIG;-- console.log("Config:", config);-- // @ts-ignore we reeeally don't want the timeline in the preset- config.timeline = undefined;- return config;- },setDefault: (index: number) =>updatePresets((prev) => ({presets: [...prev.presets],diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex c1cdc497d..60bad7887 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -53,8 +53,8 @@ async focusCapturesPanel() : Promise<void> {async getCurrentRecording() : Promise<JsonValue<RecordingInfo | null>> {return await TAURI_INVOKE("get_current_recording");},-async exportVideo(videoId: string, project: ProjectConfiguration, progress: TAURI_CHANNEL<RenderProgress>, force: boolean, fps: number, resolutionBase: XY<number>) : Promise<string> {- return await TAURI_INVOKE("export_video", { videoId, project, progress, force, fps, resolutionBase });+async exportVideo(videoId: string, progress: TAURI_CHANNEL<RenderProgress>, force: boolean, fps: number, resolutionBase: XY<number>) : Promise<string> {+ return await TAURI_INVOKE("export_video", { videoId, progress, force, fps, resolutionBase });},async getExportEstimates(videoId: string, resolution: XY<number>, fps: number) : Promise<ExportEstimates> {return await TAURI_INVOKE("get_export_estimates", { videoId, resolution, fps });@@ -229,7 +229,7 @@ export type AuthenticationInvalid = nullexport type BackgroundConfiguration = { source: BackgroundSource; blur: number; padding: number; rounding: number; inset: number; crop: Crop | null; shadow?: number; advancedShadow?: ShadowConfiguration | null }export type BackgroundSource = { type: "wallpaper"; path: string | null } | { type: "image"; path: string | null } | { type: "color"; value: [number, number, number] } | { type: "gradient"; from: [number, number, number]; to: [number, number, number]; angle?: number }export type Bounds = { x: number; y: number; width: number; height: number }-export type Camera = { hide: boolean; mirror: boolean; position: CameraPosition; size: number; zoom_size: number | null; rounding: number; shadow?: number; advanced_shadow?: ShadowConfiguration | null }+export type Camera = { hide: boolean; mirror: boolean; position: CameraPosition; size: number; zoom_size?: number; rounding?: number; shadow?: number; advanced_shadow?: ShadowConfiguration | null }export type CameraMeta = { path: string; fps?: number }export type CameraPosition = { x: CameraXPosition; y: CameraYPosition }export type CameraXPosition = "left" | "center" | "right"@@ -267,6 +267,8 @@ export type OSPermissionStatus = "notNeeded" | "empty" | "granted" | "denied"export type OSPermissionsCheck = { screenRecording: OSPermissionStatus; microphone: OSPermissionStatus; camera: OSPermissionStatus; accessibility: OSPermissionStatus }export type Plan = { upgraded: boolean; manual: boolean; last_checked: number }export type PreCreatedVideo = { id: string; link: string; config: S3UploadMeta }+export type Preset = { name: string; config: ProjectConfiguration }+export type PresetsStore = { presets: Preset[]; default: number | null }export type ProjectConfiguration = { aspectRatio: AspectRatio | null; background: BackgroundConfiguration; camera: Camera; audio: AudioConfiguration; cursor: CursorConfiguration; hotkeys: HotkeysConfiguration; timeline?: TimelineConfiguration | null; motionBlur: number | null }export type ProjectRecordings = { segments: SegmentRecordings[] }export type RecordingConfig = { fps: number; resolution: Resolution }diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rsindex 6df6a1517..eeb86caf3 100644--- a/crates/project/src/configuration.rs+++ b/crates/project/src/configuration.rs@@ -228,7 +228,9 @@ pub struct Camera {pub mirror: bool,pub position: CameraPosition,pub size: f32,- pub zoom_size: Option<f32>,+ #[serde(default = "Camera::default_zoom_size")]+ pub zoom_size: f32,+ #[serde(default = "Camera::default_rounding")]pub rounding: f32,#[serde(default)]pub shadow: f32,@@ -236,6 +238,16 @@ pub struct Camera {pub advanced_shadow: Option<ShadowConfiguration>,}+impl Camera {+ fn default_zoom_size() -> f32 {+ 60.0+ }++ fn default_rounding() -> f32 {+ 30.0+ }+}+impl Default for Camera {fn default() -> Self {Self {@@ -243,8 +255,8 @@ impl Default for Camera {mirror: false,position: CameraPosition::default(),size: 30.0,- zoom_size: None,- rounding: 100.0,+ zoom_size: Self::default_zoom_size(),+ rounding: Self::default_rounding(),shadow: 62.5,advanced_shadow: Some(ShadowConfiguration {size: 33.9,diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 8572322e7..7965749ee 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -784,7 +784,7 @@ impl ProjectUniforms {// Calculate camera size based on zoomlet base_size = project.camera.size / 100.0;- let zoom_size = project.camera.zoom_size.unwrap_or(60.0) / 100.0;+ let zoom_size = project.camera.zoom_size / 100.0;let zoomed_size =(zoom.t as f32) * zoom_size * base_size + (1.0 - zoom.t as f32) * base_size;