Skip to content

Commit 6b9b4d3

Browse files
committed
chores
1 parent ac21a45 commit 6b9b4d3

File tree

1 file changed

+188
-93
lines changed

1 file changed

+188
-93
lines changed

plugins/git/js/bindings.gen.ts

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

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

155
/** user-defined commands **/
166

7+
178
export const commands = {
18-
async init(path: string): Promise<Result<null, string>> {
9+
async isRepo(path: string) : Promise<Result<boolean, string>> {
1910
try {
20-
return {
21-
status: "ok",
22-
data: await TAURI_INVOKE("plugin:git|init", { path }),
23-
};
24-
} catch (e) {
25-
if (e instanceof Error) throw e;
26-
else return { status: "error", error: e as any };
27-
}
28-
},
29-
async add(path: string, patterns: string[]): Promise<Result<null, string>> {
11+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|is_repo", { path }) };
12+
} catch (e) {
13+
if(e instanceof Error) throw e;
14+
else return { status: "error", error: e as any };
15+
}
16+
},
17+
async init(path: string) : Promise<Result<null, string>> {
3018
try {
31-
return {
32-
status: "ok",
33-
data: await TAURI_INVOKE("plugin:git|add", { path, patterns }),
34-
};
35-
} catch (e) {
36-
if (e instanceof Error) throw e;
37-
else return { status: "error", error: e as any };
38-
}
39-
},
40-
async commit(path: string, message: string): Promise<Result<string, string>> {
19+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|init", { path }) };
20+
} catch (e) {
21+
if(e instanceof Error) throw e;
22+
else return { status: "error", error: e as any };
23+
}
24+
},
25+
async status(path: string) : Promise<Result<StatusInfo, string>> {
4126
try {
42-
return {
43-
status: "ok",
44-
data: await TAURI_INVOKE("plugin:git|commit", { path, message }),
45-
};
46-
} catch (e) {
47-
if (e instanceof Error) throw e;
48-
else return { status: "error", error: e as any };
49-
}
50-
},
51-
async status(path: string): Promise<Result<string[], string>> {
27+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|status", { path }) };
28+
} catch (e) {
29+
if(e instanceof Error) throw e;
30+
else return { status: "error", error: e as any };
31+
}
32+
},
33+
async add(path: string, patterns: string[]) : Promise<Result<null, string>> {
5234
try {
53-
return {
54-
status: "ok",
55-
data: await TAURI_INVOKE("plugin:git|status", { path }),
56-
};
57-
} catch (e) {
58-
if (e instanceof Error) throw e;
59-
else return { status: "error", error: e as any };
60-
}
61-
},
62-
};
35+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|add", { path, patterns }) };
36+
} catch (e) {
37+
if(e instanceof Error) throw e;
38+
else return { status: "error", error: e as any };
39+
}
40+
},
41+
async reset(path: string, files: string[]) : Promise<Result<null, string>> {
42+
try {
43+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|reset", { path, files }) };
44+
} catch (e) {
45+
if(e instanceof Error) throw e;
46+
else return { status: "error", error: e as any };
47+
}
48+
},
49+
async commit(path: string, message: string) : Promise<Result<string, string>> {
50+
try {
51+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|commit", { path, message }) };
52+
} catch (e) {
53+
if(e instanceof Error) throw e;
54+
else return { status: "error", error: e as any };
55+
}
56+
},
57+
async log(path: string, limit: number) : Promise<Result<CommitInfo[], string>> {
58+
try {
59+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|log", { path, limit }) };
60+
} catch (e) {
61+
if(e instanceof Error) throw e;
62+
else return { status: "error", error: e as any };
63+
}
64+
},
65+
async addRemote(path: string, name: string, url: string) : Promise<Result<null, string>> {
66+
try {
67+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|add_remote", { path, name, url }) };
68+
} catch (e) {
69+
if(e instanceof Error) throw e;
70+
else return { status: "error", error: e as any };
71+
}
72+
},
73+
async listRemotes(path: string) : Promise<Result<RemoteInfo[], string>> {
74+
try {
75+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|list_remotes", { path }) };
76+
} catch (e) {
77+
if(e instanceof Error) throw e;
78+
else return { status: "error", error: e as any };
79+
}
80+
},
81+
async fetch(path: string, remoteName: string) : Promise<Result<null, string>> {
82+
try {
83+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|fetch", { path, remoteName }) };
84+
} catch (e) {
85+
if(e instanceof Error) throw e;
86+
else return { status: "error", error: e as any };
87+
}
88+
},
89+
async push(path: string, remoteName: string, branch: string) : Promise<Result<PushResult, string>> {
90+
try {
91+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|push", { path, remoteName, branch }) };
92+
} catch (e) {
93+
if(e instanceof Error) throw e;
94+
else return { status: "error", error: e as any };
95+
}
96+
},
97+
async pull(path: string, remoteName: string, branch: string) : Promise<Result<PullResult, string>> {
98+
try {
99+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|pull", { path, remoteName, branch }) };
100+
} catch (e) {
101+
if(e instanceof Error) throw e;
102+
else return { status: "error", error: e as any };
103+
}
104+
},
105+
async checkConflicts(path: string) : Promise<Result<ConflictInfo | null, string>> {
106+
try {
107+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|check_conflicts", { path }) };
108+
} catch (e) {
109+
if(e instanceof Error) throw e;
110+
else return { status: "error", error: e as any };
111+
}
112+
},
113+
async abortMerge(path: string) : Promise<Result<null, string>> {
114+
try {
115+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|abort_merge", { path }) };
116+
} catch (e) {
117+
if(e instanceof Error) throw e;
118+
else return { status: "error", error: e as any };
119+
}
120+
},
121+
async getCurrentBranch(path: string) : Promise<Result<string, string>> {
122+
try {
123+
return { status: "ok", data: await TAURI_INVOKE("plugin:git|get_current_branch", { path }) };
124+
} catch (e) {
125+
if(e instanceof Error) throw e;
126+
else return { status: "error", error: e as any };
127+
}
128+
}
129+
}
130+
131+
/** user-defined events **/
132+
133+
134+
135+
/** user-defined constants **/
136+
137+
138+
139+
/** user-defined types **/
140+
141+
export type CommitInfo = { id: string; message: string; author: string; timestamp: number }
142+
export type ConflictInfo = { files: string[] }
143+
export type FileChangeType = "Added" | "Modified" | "Deleted" | "Renamed" | "Copied"
144+
export type FileStatus = { path: string; status: FileChangeType }
145+
export type PullResult = { Success: { commits_pulled: number } } | "AlreadyUpToDate" | { Conflicts: { files: string[] } }
146+
export type PushResult = { Success: { commits_pushed: number } } | "AlreadyUpToDate" | { Rejected: { reason: string } }
147+
export type RemoteInfo = { name: string; url: string }
148+
export type StatusInfo = { staged: FileStatus[]; unstaged: FileStatus[]; untracked: string[]; conflicted: string[]; has_changes: boolean }
149+
150+
/** tauri-specta globals **/
151+
152+
import {
153+
invoke as TAURI_INVOKE,
154+
Channel as TAURI_CHANNEL,
155+
} from "@tauri-apps/api/core";
156+
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
157+
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
63158

