mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-27 11:56:05 +02:00
chore(api): update @since tag to 2.0.0 (#395)
This commit is contained in:
committed by
GitHub
parent
7e3034904c
commit
9bf98f68e7
@@ -22,7 +22,7 @@ declare global {
|
||||
* const appVersion = await getVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getVersion(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:app|version");
|
||||
@@ -36,7 +36,7 @@ async function getVersion(): Promise<string> {
|
||||
* const appName = await getName();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getName(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:app|name");
|
||||
@@ -51,7 +51,7 @@ async function getName(): Promise<string> {
|
||||
* const tauriVersion = await getTauriVersion();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getTauriVersion(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:app|tauri_version");
|
||||
@@ -66,7 +66,7 @@ async function getTauriVersion(): Promise<string> {
|
||||
* await show();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function show(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:app|show");
|
||||
@@ -81,7 +81,7 @@ async function show(): Promise<void> {
|
||||
* await hide();
|
||||
* ```
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function hide(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:app|hide");
|
||||
|
||||
@@ -15,7 +15,7 @@ declare global {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface ArgMatch {
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ interface ArgMatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface SubcommandMatch {
|
||||
name: string;
|
||||
@@ -39,7 +39,7 @@ interface SubcommandMatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface CliMatches {
|
||||
args: Record<string, ArgMatch>;
|
||||
@@ -65,7 +65,7 @@ interface CliMatches {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getMatches(): Promise<CliMatches> {
|
||||
return await window.__TAURI_INVOKE__("plugin:cli|cli_matches");
|
||||
|
||||
@@ -32,7 +32,7 @@ type ClipResponse = Clip<"PlainText", string>;
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeText(
|
||||
text: string,
|
||||
@@ -56,7 +56,7 @@ async function writeText(
|
||||
* import { readText } from '@tauri-apps/plugin-clipboard';
|
||||
* const clipboardText = await readText();
|
||||
* ```
|
||||
* @since 1.0.0.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function readText(): Promise<string> {
|
||||
const kind: ClipResponse = await window.__TAURI_INVOKE__(
|
||||
|
||||
@@ -23,7 +23,7 @@ interface FileResponse {
|
||||
/**
|
||||
* Extension filters for the file dialog.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface DialogFilter {
|
||||
/** Filter name. */
|
||||
@@ -41,7 +41,7 @@ interface DialogFilter {
|
||||
/**
|
||||
* Options for the open dialog.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface OpenDialogOptions {
|
||||
/** The title of the dialog window. */
|
||||
@@ -64,7 +64,7 @@ interface OpenDialogOptions {
|
||||
/**
|
||||
* Options for the save dialog.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface SaveDialogOptions {
|
||||
/** The title of the dialog window. */
|
||||
@@ -80,7 +80,7 @@ interface SaveDialogOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface MessageDialogOptions {
|
||||
/** The title of the dialog. Defaults to the app name. */
|
||||
@@ -164,7 +164,7 @@ async function open(
|
||||
*
|
||||
* @returns A promise resolving to the selected path(s)
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function open(
|
||||
options: OpenDialogOptions = {}
|
||||
@@ -198,7 +198,7 @@ async function open(
|
||||
*
|
||||
* @returns A promise resolving to the selected path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function save(options: SaveDialogOptions = {}): Promise<string | null> {
|
||||
if (typeof options === "object") {
|
||||
@@ -222,7 +222,7 @@ async function save(options: SaveDialogOptions = {}): Promise<string | null> {
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
*/
|
||||
async function message(
|
||||
@@ -252,7 +252,7 @@ async function message(
|
||||
*
|
||||
* @returns A promise resolving to a boolean indicating whether `Yes` was clicked or not.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function ask(
|
||||
message: string,
|
||||
@@ -282,7 +282,7 @@ async function ask(
|
||||
*
|
||||
* @returns A promise resolving to a boolean indicating whether `Ok` was clicked or not.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function confirm(
|
||||
message: string,
|
||||
|
||||
@@ -161,7 +161,7 @@ interface BackendMetadata {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FsOptions {
|
||||
dir?: BaseDirectory;
|
||||
@@ -169,7 +169,7 @@ interface FsOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FsDirOptions {
|
||||
dir?: BaseDirectory;
|
||||
@@ -179,7 +179,7 @@ interface FsDirOptions {
|
||||
/**
|
||||
* Options object used to write a UTF-8 string to a file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FsTextFileOption {
|
||||
/** Path to the file to write. */
|
||||
@@ -193,7 +193,7 @@ type BinaryFileContents = Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
||||
/**
|
||||
* Options object used to write a binary data to a file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FsBinaryFileOption {
|
||||
/** Path to the file to write. */
|
||||
@@ -203,7 +203,7 @@ interface FsBinaryFileOption {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FileEntry {
|
||||
path: string;
|
||||
@@ -225,7 +225,7 @@ interface FileEntry {
|
||||
* const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig });
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function readTextFile(
|
||||
filePath: string,
|
||||
@@ -246,7 +246,7 @@ async function readTextFile(
|
||||
* const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource });
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function readBinaryFile(
|
||||
filePath: string,
|
||||
@@ -269,7 +269,7 @@ async function readBinaryFile(
|
||||
* await writeTextFile('app.conf', 'file contents', { dir: BaseDirectory.AppConfig });
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeTextFile(
|
||||
path: string,
|
||||
@@ -287,7 +287,7 @@ async function writeTextFile(
|
||||
* ```
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeTextFile(
|
||||
file: FsTextFileOption,
|
||||
@@ -299,7 +299,7 @@ async function writeTextFile(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeTextFile(
|
||||
path: string | FsTextFileOption,
|
||||
@@ -347,7 +347,7 @@ async function writeTextFile(
|
||||
* @param options Configuration object.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeBinaryFile(
|
||||
path: string,
|
||||
@@ -368,7 +368,7 @@ async function writeBinaryFile(
|
||||
* @param options Configuration object.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeBinaryFile(
|
||||
file: FsBinaryFileOption,
|
||||
@@ -380,7 +380,7 @@ async function writeBinaryFile(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeBinaryFile(
|
||||
path: string | FsBinaryFileOption,
|
||||
@@ -439,7 +439,7 @@ async function writeBinaryFile(
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function readDir(
|
||||
dir: string,
|
||||
@@ -464,7 +464,7 @@ async function readDir(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function createDir(
|
||||
dir: string,
|
||||
@@ -488,7 +488,7 @@ async function createDir(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function removeDir(
|
||||
dir: string,
|
||||
@@ -511,7 +511,7 @@ async function removeDir(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function copyFile(
|
||||
source: string,
|
||||
@@ -536,7 +536,7 @@ async function copyFile(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function removeFile(
|
||||
file: string,
|
||||
@@ -559,7 +559,7 @@ async function removeFile(
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function renameFile(
|
||||
oldPath: string,
|
||||
@@ -582,7 +582,7 @@ async function renameFile(
|
||||
* await exists('avatar.png', { dir: BaseDirectory.AppData });
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function exists(path: string): Promise<boolean> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|exists", { path });
|
||||
@@ -591,7 +591,7 @@ async function exists(path: string): Promise<boolean> {
|
||||
/**
|
||||
* Returns the metadata for the given path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function metadata(path: string): Promise<Metadata> {
|
||||
return await window
|
||||
|
||||
@@ -32,7 +32,7 @@ export type ShortcutHandler = (shortcut: string) => void;
|
||||
* @param shortcut Shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q
|
||||
* @param handler Shortcut handler callback - takes the triggered shortcut as argument
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function register(
|
||||
shortcut: string,
|
||||
@@ -57,7 +57,7 @@ async function register(
|
||||
* @param shortcuts Array of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q
|
||||
* @param handler Shortcut handler callback - takes the triggered shortcut as argument
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function registerAll(
|
||||
shortcuts: string[],
|
||||
@@ -82,7 +82,7 @@ async function registerAll(
|
||||
*
|
||||
* @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function isRegistered(shortcut: string): Promise<boolean> {
|
||||
return await window.__TAURI_INVOKE__("plugin:globalShortcut|is_registered", {
|
||||
@@ -100,7 +100,7 @@ async function isRegistered(shortcut: string): Promise<boolean> {
|
||||
*
|
||||
* @param shortcut shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function unregister(shortcut: string): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister", {
|
||||
@@ -116,7 +116,7 @@ async function unregister(shortcut: string): Promise<void> {
|
||||
* await unregisterAll();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function unregisterAll(): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:globalShortcut|unregister_all");
|
||||
|
||||
@@ -31,7 +31,7 @@ declare global {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface Duration {
|
||||
secs: number;
|
||||
@@ -39,7 +39,7 @@ interface Duration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface ClientOptions {
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ interface ClientOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
enum ResponseType {
|
||||
JSON = 1,
|
||||
@@ -60,7 +60,7 @@ enum ResponseType {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface FilePart<T> {
|
||||
file: string | T;
|
||||
@@ -73,7 +73,7 @@ type Part = string | Uint8Array | FilePart<Uint8Array>;
|
||||
/**
|
||||
* The body object to be used on POST and PUT requests.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Body {
|
||||
type: string;
|
||||
@@ -115,6 +115,8 @@ class Body {
|
||||
* @param data The body data.
|
||||
*
|
||||
* @returns The body object ready to be used on the POST and PUT requests.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static form(data: Record<string, Part> | FormData): Body {
|
||||
const form: Record<string, string | number[] | FilePart<number[]>> = {};
|
||||
@@ -166,6 +168,8 @@ class Body {
|
||||
* @param data The body JSON object.
|
||||
*
|
||||
* @returns The body object ready to be used on the POST and PUT requests.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static json<K extends string | number | symbol, V>(data: Record<K, V>): Body {
|
||||
return new Body("Json", data);
|
||||
@@ -182,6 +186,8 @@ class Body {
|
||||
* @param value The body string.
|
||||
*
|
||||
* @returns The body object ready to be used on the POST and PUT requests.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static text(value: string): Body {
|
||||
return new Body("Text", value);
|
||||
@@ -198,6 +204,8 @@ class Body {
|
||||
* @param bytes The body byte array.
|
||||
*
|
||||
* @returns The body object ready to be used on the POST and PUT requests.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static bytes(
|
||||
bytes: Iterable<number> | ArrayLike<number> | ArrayBuffer
|
||||
@@ -225,7 +233,7 @@ type HttpVerb =
|
||||
/**
|
||||
* Options object sent to the backend.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface HttpOptions {
|
||||
method: HttpVerb;
|
||||
@@ -254,7 +262,7 @@ interface IResponse<T> {
|
||||
/**
|
||||
* Response object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
* */
|
||||
class Response<T> {
|
||||
/** The request URL. */
|
||||
@@ -282,7 +290,7 @@ class Response<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Client {
|
||||
id: number;
|
||||
@@ -481,7 +489,7 @@ class Client {
|
||||
*
|
||||
* @returns A promise resolving to the client instance.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getClient(options?: ClientOptions): Promise<Client> {
|
||||
return window
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
/**
|
||||
* Options to send a notification.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
@@ -300,7 +300,7 @@ type Permission = "granted" | "denied" | "default";
|
||||
* const permissionGranted = await isPermissionGranted();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function isPermissionGranted(): Promise<boolean> {
|
||||
if (window.Notification.permission !== "default") {
|
||||
@@ -323,7 +323,7 @@ async function isPermissionGranted(): Promise<boolean> {
|
||||
*
|
||||
* @returns A promise resolving to whether the user granted the permission or not.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function requestPermission(): Promise<Permission> {
|
||||
return window.Notification.requestPermission();
|
||||
@@ -345,7 +345,7 @@ async function requestPermission(): Promise<Permission> {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function sendNotification(options: Options | string): void {
|
||||
if (typeof options === "string") {
|
||||
|
||||
@@ -50,7 +50,7 @@ function isWindows(): boolean {
|
||||
* - `\n` on POSIX
|
||||
* - `\r\n` on Windows
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
* */
|
||||
const EOL = isWindows() ? "\r\n" : "\n";
|
||||
|
||||
@@ -63,7 +63,7 @@ const EOL = isWindows() ? "\r\n" : "\n";
|
||||
* const platformName = await platform();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
*/
|
||||
async function platform(): Promise<Platform> {
|
||||
@@ -78,7 +78,7 @@ async function platform(): Promise<Platform> {
|
||||
* const osVersion = await version();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function version(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:os|version");
|
||||
@@ -92,7 +92,7 @@ async function version(): Promise<string> {
|
||||
* const osType = await type();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function type(): Promise<OsType> {
|
||||
return window.__TAURI_INVOKE__("plugin:os|kind");
|
||||
@@ -107,7 +107,7 @@ async function type(): Promise<OsType> {
|
||||
* const archName = await arch();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function arch(): Promise<Arch> {
|
||||
return window.__TAURI_INVOKE__("plugin:os|arch");
|
||||
@@ -121,7 +121,7 @@ async function arch(): Promise<Arch> {
|
||||
* const tempdirPath = await tempdir();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function tempdir(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:os|tempdir");
|
||||
|
||||
@@ -24,7 +24,7 @@ declare global {
|
||||
* @param code The exit code to use.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function exit(code = 0): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:process|exit", { code });
|
||||
@@ -40,7 +40,7 @@ async function exit(code = 0): Promise<void> {
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function relaunch(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:process|restart");
|
||||
|
||||
@@ -72,7 +72,7 @@ declare global {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface SpawnOptions {
|
||||
/** Current working directory. */
|
||||
@@ -82,7 +82,7 @@ interface SpawnOptions {
|
||||
/**
|
||||
* Character encoding for stdout/stderr
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
* */
|
||||
encoding?: string;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ interface InternalSpawnOptions extends SpawnOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface ChildProcess<O extends IOPayload> {
|
||||
/** Exit code of the process. `null` if the process was terminated by a signal on Unix. */
|
||||
@@ -115,6 +115,8 @@ interface ChildProcess<O extends IOPayload> {
|
||||
* @param args Program arguments.
|
||||
* @param options Configuration for the process spawn.
|
||||
* @returns A promise resolving to the process id.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function execute<O extends IOPayload>(
|
||||
onEvent: (event: CommandEvent<O>) => void,
|
||||
@@ -135,7 +137,7 @@ async function execute<O extends IOPayload>(
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
class EventEmitter<E extends Record<string, any>> {
|
||||
@@ -147,7 +149,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
/**
|
||||
* Alias for `emitter.on(eventName, listener)`.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
addListener<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -159,7 +161,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
/**
|
||||
* Alias for `emitter.off(eventName, listener)`.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
removeListener<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -176,7 +178,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
on<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -198,7 +200,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
once<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -216,7 +218,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
* Removes the all specified listener from the listener array for the event eventName
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
off<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -236,7 +238,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
removeAllListeners<N extends keyof E>(event?: N): this {
|
||||
if (event) {
|
||||
@@ -255,6 +257,8 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
* to each.
|
||||
*
|
||||
* @returns `true` if the event had listeners, `false` otherwise.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
emit<N extends keyof E>(eventName: N, arg: E[typeof eventName]): boolean {
|
||||
if (eventName in this.eventListeners) {
|
||||
@@ -270,7 +274,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
/**
|
||||
* Returns the number of listeners listening to the event named `eventName`.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
listenerCount<N extends keyof E>(eventName: N): number {
|
||||
if (eventName in this.eventListeners)
|
||||
@@ -287,7 +291,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
prependListener<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -309,7 +313,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
prependOnceListener<N extends keyof E>(
|
||||
eventName: N,
|
||||
@@ -326,7 +330,7 @@ class EventEmitter<E extends Record<string, any>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class Child {
|
||||
/** The child process `pid`. */
|
||||
@@ -350,6 +354,8 @@ class Child {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async write(data: IOPayload): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:shell|stdin_write", {
|
||||
@@ -363,6 +369,8 @@ class Child {
|
||||
* Kills the child process.
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async kill(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:shell|kill", {
|
||||
@@ -399,7 +407,7 @@ interface OutputEvents<O extends IOPayload> {
|
||||
* console.log('pid:', child.pid);
|
||||
* ```
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
*/
|
||||
class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
@@ -504,6 +512,8 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* Executes the command as a child process, returning a handle to it.
|
||||
*
|
||||
* @returns A promise resolving to the child process handle.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async spawn(): Promise<Child> {
|
||||
return execute<O>(
|
||||
@@ -542,6 +552,8 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise resolving to the child process output.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async execute(): Promise<ChildProcess<O>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -633,7 +645,7 @@ type CommandEvent<O extends IOPayload> =
|
||||
* @param openWith The app to open the file or URL with.
|
||||
* Defaults to the system default application for the specified path type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function open(path: string, openWith?: string): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:shell|open", {
|
||||
|
||||
@@ -179,6 +179,8 @@ export class Store {
|
||||
* @param key
|
||||
* @param cb
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onKeyChange<T>(
|
||||
key: string,
|
||||
@@ -195,6 +197,8 @@ export class Store {
|
||||
* Listen to changes on the store.
|
||||
* @param cb
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onChange<T>(
|
||||
cb: (key: string, value: T | null) => void
|
||||
|
||||
@@ -239,6 +239,8 @@ class ProcedureExecutor {
|
||||
* Gets the Ed25519 public key of a SLIP10 private key.
|
||||
* @param privateKeyLocation The location of the private key. Must be the `outputLocation` of a previous call to `deriveSLIP10`.
|
||||
* @returns A promise resolving to the public key hex string.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async getEd25519PublicKey(privateKeyLocation: Location): Promise<Uint8Array> {
|
||||
return await window
|
||||
@@ -260,6 +262,8 @@ class ProcedureExecutor {
|
||||
* @param privateKeyLocation The location of the record where the private key is stored. Must be the `outputLocation` of a previous call to `deriveSLIP10`.
|
||||
* @param msg The message to sign.
|
||||
* @returns A promise resolving to the signature hex string.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async signEd25519(
|
||||
privateKeyLocation: Location,
|
||||
|
||||
@@ -38,7 +38,7 @@ type TitleBarStyle = "visible" | "transparent" | "overlay";
|
||||
/**
|
||||
* Allows you to retrieve information about a given monitor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface Monitor {
|
||||
/** Human-readable name of the monitor */
|
||||
@@ -54,7 +54,7 @@ interface Monitor {
|
||||
/**
|
||||
* The payload for the `scaleChange` event.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface ScaleFactorChanged {
|
||||
/** The new window scale factor. */
|
||||
@@ -72,7 +72,7 @@ type FileDropEvent =
|
||||
/**
|
||||
* A size represented in logical pixels.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalSize {
|
||||
type = "Logical";
|
||||
@@ -88,7 +88,7 @@ class LogicalSize {
|
||||
/**
|
||||
* A size represented in physical pixels.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalSize {
|
||||
type = "Physical";
|
||||
@@ -118,7 +118,7 @@ class PhysicalSize {
|
||||
/**
|
||||
* A position represented in logical pixels.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class LogicalPosition {
|
||||
type = "Logical";
|
||||
@@ -134,7 +134,7 @@ class LogicalPosition {
|
||||
/**
|
||||
* A position represented in physical pixels.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class PhysicalPosition {
|
||||
type = "Physical";
|
||||
@@ -179,7 +179,7 @@ declare global {
|
||||
/**
|
||||
* Attention type to request on a window.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
enum UserAttentionType {
|
||||
/**
|
||||
@@ -240,7 +240,7 @@ export type CursorIcon =
|
||||
/**
|
||||
* Get an instance of `WebviewWindow` for the current webview window.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getCurrent(): WebviewWindow {
|
||||
return new WebviewWindow(window.__TAURI_METADATA__.__currentWindow.label, {
|
||||
@@ -252,7 +252,7 @@ function getCurrent(): WebviewWindow {
|
||||
/**
|
||||
* Gets a list of instances of `WebviewWindow` for all available webview windows.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function getAll(): WebviewWindow[] {
|
||||
return window.__TAURI_METADATA__.__windows.map(
|
||||
@@ -273,7 +273,7 @@ export type WindowLabel = string;
|
||||
* A webview window handle allows emitting and listening to events from the backend that are tied to the window.
|
||||
*
|
||||
* @ignore
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class WebviewWindowHandle {
|
||||
/** The window label. It is a unique identifier for the window, can be used to reference it later. */
|
||||
@@ -306,6 +306,8 @@ class WebviewWindowHandle {
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async listen<T>(
|
||||
event: EventName,
|
||||
@@ -339,6 +341,8 @@ class WebviewWindowHandle {
|
||||
* @param handler Event handler.
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn> {
|
||||
if (this._handleTauriEvent(event, handler)) {
|
||||
@@ -393,7 +397,7 @@ class WebviewWindowHandle {
|
||||
* Manage the current window object.
|
||||
*
|
||||
* @ignore
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class WindowManager extends WebviewWindowHandle {
|
||||
// Getters
|
||||
@@ -406,6 +410,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window's monitor scale factor.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async scaleFactor(): Promise<number> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|scale_factor", {
|
||||
@@ -422,6 +428,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window's inner position.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async innerPosition(): Promise<PhysicalPosition> {
|
||||
return window
|
||||
@@ -443,6 +451,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window's outer position.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async outerPosition(): Promise<PhysicalPosition> {
|
||||
return window
|
||||
@@ -465,6 +475,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window's inner size.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async innerSize(): Promise<PhysicalSize> {
|
||||
return window
|
||||
@@ -487,6 +499,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window's outer size.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async outerSize(): Promise<PhysicalSize> {
|
||||
return window
|
||||
@@ -508,6 +522,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window is in fullscreen mode or not.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isFullscreen(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_fullscreen", {
|
||||
@@ -523,7 +539,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* const minimized = await appWindow.isMinimized();
|
||||
* ```
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isMinimized(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_minimized", {
|
||||
@@ -540,6 +556,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window is maximized or not.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isMaximized(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_maximized", {
|
||||
@@ -556,6 +574,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window is decorated or not.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isDecorated(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_decorated", {
|
||||
@@ -572,6 +592,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window is resizable or not.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isResizable(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_resizable", {
|
||||
@@ -588,6 +610,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns Whether the window is visible or not.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async isVisible(): Promise<boolean> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|is_visible", {
|
||||
@@ -603,7 +627,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* const title = await appWindow.title();
|
||||
* ```
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async title(): Promise<string> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|title", {
|
||||
@@ -625,6 +649,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns The window theme.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* */
|
||||
async theme(): Promise<Theme | null> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|theme", {
|
||||
@@ -644,6 +670,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param resizable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async center(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|center", {
|
||||
@@ -671,6 +699,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param resizable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async requestUserAttention(
|
||||
requestType: UserAttentionType | null
|
||||
@@ -700,6 +730,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param resizable
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setResizable(resizable: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_resizable", {
|
||||
@@ -718,6 +750,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param title The new title
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setTitle(title: string): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_title", {
|
||||
@@ -735,6 +769,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async maximize(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|maximize", {
|
||||
@@ -751,6 +787,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async unmaximize(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|unmaximize", {
|
||||
@@ -767,6 +805,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async toggleMaximize(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|toggle_maximize", {
|
||||
@@ -783,6 +823,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async minimize(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|minimize", {
|
||||
@@ -799,6 +841,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async unminimize(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|unminimize", {
|
||||
@@ -815,6 +859,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async show(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|show", {
|
||||
@@ -831,6 +877,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async hide(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|hide", {
|
||||
@@ -847,6 +895,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async close(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|close", {
|
||||
@@ -864,6 +914,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param decorations Whether the window should have borders and bars.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setDecorations(decorations: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_decorations", {
|
||||
@@ -891,7 +943,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setShadow(enable: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_shadow", {
|
||||
@@ -910,6 +962,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param alwaysOnTop Whether the window should always be on top of other windows or not.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_always_on_top", {
|
||||
@@ -928,7 +982,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setContentProtected(protected_: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_content_protected", {
|
||||
@@ -947,6 +1001,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param size The logical or physical inner size.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setSize(size: LogicalSize | PhysicalSize): Promise<void> {
|
||||
if (!size || (size.type !== "Logical" && size.type !== "Physical")) {
|
||||
@@ -977,6 +1033,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setMinSize(
|
||||
size: LogicalSize | PhysicalSize | null | undefined
|
||||
@@ -1011,6 +1069,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setMaxSize(
|
||||
size: LogicalSize | PhysicalSize | null | undefined
|
||||
@@ -1045,6 +1105,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param position The new position, in logical or physical pixels.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setPosition(
|
||||
position: LogicalPosition | PhysicalPosition
|
||||
@@ -1080,6 +1142,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param fullscreen Whether the window should go to fullscreen or not.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setFullscreen(fullscreen: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_fullscreen", {
|
||||
@@ -1097,6 +1161,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setFocus(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_focus", {
|
||||
@@ -1121,6 +1187,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param icon Icon bytes or path to the icon file.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setIcon(icon: string | Uint8Array): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_icon", {
|
||||
@@ -1143,6 +1211,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param skip true to hide window icon, false to show it.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setSkipTaskbar(skip: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_skip_taskbar", {
|
||||
@@ -1169,6 +1239,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param grab `true` to grab the cursor icon, `false` to release it.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setCursorGrab(grab: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_cursor_grab", {
|
||||
@@ -1193,6 +1265,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setCursorVisible(visible: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_cursor_visible", {
|
||||
@@ -1211,6 +1285,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param icon The new cursor icon.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setCursorIcon(icon: CursorIcon): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_cursor_icon", {
|
||||
@@ -1229,6 +1305,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param position The new cursor position.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setCursorPosition(
|
||||
position: LogicalPosition | PhysicalPosition
|
||||
@@ -1265,6 +1343,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
*
|
||||
* @param ignore `true` to ignore the cursor events; `false` to process them as usual.
|
||||
* @returns A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async setIgnoreCursorEvents(ignore: boolean): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|set_ignore_cursor_events", {
|
||||
@@ -1282,6 +1362,8 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* ```
|
||||
*
|
||||
* @return A promise indicating the success or failure of the operation.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async startDragging(): Promise<void> {
|
||||
return window.__TAURI_INVOKE__("plugin:window|start_dragging", {
|
||||
@@ -1308,7 +1390,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onResized(handler: EventCallback<PhysicalSize>): Promise<UnlistenFn> {
|
||||
return this.listen<PhysicalSize>(TauriEvent.WINDOW_RESIZED, (e) => {
|
||||
@@ -1334,7 +1416,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onMoved(handler: EventCallback<PhysicalPosition>): Promise<UnlistenFn> {
|
||||
return this.listen<PhysicalPosition>(TauriEvent.WINDOW_MOVED, (e) => {
|
||||
@@ -1365,7 +1447,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/promise-function-async */
|
||||
async onCloseRequested(
|
||||
@@ -1399,7 +1481,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onFocusChanged(handler: EventCallback<boolean>): Promise<UnlistenFn> {
|
||||
const unlistenFocus = await this.listen<PhysicalPosition>(
|
||||
@@ -1441,7 +1523,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onScaleChanged(
|
||||
handler: EventCallback<ScaleFactorChanged>
|
||||
@@ -1469,7 +1551,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onMenuClicked(handler: EventCallback<string>): Promise<UnlistenFn> {
|
||||
return this.listen<string>(TauriEvent.MENU, handler);
|
||||
@@ -1500,7 +1582,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onFileDropEvent(
|
||||
handler: EventCallback<FileDropEvent>
|
||||
@@ -1550,7 +1632,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async onThemeChanged(handler: EventCallback<Theme>): Promise<UnlistenFn> {
|
||||
return this.listen<Theme>(TauriEvent.WINDOW_THEME_CHANGED, handler);
|
||||
@@ -1558,7 +1640,7 @@ class WindowManager extends WebviewWindowHandle {
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class CloseRequestedEvent {
|
||||
/** Event name */
|
||||
@@ -1615,7 +1697,7 @@ class CloseRequestedEvent {
|
||||
* unlisten();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.2
|
||||
* @since 2.0.0
|
||||
*/
|
||||
class WebviewWindow extends WindowManager {
|
||||
/**
|
||||
@@ -1636,6 +1718,8 @@ class WebviewWindow extends WindowManager {
|
||||
*
|
||||
* * @param label The unique webview window label. Must be alphanumeric: `a-zA-Z-/:_`.
|
||||
* @returns The WebviewWindow instance to communicate with the webview.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
constructor(label: WindowLabel, options: WindowOptions = {}) {
|
||||
super(label);
|
||||
@@ -1663,6 +1747,8 @@ class WebviewWindow extends WindowManager {
|
||||
*
|
||||
* @param label The webview window label.
|
||||
* @returns The WebviewWindow instance to communicate with the webview or null if the webview doesn't exist.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static getByLabel(label: string): WebviewWindow | null {
|
||||
if (getAll().some((w) => w.label === label)) {
|
||||
@@ -1696,7 +1782,7 @@ if ("__TAURI_METADATA__" in window) {
|
||||
/**
|
||||
* Configuration for the window to create.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
interface WindowOptions {
|
||||
/**
|
||||
@@ -1762,7 +1848,7 @@ interface WindowOptions {
|
||||
* and on Windows 11, it will have a rounded corners.
|
||||
* - **Linux:** Unsupported.
|
||||
*
|
||||
* @since 2.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
shadow?: boolean;
|
||||
/**
|
||||
@@ -1830,7 +1916,7 @@ function mapPhysicalSize(m: PhysicalSize): PhysicalSize {
|
||||
* const monitor = currentMonitor();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function currentMonitor(): Promise<Monitor | null> {
|
||||
return window
|
||||
@@ -1847,7 +1933,7 @@ async function currentMonitor(): Promise<Monitor | null> {
|
||||
* const monitor = primaryMonitor();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function primaryMonitor(): Promise<Monitor | null> {
|
||||
return window
|
||||
@@ -1863,7 +1949,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
|
||||
* const monitors = availableMonitors();
|
||||
* ```
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function availableMonitors(): Promise<Monitor[]> {
|
||||
return window
|
||||
|
||||
Reference in New Issue
Block a user