-
-
Notifications
You must be signed in to change notification settings - Fork 40
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 #124 from kareemmahlees/docs/missing-docs
doc: add missing docs & fix some errors in doc testing 📝
- Loading branch information
Showing
14 changed files
with
387 additions
and
96 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -23,4 +23,5 @@ dist-ssr | |
*.sw? | ||
target | ||
|
||
dist | ||
dist | ||
/_out |
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 |
---|---|---|
@@ -1,88 +1,91 @@ | ||
|
||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. | ||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. | ||
|
||
/** user-defined commands **/ | ||
/** user-defined commands **/ | ||
|
||
export const commands = { | ||
|
||
export const commands = { | ||
/** | ||
* Adds two numbers, returning the result. | ||
*/ | ||
async addNumbers(a: number, b: number) : Promise<number> { | ||
return await TAURI_INVOKE("plugin:specta-example|add_numbers", { a, b }); | ||
return await TAURI_INVOKE("plugin:specta-example|add_numbers", { a, b }); | ||
} | ||
} | ||
|
||
/** user-defined events **/ | ||
/** user-defined events **/ | ||
|
||
|
||
export const events = __makeEvents__<{ | ||
randomNumber: RandomNumber | ||
}>({ | ||
randomNumber: "plugin:specta-example:random-number" | ||
}) | ||
|
||
/** user-defined statics **/ | ||
/** user-defined constants **/ | ||
|
||
|
||
|
||
|
||
/** user-defined types **/ | ||
|
||
export type RandomNumber = number | ||
|
||
/** tauri-specta globals **/ | ||
|
||
import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; | ||
import { | ||
invoke as TAURI_INVOKE, | ||
Channel as TAURI_CHANNEL, | ||
} from "@tauri-apps/api/core"; | ||
import * as TAURI_API_EVENT from "@tauri-apps/api/event"; | ||
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; | ||
|
||
type __EventObj__<T> = { | ||
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>; | ||
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>; | ||
}; | ||
|
||
export type Result<T, E> = | ||
| { status: "ok"; data: T } | ||
| { status: "error"; error: E }; | ||
| { status: "ok"; data: T } | ||
| { status: "error"; error: E }; | ||
|
||
function __makeEvents__<T extends Record<string, any>>( | ||
mappings: Record<keyof T, string> | ||
mappings: Record<keyof T, string>, | ||
) { | ||
return new Proxy( | ||
{} as unknown as { | ||
[K in keyof T]: __EventObj__<T[K]> & { | ||
(handle: __WebviewWindow__): __EventObj__<T[K]>; | ||
}; | ||
}, | ||
{ | ||
get: (_, event) => { | ||
const name = mappings[event as keyof T]; | ||
|
||
return new Proxy((() => {}) as any, { | ||
apply: (_, __, [window]: [__WebviewWindow__]) => ({ | ||
listen: (arg: any) => window.listen(name, arg), | ||
once: (arg: any) => window.once(name, arg), | ||
emit: (arg: any) => window.emit(name, arg), | ||
}), | ||
get: (_, command: keyof __EventObj__<any>) => { | ||
switch (command) { | ||
case "listen": | ||
return (arg: any) => TAURI_API_EVENT.listen(name, arg); | ||
case "once": | ||
return (arg: any) => TAURI_API_EVENT.once(name, arg); | ||
case "emit": | ||
return (arg: any) => TAURI_API_EVENT.emit(name, arg); | ||
} | ||
}, | ||
}); | ||
}, | ||
} | ||
); | ||
return new Proxy( | ||
{} as unknown as { | ||
[K in keyof T]: __EventObj__<T[K]> & { | ||
(handle: __WebviewWindow__): __EventObj__<T[K]>; | ||
}; | ||
}, | ||
{ | ||
get: (_, event) => { | ||
const name = mappings[event as keyof T]; | ||
|
||
return new Proxy((() => {}) as any, { | ||
apply: (_, __, [window]: [__WebviewWindow__]) => ({ | ||
listen: (arg: any) => window.listen(name, arg), | ||
once: (arg: any) => window.once(name, arg), | ||
emit: (arg: any) => window.emit(name, arg), | ||
}), | ||
get: (_, command: keyof __EventObj__<any>) => { | ||
switch (command) { | ||
case "listen": | ||
return (arg: any) => TAURI_API_EVENT.listen(name, arg); | ||
case "once": | ||
return (arg: any) => TAURI_API_EVENT.once(name, arg); | ||
case "emit": | ||
return (arg: any) => TAURI_API_EVENT.emit(name, arg); | ||
} | ||
}, | ||
}); | ||
}, | ||
}, | ||
); | ||
} | ||
|
||
|
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
Oops, something went wrong.