Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
commercial licensing
Brendan Allan9c3027a45cbe
diff --git a/Cargo.lock b/Cargo.lockindex fbd12152f..07f8688c5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -6765,6 +6765,7 @@ dependencies = ["paste","specta-macros","thiserror 1.0.63",+ "uuid",][[package]]diff --git a/Cargo.toml b/Cargo.tomlindex 840be2b2e..101efebc9 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -19,7 +19,7 @@ tokio = { version = "1.39.3", features = ["time",] }tauri = { version = "2.2.3", features = ["specta"] }-specta = { version = "=2.0.0-rc.20", features = ["derive"] }+specta = { version = "=2.0.0-rc.20", features = ["derive", "uuid"] }scap = { git = "https://github.com/CapSoftware/scap", rev = "58d4410bf52f" }nokhwa = { git = "https://github.com/CapSoftware/nokhwa", rev = "d37141b1883d", features = [diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.jsonindex 8a3d29a50..7d0b42272 100644--- a/apps/desktop/src-tauri/capabilities/default.json+++ b/apps/desktop/src-tauri/capabilities/default.json@@ -56,6 +56,7 @@"identifier": "http:default","allow": [{ "url": "https://cap.so" },+ { "url": "https://l.cap.so" },{ "url": "http://localhost:3000/*" }]},diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rsindex 055bf9b29..56a731c2b 100644--- a/apps/desktop/src-tauri/src/general_settings.rs+++ b/apps/desktop/src-tauri/src/general_settings.rs@@ -5,10 +5,13 @@ use specta::Type;use std::sync::Mutex;use tauri::{AppHandle, Manager, Wry};use tauri_plugin_store::StoreExt;+use uuid::Uuid;-#[derive(Serialize, Deserialize, Type, Default)]+#[derive(Serialize, Deserialize, Type, Debug)]#[serde(rename_all = "camelCase")]pub struct GeneralSettingsStore {+ #[serde(default = "uuid::Uuid::new_v4")]+ pub instance_id: Uuid,#[serde(default)]pub upload_individual_files: bool,#[serde(default)]@@ -30,6 +33,39 @@ pub struct GeneralSettingsStore {pub theme: AppTheme,#[serde(default)]pub recording_config: Option<RecordingConfig>,+ #[serde(default)]+ pub commercial_license: Option<CommercialLicense>,+ #[serde(default)]+ pub last_version: Option<String>,+}++#[derive(Serialize, Deserialize, Type, Debug)]+#[serde(rename_all = "camelCase")]+pub struct CommercialLicense {+ license_key: String,+ expiry_date: u32,+ refresh: u32,+ activated_on: u32,+}++impl Default for GeneralSettingsStore {+ fn default() -> Self {+ Self {+ instance_id: uuid::Uuid::new_v4(),+ upload_individual_files: false,+ open_editor_after_recording: false,+ hide_dock_icon: false,+ haptics_enabled: true,+ auto_create_shareable_link: false,+ enable_notifications: true,+ disable_auto_open_links: false,+ has_completed_startup: false,+ theme: AppTheme::System,+ recording_config: None,+ commercial_license: None,+ last_version: None,+ }+ }}#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize, Type)]@@ -71,7 +107,7 @@ impl GeneralSettingsStore {// Handle potential deserialization errors gracefullymatch serde_json::from_value(store) {Ok(settings) => Ok(Some(settings)),- Err(_) => Ok(Some(GeneralSettingsStore::default())),+ Err(_) => Err("Failed to deserialize general settings store".to_string()),}}_ => Ok(None),@@ -102,20 +138,3 @@ pub fn init(app: &AppHandle) {app.manage(GeneralSettingsState::new(store));println!("GeneralSettingsState managed");}--#[tauri::command]-#[specta::specta]-pub async fn get_recording_config(app: AppHandle) -> Result<RecordingConfig, String> {- let settings = GeneralSettingsStore::get(&app)?;- Ok(settings- .and_then(|s| s.recording_config)- .unwrap_or_default())-}--#[tauri::command]-#[specta::specta]-pub async fn set_recording_config(app: AppHandle, config: RecordingConfig) -> Result<(), String> {- GeneralSettingsStore::update(&app, |settings| {- settings.recording_config = Some(config);- })-}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 0520c4add..46efe7ce2 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -2102,6 +2102,7 @@ pub async fn run() {CapWindowId::Camera.label().as_str(),CapWindowId::RecordingsOverlay.label().as_str(),CapWindowId::InProgressRecording.label().as_str(),+ CapWindowId::Upgrade.label().as_str(),]).map_label(|label| match label {label if label.starts_with("editor-") => "editor",@@ -2173,9 +2174,7 @@ pub async fn run() {if !permissions.screen_recording.permitted()|| !permissions.accessibility.permitted()- || GeneralSettingsStore::get(&app)- .ok()- .flatten()+ || dbg!(GeneralSettingsStore::get(&app).ok().flatten()).map(|s| !s.has_completed_startup).unwrap_or(false){diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex 20de61d70..402cd2c99 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -129,6 +129,7 @@ impl CapWindowId {Self::Editor { .. } => (900.0, 800.0),Self::Settings => (600.0, 450.0),Self::Camera => (460.0, 920.0),+ Self::Upgrade => (800.0, 850.0),_ => return None,})}@@ -200,7 +201,6 @@ impl ShowCapWindow {.build()?,Self::Upgrade => self.window_builder(app, "/upgrade")- .inner_size(800.0, 800.0).resizable(false).focused(true).always_on_top(true)diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsxindex 58e87804d..3cf326c47 100644--- a/apps/desktop/src/App.tsx+++ b/apps/desktop/src/App.tsx@@ -68,13 +68,15 @@ function Inner() {fallback={(e: Error) => {console.error(e);return (- <div class="w-screen h-screen flex flex-col justify-center items-center bg-gray-100 border-gray-200 max-h-screen overflow-hidden transition-[border-radius] duration-200 text-[--text-secondary] gap-y-4">- <IconCapLogo />- <h1 class="text-[--text-primary] text-3xl font-bold">+ <div class="w-screen h-screen flex flex-col justify-center items-center bg-gray-100 border-gray-200 max-h-screen overflow-hidden transition-[border-radius] duration-200 text-[--text-secondary] gap-y-4 max-sm:gap-y-2 px-8 text-center">+ <IconCapLogo class="max-sm:size-16" />+ <h1 class="text-[--text-primary] text-3xl max-sm:text-xl font-bold">An Error Occured</h1>- <p>We're very sorry, but something has gone wrong.</p>- <div class="flex flex-row gap-x-4">+ <p class="max-sm:text-sm mb-2">+ We're very sorry, but something has gone wrong.+ </p>+ <div class="flex max-sm:flex-col flex-row max-sm:gap-2 gap-4"><ButtononClick={() => {writeText(`${e.toString()}\n\n${e.stack}`);diff --git a/apps/desktop/src/entry-server.tsx b/apps/desktop/src/entry-server.tsxindex 1a59aad18..d1fad5f25 100644--- a/apps/desktop/src/entry-server.tsx+++ b/apps/desktop/src/entry-server.tsx@@ -12,7 +12,7 @@ export default createHandler(() => ({assets}</head><body class="w-screen h-screen select-none cursor-default">- <div id="app" class="h-full">+ <div id="app" class="h-full text-[--text-primary]">{children}</div>{scripts}diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsxindex df90a0617..2f75718f6 100644--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx@@ -1,6 +1,6 @@import { Button } from "@cap/ui-solid";import { Select as KSelect, SelectRootProps } from "@kobalte/core/select";-import { cache, createAsync, redirect, useNavigate } from "@solidjs/router";+import { useNavigate } from "@solidjs/router";import {createMutation,createQuery,@@ -27,7 +27,6 @@ import { createStore } from "solid-js/store";import { Tooltip } from "@kobalte/core";import { trackEvent } from "~/utils/analytics";-import { authStore } from "~/store";import {createCurrentRecordingQuery,createOptionsQuery,@@ -36,6 +35,7 @@ import {getPermissions,createVideoDevicesQuery,listScreens,+ createLicenseQuery,} from "~/utils/queries";import {CaptureScreen,@@ -51,28 +51,7 @@ import {topRightAnimateClasses,} from "../editor/ui";-const getAuth = cache(async () => {- const value = await authStore.get();- const local = import.meta.env.VITE_ENVIRONMENT === "development";-- const res = await apiClient.desktop.getUserPlan({- headers: await protectedHeaders(),- });- if (res.status !== 200 && !local) return redirect("/signin");-- return value;-}, "getAuth");--export const route = {- load: () => getAuth(),-};-export default function () {- const [isLoading, setIsLoading] = createSignal(true);- const [loadError, setLoadError] = createSignal(false);- const [retryCount, setRetryCount] = createSignal(0);- const MAX_RETRIES = 3;-const { options, setOptions } = createOptionsQuery();const currentRecording = createCurrentRecordingQuery();@@ -88,229 +67,185 @@ export default function () {},}));- const [isUpgraded] = createResource(() => commands.checkUpgradedAndUpdate());-- createAsync(() => getAuth());+ const license = createLicenseQuery();createUpdateCheck();- const initializeWindow = async () => {- try {- setIsLoading(true);- setLoadError(false);+ let unlistenFn: UnlistenFn;+ onCleanup(() => unlistenFn?.());+ const [initialize] = createResource(async () => {+ const version = await getVersion();- if (- options.data?.cameraLabel &&- options.data.cameraLabel !== "No Camera"- ) {- const cameraWindowActive = await commands.isCameraWindowOpen();+ if (options.data?.cameraLabel && options.data.cameraLabel !== "No Camera") {+ const cameraWindowActive = await commands.isCameraWindowOpen();- if (!cameraWindowActive) {- console.log("cameraWindow not found");- await setOptions.mutate({- ...options.data,- });- }+ if (!cameraWindowActive) {+ console.log("cameraWindow not found");+ setOptions.mutate({+ ...options.data,+ });}+ }- // Enforce window size with multiple safeguards- const currentWindow = await getCurrentWindow();- const MAIN_WINDOW_SIZE = { width: 300, height: 360 };+ // Enforce window size with multiple safeguards+ const currentWindow = getCurrentWindow();+ const MAIN_WINDOW_SIZE = { width: 300, height: 360 };- // Set initial size- await currentWindow.setSize(- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)- );+ // Set initial size+ await currentWindow.setSize(+ new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)+ );- // Check size when app regains focus- const unlistenFocus = await currentWindow.onFocusChanged(- ({ payload: focused }) => {- if (focused) {- currentWindow.setSize(- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)- );- }+ // Check size when app regains focus+ const unlistenFocus = await currentWindow.onFocusChanged(+ ({ payload: focused }) => {+ if (focused) {+ currentWindow.setSize(+ new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)+ );}- );-- // Listen for resize events- const unlistenResize = await currentWindow.onResized(() => {- currentWindow.setSize(- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)- );- });+ }+ );- setTitlebar("hideMaximize", true);- setTitlebar(- "items",- <div- dir={ostype() === "windows" ? "rtl" : "rtl"}- class="flex mx-2 items-center gap-[0.3rem]"- >- <Button- variant="secondary"- size="xs"- onClick={() => {- commands.showWindow({ Settings: { page: "feedback" } });- }}- >- Feedback- </Button>- <ChangelogButton />- <GiftButton />- </div>+ // Listen for resize events+ const unlistenResize = await currentWindow.onResized(() => {+ currentWindow.setSize(+ new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height));+ });- onCleanup(() => {- unlistenFocus();- unlistenResize();- });+ unlistenFn = () => {+ unlistenFocus();+ unlistenResize();+ };- setIsLoading(false);- } catch (error) {- console.error("Failed to initialize window:", error);- setLoadError(true);-- if (retryCount() < MAX_RETRIES) {- setTimeout(() => {- setRetryCount((c) => c + 1);- initializeWindow();- }, 2000 * Math.pow(2, retryCount())); // Exponential backoff- }- }- };+ setTitlebar("hideMaximize", true);+ setTitlebar(+ "items",+ <div+ dir={ostype() === "windows" ? "rtl" : "rtl"}+ class="flex mx-2 items-center gap-[0.3rem]"+ >+ <Button+ variant="secondary"+ size="xs"+ onClick={() => {+ commands.showWindow({ Settings: { page: "feedback" } });+ }}+ >+ Feedback+ </Button>+ <ChangelogButton />+ <GiftButton />+ </div>+ );- onMount(() => {- initializeWindow();+ return null;});return (- <Show- when={!isLoading() && !loadError()}- fallback={- <div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-[--gray-50] h-full text-[--text-primary]">- <div class="flex items-center justify-center h-full">- {loadError() ? (- <div class="text-center">- <p class="text-red-500 mb-2">Failed to load window content</p>- <Show when={retryCount() >= MAX_RETRIES}>- <Button- variant="secondary"- size="sm"- onClick={() => {- setRetryCount(0);- initializeWindow();- }}- >- Retry- </Button>- </Show>- </div>- ) : (- <div class="animate-pulse">Loading...</div>- )}+ <div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-[--gray-50] h-full text-[--text-primary]">+ {initialize()}+ <div class="flex items-center justify-between pb-[0.25rem]">+ <div class="flex items-center space-x-1">+ <div class="*:w-[92px] *:h-auto text-[--text-primary] ">+ <IconCapLogoFullDark class="dark:block hidden" />+ <IconCapLogoFull class="dark:hidden block" /></div>- </div>- }- >- <div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-[--gray-50] h-full text-[--text-primary]">- <div class="flex items-center justify-between pb-[0.25rem]">- <div class="flex items-center space-x-1">- <div class="*:w-[92px] *:h-auto text-[--text-primary] ">- <IconCapLogoFullDark class="dark:block hidden" />- <IconCapLogoFull class="dark:hidden block" />- </div>- <ErrorBoundary fallback={<></>}>- <Suspense>- <span- onClick={async () => {- if (!isUpgraded()) {- await commands.showWindow("Upgrade");- }- }}- class={`text-[0.6rem] ${- isUpgraded()- ? "bg-[--blue-400] text-gray-50 dark:text-gray-500"- : "bg-gray-200 cursor-pointer hover:bg-gray-300"- } rounded-lg px-1.5 py-0.5`}- >- {isUpgraded() ? "Pro" : "Upgrade to Pro"}- </span>- </Suspense>- </ErrorBoundary>- </div>- <div class="flex items-center space-x-2">- <Tooltip.Root openDelay={0}>- <Tooltip.Trigger>- <button- type="button"- onClick={() =>- commands.showWindow({ Settings: { page: "recordings" } })+ <ErrorBoundary fallback={<></>}>+ <Suspense>+ <span+ onClick={async () => {+ if (license.data?.type !== "pro") {+ await commands.showWindow("Upgrade");}- >- <IconLucideSquarePlay class="w-[1.25rem] h-[1.25rem] text-gray-400 hover:text-gray-500" />- </button>- </Tooltip.Trigger>- <Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">- Previous Recordings- <Tooltip.Arrow class="fill-gray-500" />- </Tooltip.Content>- </Tooltip.Portal>- </Tooltip.Root>-- <Tooltip.Root openDelay={0}>- <Tooltip.Trigger>- <button- type="button"- onClick={() =>- commands.showWindow({ Settings: { page: "general" } })- }- >- <IconCapSettings class="w-[1.25rem] h-[1.25rem] text-gray-400 hover:text-gray-500" />- </button>- </Tooltip.Trigger>- <Tooltip.Portal>- <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">- Settings- <Tooltip.Arrow class="fill-gray-500" />- </Tooltip.Content>- </Tooltip.Portal>- </Tooltip.Root>- </div>+ }}+ class={`text-[0.6rem] ${+ license.data?.type === "pro"+ ? "bg-[--blue-400] text-gray-50 dark:text-gray-500"+ : "bg-gray-200 cursor-pointer hover:bg-gray-300"+ } rounded-lg px-1.5 py-0.5`}+ >+ {license.data?.type === "commercial"+ ? "Commercial"+ : license.data?.type === "pro"+ ? "Pro"+ : "Personal"}+ </span>+ </Suspense>+ </ErrorBoundary></div>- <TargetSelects options={options.data} />- <CameraSelect options={options.data} setOptions={setOptions} />- <MicrophoneSelect options={options.data} setOptions={setOptions} />- <div class="w-full flex items-center space-x-1">- <Button- disabled={toggleRecording.isPending}- variant={isRecording() ? "destructive" : "primary"}- size="md"- onClick={() => toggleRecording.mutate()}- class="flex-grow"- >- {isRecording() ? "Stop Recording" : "Start Recording"}- </Button>- <Button- disabled={isRecording()}- variant="secondary"- size="md"- onClick={() => commands.takeScreenshot()}- >- <IconLucideCamera class="w-[1rem] h-[1rem]" />- </Button>+ <div class="flex items-center space-x-2">+ <Tooltip.Root openDelay={0}>+ <Tooltip.Trigger>+ <button+ type="button"+ onClick={() =>+ commands.showWindow({ Settings: { page: "recordings" } })+ }+ >+ <IconLucideSquarePlay class="w-[1.25rem] h-[1.25rem] text-gray-400 hover:text-gray-500" />+ </button>+ </Tooltip.Trigger>+ <Tooltip.Portal>+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ Previous Recordings+ <Tooltip.Arrow class="fill-gray-500" />+ </Tooltip.Content>+ </Tooltip.Portal>+ </Tooltip.Root>++ <Tooltip.Root openDelay={0}>+ <Tooltip.Trigger>+ <button+ type="button"+ onClick={() =>+ commands.showWindow({ Settings: { page: "general" } })+ }+ >+ <IconCapSettings class="w-[1.25rem] h-[1.25rem] text-gray-400 hover:text-gray-500" />+ </button>+ </Tooltip.Trigger>+ <Tooltip.Portal>+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ Settings+ <Tooltip.Arrow class="fill-gray-500" />+ </Tooltip.Content>+ </Tooltip.Portal>+ </Tooltip.Root></div>- <a- href={`${import.meta.env.VITE_SERVER_URL}/dashboard`}- target="_blank"- rel="noreferrer"- class="text-[--text-tertiary] text-[0.875rem] mx-auto hover:text-[--text-primary] hover:underline"+ </div>+ <TargetSelects options={options.data} />+ <CameraSelect options={options.data} setOptions={setOptions} />+ <MicrophoneSelect options={options.data} setOptions={setOptions} />+ <div class="w-full flex items-center space-x-1">+ <Button+ disabled={toggleRecording.isPending}+ variant={isRecording() ? "destructive" : "primary"}+ size="md"+ onClick={() => toggleRecording.mutate()}+ class="flex-grow">- Open Cap on Web- </a>+ {isRecording() ? "Stop Recording" : "Start Recording"}+ </Button>+ <Button+ disabled={isRecording()}+ variant="secondary"+ size="md"+ onClick={() => commands.takeScreenshot()}+ >+ <IconLucideCamera class="w-[1rem] h-[1rem]" />+ </Button></div>- </Show>+ <a+ href={`${import.meta.env.VITE_SERVER_URL}/dashboard`}+ target="_blank"+ rel="noreferrer"+ class="text-[--text-tertiary] text-[0.875rem] mx-auto hover:text-[--text-primary] hover:underline"+ >+ Open Cap on Web+ </a>+ </div>);}@@ -346,6 +281,7 @@ import {getCurrentWebviewWindow,WebviewWindow,} from "@tauri-apps/api/webviewWindow";+import { UnlistenFn } from "@tauri-apps/api/event";let hasChecked = false;function createUpdateCheck() {diff --git a/apps/desktop/src/routes/(window-chrome)/licensing.tsx b/apps/desktop/src/routes/(window-chrome)/licensing.tsxnew file mode 100644index 000000000..0793c2d60--- /dev/null+++ b/apps/desktop/src/routes/(window-chrome)/licensing.tsx@@ -0,0 +1,280 @@+import { Button } from "@cap/ui-solid";+import { useNavigate } from "@solidjs/router";+import { Input } from "../editor/ui";+import { createMutation } from "@tanstack/solid-query";+import { licenseApiClient } from "~/utils/web-api";+import { generalSettingsStore } from "~/store";+import {+ createResource,+ createSignal,+ Match,+ Show,+ Suspense,+ Switch,+} from "solid-js";+import { createLicenseQuery } from "~/utils/queries";+import * as tauriShell from "@tauri-apps/plugin-shell";+import { ClientInferResponseBody } from "@ts-rest/core";+import { licenseContract } from "@cap/web-api-contract";++export default function Page() {+ const license = createLicenseQuery();+ const navigate = useNavigate();++ return (+ <div class="py-5 w-full max-w-[700px] mx-auto relative flex flex-col justify-start items-center h-full">+ <div class="text-center">+ <h1 class="text-4xl md:text-4xl mb-3 tracking-[-.05em] font-medium text-[--text-primary]">+ Commercial License+ </h1>+ <p class="text-base font-normal leading-6 text-gray-400 dark:text-[--black-transparent-60]">+ Permits using Cap for commercial purposes, but without paying for+ cloud features.+ </p>+ </div>+ <Button+ class="text-[--text-secondary] text-center text-base block my-4"+ variant="secondary"+ onClick={() => navigate("/upgrade")}+ >+ Looking for Cap Pro?+ </Button>+ <Switch fallback={<CommercialLicensePurchase />}>+ <Match when={license.data?.type === "pro" && license.data}>+ <div class="p-4 w-full space-y-4 rounded-xl bg-gray-200 mt-4">+ <p class="text-[--text-primary]">+ Your account is upgraded to Cap Pro and already includes a+ commercial license.+ </p>+ </div>+ </Match>+ <Match when={license.data?.type === "commercial" && license.data}>+ {(license) => (+ <div class="p-6 w-full space-y-4 rounded-xl bg-gray-200">+ <h3 class="text-2xl font-medium tracking-tight text-[--text-primary]">+ Your License+ </h3>+ <div class="flex flex-col">+ <label class="text-[--text-tertiary] text-sm">Key</label>+ <pre class="text-[--text-secondary] font-mono bg-gray-100 rounded-lg p-1 px-2">+ {license().licenseKey}+ </pre>+ </div>+ <div class="flex flex-col">+ <label class="text-[--text-tertiary] text-sm">Expires</label>+ <span class="text-[--text-secondary] mt-1 ml-0.5">+ {new Date(license().expiryDate).toUTCString()}+ </span>+ </div>++ <p class="text-[--text-tertiary] text-sm pt-1">+ Instance ID: {license().instanceId}+ </p>+ <div class="flex flex-row justify-end">+ <Button variant="destructive">Deactivate License Key</Button>+ </div>+ </div>+ )}+ </Match>+ </Switch>+ </div>+ );+}++function LicenseKeyActivate(props: {+ onActivated: (+ value: ClientInferResponseBody<+ (typeof licenseContract)["activateCommercialLicense"],+ 200+ > & { licenseKey: string }+ ) => void;+}) {+ const [store] = createResource(() => generalSettingsStore.get());++ return (+ <Suspense>+ <Show when={store()}>+ {(generalSettings) => {+ const [licenseKey, setLicenseKey] = createSignal("");++ const activateLicenseKey = createMutation(() => ({+ mutationFn: async (vars: { licenseKey: string }) => {+ const resp = await licenseApiClient.activateCommercialLicense({+ headers: {+ licensekey: vars.licenseKey,+ instanceid: generalSettings().instanceId!,+ },+ body: { reset: false },+ });++ if (resp.status === 200) return resp.body;+ if (+ typeof resp.body === "object" &&+ resp.body &&+ "message" in resp.body+ )+ throw resp.body.message;+ throw new Error((resp.body as any).toString());+ },+ onSuccess: (value, { licenseKey }) =>+ props.onActivated({ ...value, licenseKey }),+ }));++ return (+ <div class="p-6 w-full space-y-2 rounded-xl bg-gray-200 mt-4">+ <p class="text-[--text-primary]">+ Got a license key? Enter it below+ </p>+ <Input+ placeholder="License key"+ value={licenseKey()}+ onInput={(e) => setLicenseKey(e.currentTarget.value)}+ />+ <Button+ disabled={activateLicenseKey.isPending}+ onClick={() =>+ activateLicenseKey.mutate({ licenseKey: licenseKey() })+ }+ >+ Submit+ </Button>+ <p class="text-[--text-tertiary] text-sm pt-1">+ Instance ID: {generalSettings().instanceId}+ </p>+ </div>+ );+ }}+ </Show>+ </Suspense>+ );+}++type CommercialLicenseType = "yearly" | "lifetime";+function CommercialLicensePurchase() {+ const openCheckoutInExternalBrowser = createMutation(() => ({+ mutationFn: async ({ type }: { type: CommercialLicenseType }) => {+ const resp = await licenseApiClient.createCommercialCheckoutUrl({+ body: { type },+ });++ if (resp.status === 200) tauriShell.open(resp.body.url);+ else throw resp.body;+ },+ }));++ const [type, setType] = createSignal<CommercialLicenseType>("yearly");++ return (+ <>+ <div class="p-3 bg-blue-300 rounded-xl border shadow-sm text-card-foreground md:p-3 border-blue-500/20 w-full">+ <div class="space-y-3">+ <div class="flex flex-col space-y-1.5 pt-6 px-6">+ <h3 class="text-2xl font-medium tracking-tight text-gray-50 dark:text-[--text-primary]">+ Commercial License+ </h3>+ <p class="text-[0.875rem] leading-[1.25rem] text-gray-50 dark:text-[--text-primary]">+ For professional use without cloud features.+ </p>+ <div>+ <div class="flex items-center space-x-3">+ <h3 class="text-4xl text-gray-50 dark:text-[--text-primary]">+ {type() === "yearly" ? "$29/year" : "$58"}+ </h3>+ <div>+ {type() === "lifetime" && (+ <p class="text-sm font-medium text-gray-50 dark:text-[--text-primary]">+ billed once+ </p>+ )}+ {type() === "lifetime" && (+ <p class="text-sm text-gray-50 dark:text-[--text-primary]">+ or, $29/year.+ </p>+ )}+ </div>+ </div>+ </div>+ </div>+ <div class="px-3 md:px-8">+ <div class="flex items-center pt-4 pb-1 border-t-2 border-[--white-transparent-20] dark:border-[--black-transparent-20]">+ <span class="mr-2 text-xs text-gray-50 dark:text-[--text-primary]">+ Switch to {type() === "yearly" ? "lifetime" : "yearly"}+ </span>+ <button+ type="button"+ role="switch"+ aria-checked={type() === "lifetime"}+ data-state={type() === "yearly" ? "unchecked" : "checked"}+ value={type() === "lifetime" ? "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={() =>+ setType(type() === "yearly" ? "lifetime" : "yearly")+ }+ >+ <span+ data-state={type() === "yearly" ? "unchecked" : "checked"}+ class={`pointer-events-none block h-4 w-4 rounded-full dark:bg-gray-500+ bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4+ data-[state=unchecked]:translate-x-0 border-2 ${+ type() === "lifetime"+ ? "border-blue-400 dark:border-[#3F75E0]"+ : "border-gray-300 dark:border-[--white-transparent-20]"+ }`}+ />+ </button>+ </div>+ </div>+ <div class="px-6 pt-0 pb-4">+ <button+ onClick={() => {+ openCheckoutInExternalBrowser.mutate({ type: type() });+ }}+ disabled={openCheckoutInExternalBrowser.isPending}+ class="flex items-center justify-center hover:opacity-90 transition-opacity duration-200 rounded-full bg-[--gray-50] dark:bg-[--gray-500] hover:bg-[--gray-200] disabled:bg-[--gray-100]+ font-medium text-lg px-6 h-12 w-full no-underline text-gray-500 dark:text-gray-50"+ >+ Buy Commercial Licenses+ </button>+ </div>+ <div class="flex items-center px-6 pt-0 pb-6">+ <div class="space-y-6">+ <div>+ <ul class="p-0 space-y-3 list-none">+ {[+ "Commercial Use of Cap Recorder + Editor",+ "Community Support",+ ].map((feature) => (+ <li class="flex justify-start items-center">+ <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-50] dark:border-[--gray-500] justify-center rounded-full">+ <IconLucideCheck class="w-4 h-4 text-gray-50 dark:text-[--text-primary]" />+ </div>+ <span class="ml-2 text-[0.9rem] text-gray-50 dark:text-[--text-primary]">+ {feature}+ </span>+ </li>+ ))}+ </ul>+ </div>+ </div>+ </div>+ </div>+ </div>+ <LicenseKeyActivate+ onActivated={async (value) => {+ await generalSettingsStore.set({+ commercialLicense: {+ activatedOn: Date.now(),+ expiryDate: value.expiryDate,+ refresh: value.refresh,+ licenseKey: value.licenseKey,+ },+ });+ }}+ />+ </>+ );+}diff --git a/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx b/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsxindex 169bc1959..4802a2383 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/feedback.tsx@@ -60,7 +60,6 @@ export default function FeedbackTab() {<Buttontype="submit"- onClick={() => console.log("bruh")}disabled={!feedback().trim() || feedback().trim().length < 0}class="w-full bg-[--blue-400] text-[--text-primary]">diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsxindex a0e848614..ef1e1c569 100644--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx@@ -4,7 +4,13 @@ import { getCurrentWindow } from "@tauri-apps/api/window";import * as shell from "@tauri-apps/plugin-shell";import { listen } from "@tauri-apps/api/event";import { invoke } from "@tauri-apps/api/core";-import { action, useAction, useSubmission, redirect } from "@solidjs/router";+import {+ action,+ useAction,+ useSubmission,+ redirect,+ useNavigate,+} from "@solidjs/router";import { onOpenUrl } from "@tauri-apps/plugin-deep-link";import { Window } from "@tauri-apps/api/window";@@ -15,6 +21,7 @@ import { apiClient, protectedHeaders } from "~/utils/web-api";import { clientEnv } from "~/utils/env";import { identifyUser, trackEvent } from "~/utils/analytics";import callbackTemplate from "./callback.template";+import { Input } from "../editor/ui";const signInAction = action(async (planType: "yearly" | "monthly") => {console.log("Starting sign in action");@@ -167,6 +174,7 @@ export default function Page() {"Unlimited views","Password protected videos","Advanced analytics",+ "Commercial Use of Cap Recorder + Editor","Priority support",];@@ -325,9 +333,11 @@ export default function Page() {});});+ const navigate = useNavigate();+return (<div- class={`py-5 max-w-[700px] mx-auto relative ${+ class={`py-5 w-full max-w-[700px] mx-auto relative items-center flex flex-col ${upgradeComplete() ? "h-full" : ""}`}>@@ -366,93 +376,98 @@ export default function Page() {</span></p></div>- <div class="flex flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] flex-1 bg-gray-100">- <div class="flex-grow p-3 bg-blue-300 rounded-xl border shadow-sm text-card-foreground md:p-3 border-blue-500/20">- <div class="space-y-3">- <div class="flex flex-col space-y-1.5 pt-6 px-6 pb-3">- <h3 class="text-2xl font-medium tracking-tight text-gray-50 dark:text-[--text-primary]">- Cap Pro — Early Adopter Pricing- </h3>- <p class="text-[0.875rem] leading-[1.25rem] text-gray-50 dark:text-[--text-primary]">- For professional use and teams.- </p>- <div>- <div class="flex items-center space-x-3">- <h3 class="text-4xl text-gray-50 dark:text-[--text-primary]">- {isAnnual() ? "$6/mo" : "$9/mo"}- </h3>- <div>- <p class="text-sm font-medium text-gray-50 dark:text-[--text-primary]">- {isAnnual()- ? "per user, billed annually."- : "per user, billed monthly."}+ <Button+ class="text-[--text-secondary] text-center text-base my-4"+ variant="secondary"+ onClick={() => navigate("/licensing")}+ >+ Looking for Commercial Licenses?+ </Button>+ <div class="flex-grow p-3 bg-blue-300 rounded-xl border shadow-sm text-card-foreground md:p-3 border-blue-500/20 w-full">+ <div class="space-y-3">+ <div class="flex flex-col space-y-1.5 pt-6 px-6">+ <h3 class="text-2xl font-medium tracking-tight text-gray-50 dark:text-[--text-primary]">+ Cap Pro — Early Adopter Pricing+ </h3>+ <p class="text-[0.875rem] leading-[1.25rem] text-gray-50 dark:text-[--text-primary]">+ For professional use and teams.+ </p>+ <div>+ <div class="flex items-center space-x-3">+ <h3 class="text-4xl text-gray-50 dark:text-[--text-primary]">+ {isAnnual() ? "$6/mo" : "$9/mo"}+ </h3>+ <div>+ <p class="text-sm font-medium text-gray-50 dark:text-[--text-primary]">+ {isAnnual()+ ? "per user, billed annually."+ : "per user, billed monthly."}+ </p>+ {isAnnual() && (+ <p class="text-sm text-gray-50 dark:text-[--text-primary]">+ or, $9/month, billed monthly.</p>- {isAnnual() && (- <p class="text-sm text-gray-50 dark:text-[--text-primary]">- or, $9/month, billed monthly.- </p>- )}- </div>+ )}</div></div></div>- <div class="px-3 mt-3 md:px-8">- <div class="flex items-center pt-4 pb-1 mt-3 border-t-2 border-[--white-transparent-20] dark:border-[--black-transparent-20]">- <span class="mr-2 text-xs text-gray-50 dark:text-[--text-primary]">- Switch to {isAnnual() ? "monthly" : "annually"}- </span>- <button- type="button"- role="switch"- aria-checked={isAnnual()}- data-state={isAnnual() ? "unchecked" : "checked"}- value={isAnnual() ? "on" : "off"}- class="peer inline-flex h-4 w-8 shrink-0+ </div>+ <div class="px-3 mt-3 md:px-8">+ <div class="flex items-center pt-4 pb-1 mt-3 border-t-2 border-[--white-transparent-20] dark:border-[--black-transparent-20]">+ <span class="mr-2 text-xs text-gray-50 dark:text-[--text-primary]">+ Switch to {isAnnual() ? "monthly" : "annually"}+ </span>+ <button+ type="button"+ role="switch"+ aria-checked={isAnnual()}+ data-state={isAnnual() ? "unchecked" : "checked"}+ value={isAnnual() ? "on" : "off"}+ class="peer inline-flex h-4 w-8 shrink-0cursor-pointer items-center rounded-full border-2 border-transparentdark:bg-[#3F75E0]transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 bg-[--blue-400]"- onClick={togglePricing}- >- <span- data-state={isAnnual() ? "unchecked" : "checked"}- class={`pointer-events-none block h-4 w-4 rounded-full dark:bg-gray-500+ onClick={togglePricing}+ >+ <span+ data-state={isAnnual() ? "unchecked" : "checked"}+ class={`pointer-events-none block h-4 w-4 rounded-full dark:bg-gray-500bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4data-[state=unchecked]:translate-x-0 border-2 ${isAnnual()? "border-blue-400 dark:border-[#3F75E0]": "border-gray-300 dark:border-[--white-transparent-20]"}`}- />- </button>- </div>- </div>- <div class="px-6 pt-0 pb-4">- <button- onClick={openCheckoutInExternalBrowser}- class="flex items-center justify-center hover:opacity-90 transition-opacity duration-200 rounded-full bg-[--gray-50] dark:bg-[--gray-500] hover:bg-[--gray-200] disabled:bg-[--gray-100]- font-medium text-lg px-6 h-12 w-full no-underline text-gray-500 dark:text-gray-50"- disabled={loading()}- >- {loading() ? "Loading..." : "Upgrade to Cap Pro"}+ /></button></div>- <div class="flex items-center px-6 pt-0 pb-6">- <div class="space-y-6">- <div>- <ul class="p-0 space-y-3 list-none">- {proFeatures.map((feature) => (- <li class="flex justify-start items-center">- <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-50] dark:border-[--gray-500] justify-center rounded-full">- <IconLucideCheck class="w-4 h-4 text-gray-50 dark:text-[--text-primary]" />- </div>- <span class="ml-2 text-[0.9rem] text-gray-50 dark:text-[--text-primary]">- {feature}- </span>- </li>- ))}- </ul>- </div>+ </div>+ <div class="px-6 pt-0 pb-4">+ <button+ onClick={openCheckoutInExternalBrowser}+ class="flex items-center justify-center hover:opacity-90 transition-opacity duration-200 rounded-full bg-[--gray-50] dark:bg-[--gray-500] hover:bg-[--gray-200] disabled:bg-[--gray-100]+ font-medium text-lg px-6 h-12 w-full no-underline text-gray-500 dark:text-gray-50"+ disabled={loading()}+ >+ {loading() ? "Loading..." : "Upgrade to Cap Pro"}+ </button>+ </div>+ <div class="flex items-center px-6 pt-0 pb-6">+ <div class="space-y-6">+ <div>+ <ul class="p-0 space-y-3 list-none">+ {proFeatures.map((feature) => (+ <li class="flex justify-start items-center">+ <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-50] dark:border-[--gray-500] justify-center rounded-full">+ <IconLucideCheck class="w-4 h-4 text-gray-50 dark:text-[--text-primary]" />+ </div>+ <span class="ml-2 text-[0.9rem] text-gray-50 dark:text-[--text-primary]">+ {feature}+ </span>+ </li>+ ))}+ </ul></div></div></div>diff --git a/apps/desktop/src/routes/editor/ui.tsx b/apps/desktop/src/routes/editor/ui.tsxindex f375044b5..7ee455a15 100644--- a/apps/desktop/src/routes/editor/ui.tsx+++ b/apps/desktop/src/routes/editor/ui.tsx@@ -99,7 +99,7 @@ export function Input(props: ComponentProps<"input">) {<input{...props}class={cx(- "rounded-[0.5rem] h-[2rem] p-[0.375rem] border w-full text-[0.875rem] focus:border-blue-300 outline-none text-gray-500 dark:text-gray-50",+ "rounded-[0.5rem] h-[2rem] p-[0.375rem] border w-full text-[0.875rem] focus:border-blue-300 outline-none text-gray-500 dark:text-gray-50 placeholder:text-black-transparent-20",props.class)}/>diff --git a/apps/desktop/src/utils/queries.ts b/apps/desktop/src/utils/queries.tsindex 6ce0d21f9..8e1aa182b 100644--- a/apps/desktop/src/utils/queries.ts+++ b/apps/desktop/src/utils/queries.ts@@ -10,6 +10,7 @@ import { createStore, reconcile } from "solid-js/store";import { createEffect, createMemo } from "solid-js";import { makePersisted } from "@solid-primitives/storage";import { FPS } from "~/routes/editor/context";+import { authStore, generalSettingsStore } from "~/store";function debugFetch<T>(name: string, doFetch: () => Promise<T>) {return () => {@@ -131,3 +132,27 @@ export function createCurrentRecordingQuery() {return currentRecording;}++export function createLicenseQuery() {+ const query = createQuery(() => ({+ queryKey: ["bruh"],+ queryFn: async () => {+ const settings = await generalSettingsStore.get();+ const auth = await authStore.get();++ if (auth?.plan?.upgraded) return { type: "pro" as const, ...auth.plan };+ if (settings?.commercialLicense)+ return {+ type: "commercial" as const,+ ...settings.commercialLicense,+ instanceId: settings.instanceId,+ };+ return { type: "personal" as const };+ },+ }));++ generalSettingsStore.listen(() => query.refetch());+ authStore.listen(() => query.refetch());++ return query;+}diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex e0c6304e3..9361e6bd4 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -240,6 +240,7 @@ export type CameraYPosition = "top" | "bottom"export type CaptureArea = { screen: CaptureScreen; bounds: Bounds }export type CaptureScreen = { id: number; name: string; refresh_rate: number }export type CaptureWindow = { id: number; owner_name: string; name: string; bounds: Bounds; refresh_rate: number }+export type CommercialLicense = { licenseKey: string; expiryDate: number; refresh: number; activatedOn: number }export type Crop = { position: XY<number>; size: XY<number> }export type CurrentRecordingChanged = nullexport type CursorAnimationStyle = "regular" | "slow" | "fast"@@ -249,7 +250,7 @@ export type Display = { path: string; fps?: number }export type EditorStateChanged = { playhead_position: number }export type ExportEstimates = { duration_seconds: number; estimated_time_seconds: number; estimated_size_mb: number }export type Flags = { recordMouseState: boolean; split: boolean }-export type GeneralSettingsStore = { uploadIndividualFiles?: boolean; openEditorAfterRecording?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; recordingConfig?: RecordingConfig | null }+export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; openEditorAfterRecording?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; recordingConfig?: RecordingConfig | null; commercialLicense?: CommercialLicense | null; lastVersion?: string | null }export type HapticPattern = "Alignment" | "LevelChange" | "Generic"export type HapticPerformanceTime = "Default" | "Now" | "DrawCompleted"export type Hotkey = { code: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }diff --git a/apps/desktop/src/utils/web-api.ts b/apps/desktop/src/utils/web-api.tsindex 517967e23..1cd65876a 100644--- a/apps/desktop/src/utils/web-api.ts+++ b/apps/desktop/src/utils/web-api.ts@@ -1,31 +1,36 @@-import { initClient } from "@ts-rest/core";-import { contract } from "@cap/web-api-contract";+import { ApiFetcher, AppRouter, initClient } from "@ts-rest/core";+import { contract, licenseContract } from "@cap/web-api-contract";import { fetch } from "@tauri-apps/plugin-http";import { clientEnv } from "./env";import { authStore } from "~/store";-const baseUrl = `${clientEnv.VITE_SERVER_URL}/api`;+const api: ApiFetcher = async (args) => {+ const resp = await fetch(args.path, args);++ let body;++ const contentType = resp.headers.get("content-type");+ if (contentType === "application/json") {+ body = await resp.json();+ } else {+ body = await resp.text();+ }++ return {+ body,+ status: resp.status,+ headers: resp.headers,+ };+};+export const apiClient = initClient(contract, {- baseUrl,- api: async (args) => {- const resp = await fetch(args.path, args);-- let body;-- const contentType = resp.headers.get("content-type");- if (contentType === "application/json") {- body = await resp.json();- } else {- body = await resp.text();- }-- return {- body,- status: resp.status,- headers: resp.headers,- };- },+ baseUrl: `${clientEnv.VITE_SERVER_URL}/api`,+ api,+});+export const licenseApiClient = initClient(licenseContract, {+ baseUrl: `https://l.cap.so/api`,+ api,});export async function maybeProtectedHeaders() {diff --git a/apps/web/content/docs/commercial-license.mdx b/apps/web/content/docs/commercial-license.mdxnew file mode 100644index 000000000..8d4e92b3e--- /dev/null+++ b/apps/web/content/docs/commercial-license.mdx@@ -0,0 +1,23 @@+---+title: "Commercial Licensing"+summary: "Cap Desktop is free to use, but requires a commercial license to be used for commercial purposes."+tags: "Licensing"+---++# Cap Desktop's Commercial License++The Cap Desktop application you can download from our [download page](/download) is free to use,+but requires a commercial license to be used for commercial purposes.+You can obtain a commercial license by purchasing them standalone,+or by purchasing Cap Pro. For more information, see [our pricing page](/pricing).++This license does **not** apply to versions of the app you build yourself from our [source code](https://github.com/CapSoftware/Cap),+only to binaries that **we distribute**.++## What Are Commercial Purposes?++We define commercial purposes as any use of Cap Desktop for recording or editing content that will be used as part of revenue-generating activities.+This includes but is not limited to:++- Producing content for promotion or demonstration of your employer's product or service+- Producing content for communication between team members of a companydiff --git a/apps/web/package.json b/apps/web/package.jsonindex e069638b2..a5a149b89 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -3,7 +3,7 @@"version": "0.3.1","private": true,"scripts": {- "dev": "next dev",+ "dev": "dotenv -e ../../.env -- next dev","build": "next build","start": "next start","lint": "next lint"diff --git a/packages/ui-solid/src/Button.tsx b/packages/ui-solid/src/Button.tsxindex 9a441a911..4b6e656b8 100644--- a/packages/ui-solid/src/Button.tsx+++ b/packages/ui-solid/src/Button.tsx@@ -15,7 +15,7 @@ const styles = cva(secondary:"bg-gray-200 text-gray-500 hover:bg-gray-300 disabled:bg-gray-200 disabled:text-gray-400 outline-blue-300",destructive:- "bg-red-300 text-gray-50 dark:text-white hover:bg-red-400 disabled:bg-red-200 outline-red-300",+ "bg-red-300 text-gray-50 dark:text-gray-500 hover:bg-red-400 disabled:bg-red-200 outline-red-300",white:"bg-gray-50 dark:bg-gray-500 text-gray-500 dark:text-gray-50 hover:bg-gray-100 disabled:bg-gray-50 disabled:text-gray-400 outline-blue-300",},diff --git a/packages/web-api-contract/src/index.ts b/packages/web-api-contract/src/index.tsindex b4b93a502..d3c413a5c 100644--- a/packages/web-api-contract/src/index.ts+++ b/packages/web-api-contract/src/index.ts@@ -1,6 +1,11 @@import { z } from "zod";import desktop from "./desktop";import { c } from "./util";+import {+ ClientInferRequest,+ ClientInferResponseBody,+ ClientInferResponses,+} from "@ts-rest/core";export const contract = c.router({desktop,@@ -33,3 +38,32 @@ export const contract = c.router({},}),});++export const licenseContract = c.router({+ activateCommercialLicense: {+ method: "POST",+ path: "/commercial/activate",+ headers: z.object({ licensekey: z.string(), instanceid: z.string() }),+ body: z.object({ reset: z.boolean().optional() }),+ responses: {+ 200: z.object({+ message: z.string(),+ expiryDate: z.number(),+ refresh: z.number(),+ }),+ 403: z.object({ message: z.string() }),+ },+ },+ createCommercialCheckoutUrl: {+ method: "POST",+ path: "/commercial/checkout",+ body: z.object({+ type: z.enum(["yearly", "lifetime"]),+ quantity: z.number().min(1).max(100).optional(),+ }),+ responses: {+ 200: z.object({ url: z.string() }),+ 500: z.object({ message: z.string() }),+ },+ },+});