-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathutils.ts
More file actions
60 lines (53 loc) · 1.4 KB
/
utils.ts
File metadata and controls
60 lines (53 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Builds a Cap desktop deeplink URL.
*
* Cap desktop uses the URL scheme: cap-desktop://action?value={json_encoded_action}
* The JSON value follows the Rust serde enum serialization format:
* - Unit variants: "variant_name"
* - Struct variants: { "variant_name": { field: value } }
*/
export function buildDeeplinkUrl(action: DeepLinkAction): string {
const json = JSON.stringify(action);
return `cap-desktop://action?value=${encodeURIComponent(json)}`;
}
// Unit variants serialize as plain strings
export type DeepLinkAction =
| "stop_recording"
| "pause_recording"
| "resume_recording"
| "toggle_pause_recording"
| StartRecordingAction
| SetCameraAction
| SetMicrophoneAction
| OpenEditorAction
| OpenSettingsAction;
export interface StartRecordingAction {
start_recording: {
capture_mode: { screen: string } | { window: string };
camera: CameraId | null;
mic_label: string | null;
capture_system_audio: boolean;
mode: "studio" | "instant";
};
}
export type CameraId = { ModelID: string } | { DeviceID: string };
export interface SetCameraAction {
set_camera: {
camera: CameraId | null;
};
}
export interface SetMicrophoneAction {
set_microphone: {
mic_label: string | null;
};
}
export interface OpenEditorAction {
open_editor: {
project_path: string;
};
}
export interface OpenSettingsAction {
open_settings: {
page: string | null;
};
}