-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from oscartbeaumont/v2.5
v2.5
- Loading branch information
Showing
27 changed files
with
1,800 additions
and
1,743 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/* eslint-disable */ | ||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. | ||
|
||
/** user-defined commands **/ | ||
|
||
export const commands = { | ||
/** | ||
* HELLO | ||
* WORLD | ||
* !!!! | ||
* @param { string } myName | ||
* @returns { Promise<string> } | ||
*/ | ||
async helloWorld(myName) { | ||
return await TAURI_INVOKE("hello_world", { myName }); | ||
}, | ||
/** | ||
* @returns { Promise<string> } | ||
*/ | ||
async goodbyeWorld() { | ||
return await TAURI_INVOKE("goodbye_world"); | ||
}, | ||
/** | ||
* @returns { Promise<Result<string, number>> } | ||
*/ | ||
async hasError() { | ||
try { | ||
return { status: "ok", data: await TAURI_INVOKE("has_error") }; | ||
} catch (e) { | ||
if(e instanceof Error) throw e; | ||
else return { status: "error", error: e }; | ||
} | ||
}, | ||
/** | ||
* @deprecated This is a deprecated function | ||
* @returns { Promise<void> } | ||
*/ | ||
async deprecated() { | ||
await TAURI_INVOKE("deprecated"); | ||
}, | ||
/** | ||
* @returns { Promise<Result<null, MyError>> } | ||
*/ | ||
async typesafeErrorsUsingThiserror() { | ||
try { | ||
return { status: "ok", data: await TAURI_INVOKE("typesafe_errors_using_thiserror") }; | ||
} catch (e) { | ||
if(e instanceof Error) throw e; | ||
else return { status: "error", error: e }; | ||
} | ||
}, | ||
/** | ||
* @returns { Promise<Result<null, MyError2>> } | ||
*/ | ||
async typesafeErrorsUsingThiserrorWithValue() { | ||
try { | ||
return { status: "ok", data: await TAURI_INVOKE("typesafe_errors_using_thiserror_with_value") }; | ||
} catch (e) { | ||
if(e instanceof Error) throw e; | ||
else return { status: "error", error: e }; | ||
} | ||
} | ||
} | ||
|
||
/** user-defined events **/ | ||
|
||
|
||
/** | ||
* @type {typeof __makeEvents__<{ | ||
* demoEvent: DemoEvent | ||
* emptyEvent: EmptyEvent | ||
* }>} | ||
*/ | ||
|
||
const __typedMakeEvents__ = __makeEvents__; | ||
|
||
export const events = __typedMakeEvents__({ | ||
demoEvent: "demo-event", | ||
emptyEvent: "empty-event" | ||
}) | ||
|
||
/** user-defined constants **/ | ||
|
||
export const universalConstant = 42; | ||
|
||
/** user-defined types **/ | ||
|
||
/** | ||
* @typedef { string } Custom | ||
*/ | ||
|
||
/** | ||
* @typedef { string } DemoEvent | ||
*/ | ||
|
||
/** | ||
* @typedef { null } EmptyEvent | ||
*/ | ||
|
||
/** | ||
* @typedef { { type: "IoError" } | { type: "AnotherError"; data: string } } MyError | ||
*/ | ||
|
||
/** | ||
* @typedef { { type: "IoError"; data: string } } MyError2 | ||
*/ | ||
|
||
|
||
/** tauri-specta globals **/ | ||
|
||
import { | ||
invoke as TAURI_INVOKE, | ||
Channel as TAURI_CHANNEL, | ||
} from "@tauri-apps/api/core"; | ||
import * as TAURI_API_EVENT from "@tauri-apps/api/event"; | ||
|
||
/** @typedef {typeof import("@tauri-apps/api/window").WebviewWindowHandle} __WebviewWindowHandle__ */ | ||
|
||
/** | ||
* @template T | ||
* @typedef {{ | ||
* listen: ( | ||
* cb: TAURI_API_EVENT.EventCallback<T> | ||
* ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; | ||
* once: ( | ||
* cb: TAURI_API_EVENT.EventCallback<T> | ||
* ) => ReturnType<typeof TAURI_API_EVENT.once<T>>; | ||
* emit: T extends null | ||
* ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> | ||
* : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; | ||
* }} __EventObj__<T> | ||
*/ | ||
|
||
/** | ||
* @template T,E | ||
* @typedef { { status: "ok", data: T } | { status: "error", error: E } } Result | ||
*/ | ||
|
||
/** | ||
* @template {Record<string, any>} T | ||
* @param {Record<keyof T, string>} mappings | ||
* @returns {{ | ||
* [K in keyof T]: __EventObj__<T[K]> & { | ||
* (handle: __WebviewWindowHandle__): __EventObj__<T[K]>; | ||
* }; | ||
* }} | ||
*/ | ||
function __makeEvents__(mappings) { | ||
return new Proxy( | ||
{}, | ||
{ | ||
get: (_, event) => { | ||
const name = mappings[event]; | ||
|
||
new Proxy(() => {}, { | ||
apply: (_, __, [window]) => ({ | ||
listen: (arg) => window.listen(name, arg), | ||
once: (arg) => window.once(name, arg), | ||
emit: (arg) => window.emit(name, arg), | ||
}), | ||
get: (_, command) => { | ||
switch (command) { | ||
case "listen": | ||
return (arg) => TAURI_API_EVENT.listen(name, arg); | ||
case "once": | ||
return (arg) => TAURI_API_EVENT.once(name, arg); | ||
case "emit": | ||
return (arg) => TAURI_API_EVENT.emit(name, arg); | ||
} | ||
}, | ||
}); | ||
}, | ||
}, | ||
); | ||
} |
Oops, something went wrong.