Skip to content

Commit 59ec999

Browse files
committed
update bindings
1 parent 491cfbb commit 59ec999

File tree

18 files changed

+1609
-1628
lines changed

18 files changed

+1609
-1628
lines changed

plugins/analytics/js/bindings.gen.ts

Lines changed: 87 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,119 +4,112 @@
44

55
/** user-defined commands **/
66

7+
78
export const commands = {
8-
async event(payload: AnalyticsPayload): Promise<Result<null, string>> {
9+
async event(payload: AnalyticsPayload) : Promise<Result<null, string>> {
910
try {
10-
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|event", { payload }) };
11-
} catch (e) {
12-
if (e instanceof Error) throw e;
13-
else return { status: "error", error: e as any };
14-
}
15-
},
16-
async setProperties(payload: PropertiesPayload): Promise<Result<null, string>> {
11+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|event", { payload }) };
12+
} catch (e) {
13+
if(e instanceof Error) throw e;
14+
else return { status: "error", error: e as any };
15+
}
16+
},
17+
async setProperties(payload: PropertiesPayload) : Promise<Result<null, string>> {
1718
try {
18-
return {
19-
status: "ok",
20-
data: await TAURI_INVOKE("plugin:analytics|set_properties", { payload }),
21-
};
22-
} catch (e) {
23-
if (e instanceof Error) throw e;
24-
else return { status: "error", error: e as any };
25-
}
26-
},
27-
async setDisabled(disabled: boolean): Promise<Result<null, string>> {
19+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|set_properties", { payload }) };
20+
} catch (e) {
21+
if(e instanceof Error) throw e;
22+
else return { status: "error", error: e as any };
23+
}
24+
},
25+
async setDisabled(disabled: boolean) : Promise<Result<null, string>> {
2826
try {
29-
return {
30-
status: "ok",
31-
data: await TAURI_INVOKE("plugin:analytics|set_disabled", { disabled }),
32-
};
33-
} catch (e) {
34-
if (e instanceof Error) throw e;
35-
else return { status: "error", error: e as any };
36-
}
37-
},
38-
async isDisabled(): Promise<Result<boolean, string>> {
27+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|set_disabled", { disabled }) };
28+
} catch (e) {
29+
if(e instanceof Error) throw e;
30+
else return { status: "error", error: e as any };
31+
}
32+
},
33+
async isDisabled() : Promise<Result<boolean, string>> {
3934
try {
40-
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|is_disabled") };
41-
} catch (e) {
42-
if (e instanceof Error) throw e;
43-
else return { status: "error", error: e as any };
44-
}
45-
},
46-
};
35+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|is_disabled") };
36+
} catch (e) {
37+
if(e instanceof Error) throw e;
38+
else return { status: "error", error: e as any };
39+
}
40+
}
41+
}
4742

4843
/** user-defined events **/
4944

45+
46+
5047
/** user-defined constants **/
5148

49+
50+
5251
/** user-defined types **/
5352

54-
export type AnalyticsPayload = Partial<{
55-
[key in string]:
56-
| null
57-
| boolean
58-
| number
59-
| string
60-
| JsonValue[]
61-
| Partial<{ [key in string]: JsonValue }>;
62-
}> & { event: string };
63-
export type JsonValue =
64-
| null
65-
| boolean
66-
| number
67-
| string
68-
| JsonValue[]
69-
| Partial<{ [key in string]: JsonValue }>;
70-
export type PropertiesPayload = {
71-
set?: Partial<{ [key in string]: JsonValue }>;
72-
set_once?: Partial<{ [key in string]: JsonValue }>;
73-
};
53+
export type AnalyticsPayload = (Partial<{ [key in string]: null | boolean | number | string | JsonValue[] | Partial<{ [key in string]: JsonValue }> }>) & { event: string }
54+
export type JsonValue = null | boolean | number | string | JsonValue[] | Partial<{ [key in string]: JsonValue }>
55+
export type PropertiesPayload = { set?: Partial<{ [key in string]: JsonValue }>; set_once?: Partial<{ [key in string]: JsonValue }> }
7456

7557
/** tauri-specta globals **/
7658