64159
type __EventObj__<T> = {
65-
listen: (
66-
cb: TAURI_API_EVENT.EventCallback<T>,
67-
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
68-
once: (
69-
cb: TAURI_API_EVENT.EventCallback<T>,
70-
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
71-
emit: null extends T
72-
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
73-
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
160+
listen: (
161+
cb: TAURI_API_EVENT.EventCallback<T>,
162+
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
163+
once: (
164+
cb: TAURI_API_EVENT.EventCallback<T>,
165+
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
166+
emit: null extends T
167+
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
168+
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
74169
};
75170

76171
export type Result<T, E> =
77-
| { status: "ok"; data: T }
78-
| { status: "error"; error: E };
172+
| { status: "ok"; data: T }
173+
| { status: "error"; error: E };
79174

80175
function __makeEvents__<T extends Record<string, any>>(
81-
mappings: Record<keyof T, string>,
176+
mappings: Record<keyof T, string>,
82177
) {
83-
return new Proxy(
84-
{} as unknown as {
85-
[K in keyof T]: __EventObj__<T[K]> & {
86-
(handle: __WebviewWindow__): __EventObj__<T[K]>;
87-
};
88-
},
89-
{
90-
get: (_, event) => {
91-
const name = mappings[event as keyof T];
92-
93-
return new Proxy((() => {}) as any, {
94-
apply: (_, __, [window]: [__WebviewWindow__]) => ({
95-
listen: (arg: any) => window.listen(name, arg),
96-
once: (arg: any) => window.once(name, arg),
97-
emit: (arg: any) => window.emit(name, arg),
98-
}),
99-
get: (_, command: keyof __EventObj__<any>) => {
100-
switch (command) {
101-
case "listen":
102-
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
103-
case "once":
104-
return (arg: any) => TAURI_API_EVENT.once(name, arg);
105-
case "emit":
106-
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
107-
}
108-
},
109-
});
110-
},
111-
},
112-
);
178+
return new Proxy(
179+
{} as unknown as {
180+
[K in keyof T]: __EventObj__<T[K]> & {
181+
(handle: __WebviewWindow__): __EventObj__<T[K]>;
182+
};
183+
},
184+
{
185+
get: (_, event) => {
186+
const name = mappings[event as keyof T];
187+
188+
return new Proxy((() => {}) as any, {
189+
apply: (_, __, [window]: [__WebviewWindow__]) => ({
190+
listen: (arg: any) => window.listen(name, arg),
191+
once: (arg: any) => window.once(name, arg),
192+
emit: (arg: any) => window.emit(name, arg),
193+
}),
194+
get: (_, command: keyof __EventObj__<any>) => {
195+
switch (command) {
196+
case "listen":
197+
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
198+
case "once":
199+
return (arg: any) => TAURI_API_EVENT.once(name, arg);
200+
case "emit":
201+
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
202+
}
203+
},
204+
});
205+
},
206+
},
207+
);
113208
}

0 commit comments

Comments
 (0)