|
1 | 1 | // @ts-nocheck |
2 | | -/** tauri-specta globals **/ |
3 | | -import { Channel as TAURI_CHANNEL, invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; |
4 | | -import * as TAURI_API_EVENT from "@tauri-apps/api/event"; |
5 | | -import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; |
6 | 2 |
|
7 | 3 | // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. |
8 | 4 |
|
9 | 5 | /** user-defined commands **/ |
10 | 6 |
|
| 7 | + |
11 | 8 | export const commands = { |
12 | | - async checkMicrophonePermission(): Promise<Result<PermissionStatus, string>> { |
| 9 | +async checkMicrophonePermission() : Promise<Result<PermissionStatus, string>> { |
13 | 10 | try { |
14 | | - return { |
15 | | - status: "ok", |
16 | | - data: await TAURI_INVOKE("plugin:permissions|check_microphone_permission"), |
17 | | - }; |
18 | | - } catch (e) { |
19 | | - if (e instanceof Error) throw e; |
20 | | - else return { status: "error", error: e as any }; |
21 | | - } |
22 | | - }, |
23 | | - async requestMicrophonePermission(): Promise<Result<null, string>> { |
| 11 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|check_microphone_permission") }; |
| 12 | +} catch (e) { |
| 13 | + if(e instanceof Error) throw e; |
| 14 | + else return { status: "error", error: e as any }; |
| 15 | +} |
| 16 | +}, |
| 17 | +async requestMicrophonePermission() : Promise<Result<null, string>> { |
24 | 18 | try { |
25 | | - return { |
26 | | - status: "ok", |
27 | | - data: await TAURI_INVOKE("plugin:permissions|request_microphone_permission"), |
28 | | - }; |
29 | | - } catch (e) { |
30 | | - if (e instanceof Error) throw e; |
31 | | - else return { status: "error", error: e as any }; |
32 | | - } |
33 | | - }, |
34 | | - async checkSystemAudioPermission(): Promise<Result<PermissionStatus, string>> { |
| 19 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|request_microphone_permission") }; |
| 20 | +} catch (e) { |
| 21 | + if(e instanceof Error) throw e; |
| 22 | + else return { status: "error", error: e as any }; |
| 23 | +} |
| 24 | +}, |
| 25 | +async checkSystemAudioPermission() : Promise<Result<PermissionStatus, string>> { |
35 | 26 | try { |
36 | | - return { |
37 | | - status: "ok", |
38 | | - data: await TAURI_INVOKE("plugin:permissions|check_system_audio_permission"), |
39 | | - }; |
40 | | - } catch (e) { |
41 | | - if (e instanceof Error) throw e; |
42 | | - else return { status: "error", error: e as any }; |
43 | | - } |
44 | | - }, |
45 | | - async requestSystemAudioPermission(): Promise<Result<null, string>> { |
| 27 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|check_system_audio_permission") }; |
| 28 | +} catch (e) { |
| 29 | + if(e instanceof Error) throw e; |
| 30 | + else return { status: "error", error: e as any }; |
| 31 | +} |
| 32 | +}, |
| 33 | +async requestSystemAudioPermission() : Promise<Result<null, string>> { |
46 | 34 | try { |
47 | | - return { |
48 | | - status: "ok", |
49 | | - data: await TAURI_INVOKE("plugin:permissions|request_system_audio_permission"), |
50 | | - }; |
51 | | - } catch (e) { |
52 | | - if (e instanceof Error) throw e; |
53 | | - else return { status: "error", error: e as any }; |
54 | | - } |
55 | | - }, |
56 | | - async checkAccessibilityPermission(): Promise<Result<PermissionStatus, string>> { |
| 35 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|request_system_audio_permission") }; |
| 36 | +} catch (e) { |
| 37 | + if(e instanceof Error) throw e; |
| 38 | + else return { status: "error", error: e as any }; |
| 39 | +} |
| 40 | +}, |
| 41 | +async checkAccessibilityPermission() : Promise<Result<PermissionStatus, string>> { |
57 | 42 | try { |
58 | | - return { |
59 | | - status: "ok", |
60 | | - data: await TAURI_INVOKE("plugin:permissions|check_accessibility_permission"), |
61 | | - }; |
62 | | - } catch (e) { |
63 | | - if (e instanceof Error) throw e; |
64 | | - else return { status: "error", error: e as any }; |
65 | | - } |
66 | | - }, |
67 | | - async requestAccessibilityPermission(): Promise<Result<null, string>> { |
| 43 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|check_accessibility_permission") }; |
| 44 | +} catch (e) { |
| 45 | + if(e instanceof Error) throw e; |
| 46 | + else return { status: "error", error: e as any }; |
| 47 | +} |
| 48 | +}, |
| 49 | +async requestAccessibilityPermission() : Promise<Result<null, string>> { |
68 | 50 | try { |
69 | | - return { |
70 | | - status: "ok", |
71 | | - data: await TAURI_INVOKE("plugin:permissions|request_accessibility_permission"), |
72 | | - }; |
73 | | - } catch (e) { |
74 | | - if (e instanceof Error) throw e; |
75 | | - else return { status: "error", error: e as any }; |
76 | | - } |
77 | | - }, |
78 | | - async checkCalendarPermission(): Promise<Result<PermissionStatus, string>> { |
| 51 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|request_accessibility_permission") }; |
| 52 | +} catch (e) { |
| 53 | + if(e instanceof Error) throw e; |
| 54 | + else return { status: "error", error: e as any }; |
| 55 | +} |
| 56 | +}, |
| 57 | +async checkCalendarPermission() : Promise<Result<PermissionStatus, string>> { |
79 | 58 | try { |
80 | | - return { |
81 | | - status: "ok", |
82 | | - data: await TAURI_INVOKE("plugin:permissions|check_calendar_permission"), |
83 | | - }; |
84 | | - } catch (e) { |
85 | | - if (e instanceof Error) throw e; |
86 | | - else return { status: "error", error: e as any }; |
87 | | - } |
88 | | - }, |
89 | | - async requestCalendarPermission(): Promise<Result<null, string>> { |
| 59 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|check_calendar_permission") }; |
| 60 | +} catch (e) { |
| 61 | + if(e instanceof Error) throw e; |
| 62 | + else return { status: "error", error: e as any }; |
| 63 | +} |
| 64 | +}, |
| 65 | +async requestCalendarPermission() : Promise<Result<null, string>> { |
90 | 66 | try { |
91 | | - return { |
92 | | - status: "ok", |
93 | | - data: await TAURI_INVOKE("plugin:permissions|request_calendar_permission"), |
94 | | - }; |
95 | | - } catch (e) { |
96 | | - if (e instanceof Error) throw e; |
97 | | - else return { status: "error", error: e as any }; |
98 | | - } |
99 | | - }, |
100 | | - async checkContactsPermission(): Promise<Result<PermissionStatus, string>> { |
| 67 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|request_calendar_permission") }; |
| 68 | +} catch (e) { |
| 69 | + if(e instanceof Error) throw e; |
| 70 | + else return { status: "error", error: e as any }; |
| 71 | +} |
| 72 | +}, |
| 73 | +async checkContactsPermission() : Promise<Result<PermissionStatus, string>> { |
101 | 74 | try { |
102 | | - return { |
103 | | - status: "ok", |
104 | | - data: await TAURI_INVOKE("plugin:permissions|check_contacts_permission"), |
105 | | - }; |
106 | | - } catch (e) { |
107 | | - if (e instanceof Error) throw e; |
108 | | - else return { status: "error", error: e as any }; |
109 | | - } |
110 | | - }, |
111 | | - async requestContactsPermission(): Promise<Result<null, string>> { |
| 75 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|check_contacts_permission") }; |
| 76 | +} catch (e) { |
| 77 | + if(e instanceof Error) throw e; |
| 78 | + else return { status: "error", error: e as any }; |
| 79 | +} |
| 80 | +}, |
| 81 | +async requestContactsPermission() : Promise<Result<null, string>> { |
112 | 82 | try { |
113 | | - return { |
114 | | - status: "ok", |
115 | | - data: await TAURI_INVOKE("plugin:permissions|request_contacts_permission"), |
116 | | - }; |
117 | | - } catch (e) { |
118 | | - if (e instanceof Error) throw e; |
119 | | - else return { status: "error", error: e as any }; |
120 | | - } |
121 | | - }, |
122 | | - async openCalendarSettings(): Promise<Result<null, string>> { |
| 83 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|request_contacts_permission") }; |
| 84 | +} catch (e) { |
| 85 | + if(e instanceof Error) throw e; |
| 86 | + else return { status: "error", error: e as any }; |
| 87 | +} |
| 88 | +}, |
| 89 | +async openCalendarSettings() : Promise<Result<null, string>> { |
123 | 90 | try { |
124 | | - return { |
125 | | - status: "ok", |
126 | | - data: await TAURI_INVOKE("plugin:permissions|open_calendar_settings"), |
127 | | - }; |
128 | | - } catch (e) { |
129 | | - if (e instanceof Error) throw e; |
130 | | - else return { status: "error", error: e as any }; |
131 | | - } |
132 | | - }, |
133 | | - async openContactsSettings(): Promise<Result<null, string>> { |
| 91 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|open_calendar_settings") }; |
| 92 | +} catch (e) { |
| 93 | + if(e instanceof Error) throw e; |
| 94 | + else return { status: "error", error: e as any }; |
| 95 | +} |
| 96 | +}, |
| 97 | +async openContactsSettings() : Promise<Result<null, string>> { |
134 | 98 | try { |
135 | | - return { |
136 | | - status: "ok", |
137 | | - data: await TAURI_INVOKE("plugin:permissions|open_contacts_settings"), |
138 | | - }; |
139 | | - } catch (e) { |
140 | | - if (e instanceof Error) throw e; |
141 | | - else return { status: "error", error: e as any }; |
142 | | - } |
143 | | - }, |
144 | | -}; |
| 99 | + return { status: "ok", data: await TAURI_INVOKE("plugin:permissions|open_contacts_settings") }; |
| 100 | +} catch (e) { |
| 101 | + if(e instanceof Error) throw e; |
| 102 | + else return { status: "error", error: e as any }; |
| 103 | +} |
| 104 | +} |
| 105 | +} |
145 | 106 |
|
146 | 107 | /** user-defined events **/ |
147 | 108 |
|
| 109 | + |
| 110 | + |
148 | 111 | /** user-defined constants **/ |
149 | 112 |
|
| 113 | + |
| 114 | + |
150 | 115 | /** user-defined types **/ |
151 | 116 |
|
152 | | -export type PermissionStatus = "neverRequested" | "denied" | "authorized"; |
| 117 | +export type PermissionStatus = "neverRequested" | "denied" | "authorized" |
| 118 | + |
| 119 | +/** tauri-specta globals **/ |
| 120 | + |
| 121 | +import { |
| 122 | + invoke as TAURI_INVOKE, |
| 123 | + Channel as TAURI_CHANNEL, |
| 124 | +} from "@tauri-apps/api/core"; |
| 125 | +import * as TAURI_API_EVENT from "@tauri-apps/api/event"; |
| 126 | +import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; |
153 | 127 |
|
154 | 128 | type __EventObj__<T> = { |
155 | | - listen: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; |
156 | | - once: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.once<T>>; |
157 | | - emit: null extends T |
158 | | - ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> |
159 | | - : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; |
| 129 | + listen: ( |
| 130 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 131 | + ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; |
| 132 | + once: ( |
| 133 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 134 | + ) => ReturnType<typeof TAURI_API_EVENT.once<T>>; |
| 135 | + emit: null extends T |
| 136 | + ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> |
| 137 | + : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; |
160 | 138 | }; |
161 | 139 |
|
162 | | -export type Result<T, E> = { status: "ok"; data: T } | { status: "error"; error: E }; |
163 | | - |
164 | | -function __makeEvents__<T extends Record<string, any>>(mappings: Record<keyof T, string>) { |
165 | | - return new Proxy( |
166 | | - {} as unknown as { |
167 | | - [K in keyof T]: __EventObj__<T[K]> & { |
168 | | - (handle: __WebviewWindow__): __EventObj__<T[K]>; |
169 | | - }; |
170 | | - }, |
171 | | - { |
172 | | - get: (_, event) => { |
173 | | - const name = mappings[event as keyof T]; |
174 | | - |
175 | | - return new Proxy((() => {}) as any, { |
176 | | - apply: (_, __, [window]: [__WebviewWindow__]) => ({ |
177 | | - listen: (arg: any) => window.listen(name, arg), |
178 | | - once: (arg: any) => window.once(name, arg), |
179 | | - emit: (arg: any) => window.emit(name, arg), |
180 | | - }), |
181 | | - get: (_, command: keyof __EventObj__<any>) => { |
182 | | - switch (command) { |
183 | | - case "listen": |
184 | | - return (arg: any) => TAURI_API_EVENT.listen(name, arg); |
185 | | - case "once": |
186 | | - return (arg: any) => TAURI_API_EVENT.once(name, arg); |
187 | | - case "emit": |
188 | | - return (arg: any) => TAURI_API_EVENT.emit(name, arg); |
189 | | - } |
190 | | - }, |
191 | | - }); |
192 | | - }, |
193 | | - }, |
194 | | - ); |
| 140 | +export type Result<T, E> = |
| 141 | + | { status: "ok"; data: T } |
| 142 | + | { status: "error"; error: E }; |
| 143 | + |
| 144 | +function __makeEvents__<T extends Record<string, any>>( |
| 145 | + mappings: Record<keyof T, string>, |
| 146 | +) { |
| 147 | + return new Proxy( |
| 148 | + {} as unknown as { |
| 149 | + [K in keyof T]: __EventObj__<T[K]> & { |
| 150 | + (handle: __WebviewWindow__): __EventObj__<T[K]>; |
| 151 | + }; |
| 152 | + }, |
| 153 | + { |
| 154 | + get: (_, event) => { |
| 155 | + const name = mappings[event as keyof T]; |
| 156 | + |
| 157 | + return new Proxy((() => {}) as any, { |
| 158 | + apply: (_, __, [window]: [__WebviewWindow__]) => ({ |
| 159 | + listen: (arg: any) => window.listen(name, arg), |
| 160 | + once: (arg: any) => window.once(name, arg), |
| 161 | + emit: (arg: any) => window.emit(name, arg), |
| 162 | + }), |
| 163 | + get: (_, command: keyof __EventObj__<any>) => { |
| 164 | + switch (command) { |
| 165 | + case "listen": |
| 166 | + return (arg: any) => TAURI_API_EVENT.listen(name, arg); |
| 167 | + case "once": |
| 168 | + return (arg: any) => TAURI_API_EVENT.once(name, arg); |
| 169 | + case "emit": |
| 170 | + return (arg: any) => TAURI_API_EVENT.emit(name, arg); |
| 171 | + } |
| 172 | + }, |
| 173 | + }); |
| 174 | + }, |
| 175 | + }, |
| 176 | + ); |
195 | 177 | } |
0 commit comments