77-
import { invoke as TAURI_INVOKE, Channel as TAURI_CHANNEL } from "@tauri-apps/api/core";
59+
import {
60+
invoke as TAURI_INVOKE,
61+
Channel as TAURI_CHANNEL,
62+
} from "@tauri-apps/api/core";
7863
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
7964
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
8065

8166
type __EventObj__<T> = {
82-
listen: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
83-
once: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
84-
emit: null extends T
85-
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
86-
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
67+
listen: (
68+
cb: TAURI_API_EVENT.EventCallback<T>,
69+
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
70+
once: (
71+
cb: TAURI_API_EVENT.EventCallback<T>,
72+
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
73+
emit: null extends T
74+
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
75+
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
8776
};
8877

89-
export type Result<T, E> = { status: "ok"; data: T } | { status: "error"; error: E };
90-
91-
function __makeEvents__<T extends Record<string, any>>(mappings: Record<keyof T, string>) {
92-
return new Proxy(
93-
{} as unknown as {
94-
[K in keyof T]: __EventObj__<T[K]> & {
95-
(handle: __WebviewWindow__): __EventObj__<T[K]>;
96-
};
97-
},
98-
{
99-
get: (_, event) => {
100-
const name = mappings[event as keyof T];
101-
102-
return new Proxy((() => {}) as any, {
103-
apply: (_, __, [window]: [__WebviewWindow__]) => ({
104-
listen: (arg: any) => window.listen(name, arg),
105-
once: (arg: any) => window.once(name, arg),
106-
emit: (arg: any) => window.emit(name, arg),
107-
}),
108-
get: (_, command: keyof __EventObj__<any>) => {
109-
switch (command) {
110-
case "listen":
111-
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
112-
case "once":
113-
return (arg: any) => TAURI_API_EVENT.once(name, arg);
114-
case "emit":
115-
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
116-
}
117-
},
118-
});
119-
},
120-
},
121-
);
78+
export type Result<T, E> =
79+
| { status: "ok"; data: T }
80+
| { status: "error"; error: E };
81+
82+
function __makeEvents__<T extends Record<string, any>>(
83+
mappings: Record<keyof T, string>,
84+
) {
85+
return new Proxy(
86+
{} as unknown as {
87+
[K in keyof T]: __EventObj__<T[K]> & {
88+
(handle: __WebviewWindow__): __EventObj__<T[K]>;
89+
};
90+
},
91+
{
92+
get: (_, event) => {
93+
const name = mappings[event as keyof T];
94+
95+
return new Proxy((() => {}) as any, {
96+
apply: (_, __, [window]: [__WebviewWindow__]) => ({
97+
listen: (arg: any) => window.listen(name, arg),
98+
once: (arg: any) => window.once(name, arg),
99+
emit: (arg: any) => window.emit(name, arg),
100+
}),
101+
get: (_, command: keyof __EventObj__<any>) => {
102+
switch (command) {
103+
case "listen":
104+
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
105+
case "once":
106+
return (arg: any) => TAURI_API_EVENT.once(name, arg);
107+
case "emit":
108+
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
109+
}
110+
},
111+
});
112+
},
113+
},
114+
);
122115
}

plugins/apple-calendar/js/bindings.gen.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
// @ts-nocheck
2-
/** tauri-specta globals **/
3-
import {
4-
invoke as TAURI_INVOKE,
5-
Channel as TAURI_CHANNEL,
6-
} from "@tauri-apps/api/core";
7-
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
8-
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
92

103
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
114

@@ -85,6 +78,15 @@ export type RecurrenceRule = { frequency: RecurrenceFrequency; interval: number;
8578
export type StructuredLocation = { title: string; geo: GeoLocation | null; radius: number | null }
8679
export type Weekday = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"
8780

81+
/** tauri-specta globals **/
82+
83+
import {
84+
invoke as TAURI_INVOKE,
85+
Channel as TAURI_CHANNEL,
86+
} from "@tauri-apps/api/core";
87+
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
88+
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
89+
8890
type __EventObj__<T> = {
8991
listen: (
9092
cb: TAURI_API_EVENT.EventCallback<T>,

0 commit comments

Comments
 (0)